MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / SetObjectControlType

Function SetObjectControlType

Descent3/object.cpp:3347–3393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3345}
3346
3347void SetObjectControlType(object *obj, int control_type) {
3348 ASSERT(obj);
3349 ASSERT(OBJNUM(obj) >= 0 && OBJNUM(obj) < MAX_OBJECTS);
3350
3351 if ((control_type == CT_AI) && (obj->ai_info == NULL)) {
3352 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
3353 polyobj_info *p_info = &obj->rtype.pobj_info;
3354 int num_wbs = pm->num_wbs;
3355 int count = 0;
3356 int i;
3357
3358 obj->ai_info = (ai_frame *)mem_malloc(sizeof(ai_frame));
3359 memset(obj->ai_info, 0x00, sizeof(ai_frame)); // DAJ clear the baby
3360
3361 for (i = 0; i < num_wbs; i++) {
3362 ASSERT(pm->poly_wb[i].num_turrets >= 0 && pm->poly_wb[i].num_turrets <= 6400);
3363 count += pm->poly_wb[i].num_turrets;
3364 }
3365
3366 p_info->multi_turret_info.num_turrets = count;
3367
3368 if ((count > 0) && (p_info->multi_turret_info.keyframes == NULL)) {
3369 int cur = 0;
3370
3371 p_info->multi_turret_info.time = 0;
3372 p_info->multi_turret_info.keyframes = (float *)mem_malloc(sizeof(float) * count);
3373 p_info->multi_turret_info.last_keyframes = (float *)mem_malloc(sizeof(float) * count);
3374 p_info->multi_turret_info.flags = 0;
3375 }
3376 }
3377
3378 obj->control_type = control_type;
3379
3380 if (obj->control_type == CT_AI || obj->type == OBJ_PLAYER) {
3381 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
3382 int num_wbs = pm->num_wbs;
3383
3384 if (obj->dynamic_wb == NULL) {
3385 if (obj->type == OBJ_PLAYER) {
3386 obj->dynamic_wb = (dynamic_wb_info *)mem_malloc(sizeof(dynamic_wb_info) * MAX_WBS_PER_OBJ);
3387 } else {
3388 if (num_wbs)
3389 obj->dynamic_wb = (dynamic_wb_info *)mem_malloc(sizeof(dynamic_wb_info) * num_wbs);
3390 }
3391 }
3392 }
3393}
3394
3395void ObjSetAnimUpdate(uint16_t objnum, custom_anim *multi_anim_info) {
3396 object *obj = &Objects[objnum];

Callers 15

EditorToGameFunction · 0.85
ObjInitPlayerFunction · 0.85
ObjInitGenericFunction · 0.85
ObjInitDebrisFunction · 0.85
ObjInitShardFunction · 0.85
ObjInitLineFunction · 0.85
ObjInitCameraFunction · 0.85
ObjInitSoundSourceFunction · 0.85
ObjInitWaypointFunction · 0.85
ObjInitViewerFunction · 0.85
ObjInitWeaponFunction · 0.85
ObjInitFireballFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected