From bdaa6be430ba4bf41b61a2637f0ea196262fb840 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 09:58:43 +0200 Subject: [PATCH 1/9] types: use consistent name for object ids --- src/game/carrier.c | 14 +++-- src/game/collide.c | 4 +- src/game/console_cmd.c | 21 ++++---- src/game/creature.c | 19 ++++--- src/game/effect_routines/bubbles.c | 2 +- src/game/effect_routines/lara_effects.c | 2 +- src/game/effects.c | 4 +- src/game/effects/blood.c | 2 +- src/game/effects/exploding_death.c | 10 ++-- src/game/effects/gun.c | 4 +- src/game/effects/gunshot.c | 2 +- src/game/gameflow.c | 36 ++++++------- src/game/gun/gun_misc.c | 4 +- src/game/inject.c | 17 +++--- src/game/interpolation.c | 4 +- src/game/inventory/inventory_func.c | 14 ++--- src/game/inventory/inventory_ring.c | 15 +++--- src/game/inventory/inventory_vars.c | 58 ++++++++++---------- src/game/items.c | 31 ++++++----- src/game/items.h | 7 +-- src/game/lara.h | 2 +- src/game/lara/lara.c | 12 ++--- src/game/lara/lara_cheat.c | 6 +-- src/game/lara/lara_control.c | 2 +- src/game/lara/lara_draw.c | 4 +- src/game/lara/lara_state.c | 2 +- src/game/level.c | 21 ++++---- src/game/lot.c | 2 +- src/game/objects/common.c | 16 +++--- src/game/objects/creatures/bacon_lara.c | 2 +- src/game/objects/creatures/bat.c | 2 +- src/game/objects/creatures/lion.c | 2 +- src/game/objects/creatures/mutant.c | 4 +- src/game/objects/creatures/natla.c | 4 +- src/game/objects/creatures/pod.c | 14 ++--- src/game/objects/creatures/rat.c | 2 +- src/game/objects/creatures/skate_kid.c | 6 +-- src/game/objects/creatures/statue.c | 2 +- src/game/objects/effects/blood.c | 2 +- src/game/objects/effects/body_part.c | 4 +- src/game/objects/effects/explosion.c | 2 +- src/game/objects/effects/missile.c | 12 ++--- src/game/objects/effects/ricochet.c | 2 +- src/game/objects/effects/splash.c | 4 +- src/game/objects/effects/twinkle.c | 4 +- src/game/objects/effects/waterfall.c | 2 +- src/game/objects/general/keyhole.c | 2 +- src/game/objects/general/pickup.c | 11 ++-- src/game/objects/general/puzzle_hole.c | 12 ++--- src/game/objects/general/save_crystal.c | 2 +- src/game/objects/general/scion.c | 10 ++-- src/game/objects/general/switch.c | 4 +- src/game/objects/names.c | 25 ++++----- src/game/objects/names.h | 2 +- src/game/objects/traps/dart.c | 8 +-- src/game/objects/traps/flame.c | 4 +- src/game/objects/traps/lava.c | 4 +- src/game/objects/traps/lightning_emitter.c | 2 +- src/game/objects/traps/midas_touch.c | 2 +- src/game/objects/traps/movable_block.c | 4 +- src/game/objects/traps/thors_hammer.c | 4 +- src/game/option/option.c | 4 +- src/game/overlay.c | 12 ++--- src/game/overlay.h | 2 +- src/game/phase/phase_cutscene.c | 2 +- src/game/phase/phase_inventory.c | 34 ++++++------ src/game/room.c | 14 ++--- src/game/room_draw.c | 2 +- src/game/savegame/savegame.c | 16 +++--- src/game/savegame/savegame_bson.c | 62 +++++++++++----------- src/game/savegame/savegame_legacy.c | 17 +++--- src/game/stats.c | 22 ++++---- src/global/types.h | 6 +-- 73 files changed, 345 insertions(+), 351 deletions(-) diff --git a/src/game/carrier.c b/src/game/carrier.c index f7fd77b06..79576942c 100644 --- a/src/game/carrier.c +++ b/src/game/carrier.c @@ -56,10 +56,10 @@ void Carrier_InitialiseLevel(int32_t level_num) continue; } - if (!Object_IsObjectType(item->object_number, g_EnemyObjects)) { + if (!Object_IsObjectType(item->object_id, g_EnemyObjects)) { LOG_WARNING( "Item %d of type %d cannot carry items", data->enemy_num, - item->object_number); + item->object_id); continue; } @@ -101,12 +101,12 @@ static ITEM_INFO *Carrier_GetCarrier(int16_t item_num) // Allow carried items to be allocated to holder objects (pods/statues), // but then have those items dropped by the actual creatures within. ITEM_INFO *item = &g_Items[item_num]; - if (Object_IsObjectType(item->object_number, g_PlaceholderObjects)) { + if (Object_IsObjectType(item->object_id, g_PlaceholderObjects)) { int16_t child_item_num = *(int16_t *)item->data; item = &g_Items[child_item_num]; } - if (!g_Objects[item->object_number].loaded) { + if (!g_Objects[item->object_id].loaded) { return NULL; } @@ -151,8 +151,7 @@ void Carrier_TestItemDrops(int16_t item_num) ITEM_INFO *carrier = &g_Items[item_num]; CARRIED_ITEM *item = carrier->carried_item; if (carrier->hit_points > 0 || !item - || (carrier->object_number == O_PIERRE - && !(carrier->flags & IF_ONESHOT))) { + || (carrier->object_id == O_PIERRE && !(carrier->flags & IF_ONESHOT))) { return; } @@ -199,8 +198,7 @@ void Carrier_TestLegacyDrops(int16_t item_num) // the OG enemy will still spawn items if Lara hasn't yet collected // them by using a test cognate in each case. Ensure also that // collected items do not re-spawn now or in future saves. - GAME_OBJECT_ID test_id = - Object_GetCognate(carrier->object_number, m_LegacyMap); + GAME_OBJECT_ID test_id = Object_GetCognate(carrier->object_id, m_LegacyMap); if (test_id == NO_OBJECT) { return; } diff --git a/src/game/collide.c b/src/game/collide.c index 9c5185356..acb4e8ecd 100644 --- a/src/game/collide.c +++ b/src/game/collide.c @@ -504,7 +504,7 @@ int32_t Collide_GetSpheres(ITEM_INFO *item, SPHERE *ptr, int32_t world_space) int32_t *packed_rotation = frame->mesh_rots; Matrix_RotYXZpack(*packed_rotation++); - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; int16_t **meshpp = &g_Meshes[object->mesh_index]; int32_t *bone = &g_AnimBones[object->bone_index]; @@ -596,7 +596,7 @@ int32_t Collide_TestCollision(ITEM_INFO *item, ITEM_INFO *lara_item) void Collide_GetJointAbsPosition(ITEM_INFO *item, XYZ_32 *vec, int32_t joint) { - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; Matrix_PushUnit(); Matrix_RotYXZ(item->rot.y, item->rot.x, item->rot.z); diff --git a/src/game/console_cmd.c b/src/game/console_cmd.c index 3f2ad383e..bcc100121 100644 --- a/src/game/console_cmd.c +++ b/src/game/console_cmd.c @@ -182,7 +182,7 @@ static COMMAND_RESULT Console_Cmd_Teleport(const char *const args) item_num++) { const ITEM_INFO *const item = &g_Items[item_num]; const bool is_pickup = - Object_IsObjectType(item->object_number, g_PickupObjects); + Object_IsObjectType(item->object_id, g_PickupObjects); if (is_pickup && (item->status == IS_INVISIBLE || item->status == IS_DEACTIVATED)) { @@ -195,7 +195,7 @@ static COMMAND_RESULT Console_Cmd_Teleport(const char *const args) bool is_matched = false; for (int32_t i = 0; i < match_count; i++) { - if (matching_objs[i] == item->object_number) { + if (matching_objs[i] == item->object_id) { is_matched = true; break; } @@ -556,12 +556,13 @@ static COMMAND_RESULT Console_Cmd_GiveItem(const char *args) int32_t match_count = 0; GAME_OBJECT_ID *matching_objs = Object_IdsFromName(args, &match_count); for (int32_t i = 0; i < match_count; i++) { - const GAME_OBJECT_ID obj_id = matching_objs[i]; - if (Object_IsObjectType(obj_id, g_PickupObjects)) { - if (g_Objects[obj_id].loaded) { - Inv_AddItemNTimes(obj_id, num); + const GAME_OBJECT_ID object_id = matching_objs[i]; + if (Object_IsObjectType(object_id, g_PickupObjects)) { + if (g_Objects[object_id].loaded) { + Inv_AddItemNTimes(object_id, num); Console_Log( - GS(OSD_GIVE_ITEM), Object_GetCanonicalName(obj_id, args)); + GS(OSD_GIVE_ITEM), + Object_GetCanonicalName(object_id, args)); found = true; } } @@ -665,12 +666,12 @@ static COMMAND_RESULT Console_Cmd_Kill(const char *args) bool matched = false; int32_t num = 0; for (int32_t i = 0; i < match_count; i++) { - const GAME_OBJECT_ID obj_id = matching_objs[i]; - if (Object_IsObjectType(obj_id, g_EnemyObjects)) { + const GAME_OBJECT_ID object_id = matching_objs[i]; + if (Object_IsObjectType(object_id, g_EnemyObjects)) { matched = true; for (int16_t item_num = 0; item_num < Item_GetTotalCount(); item_num++) { - if (g_Items[item_num].object_number == obj_id + if (g_Items[item_num].object_id == object_id && Lara_Cheat_KillEnemy(item_num)) { num++; } diff --git a/src/game/creature.c b/src/game/creature.c index 2dab826fb..32e8199d7 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -70,7 +70,7 @@ void Creature_AIInfo(ITEM_INFO *item, AI_INFO *info) info->enemy_zone |= BLOCKED; } - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; int32_t z = g_LaraItem->pos.z - ((Math_Cos(item->rot.y) * object->pivot_length) >> W2V_SHIFT) - item->pos.z; @@ -185,7 +185,7 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) switch (creature->mood) { case MOOD_ATTACK: - if (Random_GetControl() < g_Objects[item->object_number].smartness) { + if (Random_GetControl() < g_Objects[item->object_id].smartness) { LOT->target.x = g_LaraItem->pos.x; LOT->target.y = g_LaraItem->pos.y; LOT->target.z = g_LaraItem->pos.z; @@ -348,7 +348,7 @@ bool Creature_CheckBaddieOverlap(int16_t item_num) int32_t x = item->pos.x; int32_t y = item->pos.y; int32_t z = item->pos.z; - int32_t radius = SQUARE(g_Objects[item->object_number].radius); + int32_t radius = SQUARE(g_Objects[item->object_id].radius); int16_t link = g_RoomInfo[item->room_number].item_number; do { @@ -485,7 +485,7 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt) shift_x = 0; shift_z = 0; - int32_t radius = g_Objects[item->object_number].radius; + int32_t radius = g_Objects[item->object_id].radius; if (pos_z < radius) { if (Box_BadFloor( @@ -612,8 +612,7 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt) int32_t ceiling = Room_GetCeiling(sector, item->pos.x, y, item->pos.z); - int32_t min_y = - item->object_number == O_ALLIGATOR ? 0 : bounds->min.y; + int32_t min_y = item->object_id == O_ALLIGATOR ? 0 : bounds->min.y; if (item->pos.y + min_y + dy < ceiling) { if (item->pos.y + min_y < ceiling) { item->pos.x = old.x; @@ -722,7 +721,7 @@ bool Creature_EnsureHabitat( *wh = Room_GetWaterHeight( item->pos.x, item->pos.y, item->pos.z, item->room_number); - return item->object_number == info->land.id + return item->object_id == info->land.id ? Creature_SwitchToWater(item_num, wh, info) : Creature_SwitchToLand(item_num, wh, info); } @@ -730,7 +729,7 @@ bool Creature_EnsureHabitat( bool Creature_IsBoss(const int16_t item_num) { const ITEM_INFO *const item = &g_Items[item_num]; - return Object_IsObjectType(item->object_number, g_BossObjects); + return Object_IsObjectType(item->object_id, g_BossObjects); } static bool Creature_SwitchToWater( @@ -749,7 +748,7 @@ static bool Creature_SwitchToWater( // The land creature is alive and the room has been flooded. Switch to the // water creature. - item->object_number = info->water.id; + item->object_id = info->water.id; Item_SwitchToAnim(item, info->water.active_anim, 0); item->current_anim_state = g_Anims[item->anim_number].current_anim_state; item->goal_anim_state = item->current_anim_state; @@ -768,7 +767,7 @@ static bool Creature_SwitchToLand( ITEM_INFO *item = &g_Items[item_num]; // Switch to the land creature regardless of death state. - item->object_number = info->land.id; + item->object_id = info->land.id; item->rot.x = 0; if (item->hit_points > 0) { diff --git a/src/game/effect_routines/bubbles.c b/src/game/effect_routines/bubbles.c index d38acd488..9685480f1 100644 --- a/src/game/effect_routines/bubbles.c +++ b/src/game/effect_routines/bubbles.c @@ -38,7 +38,7 @@ void FX_Bubbles(ITEM_INFO *item) fx->pos.x = offset.x; fx->pos.y = offset.y; fx->pos.z = offset.z; - fx->object_number = O_BUBBLES1; + fx->object_id = O_BUBBLES1; fx->frame_number = -((Random_GetDraw() * 3) / 0x8000); fx->speed = 10 + ((Random_GetDraw() * 6) / 0x8000); } diff --git a/src/game/effect_routines/lara_effects.c b/src/game/effect_routines/lara_effects.c index db3cec69d..500cbfee8 100644 --- a/src/game/effect_routines/lara_effects.c +++ b/src/game/effect_routines/lara_effects.c @@ -25,7 +25,7 @@ void FX_LaraHandsFree(ITEM_INFO *item) void FX_LaraDrawRightGun(ITEM_INFO *item) { int16_t *tmp_mesh; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; OBJECT_INFO *obj2 = &g_Objects[O_PISTOL_ANIM]; SWAP( diff --git a/src/game/effects.c b/src/game/effects.c index 988b6e262..4b44fb4eb 100644 --- a/src/game/effects.c +++ b/src/game/effects.c @@ -31,7 +31,7 @@ void Effect_Control(void) int16_t fx_num = g_NextFxActive; while (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; - OBJECT_INFO *obj = &g_Objects[fx->object_number]; + OBJECT_INFO *obj = &g_Objects[fx->object_id]; if (obj->control) { obj->control(fx_num); } @@ -122,7 +122,7 @@ void Effect_NewRoom(int16_t fx_num, int16_t room_num) void Effect_Draw(const int16_t fxnum) { const FX_INFO *const fx = &g_Effects[fxnum]; - const OBJECT_INFO *const object = &g_Objects[fx->object_number]; + const OBJECT_INFO *const object = &g_Objects[fx->object_id]; if (!object->loaded) { return; } diff --git a/src/game/effects/blood.c b/src/game/effects/blood.c index efa1a8736..86a388501 100644 --- a/src/game/effects/blood.c +++ b/src/game/effects/blood.c @@ -15,7 +15,7 @@ int16_t Effect_Blood( fx->pos.y = y; fx->pos.z = z; fx->rot.y = direction; - fx->object_number = O_BLOOD1; + fx->object_id = O_BLOOD1; fx->frame_number = 0; fx->counter = 0; fx->speed = speed; diff --git a/src/game/effects/exploding_death.c b/src/game/effects/exploding_death.c index 33dd37c26..00d3001b3 100644 --- a/src/game/effects/exploding_death.c +++ b/src/game/effects/exploding_death.c @@ -12,7 +12,7 @@ int32_t Effect_ExplodingDeath( int16_t item_num, int32_t mesh_bits, int16_t damage) { ITEM_INFO *item = &g_Items[item_num]; - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; const FRAME_INFO *const frame = Item_GetBestFrame(item); @@ -40,7 +40,7 @@ int32_t Effect_ExplodingDeath( fx->pos.y = (g_MatrixPtr->_13 >> W2V_SHIFT) + item->pos.y; fx->pos.z = (g_MatrixPtr->_23 >> W2V_SHIFT) + item->pos.z; fx->rot.y = (Random_GetControl() - 0x4000) * 2; - if (item->object_number == O_TORSO) { + if (item->object_id == O_TORSO) { fx->speed = Random_GetControl() >> 7; fx->fall_speed = -Random_GetControl() >> 7; } else { @@ -49,7 +49,7 @@ int32_t Effect_ExplodingDeath( } fx->counter = damage; fx->frame_number = object->mesh_index; - fx->object_number = O_BODY_PART; + fx->object_id = O_BODY_PART; } item->mesh_bits -= bit; } @@ -92,7 +92,7 @@ int32_t Effect_ExplodingDeath( fx->pos.y = (g_MatrixPtr->_13 >> W2V_SHIFT) + item->pos.y; fx->pos.z = (g_MatrixPtr->_23 >> W2V_SHIFT) + item->pos.z; fx->rot.y = (Random_GetControl() - 0x4000) * 2; - if (item->object_number == O_TORSO) { + if (item->object_id == O_TORSO) { fx->speed = Random_GetControl() >> 7; fx->fall_speed = -Random_GetControl() >> 7; } else { @@ -100,7 +100,7 @@ int32_t Effect_ExplodingDeath( fx->fall_speed = -Random_GetControl() >> 8; } fx->counter = damage; - fx->object_number = O_BODY_PART; + fx->object_id = O_BODY_PART; fx->frame_number = object->mesh_index + i; } item->mesh_bits -= bit; diff --git a/src/game/effects/gun.c b/src/game/effects/gun.c index 6f68cf2e3..e27c5614e 100644 --- a/src/game/effects/gun.c +++ b/src/game/effects/gun.c @@ -44,7 +44,7 @@ int16_t Effect_ShardGun( fx->rot.x = 0; fx->rot.y = y_rot; fx->rot.z = 0; - fx->object_number = O_MISSILE2; + fx->object_id = O_MISSILE2; fx->frame_number = 0; fx->speed = SHARD_SPEED; fx->shade = 3584; @@ -67,7 +67,7 @@ int16_t Effect_RocketGun( fx->rot.x = 0; fx->rot.y = y_rot; fx->rot.z = 0; - fx->object_number = O_MISSILE3; + fx->object_id = O_MISSILE3; fx->frame_number = 0; fx->speed = ROCKET_SPEED; fx->shade = 4096; diff --git a/src/game/effects/gunshot.c b/src/game/effects/gunshot.c index 1f9dc469c..034bde10a 100644 --- a/src/game/effects/gunshot.c +++ b/src/game/effects/gunshot.c @@ -25,7 +25,7 @@ int16_t Effect_GunShot( fx->rot.z = 0; fx->counter = 3; fx->frame_number = 0; - fx->object_number = O_GUN_FLASH; + fx->object_id = O_GUN_FLASH; fx->shade = 4096; } return fx_num; diff --git a/src/game/gameflow.c b/src/game/gameflow.c index 55d9e0448..44bb1312b 100644 --- a/src/game/gameflow.c +++ b/src/game/gameflow.c @@ -34,13 +34,13 @@ typedef struct GAMEFLOW_DISPLAY_PICTURE_DATA { } GAMEFLOW_DISPLAY_PICTURE_DATA; typedef struct GAMEFLOW_MESH_SWAP_DATA { - GAME_OBJECT_ID object1_num; - GAME_OBJECT_ID object2_num; + GAME_OBJECT_ID object1_id; + GAME_OBJECT_ID object2_id; int32_t mesh_num; } GAMEFLOW_MESH_SWAP_DATA; typedef struct GAMEFLOW_GIVE_ITEM_DATA { - GAME_OBJECT_ID object_num; + GAME_OBJECT_ID object_id; int quantity; } GAMEFLOW_GIVE_ITEM_DATA; @@ -422,9 +422,9 @@ static bool GameFlow_LoadLevelSequence( GAMEFLOW_GIVE_ITEM_DATA *give_item_data = Memory_Alloc(sizeof(GAMEFLOW_GIVE_ITEM_DATA)); - give_item_data->object_num = + give_item_data->object_id = json_object_get_int(jseq_obj, "object_id", JSON_INVALID_NUMBER); - if (give_item_data->object_num == JSON_INVALID_NUMBER) { + if (give_item_data->object_id == JSON_INVALID_NUMBER) { LOG_ERROR( "level %d, sequence %s: 'object_id' must be a number", level_num, type_str); @@ -455,18 +455,18 @@ static bool GameFlow_LoadLevelSequence( GAMEFLOW_MESH_SWAP_DATA *swap_data = Memory_Alloc(sizeof(GAMEFLOW_MESH_SWAP_DATA)); - swap_data->object1_num = json_object_get_int( + swap_data->object1_id = json_object_get_int( jseq_obj, "object1_id", JSON_INVALID_NUMBER); - if (swap_data->object1_num == JSON_INVALID_NUMBER) { + if (swap_data->object1_id == JSON_INVALID_NUMBER) { LOG_ERROR( "level %d, sequence %s: 'object1_id' must be a number", level_num, type_str); return false; } - swap_data->object2_num = json_object_get_int( + swap_data->object2_id = json_object_get_int( jseq_obj, "object2_id", JSON_INVALID_NUMBER); - if (swap_data->object2_num == JSON_INVALID_NUMBER) { + if (swap_data->object2_id == JSON_INVALID_NUMBER) { LOG_ERROR( "level %d, sequence %s: 'object2_id' must be a number", level_num, type_str); @@ -1273,7 +1273,7 @@ GameFlow_InterpretSequence(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type) const GAMEFLOW_GIVE_ITEM_DATA *give_item_data = (const GAMEFLOW_GIVE_ITEM_DATA *)seq->data; Inv_AddItemNTimes( - give_item_data->object_num, give_item_data->quantity); + give_item_data->object_id, give_item_data->quantity); } break; @@ -1308,15 +1308,15 @@ GameFlow_InterpretSequence(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type) int16_t *temp; temp = g_Meshes - [g_Objects[swap_data->object1_num].mesh_index + [g_Objects[swap_data->object1_id].mesh_index + swap_data->mesh_num]; g_Meshes - [g_Objects[swap_data->object1_num].mesh_index + [g_Objects[swap_data->object1_id].mesh_index + swap_data->mesh_num] = g_Meshes - [g_Objects[swap_data->object2_num].mesh_index + [g_Objects[swap_data->object2_id].mesh_index + swap_data->mesh_num]; g_Meshes - [g_Objects[swap_data->object2_num].mesh_index + [g_Objects[swap_data->object2_id].mesh_index + swap_data->mesh_num] = temp; break; } @@ -1436,15 +1436,15 @@ GameFlow_StorySoFar(int32_t level_num, int32_t savegame_level) case GFS_MESH_SWAP: { GAMEFLOW_MESH_SWAP_DATA *swap_data = seq->data; int16_t *temp = g_Meshes - [g_Objects[swap_data->object1_num].mesh_index + [g_Objects[swap_data->object1_id].mesh_index + swap_data->mesh_num]; g_Meshes - [g_Objects[swap_data->object1_num].mesh_index + [g_Objects[swap_data->object1_id].mesh_index + swap_data->mesh_num] = g_Meshes - [g_Objects[swap_data->object2_num].mesh_index + [g_Objects[swap_data->object2_id].mesh_index + swap_data->mesh_num]; g_Meshes - [g_Objects[swap_data->object2_num].mesh_index + [g_Objects[swap_data->object2_id].mesh_index + swap_data->mesh_num] = temp; break; } diff --git a/src/game/gun/gun_misc.c b/src/game/gun/gun_misc.c index 313fa56ac..9efff2d08 100644 --- a/src/game/gun/gun_misc.c +++ b/src/game/gun/gun_misc.c @@ -499,7 +499,7 @@ void Gun_HitTarget(ITEM_INFO *item, GAME_VECTOR *hitpos, int16_t damage) } Item_TakeDamage(item, damage, true); - if (g_Config.fix_texture_issues && item->object_number == O_SCION_ITEM3) { + if (g_Config.fix_texture_issues && item->object_id == O_SCION_ITEM3) { GAME_VECTOR pos; pos.x = hitpos->x; pos.y = hitpos->y; @@ -513,7 +513,7 @@ void Gun_HitTarget(ITEM_INFO *item, GAME_VECTOR *hitpos, int16_t damage) } if (item->hit_points > 0) { - switch (item->object_number) { + switch (item->object_id) { case O_WOLF: Sound_Effect(SFX_WOLF_HURT, &item->pos, SPM_NORMAL); break; diff --git a/src/game/inject.c b/src/game/inject.c index 3e08a13b2..3f69a43c8 100644 --- a/src/game/inject.c +++ b/src/game/inject.c @@ -503,18 +503,17 @@ static void Inject_TextureData( } for (int32_t i = 0; i < inj_info->sprite_count; i++) { - GAME_OBJECT_ID object_num; - object_num = File_ReadS32(fp); + const GAME_OBJECT_ID object_id = File_ReadS32(fp); const int16_t num_meshes = File_ReadS16(fp); const int16_t mesh_index = File_ReadS16(fp); - if (object_num < O_NUMBER_OF) { - OBJECT_INFO *object = &g_Objects[object_num]; + if (object_id < O_NUMBER_OF) { + OBJECT_INFO *object = &g_Objects[object_id]; object->nmeshes = num_meshes; object->mesh_index = mesh_index + level_info->sprite_info_count; object->loaded = 1; - } else if (object_num - O_NUMBER_OF < STATIC_NUMBER_OF) { - STATIC_INFO *object = &g_StaticObjects[object_num - O_NUMBER_OF]; + } else if (object_id - O_NUMBER_OF < STATIC_NUMBER_OF) { + STATIC_INFO *object = &g_StaticObjects[object_id - O_NUMBER_OF]; object->nmeshes = num_meshes; object->mesh_number = mesh_index + level_info->sprite_info_count; object->loaded = true; @@ -717,8 +716,8 @@ static void Inject_ObjectData( // TODO: consider refactoring once we have more injection // use cases. for (int32_t i = 0; i < inj_info->object_count; i++) { - const int32_t object_num = File_ReadS32(fp); - OBJECT_INFO *object = &g_Objects[object_num]; + const GAME_OBJECT_ID object_id = File_ReadS32(fp); + OBJECT_INFO *object = &g_Objects[object_id]; const int16_t num_meshes = File_ReadS16(fp); const int16_t mesh_index = File_ReadS16(fp); @@ -1296,7 +1295,7 @@ static void Inject_TriggeredItem(INJECTION *injection, LEVEL_INFO *level_info) int16_t item_number = Item_Create(); ITEM_INFO *item = &g_Items[item_number]; - item->object_number = File_ReadS16(fp); + item->object_id = File_ReadS16(fp); item->room_number = File_ReadS16(fp); item->pos.x = File_ReadS32(fp); item->pos.y = File_ReadS32(fp); diff --git a/src/game/interpolation.c b/src/game/interpolation.c index 83fbf2fad..820681427 100644 --- a/src/game/interpolation.c +++ b/src/game/interpolation.c @@ -108,7 +108,7 @@ void Interpolation_Commit(void) for (int i = 0; i < Item_GetTotalCount(); i++) { ITEM_INFO *const item = &g_Items[i]; if ((item->flags & IF_KILLED_ITEM) || item->status == IS_NOT_ACTIVE - || item->object_number == O_BAT) { + || item->object_id == O_BAT) { COMMIT(item, pos.x); COMMIT(item, pos.y); COMMIT(item, pos.z); @@ -118,7 +118,7 @@ void Interpolation_Commit(void) continue; } - const int32_t max_xz = item->object_number == O_DARTS ? 200 : 128; + const int32_t max_xz = item->object_id == O_DARTS ? 200 : 128; const int32_t max_y = MAX(128, item->fall_speed * 2); INTERPOLATE(item, pos.x, ratio, max_xz); INTERPOLATE(item, pos.y, ratio, max_y); diff --git a/src/game/inventory/inventory_func.c b/src/game/inventory/inventory_func.c index f268b8bc2..582e82044 100644 --- a/src/game/inventory/inventory_func.c +++ b/src/game/inventory/inventory_func.c @@ -28,7 +28,7 @@ bool Inv_AddItem(const GAME_OBJECT_ID object_id) for (int i = 0; i < g_InvMainObjects; i++) { INVENTORY_ITEM *inv_item = g_InvMainList[i]; - if (inv_item->object_number == inv_object_id) { + if (inv_item->object_id == inv_object_id) { g_InvMainQtys[i]++; return true; } @@ -36,7 +36,7 @@ bool Inv_AddItem(const GAME_OBJECT_ID object_id) for (int i = 0; i < g_InvKeysObjects; i++) { INVENTORY_ITEM *inv_item = g_InvKeysList[i]; - if (inv_item->object_number == inv_object_id) { + if (inv_item->object_id == inv_object_id) { g_InvKeysQtys[i]++; return true; } @@ -245,13 +245,13 @@ int32_t Inv_RequestItem(const GAME_OBJECT_ID object_id) const GAME_OBJECT_ID inv_object_id = Inv_GetItemOption(object_id); for (int i = 0; i < g_InvMainObjects; i++) { - if (g_InvMainList[i]->object_number == inv_object_id) { + if (g_InvMainList[i]->object_id == inv_object_id) { return g_InvMainQtys[i]; } } for (int i = 0; i < g_InvKeysObjects; i++) { - if (g_InvKeysList[i]->object_number == inv_object_id) { + if (g_InvKeysList[i]->object_id == inv_object_id) { return g_InvKeysQtys[i]; } } @@ -273,7 +273,7 @@ bool Inv_RemoveItem(const GAME_OBJECT_ID object_id) const GAME_OBJECT_ID inv_object_id = Inv_GetItemOption(object_id); for (int i = 0; i < g_InvMainObjects; i++) { - if (g_InvMainList[i]->object_number == inv_object_id) { + if (g_InvMainList[i]->object_id == inv_object_id) { g_InvMainQtys[i]--; if (g_InvMainQtys[i] > 0) { return true; @@ -287,7 +287,7 @@ bool Inv_RemoveItem(const GAME_OBJECT_ID object_id) } for (int i = 0; i < g_InvKeysObjects; i++) { - if (g_InvKeysList[i]->object_number == inv_object_id) { + if (g_InvKeysList[i]->object_id == inv_object_id) { g_InvKeysQtys[i]--; if (g_InvKeysQtys[i] > 0) { return true; @@ -302,7 +302,7 @@ bool Inv_RemoveItem(const GAME_OBJECT_ID object_id) } for (int i = 0; i < g_InvOptionObjects; i++) { - if (g_InvOptionList[i]->object_number == inv_object_id) { + if (g_InvOptionList[i]->object_id == inv_object_id) { g_InvOptionObjects--; for (int j = i; j < g_InvOptionObjects; j++) { g_InvOptionList[j] = g_InvOptionList[j + 1]; diff --git a/src/game/inventory/inventory_ring.c b/src/game/inventory/inventory_ring.c index a6ce842c8..5694a1bc4 100644 --- a/src/game/inventory/inventory_ring.c +++ b/src/game/inventory/inventory_ring.c @@ -163,17 +163,16 @@ void Inv_Ring_RemoveAllText(void) void Inv_Ring_Active(INVENTORY_ITEM *inv_item) { - if (!g_InvItemText[IT_NAME] - && inv_item->object_number != O_PASSPORT_OPTION) { + if (!g_InvItemText[IT_NAME] && inv_item->object_id != O_PASSPORT_OPTION) { g_InvItemText[IT_NAME] = Text_Create(0, -16, inv_item->string); Text_AlignBottom(g_InvItemText[IT_NAME], 1); Text_CentreH(g_InvItemText[IT_NAME], 1); } char temp_text[64]; - int32_t qty = Inv_RequestItem(inv_item->object_number); + int32_t qty = Inv_RequestItem(inv_item->object_id); - switch (inv_item->object_number) { + switch (inv_item->object_id) { case O_SHOTGUN_OPTION: if (!g_InvItemText[IT_QTY] && !(g_GameInfo.bonus_flag & GBF_NGPLUS)) { sprintf( @@ -282,8 +281,8 @@ void Inv_Ring_Active(INVENTORY_ITEM *inv_item) break; } - if (inv_item->object_number == O_MEDI_OPTION - || inv_item->object_number == O_BIGMEDI_OPTION) { + if (inv_item->object_id == O_MEDI_OPTION + || inv_item->object_id == O_BIGMEDI_OPTION) { if (g_Config.healthbar_location == BL_TOP_LEFT) { Text_Hide(m_InvUpArrow1, true); } else if (g_Config.healthbar_location == BL_TOP_RIGHT) { @@ -313,8 +312,8 @@ void Inv_Ring_ResetItem(INVENTORY_ITEM *const inv_item) inv_item->y_rot = 0; inv_item->ytrans = 0; inv_item->ztrans = 0; - if (inv_item->object_number == O_PASSPORT_OPTION) { - inv_item->object_number = O_PASSPORT_CLOSED; + if (inv_item->object_id == O_PASSPORT_OPTION) { + inv_item->object_id = O_PASSPORT_CLOSED; } } diff --git a/src/game/inventory/inventory_vars.c b/src/game/inventory/inventory_vars.c index 5dac4c007..421ad7ddb 100644 --- a/src/game/inventory/inventory_vars.c +++ b/src/game/inventory/inventory_vars.c @@ -77,7 +77,7 @@ INVENTORY_ITEM *g_InvOptionList[] = { INVENTORY_ITEM g_InvItemCompass = { .string = "Compass", - .object_number = O_MAP_OPTION, + .object_id = O_MAP_OPTION, .frames_total = 25, .current_frame = 0, .goal_frame = 0, @@ -101,7 +101,7 @@ INVENTORY_ITEM g_InvItemCompass = { INVENTORY_ITEM g_InvItemMedi = { .string = "Small Medi Pack", - .object_number = O_MEDI_OPTION, + .object_id = O_MEDI_OPTION, .frames_total = 26, .current_frame = 0, .goal_frame = 0, @@ -125,7 +125,7 @@ INVENTORY_ITEM g_InvItemMedi = { INVENTORY_ITEM g_InvItemBigMedi = { .string = "Large Medi Pack", - .object_number = O_BIGMEDI_OPTION, + .object_id = O_BIGMEDI_OPTION, .frames_total = 20, .current_frame = 0, .goal_frame = 0, @@ -149,7 +149,7 @@ INVENTORY_ITEM g_InvItemBigMedi = { INVENTORY_ITEM g_InvItemLeadBar = { .string = "Lead Bar", - .object_number = O_LEADBAR_OPTION, + .object_id = O_LEADBAR_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -173,7 +173,7 @@ INVENTORY_ITEM g_InvItemLeadBar = { INVENTORY_ITEM g_InvItemPickup1 = { .string = "Pickup", - .object_number = O_PICKUP_OPTION1, + .object_id = O_PICKUP_OPTION1, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -197,7 +197,7 @@ INVENTORY_ITEM g_InvItemPickup1 = { INVENTORY_ITEM g_InvItemPickup2 = { .string = "Pickup", - .object_number = O_PICKUP_OPTION2, + .object_id = O_PICKUP_OPTION2, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -221,7 +221,7 @@ INVENTORY_ITEM g_InvItemPickup2 = { INVENTORY_ITEM g_InvItemScion = { .string = "Scion", - .object_number = O_SCION_OPTION, + .object_id = O_SCION_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -245,7 +245,7 @@ INVENTORY_ITEM g_InvItemScion = { INVENTORY_ITEM g_InvItemPuzzle1 = { .string = "Puzzle", - .object_number = O_PUZZLE_OPTION1, + .object_id = O_PUZZLE_OPTION1, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -269,7 +269,7 @@ INVENTORY_ITEM g_InvItemPuzzle1 = { INVENTORY_ITEM g_InvItemPuzzle2 = { .string = "Puzzle", - .object_number = O_PUZZLE_OPTION2, + .object_id = O_PUZZLE_OPTION2, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -293,7 +293,7 @@ INVENTORY_ITEM g_InvItemPuzzle2 = { INVENTORY_ITEM g_InvItemPuzzle3 = { .string = "Puzzle", - .object_number = O_PUZZLE_OPTION3, + .object_id = O_PUZZLE_OPTION3, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -317,7 +317,7 @@ INVENTORY_ITEM g_InvItemPuzzle3 = { INVENTORY_ITEM g_InvItemPuzzle4 = { .string = "Puzzle", - .object_number = O_PUZZLE_OPTION4, + .object_id = O_PUZZLE_OPTION4, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -341,7 +341,7 @@ INVENTORY_ITEM g_InvItemPuzzle4 = { INVENTORY_ITEM g_InvItemKey1 = { .string = "Key", - .object_number = O_KEY_OPTION1, + .object_id = O_KEY_OPTION1, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -365,7 +365,7 @@ INVENTORY_ITEM g_InvItemKey1 = { INVENTORY_ITEM g_InvItemKey2 = { .string = "Key", - .object_number = O_KEY_OPTION2, + .object_id = O_KEY_OPTION2, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -389,7 +389,7 @@ INVENTORY_ITEM g_InvItemKey2 = { INVENTORY_ITEM g_InvItemKey3 = { .string = "Key", - .object_number = O_KEY_OPTION3, + .object_id = O_KEY_OPTION3, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -413,7 +413,7 @@ INVENTORY_ITEM g_InvItemKey3 = { INVENTORY_ITEM g_InvItemKey4 = { .string = "Key", - .object_number = O_KEY_OPTION4, + .object_id = O_KEY_OPTION4, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -437,7 +437,7 @@ INVENTORY_ITEM g_InvItemKey4 = { INVENTORY_ITEM g_InvItemPistols = { .string = "Pistols", - .object_number = O_PISTOL_OPTION, + .object_id = O_PISTOL_OPTION, .frames_total = 12, .current_frame = 0, .goal_frame = 0, @@ -461,7 +461,7 @@ INVENTORY_ITEM g_InvItemPistols = { INVENTORY_ITEM g_InvItemShotgun = { .string = "Shotgun", - .object_number = O_SHOTGUN_OPTION, + .object_id = O_SHOTGUN_OPTION, .frames_total = 13, .current_frame = 0, .goal_frame = 0, @@ -485,7 +485,7 @@ INVENTORY_ITEM g_InvItemShotgun = { INVENTORY_ITEM g_InvItemMagnum = { .string = "Magnums", - .object_number = O_MAGNUM_OPTION, + .object_id = O_MAGNUM_OPTION, .frames_total = 12, .current_frame = 0, .goal_frame = 0, @@ -509,7 +509,7 @@ INVENTORY_ITEM g_InvItemMagnum = { INVENTORY_ITEM g_InvItemUzi = { .string = "Uzis", - .object_number = O_UZI_OPTION, + .object_id = O_UZI_OPTION, .frames_total = 13, .current_frame = 0, .goal_frame = 0, @@ -533,7 +533,7 @@ INVENTORY_ITEM g_InvItemUzi = { INVENTORY_ITEM g_InvItemGrenade = { .string = "Grenade", - .object_number = O_EXPLOSIVE_OPTION, + .object_id = O_EXPLOSIVE_OPTION, .frames_total = 15, .current_frame = 0, .goal_frame = 0, @@ -557,7 +557,7 @@ INVENTORY_ITEM g_InvItemGrenade = { INVENTORY_ITEM g_InvItemPistolAmmo = { .string = "Pistol Clips", - .object_number = O_PISTOL_AMMO_OPTION, + .object_id = O_PISTOL_AMMO_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -581,7 +581,7 @@ INVENTORY_ITEM g_InvItemPistolAmmo = { INVENTORY_ITEM g_InvItemShotgunAmmo = { .string = "Shotgun Shells", - .object_number = O_SG_AMMO_OPTION, + .object_id = O_SG_AMMO_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -605,7 +605,7 @@ INVENTORY_ITEM g_InvItemShotgunAmmo = { INVENTORY_ITEM g_InvItemMagnumAmmo = { .string = "Magnum Clips", - .object_number = O_MAG_AMMO_OPTION, + .object_id = O_MAG_AMMO_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -629,7 +629,7 @@ INVENTORY_ITEM g_InvItemMagnumAmmo = { INVENTORY_ITEM g_InvItemUziAmmo = { .string = "Uzi Clips", - .object_number = O_UZI_AMMO_OPTION, + .object_id = O_UZI_AMMO_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -653,7 +653,7 @@ INVENTORY_ITEM g_InvItemUziAmmo = { INVENTORY_ITEM g_InvItemGame = { .string = "Game", - .object_number = O_PASSPORT_CLOSED, + .object_id = O_PASSPORT_CLOSED, .frames_total = 30, .current_frame = 0, .goal_frame = 0, @@ -677,7 +677,7 @@ INVENTORY_ITEM g_InvItemGame = { INVENTORY_ITEM g_InvItemDetails = { .string = "Detail Levels", - .object_number = O_DETAIL_OPTION, + .object_id = O_DETAIL_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -701,7 +701,7 @@ INVENTORY_ITEM g_InvItemDetails = { INVENTORY_ITEM g_InvItemSound = { .string = "Sound", - .object_number = O_SOUND_OPTION, + .object_id = O_SOUND_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -725,7 +725,7 @@ INVENTORY_ITEM g_InvItemSound = { INVENTORY_ITEM g_InvItemControls = { .string = "Controls", - .object_number = O_CONTROL_OPTION, + .object_id = O_CONTROL_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, @@ -749,7 +749,7 @@ INVENTORY_ITEM g_InvItemControls = { INVENTORY_ITEM g_InvItemLarasHome = { .string = "Lara's Home", - .object_number = O_PHOTO_OPTION, + .object_id = O_PHOTO_OPTION, .frames_total = 1, .current_frame = 0, .goal_frame = 0, diff --git a/src/game/items.c b/src/game/items.c index 5430caf10..3ba6f2ed3 100644 --- a/src/game/items.c +++ b/src/game/items.c @@ -59,7 +59,7 @@ void Item_Control(void) int16_t item_num = g_NextItemActive; while (item_num != NO_ITEM) { ITEM_INFO *item = &g_Items[item_num]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; if (obj->control) { obj->control(item_num); } @@ -107,7 +107,7 @@ int16_t Item_Create(void) void Item_Initialise(int16_t item_num) { ITEM_INFO *item = &g_Items[item_num]; - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; Item_SwitchToAnim(item, 0, 0); item->current_anim_state = g_Anims[item->anim_number].current_anim_state; @@ -210,7 +210,7 @@ void Item_AddActive(int16_t item_num) { ITEM_INFO *item = &g_Items[item_num]; - if (!g_Objects[item->object_number].control) { + if (!g_Objects[item->object_id].control) { item->status = IS_NOT_ACTIVE; return; } @@ -282,12 +282,12 @@ int16_t Item_GetWaterHeight(ITEM_INFO *item) return height; } -int16_t Item_Spawn(ITEM_INFO *item, int16_t object_num) +int16_t Item_Spawn(const ITEM_INFO *const item, const GAME_OBJECT_ID object_id) { int16_t spawn_num = Item_Create(); if (spawn_num != NO_ITEM) { ITEM_INFO *spawn = &g_Items[spawn_num]; - spawn->object_number = object_num; + spawn->object_id = object_id; spawn->room_number = item->room_number; spawn->pos = item->pos; spawn->rot = item->rot; @@ -298,15 +298,16 @@ int16_t Item_Spawn(ITEM_INFO *item, int16_t object_num) return spawn_num; } -int32_t Item_GlobalReplace(int32_t src_object_num, int32_t dst_object_num) +int32_t Item_GlobalReplace( + const GAME_OBJECT_ID src_object_id, const GAME_OBJECT_ID dst_object_id) { int32_t changed = 0; for (int i = 0; i < g_RoomCount; i++) { ROOM_INFO *r = &g_RoomInfo[i]; for (int16_t item_num = r->item_number; item_num != NO_ITEM; item_num = g_Items[item_num].next_item) { - if (g_Items[item_num].object_number == src_object_num) { - g_Items[item_num].object_number = dst_object_num; + if (g_Items[item_num].object_id == src_object_id) { + g_Items[item_num].object_id = dst_object_id; changed++; } } @@ -550,19 +551,19 @@ void Item_Translate(ITEM_INFO *item, int32_t x, int32_t y, int32_t z) bool Item_TestAnimEqual(ITEM_INFO *item, int16_t anim_index) { return item->anim_number - == g_Objects[item->object_number].anim_index + anim_index; + == g_Objects[item->object_id].anim_index + anim_index; } void Item_SwitchToAnim(ITEM_INFO *item, int16_t anim_index, int16_t frame) { - Item_SwitchToObjAnim(item, anim_index, frame, item->object_number); + Item_SwitchToObjAnim(item, anim_index, frame, item->object_id); } void Item_SwitchToObjAnim( ITEM_INFO *item, int16_t anim_index, int16_t frame, - GAME_OBJECT_ID object_number) + GAME_OBJECT_ID object_id) { - item->anim_number = g_Objects[object_number].anim_index + anim_index; + item->anim_number = g_Objects[object_id].anim_index + anim_index; if (frame < 0) { item->frame_number = g_Anims[item->anim_number].frame_end + frame + 1; } else { @@ -808,10 +809,8 @@ int32_t Item_GetFrames( } // interpolated - if ((item != g_LaraItem && !item->active) - || (item->object_number == O_STATUE) - || (item->object_number == O_ROLLING_BALL - && item->status != IS_ACTIVE)) { + if ((item != g_LaraItem && !item->active) || (item->object_id == O_STATUE) + || (item->object_id == O_ROLLING_BALL && item->status != IS_ACTIVE)) { *rate = denominator; return numerator; } diff --git a/src/game/items.h b/src/game/items.h index c0a9e7ea0..6c3060074 100644 --- a/src/game/items.h +++ b/src/game/items.h @@ -21,8 +21,9 @@ void Item_NewRoom(int16_t item_num, int16_t room_num); void Item_UpdateRoom(ITEM_INFO *item, int32_t height); int16_t Item_GetHeight(ITEM_INFO *item); int16_t Item_GetWaterHeight(ITEM_INFO *item); -int16_t Item_Spawn(ITEM_INFO *item, int16_t object_num); -int32_t Item_GlobalReplace(int32_t src_object_num, int32_t dst_object_num); +int16_t Item_Spawn(const ITEM_INFO *item, GAME_OBJECT_ID object_id); +int32_t Item_GlobalReplace( + GAME_OBJECT_ID src_object_id, GAME_OBJECT_ID dst_object_id); bool Item_IsNearItem( const ITEM_INFO *item, const XYZ_32 *pos, int32_t distance); @@ -44,7 +45,7 @@ bool Item_TestAnimEqual(ITEM_INFO *item, int16_t anim_index); void Item_SwitchToAnim(ITEM_INFO *item, int16_t anim_index, int16_t frame); void Item_SwitchToObjAnim( ITEM_INFO *item, int16_t anim_index, int16_t frame, - GAME_OBJECT_ID object_number); + GAME_OBJECT_ID object_id); void Item_Animate(ITEM_INFO *item); bool Item_GetAnimChange(ITEM_INFO *item, ANIM_STRUCT *anim); void Item_PlayAnimSFX(ITEM_INFO *item, int16_t *command, uint16_t flags); diff --git a/src/game/lara.h b/src/game/lara.h index ba00d7c93..eff7d1b2f 100644 --- a/src/game/lara.h +++ b/src/game/lara.h @@ -21,7 +21,7 @@ void Lara_InitialiseMeshes(int32_t level_num); void Lara_SwapMeshExtra(void); void Lara_SwapSingleMesh(LARA_MESH mesh, GAME_OBJECT_ID); bool Lara_IsNearItem(const XYZ_32 *pos, int32_t distance); -void Lara_UseItem(GAME_OBJECT_ID object_num); +void Lara_UseItem(GAME_OBJECT_ID object_id); int16_t Lara_GetNearestEnemy(void); bool Lara_TestBoundsCollide(ITEM_INFO *item, int32_t radius); diff --git a/src/game/lara/lara.c b/src/game/lara/lara.c index 8195e729f..897d72c13 100644 --- a/src/game/lara/lara.c +++ b/src/game/lara/lara.c @@ -329,10 +329,10 @@ void Lara_AnimateUntil(ITEM_INFO *lara_item, int32_t goal) } while (lara_item->current_anim_state != goal); } -void Lara_UseItem(GAME_OBJECT_ID object_num) +void Lara_UseItem(GAME_OBJECT_ID object_id) { - LOG_INFO("%d", object_num); - switch (object_num) { + LOG_INFO("%d", object_id); + switch (object_id) { case O_PISTOL_ITEM: case O_PISTOL_OPTION: g_Lara.request_gun_type = LGT_PISTOLS; @@ -415,7 +415,7 @@ void Lara_UseItem(GAME_OBJECT_ID object_num) case O_SCION_ITEM3: case O_SCION_ITEM4: case O_SCION_OPTION: { - int16_t receptacle_item_number = Object_FindReceptacle(object_num); + int16_t receptacle_item_number = Object_FindReceptacle(object_id); if (receptacle_item_number == NO_OBJECT) { Sound_Effect(SFX_LARA_NO, NULL, SPM_NORMAL); return; @@ -423,7 +423,7 @@ void Lara_UseItem(GAME_OBJECT_ID object_num) g_Lara.interact_target.item_num = receptacle_item_number; g_Lara.interact_target.is_moving = true; g_Lara.interact_target.move_count = 0; - Inv_RemoveItem(object_num); + Inv_RemoveItem(object_id); break; } @@ -670,7 +670,7 @@ int16_t Lara_GetNearestEnemy(void) while (item_num != NO_ITEM) { ITEM_INFO *item = &g_Items[item_num]; - if (Object_IsObjectType(item->object_number, g_EnemyObjects)) { + if (Object_IsObjectType(item->object_id, g_EnemyObjects)) { const int32_t distance = Item_GetDistance(item, &g_LaraItem->pos); if (best_item_num == NO_ITEM || distance < best_distance) { best_item_num = item_num; diff --git a/src/game/lara/lara_cheat.c b/src/game/lara/lara_cheat.c index f6402dcda..7081f1e00 100644 --- a/src/game/lara/lara_cheat.c +++ b/src/game/lara/lara_cheat.c @@ -319,8 +319,8 @@ bool Lara_Cheat_OpenNearestDoor(void) const int32_t max_dist = SQUARE((WALL_L * 2) >> shift); for (int item_num = 0; item_num < g_LevelItemCount; item_num++) { ITEM_INFO *const item = &g_Items[item_num]; - if (!Object_IsObjectType(item->object_number, g_DoorObjects) - && !Object_IsObjectType(item->object_number, g_TrapdoorObjects)) { + if (!Object_IsObjectType(item->object_id, g_DoorObjects) + && !Object_IsObjectType(item->object_id, g_TrapdoorObjects)) { continue; } @@ -358,7 +358,7 @@ bool Lara_Cheat_OpenNearestDoor(void) bool Lara_Cheat_KillEnemy(const int16_t item_num) { ITEM_INFO *const item = &g_Items[item_num]; - if (!Object_IsObjectType(item->object_number, g_EnemyObjects) + if (!Object_IsObjectType(item->object_id, g_EnemyObjects) || item->hit_points <= 0) { return false; } diff --git a/src/game/lara/lara_control.c b/src/game/lara/lara_control.c index e18efe048..2b954ab84 100644 --- a/src/game/lara/lara_control.c +++ b/src/game/lara/lara_control.c @@ -137,7 +137,7 @@ static void Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll) while (item_num != NO_ITEM) { ITEM_INFO *item = &g_Items[item_num]; if (item->collidable && item->status != IS_INVISIBLE) { - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; if (object->collision) { int32_t x = lara_item->pos.x - item->pos.x; int32_t y = lara_item->pos.y - item->pos.y; diff --git a/src/game/lara/lara_draw.c b/src/game/lara/lara_draw.c index 711fc8c51..e88b5f217 100644 --- a/src/game/lara/lara_draw.c +++ b/src/game/lara/lara_draw.c @@ -38,7 +38,7 @@ void Lara_Draw(ITEM_INFO *item) } } - object = &g_Objects[item->object_number]; + object = &g_Objects[item->object_id]; if (g_Lara.hit_direction >= 0) { switch (g_Lara.hit_direction) { default: @@ -333,7 +333,7 @@ void Lara_Draw_I( { MATRIX saved_matrix; - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; const BOUNDS_16 *const bounds = Item_GetBoundsAccurate(item); saved_matrix = *g_MatrixPtr; diff --git a/src/game/lara/lara_state.c b/src/game/lara/lara_state.c index c2f2f2e18..2951eaeae 100644 --- a/src/game/lara/lara_state.c +++ b/src/game/lara/lara_state.c @@ -124,7 +124,7 @@ void Lara_State_Run(ITEM_INFO *item, COLL_INFO *coll) if (g_Config.enable_tr2_jumping) { int16_t anim = - item->anim_number - g_Objects[item->object_number].anim_index; + item->anim_number - g_Objects[item->object_id].anim_index; if (anim == LA_RUN_START) { m_JumpPermitted = false; } else if ( diff --git a/src/game/level.c b/src/game/level.c index 0f950f197..ecaa59b8b 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -484,8 +484,8 @@ static void Level_LoadObjects(VFILE *file) m_LevelInfo.object_count = VFile_ReadS32(file); LOG_INFO("%d objects", m_LevelInfo.object_count); for (int i = 0; i < m_LevelInfo.object_count; i++) { - const int32_t object_num = VFile_ReadS32(file); - OBJECT_INFO *object = &g_Objects[object_num]; + const GAME_OBJECT_ID object_id = VFile_ReadS32(file); + OBJECT_INFO *object = &g_Objects[object_id]; object->nmeshes = VFile_ReadS16(file); object->mesh_index = VFile_ReadS16(file); @@ -580,18 +580,17 @@ static void Level_LoadSprites(VFILE *file) m_LevelInfo.sprite_count = VFile_ReadS32(file); for (int i = 0; i < m_LevelInfo.sprite_count; i++) { - GAME_OBJECT_ID object_num; - object_num = VFile_ReadS32(file); + const GAME_OBJECT_ID object_id = VFile_ReadS32(file); const int16_t num_meshes = VFile_ReadS16(file); const int16_t mesh_index = VFile_ReadS16(file); - if (object_num < O_NUMBER_OF) { - OBJECT_INFO *object = &g_Objects[object_num]; + if (object_id < O_NUMBER_OF) { + OBJECT_INFO *object = &g_Objects[object_id]; object->nmeshes = num_meshes; object->mesh_index = mesh_index; object->loaded = 1; - } else if (object_num - O_NUMBER_OF < STATIC_NUMBER_OF) { - STATIC_INFO *object = &g_StaticObjects[object_num - O_NUMBER_OF]; + } else if (object_id - O_NUMBER_OF < STATIC_NUMBER_OF) { + STATIC_INFO *object = &g_StaticObjects[object_id - O_NUMBER_OF]; object->nmeshes = num_meshes; object->mesh_number = mesh_index; object->loaded = true; @@ -749,7 +748,7 @@ static void Level_LoadItems(VFILE *file) for (int i = 0; i < m_LevelInfo.item_count; i++) { ITEM_INFO *item = &g_Items[i]; - item->object_number = VFile_ReadS16(file); + item->object_id = VFile_ReadS16(file); item->room_number = VFile_ReadS16(file); item->pos.x = VFile_ReadS32(file); item->pos.y = VFile_ReadS32(file); @@ -758,10 +757,10 @@ static void Level_LoadItems(VFILE *file) item->shade = VFile_ReadS16(file); item->flags = VFile_ReadU16(file); - if (item->object_number < 0 || item->object_number >= O_NUMBER_OF) { + if (item->object_id < 0 || item->object_id >= O_NUMBER_OF) { Shell_ExitSystemFmt( "Level_LoadItems(): Bad Object number (%d) on Item %d", - item->object_number, i); + item->object_id, i); } } } diff --git a/src/game/lot.c b/src/game/lot.c index a51126898..6af8a5ab8 100644 --- a/src/game/lot.c +++ b/src/game/lot.c @@ -104,7 +104,7 @@ void LOT_InitialiseSlot(int16_t item_num, int32_t slot) creature->LOT.block_mask = BLOCKED; creature->LOT.fly = 0; - switch (item->object_number) { + switch (item->object_id) { case O_BAT: case O_ALLIGATOR: case O_FISH: diff --git a/src/game/objects/common.c b/src/game/objects/common.c index a87018ad2..4fec5e67f 100644 --- a/src/game/objects/common.c +++ b/src/game/objects/common.c @@ -255,8 +255,8 @@ int16_t Object_FindReceptacle(GAME_OBJECT_ID object_id) Object_GetCognate(object_id, m_KeyItemToReceptacleMap); for (int item_num = 0; item_num < g_LevelItemCount; item_num++) { ITEM_INFO *item = &g_Items[item_num]; - if (item->object_number == receptacle_to_check) { - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + if (item->object_id == receptacle_to_check) { + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; if (Lara_TestPosition(item, obj->bounds())) { return item_num; } @@ -316,7 +316,7 @@ void Object_DrawSpriteItem(ITEM_INFO *item) Output_DrawSprite( item->interp.result.pos.x, item->interp.result.pos.y, item->interp.result.pos.z, - g_Objects[item->object_number].mesh_index - item->frame_number, + g_Objects[item->object_id].mesh_index - item->frame_number, item->shade); } @@ -328,7 +328,7 @@ void Object_DrawPickupItem(ITEM_INFO *item) } // Convert item to menu display item. - int16_t item_num_option = Inv_GetItemOption(item->object_number); + int16_t item_num_option = Inv_GetItemOption(item->object_id); // Save the frame number. int16_t old_frame_number = item->frame_number; // Modify item to be the anim for inv item and animation 0. @@ -367,7 +367,7 @@ void Object_DrawPickupItem(ITEM_INFO *item) // First get the sprite that was to be used, int16_t spr_num = - g_Objects[item->object_number].mesh_index - item->frame_number; + g_Objects[item->object_id].mesh_index - item->frame_number; PHD_SPRITE *sprite = &g_PhdSpriteInfo[spr_num]; // and get the animation bounding box, which is not the mesh one. @@ -591,7 +591,7 @@ void Object_DrawAnimatingItem(ITEM_INFO *item) FRAME_INFO *frmptr[2]; int32_t rate; int32_t frac = Item_GetFrames(item, frmptr, &rate); - OBJECT_INFO *object = &g_Objects[item->object_number]; + OBJECT_INFO *object = &g_Objects[item->object_id]; if (object->shadow_size) { Output_DrawShadow(object->shadow_size, &frmptr[0]->bounds, item); @@ -609,8 +609,8 @@ void Object_DrawAnimatingItem(ITEM_INFO *item) const int16_t *extra_rotation = item->data ? item->data : NULL; Object_DrawInterpolatedObject( - &g_Objects[item->object_number], item->mesh_bits, extra_rotation, - frmptr[0], frmptr[1], frac, rate); + &g_Objects[item->object_id], item->mesh_bits, extra_rotation, frmptr[0], + frmptr[1], frac, rate); Matrix_Pop(); } diff --git a/src/game/objects/creatures/bacon_lara.c b/src/game/objects/creatures/bacon_lara.c index ebbcbeac9..c0923cd2f 100644 --- a/src/game/objects/creatures/bacon_lara.c +++ b/src/game/objects/creatures/bacon_lara.c @@ -80,7 +80,7 @@ void BaconLara_Control(int16_t item_num) sector, g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z); int16_t relative_anim = g_LaraItem->anim_number - - g_Objects[g_LaraItem->object_number].anim_index; + - g_Objects[g_LaraItem->object_id].anim_index; int16_t relative_frame = g_LaraItem->frame_number - g_Anims[g_LaraItem->anim_number].frame_base; Item_SwitchToObjAnim(item, relative_anim, relative_frame, O_LARA); diff --git a/src/game/objects/creatures/bat.c b/src/game/objects/creatures/bat.c index ada972152..7ec7805a5 100644 --- a/src/game/objects/creatures/bat.c +++ b/src/game/objects/creatures/bat.c @@ -51,7 +51,7 @@ static void Bat_FixEmbeddedPosition(int16_t item_num) // one to properly measure them. Save it so it can be restored // after. int16_t old_anim = - item->anim_number - g_Objects[item->object_number].anim_index; + item->anim_number - g_Objects[item->object_id].anim_index; int16_t old_frame = item->frame_number - g_Anims[item->anim_number].frame_base; diff --git a/src/game/objects/creatures/lion.c b/src/game/objects/creatures/lion.c index d06e210d7..a067c2b4a 100644 --- a/src/game/objects/creatures/lion.c +++ b/src/game/objects/creatures/lion.c @@ -130,7 +130,7 @@ void Lion_Control(int16_t item_num) if (item->current_anim_state != LION_DEATH) { item->current_anim_state = LION_DEATH; int16_t anim_index = - item->object_number == O_PUMA ? PUMA_DIE_ANIM : LION_DIE_ANIM; + item->object_id == O_PUMA ? PUMA_DIE_ANIM : LION_DIE_ANIM; Item_SwitchToAnim( item, anim_index + (int16_t)(Random_GetControl() / 0x4000), 0); } diff --git a/src/game/objects/creatures/mutant.c b/src/game/objects/creatures/mutant.c index 179e39246..1c3e8c767 100644 --- a/src/game/objects/creatures/mutant.c +++ b/src/game/objects/creatures/mutant.c @@ -137,7 +137,7 @@ void Mutant_FlyerControl(int16_t item_num) int32_t shoot1 = 0; int32_t shoot2 = 0; - if (item->object_number != O_WARRIOR3 + if (item->object_id != O_WARRIOR3 && Creature_CanTargetEnemy(item, &info) && (info.zone_number != info.enemy_zone || info.distance > FLYER_ATTACK_RANGE)) { @@ -148,7 +148,7 @@ void Mutant_FlyerControl(int16_t item_num) } } - if (item->object_number == O_WARRIOR1) { + if (item->object_id == O_WARRIOR1) { if (item->current_anim_state == FLYER_FLY) { if ((flyer->flags & FLYER_FLYMODE) && flyer->mood != MOOD_ESCAPE && info.zone_number == info.enemy_zone) { diff --git a/src/game/objects/creatures/natla.c b/src/game/objects/creatures/natla.c index c35e32c9a..8b77a808b 100644 --- a/src/game/objects/creatures/natla.c +++ b/src/game/objects/creatures/natla.c @@ -327,7 +327,7 @@ void NatlaGun_Setup(OBJECT_INFO *obj) void NatlaGun_Control(int16_t fx_num) { FX_INFO *fx = &g_Effects[fx_num]; - OBJECT_INFO *object = &g_Objects[fx->object_number]; + OBJECT_INFO *object = &g_Objects[fx->object_id]; fx->frame_number--; if (fx->frame_number <= object->nmeshes) { @@ -359,6 +359,6 @@ void NatlaGun_Control(int16_t fx_num) newfx->room_number = room_num; newfx->speed = fx->speed; newfx->frame_number = 0; - newfx->object_number = O_MISSILE1; + newfx->object_id = O_MISSILE1; } } diff --git a/src/game/objects/creatures/pod.c b/src/game/objects/creatures/pod.c index 2bbcced6f..48c932636 100644 --- a/src/game/objects/creatures/pod.c +++ b/src/game/objects/creatures/pod.c @@ -51,19 +51,19 @@ void Pod_Initialise(int16_t item_num) switch ((item->flags & IF_CODE_BITS) >> 9) { case 1: - bug->object_number = O_WARRIOR2; + bug->object_id = O_WARRIOR2; break; case 2: - bug->object_number = O_CENTAUR; + bug->object_id = O_CENTAUR; break; case 4: - bug->object_number = O_TORSO; + bug->object_id = O_TORSO; break; case 8: - bug->object_number = O_WARRIOR3; + bug->object_id = O_WARRIOR3; break; default: - bug->object_number = O_WARRIOR1; + bug->object_id = O_WARRIOR1; break; } @@ -96,7 +96,7 @@ void Pod_Control(int16_t item_num) if (item->flags & IF_ONESHOT) { explode = 1; - } else if (item->object_number == O_BIG_POD) { + } else if (item->object_id == O_BIG_POD) { explode = 1; } else { int32_t x = g_LaraItem->pos.x - item->pos.x; @@ -116,7 +116,7 @@ void Pod_Control(int16_t item_num) int16_t bug_item_num = *(int16_t *)item->data; ITEM_INFO *bug = &g_Items[bug_item_num]; - if (g_Objects[bug->object_number].loaded) { + if (g_Objects[bug->object_id].loaded) { bug->touch_bits = 0; Item_AddActive(bug_item_num); if (LOT_EnableBaddieAI(bug_item_num, 0)) { diff --git a/src/game/objects/creatures/rat.c b/src/game/objects/creatures/rat.c index e9b82edee..80c807319 100644 --- a/src/game/objects/creatures/rat.c +++ b/src/game/objects/creatures/rat.c @@ -218,7 +218,7 @@ void Vole_Control(int16_t item_num) int32_t wh = Room_GetWaterHeight( item->pos.x, item->pos.y, item->pos.z, item->room_number); if (wh == NO_HEIGHT) { - item->object_number = O_RAT; + item->object_id = O_RAT; item->current_anim_state = RAT_DEATH; item->goal_anim_state = RAT_DEATH; Item_SwitchToAnim(item, RAT_DIE_ANIM, -1); diff --git a/src/game/objects/creatures/skate_kid.c b/src/game/objects/creatures/skate_kid.c index cd19325dd..a1c8e4523 100644 --- a/src/game/objects/creatures/skate_kid.c +++ b/src/game/objects/creatures/skate_kid.c @@ -172,13 +172,13 @@ void SkateKid_Draw(ITEM_INFO *item) Object_DrawAnimatingItem(item); int16_t relative_anim = - item->anim_number - g_Objects[item->object_number].anim_index; + item->anim_number - g_Objects[item->object_id].anim_index; int16_t relative_frame = item->frame_number - g_Anims[item->anim_number].frame_base; - item->object_number = O_SKATEBOARD; + item->object_id = O_SKATEBOARD; Item_SwitchToAnim(item, relative_anim, relative_frame); Object_DrawAnimatingItem(item); - item->object_number = O_SKATEKID; + item->object_id = O_SKATEKID; Item_SwitchToAnim(item, relative_anim, relative_frame); } diff --git a/src/game/objects/creatures/statue.c b/src/game/objects/creatures/statue.c index f9bf9371e..9da74a37d 100644 --- a/src/game/objects/creatures/statue.c +++ b/src/game/objects/creatures/statue.c @@ -39,7 +39,7 @@ void Statue_Initialise(int16_t item_num) } ITEM_INFO *centaur = &g_Items[centaur_item_num]; - centaur->object_number = O_CENTAUR; + centaur->object_id = O_CENTAUR; centaur->room_number = item->room_number; centaur->pos.x = item->pos.x; centaur->pos.y = item->pos.y; diff --git a/src/game/objects/effects/blood.c b/src/game/objects/effects/blood.c index aa58e07e2..5db579d6e 100644 --- a/src/game/objects/effects/blood.c +++ b/src/game/objects/effects/blood.c @@ -19,7 +19,7 @@ void Blood_Control(int16_t fx_num) if (fx->counter == 4) { fx->counter = 0; fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_number].nmeshes) { + if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } diff --git a/src/game/objects/effects/body_part.c b/src/game/objects/effects/body_part.c index a852c16fe..97531da44 100644 --- a/src/game/objects/effects/body_part.c +++ b/src/game/objects/effects/body_part.c @@ -45,7 +45,7 @@ void BodyPart_Control(int16_t fx_num) fx->speed = 0; fx->frame_number = 0; fx->counter = 0; - fx->object_number = O_EXPLOSION1; + fx->object_id = O_EXPLOSION1; Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); } else { Effect_Kill(fx_num); @@ -60,7 +60,7 @@ void BodyPart_Control(int16_t fx_num) fx->speed = 0; fx->frame_number = 0; fx->counter = 0; - fx->object_number = O_EXPLOSION1; + fx->object_id = O_EXPLOSION1; Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); g_Lara.spaz_effect_count = 5; diff --git a/src/game/objects/effects/explosion.c b/src/game/objects/effects/explosion.c index e69303ae8..5d5821f41 100644 --- a/src/game/objects/effects/explosion.c +++ b/src/game/objects/effects/explosion.c @@ -15,7 +15,7 @@ void Explosion_Control(int16_t fx_num) if (fx->counter == 2) { fx->counter = 0; fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_number].nmeshes) { + if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } diff --git a/src/game/objects/effects/missile.c b/src/game/objects/effects/missile.c index d3972d726..38c27acb0 100644 --- a/src/game/objects/effects/missile.c +++ b/src/game/objects/effects/missile.c @@ -42,14 +42,14 @@ void Missile_Control(int16_t fx_num) Room_GetCeiling(sector, fx->pos.x, fx->pos.y, fx->pos.z); if (fx->pos.y >= height || fx->pos.y <= ceiling) { - if (fx->object_number == O_MISSILE2) { - fx->object_number = O_RICOCHET1; + if (fx->object_id == O_MISSILE2) { + fx->object_id = O_RICOCHET1; fx->frame_number = -Random_GetControl() / 11000; fx->speed = 0; fx->counter = 6; Sound_Effect(SFX_LARA_RICOCHET, &fx->pos, SPM_NORMAL); } else { - fx->object_number = O_EXPLOSION1; + fx->object_id = O_EXPLOSION1; fx->frame_number = 0; fx->speed = 0; fx->counter = 0; @@ -76,13 +76,13 @@ void Missile_Control(int16_t fx_num) return; } - if (fx->object_number == O_MISSILE2) { + if (fx->object_id == O_MISSILE2) { Lara_TakeDamage(SHARD_DAMAGE, true); - fx->object_number = O_BLOOD1; + fx->object_id = O_BLOOD1; Sound_Effect(SFX_LARA_BULLETHIT, &fx->pos, SPM_NORMAL); } else { Lara_TakeDamage(ROCKET_DAMAGE, true); - fx->object_number = O_EXPLOSION1; + fx->object_id = O_EXPLOSION1; if (g_LaraItem->hit_points > 0) { Sound_Effect(SFX_LARA_INJURY, &g_LaraItem->pos, SPM_NORMAL); g_Lara.spaz_effect = fx; diff --git a/src/game/objects/effects/ricochet.c b/src/game/objects/effects/ricochet.c index 784de7802..1d578724f 100644 --- a/src/game/objects/effects/ricochet.c +++ b/src/game/objects/effects/ricochet.c @@ -28,7 +28,7 @@ void Ricochet_Spawn(GAME_VECTOR *pos) fx->pos.y = pos->y; fx->pos.z = pos->z; fx->counter = 4; - fx->object_number = O_RICOCHET1; + fx->object_id = O_RICOCHET1; fx->frame_number = -3 * Random_GetDraw() / 0x8000; Sound_Effect(SFX_LARA_RICOCHET, &fx->pos, SPM_NORMAL); } diff --git a/src/game/objects/effects/splash.c b/src/game/objects/effects/splash.c index ea215e2dc..72404dafc 100644 --- a/src/game/objects/effects/splash.c +++ b/src/game/objects/effects/splash.c @@ -17,7 +17,7 @@ void Splash_Control(int16_t fx_num) { FX_INFO *fx = &g_Effects[fx_num]; fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_number].nmeshes) { + if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); return; } @@ -43,7 +43,7 @@ void Splash_Spawn(ITEM_INFO *item) fx->pos.y = wh; fx->pos.z = item->pos.z; fx->rot.y = PHD_180 + 2 * Random_GetDraw(); - fx->object_number = O_SPLASH1; + fx->object_id = O_SPLASH1; fx->frame_number = 0; fx->speed = Random_GetDraw() / 256; } diff --git a/src/game/objects/effects/twinkle.c b/src/game/objects/effects/twinkle.c index 4395bad0e..e727501a2 100644 --- a/src/game/objects/effects/twinkle.c +++ b/src/game/objects/effects/twinkle.c @@ -18,7 +18,7 @@ void Twinkle_Control(int16_t fx_num) if (fx->counter == 1) { fx->counter = 0; fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_number].nmeshes) { + if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } @@ -33,7 +33,7 @@ void Twinkle_Spawn(GAME_VECTOR *pos) fx->pos.y = pos->y; fx->pos.z = pos->z; fx->counter = 0; - fx->object_number = O_TWINKLE; + fx->object_id = O_TWINKLE; fx->frame_number = 0; } } diff --git a/src/game/objects/effects/waterfall.c b/src/game/objects/effects/waterfall.c index 40c29ce92..f7195b204 100644 --- a/src/game/objects/effects/waterfall.c +++ b/src/game/objects/effects/waterfall.c @@ -41,7 +41,7 @@ void Waterfall_Control(int16_t item_num) fx->pos.y = item->pos.y; fx->speed = 0; fx->frame_number = 0; - fx->object_number = O_SPLASH1; + fx->object_id = O_SPLASH1; } } } diff --git a/src/game/objects/general/keyhole.c b/src/game/objects/general/keyhole.c index 37b4b2fd1..8e318796d 100644 --- a/src/game/objects/general/keyhole.c +++ b/src/game/objects/general/keyhole.c @@ -38,7 +38,7 @@ void KeyHole_Setup(OBJECT_INFO *obj) void KeyHole_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; if (g_Lara.interact_target.is_moving && g_Lara.interact_target.item_num == item_num) { diff --git a/src/game/objects/general/pickup.c b/src/game/objects/general/pickup.c index b4ca48ca7..00e16089e 100644 --- a/src/game/objects/general/pickup.c +++ b/src/game/objects/general/pickup.c @@ -57,8 +57,8 @@ static void PickUp_GetAllAtLaraPos(ITEM_INFO *item, ITEM_INFO *lara_item); static void PickUp_GetItem( int16_t item_num, ITEM_INFO *item, ITEM_INFO *lara_item) { - Overlay_AddPickup(item->object_number); - Inv_AddItem(item->object_number); + Overlay_AddPickup(item->object_id); + Inv_AddItem(item->object_id); item->status = IS_INVISIBLE; Item_RemoveDrawn(item_num); g_GameInfo.current[g_CurrentLevel].stats.pickup_count++; @@ -71,8 +71,7 @@ static void PickUp_GetAllAtLaraPos(ITEM_INFO *item, ITEM_INFO *lara_item) while (pickup_num != NO_ITEM) { ITEM_INFO *check_item = &g_Items[pickup_num]; if (check_item->pos.x == item->pos.x && check_item->pos.z == item->pos.z - && g_Objects[check_item->object_number].collision - == Pickup_Collision) { + && g_Objects[check_item->object_id].collision == Pickup_Collision) { PickUp_GetItem(pickup_num, check_item, lara_item); } pickup_num = check_item->next_item; @@ -106,7 +105,7 @@ void Pickup_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) } ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; int16_t rotx = item->rot.x; int16_t roty = item->rot.y; int16_t rotz = item->rot.z; @@ -169,7 +168,7 @@ void Pickup_CollisionControlled( int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; if (item->status == IS_INVISIBLE) { return; diff --git a/src/game/objects/general/puzzle_hole.c b/src/game/objects/general/puzzle_hole.c index ec0a6df6e..8e7e6d34d 100644 --- a/src/game/objects/general/puzzle_hole.c +++ b/src/game/objects/general/puzzle_hole.c @@ -58,7 +58,7 @@ void PuzzleHole_Collision( int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; if (lara_item->current_anim_state == LS_USE_PUZZLE) { if (!Lara_TestPosition(item, obj->bounds())) { @@ -66,21 +66,21 @@ void PuzzleHole_Collision( } if (Item_TestFrameEqual(lara_item, LF_USEPUZZLE)) { - switch (item->object_number) { + switch (item->object_id) { case O_PUZZLE_HOLE1: - item->object_number = O_PUZZLE_DONE1; + item->object_id = O_PUZZLE_DONE1; break; case O_PUZZLE_HOLE2: - item->object_number = O_PUZZLE_DONE2; + item->object_id = O_PUZZLE_DONE2; break; case O_PUZZLE_HOLE3: - item->object_number = O_PUZZLE_DONE3; + item->object_id = O_PUZZLE_DONE3; break; case O_PUZZLE_HOLE4: - item->object_number = O_PUZZLE_DONE4; + item->object_id = O_PUZZLE_DONE4; break; default: diff --git a/src/game/objects/general/save_crystal.c b/src/game/objects/general/save_crystal.c index 594863e7e..b687bf071 100644 --- a/src/game/objects/general/save_crystal.c +++ b/src/game/objects/general/save_crystal.c @@ -57,7 +57,7 @@ void SaveCrystal_Collision( int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; Object_Collision(item_num, lara_item, coll); diff --git a/src/game/objects/general/scion.c b/src/game/objects/general/scion.c index 1999ac5c6..22b3e977c 100644 --- a/src/game/objects/general/scion.c +++ b/src/game/objects/general/scion.c @@ -130,7 +130,7 @@ void Scion_Control3(int16_t item_num) fx->pos.z = item->pos.z + (Random_GetControl() - 0x4000) / 32; fx->speed = 0; fx->frame_number = 0; - fx->object_number = O_EXPLOSION1; + fx->object_id = O_EXPLOSION1; fx->counter = 0; Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); g_Camera.bounce = -200; @@ -146,7 +146,7 @@ void Scion_Control3(int16_t item_num) void Scion_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; int16_t rotx = item->rot.x; int16_t roty = item->rot.y; int16_t rotz = item->rot.z; @@ -160,8 +160,8 @@ void Scion_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) if (lara_item->current_anim_state == LS_PICKUP) { if (Item_TestFrameEqual(lara_item, LF_PICKUPSCION)) { - Overlay_AddPickup(item->object_number); - Inv_AddItem(item->object_number); + Overlay_AddPickup(item->object_id); + Inv_AddItem(item->object_id); item->status = IS_INVISIBLE; Item_RemoveDrawn(item_num); g_GameInfo.current[g_CurrentLevel].stats.pickup_count++; @@ -192,7 +192,7 @@ void Scion_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) void Scion_Collision4(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; int16_t rotx = item->rot.x; int16_t roty = item->rot.y; int16_t rotz = item->rot.z; diff --git a/src/game/objects/general/switch.c b/src/game/objects/general/switch.c index 0468a71cf..44a78673f 100644 --- a/src/game/objects/general/switch.c +++ b/src/game/objects/general/switch.c @@ -94,7 +94,7 @@ void Switch_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) } ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; if (!g_Input.action || item->status != IS_NOT_ACTIVE || g_Lara.gun_status != LGS_ARMLESS || lara_item->gravity_status) { @@ -188,7 +188,7 @@ void Switch_CollisionControlled( void Switch_CollisionUW(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; if (!g_Input.action || item->status != IS_NOT_ACTIVE || g_Lara.water_status != LWS_UNDERWATER) { diff --git a/src/game/objects/names.c b/src/game/objects/names.c index f742a225d..e74377e3d 100644 --- a/src/game/objects/names.c +++ b/src/game/objects/names.c @@ -11,13 +11,13 @@ #include typedef struct { - const GAME_OBJECT_ID obj_id; + const GAME_OBJECT_ID object_id; const char *regex; } ITEM_NAME; typedef struct { int32_t match_length; - GAME_OBJECT_ID obj_id; + GAME_OBJECT_ID object_id; } MATCH; static const INVENTORY_ITEM *const m_InvItems[] = { @@ -222,13 +222,13 @@ GAME_OBJECT_ID *Object_IdsFromName(const char *name, int32_t *out_match_count) VECTOR *matches = Vector_Create(sizeof(MATCH)); // Store matches from hardcoded strings - for (const ITEM_NAME *desc = m_ItemNames; desc->obj_id != NO_OBJECT; + for (const ITEM_NAME *desc = m_ItemNames; desc->object_id != NO_OBJECT; desc++) { const int32_t match_length = String_Match(name, desc->regex); if (match_length > 0) { MATCH match = { .match_length = match_length, - .obj_id = desc->obj_id, + .object_id = desc->object_id, }; Vector_Add(matches, &match); } @@ -241,8 +241,8 @@ GAME_OBJECT_ID *Object_IdsFromName(const char *name, int32_t *out_match_count) if (String_CaseSubstring(item->string, name)) { MATCH match = { .match_length = strlen(name), - .obj_id = Object_GetCognateInverse( - item->object_number, g_ItemToInvObjectMap), + .object_id = Object_GetCognateInverse( + item->object_id, g_ItemToInvObjectMap), }; Vector_Add(matches, &match); } @@ -264,16 +264,17 @@ GAME_OBJECT_ID *Object_IdsFromName(const char *name, int32_t *out_match_count) int32_t unique_count = 0; for (int32_t i = 0; i < matches->count; i++) { - const GAME_OBJECT_ID obj_id = ((MATCH *)Vector_Get(matches, i))->obj_id; + const GAME_OBJECT_ID object_id = + ((MATCH *)Vector_Get(matches, i))->object_id; bool is_unique = true; for (int32_t j = 0; j < unique_count; j++) { - if (obj_id == unique_ids[j]) { + if (object_id == unique_ids[j]) { is_unique = false; break; } } if (is_unique) { - unique_ids[unique_count++] = obj_id; + unique_ids[unique_count++] = object_id; } } @@ -291,14 +292,14 @@ GAME_OBJECT_ID *Object_IdsFromName(const char *name, int32_t *out_match_count) } const char *Object_GetCanonicalName( - const GAME_OBJECT_ID obj_id, const char *user_input) + const GAME_OBJECT_ID object_id, const char *user_input) { for (const INVENTORY_ITEM *const *item_ptr = m_InvItems; *item_ptr != NULL; item_ptr++) { const INVENTORY_ITEM *item = *item_ptr; if (item->string != NULL - && Inv_GetItemOption(item->object_number) - == Inv_GetItemOption(obj_id)) { + && Inv_GetItemOption(item->object_id) + == Inv_GetItemOption(object_id)) { return item->string; } } diff --git a/src/game/objects/names.h b/src/game/objects/names.h index d3db7bc38..3da49786e 100644 --- a/src/game/objects/names.h +++ b/src/game/objects/names.h @@ -10,4 +10,4 @@ GAME_OBJECT_ID *Object_IdsFromName(const char *name, int32_t *out_match_count); const char *Object_GetCanonicalName( - const GAME_OBJECT_ID obj_id, const char *user_input); + const GAME_OBJECT_ID object_id, const char *user_input); diff --git a/src/game/objects/traps/dart.c b/src/game/objects/traps/dart.c index 4ad75d31d..19c7066e6 100644 --- a/src/game/objects/traps/dart.c +++ b/src/game/objects/traps/dart.c @@ -61,7 +61,7 @@ void Dart_Control(int16_t item_num) fx->speed = 0; fx->counter = 6; fx->frame_number = -3 * Random_GetControl() / 0x8000; - fx->object_number = O_RICOCHET1; + fx->object_id = O_RICOCHET1; } } } @@ -79,7 +79,7 @@ void DartEffect_Control(int16_t fx_num) if (fx->counter >= 3) { fx->counter = 0; fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_number].nmeshes) { + if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } @@ -110,7 +110,7 @@ void DartEmitter_Control(int16_t item_num) int16_t dart_item_num = Item_Create(); if (dart_item_num != NO_ITEM) { ITEM_INFO *dart = &g_Items[dart_item_num]; - dart->object_number = O_DARTS; + dart->object_id = O_DARTS; dart->room_number = item->room_number; dart->shade = -1; dart->rot.y = item->rot.y; @@ -147,7 +147,7 @@ void DartEmitter_Control(int16_t item_num) fx->speed = 0; fx->frame_number = 0; fx->counter = 0; - fx->object_number = O_DART_EFFECT; + fx->object_id = O_DART_EFFECT; Sound_Effect(SFX_DARTS, &fx->pos, SPM_NORMAL); } } diff --git a/src/game/objects/traps/flame.c b/src/game/objects/traps/flame.c index 4e3557b8e..c289fa879 100644 --- a/src/game/objects/traps/flame.c +++ b/src/game/objects/traps/flame.c @@ -88,7 +88,7 @@ void Flame_Control(int16_t fx_num) if (fx_num != NO_ITEM) { fx = &g_Effects[fx_num]; fx->frame_number = 0; - fx->object_number = O_FLAME; + fx->object_id = O_FLAME; fx->counter = -1; } } @@ -114,7 +114,7 @@ void FlameEmitter_Control(int16_t item_num) fx->pos.y = item->pos.y; fx->pos.z = item->pos.z; fx->frame_number = 0; - fx->object_number = O_FLAME; + fx->object_id = O_FLAME; fx->counter = 0; } item->data = (void *)(intptr_t)(fx_num + 1); diff --git a/src/game/objects/traps/lava.c b/src/game/objects/traps/lava.c index 4cc6405d2..0615a3b0a 100644 --- a/src/game/objects/traps/lava.c +++ b/src/game/objects/traps/lava.c @@ -59,7 +59,7 @@ void Lava_Burn(ITEM_INFO *const item) const int16_t fx_num = Effect_Create(item->room_number); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; - fx->object_number = O_FLAME; + fx->object_id = O_FLAME; fx->frame_number = (g_Objects[O_FLAME].nmeshes * Random_GetControl()) / 0x7FFF; fx->counter = -1 - Random_GetControl() * 24 / 0x7FFF; @@ -116,7 +116,7 @@ void LavaEmitter_Control(int16_t item_num) fx->speed = Random_GetControl() >> 10; fx->fall_speed = -Random_GetControl() / 200; fx->frame_number = -4 * Random_GetControl() / 0x7FFF; - fx->object_number = O_LAVA; + fx->object_id = O_LAVA; Sound_Effect(SFX_LAVA_FOUNTAIN, &item->pos, SPM_NORMAL); } } diff --git a/src/game/objects/traps/lightning_emitter.c b/src/game/objects/traps/lightning_emitter.c index bc8f1c6a5..f871a2810 100644 --- a/src/game/objects/traps/lightning_emitter.c +++ b/src/game/objects/traps/lightning_emitter.c @@ -48,7 +48,7 @@ void LightningEmitter_Initialise(int16_t item_num) LIGHTNING *l = GameBuf_Alloc(sizeof(LIGHTNING), GBUF_TRAP_DATA); g_Items[item_num].data = l; - if (g_Objects[g_Items[item_num].object_number].nmeshes > 1) { + if (g_Objects[g_Items[item_num].object_id].nmeshes > 1) { g_Items[item_num].mesh_bits = 1; l->no_target = false; } else { diff --git a/src/game/objects/traps/midas_touch.c b/src/game/objects/traps/midas_touch.c index b911ee310..d86f5ac45 100644 --- a/src/game/objects/traps/midas_touch.c +++ b/src/game/objects/traps/midas_touch.c @@ -44,7 +44,7 @@ void MidasTouch_Collision( int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; DIRECTION quadrant = (uint16_t)(lara_item->rot.y + PHD_45) / PHD_90; switch (quadrant) { diff --git a/src/game/objects/traps/movable_block.c b/src/game/objects/traps/movable_block.c index 7356bda84..11b4a2005 100644 --- a/src/game/objects/traps/movable_block.c +++ b/src/game/objects/traps/movable_block.c @@ -55,7 +55,7 @@ static bool MovableBlock_TestDoor(ITEM_INFO *lara_item, COLL_INFO *coll) const int32_t max_dist = SQUARE((WALL_L * 2) >> shift); for (int item_num = 0; item_num < g_LevelItemCount; item_num++) { ITEM_INFO *const item = &g_Items[item_num]; - if (!Object_IsObjectType(item->object_number, g_DoorObjects)) { + if (!Object_IsObjectType(item->object_id, g_DoorObjects)) { continue; } @@ -284,7 +284,7 @@ void MovableBlock_Collision( int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) { ITEM_INFO *item = &g_Items[item_num]; - const OBJECT_INFO *const obj = &g_Objects[item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[item->object_id]; if (item->current_anim_state == MBS_STILL) { item->priv = (void *)false; diff --git a/src/game/objects/traps/thors_hammer.c b/src/game/objects/traps/thors_hammer.c index 7408615cd..bb58f9969 100644 --- a/src/game/objects/traps/thors_hammer.c +++ b/src/game/objects/traps/thors_hammer.c @@ -39,7 +39,7 @@ void ThorsHandle_Initialise(int16_t item_num) ITEM_INFO *hand_item = &g_Items[item_num]; int16_t head_item_num = Item_Create(); ITEM_INFO *head_item = &g_Items[head_item_num]; - head_item->object_number = O_THORS_HEAD; + head_item->object_id = O_THORS_HEAD; head_item->room_number = hand_item->room_number; head_item->pos = hand_item->pos; head_item->rot = hand_item->rot; @@ -147,7 +147,7 @@ void ThorsHandle_Control(int16_t item_num) ITEM_INFO *head_item = item->data; int16_t relative_anim = - item->anim_number - g_Objects[item->object_number].anim_index; + item->anim_number - g_Objects[item->object_id].anim_index; int16_t relative_frame = item->frame_number - g_Anims[item->anim_number].frame_base; Item_SwitchToAnim(head_item, relative_anim, relative_frame); diff --git a/src/game/option/option.c b/src/game/option/option.c index d88bdca97..0ff1fc6f9 100644 --- a/src/game/option/option.c +++ b/src/game/option/option.c @@ -13,7 +13,7 @@ static CONTROL_MODE m_ControlMode = CM_PICK; void Option_Shutdown(INVENTORY_ITEM *inv_item) { - switch (inv_item->object_number) { + switch (inv_item->object_id) { case O_PASSPORT_OPTION: Option_Passport_Shutdown(); break; @@ -45,7 +45,7 @@ void Option_Shutdown(INVENTORY_ITEM *inv_item) void Option_DoInventory(INVENTORY_ITEM *inv_item) { - switch (inv_item->object_number) { + switch (inv_item->object_id) { case O_PASSPORT_OPTION: Option_Passport(inv_item); break; diff --git a/src/game/overlay.c b/src/game/overlay.c index e0ea9e3d0..2f4594eed 100644 --- a/src/game/overlay.c +++ b/src/game/overlay.c @@ -37,7 +37,7 @@ typedef enum DISPLAY_PICKUP_PHASE { } DISPLAY_PICKUP_PHASE; typedef struct DISPLAY_PICKUP_INFO { - int16_t obj_num; + GAME_OBJECT_ID object_id; double duration; int32_t grid_x; int32_t grid_y; @@ -377,7 +377,7 @@ static void Overlay_DrawPickup3D(DISPLAY_PICKUP_INFO *pu) Output_RotateLight(0, 0); Output_SetupAboveWater(false); - OBJECT_INFO *obj = &g_Objects[Inv_GetItemOption(pu->obj_num)]; + OBJECT_INFO *obj = &g_Objects[Inv_GetItemOption(pu->object_id)]; const FRAME_INFO *const frame = g_Anims[obj->anim_index].frame_ptr; Matrix_Push(); @@ -485,7 +485,7 @@ static void Overlay_DrawPickupsSprites(void) const int32_t y = Viewport_GetHeight() - sprite_height - sprite_height * pu->grid_y; const int32_t scale = Screen_GetRenderScaleGLRage(12288); - const int16_t sprite_num = g_Objects[pu->obj_num].mesh_index; + const int16_t sprite_num = g_Objects[pu->object_id].mesh_index; Output_DrawUISprite(x, y, scale, sprite_num, 4096); } } @@ -562,7 +562,7 @@ static void Overlay_BarDrawEnemy(void) } m_EnemyBar.value = g_Lara.target->hit_points; - m_EnemyBar.max_value = g_Objects[g_Lara.target->object_number].hit_points + m_EnemyBar.max_value = g_Objects[g_Lara.target->object_id].hit_points * ((g_GameInfo.bonus_flag & GBF_NGPLUS) ? 2 : 1); CLAMP(m_EnemyBar.value, 0, m_EnemyBar.max_value); @@ -778,7 +778,7 @@ void Overlay_DrawFPSInfo(void) } } -void Overlay_AddPickup(int16_t object_num) +void Overlay_AddPickup(const GAME_OBJECT_ID object_id) { int32_t grid_x = -1; int32_t grid_y = -1; @@ -805,7 +805,7 @@ void Overlay_AddPickup(int16_t object_num) for (int i = 0; i < MAX_PICKUPS; i++) { if (m_Pickups[i].phase == DPP_DEAD) { - m_Pickups[i].obj_num = object_num; + m_Pickups[i].object_id = object_id; m_Pickups[i].duration = 0; m_Pickups[i].grid_x = grid_x; m_Pickups[i].grid_y = grid_y; diff --git a/src/game/overlay.h b/src/game/overlay.h index 62f888579..89bbe989d 100644 --- a/src/game/overlay.h +++ b/src/game/overlay.h @@ -19,6 +19,6 @@ void Overlay_HideGameInfo(void); void Overlay_DrawGameInfo(void); void Overlay_DrawFPSInfo(void); -void Overlay_AddPickup(int16_t object_num); +void Overlay_AddPickup(GAME_OBJECT_ID object_id); void Overlay_MakeAmmoString(char *string); diff --git a/src/game/phase/phase_cutscene.c b/src/game/phase/phase_cutscene.c index 137b545e3..b4e4138ac 100644 --- a/src/game/phase/phase_cutscene.c +++ b/src/game/phase/phase_cutscene.c @@ -43,7 +43,7 @@ static void Phase_Cutscene_InitialiseHair(int32_t level_num) int16_t lara_item_num = NO_ITEM; for (int i = 0; i < g_LevelItemCount; i++) { - if (g_Items[i].object_number == lara_type) { + if (g_Items[i].object_id == lara_type) { lara_item_num = i; break; } diff --git a/src/game/phase/phase_inventory.c b/src/game/phase/phase_inventory.c index 852b8cbf2..4438d7612 100644 --- a/src/game/phase/phase_inventory.c +++ b/src/game/phase/phase_inventory.c @@ -132,7 +132,7 @@ static void Inv_Draw(RING_INFO *ring, IMOTION_INFO *motion) } INVENTORY_ITEM *inv_item = ring->list[ring->current_object]; - switch (inv_item->object_number) { + switch (inv_item->object_id) { case O_MEDI_OPTION: case O_BIGMEDI_OPTION: Overlay_BarDrawHealth(); @@ -352,7 +352,7 @@ static PHASE_CONTROL Inv_Close(GAME_OBJECT_ID inv_chosen) static void Inv_SelectMeshes(INVENTORY_ITEM *inv_item) { - if (inv_item->object_number == O_PASSPORT_OPTION) { + if (inv_item->object_id == O_PASSPORT_OPTION) { if (inv_item->current_frame <= 14) { inv_item->drawn_meshes = PASS_MESH | PINFRONT | PPAGE1; } else if (inv_item->current_frame < 19) { @@ -366,7 +366,7 @@ static void Inv_SelectMeshes(INVENTORY_ITEM *inv_item) } else if (inv_item->current_frame == 29) { inv_item->drawn_meshes = PASS_MESH; } - } else if (inv_item->object_number == O_MAP_OPTION) { + } else if (inv_item->object_id == O_MAP_OPTION) { if (inv_item->current_frame && inv_item->current_frame < 18) { inv_item->drawn_meshes = -1; } else { @@ -400,7 +400,7 @@ static int32_t InvItem_GetFrames( { const RING_INFO *const ring = &m_Ring; const IMOTION_INFO *const motion = &m_Motion; - const OBJECT_INFO *const obj = &g_Objects[inv_item->object_number]; + const OBJECT_INFO *const obj = &g_Objects[inv_item->object_id]; const INVENTORY_ITEM *const cur_inv_item = ring->list[ring->current_object]; if (inv_item != cur_inv_item || (motion->status != RNG_SELECTED @@ -493,7 +493,7 @@ static void Inv_DrawItem(INVENTORY_ITEM *const inv_item, const int32_t frames) Matrix_TranslateRel(0, inv_item->ytrans, inv_item->ztrans); Matrix_RotYXZ(inv_item->y_rot, inv_item->x_rot, 0); - OBJECT_INFO *obj = &g_Objects[inv_item->object_number]; + OBJECT_INFO *obj = &g_Objects[inv_item->object_id]; if (obj->nmeshes < 0) { Output_DrawSpriteRel(0, 0, 0, obj->mesh_index, 4096); return; @@ -549,7 +549,7 @@ static void Inv_DrawItem(INVENTORY_ITEM *const inv_item, const int32_t frames) FRAME_INFO *frame1; FRAME_INFO *frame2; const int32_t frac = InvItem_GetFrames(inv_item, &frame1, &frame2, &rate); - if (inv_item->object_number == O_MAP_OPTION) { + if (inv_item->object_id == O_MAP_OPTION) { const int16_t extra_rotation[1] = { Option_Compass_GetNeedleAngle() }; int32_t *const bone = &g_AnimBones[obj->bone_index]; bone[0] |= BEB_ROT_Y; @@ -719,7 +719,7 @@ static PHASE_CONTROL Phase_Inventory_ControlFrame(void) || motion->status == RNG_OPENING)) { for (int i = 0; i < ring->number_of_objects; i++) { INVENTORY_ITEM *inv_item = ring->list[i]; - if (inv_item->object_number == O_MAP_OPTION) { + if (inv_item->object_id == O_MAP_OPTION) { Option_Compass_UpdateNeedle(inv_item); } } @@ -796,7 +796,7 @@ static PHASE_CONTROL Phase_Inventory_ControlFrame(void) g_Input = (INPUT_STATE) { 0 }; g_InputDB = (INPUT_STATE) { 0 }; - switch (inv_item->object_number) { + switch (inv_item->object_id) { case O_MAP_OPTION: Sound_Effect(SFX_MENU_COMPASS, NULL, SPM_ALWAYS); break; @@ -966,8 +966,8 @@ static PHASE_CONTROL Phase_Inventory_ControlFrame(void) case RNG_SELECTED: { INVENTORY_ITEM *inv_item = ring->list[ring->current_object]; - if (inv_item->object_number == O_PASSPORT_CLOSED) { - inv_item->object_number = O_PASSPORT_OPTION; + if (inv_item->object_id == O_PASSPORT_CLOSED) { + inv_item->object_id = O_PASSPORT_OPTION; } bool busy = false; @@ -995,7 +995,7 @@ static PHASE_CONTROL Phase_Inventory_ControlFrame(void) if (g_InputDB.menu_confirm) { inv_item->sprlist = NULL; - m_InvChosen = inv_item->object_number; + m_InvChosen = inv_item->object_id; if (ring->type == RT_MAIN) { g_InvMainCurrent = ring->current_object; } else { @@ -1003,10 +1003,10 @@ static PHASE_CONTROL Phase_Inventory_ControlFrame(void) } if (g_InvMode == INV_TITLE_MODE - && ((inv_item->object_number == O_DETAIL_OPTION) - || inv_item->object_number == O_SOUND_OPTION - || inv_item->object_number == O_CONTROL_OPTION - || inv_item->object_number == O_GAMMA_OPTION)) { + && ((inv_item->object_id == O_DETAIL_OPTION) + || inv_item->object_id == O_SOUND_OPTION + || inv_item->object_id == O_CONTROL_OPTION + || inv_item->object_id == O_GAMMA_OPTION)) { Inv_Ring_MotionSetup( ring, RNG_CLOSING_ITEM, RNG_DESELECT, 0); } else { @@ -1032,8 +1032,8 @@ static PHASE_CONTROL Phase_Inventory_ControlFrame(void) case RNG_CLOSING_ITEM: { INVENTORY_ITEM *inv_item = ring->list[ring->current_object]; if (!Inv_AnimateItem(inv_item)) { - if (inv_item->object_number == O_PASSPORT_OPTION) { - inv_item->object_number = O_PASSPORT_CLOSED; + if (inv_item->object_id == O_PASSPORT_OPTION) { + inv_item->object_id = O_PASSPORT_CLOSED; inv_item->current_frame = 0; } motion->count = SELECTING_FRAMES; diff --git a/src/game/room.c b/src/game/room.c index e46907fa3..0d15f2b01 100644 --- a/src/game/room.c +++ b/src/game/room.c @@ -129,7 +129,7 @@ static void Room_AddFlipItems(ROOM_INFO *r) item_num = g_Items[item_num].next_item) { ITEM_INFO *item = &g_Items[item_num]; - switch (item->object_number) { + switch (item->object_id) { case O_MOVABLE_BLOCK: case O_MOVABLE_BLOCK2: case O_MOVABLE_BLOCK3: @@ -153,7 +153,7 @@ static void Room_RemoveFlipItems(ROOM_INFO *r) item_num = g_Items[item_num].next_item) { ITEM_INFO *item = &g_Items[item_num]; - switch (item->object_number) { + switch (item->object_id) { case O_MOVABLE_BLOCK: case O_MOVABLE_BLOCK2: case O_MOVABLE_BLOCK3: @@ -349,7 +349,7 @@ int16_t Room_GetCeiling( const ITEM_INFO *const item = &g_Items[(int16_t)(intptr_t)cmd->parameter]; - const OBJECT_INFO *const object = &g_Objects[item->object_number]; + const OBJECT_INFO *const object = &g_Objects[item->object_id]; if (object->ceiling_height_func) { height = object->ceiling_height_func(item, x, y, z, height); } @@ -378,7 +378,7 @@ int16_t Room_GetHeight( const ITEM_INFO *const item = &g_Items[(int16_t)(intptr_t)cmd->parameter]; - const OBJECT_INFO *const object = &g_Objects[item->object_number]; + const OBJECT_INFO *const object = &g_Objects[item->object_id]; if (object->floor_height_func) { height = object->floor_height_func(item, x, y, z, height); } @@ -736,7 +736,7 @@ void Room_PopulateSectorData( void Room_TestTriggers(const ITEM_INFO *const item) { - const bool is_heavy = item->object_number != O_LARA; + const bool is_heavy = item->object_id != O_LARA; int16_t room_num = item->room_number; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, MAX_HEIGHT, item->pos.z, &room_num); @@ -843,7 +843,7 @@ void Room_TestTriggers(const ITEM_INFO *const item) } if (!item->active) { - if (g_Objects[item->object_number].intelligent) { + if (g_Objects[item->object_id].intelligent) { if (item->status == IS_NOT_ACTIVE) { item->touch_bits = 0; item->status = IS_ACTIVE; @@ -1028,7 +1028,7 @@ bool Room_IsOnWalkable( const int16_t item_num = (int16_t)(intptr_t)cmd->parameter; const ITEM_INFO *const item = &g_Items[item_num]; - const OBJECT_INFO *const object = &g_Objects[item->object_number]; + const OBJECT_INFO *const object = &g_Objects[item->object_id]; if (object->floor_height_func) { height = object->floor_height_func(item, x, y, z, height); object_found = true; diff --git a/src/game/room_draw.c b/src/game/room_draw.c index 086527c72..75278d12a 100644 --- a/src/game/room_draw.c +++ b/src/game/room_draw.c @@ -297,7 +297,7 @@ void Room_DrawSingleRoom(int16_t room_num) for (int i = r->item_number; i != NO_ITEM; i = g_Items[i].next_item) { ITEM_INFO *item = &g_Items[i]; if (item->status != IS_INVISIBLE) { - g_Objects[item->object_number].draw_routine(item); + g_Objects[item->object_id].draw_routine(item); } } diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index 8a71fc542..74895da73 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -85,7 +85,7 @@ static void Savegame_LoadPostprocess(void) { for (int i = 0; i < g_LevelItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; if (obj->save_position && obj->shadow_size) { int16_t room_num = item->room_number; @@ -101,7 +101,7 @@ static void Savegame_LoadPostprocess(void) if (obj->collision == PuzzleHole_Collision && (item->status == IS_DEACTIVATED || item->status == IS_ACTIVE)) { - item->object_number += O_PUZZLE_DONE1 - O_PUZZLE_HOLE1; + item->object_id += O_PUZZLE_DONE1 - O_PUZZLE_HOLE1; } if (obj->control == Pod_Control && item->status == IS_DEACTIVATED) { @@ -130,20 +130,20 @@ static void Savegame_LoadPostprocess(void) Room_AlterFloorHeight(item, -WALL_L * 2); } - if (item->object_number == O_PIERRE && item->hit_points <= 0 + if (item->object_id == O_PIERRE && item->hit_points <= 0 && (item->flags & IF_ONESHOT)) { g_MusicTrackFlags[MX_PIERRE_SPEECH] |= IF_ONESHOT; } - if (item->object_number == O_COWBOY && item->hit_points <= 0) { + if (item->object_id == O_COWBOY && item->hit_points <= 0) { g_MusicTrackFlags[MX_COWBOY_SPEECH] |= IF_ONESHOT; } - if (item->object_number == O_BALDY && item->hit_points <= 0) { + if (item->object_id == O_BALDY && item->hit_points <= 0) { g_MusicTrackFlags[MX_BALDY_SPEECH] |= IF_ONESHOT; } - if (item->object_number == O_LARSON && item->hit_points <= 0) { + if (item->object_id == O_LARSON && item->hit_points <= 0) { g_MusicTrackFlags[MX_BALDY_SPEECH] |= IF_ONESHOT; } } @@ -183,7 +183,7 @@ void Savegame_ProcessItemsBeforeLoad(void) { for (int i = 0; i < g_LevelItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; if (obj->control == MovableBlock_Control && item->status != IS_INVISIBLE && item->pos.y >= Item_GetHeight(item)) { @@ -199,7 +199,7 @@ void Savegame_ProcessItemsBeforeSave(void) { for (int i = 0; i < g_LevelItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; if (obj->control == SaveCrystal_Control && item->data) { // need to reset the crystal status diff --git a/src/game/savegame/savegame_bson.c b/src/game/savegame/savegame_bson.c index fd7f7d2d9..b5a5786cd 100644 --- a/src/game/savegame/savegame_bson.c +++ b/src/game/savegame/savegame_bson.c @@ -90,7 +90,7 @@ static struct json_array_s *SaveGame_BSON_DumpMusicTrackFlags(void); static void SaveGame_BSON_GetFXOrder(SAVEGAME_BSON_FX_ORDER *order); static bool Savegame_BSON_IsValidItemObject( - int16_t saved_obj_num, int16_t current_obj_num); + GAME_OBJECT_ID saved_object_id, GAME_OBJECT_ID current_object_id); static void SaveGame_BSON_SaveRaw( MYFILE *fp, struct json_value_s *root, int32_t version) @@ -138,33 +138,34 @@ static void SaveGame_BSON_GetFXOrder(SAVEGAME_BSON_FX_ORDER *order) } static bool Savegame_BSON_IsValidItemObject( - int16_t saved_obj_num, int16_t initial_obj_num) + const GAME_OBJECT_ID saved_object_id, + const GAME_OBJECT_ID initial_object_id) { - if (saved_obj_num == initial_obj_num) { + if (saved_object_id == initial_object_id) { return true; } // clang-format off - switch (saved_obj_num) { + switch (saved_object_id) { // used keyholes - case O_PUZZLE_DONE1: return initial_obj_num == O_PUZZLE_HOLE1; - case O_PUZZLE_DONE2: return initial_obj_num == O_PUZZLE_HOLE2; - case O_PUZZLE_DONE3: return initial_obj_num == O_PUZZLE_HOLE3; - case O_PUZZLE_DONE4: return initial_obj_num == O_PUZZLE_HOLE4; + case O_PUZZLE_DONE1: return initial_object_id == O_PUZZLE_HOLE1; + case O_PUZZLE_DONE2: return initial_object_id == O_PUZZLE_HOLE2; + case O_PUZZLE_DONE3: return initial_object_id == O_PUZZLE_HOLE3; + case O_PUZZLE_DONE4: return initial_object_id == O_PUZZLE_HOLE4; // pickups - case O_PISTOL_AMMO_ITEM: return initial_obj_num == O_PISTOL_ANIM; - case O_SG_AMMO_ITEM: return initial_obj_num == O_SHOTGUN_ITEM; - case O_MAG_AMMO_ITEM: return initial_obj_num == O_MAGNUM_ITEM; - case O_UZI_AMMO_ITEM: return initial_obj_num == O_UZI_ITEM; + case O_PISTOL_AMMO_ITEM: return initial_object_id == O_PISTOL_ANIM; + case O_SG_AMMO_ITEM: return initial_object_id == O_SHOTGUN_ITEM; + case O_MAG_AMMO_ITEM: return initial_object_id == O_MAGNUM_ITEM; + case O_UZI_AMMO_ITEM: return initial_object_id == O_UZI_ITEM; // dual-state animals - case O_ALLIGATOR: return initial_obj_num == O_CROCODILE; - case O_CROCODILE: return initial_obj_num == O_ALLIGATOR; - case O_RAT: return initial_obj_num == O_VOLE; - case O_VOLE: return initial_obj_num == O_RAT; + case O_ALLIGATOR: return initial_object_id == O_CROCODILE; + case O_CROCODILE: return initial_object_id == O_ALLIGATOR; + case O_RAT: return initial_object_id == O_VOLE; + case O_VOLE: return initial_object_id == O_RAT; + // default + default: return false; } // clang-format on - - return false; } static struct json_value_s *Savegame_BSON_ParseFromBuffer( @@ -500,13 +501,14 @@ static bool Savegame_BSON_LoadItems( } ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; - int obj_num = json_object_get_int(item_obj, "obj_num", -1); - if (!Savegame_BSON_IsValidItemObject(obj_num, item->object_number)) { + const GAME_OBJECT_ID object_id = + json_object_get_int(item_obj, "obj_num", -1); + if (!Savegame_BSON_IsValidItemObject(object_id, item->object_id)) { LOG_ERROR( - "Malformed save: expected object %d, got %d", - item->object_number, obj_num); + "Malformed save: expected object %d, got %d", item->object_id, + object_id); return false; } @@ -586,7 +588,7 @@ static bool Savegame_BSON_LoadItems( } if (header_version >= VERSION_3 - && item->object_number == O_FLAME_EMITTER + && item->object_id == O_FLAME_EMITTER && g_Config.enable_enhanced_saves) { int32_t fx_num = json_object_get_int(item_obj, "fx_num", -1); if (fx_num != -1) { @@ -666,7 +668,7 @@ static bool SaveGame_BSON_LoadFx(struct json_array_s *fx_arr) int32_t y = json_object_get_int(fx_obj, "y", 0); int32_t z = json_object_get_int(fx_obj, "z", 0); int16_t room_num = json_object_get_int(fx_obj, "room_number", 0); - GAME_OBJECT_ID object_number = + GAME_OBJECT_ID object_id = json_object_get_int(fx_obj, "object_number", 0); int16_t speed = json_object_get_int(fx_obj, "speed", 0); int16_t fall_speed = json_object_get_int(fx_obj, "fall_speed", 0); @@ -680,7 +682,7 @@ static bool SaveGame_BSON_LoadFx(struct json_array_s *fx_arr) fx->pos.x = x; fx->pos.y = y; fx->pos.z = z; - fx->object_number = object_number; + fx->object_id = object_id; fx->speed = speed; fx->fall_speed = fall_speed; fx->frame_number = frame_number; @@ -1042,9 +1044,9 @@ static struct json_array_s *Savegame_BSON_DumpItems(void) for (int i = 0; i < g_LevelItemCount; i++) { struct json_object_s *item_obj = json_object_new(); ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; - json_object_append_int(item_obj, "obj_num", item->object_number); + json_object_append_int(item_obj, "obj_num", item->object_id); if (obj->save_position) { json_object_append_int(item_obj, "x", item->pos.x); @@ -1096,7 +1098,7 @@ static struct json_array_s *Savegame_BSON_DumpItems(void) item_obj, "creature_mood", creature->mood); } - if (item->object_number == O_FLAME_EMITTER && item->data) { + if (item->object_id == O_FLAME_EMITTER && item->data) { int32_t fx_num = (int32_t)(intptr_t)item->data - 1; fx_num = fx_order.id_map[fx_num]; json_object_append_int(item_obj, "fx_num", fx_num); @@ -1147,7 +1149,7 @@ static struct json_array_s *SaveGame_BSON_DumpFx(void) json_object_append_int(fx_obj, "y", fx->pos.y); json_object_append_int(fx_obj, "z", fx->pos.z); json_object_append_int(fx_obj, "room_number", fx->room_number); - json_object_append_int(fx_obj, "object_number", fx->object_number); + json_object_append_int(fx_obj, "object_number", fx->object_id); json_object_append_int(fx_obj, "speed", fx->speed); json_object_append_int(fx_obj, "fall_speed", fx->fall_speed); json_object_append_int(fx_obj, "frame_number", fx->frame_number); diff --git a/src/game/savegame/savegame_legacy.c b/src/game/savegame/savegame_legacy.c index d4947e2e0..3857e3d28 100644 --- a/src/game/savegame/savegame_legacy.c +++ b/src/game/savegame/savegame_legacy.c @@ -74,11 +74,10 @@ static bool Savegame_Legacy_ItemHasSaveFlags(OBJECT_INFO *obj, ITEM_INFO *item) // to make sure the legacy savegame reader doesn't try to reach out for // information that's not there. return ( - obj->save_flags && item->object_number != O_LAVA_EMITTER - && item->object_number != O_FLAME_EMITTER - && item->object_number != O_WATERFALL - && item->object_number != O_SCION_ITEM - && item->object_number != O_DART_EMITTER); + obj->save_flags && item->object_id != O_LAVA_EMITTER + && item->object_id != O_FLAME_EMITTER && item->object_id != O_WATERFALL + && item->object_id != O_SCION_ITEM + && item->object_id != O_DART_EMITTER); } static bool Savegame_Legacy_NeedsBaconLaraFix(char *buffer) @@ -130,7 +129,7 @@ static bool Savegame_Legacy_NeedsBaconLaraFix(char *buffer) for (int i = 0; i < g_LevelItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; ITEM_INFO tmp_item; @@ -568,7 +567,7 @@ bool Savegame_Legacy_LoadFromFile(MYFILE *fp, GAME_INFO *game_info) for (int i = 0; i < g_LevelItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; if (obj->save_position) { Savegame_Legacy_Read(&item->pos.x, sizeof(int32_t)); @@ -598,7 +597,7 @@ bool Savegame_Legacy_LoadFromFile(MYFILE *fp, GAME_INFO *game_info) Savegame_Legacy_Read(&item->hit_points, sizeof(int16_t)); } - if ((item->object_number != O_BACON_LARA || !skip_reading_bacon_lara) + if ((item->object_id != O_BACON_LARA || !skip_reading_bacon_lara) && Savegame_Legacy_ItemHasSaveFlags(obj, item)) { Savegame_Legacy_Read(&item->flags, sizeof(int16_t)); Savegame_Legacy_Read(&item->timer, sizeof(int16_t)); @@ -747,7 +746,7 @@ void Savegame_Legacy_SaveToFile(MYFILE *fp, GAME_INFO *game_info) for (int i = 0; i < g_LevelItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - OBJECT_INFO *obj = &g_Objects[item->object_number]; + OBJECT_INFO *obj = &g_Objects[item->object_id]; if (obj->save_position) { Savegame_Legacy_Write(&item->pos.x, sizeof(int32_t)); diff --git a/src/game/stats.c b/src/game/stats.c index c434d5a14..828dfc579 100644 --- a/src/game/stats.c +++ b/src/game/stats.c @@ -54,7 +54,7 @@ int16_t m_KillableObjs[] = { static void Stats_TraverseFloor(void); static void Stats_CheckTriggers( ROOM_INFO *r, int room_num, int z_sector, int x_sector); -static bool Stats_IsObjectKillable(int32_t obj_num); +static bool Stats_IsObjectKillable(GAME_OBJECT_ID object_id); static void Stats_IncludeKillableItem(int16_t item_num); static void Stats_TraverseFloor(void) @@ -105,33 +105,32 @@ static void Stats_CheckTriggers( const ITEM_INFO *const item = &g_Items[item_num]; // Add Pierre pickup and kills if oneshot - if (item->object_number == O_PIERRE && sector->trigger->one_shot) { + if (item->object_id == O_PIERRE && sector->trigger->one_shot) { Stats_IncludeKillableItem(item_num); } // Check for only valid pods - if ((item->object_number == O_PODS - || item->object_number == O_BIG_POD) + if ((item->object_id == O_PODS || item->object_id == O_BIG_POD) && item->data != NULL) { const int16_t bug_item_num = *(int16_t *)item->data; const ITEM_INFO *const bug_item = &g_Items[bug_item_num]; - if (g_Objects[bug_item->object_number].loaded) { + if (g_Objects[bug_item->object_id].loaded) { Stats_IncludeKillableItem(item_num); } } // Add killable if object triggered - if (Stats_IsObjectKillable(item->object_number)) { + if (Stats_IsObjectKillable(item->object_id)) { Stats_IncludeKillableItem(item_num); } } } } -static bool Stats_IsObjectKillable(int32_t obj_num) +static bool Stats_IsObjectKillable(const GAME_OBJECT_ID object_id) { for (int i = 0; m_KillableObjs[i] != NO_ITEM; i++) { - if (m_KillableObjs[i] == obj_num) { + if (m_KillableObjs[i] == object_id) { return true; } } @@ -214,15 +213,14 @@ void Stats_CalculateStats(void) for (int i = 0; i < m_CachedItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - if (item->object_number < 0 || item->object_number >= O_NUMBER_OF) { + if (item->object_id < 0 || item->object_id >= O_NUMBER_OF) { LOG_ERROR( - "Bad Object number (%d) on Item %d", item->object_number, - i); + "Bad Object number (%d) on Item %d", item->object_id, i); continue; } for (int j = 0; m_PickupObjs[j] != NO_ITEM; j++) { - if (item->object_number == m_PickupObjs[j]) { + if (item->object_id == m_PickupObjs[j]) { m_LevelPickups++; } } diff --git a/src/global/types.h b/src/global/types.h index 53291bfe1..cbcecd576 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1284,7 +1284,7 @@ typedef struct { int32_t floor; uint32_t touch_bits; uint32_t mesh_bits; - GAME_OBJECT_ID object_number; + GAME_OBJECT_ID object_id; int16_t current_anim_state; int16_t goal_anim_state; int16_t required_anim_state; @@ -1394,7 +1394,7 @@ typedef struct FX_INFO { XYZ_32 pos; XYZ_16 rot; int16_t room_number; - GAME_OBJECT_ID object_number; + GAME_OBJECT_ID object_id; int16_t next_draw; int16_t next_active; int16_t next_free; @@ -1929,7 +1929,7 @@ typedef struct INVENTORY_SPRITE { typedef struct INVENTORY_ITEM { const char *string; - GAME_OBJECT_ID object_number; + GAME_OBJECT_ID object_id; int16_t frames_total; int16_t current_frame; int16_t goal_frame; From e0551a7dc82eb8b8da34ff00f20cefe646171ec8 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:03:14 +0200 Subject: [PATCH 2/9] types: use consistent naming for frame numbers --- src/game/effect_routines/bubbles.c | 2 +- src/game/effects.c | 5 ++--- src/game/effects/blood.c | 2 +- src/game/effects/exploding_death.c | 4 ++-- src/game/effects/gun.c | 4 ++-- src/game/effects/gunshot.c | 2 +- src/game/gun/gun.c | 12 ++++++------ src/game/gun/gun_pistols.c | 26 ++++++++++++------------- src/game/gun/gun_rifle.c | 18 ++++++++--------- src/game/items.c | 25 ++++++++++++------------ src/game/lara/lara.c | 13 ++++++------- src/game/lara/lara_draw.c | 20 ++++++++----------- src/game/lara/lara_state.c | 2 +- src/game/objects/common.c | 9 ++++----- src/game/objects/creatures/bacon_lara.c | 4 ++-- src/game/objects/creatures/bat.c | 3 +-- src/game/objects/creatures/crocodile.c | 2 +- src/game/objects/creatures/natla.c | 8 ++++---- src/game/objects/creatures/skate_kid.c | 2 +- src/game/objects/creatures/torso.c | 4 ++-- src/game/objects/creatures/wolf.c | 2 +- src/game/objects/effects/blood.c | 4 ++-- src/game/objects/effects/body_part.c | 4 ++-- src/game/objects/effects/explosion.c | 4 ++-- src/game/objects/effects/missile.c | 6 +++--- src/game/objects/effects/ricochet.c | 2 +- src/game/objects/effects/splash.c | 6 +++--- src/game/objects/effects/twinkle.c | 6 +++--- src/game/objects/effects/waterfall.c | 2 +- src/game/objects/general/scion.c | 2 +- src/game/objects/traps/dart.c | 8 ++++---- src/game/objects/traps/flame.c | 10 +++++----- src/game/objects/traps/lava.c | 4 ++-- src/game/objects/traps/thors_hammer.c | 5 ++--- src/game/savegame/savegame_bson.c | 17 ++++++++-------- src/game/savegame/savegame_legacy.c | 10 +++++----- src/global/types.h | 6 +++--- 37 files changed, 127 insertions(+), 138 deletions(-) diff --git a/src/game/effect_routines/bubbles.c b/src/game/effect_routines/bubbles.c index 9685480f1..3628d35bf 100644 --- a/src/game/effect_routines/bubbles.c +++ b/src/game/effect_routines/bubbles.c @@ -39,7 +39,7 @@ void FX_Bubbles(ITEM_INFO *item) fx->pos.y = offset.y; fx->pos.z = offset.z; fx->object_id = O_BUBBLES1; - fx->frame_number = -((Random_GetDraw() * 3) / 0x8000); + fx->frame_num = -((Random_GetDraw() * 3) / 0x8000); fx->speed = 10 + ((Random_GetDraw() * 6) / 0x8000); } } diff --git a/src/game/effects.c b/src/game/effects.c index 4b44fb4eb..68ee84c91 100644 --- a/src/game/effects.c +++ b/src/game/effects.c @@ -130,8 +130,7 @@ void Effect_Draw(const int16_t fxnum) if (object->nmeshes < 0) { Output_DrawSprite( fx->interp.result.pos.x, fx->interp.result.pos.y, - fx->interp.result.pos.z, object->mesh_index - fx->frame_number, - 4096); + fx->interp.result.pos.z, object->mesh_index - fx->frame_num, 4096); } else { Matrix_Push(); Matrix_TranslateAbs( @@ -149,7 +148,7 @@ void Effect_Draw(const int16_t fxnum) Output_CalculateLight( fx->interp.result.pos.x, fx->interp.result.pos.y, fx->interp.result.pos.z, fx->room_number); - Output_DrawPolygons(g_Meshes[fx->frame_number], -1); + Output_DrawPolygons(g_Meshes[fx->frame_num], -1); } } Matrix_Pop(); diff --git a/src/game/effects/blood.c b/src/game/effects/blood.c index 86a388501..c5e98ad6f 100644 --- a/src/game/effects/blood.c +++ b/src/game/effects/blood.c @@ -16,7 +16,7 @@ int16_t Effect_Blood( fx->pos.z = z; fx->rot.y = direction; fx->object_id = O_BLOOD1; - fx->frame_number = 0; + fx->frame_num = 0; fx->counter = 0; fx->speed = speed; } diff --git a/src/game/effects/exploding_death.c b/src/game/effects/exploding_death.c index 00d3001b3..8ef74fa70 100644 --- a/src/game/effects/exploding_death.c +++ b/src/game/effects/exploding_death.c @@ -48,7 +48,7 @@ int32_t Effect_ExplodingDeath( fx->fall_speed = -Random_GetControl() >> 8; } fx->counter = damage; - fx->frame_number = object->mesh_index; + fx->frame_num = object->mesh_index; fx->object_id = O_BODY_PART; } item->mesh_bits -= bit; @@ -101,7 +101,7 @@ int32_t Effect_ExplodingDeath( } fx->counter = damage; fx->object_id = O_BODY_PART; - fx->frame_number = object->mesh_index + i; + fx->frame_num = object->mesh_index + i; } item->mesh_bits -= bit; } diff --git a/src/game/effects/gun.c b/src/game/effects/gun.c index e27c5614e..411ab39bc 100644 --- a/src/game/effects/gun.c +++ b/src/game/effects/gun.c @@ -45,7 +45,7 @@ int16_t Effect_ShardGun( fx->rot.y = y_rot; fx->rot.z = 0; fx->object_id = O_MISSILE2; - fx->frame_number = 0; + fx->frame_num = 0; fx->speed = SHARD_SPEED; fx->shade = 3584; ShootAtLara(fx); @@ -68,7 +68,7 @@ int16_t Effect_RocketGun( fx->rot.y = y_rot; fx->rot.z = 0; fx->object_id = O_MISSILE3; - fx->frame_number = 0; + fx->frame_num = 0; fx->speed = ROCKET_SPEED; fx->shade = 4096; ShootAtLara(fx); diff --git a/src/game/effects/gunshot.c b/src/game/effects/gunshot.c index 034bde10a..069748112 100644 --- a/src/game/effects/gunshot.c +++ b/src/game/effects/gunshot.c @@ -24,7 +24,7 @@ int16_t Effect_GunShot( fx->rot.y = y_rot; fx->rot.z = 0; fx->counter = 3; - fx->frame_number = 0; + fx->frame_num = 0; fx->object_id = O_GUN_FLASH; fx->shade = 4096; } diff --git a/src/game/gun/gun.c b/src/game/gun/gun.c index 7a2055e1c..6d1f7e6cf 100644 --- a/src/game/gun/gun.c +++ b/src/game/gun/gun.c @@ -59,8 +59,8 @@ void Gun_Control(void) case LGT_UZIS: if (g_Lara.gun_status == LGS_ARMLESS) { g_Lara.gun_status = LGS_DRAW; - g_Lara.right_arm.frame_number = LF_G_AIM_START; - g_Lara.left_arm.frame_number = LF_G_AIM_START; + g_Lara.right_arm.frame_num = LF_G_AIM_START; + g_Lara.left_arm.frame_num = LF_G_AIM_START; } else if (g_Lara.gun_status == LGS_READY) { g_Lara.gun_status = LGS_UNDRAW; } @@ -69,8 +69,8 @@ void Gun_Control(void) case LGT_SHOTGUN: if (g_Lara.gun_status == LGS_ARMLESS) { g_Lara.gun_status = LGS_DRAW; - g_Lara.left_arm.frame_number = LF_SG_AIM_START; - g_Lara.right_arm.frame_number = LF_SG_AIM_START; + g_Lara.left_arm.frame_num = LF_SG_AIM_START; + g_Lara.right_arm.frame_num = LF_SG_AIM_START; } else if (g_Lara.gun_status == LGS_READY) { g_Lara.gun_status = LGS_UNDRAW; } @@ -182,13 +182,13 @@ void Gun_InitialiseNewWeapon(void) g_Lara.left_arm.rot.z = 0; g_Lara.left_arm.lock = 0; g_Lara.left_arm.flash_gun = 0; - g_Lara.left_arm.frame_number = LF_G_AIM_START; + g_Lara.left_arm.frame_num = LF_G_AIM_START; g_Lara.right_arm.rot.x = 0; g_Lara.right_arm.rot.y = 0; g_Lara.right_arm.rot.z = 0; g_Lara.right_arm.lock = 0; g_Lara.right_arm.flash_gun = 0; - g_Lara.right_arm.frame_number = LF_G_AIM_START; + g_Lara.right_arm.frame_num = LF_G_AIM_START; g_Lara.target = NULL; const GAME_OBJECT_ID anim_type = Gun_GetLaraAnim(g_Lara.gun_type); diff --git a/src/game/gun/gun_pistols.c b/src/game/gun/gun_pistols.c index f50f8c356..fe361945f 100644 --- a/src/game/gun/gun_pistols.c +++ b/src/game/gun/gun_pistols.c @@ -13,7 +13,7 @@ void Gun_Pistols_Draw(const LARA_GUN_TYPE weapon_type) { - int16_t ani = g_Lara.left_arm.frame_number; + int16_t ani = g_Lara.left_arm.frame_num; ani++; if (!Anim_TestAbsFrameRange(ani, LF_G_UNDRAW_START, LF_G_DRAW_END)) { @@ -26,13 +26,13 @@ void Gun_Pistols_Draw(const LARA_GUN_TYPE weapon_type) ani = LF_G_AIM_START; } - g_Lara.left_arm.frame_number = ani; - g_Lara.right_arm.frame_number = ani; + g_Lara.left_arm.frame_num = ani; + g_Lara.right_arm.frame_num = ani; } void Gun_Pistols_Undraw(const LARA_GUN_TYPE weapon_type) { - int16_t anil = g_Lara.left_arm.frame_number; + int16_t anil = g_Lara.left_arm.frame_num; if (Anim_TestAbsFrameRange(anil, LF_G_RECOIL_START, LF_G_RECOIL_END)) { anil = LF_G_AIM_END; } else if (Anim_TestAbsFrameRange(anil, LF_G_AIM_BEND, LF_G_AIM_END)) { @@ -50,9 +50,9 @@ void Gun_Pistols_Undraw(const LARA_GUN_TYPE weapon_type) } else if (Anim_TestAbsFrameRange(anil, LF_G_UNDRAW_BEND, LF_G_DRAW_END)) { anil--; } - g_Lara.left_arm.frame_number = anil; + g_Lara.left_arm.frame_num = anil; - int16_t anir = g_Lara.right_arm.frame_number; + int16_t anir = g_Lara.right_arm.frame_num; if (Anim_TestAbsFrameRange(anir, LF_G_RECOIL_START, LF_G_RECOIL_END)) { anir = LF_G_AIM_END; } else if (Anim_TestAbsFrameRange(anir, LF_G_AIM_BEND, LF_G_AIM_END)) { @@ -70,14 +70,14 @@ void Gun_Pistols_Undraw(const LARA_GUN_TYPE weapon_type) } else if (Anim_TestAbsFrameRange(anir, LF_G_UNDRAW_BEND, LF_G_DRAW_END)) { anir--; } - g_Lara.right_arm.frame_number = anir; + g_Lara.right_arm.frame_num = anir; if (Anim_TestAbsFrameEqual(anil, LF_G_UNDRAW_START) && Anim_TestAbsFrameEqual(anir, LF_G_UNDRAW_START)) { g_Lara.left_arm.lock = 0; g_Lara.right_arm.lock = 0; - g_Lara.left_arm.frame_number = LF_G_AIM_START; - g_Lara.right_arm.frame_number = LF_G_AIM_START; + g_Lara.left_arm.frame_num = LF_G_AIM_START; + g_Lara.right_arm.frame_num = LF_G_AIM_START; g_Lara.gun_status = LGS_ARMLESS; g_Lara.target = NULL; } @@ -178,7 +178,7 @@ void Gun_Pistols_Animate(const LARA_GUN_TYPE weapon_type) PHD_ANGLE angles[2]; WEAPON_INFO *winfo = &g_Weapons[weapon_type]; - int16_t anir = g_Lara.right_arm.frame_number; + int16_t anir = g_Lara.right_arm.frame_num; if (g_Lara.right_arm.lock || (g_Input.action && !g_Lara.target)) { if (Anim_TestAbsFrameRange(anir, LF_G_AIM_START, LF_G_AIM_EXTEND)) { anir++; @@ -206,9 +206,9 @@ void Gun_Pistols_Animate(const LARA_GUN_TYPE weapon_type) } else if (Anim_TestAbsFrameRange(anir, LF_G_AIM_BEND, LF_G_AIM_END)) { anir--; } - g_Lara.right_arm.frame_number = anir; + g_Lara.right_arm.frame_num = anir; - int16_t anil = g_Lara.left_arm.frame_number; + int16_t anil = g_Lara.left_arm.frame_num; if (g_Lara.left_arm.lock || (g_Input.action && !g_Lara.target)) { if (Anim_TestAbsFrameRange(anil, LF_G_AIM_START, LF_G_AIM_EXTEND)) { anil++; @@ -236,5 +236,5 @@ void Gun_Pistols_Animate(const LARA_GUN_TYPE weapon_type) } else if (Anim_TestAbsFrameRange(anil, LF_G_AIM_BEND, LF_G_AIM_END)) { anil--; } - g_Lara.left_arm.frame_number = anil; + g_Lara.left_arm.frame_num = anil; } diff --git a/src/game/gun/gun_rifle.c b/src/game/gun/gun_rifle.c index 730f84d35..66cec305d 100644 --- a/src/game/gun/gun_rifle.c +++ b/src/game/gun/gun_rifle.c @@ -16,7 +16,7 @@ void Gun_Rifle_Draw(const LARA_GUN_TYPE weapon_type) { - int16_t ani = g_Lara.left_arm.frame_number; + int16_t ani = g_Lara.left_arm.frame_num; ani++; if (!Anim_TestAbsFrameRange(ani, LF_SG_DRAW_START, LF_SG_RECOIL_START)) { @@ -28,13 +28,13 @@ void Gun_Rifle_Draw(const LARA_GUN_TYPE weapon_type) Gun_Rifle_Ready(weapon_type); ani = LF_SG_AIM_START; } - g_Lara.left_arm.frame_number = ani; - g_Lara.right_arm.frame_number = ani; + g_Lara.left_arm.frame_num = ani; + g_Lara.right_arm.frame_num = ani; } void Gun_Rifle_Undraw(const LARA_GUN_TYPE weapon_type) { - int16_t ani = ani = g_Lara.left_arm.frame_number; + int16_t ani = ani = g_Lara.left_arm.frame_num; if (Anim_TestAbsFrameEqual(ani, LF_SG_AIM_START)) { ani = LF_SG_UNDRAW_START; @@ -78,8 +78,8 @@ void Gun_Rifle_Undraw(const LARA_GUN_TYPE weapon_type) g_Lara.head_rot.y = 0; g_Lara.torso_rot.x += g_Lara.torso_rot.x / -2; g_Lara.torso_rot.y += g_Lara.torso_rot.y / -2; - g_Lara.right_arm.frame_number = ani; - g_Lara.left_arm.frame_number = ani; + g_Lara.right_arm.frame_num = ani; + g_Lara.left_arm.frame_num = ani; } void Gun_Rifle_DrawMeshes(const LARA_GUN_TYPE weapon_type) @@ -142,7 +142,7 @@ void Gun_Rifle_Control(const LARA_GUN_TYPE weapon_type) void Gun_Rifle_Animate(const LARA_GUN_TYPE weapon_type) { - int16_t ani = g_Lara.left_arm.frame_number; + int16_t ani = g_Lara.left_arm.frame_num; if (g_Lara.left_arm.lock) { if (Anim_TestAbsFrameRange(ani, LF_SG_AIM_START, LF_SG_AIM_END)) { ani++; @@ -235,8 +235,8 @@ void Gun_Rifle_Animate(const LARA_GUN_TYPE weapon_type) } } } - g_Lara.right_arm.frame_number = ani; - g_Lara.left_arm.frame_number = ani; + g_Lara.right_arm.frame_num = ani; + g_Lara.left_arm.frame_num = ani; } void Gun_Rifle_Fire(const LARA_GUN_TYPE weapon_type) diff --git a/src/game/items.c b/src/game/items.c index 3ba6f2ed3..7744cd09c 100644 --- a/src/game/items.c +++ b/src/game/items.c @@ -565,9 +565,9 @@ void Item_SwitchToObjAnim( { item->anim_number = g_Objects[object_id].anim_index + anim_index; if (frame < 0) { - item->frame_number = g_Anims[item->anim_number].frame_end + frame + 1; + item->frame_num = g_Anims[item->anim_number].frame_end + frame + 1; } else { - item->frame_number = g_Anims[item->anim_number].frame_base + frame; + item->frame_num = g_Anims[item->anim_number].frame_base + frame; } } @@ -578,7 +578,7 @@ void Item_Animate(ITEM_INFO *item) ANIM_STRUCT *anim = &g_Anims[item->anim_number]; - item->frame_number++; + item->frame_num++; if (anim->number_changes > 0) { if (Item_GetAnimChange(item, anim)) { @@ -591,7 +591,7 @@ void Item_Animate(ITEM_INFO *item) } } - if (item->frame_number > anim->frame_end) { + if (item->frame_num > anim->frame_end) { if (anim->number_commands > 0) { int16_t *command = &g_AnimCommands[anim->command_index]; for (int i = 0; i < anim->number_commands; i++) { @@ -621,7 +621,7 @@ void Item_Animate(ITEM_INFO *item) } item->anim_number = anim->jump_anim_num; - item->frame_number = anim->jump_frame_num; + item->frame_num = anim->jump_frame_num; anim = &g_Anims[item->anim_number]; item->current_anim_state = anim->current_anim_state; @@ -650,7 +650,7 @@ void Item_Animate(ITEM_INFO *item) break; case AC_EFFECT: - if (item->frame_number == command[0]) { + if (item->frame_num == command[0]) { g_EffectRoutines[command[1]](item); } command += 2; @@ -662,8 +662,7 @@ void Item_Animate(ITEM_INFO *item) if (!item->gravity_status) { int32_t speed = anim->velocity; if (anim->acceleration) { - speed += - anim->acceleration * (item->frame_number - anim->frame_base); + speed += anim->acceleration * (item->frame_num - anim->frame_base); } item->speed = speed >> 16; } else { @@ -693,7 +692,7 @@ bool Item_GetAnimChange(ITEM_INFO *item, ANIM_STRUCT *anim) range->end_frame - g_Anims[item->anim_number].frame_base)) { item->anim_number = range->link_anim_num; - item->frame_number = range->link_frame_num; + item->frame_num = range->link_frame_num; return true; } } @@ -705,7 +704,7 @@ bool Item_GetAnimChange(ITEM_INFO *item, ANIM_STRUCT *anim) void Item_PlayAnimSFX(ITEM_INFO *item, int16_t *command, uint16_t flags) { - if (item->frame_number != command[0]) { + if (item->frame_num != command[0]) { return; } @@ -786,7 +785,7 @@ int32_t Item_GetFrames( { const ANIM_STRUCT *anim = &g_Anims[item->anim_number]; - const int32_t cur_frame_num = item->frame_number - anim->frame_base; + const int32_t cur_frame_num = item->frame_num - anim->frame_base; const int32_t last_frame_num = anim->frame_end - anim->frame_base; const int32_t key_frame_span = anim->interpolation; const int32_t first_key_frame_num = cur_frame_num / key_frame_span; @@ -846,12 +845,12 @@ void Item_TakeDamage(ITEM_INFO *item, int16_t damage, bool hit_status) bool Item_TestFrameEqual(ITEM_INFO *item, int16_t frame) { return Anim_TestAbsFrameEqual( - item->frame_number, g_Anims[item->anim_number].frame_base + frame); + item->frame_num, g_Anims[item->anim_number].frame_base + frame); } bool Item_TestFrameRange(ITEM_INFO *item, int16_t start, int16_t end) { return Anim_TestAbsFrameRange( - item->frame_number, g_Anims[item->anim_number].frame_base + start, + item->frame_num, g_Anims[item->anim_number].frame_base + start, g_Anims[item->anim_number].frame_base + end); } diff --git a/src/game/lara/lara.c b/src/game/lara/lara.c index 897d72c13..a659627ad 100644 --- a/src/game/lara/lara.c +++ b/src/game/lara/lara.c @@ -225,14 +225,14 @@ void Lara_Animate(ITEM_INFO *item) int16_t *command; ANIM_STRUCT *anim; - item->frame_number++; + item->frame_num++; anim = &g_Anims[item->anim_number]; if (anim->number_changes > 0 && Item_GetAnimChange(item, anim)) { anim = &g_Anims[item->anim_number]; item->current_anim_state = anim->current_anim_state; } - if (item->frame_number > anim->frame_end) { + if (item->frame_num > anim->frame_end) { if (anim->number_commands > 0) { command = &g_AnimCommands[anim->command_index]; for (int i = 0; i < anim->number_commands; i++) { @@ -266,7 +266,7 @@ void Lara_Animate(ITEM_INFO *item) } item->anim_number = anim->jump_anim_num; - item->frame_number = anim->jump_frame_num; + item->frame_num = anim->jump_frame_num; anim = &g_Anims[anim->jump_anim_num]; item->current_anim_state = anim->current_anim_state; @@ -290,7 +290,7 @@ void Lara_Animate(ITEM_INFO *item) break; case AC_EFFECT: - if (item->frame_number == command[0]) { + if (item->frame_num == command[0]) { g_EffectRoutines[command[1]](item); } command += 2; @@ -301,7 +301,7 @@ void Lara_Animate(ITEM_INFO *item) if (item->gravity_status) { int32_t speed = anim->velocity - + anim->acceleration * (item->frame_number - anim->frame_base - 1); + + anim->acceleration * (item->frame_num - anim->frame_base - 1); item->speed -= (int16_t)(speed >> 16); speed += anim->acceleration; item->speed += (int16_t)(speed >> 16); @@ -311,8 +311,7 @@ void Lara_Animate(ITEM_INFO *item) } else { int32_t speed = anim->velocity; if (anim->acceleration) { - speed += - anim->acceleration * (item->frame_number - anim->frame_base); + speed += anim->acceleration * (item->frame_num - anim->frame_base); } item->speed = (int16_t)(speed >> 16); } diff --git a/src/game/lara/lara_draw.c b/src/game/lara/lara_draw.c index e88b5f217..76eeb951e 100644 --- a/src/game/lara/lara_draw.c +++ b/src/game/lara/lara_draw.c @@ -203,8 +203,7 @@ void Lara_Draw(ITEM_INFO *item) g_MatrixPtr->_22 = g_MatrixPtr[-2]._22; packed_rotation = - g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_number] - .mesh_rots; + g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_num].mesh_rots; Matrix_RotYXZ( g_Lara.right_arm.interp.result.rot.y, g_Lara.right_arm.interp.result.rot.x, @@ -241,7 +240,7 @@ void Lara_Draw(ITEM_INFO *item) g_MatrixPtr->_22 = g_MatrixPtr[-2]._22; packed_rotation = - g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_number].mesh_rots; + g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_num].mesh_rots; Matrix_RotYXZ( g_Lara.left_arm.interp.result.rot.y, g_Lara.left_arm.interp.result.rot.x, @@ -272,8 +271,7 @@ void Lara_Draw(ITEM_INFO *item) Matrix_Push(); packed_rotation = - g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_number] - .mesh_rots; + g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_num].mesh_rots; Matrix_TranslateRel(bone[29], bone[30], bone[31]); Matrix_RotYXZpack(packed_rotation[LM_UARM_R]); Output_DrawPolygons(g_Lara.mesh_ptrs[LM_UARM_R], clip); @@ -295,7 +293,7 @@ void Lara_Draw(ITEM_INFO *item) Matrix_Push(); packed_rotation = - g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_number].mesh_rots; + g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_num].mesh_rots; Matrix_TranslateRel(bone[41], bone[42], bone[43]); Matrix_RotYXZpack(packed_rotation[LM_UARM_L]); Output_DrawPolygons(g_Lara.mesh_ptrs[LM_UARM_L], clip); @@ -486,8 +484,7 @@ void Lara_Draw_I( Matrix_InterpolateArm(); packed_rotation1 = - g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_number] - .mesh_rots; + g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_num].mesh_rots; Matrix_RotYXZ( g_Lara.right_arm.interp.result.rot.y, g_Lara.right_arm.interp.result.rot.x, @@ -515,7 +512,7 @@ void Lara_Draw_I( Matrix_InterpolateArm(); packed_rotation1 = - g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_number].mesh_rots; + g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_num].mesh_rots; Matrix_RotYXZ( g_Lara.left_arm.interp.result.rot.y, g_Lara.left_arm.interp.result.rot.x, @@ -547,8 +544,7 @@ void Lara_Draw_I( Matrix_Push_I(); packed_rotation1 = - g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_number] - .mesh_rots; + g_Lara.right_arm.frame_base[g_Lara.right_arm.frame_num].mesh_rots; packed_rotation2 = packed_rotation1; Matrix_TranslateRel_I(bone[29], bone[30], bone[31]); Matrix_RotYXZpack_I( @@ -574,7 +570,7 @@ void Lara_Draw_I( Matrix_Push_I(); packed_rotation1 = - g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_number].mesh_rots; + g_Lara.left_arm.frame_base[g_Lara.left_arm.frame_num].mesh_rots; packed_rotation2 = packed_rotation1; Matrix_TranslateRel_I(bone[41], bone[42], bone[43]); Matrix_RotYXZpack_I( diff --git a/src/game/lara/lara_state.c b/src/game/lara/lara_state.c index 2951eaeae..27675e108 100644 --- a/src/game/lara/lara_state.c +++ b/src/game/lara/lara_state.c @@ -679,7 +679,7 @@ void Lara_State_DieMidas(ITEM_INFO *item, COLL_INFO *coll) coll->enable_spaz = 0; coll->enable_baddie_push = 0; - int frm = item->frame_number - g_Anims[item->anim_number].frame_base; + int frm = item->frame_num - g_Anims[item->anim_number].frame_base; switch (frm) { case 5: g_Lara.mesh_effects |= (1 << LM_FOOT_L); diff --git a/src/game/objects/common.c b/src/game/objects/common.c index 4fec5e67f..b58bdf883 100644 --- a/src/game/objects/common.c +++ b/src/game/objects/common.c @@ -316,8 +316,7 @@ void Object_DrawSpriteItem(ITEM_INFO *item) Output_DrawSprite( item->interp.result.pos.x, item->interp.result.pos.y, item->interp.result.pos.z, - g_Objects[item->object_id].mesh_index - item->frame_number, - item->shade); + g_Objects[item->object_id].mesh_index - item->frame_num, item->shade); } void Object_DrawPickupItem(ITEM_INFO *item) @@ -330,7 +329,7 @@ void Object_DrawPickupItem(ITEM_INFO *item) // Convert item to menu display item. int16_t item_num_option = Inv_GetItemOption(item->object_id); // Save the frame number. - int16_t old_frame_number = item->frame_number; + int16_t old_frame_num = item->frame_num; // Modify item to be the anim for inv item and animation 0. Item_SwitchToObjAnim(item, 0, 0, item_num_option); @@ -339,7 +338,7 @@ void Object_DrawPickupItem(ITEM_INFO *item) const FRAME_INFO *frame = g_Anims[item->anim_number].frame_ptr; // Restore the old frame number in case we need to get the sprite again. - item->frame_number = old_frame_number; + item->frame_num = old_frame_num; // Fall back to normal sprite rendering if not found. if (object->nmeshes < 0) { @@ -367,7 +366,7 @@ void Object_DrawPickupItem(ITEM_INFO *item) // First get the sprite that was to be used, int16_t spr_num = - g_Objects[item->object_id].mesh_index - item->frame_number; + g_Objects[item->object_id].mesh_index - item->frame_num; PHD_SPRITE *sprite = &g_PhdSpriteInfo[spr_num]; // and get the animation bounding box, which is not the mesh one. diff --git a/src/game/objects/creatures/bacon_lara.c b/src/game/objects/creatures/bacon_lara.c index c0923cd2f..067f7039f 100644 --- a/src/game/objects/creatures/bacon_lara.c +++ b/src/game/objects/creatures/bacon_lara.c @@ -81,8 +81,8 @@ void BaconLara_Control(int16_t item_num) int16_t relative_anim = g_LaraItem->anim_number - g_Objects[g_LaraItem->object_id].anim_index; - int16_t relative_frame = g_LaraItem->frame_number - - g_Anims[g_LaraItem->anim_number].frame_base; + int16_t relative_frame = + g_LaraItem->frame_num - g_Anims[g_LaraItem->anim_number].frame_base; Item_SwitchToObjAnim(item, relative_anim, relative_frame, O_LARA); item->pos.x = x; item->pos.y = y; diff --git a/src/game/objects/creatures/bat.c b/src/game/objects/creatures/bat.c index 7ec7805a5..5461ca0c2 100644 --- a/src/game/objects/creatures/bat.c +++ b/src/game/objects/creatures/bat.c @@ -52,8 +52,7 @@ static void Bat_FixEmbeddedPosition(int16_t item_num) // after. int16_t old_anim = item->anim_number - g_Objects[item->object_id].anim_index; - int16_t old_frame = - item->frame_number - g_Anims[item->anim_number].frame_base; + int16_t old_frame = item->frame_num - g_Anims[item->anim_number].frame_base; Item_SwitchToAnim(item, 0, 0); const BOUNDS_16 *const bounds = Item_GetBoundsAccurate(item); diff --git a/src/game/objects/creatures/crocodile.c b/src/game/objects/creatures/crocodile.c index acd033962..e37b06cfb 100644 --- a/src/game/objects/creatures/crocodile.c +++ b/src/game/objects/creatures/crocodile.c @@ -297,7 +297,7 @@ void Alligator_Control(int16_t item_num) break; case ALLIGATOR_ATTACK: - if (item->frame_number + if (item->frame_num == (g_Config.fix_alligator_ai ? ALLIGATOR_BITE_AF : g_Anims[item->anim_number].frame_base)) { diff --git a/src/game/objects/creatures/natla.c b/src/game/objects/creatures/natla.c index 8b77a808b..f9777d0dc 100644 --- a/src/game/objects/creatures/natla.c +++ b/src/game/objects/creatures/natla.c @@ -329,12 +329,12 @@ void NatlaGun_Control(int16_t fx_num) FX_INFO *fx = &g_Effects[fx_num]; OBJECT_INFO *object = &g_Objects[fx->object_id]; - fx->frame_number--; - if (fx->frame_number <= object->nmeshes) { + fx->frame_num--; + if (fx->frame_num <= object->nmeshes) { Effect_Kill(fx_num); } - if (fx->frame_number == -1) { + if (fx->frame_num == -1) { return; } @@ -358,7 +358,7 @@ void NatlaGun_Control(int16_t fx_num) newfx->rot.y = fx->rot.y; newfx->room_number = room_num; newfx->speed = fx->speed; - newfx->frame_number = 0; + newfx->frame_num = 0; newfx->object_id = O_MISSILE1; } } diff --git a/src/game/objects/creatures/skate_kid.c b/src/game/objects/creatures/skate_kid.c index a1c8e4523..1d9cb0d16 100644 --- a/src/game/objects/creatures/skate_kid.c +++ b/src/game/objects/creatures/skate_kid.c @@ -174,7 +174,7 @@ void SkateKid_Draw(ITEM_INFO *item) int16_t relative_anim = item->anim_number - g_Objects[item->object_id].anim_index; int16_t relative_frame = - item->frame_number - g_Anims[item->anim_number].frame_base; + item->frame_num - g_Anims[item->anim_number].frame_base; item->object_id = O_SKATEBOARD; Item_SwitchToAnim(item, relative_anim, relative_frame); Object_DrawAnimatingItem(item); diff --git a/src/game/objects/creatures/torso.c b/src/game/objects/creatures/torso.c index 3669ef775..4dccd9cd4 100644 --- a/src/game/objects/creatures/torso.c +++ b/src/game/objects/creatures/torso.c @@ -161,7 +161,7 @@ void Torso_Control(int16_t item_num) case TORSO_TURN_L: if (!torso->flags) { - torso->flags = item->frame_number; + torso->flags = item->frame_num; } else if ( Item_TestAnimEqual(item, TORSO_TURN_L_ANIM) && Item_TestFrameRange( @@ -176,7 +176,7 @@ void Torso_Control(int16_t item_num) case TORSO_TURN_R: if (!torso->flags) { - torso->flags = item->frame_number; + torso->flags = item->frame_num; } else if ( Item_TestAnimEqual(item, TORSO_TURN_R_ANIM) && Item_TestFrameRange( diff --git a/src/game/objects/creatures/wolf.c b/src/game/objects/creatures/wolf.c index 986a6b3da..e122d73d6 100644 --- a/src/game/objects/creatures/wolf.c +++ b/src/game/objects/creatures/wolf.c @@ -72,7 +72,7 @@ void Wolf_Setup(OBJECT_INFO *obj) void Wolf_Initialise(int16_t item_num) { - g_Items[item_num].frame_number = WOLF_SLEEP_FRAME; + g_Items[item_num].frame_num = WOLF_SLEEP_FRAME; Creature_Initialise(item_num); } diff --git a/src/game/objects/effects/blood.c b/src/game/objects/effects/blood.c index 5db579d6e..bf28f4c58 100644 --- a/src/game/objects/effects/blood.c +++ b/src/game/objects/effects/blood.c @@ -18,8 +18,8 @@ void Blood_Control(int16_t fx_num) fx->counter++; if (fx->counter == 4) { fx->counter = 0; - fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { + fx->frame_num--; + if (fx->frame_num <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } diff --git a/src/game/objects/effects/body_part.c b/src/game/objects/effects/body_part.c index 97531da44..ecdd38e25 100644 --- a/src/game/objects/effects/body_part.c +++ b/src/game/objects/effects/body_part.c @@ -43,7 +43,7 @@ void BodyPart_Control(int16_t fx_num) if (fx->pos.y >= height) { if (fx->counter) { fx->speed = 0; - fx->frame_number = 0; + fx->frame_num = 0; fx->counter = 0; fx->object_id = O_EXPLOSION1; Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); @@ -58,7 +58,7 @@ void BodyPart_Control(int16_t fx_num) if (fx->counter) { fx->speed = 0; - fx->frame_number = 0; + fx->frame_num = 0; fx->counter = 0; fx->object_id = O_EXPLOSION1; Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); diff --git a/src/game/objects/effects/explosion.c b/src/game/objects/effects/explosion.c index 5d5821f41..db867e23b 100644 --- a/src/game/objects/effects/explosion.c +++ b/src/game/objects/effects/explosion.c @@ -14,8 +14,8 @@ void Explosion_Control(int16_t fx_num) fx->counter++; if (fx->counter == 2) { fx->counter = 0; - fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { + fx->frame_num--; + if (fx->frame_num <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } diff --git a/src/game/objects/effects/missile.c b/src/game/objects/effects/missile.c index 38c27acb0..dc949222a 100644 --- a/src/game/objects/effects/missile.c +++ b/src/game/objects/effects/missile.c @@ -44,13 +44,13 @@ void Missile_Control(int16_t fx_num) if (fx->pos.y >= height || fx->pos.y <= ceiling) { if (fx->object_id == O_MISSILE2) { fx->object_id = O_RICOCHET1; - fx->frame_number = -Random_GetControl() / 11000; + fx->frame_num = -Random_GetControl() / 11000; fx->speed = 0; fx->counter = 6; Sound_Effect(SFX_LARA_RICOCHET, &fx->pos, SPM_NORMAL); } else { fx->object_id = O_EXPLOSION1; - fx->frame_number = 0; + fx->frame_num = 0; fx->speed = 0; fx->counter = 0; Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); @@ -91,7 +91,7 @@ void Missile_Control(int16_t fx_num) Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); } - fx->frame_number = 0; + fx->frame_num = 0; fx->rot.y = g_LaraItem->rot.y; fx->speed = g_LaraItem->speed; fx->counter = 0; diff --git a/src/game/objects/effects/ricochet.c b/src/game/objects/effects/ricochet.c index 1d578724f..012072dbd 100644 --- a/src/game/objects/effects/ricochet.c +++ b/src/game/objects/effects/ricochet.c @@ -29,7 +29,7 @@ void Ricochet_Spawn(GAME_VECTOR *pos) fx->pos.z = pos->z; fx->counter = 4; fx->object_id = O_RICOCHET1; - fx->frame_number = -3 * Random_GetDraw() / 0x8000; + fx->frame_num = -3 * Random_GetDraw() / 0x8000; Sound_Effect(SFX_LARA_RICOCHET, &fx->pos, SPM_NORMAL); } } diff --git a/src/game/objects/effects/splash.c b/src/game/objects/effects/splash.c index 72404dafc..04273b4ae 100644 --- a/src/game/objects/effects/splash.c +++ b/src/game/objects/effects/splash.c @@ -16,8 +16,8 @@ void Splash_Setup(OBJECT_INFO *obj) void Splash_Control(int16_t fx_num) { FX_INFO *fx = &g_Effects[fx_num]; - fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { + fx->frame_num--; + if (fx->frame_num <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); return; } @@ -44,7 +44,7 @@ void Splash_Spawn(ITEM_INFO *item) fx->pos.z = item->pos.z; fx->rot.y = PHD_180 + 2 * Random_GetDraw(); fx->object_id = O_SPLASH1; - fx->frame_number = 0; + fx->frame_num = 0; fx->speed = Random_GetDraw() / 256; } } diff --git a/src/game/objects/effects/twinkle.c b/src/game/objects/effects/twinkle.c index e727501a2..2a732b081 100644 --- a/src/game/objects/effects/twinkle.c +++ b/src/game/objects/effects/twinkle.c @@ -17,8 +17,8 @@ void Twinkle_Control(int16_t fx_num) fx->counter++; if (fx->counter == 1) { fx->counter = 0; - fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { + fx->frame_num--; + if (fx->frame_num <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } @@ -34,7 +34,7 @@ void Twinkle_Spawn(GAME_VECTOR *pos) fx->pos.z = pos->z; fx->counter = 0; fx->object_id = O_TWINKLE; - fx->frame_number = 0; + fx->frame_num = 0; } } diff --git a/src/game/objects/effects/waterfall.c b/src/game/objects/effects/waterfall.c index f7195b204..5b5c93fb1 100644 --- a/src/game/objects/effects/waterfall.c +++ b/src/game/objects/effects/waterfall.c @@ -40,7 +40,7 @@ void Waterfall_Control(int16_t item_num) + ((Random_GetDraw() - 0x4000) << WALL_SHIFT) / 0x7FFF; fx->pos.y = item->pos.y; fx->speed = 0; - fx->frame_number = 0; + fx->frame_num = 0; fx->object_id = O_SPLASH1; } } diff --git a/src/game/objects/general/scion.c b/src/game/objects/general/scion.c index 22b3e977c..830af8e3c 100644 --- a/src/game/objects/general/scion.c +++ b/src/game/objects/general/scion.c @@ -129,7 +129,7 @@ void Scion_Control3(int16_t item_num) item->pos.y + (Random_GetControl() - 0x4000) / 256 - 500; fx->pos.z = item->pos.z + (Random_GetControl() - 0x4000) / 32; fx->speed = 0; - fx->frame_number = 0; + fx->frame_num = 0; fx->object_id = O_EXPLOSION1; fx->counter = 0; Sound_Effect(SFX_ATLANTEAN_EXPLODE, &fx->pos, SPM_NORMAL); diff --git a/src/game/objects/traps/dart.c b/src/game/objects/traps/dart.c index 19c7066e6..b30155a49 100644 --- a/src/game/objects/traps/dart.c +++ b/src/game/objects/traps/dart.c @@ -60,7 +60,7 @@ void Dart_Control(int16_t item_num) fx->pos.z = old_z; fx->speed = 0; fx->counter = 6; - fx->frame_number = -3 * Random_GetControl() / 0x8000; + fx->frame_num = -3 * Random_GetControl() / 0x8000; fx->object_id = O_RICOCHET1; } } @@ -78,8 +78,8 @@ void DartEffect_Control(int16_t fx_num) fx->counter++; if (fx->counter >= 3) { fx->counter = 0; - fx->frame_number--; - if (fx->frame_number <= g_Objects[fx->object_id].nmeshes) { + fx->frame_num--; + if (fx->frame_num <= g_Objects[fx->object_id].nmeshes) { Effect_Kill(fx_num); } } @@ -145,7 +145,7 @@ void DartEmitter_Control(int16_t item_num) fx->pos = dart->pos; fx->rot = dart->rot; fx->speed = 0; - fx->frame_number = 0; + fx->frame_num = 0; fx->counter = 0; fx->object_id = O_DART_EFFECT; Sound_Effect(SFX_DARTS, &fx->pos, SPM_NORMAL); diff --git a/src/game/objects/traps/flame.c b/src/game/objects/traps/flame.c index c289fa879..1de4aa9ec 100644 --- a/src/game/objects/traps/flame.c +++ b/src/game/objects/traps/flame.c @@ -27,9 +27,9 @@ void Flame_Control(int16_t fx_num) { FX_INFO *fx = &g_Effects[fx_num]; - fx->frame_number--; - if (fx->frame_number <= g_Objects[O_FLAME].nmeshes) { - fx->frame_number = 0; + fx->frame_num--; + if (fx->frame_num <= g_Objects[O_FLAME].nmeshes) { + fx->frame_num = 0; } if (fx->counter < 0) { @@ -87,7 +87,7 @@ void Flame_Control(int16_t fx_num) fx_num = Effect_Create(g_LaraItem->room_number); if (fx_num != NO_ITEM) { fx = &g_Effects[fx_num]; - fx->frame_number = 0; + fx->frame_num = 0; fx->object_id = O_FLAME; fx->counter = -1; } @@ -113,7 +113,7 @@ void FlameEmitter_Control(int16_t item_num) fx->pos.x = item->pos.x; fx->pos.y = item->pos.y; fx->pos.z = item->pos.z; - fx->frame_number = 0; + fx->frame_num = 0; fx->object_id = O_FLAME; fx->counter = 0; } diff --git a/src/game/objects/traps/lava.c b/src/game/objects/traps/lava.c index 0615a3b0a..f52468bcf 100644 --- a/src/game/objects/traps/lava.c +++ b/src/game/objects/traps/lava.c @@ -60,7 +60,7 @@ void Lava_Burn(ITEM_INFO *const item) if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->object_id = O_FLAME; - fx->frame_number = + fx->frame_num = (g_Objects[O_FLAME].nmeshes * Random_GetControl()) / 0x7FFF; fx->counter = -1 - Random_GetControl() * 24 / 0x7FFF; } @@ -115,7 +115,7 @@ void LavaEmitter_Control(int16_t item_num) fx->rot.y = (Random_GetControl() - 0x4000) * 2; fx->speed = Random_GetControl() >> 10; fx->fall_speed = -Random_GetControl() / 200; - fx->frame_number = -4 * Random_GetControl() / 0x7FFF; + fx->frame_num = -4 * Random_GetControl() / 0x7FFF; fx->object_id = O_LAVA; Sound_Effect(SFX_LAVA_FOUNTAIN, &item->pos, SPM_NORMAL); } diff --git a/src/game/objects/traps/thors_hammer.c b/src/game/objects/traps/thors_hammer.c index bb58f9969..535473044 100644 --- a/src/game/objects/traps/thors_hammer.c +++ b/src/game/objects/traps/thors_hammer.c @@ -72,8 +72,7 @@ void ThorsHandle_Control(int16_t item_num) break; case THS_ACTIVE: { - int32_t frm = - item->frame_number - g_Anims[item->anim_number].frame_base; + int32_t frm = item->frame_num - g_Anims[item->anim_number].frame_base; if (frm > 30) { int32_t x = item->pos.x; int32_t z = item->pos.z; @@ -149,7 +148,7 @@ void ThorsHandle_Control(int16_t item_num) int16_t relative_anim = item->anim_number - g_Objects[item->object_id].anim_index; int16_t relative_frame = - item->frame_number - g_Anims[item->anim_number].frame_base; + item->frame_num - g_Anims[item->anim_number].frame_base; Item_SwitchToAnim(head_item, relative_anim, relative_frame); head_item->current_anim_state = item->current_anim_state; } diff --git a/src/game/savegame/savegame_bson.c b/src/game/savegame/savegame_bson.c index b5a5786cd..5dd61bff4 100644 --- a/src/game/savegame/savegame_bson.c +++ b/src/game/savegame/savegame_bson.c @@ -538,8 +538,8 @@ static bool Savegame_BSON_LoadItems( item_obj, "required_anim", item->required_anim_state); item->anim_number = json_object_get_int(item_obj, "anim_num", item->anim_number); - item->frame_number = - json_object_get_int(item_obj, "frame_num", item->frame_number); + item->frame_num = + json_object_get_int(item_obj, "frame_num", item->frame_num); } if (obj->save_hitpoints) { @@ -672,7 +672,7 @@ static bool SaveGame_BSON_LoadFx(struct json_array_s *fx_arr) json_object_get_int(fx_obj, "object_number", 0); int16_t speed = json_object_get_int(fx_obj, "speed", 0); int16_t fall_speed = json_object_get_int(fx_obj, "fall_speed", 0); - int16_t frame_number = json_object_get_int(fx_obj, "frame_number", 0); + int16_t frame_num = json_object_get_int(fx_obj, "frame_number", 0); int16_t counter = json_object_get_int(fx_obj, "counter", 0); int16_t shade = json_object_get_int(fx_obj, "shade", 0); @@ -685,7 +685,7 @@ static bool SaveGame_BSON_LoadFx(struct json_array_s *fx_arr) fx->object_id = object_id; fx->speed = speed; fx->fall_speed = fall_speed; - fx->frame_number = frame_number; + fx->frame_num = frame_num; fx->counter = counter; fx->shade = shade; } @@ -702,8 +702,7 @@ static bool Savegame_BSON_LoadArm(struct json_object_s *arm_obj, LARA_ARM *arm) return false; } - arm->frame_number = - json_object_get_int(arm_obj, "frame_num", arm->frame_number); + arm->frame_num = json_object_get_int(arm_obj, "frame_num", arm->frame_num); arm->lock = json_object_get_int(arm_obj, "lock", arm->lock); arm->rot.x = json_object_get_int(arm_obj, "x_rot", arm->rot.x); arm->rot.y = json_object_get_int(arm_obj, "y_rot", arm->rot.y); @@ -1068,7 +1067,7 @@ static struct json_array_s *Savegame_BSON_DumpItems(void) json_object_append_int( item_obj, "required_anim", item->required_anim_state); json_object_append_int(item_obj, "anim_num", item->anim_number); - json_object_append_int(item_obj, "frame_num", item->frame_number); + json_object_append_int(item_obj, "frame_num", item->frame_num); } if (obj->save_hitpoints) { @@ -1152,7 +1151,7 @@ static struct json_array_s *SaveGame_BSON_DumpFx(void) json_object_append_int(fx_obj, "object_number", fx->object_id); json_object_append_int(fx_obj, "speed", fx->speed); json_object_append_int(fx_obj, "fall_speed", fx->fall_speed); - json_object_append_int(fx_obj, "frame_number", fx->frame_number); + json_object_append_int(fx_obj, "frame_number", fx->frame_num); json_object_append_int(fx_obj, "counter", fx->counter); json_object_append_int(fx_obj, "shade", fx->shade); json_array_append_object(fx_arr, fx_obj); @@ -1165,7 +1164,7 @@ static struct json_object_s *Savegame_BSON_DumpArm(LARA_ARM *arm) { assert(arm); struct json_object_s *arm_obj = json_object_new(); - json_object_append_int(arm_obj, "frame_num", arm->frame_number); + json_object_append_int(arm_obj, "frame_num", arm->frame_num); json_object_append_int(arm_obj, "lock", arm->lock); json_object_append_int(arm_obj, "x_rot", arm->rot.x); json_object_append_int(arm_obj, "y_rot", arm->rot.y); diff --git a/src/game/savegame/savegame_legacy.c b/src/game/savegame/savegame_legacy.c index 3857e3d28..37dc47105 100644 --- a/src/game/savegame/savegame_legacy.c +++ b/src/game/savegame/savegame_legacy.c @@ -150,7 +150,7 @@ static bool Savegame_Legacy_NeedsBaconLaraFix(char *buffer) Savegame_Legacy_Read( &tmp_item.required_anim_state, sizeof(int16_t)); Savegame_Legacy_Read(&tmp_item.anim_number, sizeof(int16_t)); - Savegame_Legacy_Read(&tmp_item.frame_number, sizeof(int16_t)); + Savegame_Legacy_Read(&tmp_item.frame_num, sizeof(int16_t)); } if (obj->save_hitpoints) { Savegame_Legacy_Read(&tmp_item.hit_points, sizeof(int16_t)); @@ -277,7 +277,7 @@ static void Savegame_Legacy_WriteArm(LARA_ARM *arm) const int32_t frame_base = level_info->anim_frame_offsets[arm->frame_base - g_AnimFrames]; Savegame_Legacy_Write(&frame_base, sizeof(int32_t)); - Savegame_Legacy_Write(&arm->frame_number, sizeof(int16_t)); + Savegame_Legacy_Write(&arm->frame_num, sizeof(int16_t)); Savegame_Legacy_Write(&arm->lock, sizeof(int16_t)); Savegame_Legacy_Write(&arm->rot.y, sizeof(PHD_ANGLE)); Savegame_Legacy_Write(&arm->rot.x, sizeof(PHD_ANGLE)); @@ -378,7 +378,7 @@ static void Savegame_Legacy_ReadArm(LARA_ARM *arm) // frame_base is superfluous Savegame_Legacy_Skip(sizeof(int32_t)); - Savegame_Legacy_Read(&arm->frame_number, sizeof(int16_t)); + Savegame_Legacy_Read(&arm->frame_num, sizeof(int16_t)); Savegame_Legacy_Read(&arm->lock, sizeof(int16_t)); Savegame_Legacy_Read(&arm->rot.y, sizeof(PHD_ANGLE)); Savegame_Legacy_Read(&arm->rot.x, sizeof(PHD_ANGLE)); @@ -590,7 +590,7 @@ bool Savegame_Legacy_LoadFromFile(MYFILE *fp, GAME_INFO *game_info) Savegame_Legacy_Read(&item->goal_anim_state, sizeof(int16_t)); Savegame_Legacy_Read(&item->required_anim_state, sizeof(int16_t)); Savegame_Legacy_Read(&item->anim_number, sizeof(int16_t)); - Savegame_Legacy_Read(&item->frame_number, sizeof(int16_t)); + Savegame_Legacy_Read(&item->frame_num, sizeof(int16_t)); } if (obj->save_hitpoints) { @@ -765,7 +765,7 @@ void Savegame_Legacy_SaveToFile(MYFILE *fp, GAME_INFO *game_info) Savegame_Legacy_Write(&item->goal_anim_state, sizeof(int16_t)); Savegame_Legacy_Write(&item->required_anim_state, sizeof(int16_t)); Savegame_Legacy_Write(&item->anim_number, sizeof(int16_t)); - Savegame_Legacy_Write(&item->frame_number, sizeof(int16_t)); + Savegame_Legacy_Write(&item->frame_num, sizeof(int16_t)); } if (obj->save_hitpoints) { diff --git a/src/global/types.h b/src/global/types.h index cbcecd576..1af832355 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1289,7 +1289,7 @@ typedef struct { int16_t goal_anim_state; int16_t required_anim_state; int16_t anim_number; - int16_t frame_number; + int16_t frame_num; int16_t room_number; int16_t next_item; int16_t next_active; @@ -1350,7 +1350,7 @@ typedef struct FRAME_INFO { typedef struct LARA_ARM { FRAME_INFO *frame_base; - int16_t frame_number; + int16_t frame_num; int16_t lock; XYZ_16 rot; uint16_t flash_gun; @@ -1400,7 +1400,7 @@ typedef struct FX_INFO { int16_t next_free; int16_t speed; int16_t fall_speed; - int16_t frame_number; + int16_t frame_num; int16_t counter; int16_t shade; From dfdc8f461f6a59d5be80dc076ad6ddcc3c1fa64c Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:03:30 +0200 Subject: [PATCH 3/9] types: use consistent naming for anim numbers --- src/game/creature.c | 5 ++-- src/game/items.c | 34 ++++++++++++------------- src/game/lara/lara.c | 6 ++--- src/game/lara/lara_state.c | 5 ++-- src/game/objects/common.c | 2 +- src/game/objects/creatures/bacon_lara.c | 6 ++--- src/game/objects/creatures/bat.c | 5 ++-- src/game/objects/creatures/crocodile.c | 2 +- src/game/objects/creatures/skate_kid.c | 4 +-- src/game/objects/creatures/statue.c | 3 +-- src/game/objects/traps/rolling_ball.c | 3 +-- src/game/objects/traps/thors_hammer.c | 6 ++--- src/game/phase/phase_cutscene.c | 2 +- src/game/savegame/savegame_bson.c | 6 ++--- src/game/savegame/savegame_legacy.c | 6 ++--- src/global/types.h | 2 +- 16 files changed, 45 insertions(+), 52 deletions(-) diff --git a/src/game/creature.c b/src/game/creature.c index 32e8199d7..d2990ab7b 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -750,7 +750,7 @@ static bool Creature_SwitchToWater( // water creature. item->object_id = info->water.id; Item_SwitchToAnim(item, info->water.active_anim, 0); - item->current_anim_state = g_Anims[item->anim_number].current_anim_state; + item->current_anim_state = g_Anims[item->anim_num].current_anim_state; item->goal_anim_state = item->current_anim_state; item->pos.y = *wh; @@ -772,8 +772,7 @@ static bool Creature_SwitchToLand( if (item->hit_points > 0) { Item_SwitchToAnim(item, info->land.active_anim, 0); - item->current_anim_state = - g_Anims[item->anim_number].current_anim_state; + item->current_anim_state = g_Anims[item->anim_num].current_anim_state; item->goal_anim_state = item->current_anim_state; } else { diff --git a/src/game/items.c b/src/game/items.c index 7744cd09c..db36619fd 100644 --- a/src/game/items.c +++ b/src/game/items.c @@ -110,7 +110,7 @@ void Item_Initialise(int16_t item_num) OBJECT_INFO *object = &g_Objects[item->object_id]; Item_SwitchToAnim(item, 0, 0); - item->current_anim_state = g_Anims[item->anim_number].current_anim_state; + item->current_anim_state = g_Anims[item->anim_num].current_anim_state; item->goal_anim_state = item->current_anim_state; item->required_anim_state = 0; item->rot.x = 0; @@ -550,8 +550,7 @@ void Item_Translate(ITEM_INFO *item, int32_t x, int32_t y, int32_t z) bool Item_TestAnimEqual(ITEM_INFO *item, int16_t anim_index) { - return item->anim_number - == g_Objects[item->object_id].anim_index + anim_index; + return item->anim_num == g_Objects[item->object_id].anim_index + anim_index; } void Item_SwitchToAnim(ITEM_INFO *item, int16_t anim_index, int16_t frame) @@ -563,11 +562,11 @@ void Item_SwitchToObjAnim( ITEM_INFO *item, int16_t anim_index, int16_t frame, GAME_OBJECT_ID object_id) { - item->anim_number = g_Objects[object_id].anim_index + anim_index; + item->anim_num = g_Objects[object_id].anim_index + anim_index; if (frame < 0) { - item->frame_num = g_Anims[item->anim_number].frame_end + frame + 1; + item->frame_num = g_Anims[item->anim_num].frame_end + frame + 1; } else { - item->frame_num = g_Anims[item->anim_number].frame_base + frame; + item->frame_num = g_Anims[item->anim_num].frame_base + frame; } } @@ -576,13 +575,13 @@ void Item_Animate(ITEM_INFO *item) item->touch_bits = 0; item->hit_status = 0; - ANIM_STRUCT *anim = &g_Anims[item->anim_number]; + ANIM_STRUCT *anim = &g_Anims[item->anim_num]; item->frame_num++; if (anim->number_changes > 0) { if (Item_GetAnimChange(item, anim)) { - anim = &g_Anims[item->anim_number]; + anim = &g_Anims[item->anim_num]; item->current_anim_state = anim->current_anim_state; if (item->required_anim_state == item->current_anim_state) { @@ -620,10 +619,10 @@ void Item_Animate(ITEM_INFO *item) } } - item->anim_number = anim->jump_anim_num; + item->anim_num = anim->jump_anim_num; item->frame_num = anim->jump_frame_num; - anim = &g_Anims[item->anim_number]; + anim = &g_Anims[item->anim_num]; item->current_anim_state = anim->current_anim_state; item->goal_anim_state = item->current_anim_state; if (item->required_anim_state == item->current_anim_state) { @@ -687,11 +686,10 @@ bool Item_GetAnimChange(ITEM_INFO *item, ANIM_STRUCT *anim) for (int j = 0; j < change->number_ranges; j++, range++) { if (Item_TestFrameRange( item, - range->start_frame - - g_Anims[item->anim_number].frame_base, + range->start_frame - g_Anims[item->anim_num].frame_base, range->end_frame - - g_Anims[item->anim_number].frame_base)) { - item->anim_number = range->link_anim_num; + - g_Anims[item->anim_num].frame_base)) { + item->anim_num = range->link_anim_num; item->frame_num = range->link_frame_num; return true; } @@ -783,7 +781,7 @@ const BOUNDS_16 *Item_GetBoundsAccurate(const ITEM_INFO *item) int32_t Item_GetFrames( const ITEM_INFO *item, FRAME_INFO *frmptr[], int32_t *rate) { - const ANIM_STRUCT *anim = &g_Anims[item->anim_number]; + const ANIM_STRUCT *anim = &g_Anims[item->anim_num]; const int32_t cur_frame_num = item->frame_num - anim->frame_base; const int32_t last_frame_num = anim->frame_end - anim->frame_base; @@ -845,12 +843,12 @@ void Item_TakeDamage(ITEM_INFO *item, int16_t damage, bool hit_status) bool Item_TestFrameEqual(ITEM_INFO *item, int16_t frame) { return Anim_TestAbsFrameEqual( - item->frame_num, g_Anims[item->anim_number].frame_base + frame); + item->frame_num, g_Anims[item->anim_num].frame_base + frame); } bool Item_TestFrameRange(ITEM_INFO *item, int16_t start, int16_t end) { return Anim_TestAbsFrameRange( - item->frame_num, g_Anims[item->anim_number].frame_base + start, - g_Anims[item->anim_number].frame_base + end); + item->frame_num, g_Anims[item->anim_num].frame_base + start, + g_Anims[item->anim_num].frame_base + end); } diff --git a/src/game/lara/lara.c b/src/game/lara/lara.c index a659627ad..4c1782a97 100644 --- a/src/game/lara/lara.c +++ b/src/game/lara/lara.c @@ -226,9 +226,9 @@ void Lara_Animate(ITEM_INFO *item) ANIM_STRUCT *anim; item->frame_num++; - anim = &g_Anims[item->anim_number]; + anim = &g_Anims[item->anim_num]; if (anim->number_changes > 0 && Item_GetAnimChange(item, anim)) { - anim = &g_Anims[item->anim_number]; + anim = &g_Anims[item->anim_num]; item->current_anim_state = anim->current_anim_state; } @@ -265,7 +265,7 @@ void Lara_Animate(ITEM_INFO *item) } } - item->anim_number = anim->jump_anim_num; + item->anim_num = anim->jump_anim_num; item->frame_num = anim->jump_frame_num; anim = &g_Anims[anim->jump_anim_num]; diff --git a/src/game/lara/lara_state.c b/src/game/lara/lara_state.c index 27675e108..eee3cac17 100644 --- a/src/game/lara/lara_state.c +++ b/src/game/lara/lara_state.c @@ -123,8 +123,7 @@ void Lara_State_Run(ITEM_INFO *item, COLL_INFO *coll) } if (g_Config.enable_tr2_jumping) { - int16_t anim = - item->anim_number - g_Objects[item->object_id].anim_index; + int16_t anim = item->anim_num - g_Objects[item->object_id].anim_index; if (anim == LA_RUN_START) { m_JumpPermitted = false; } else if ( @@ -679,7 +678,7 @@ void Lara_State_DieMidas(ITEM_INFO *item, COLL_INFO *coll) coll->enable_spaz = 0; coll->enable_baddie_push = 0; - int frm = item->frame_num - g_Anims[item->anim_number].frame_base; + int frm = item->frame_num - g_Anims[item->anim_num].frame_base; switch (frm) { case 5: g_Lara.mesh_effects |= (1 << LM_FOOT_L); diff --git a/src/game/objects/common.c b/src/game/objects/common.c index b58bdf883..3ead2fbf8 100644 --- a/src/game/objects/common.c +++ b/src/game/objects/common.c @@ -335,7 +335,7 @@ void Object_DrawPickupItem(ITEM_INFO *item) OBJECT_INFO *object = &g_Objects[item_num_option]; - const FRAME_INFO *frame = g_Anims[item->anim_number].frame_ptr; + const FRAME_INFO *frame = g_Anims[item->anim_num].frame_ptr; // Restore the old frame number in case we need to get the sprite again. item->frame_num = old_frame_num; diff --git a/src/game/objects/creatures/bacon_lara.c b/src/game/objects/creatures/bacon_lara.c index 067f7039f..4e6ad16d9 100644 --- a/src/game/objects/creatures/bacon_lara.c +++ b/src/game/objects/creatures/bacon_lara.c @@ -79,10 +79,10 @@ void BaconLara_Control(int16_t item_num) int32_t lh = Room_GetHeight( sector, g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z); - int16_t relative_anim = g_LaraItem->anim_number - - g_Objects[g_LaraItem->object_id].anim_index; + int16_t relative_anim = + g_LaraItem->anim_num - g_Objects[g_LaraItem->object_id].anim_index; int16_t relative_frame = - g_LaraItem->frame_num - g_Anims[g_LaraItem->anim_number].frame_base; + g_LaraItem->frame_num - g_Anims[g_LaraItem->anim_num].frame_base; Item_SwitchToObjAnim(item, relative_anim, relative_frame, O_LARA); item->pos.x = x; item->pos.y = y; diff --git a/src/game/objects/creatures/bat.c b/src/game/objects/creatures/bat.c index 5461ca0c2..b00353dd0 100644 --- a/src/game/objects/creatures/bat.c +++ b/src/game/objects/creatures/bat.c @@ -50,9 +50,8 @@ static void Bat_FixEmbeddedPosition(int16_t item_num) // The bats animation and frame have to be changed to the hanging // one to properly measure them. Save it so it can be restored // after. - int16_t old_anim = - item->anim_number - g_Objects[item->object_id].anim_index; - int16_t old_frame = item->frame_num - g_Anims[item->anim_number].frame_base; + int16_t old_anim = item->anim_num - g_Objects[item->object_id].anim_index; + int16_t old_frame = item->frame_num - g_Anims[item->anim_num].frame_base; Item_SwitchToAnim(item, 0, 0); const BOUNDS_16 *const bounds = Item_GetBoundsAccurate(item); diff --git a/src/game/objects/creatures/crocodile.c b/src/game/objects/creatures/crocodile.c index e37b06cfb..053f319c4 100644 --- a/src/game/objects/creatures/crocodile.c +++ b/src/game/objects/creatures/crocodile.c @@ -300,7 +300,7 @@ void Alligator_Control(int16_t item_num) if (item->frame_num == (g_Config.fix_alligator_ai ? ALLIGATOR_BITE_AF - : g_Anims[item->anim_number].frame_base)) { + : g_Anims[item->anim_num].frame_base)) { item->required_anim_state = ALLIGATOR_EMPTY; } diff --git a/src/game/objects/creatures/skate_kid.c b/src/game/objects/creatures/skate_kid.c index 1d9cb0d16..1c00c19ba 100644 --- a/src/game/objects/creatures/skate_kid.c +++ b/src/game/objects/creatures/skate_kid.c @@ -172,9 +172,9 @@ void SkateKid_Draw(ITEM_INFO *item) Object_DrawAnimatingItem(item); int16_t relative_anim = - item->anim_number - g_Objects[item->object_id].anim_index; + item->anim_num - g_Objects[item->object_id].anim_index; int16_t relative_frame = - item->frame_num - g_Anims[item->anim_number].frame_base; + item->frame_num - g_Anims[item->anim_num].frame_base; item->object_id = O_SKATEBOARD; Item_SwitchToAnim(item, relative_anim, relative_frame); Object_DrawAnimatingItem(item); diff --git a/src/game/objects/creatures/statue.c b/src/game/objects/creatures/statue.c index 9da74a37d..0c73abd11 100644 --- a/src/game/objects/creatures/statue.c +++ b/src/game/objects/creatures/statue.c @@ -50,8 +50,7 @@ void Statue_Initialise(int16_t item_num) Item_Initialise(centaur_item_num); Item_SwitchToAnim(centaur, CENTAUR_REARING_ANIM, CENTAUR_REARING_FRAME); - centaur->current_anim_state = - g_Anims[centaur->anim_number].current_anim_state; + centaur->current_anim_state = g_Anims[centaur->anim_num].current_anim_state; centaur->goal_anim_state = centaur->current_anim_state; centaur->rot.y = item->rot.y; diff --git a/src/game/objects/traps/rolling_ball.c b/src/game/objects/traps/rolling_ball.c index 97c448d03..587e66a8b 100644 --- a/src/game/objects/traps/rolling_ball.c +++ b/src/game/objects/traps/rolling_ball.c @@ -104,8 +104,7 @@ void RollingBall_Control(int16_t item_num) item->current_anim_state = TRAP_SET; item->goal_anim_state = TRAP_SET; Item_SwitchToAnim(item, 0, 0); - item->current_anim_state = - g_Anims[item->anim_number].current_anim_state; + item->current_anim_state = g_Anims[item->anim_num].current_anim_state; item->goal_anim_state = item->current_anim_state; item->required_anim_state = TRAP_SET; Item_RemoveActive(item_num); diff --git a/src/game/objects/traps/thors_hammer.c b/src/game/objects/traps/thors_hammer.c index 535473044..66ceae30a 100644 --- a/src/game/objects/traps/thors_hammer.c +++ b/src/game/objects/traps/thors_hammer.c @@ -72,7 +72,7 @@ void ThorsHandle_Control(int16_t item_num) break; case THS_ACTIVE: { - int32_t frm = item->frame_num - g_Anims[item->anim_number].frame_base; + int32_t frm = item->frame_num - g_Anims[item->anim_num].frame_base; if (frm > 30) { int32_t x = item->pos.x; int32_t z = item->pos.z; @@ -146,9 +146,9 @@ void ThorsHandle_Control(int16_t item_num) ITEM_INFO *head_item = item->data; int16_t relative_anim = - item->anim_number - g_Objects[item->object_id].anim_index; + item->anim_num - g_Objects[item->object_id].anim_index; int16_t relative_frame = - item->frame_num - g_Anims[item->anim_number].frame_base; + item->frame_num - g_Anims[item->anim_num].frame_base; Item_SwitchToAnim(head_item, relative_anim, relative_frame); head_item->current_anim_state = item->current_anim_state; } diff --git a/src/game/phase/phase_cutscene.c b/src/game/phase/phase_cutscene.c index b4e4138ac..4d152ecda 100644 --- a/src/game/phase/phase_cutscene.c +++ b/src/game/phase/phase_cutscene.c @@ -57,7 +57,7 @@ static void Phase_Cutscene_InitialiseHair(int32_t level_num) Lara_Initialise(level_num); Item_SwitchToObjAnim(g_LaraItem, 0, 0, lara_type); - ANIM_STRUCT *cut_anim = &g_Anims[g_LaraItem->anim_number]; + ANIM_STRUCT *cut_anim = &g_Anims[g_LaraItem->anim_num]; g_LaraItem->current_anim_state = g_LaraItem->goal_anim_state = g_LaraItem->required_anim_state = cut_anim->current_anim_state; } diff --git a/src/game/savegame/savegame_bson.c b/src/game/savegame/savegame_bson.c index 5dd61bff4..454d978da 100644 --- a/src/game/savegame/savegame_bson.c +++ b/src/game/savegame/savegame_bson.c @@ -536,8 +536,8 @@ static bool Savegame_BSON_LoadItems( item_obj, "goal_anim", item->goal_anim_state); item->required_anim_state = json_object_get_int( item_obj, "required_anim", item->required_anim_state); - item->anim_number = - json_object_get_int(item_obj, "anim_num", item->anim_number); + item->anim_num = + json_object_get_int(item_obj, "anim_num", item->anim_num); item->frame_num = json_object_get_int(item_obj, "frame_num", item->frame_num); } @@ -1066,7 +1066,7 @@ static struct json_array_s *Savegame_BSON_DumpItems(void) item_obj, "goal_anim", item->goal_anim_state); json_object_append_int( item_obj, "required_anim", item->required_anim_state); - json_object_append_int(item_obj, "anim_num", item->anim_number); + json_object_append_int(item_obj, "anim_num", item->anim_num); json_object_append_int(item_obj, "frame_num", item->frame_num); } diff --git a/src/game/savegame/savegame_legacy.c b/src/game/savegame/savegame_legacy.c index 37dc47105..9752f980a 100644 --- a/src/game/savegame/savegame_legacy.c +++ b/src/game/savegame/savegame_legacy.c @@ -149,7 +149,7 @@ static bool Savegame_Legacy_NeedsBaconLaraFix(char *buffer) Savegame_Legacy_Read(&tmp_item.goal_anim_state, sizeof(int16_t)); Savegame_Legacy_Read( &tmp_item.required_anim_state, sizeof(int16_t)); - Savegame_Legacy_Read(&tmp_item.anim_number, sizeof(int16_t)); + Savegame_Legacy_Read(&tmp_item.anim_num, sizeof(int16_t)); Savegame_Legacy_Read(&tmp_item.frame_num, sizeof(int16_t)); } if (obj->save_hitpoints) { @@ -589,7 +589,7 @@ bool Savegame_Legacy_LoadFromFile(MYFILE *fp, GAME_INFO *game_info) Savegame_Legacy_Read(&item->current_anim_state, sizeof(int16_t)); Savegame_Legacy_Read(&item->goal_anim_state, sizeof(int16_t)); Savegame_Legacy_Read(&item->required_anim_state, sizeof(int16_t)); - Savegame_Legacy_Read(&item->anim_number, sizeof(int16_t)); + Savegame_Legacy_Read(&item->anim_num, sizeof(int16_t)); Savegame_Legacy_Read(&item->frame_num, sizeof(int16_t)); } @@ -764,7 +764,7 @@ void Savegame_Legacy_SaveToFile(MYFILE *fp, GAME_INFO *game_info) Savegame_Legacy_Write(&item->current_anim_state, sizeof(int16_t)); Savegame_Legacy_Write(&item->goal_anim_state, sizeof(int16_t)); Savegame_Legacy_Write(&item->required_anim_state, sizeof(int16_t)); - Savegame_Legacy_Write(&item->anim_number, sizeof(int16_t)); + Savegame_Legacy_Write(&item->anim_num, sizeof(int16_t)); Savegame_Legacy_Write(&item->frame_num, sizeof(int16_t)); } diff --git a/src/global/types.h b/src/global/types.h index 1af832355..2544922fe 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1288,7 +1288,7 @@ typedef struct { int16_t current_anim_state; int16_t goal_anim_state; int16_t required_anim_state; - int16_t anim_number; + int16_t anim_num; int16_t frame_num; int16_t room_number; int16_t next_item; From 268f7446abfcd2439a6d9437b11cc78c52090c59 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:03:51 +0200 Subject: [PATCH 4/9] types: use consistent naming for room numbers --- src/game/box.c | 4 +- src/game/box.h | 2 +- src/game/camera.c | 58 ++++++++++---------- src/game/carrier.c | 16 +++--- src/game/collide.c | 4 +- src/game/collide.h | 2 +- src/game/console_cmd.c | 2 +- src/game/creature.c | 21 ++++--- src/game/effect_routines/bubbles.c | 4 +- src/game/effects.c | 10 ++-- src/game/effects/exploding_death.c | 8 +-- src/game/effects/gun.c | 4 +- src/game/effects/gunshot.c | 6 +- src/game/game/game_draw.c | 3 +- src/game/gun/gun_misc.c | 12 ++-- src/game/inject.c | 6 +- src/game/interpolation.c | 6 +- src/game/items.c | 20 +++---- src/game/lara/lara.c | 8 +-- src/game/lara/lara_cheat.c | 6 +- src/game/lara/lara_col.c | 4 +- src/game/lara/lara_control.c | 8 +-- src/game/lara/lara_hair.c | 13 ++--- src/game/lara/lara_misc.c | 12 ++-- src/game/lara/lara_state.c | 2 +- src/game/level.c | 2 +- src/game/los.c | 26 ++++----- src/game/lot.c | 2 +- src/game/objects/common.c | 6 +- src/game/objects/creatures/ape.c | 4 +- src/game/objects/creatures/bacon_lara.c | 8 +-- src/game/objects/creatures/bat.c | 4 +- src/game/objects/creatures/crocodile.c | 4 +- src/game/objects/creatures/cutscene_player.c | 2 +- src/game/objects/creatures/natla.c | 4 +- src/game/objects/creatures/pierre.c | 4 +- src/game/objects/creatures/pod.c | 2 +- src/game/objects/creatures/rat.c | 2 +- src/game/objects/creatures/statue.c | 2 +- src/game/objects/creatures/torso.c | 2 +- src/game/objects/creatures/trex.c | 4 +- src/game/objects/effects/body_part.c | 4 +- src/game/objects/effects/bubble.c | 4 +- src/game/objects/effects/missile.c | 4 +- src/game/objects/effects/ricochet.c | 2 +- src/game/objects/effects/splash.c | 4 +- src/game/objects/effects/twinkle.c | 4 +- src/game/objects/effects/waterfall.c | 2 +- src/game/objects/general/bridge.c | 2 +- src/game/objects/general/cog.c | 4 +- src/game/objects/general/door.c | 4 +- src/game/objects/general/pickup.c | 2 +- src/game/objects/general/scion.c | 2 +- src/game/objects/traps/damocles_sword.c | 2 +- src/game/objects/traps/dart.c | 12 ++-- src/game/objects/traps/falling_block.c | 4 +- src/game/objects/traps/flame.c | 10 ++-- src/game/objects/traps/lava.c | 16 +++--- src/game/objects/traps/lightning_emitter.c | 2 +- src/game/objects/traps/movable_block.c | 14 ++--- src/game/objects/traps/pendulum.c | 6 +- src/game/objects/traps/rolling_ball.c | 20 +++---- src/game/objects/traps/sliding_pillar.c | 4 +- src/game/objects/traps/spikes.c | 2 +- src/game/objects/traps/teeth_trap.c | 3 +- src/game/objects/traps/thors_hammer.c | 2 +- src/game/output.c | 2 +- src/game/phase/phase_demo.c | 2 +- src/game/room.c | 4 +- src/game/room_draw.c | 4 +- src/game/savegame/savegame.c | 2 +- src/game/savegame/savegame_bson.c | 13 ++--- src/game/savegame/savegame_legacy.c | 4 +- src/game/sound.c | 2 +- src/global/types.h | 8 +-- 75 files changed, 244 insertions(+), 251 deletions(-) diff --git a/src/game/box.c b/src/game/box.c index 4745bcbcc..47da9ecaa 100644 --- a/src/game/box.c +++ b/src/game/box.c @@ -424,9 +424,9 @@ TARGET_TYPE Box_CalculateTarget(XYZ_32 *target, ITEM_INFO *item, LOT_INFO *LOT) bool Box_BadFloor( int32_t x, int32_t y, int32_t z, int16_t box_height, int16_t next_height, - int16_t room_number, LOT_INFO *LOT) + int16_t room_num, LOT_INFO *LOT) { - const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_number); + const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num); if (sector->box == NO_BOX) { return true; } diff --git a/src/game/box.h b/src/game/box.h index a276d3cc2..2ccd01a2d 100644 --- a/src/game/box.h +++ b/src/game/box.h @@ -14,4 +14,4 @@ bool Box_ValidBox(ITEM_INFO *item, int16_t zone_number, int16_t box_number); TARGET_TYPE Box_CalculateTarget(XYZ_32 *target, ITEM_INFO *item, LOT_INFO *LOT); bool Box_BadFloor( int32_t x, int32_t y, int32_t z, int16_t box_height, int16_t next_height, - int16_t room_number, LOT_INFO *LOT); + int16_t room_num, LOT_INFO *LOT); diff --git a/src/game/camera.c b/src/game/camera.c index 03431eb6b..ff61909ed 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -60,25 +60,24 @@ static int32_t Camera_ShiftClamp(GAME_VECTOR *pos, int32_t clamp) int32_t y = pos->y; int32_t z = pos->z; - const SECTOR_INFO *const sector = - Room_GetSector(x, y, z, &pos->room_number); + const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &pos->room_num); const BOX_INFO *const box = &g_Boxes[sector->box]; if (z < box->left + clamp - && Camera_BadPosition(x, y, z - clamp, pos->room_number)) { + && Camera_BadPosition(x, y, z - clamp, pos->room_num)) { pos->z = box->left + clamp; } else if ( z > box->right - clamp - && Camera_BadPosition(x, y, z + clamp, pos->room_number)) { + && Camera_BadPosition(x, y, z + clamp, pos->room_num)) { pos->z = box->right - clamp; } if (x < box->top + clamp - && Camera_BadPosition(x - clamp, y, z, pos->room_number)) { + && Camera_BadPosition(x - clamp, y, z, pos->room_num)) { pos->x = box->top + clamp; } else if ( x > box->bottom - clamp - && Camera_BadPosition(x + clamp, y, z, pos->room_number)) { + && Camera_BadPosition(x + clamp, y, z, pos->room_num)) { pos->x = box->bottom - clamp; } @@ -107,14 +106,14 @@ static void Camera_SmartShift( { LOS_Check(&g_Camera.target, ideal); - const ROOM_INFO *r = &g_RoomInfo[g_Camera.target.room_number]; + const ROOM_INFO *r = &g_RoomInfo[g_Camera.target.room_num]; int32_t z_sector = (g_Camera.target.z - r->z) >> WALL_SHIFT; int32_t x_sector = (g_Camera.target.x - r->x) >> WALL_SHIFT; const int16_t item_box = r->sectors[z_sector + x_sector * r->z_size].box; BOX_INFO *box = &g_Boxes[item_box]; - r = &g_RoomInfo[ideal->room_number]; + r = &g_RoomInfo[ideal->room_num]; z_sector = (ideal->z - r->z) >> WALL_SHIFT; x_sector = (ideal->x - r->x) >> WALL_SHIFT; @@ -132,7 +131,7 @@ static void Camera_SmartShift( int32_t test = (ideal->z - WALL_L) | (WALL_L - 1); bool bad_left = - Camera_BadPosition(ideal->x, ideal->y, test, ideal->room_number); + Camera_BadPosition(ideal->x, ideal->y, test, ideal->room_num); if (!bad_left) { camera_box = r->sectors[z_sector - 1 + x_sector * r->z_size].box; if (camera_box != NO_ITEM && g_Boxes[camera_box].left < left) { @@ -142,7 +141,7 @@ static void Camera_SmartShift( test = (ideal->z + WALL_L) & (~(WALL_L - 1)); bool bad_right = - Camera_BadPosition(ideal->x, ideal->y, test, ideal->room_number); + Camera_BadPosition(ideal->x, ideal->y, test, ideal->room_num); if (!bad_right) { camera_box = r->sectors[z_sector + 1 + x_sector * r->z_size].box; if (camera_box != NO_ITEM && g_Boxes[camera_box].right > right) { @@ -152,7 +151,7 @@ static void Camera_SmartShift( test = (ideal->x - WALL_L) | (WALL_L - 1); bool bad_top = - Camera_BadPosition(test, ideal->y, ideal->z, ideal->room_number); + Camera_BadPosition(test, ideal->y, ideal->z, ideal->room_num); if (!bad_top) { camera_box = r->sectors[z_sector + (x_sector - 1) * r->z_size].box; if (camera_box != NO_ITEM && g_Boxes[camera_box].top < top) { @@ -162,7 +161,7 @@ static void Camera_SmartShift( test = (ideal->x + WALL_L) & (~(WALL_L - 1)); bool bad_bottom = - Camera_BadPosition(test, ideal->y, ideal->z, ideal->room_number); + Camera_BadPosition(test, ideal->y, ideal->z, ideal->room_num); if (!bad_bottom) { camera_box = r->sectors[z_sector + (x_sector + 1) * r->z_size].box; if (camera_box != NO_ITEM && g_Boxes[camera_box].bottom > bottom) { @@ -227,7 +226,7 @@ static void Camera_SmartShift( } if (!noclip) { - Room_GetSector(ideal->x, ideal->y, ideal->z, &ideal->room_number); + Room_GetSector(ideal->x, ideal->y, ideal->z, &ideal->room_num); } } @@ -301,13 +300,12 @@ static void Camera_Move(GAME_VECTOR *ideal, int32_t speed) g_Camera.pos.x += (ideal->x - g_Camera.pos.x) / speed; g_Camera.pos.z += (ideal->z - g_Camera.pos.z) / speed; g_Camera.pos.y += (ideal->y - g_Camera.pos.y) / speed; - g_Camera.pos.room_number = ideal->room_number; + g_Camera.pos.room_num = ideal->room_num; g_ChunkyFlag = false; const SECTOR_INFO *sector = Room_GetSector( - g_Camera.pos.x, g_Camera.pos.y, g_Camera.pos.z, - &g_Camera.pos.room_number); + g_Camera.pos.x, g_Camera.pos.y, g_Camera.pos.z, &g_Camera.pos.room_num); int32_t height = Room_GetHeight(sector, g_Camera.pos.x, g_Camera.pos.y, g_Camera.pos.z) - GROUND_SHIFT; @@ -316,7 +314,7 @@ static void Camera_Move(GAME_VECTOR *ideal, int32_t speed) LOS_Check(&g_Camera.target, &g_Camera.pos); sector = Room_GetSector( g_Camera.pos.x, g_Camera.pos.y, g_Camera.pos.z, - &g_Camera.pos.room_number); + &g_Camera.pos.room_num); height = Room_GetHeight( sector, g_Camera.pos.x, g_Camera.pos.y, g_Camera.pos.z) - GROUND_SHIFT; @@ -445,7 +443,7 @@ static void Camera_AdjustMusicVolume(const bool underwater) void Camera_Reset(void) { - g_Camera.pos.room_number = NO_ROOM; + g_Camera.pos.room_num = NO_ROOM; } void Camera_ResetPosition(void) @@ -456,12 +454,12 @@ void Camera_ResetPosition(void) g_Camera.target.x = g_LaraItem->pos.x; g_Camera.target.y = g_Camera.shift; g_Camera.target.z = g_LaraItem->pos.z; - g_Camera.target.room_number = g_LaraItem->room_number; + g_Camera.target.room_num = g_LaraItem->room_num; g_Camera.pos.x = g_Camera.target.x; g_Camera.pos.y = g_Camera.target.y; g_Camera.pos.z = g_Camera.target.z - 100; - g_Camera.pos.room_number = g_Camera.target.room_number; + g_Camera.pos.room_num = g_Camera.target.room_num; g_Camera.target_distance = WALL_L * 3 / 2; g_Camera.item = NULL; @@ -503,7 +501,7 @@ void Camera_Chase(ITEM_INFO *item) PHD_ANGLE angle = item->rot.y + g_Camera.target_angle; ideal.x = g_Camera.target.x - (distance * Math_Sin(angle) >> W2V_SHIFT); ideal.z = g_Camera.target.z - (distance * Math_Cos(angle) >> W2V_SHIFT); - ideal.room_number = g_Camera.pos.room_number; + ideal.room_num = g_Camera.pos.room_num; Camera_SmartShift(&ideal, Camera_Shift); @@ -544,7 +542,7 @@ void Camera_Combat(ITEM_INFO *item) >> W2V_SHIFT); ideal.z = g_Camera.target.z - (distance * Math_Cos(g_Camera.target_angle) >> W2V_SHIFT); - ideal.room_number = g_Camera.pos.room_number; + ideal.room_num = g_Camera.pos.room_num; Camera_SmartShift(&ideal, Camera_Shift); Camera_Move(&ideal, g_Camera.speed); @@ -578,7 +576,7 @@ void Camera_Look(ITEM_INFO *item) if (Camera_BadPosition( g_Camera.target.x, g_Camera.target.y, g_Camera.target.z, - g_Camera.target.room_number)) { + g_Camera.target.room_num)) { g_Camera.target.x = item->pos.x; g_Camera.target.z = item->pos.z; } @@ -592,7 +590,7 @@ void Camera_Look(ITEM_INFO *item) >> W2V_SHIFT); ideal.z = g_Camera.target.z - (distance * Math_Cos(g_Camera.target_angle) >> W2V_SHIFT); - ideal.room_number = g_Camera.pos.room_number; + ideal.room_num = g_Camera.pos.room_num; Camera_SmartShift(&ideal, Camera_Clip); @@ -611,7 +609,7 @@ void Camera_Fixed(void) ideal.x = fixed->x; ideal.y = fixed->y; ideal.z = fixed->z; - ideal.room_number = fixed->data; + ideal.room_num = fixed->data; g_Camera.fixed_camera = 1; @@ -694,7 +692,7 @@ void Camera_Update(void) if (g_Camera.type == CAM_LOOK || g_Camera.type == CAM_COMBAT) { y -= STEP_L; - g_Camera.target.room_number = item->room_number; + g_Camera.target.room_num = item->room_num; if (g_Camera.fixed_camera) { g_Camera.target.y = y; @@ -722,7 +720,7 @@ void Camera_Update(void) g_Camera.target.x += Math_Sin(item->rot.y) * shift >> W2V_SHIFT; } - g_Camera.target.room_number = item->room_number; + g_Camera.target.room_num = item->room_num; if (g_Camera.fixed_camera != fixed_camera) { g_Camera.target.y = y; @@ -735,7 +733,7 @@ void Camera_Update(void) const SECTOR_INFO *const sector = Room_GetSector( g_Camera.target.x, g_Camera.target.y, g_Camera.target.z, - &g_Camera.target.room_number); + &g_Camera.target.room_num); if (g_Camera.target.y > Room_GetHeight( sector, g_Camera.target.x, g_Camera.target.y, g_Camera.target.z)) { @@ -779,11 +777,11 @@ void Camera_Update(void) static void Camera_EnsureEnvironment(void) { - if (g_Camera.pos.room_number == NO_ROOM) { + if (g_Camera.pos.room_num == NO_ROOM) { return; } - if (g_RoomInfo[g_Camera.pos.room_number].flags & RF_UNDERWATER) { + if (g_RoomInfo[g_Camera.pos.room_num].flags & RF_UNDERWATER) { Camera_AdjustMusicVolume(true); Sound_Effect(SFX_UNDERWATER, NULL, SPM_ALWAYS); g_Camera.underwater = true; diff --git a/src/game/carrier.c b/src/game/carrier.c index 79576942c..6e3242293 100644 --- a/src/game/carrier.c +++ b/src/game/carrier.c @@ -69,7 +69,7 @@ void Carrier_InitialiseLevel(int32_t level_num) for (int i = 0; i < data->count; i++) { drop->object_id = data->object_ids[i]; drop->spawn_number = NO_ITEM; - drop->room_number = NO_ROOM; + drop->room_num = NO_ROOM; drop->fall_speed = 0; if (Object_IsObjectType(drop->object_id, g_PickupObjects)) { @@ -174,13 +174,13 @@ void Carrier_TestItemDrops(int16_t item_num) item->status = DS_FALLING; m_AnimatingCount++; - if (item->room_number != NO_ROOM) { + if (item->room_num != NO_ROOM) { // Handle reloading a save with a falling or landed item. ITEM_INFO *pickup = &g_Items[item->spawn_number]; pickup->pos = item->pos; pickup->fall_speed = item->fall_speed; - if (pickup->room_number != item->room_number) { - Item_NewRoom(item->spawn_number, item->room_number); + if (pickup->room_num != item->room_num) { + Item_NewRoom(item->spawn_number, item->room_num); } } @@ -239,12 +239,12 @@ static void Carrier_AnimateDrop(CARRIED_ITEM *item) } ITEM_INFO *const pickup = &g_Items[item->spawn_number]; - int16_t room_num = pickup->room_number; + int16_t room_num = pickup->room_num; const SECTOR_INFO *const sector = Room_GetSector(pickup->pos.x, pickup->pos.y, pickup->pos.z, &room_num); const int16_t height = Room_GetHeight(sector, pickup->pos.x, pickup->pos.y, pickup->pos.z); - const bool in_water = g_RoomInfo[pickup->room_number].flags & RF_UNDERWATER; + const bool in_water = g_RoomInfo[pickup->room_num].flags & RF_UNDERWATER; if (sector->portal_room.pit == NO_ROOM && pickup->pos.y >= height) { item->status = DS_DROPPED; @@ -264,13 +264,13 @@ static void Carrier_AnimateDrop(CARRIED_ITEM *item) } } - if (room_num != pickup->room_number) { + if (room_num != pickup->room_num) { Item_NewRoom(item->spawn_number, room_num); } // Track animating status in the carrier for saving/loading. item->pos = pickup->pos; item->rot = pickup->rot; - item->room_number = pickup->room_number; + item->room_num = pickup->room_num; item->fall_speed = pickup->fall_speed; } diff --git a/src/game/collide.c b/src/game/collide.c index acb4e8ecd..7d931b78d 100644 --- a/src/game/collide.c +++ b/src/game/collide.c @@ -311,7 +311,7 @@ void Collide_GetCollisionInfo( } bool Collide_CollideStaticObjects( - COLL_INFO *coll, int32_t x, int32_t y, int32_t z, int16_t room_number, + COLL_INFO *coll, int32_t x, int32_t y, int32_t z, int16_t room_num, int32_t height) { XYZ_32 shifter; @@ -328,7 +328,7 @@ bool Collide_CollideStaticObjects( shifter.y = 0; shifter.z = 0; - Room_GetNearByRooms(x, y, z, coll->radius + 50, height + 50, room_number); + Room_GetNearByRooms(x, y, z, coll->radius + 50, height + 50, room_num); for (int i = 0; i < g_RoomsToDrawCount; i++) { int16_t room_num = g_RoomsToDraw[i]; diff --git a/src/game/collide.h b/src/game/collide.h index bf01975e1..a00d9f366 100644 --- a/src/game/collide.h +++ b/src/game/collide.h @@ -10,7 +10,7 @@ void Collide_GetCollisionInfo( int32_t objheight); bool Collide_CollideStaticObjects( - COLL_INFO *coll, int32_t x, int32_t y, int32_t z, int16_t room_number, + COLL_INFO *coll, int32_t x, int32_t y, int32_t z, int16_t room_num, int32_t height); int32_t Collide_GetSpheres(ITEM_INFO *item, SPHERE *slist, int32_t world_space); diff --git a/src/game/console_cmd.c b/src/game/console_cmd.c index bcc100121..2b852ad01 100644 --- a/src/game/console_cmd.c +++ b/src/game/console_cmd.c @@ -95,7 +95,7 @@ static COMMAND_RESULT Console_Cmd_Pos(const char *const args) } Console_Log( - GS(OSD_POS_GET), g_LaraItem->room_number, + GS(OSD_POS_GET), g_LaraItem->room_num, g_LaraItem->pos.x / (float)WALL_L, g_LaraItem->pos.y / (float)WALL_L, g_LaraItem->pos.z / (float)WALL_L, g_LaraItem->rot.x * 360.0f / (float)PHD_ONE, diff --git a/src/game/creature.c b/src/game/creature.c index d2990ab7b..d563141bd 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -49,13 +49,13 @@ void Creature_AIInfo(ITEM_INFO *item, AI_INFO *info) zone = g_GroundZone2[g_FlipStatus]; } - const ROOM_INFO *r = &g_RoomInfo[item->room_number]; + const ROOM_INFO *r = &g_RoomInfo[item->room_num]; int32_t z_sector = (item->pos.z - r->z) >> WALL_SHIFT; int32_t x_sector = (item->pos.x - r->x) >> WALL_SHIFT; item->box_number = r->sectors[z_sector + x_sector * r->z_size].box; info->zone_number = zone[item->box_number]; - r = &g_RoomInfo[g_LaraItem->room_number]; + r = &g_RoomInfo[g_LaraItem->room_num]; z_sector = (g_LaraItem->pos.z - r->z) >> WALL_SHIFT; x_sector = (g_LaraItem->pos.x - r->x) >> WALL_SHIFT; g_LaraItem->box_number = r->sectors[z_sector + x_sector * r->z_size].box; @@ -337,8 +337,7 @@ int16_t Creature_Effect( .z = bite->z, }; Collide_GetJointAbsPosition(item, &pos, bite->mesh_num); - return spawn( - pos.x, pos.y, pos.z, item->speed, item->rot.y, item->room_number); + return spawn(pos.x, pos.y, pos.z, item->speed, item->rot.y, item->room_num); } bool Creature_CheckBaddieOverlap(int16_t item_num) @@ -350,7 +349,7 @@ bool Creature_CheckBaddieOverlap(int16_t item_num) int32_t z = item->pos.z; int32_t radius = SQUARE(g_Objects[item->object_id].radius); - int16_t link = g_RoomInfo[item->room_number].item_number; + int16_t link = g_RoomInfo[item->room_num].item_number; do { item = &g_Items[link]; @@ -432,7 +431,7 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt) const BOUNDS_16 *const bounds = Item_GetBoundsAccurate(item); int32_t y = item->pos.y + bounds->min.y; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *sector = Room_GetSector(item->pos.x, y, item->pos.z, &room_num); int32_t height = g_Boxes[sector->box].height; @@ -653,7 +652,7 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt) item->rot.x = 0; } - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } @@ -670,7 +669,7 @@ bool Creature_CanTargetEnemy(ITEM_INFO *item, AI_INFO *info) start.x = item->pos.x; start.y = item->pos.y - STEP_L * 3; start.z = item->pos.z; - start.room_number = item->room_number; + start.room_num = item->room_num; GAME_VECTOR target; target.x = g_LaraItem->pos.x; @@ -719,7 +718,7 @@ bool Creature_EnsureHabitat( // return whether or not a type conversion has taken place. ITEM_INFO *item = &g_Items[item_num]; *wh = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); return item->object_id == info->land.id ? Creature_SwitchToWater(item_num, wh, info) @@ -780,14 +779,14 @@ static bool Creature_SwitchToLand( item->current_anim_state = info->land.death_state; item->goal_anim_state = item->current_anim_state; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); item->floor = Room_GetHeight(sector, item->pos.x, item->pos.y, item->pos.z); item->pos.y = item->floor; - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } } diff --git a/src/game/effect_routines/bubbles.c b/src/game/effect_routines/bubbles.c index 3628d35bf..cf12b17d4 100644 --- a/src/game/effect_routines/bubbles.c +++ b/src/game/effect_routines/bubbles.c @@ -13,7 +13,7 @@ void FX_Bubbles(ITEM_INFO *item) { // XXX: until we get Robolara, it makes sense for her to breathe underwater if (g_Lara.water_status == LWS_CHEAT - && !(g_RoomInfo[g_LaraItem->room_number].flags & RF_UNDERWATER)) { + && !(g_RoomInfo[g_LaraItem->room_num].flags & RF_UNDERWATER)) { return; } @@ -32,7 +32,7 @@ void FX_Bubbles(ITEM_INFO *item) Collide_GetJointAbsPosition(item, &offset, LM_HEAD); for (int i = 0; i < count; i++) { - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = offset.x; diff --git a/src/game/effects.c b/src/game/effects.c index 68ee84c91..4e08427c8 100644 --- a/src/game/effects.c +++ b/src/game/effects.c @@ -50,7 +50,7 @@ int16_t Effect_Create(int16_t room_num) m_NextFxFree = fx->next_free; ROOM_INFO *r = &g_RoomInfo[room_num]; - fx->room_number = room_num; + fx->room_num = room_num; fx->next_draw = r->fx_number; r->fx_number = fx_num; @@ -77,7 +77,7 @@ void Effect_Kill(int16_t fx_num) } } - ROOM_INFO *r = &g_RoomInfo[fx->room_number]; + ROOM_INFO *r = &g_RoomInfo[fx->room_num]; if (r->fx_number == fx_num) { r->fx_number = fx->next_draw; } else { @@ -99,7 +99,7 @@ void Effect_Kill(int16_t fx_num) void Effect_NewRoom(int16_t fx_num, int16_t room_num) { FX_INFO *fx = &g_Effects[fx_num]; - ROOM_INFO *r = &g_RoomInfo[fx->room_number]; + ROOM_INFO *r = &g_RoomInfo[fx->room_num]; int16_t linknum = r->fx_number; if (linknum == fx_num) { @@ -114,7 +114,7 @@ void Effect_NewRoom(int16_t fx_num, int16_t room_num) } r = &g_RoomInfo[room_num]; - fx->room_number = room_num; + fx->room_num = room_num; fx->next_draw = r->fx_number; r->fx_number = fx_num; } @@ -147,7 +147,7 @@ void Effect_Draw(const int16_t fxnum) } else { Output_CalculateLight( fx->interp.result.pos.x, fx->interp.result.pos.y, - fx->interp.result.pos.z, fx->room_number); + fx->interp.result.pos.z, fx->room_num); Output_DrawPolygons(g_Meshes[fx->frame_num], -1); } } diff --git a/src/game/effects/exploding_death.c b/src/game/effects/exploding_death.c index 8ef74fa70..8c3f73ba6 100644 --- a/src/game/effects/exploding_death.c +++ b/src/game/effects/exploding_death.c @@ -32,10 +32,10 @@ int32_t Effect_ExplodingDeath( int32_t bit = 1; if ((bit & mesh_bits) && (bit & item->mesh_bits)) { - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; - fx->room_number = item->room_number; + fx->room_num = item->room_num; fx->pos.x = (g_MatrixPtr->_03 >> W2V_SHIFT) + item->pos.x; fx->pos.y = (g_MatrixPtr->_13 >> W2V_SHIFT) + item->pos.y; fx->pos.z = (g_MatrixPtr->_23 >> W2V_SHIFT) + item->pos.z; @@ -84,10 +84,10 @@ int32_t Effect_ExplodingDeath( bit <<= 1; if ((bit & mesh_bits) && (bit & item->mesh_bits)) { - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; - fx->room_number = item->room_number; + fx->room_num = item->room_num; fx->pos.x = (g_MatrixPtr->_03 >> W2V_SHIFT) + item->pos.x; fx->pos.y = (g_MatrixPtr->_13 >> W2V_SHIFT) + item->pos.y; fx->pos.z = (g_MatrixPtr->_23 >> W2V_SHIFT) + item->pos.z; diff --git a/src/game/effects/gun.c b/src/game/effects/gun.c index 411ab39bc..bad62067a 100644 --- a/src/game/effects/gun.c +++ b/src/game/effects/gun.c @@ -37,7 +37,7 @@ int16_t Effect_ShardGun( int16_t fx_num = Effect_Create(room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; - fx->room_number = room_num; + fx->room_num = room_num; fx->pos.x = x; fx->pos.y = y; fx->pos.z = z; @@ -60,7 +60,7 @@ int16_t Effect_RocketGun( int16_t fx_num = Effect_Create(room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; - fx->room_number = room_num; + fx->room_num = room_num; fx->pos.x = x; fx->pos.y = y; fx->pos.z = z; diff --git a/src/game/effects/gunshot.c b/src/game/effects/gunshot.c index 069748112..5ae0889d0 100644 --- a/src/game/effects/gunshot.c +++ b/src/game/effects/gunshot.c @@ -19,7 +19,7 @@ int16_t Effect_GunShot( fx->pos.x = x; fx->pos.y = y; fx->pos.z = z; - fx->room_number = room_num; + fx->room_num = room_num; fx->rot.x = 0; fx->rot.y = y_rot; fx->rot.z = 0; @@ -44,7 +44,7 @@ int16_t Effect_GunShotHit( g_LaraItem, &pos, (Random_GetControl() * 25) / 0x7FFF); Effect_Blood( pos.x, pos.y, pos.z, g_LaraItem->speed, g_LaraItem->rot.y, - g_LaraItem->room_number); + g_LaraItem->room_num); Sound_Effect(SFX_LARA_BULLETHIT, &g_LaraItem->pos, SPM_NORMAL); return Effect_GunShot(x, y, z, speed, y_rot, room_num); } @@ -59,7 +59,7 @@ int16_t Effect_GunShotMiss( pos.y = g_LaraItem->floor; pos.z = g_LaraItem->pos.z + ((Random_GetDraw() - 0x4000) * (WALL_L / 2)) / 0x7FFF; - pos.room_number = g_LaraItem->room_number; + pos.room_num = g_LaraItem->room_num; Ricochet_Spawn(&pos); return Effect_GunShot(x, y, z, speed, y_rot, room_num); } diff --git a/src/game/game/game_draw.c b/src/game/game/game_draw.c index b8fd6aced..e9a072c3c 100644 --- a/src/game/game/game_draw.c +++ b/src/game/game/game_draw.c @@ -19,8 +19,7 @@ void Game_DrawScene(bool draw_overlay) Camera_Apply(); if (g_Objects[O_LARA].loaded) { - Room_DrawAllRooms( - g_Camera.interp.room_num, g_Camera.target.room_number); + Room_DrawAllRooms(g_Camera.interp.room_num, g_Camera.target.room_num); if (draw_overlay) { Overlay_DrawGameInfo(); } else { diff --git a/src/game/gun/gun_misc.c b/src/game/gun/gun_misc.c index 9efff2d08..083826f26 100644 --- a/src/game/gun/gun_misc.c +++ b/src/game/gun/gun_misc.c @@ -158,7 +158,7 @@ void Gun_TargetInfo(WEAPON_INFO *winfo) src.x = g_LaraItem->pos.x; src.y = g_LaraItem->pos.y - 650; src.z = g_LaraItem->pos.z; - src.room_number = g_LaraItem->room_number; + src.room_num = g_LaraItem->room_num; Gun_FindTargetPoint(g_Lara.target, &target); int16_t ang[2]; @@ -216,7 +216,7 @@ void Gun_GetNewTarget(WEAPON_INFO *winfo) src.x = g_LaraItem->pos.x; src.y = g_LaraItem->pos.y - 650; src.z = g_LaraItem->pos.z; - src.room_number = g_LaraItem->room_number; + src.room_num = g_LaraItem->room_num; ITEM_INFO *item = NULL; for (int16_t item_num = g_NextItemActive; item_num != NO_ITEM; @@ -346,7 +346,7 @@ void Gun_FindTargetPoint(ITEM_INFO *item, GAME_VECTOR *target) target->x = item->pos.x + ((c * x + s * z) >> W2V_SHIFT); target->y = item->pos.y + y; target->z = item->pos.z + ((c * z - s * x) >> W2V_SHIFT); - target->room_number = item->room_number; + target->room_num = item->room_num; } void Gun_AimWeapon(WEAPON_INFO *winfo, LARA_ARM *arm) @@ -465,7 +465,7 @@ int32_t Gun_FireWeapon( } GAME_VECTOR vsrc; - vsrc.room_number = src->room_number; + vsrc.room_num = src->room_num; vsrc.pos = view_pos; GAME_VECTOR vdest; @@ -504,12 +504,12 @@ void Gun_HitTarget(ITEM_INFO *item, GAME_VECTOR *hitpos, int16_t damage) pos.x = hitpos->x; pos.y = hitpos->y; pos.z = hitpos->z; - pos.room_number = item->room_number; + pos.room_num = item->room_num; Ricochet_Spawn(&pos); } else { Effect_Blood( hitpos->x, hitpos->y, hitpos->z, item->speed, item->rot.y, - item->room_number); + item->room_num); } if (item->hit_points > 0) { diff --git a/src/game/inject.c b/src/game/inject.c index 3f69a43c8..e10e4d78f 100644 --- a/src/game/inject.c +++ b/src/game/inject.c @@ -1248,7 +1248,7 @@ static void Inject_RoomShift(INJECTION *injection, int16_t room_num) // Move any items in the room to match. for (int32_t i = 0; i < g_LevelItemCount; i++) { ITEM_INFO *item = &g_Items[i]; - if (item->room_number != room_num) { + if (item->room_num != room_num) { continue; } @@ -1296,7 +1296,7 @@ static void Inject_TriggeredItem(INJECTION *injection, LEVEL_INFO *level_info) ITEM_INFO *item = &g_Items[item_number]; item->object_id = File_ReadS16(fp); - item->room_number = File_ReadS16(fp); + item->room_num = File_ReadS16(fp); item->pos.x = File_ReadS32(fp); item->pos.y = File_ReadS32(fp); item->pos.z = File_ReadS32(fp); @@ -1730,7 +1730,7 @@ static void Inject_ItemPositions(INJECTION *injection) item->pos.x = x; item->pos.y = y; item->pos.z = z; - item->room_number = room_num; + item->room_num = room_num; } } } diff --git a/src/game/interpolation.c b/src/game/interpolation.c index 820681427..c0d35c568 100644 --- a/src/game/interpolation.c +++ b/src/game/interpolation.c @@ -76,7 +76,7 @@ void Interpolation_Commit(void) { const double ratio = Interpolation_GetRate(); - if (g_Camera.pos.room_number != NO_ROOM) { + if (g_Camera.pos.room_num != NO_ROOM) { INTERPOLATE(&g_Camera, shift, ratio, 128); INTERPOLATE(&g_Camera, pos.x, ratio, 512); INTERPOLATE(&g_Camera, pos.y, ratio, 512); @@ -85,7 +85,7 @@ void Interpolation_Commit(void) INTERPOLATE(&g_Camera, target.y, ratio, 512); INTERPOLATE(&g_Camera, target.z, ratio, 512); - g_Camera.interp.room_num = g_Camera.pos.room_number; + g_Camera.interp.room_num = g_Camera.pos.room_num; Room_GetSector( g_Camera.interp.result.pos.x, g_Camera.interp.result.pos.y + g_Camera.interp.result.shift, @@ -166,7 +166,7 @@ void Interpolation_Commit(void) void Interpolation_Remember(void) { - if (g_Camera.pos.room_number != NO_ROOM) { + if (g_Camera.pos.room_num != NO_ROOM) { REMEMBER(&g_Camera, shift); REMEMBER(&g_Camera, pos.x); REMEMBER(&g_Camera, pos.y); diff --git a/src/game/items.c b/src/game/items.c index db36619fd..3c00b14fc 100644 --- a/src/game/items.c +++ b/src/game/items.c @@ -143,7 +143,7 @@ void Item_Initialise(int16_t item_num) item->status = IS_ACTIVE; } - ROOM_INFO *const r = &g_RoomInfo[item->room_number]; + ROOM_INFO *const r = &g_RoomInfo[item->room_num]; item->next_item = r->item_number; r->item_number = item_num; const int32_t z_sector = (item->pos.z - r->z) >> WALL_SHIFT; @@ -189,7 +189,7 @@ void Item_RemoveActive(int16_t item_num) void Item_RemoveDrawn(int16_t item_num) { ITEM_INFO *const item = &g_Items[item_num]; - ROOM_INFO *const r = &g_RoomInfo[item->room_number]; + ROOM_INFO *const r = &g_RoomInfo[item->room_num]; int16_t link_num = r->item_number; if (link_num == item_num) { @@ -227,7 +227,7 @@ void Item_AddActive(int16_t item_num) void Item_NewRoom(int16_t item_num, int16_t room_num) { ITEM_INFO *item = &g_Items[item_num]; - ROOM_INFO *r = &g_RoomInfo[item->room_number]; + ROOM_INFO *r = &g_RoomInfo[item->room_num]; int16_t linknum = r->item_number; if (linknum == item_num) { @@ -242,7 +242,7 @@ void Item_NewRoom(int16_t item_num, int16_t room_num) } r = &g_RoomInfo[room_num]; - item->room_number = room_num; + item->room_num = room_num; item->next_item = r->item_number; r->item_number = item_num; } @@ -252,17 +252,17 @@ void Item_UpdateRoom(ITEM_INFO *item, int32_t height) int32_t x = item->pos.x; int32_t y = item->pos.y + height; int32_t z = item->pos.z; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num); item->floor = Room_GetHeight(sector, x, y, z); - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(g_Lara.item_number, room_num); } } int16_t Item_GetHeight(ITEM_INFO *item) { - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); const int32_t height = @@ -274,7 +274,7 @@ int16_t Item_GetHeight(ITEM_INFO *item) int16_t Item_GetWaterHeight(ITEM_INFO *item) { int16_t height = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); if (height != NO_HEIGHT) { height -= item->pos.y; } @@ -288,7 +288,7 @@ int16_t Item_Spawn(const ITEM_INFO *const item, const GAME_OBJECT_ID object_id) if (spawn_num != NO_ITEM) { ITEM_INFO *spawn = &g_Items[spawn_num]; spawn->object_id = object_id; - spawn->room_number = item->room_number; + spawn->room_num = item->room_num; spawn->pos = item->pos; spawn->rot = item->rot; Item_Initialise(spawn_num); @@ -644,7 +644,7 @@ void Item_Animate(ITEM_INFO *item) case AC_SOUND_FX: Item_PlayAnimSFX( - item, command, g_RoomInfo[item->room_number].flags); + item, command, g_RoomInfo[item->room_num].flags); command += 2; break; diff --git a/src/game/lara/lara.c b/src/game/lara/lara.c index 4c1782a97..e8858fc59 100644 --- a/src/game/lara/lara.c +++ b/src/game/lara/lara.c @@ -36,7 +36,7 @@ void Lara_Control(void) COLL_INFO coll = { 0 }; ITEM_INFO *item = g_LaraItem; - const ROOM_INFO *const room = &g_RoomInfo[item->room_number]; + const ROOM_INFO *const room = &g_RoomInfo[item->room_num]; const bool room_submerged = (room->flags & RF_UNDERWATER) != 0; if (g_Lara.interact_target.is_moving @@ -94,7 +94,7 @@ void Lara_Control(void) Splash_Spawn(item); } else if (g_Lara.water_status == LWS_UNDERWATER && !room_submerged) { const int16_t water_height = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); if (water_height != NO_HEIGHT && ABS(water_height - item->pos.y) < STEP_L) { g_Lara.water_status = LWS_SURFACE; @@ -483,7 +483,7 @@ void Lara_Initialise(int32_t level_num) g_Lara.interact_target.item_num = NO_OBJECT; g_Lara.interact_target.move_count = 0; - if (g_RoomInfo[g_LaraItem->room_number].flags & RF_UNDERWATER) { + if (g_RoomInfo[g_LaraItem->room_num].flags & RF_UNDERWATER) { g_Lara.water_status = LWS_UNDERWATER; g_LaraItem->fall_speed = 0; g_LaraItem->goal_anim_state = LS_TREAD; @@ -780,7 +780,7 @@ void Lara_Push(ITEM_INFO *item, COLL_INFO *coll, bool spaz_on, bool big_push) lara_item->pos.z - coll->old.z, lara_item->pos.x - coll->old.x); Collide_GetCollisionInfo( coll, lara_item->pos.x, lara_item->pos.y, lara_item->pos.z, - lara_item->room_number, LARA_HEIGHT); + lara_item->room_num, LARA_HEIGHT); coll->facing = old_facing; if (coll->coll_type != COLL_NONE) { diff --git a/src/game/lara/lara_cheat.c b/src/game/lara/lara_cheat.c index 7081f1e00..c017c46e5 100644 --- a/src/game/lara/lara_cheat.c +++ b/src/game/lara/lara_cheat.c @@ -174,11 +174,11 @@ bool Lara_Cheat_ExitFlyMode(void) return false; } - const ROOM_INFO *const room = &g_RoomInfo[g_LaraItem->room_number]; + const ROOM_INFO *const room = &g_RoomInfo[g_LaraItem->room_num]; const bool room_submerged = (room->flags & RF_UNDERWATER) != 0; const int16_t water_height = Room_GetWaterHeight( g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z, - g_LaraItem->room_number); + g_LaraItem->room_num); if (room_submerged || (water_height != NO_HEIGHT && water_height > 0)) { g_Lara.water_status = LWS_UNDERWATER; @@ -447,7 +447,7 @@ bool Lara_Cheat_Teleport(int32_t x, int32_t y, int32_t z) g_LaraItem->pos.z = z; g_LaraItem->floor = height; - if (g_LaraItem->room_number != room_num) { + if (g_LaraItem->room_num != room_num) { const int16_t item_num = g_LaraItem - g_Items; Item_NewRoom(item_num, room_num); } diff --git a/src/game/lara/lara_col.c b/src/game/lara/lara_col.c index 495d5c0bc..b019a7348 100644 --- a/src/game/lara/lara_col.c +++ b/src/game/lara/lara_col.c @@ -628,7 +628,7 @@ void Lara_Col_UpJump(ITEM_INFO *item, COLL_INFO *coll) } Collide_GetCollisionInfo( - coll, item->pos.x, item->pos.y, item->pos.z, item->room_number, 870); + coll, item->pos.x, item->pos.y, item->pos.z, item->room_num, 870); if (Lara_TestHangJumpUp(item, coll)) { return; @@ -943,7 +943,7 @@ void Lara_Col_UWDeath(ITEM_INFO *item, COLL_INFO *coll) g_Lara.air = -1; g_Lara.gun_status = LGS_HANDS_BUSY; int16_t wh = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); if (wh != NO_HEIGHT && wh < item->pos.y - 100) { item->pos.y -= 5; } diff --git a/src/game/lara/lara_control.c b/src/game/lara/lara_control.c index 2b954ab84..8d12ad23e 100644 --- a/src/game/lara/lara_control.c +++ b/src/game/lara/lara_control.c @@ -34,7 +34,7 @@ static void Lara_WaterCurrent(COLL_INFO *coll) XYZ_32 target; ITEM_INFO *const item = g_LaraItem; - const ROOM_INFO *const r = &g_RoomInfo[item->room_number]; + const ROOM_INFO *const r = &g_RoomInfo[item->room_num]; const SECTOR_INFO *const sector = &r->sectors [((item->pos.z - r->z) >> WALL_SHIFT) @@ -78,7 +78,7 @@ static void Lara_WaterCurrent(COLL_INFO *coll) item->pos.z - coll->old.z, item->pos.x - coll->old.x); Collide_GetCollisionInfo( coll, item->pos.x, item->pos.y + UW_HEIGHT / 2, item->pos.z, - item->room_number, UW_HEIGHT); + item->room_num, UW_HEIGHT); if (coll->coll_type == COLL_FRONT) { if (item->rot.x > 35 * PHD_DEGREE) { @@ -120,9 +120,9 @@ static void Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll) int16_t numroom = 0; int16_t roomies[MAX_BADDIE_COLLISION]; - roomies[numroom++] = lara_item->room_number; + roomies[numroom++] = lara_item->room_num; - DOOR_INFOS *door = g_RoomInfo[lara_item->room_number].doors; + DOOR_INFOS *door = g_RoomInfo[lara_item->room_num].doors; if (door) { for (int i = 0; i < door->count; i++) { if (numroom >= MAX_BADDIE_COLLISION) { diff --git a/src/game/lara/lara_hair.c b/src/game/lara/lara_hair.c index cecdc442f..baf0b74a4 100644 --- a/src/game/lara/lara_hair.c +++ b/src/game/lara/lara_hair.c @@ -73,7 +73,7 @@ void Lara_Hair_Control(void) int32_t distance; FRAME_INFO *frame; int16_t *objptr; - int16_t room_number; + int16_t room_num; FRAME_INFO *frmptr[2]; int16_t **mesh_base; XYZ_32 pos; @@ -322,25 +322,24 @@ void Lara_Hair_Control(void) } } else { if (in_cutscene) { - room_number = Lara_Hair_GetRoom(pos.x, pos.y, pos.z); + room_num = Lara_Hair_GetRoom(pos.x, pos.y, pos.z); water_level = NO_HEIGHT; } else { - room_number = g_LaraItem->room_number; + room_num = g_LaraItem->room_num; x = g_LaraItem->pos.x + (frame->bounds.min.x + frame->bounds.max.x) / 2; y = g_LaraItem->pos.y + (frame->bounds.min.y + frame->bounds.max.y) / 2; z = g_LaraItem->pos.z + (frame->bounds.min.z + frame->bounds.max.z) / 2; - water_level = Room_GetWaterHeight(x, y, z, room_number); + water_level = Room_GetWaterHeight(x, y, z, room_num); } for (i = 1; i < HAIR_SEGMENTS + 1; i++, bone += 4) { m_HVel[0] = m_Hair[i].pos; sector = Room_GetSector( - m_Hair[i].pos.x, m_Hair[i].pos.y, m_Hair[i].pos.z, - &room_number); + m_Hair[i].pos.x, m_Hair[i].pos.y, m_Hair[i].pos.z, &room_num); height = Room_GetHeight( sector, m_Hair[i].pos.x, m_Hair[i].pos.y, m_Hair[i].pos.z); @@ -458,7 +457,7 @@ static int16_t Lara_Hair_GetRoom(int32_t x, int32_t y, int32_t z) if (room_num != NO_ROOM) { return room_num; } - return g_LaraItem->room_number; + return g_LaraItem->room_num; } int32_t Lara_Hair_GetSegmentCount(void) diff --git a/src/game/lara/lara_misc.c b/src/game/lara/lara_misc.c index ef786c080..8ed42885d 100644 --- a/src/game/lara/lara_misc.c +++ b/src/game/lara/lara_misc.c @@ -23,7 +23,7 @@ void Lara_GetCollisionInfo(ITEM_INFO *item, COLL_INFO *coll) { coll->facing = g_Lara.move_angle; Collide_GetCollisionInfo( - coll, item->pos.x, item->pos.y, item->pos.z, item->room_number, + coll, item->pos.x, item->pos.y, item->pos.z, item->room_num, LARA_HEIGHT); } @@ -418,7 +418,7 @@ bool Lara_TestHangSwingIn(ITEM_INFO *item, PHD_ANGLE angle) int x = item->pos.x; int y = item->pos.y; int z = item->pos.z; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; switch (angle) { case 0: z += 256; @@ -545,7 +545,7 @@ bool Lara_TestSlide(ITEM_INFO *item, COLL_INFO *coll) bool Lara_LandedBad(ITEM_INFO *item, COLL_INFO *coll) { - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); @@ -584,7 +584,7 @@ void Lara_SurfaceCollision(ITEM_INFO *item, COLL_INFO *coll) Collide_GetCollisionInfo( coll, item->pos.x, item->pos.y + SURF_HEIGHT, item->pos.z, - item->room_number, SURF_HEIGHT); + item->room_num, SURF_HEIGHT); Item_ShiftCol(item, coll); @@ -603,7 +603,7 @@ void Lara_SurfaceCollision(ITEM_INFO *item, COLL_INFO *coll) } int16_t wh = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); if (wh - item->pos.y <= -100) { item->goal_anim_state = LS_SWIM; item->current_anim_state = LS_DIVE; @@ -694,7 +694,7 @@ void Lara_SwimCollision(ITEM_INFO *item, COLL_INFO *coll) } Collide_GetCollisionInfo( coll, item->pos.x, item->pos.y + UW_HEIGHT / 2, item->pos.z, - item->room_number, UW_HEIGHT); + item->room_num, UW_HEIGHT); Item_ShiftCol(item, coll); diff --git a/src/game/lara/lara_state.c b/src/game/lara/lara_state.c index eee3cac17..ec59c8dd2 100644 --- a/src/game/lara/lara_state.c +++ b/src/game/lara/lara_state.c @@ -50,7 +50,7 @@ static int16_t Lara_FloorFront(ITEM_INFO *item, PHD_ANGLE ang, int32_t dist) int32_t x = item->pos.x + ((Math_Sin(ang) * dist) >> W2V_SHIFT); int32_t y = item->pos.y - LARA_HEIGHT; int32_t z = item->pos.z + ((Math_Cos(ang) * dist) >> W2V_SHIFT); - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num); int32_t height = Room_GetHeight(sector, x, y, z); if (height != NO_HEIGHT) { diff --git a/src/game/level.c b/src/game/level.c index ecaa59b8b..f1460b691 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -749,7 +749,7 @@ static void Level_LoadItems(VFILE *file) for (int i = 0; i < m_LevelInfo.item_count; i++) { ITEM_INFO *item = &g_Items[i]; item->object_id = VFile_ReadS16(file); - item->room_number = VFile_ReadS16(file); + item->room_num = VFile_ReadS16(file); item->pos.x = VFile_ReadS32(file); item->pos.y = VFile_ReadS32(file); item->pos.z = VFile_ReadS32(file); diff --git a/src/game/los.c b/src/game/los.c index 7cadc9803..23dd96902 100644 --- a/src/game/los.c +++ b/src/game/los.c @@ -25,7 +25,7 @@ static int32_t LOS_CheckX( int32_t dy = ((target->y - start->y) << WALL_SHIFT) / dx; int32_t dz = ((target->z - start->z) << WALL_SHIFT) / dx; - int16_t room_num = start->room_number; + int16_t room_num = start->room_num; int16_t last_room; if (dx < 0) { @@ -40,7 +40,7 @@ static int32_t LOS_CheckX( target->x = x; target->y = y; target->z = z; - target->room_number = room_num; + target->room_num = room_num; return -1; } @@ -52,7 +52,7 @@ static int32_t LOS_CheckX( target->x = x; target->y = y; target->z = z; - target->room_number = last_room; + target->room_num = last_room; return 0; } @@ -72,7 +72,7 @@ static int32_t LOS_CheckX( target->x = x; target->y = y; target->z = z; - target->room_number = room_num; + target->room_num = room_num; return -1; } @@ -84,7 +84,7 @@ static int32_t LOS_CheckX( target->x = x; target->y = y; target->z = z; - target->room_number = last_room; + target->room_num = last_room; return 0; } @@ -94,7 +94,7 @@ static int32_t LOS_CheckX( } } - target->room_number = room_num; + target->room_num = room_num; return 1; } @@ -111,7 +111,7 @@ static int32_t LOS_CheckZ( int32_t dx = ((target->x - start->x) << WALL_SHIFT) / dz; int32_t dy = ((target->y - start->y) << WALL_SHIFT) / dz; - int16_t room_num = start->room_number; + int16_t room_num = start->room_num; int16_t last_room; if (dz < 0) { @@ -126,7 +126,7 @@ static int32_t LOS_CheckZ( target->x = x; target->y = y; target->z = z; - target->room_number = room_num; + target->room_num = room_num; return -1; } @@ -138,7 +138,7 @@ static int32_t LOS_CheckZ( target->x = x; target->y = y; target->z = z; - target->room_number = last_room; + target->room_num = last_room; return 0; } @@ -158,7 +158,7 @@ static int32_t LOS_CheckZ( target->x = x; target->y = y; target->z = z; - target->room_number = room_num; + target->room_num = room_num; return -1; } @@ -170,7 +170,7 @@ static int32_t LOS_CheckZ( target->x = x; target->y = y; target->z = z; - target->room_number = last_room; + target->room_num = last_room; return 0; } @@ -180,7 +180,7 @@ static int32_t LOS_CheckZ( } } - target->room_number = room_num; + target->room_num = room_num; return 1; } @@ -231,7 +231,7 @@ bool LOS_Check(const GAME_VECTOR *const start, GAME_VECTOR *const target) } const SECTOR_INFO *const sector = - Room_GetSector(target->x, target->y, target->z, &target->room_number); + Room_GetSector(target->x, target->y, target->z, &target->room_num); return LOS_ClipTarget(start, target, sector) && los1 == 1 && los2 == 1; } diff --git a/src/game/lot.c b/src/game/lot.c index 6af8a5ab8..da19cbf00 100644 --- a/src/game/lot.c +++ b/src/game/lot.c @@ -158,7 +158,7 @@ void LOT_CreateZone(ITEM_INFO *item) flip = g_GroundZone2[1]; } - const ROOM_INFO *const r = &g_RoomInfo[item->room_number]; + const ROOM_INFO *const r = &g_RoomInfo[item->room_num]; const int32_t z_sector = (item->pos.z - r->z) >> WALL_SHIFT; const int32_t x_sector = (item->pos.x - r->x) >> WALL_SHIFT; item->box_number = r->sectors[z_sector + x_sector * r->z_size].box; diff --git a/src/game/objects/common.c b/src/game/objects/common.c index 3ead2fbf8..40a0c6f22 100644 --- a/src/game/objects/common.c +++ b/src/game/objects/common.c @@ -352,8 +352,8 @@ void Object_DrawPickupItem(ITEM_INFO *item) // This is mostly true, but for example the 4 items in the Obelisk of // Khamoon the 4 items are sitting on top of a static mesh which is not // floor. - const SECTOR_INFO *const sector = Room_GetSector( - item->pos.x, item->pos.y, item->pos.z, &item->room_number); + const SECTOR_INFO *const sector = + Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &item->room_num); const int16_t floor_height = Room_GetHeight(sector, item->pos.x, item->pos.y, item->pos.z); @@ -427,7 +427,7 @@ void Object_DrawPickupItem(ITEM_INFO *item) item->interp.result.rot.z); Output_CalculateLight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); frame = object->frame_base; int32_t clip = Output_GetObjectBounds(&frame->bounds); diff --git a/src/game/objects/creatures/ape.c b/src/game/objects/creatures/ape.c index c2cbbb053..5538885f9 100644 --- a/src/game/objects/creatures/ape.c +++ b/src/game/objects/creatures/ape.c @@ -59,7 +59,7 @@ static bool Ape_Vault(int16_t item_num, int16_t angle) int32_t x = item->pos.x >> WALL_SHIFT; int32_t y = item->pos.y; int32_t z = item->pos.z >> WALL_SHIFT; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; if (ape->flags & APE_TURN_L_FLAG) { item->rot.y -= PHD_90; @@ -103,7 +103,7 @@ static bool Ape_Vault(int16_t item_num, int16_t angle) item->floor = y; item->pos.y = y; - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } diff --git a/src/game/objects/creatures/bacon_lara.c b/src/game/objects/creatures/bacon_lara.c index 4e6ad16d9..74e48fb0e 100644 --- a/src/game/objects/creatures/bacon_lara.c +++ b/src/game/objects/creatures/bacon_lara.c @@ -68,12 +68,12 @@ void BaconLara_Control(int16_t item_num) int32_t y = g_LaraItem->pos.y; int32_t z = 2 * m_AnchorZ - g_LaraItem->pos.z; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *sector = Room_GetSector(x, y, z, &room_num); const int32_t h = Room_GetHeight(sector, x, y, z); item->floor = h; - room_num = g_LaraItem->room_number; + room_num = g_LaraItem->room_num; sector = Room_GetSector( g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z, &room_num); int32_t lh = Room_GetHeight( @@ -90,7 +90,7 @@ void BaconLara_Control(int16_t item_num) item->rot.x = g_LaraItem->rot.x; item->rot.y = g_LaraItem->rot.y - PHD_180; item->rot.z = g_LaraItem->rot.z; - Item_NewRoom(item_num, g_LaraItem->room_number); + Item_NewRoom(item_num, g_LaraItem->room_num); if (h >= lh + WALL_L && !g_LaraItem->gravity_status) { item->current_anim_state = LS_FAST_FALL; @@ -111,7 +111,7 @@ void BaconLara_Control(int16_t item_num) int32_t y = item->pos.y; int32_t z = item->pos.z; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *sector = Room_GetSector(x, y, z, &room_num); const int32_t h = Room_GetHeight(sector, x, y, z); item->floor = h; diff --git a/src/game/objects/creatures/bat.c b/src/game/objects/creatures/bat.c index b00353dd0..ce5746474 100644 --- a/src/game/objects/creatures/bat.c +++ b/src/game/objects/creatures/bat.c @@ -43,8 +43,8 @@ static void Bat_FixEmbeddedPosition(int16_t item_num) const int32_t x = item->pos.x; const int32_t y = item->pos.y; const int32_t z = item->pos.z; - int16_t room_number = item->room_number; - const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_number); + int16_t room_num = item->room_num; + const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num); const int16_t ceiling = Room_GetCeiling(sector, x, y, z); // The bats animation and frame have to be changed to the hanging diff --git a/src/game/objects/creatures/crocodile.c b/src/game/objects/creatures/crocodile.c index 053f319c4..7e1f3f192 100644 --- a/src/game/objects/creatures/crocodile.c +++ b/src/game/objects/creatures/crocodile.c @@ -265,12 +265,12 @@ void Alligator_Control(int16_t item_num) Item_Animate(item); - room_num = item->room_number; + room_num = item->room_num; sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); item->floor = Room_GetHeight(sector, item->pos.x, item->pos.y, item->pos.z); - if (room_num != item->room_number) { + if (room_num != item->room_num) { Item_NewRoom(item_num, room_num); } return; diff --git a/src/game/objects/creatures/cutscene_player.c b/src/game/objects/creatures/cutscene_player.c index cd2f24143..68563fd49 100644 --- a/src/game/objects/creatures/cutscene_player.c +++ b/src/game/objects/creatures/cutscene_player.c @@ -52,7 +52,7 @@ void CutscenePlayer1_Initialise(int16_t item_num) Item_AddActive(item_num); ITEM_INFO *item = &g_Items[item_num]; - g_Camera.pos.room_number = item->room_number; + g_Camera.pos.room_num = item->room_num; g_CinePosition.pos.x = item->pos.x; g_CinePosition.pos.y = item->pos.y; g_CinePosition.pos.z = item->pos.z; diff --git a/src/game/objects/creatures/natla.c b/src/game/objects/creatures/natla.c index f9777d0dc..7ae857475 100644 --- a/src/game/objects/creatures/natla.c +++ b/src/game/objects/creatures/natla.c @@ -341,7 +341,7 @@ void NatlaGun_Control(int16_t fx_num) int32_t z = fx->pos.z + ((fx->speed * Math_Cos(fx->rot.y)) >> W2V_SHIFT); int32_t x = fx->pos.x + ((fx->speed * Math_Sin(fx->rot.y)) >> W2V_SHIFT); int32_t y = fx->pos.y; - int16_t room_num = fx->room_number; + int16_t room_num = fx->room_num; const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num); if (y >= Room_GetHeight(sector, x, y, z) @@ -356,7 +356,7 @@ void NatlaGun_Control(int16_t fx_num) newfx->pos.y = y; newfx->pos.z = z; newfx->rot.y = fx->rot.y; - newfx->room_number = room_num; + newfx->room_num = room_num; newfx->speed = fx->speed; newfx->frame_num = 0; newfx->object_id = O_MISSILE1; diff --git a/src/game/objects/creatures/pierre.c b/src/game/objects/creatures/pierre.c index a9b726082..e572cb4b2 100644 --- a/src/game/objects/creatures/pierre.c +++ b/src/game/objects/creatures/pierre.c @@ -231,7 +231,7 @@ void Pierre_Control(int16_t item_num) start.x = g_Camera.pos.x; start.y = g_Camera.pos.y; start.z = g_Camera.pos.z; - start.room_number = g_Camera.pos.room_number; + start.room_num = g_Camera.pos.room_num; if (LOS_Check(&start, &target)) { pierre->flags = 1; @@ -244,7 +244,7 @@ void Pierre_Control(int16_t item_num) } int16_t wh = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); if (wh != NO_HEIGHT) { item->hit_points = DONT_TARGET; LOT_DisableBaddieAI(item_num); diff --git a/src/game/objects/creatures/pod.c b/src/game/objects/creatures/pod.c index 48c932636..20cfbf967 100644 --- a/src/game/objects/creatures/pod.c +++ b/src/game/objects/creatures/pod.c @@ -67,7 +67,7 @@ void Pod_Initialise(int16_t item_num) break; } - bug->room_number = item->room_number; + bug->room_num = item->room_num; bug->pos.x = item->pos.x; bug->pos.y = item->pos.y; bug->pos.z = item->pos.z; diff --git a/src/game/objects/creatures/rat.c b/src/game/objects/creatures/rat.c index 80c807319..b62f2a992 100644 --- a/src/game/objects/creatures/rat.c +++ b/src/game/objects/creatures/rat.c @@ -216,7 +216,7 @@ void Vole_Control(int16_t item_num) Item_Animate(item); int32_t wh = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); + item->pos.x, item->pos.y, item->pos.z, item->room_num); if (wh == NO_HEIGHT) { item->object_id = O_RAT; item->current_anim_state = RAT_DEATH; diff --git a/src/game/objects/creatures/statue.c b/src/game/objects/creatures/statue.c index 0c73abd11..2f63090d7 100644 --- a/src/game/objects/creatures/statue.c +++ b/src/game/objects/creatures/statue.c @@ -40,7 +40,7 @@ void Statue_Initialise(int16_t item_num) ITEM_INFO *centaur = &g_Items[centaur_item_num]; centaur->object_id = O_CENTAUR; - centaur->room_number = item->room_number; + centaur->room_num = item->room_num; centaur->pos.x = item->pos.x; centaur->pos.y = item->pos.y; centaur->pos.z = item->pos.z; diff --git a/src/game/objects/creatures/torso.c b/src/game/objects/creatures/torso.c index 4dccd9cd4..a3b387437 100644 --- a/src/game/objects/creatures/torso.c +++ b/src/game/objects/creatures/torso.c @@ -212,7 +212,7 @@ void Torso_Control(int16_t item_num) g_LaraItem, EXTRA_ANIM_TORSO_SLAM, 0, O_LARA_EXTRA); g_LaraItem->current_anim_state = LS_SPECIAL; g_LaraItem->goal_anim_state = LS_SPECIAL; - g_LaraItem->room_number = item->room_number; + g_LaraItem->room_num = item->room_num; g_LaraItem->pos.x = item->pos.x; g_LaraItem->pos.y = item->pos.y; g_LaraItem->pos.z = item->pos.z; diff --git a/src/game/objects/creatures/trex.c b/src/game/objects/creatures/trex.c index fd2f7d767..edfe001d8 100644 --- a/src/game/objects/creatures/trex.c +++ b/src/game/objects/creatures/trex.c @@ -181,8 +181,8 @@ void TRex_Control(int16_t item_num) void TRex_LaraDeath(ITEM_INFO *item) { item->goal_anim_state = TREX_KILL; - if (g_LaraItem->room_number != item->room_number) { - Item_NewRoom(g_Lara.item_number, item->room_number); + if (g_LaraItem->room_num != item->room_num) { + Item_NewRoom(g_Lara.item_number, item->room_num); } g_LaraItem->pos.x = item->pos.x; diff --git a/src/game/objects/effects/body_part.c b/src/game/objects/effects/body_part.c index ecdd38e25..aaea0c867 100644 --- a/src/game/objects/effects/body_part.c +++ b/src/game/objects/effects/body_part.c @@ -27,7 +27,7 @@ void BodyPart_Control(int16_t fx_num) fx->fall_speed += GRAVITY; fx->pos.y += fx->fall_speed; - int16_t room_num = fx->room_number; + int16_t room_num = fx->room_num; const SECTOR_INFO *const sector = Room_GetSector(fx->pos.x, fx->pos.y, fx->pos.z, &room_num); @@ -70,7 +70,7 @@ void BodyPart_Control(int16_t fx_num) } } - if (room_num != fx->room_number) { + if (room_num != fx->room_num) { Effect_NewRoom(fx_num, room_num); } } diff --git a/src/game/objects/effects/bubble.c b/src/game/objects/effects/bubble.c index 37e98de06..2b0654a16 100644 --- a/src/game/objects/effects/bubble.c +++ b/src/game/objects/effects/bubble.c @@ -21,7 +21,7 @@ void Bubble_Control(int16_t fx_num) int32_t y = fx->pos.y - fx->speed; int32_t z = fx->pos.z + ((Math_Cos(fx->rot.x) * 8) >> W2V_SHIFT); - int16_t room_num = fx->room_number; + int16_t room_num = fx->room_num; const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num); if (!sector || !(g_RoomInfo[room_num].flags & RF_UNDERWATER)) { Effect_Kill(fx_num); @@ -34,7 +34,7 @@ void Bubble_Control(int16_t fx_num) return; } - if (fx->room_number != room_num) { + if (fx->room_num != room_num) { Effect_NewRoom(fx_num, room_num); } fx->pos.x = x; diff --git a/src/game/objects/effects/missile.c b/src/game/objects/effects/missile.c index dc949222a..45491afe3 100644 --- a/src/game/objects/effects/missile.c +++ b/src/game/objects/effects/missile.c @@ -33,7 +33,7 @@ void Missile_Control(int16_t fx_num) fx->pos.z += (speed * Math_Cos(fx->rot.y)) >> W2V_SHIFT; fx->pos.x += (speed * Math_Sin(fx->rot.y)) >> W2V_SHIFT; - int16_t room_num = fx->room_number; + int16_t room_num = fx->room_num; const SECTOR_INFO *const sector = Room_GetSector(fx->pos.x, fx->pos.y, fx->pos.z, &room_num); const int32_t height = @@ -68,7 +68,7 @@ void Missile_Control(int16_t fx_num) return; } - if (room_num != fx->room_number) { + if (room_num != fx->room_num) { Effect_NewRoom(fx_num, room_num); } diff --git a/src/game/objects/effects/ricochet.c b/src/game/objects/effects/ricochet.c index 012072dbd..5a88b7c3b 100644 --- a/src/game/objects/effects/ricochet.c +++ b/src/game/objects/effects/ricochet.c @@ -21,7 +21,7 @@ void Ricochet_Control(int16_t fx_num) void Ricochet_Spawn(GAME_VECTOR *pos) { - int16_t fx_num = Effect_Create(pos->room_number); + int16_t fx_num = Effect_Create(pos->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = pos->x; diff --git a/src/game/objects/effects/splash.c b/src/game/objects/effects/splash.c index 04273b4ae..c82241ef2 100644 --- a/src/game/objects/effects/splash.c +++ b/src/game/objects/effects/splash.c @@ -29,8 +29,8 @@ void Splash_Control(int16_t fx_num) void Splash_Spawn(ITEM_INFO *item) { int16_t wh = Room_GetWaterHeight( - item->pos.x, item->pos.y, item->pos.z, item->room_number); - int16_t room_num = item->room_number; + item->pos.x, item->pos.y, item->pos.z, item->room_num); + int16_t room_num = item->room_num; Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); Sound_Effect(SFX_LARA_SPLASH, &item->pos, SPM_NORMAL); diff --git a/src/game/objects/effects/twinkle.c b/src/game/objects/effects/twinkle.c index 2a732b081..14e173a83 100644 --- a/src/game/objects/effects/twinkle.c +++ b/src/game/objects/effects/twinkle.c @@ -26,7 +26,7 @@ void Twinkle_Control(int16_t fx_num) void Twinkle_Spawn(GAME_VECTOR *pos) { - int16_t fx_num = Effect_Create(pos->room_number); + int16_t fx_num = Effect_Create(pos->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = pos->x; @@ -44,7 +44,7 @@ void Twinkle_SparkleItem(ITEM_INFO *item, int mesh_mask) GAME_VECTOR effect_pos; int32_t num = Collide_GetSpheres(item, slist, 1); - effect_pos.room_number = item->room_number; + effect_pos.room_num = item->room_num; for (int i = 0; i < num; i++) { if (mesh_mask & (1 << i)) { SPHERE *sptr = &slist[i]; diff --git a/src/game/objects/effects/waterfall.c b/src/game/objects/effects/waterfall.c index 5b5c93fb1..7fbc859b6 100644 --- a/src/game/objects/effects/waterfall.c +++ b/src/game/objects/effects/waterfall.c @@ -31,7 +31,7 @@ void Waterfall_Control(int16_t item_num) if (ABS(x) <= WATERFALL_RANGE && ABS(z) <= WATERFALL_RANGE && ABS(y) <= WATERFALL_RANGE) { - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = item->pos.x diff --git a/src/game/objects/general/bridge.c b/src/game/objects/general/bridge.c index 01b661397..a39b9b0ea 100644 --- a/src/game/objects/general/bridge.c +++ b/src/game/objects/general/bridge.c @@ -102,7 +102,7 @@ static void Bridge_FixEmbeddedPosition(int16_t item_num) int32_t x = item->pos.x; int32_t y = item->pos.y; int32_t z = item->pos.z; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const BOUNDS_16 *const bounds = Item_GetBoundsAccurate(item); const int16_t bridge_height = ABS(bounds->max.y) - ABS(bounds->min.y); diff --git a/src/game/objects/general/cog.c b/src/game/objects/general/cog.c index 55afdef64..df87cc800 100644 --- a/src/game/objects/general/cog.c +++ b/src/game/objects/general/cog.c @@ -20,9 +20,9 @@ void Cog_Control(int16_t item_num) Item_Animate(item); - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); - if (room_num != item->room_number) { + if (room_num != item->room_num) { Item_NewRoom(item_num, room_num); } } diff --git a/src/game/objects/general/door.c b/src/game/objects/general/door.c index a6b2cc7ae..3da0cd677 100644 --- a/src/game/objects/general/door.c +++ b/src/game/objects/general/door.c @@ -26,7 +26,7 @@ static bool Door_LaraDoorCollision(const SECTOR_INFO *const sector) return false; } - int16_t room_num = g_LaraItem->room_number; + int16_t room_num = g_LaraItem->room_num; const SECTOR_INFO *const lara_sector = Room_GetSector( g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z, &room_num); return lara_sector == sector; @@ -115,7 +115,7 @@ void Door_Initialise(int16_t item_num) int16_t room_num; int16_t box_num; - r = &g_RoomInfo[item->room_number]; + r = &g_RoomInfo[item->room_num]; z_sector = ((item->pos.z - r->z) >> WALL_SHIFT) + dx; x_sector = ((item->pos.x - r->x) >> WALL_SHIFT) + dy; door->d1.sector = &r->sectors[z_sector + x_sector * r->z_size]; diff --git a/src/game/objects/general/pickup.c b/src/game/objects/general/pickup.c index 00e16089e..4f43cb8b8 100644 --- a/src/game/objects/general/pickup.c +++ b/src/game/objects/general/pickup.c @@ -67,7 +67,7 @@ static void PickUp_GetItem( static void PickUp_GetAllAtLaraPos(ITEM_INFO *item, ITEM_INFO *lara_item) { - int16_t pickup_num = g_RoomInfo[item->room_number].item_number; + int16_t pickup_num = g_RoomInfo[item->room_num].item_number; while (pickup_num != NO_ITEM) { ITEM_INFO *check_item = &g_Items[pickup_num]; if (check_item->pos.x == item->pos.x && check_item->pos.z == item->pos.z diff --git a/src/game/objects/general/scion.c b/src/game/objects/general/scion.c index 830af8e3c..349c1d879 100644 --- a/src/game/objects/general/scion.c +++ b/src/game/objects/general/scion.c @@ -121,7 +121,7 @@ void Scion_Control3(int16_t item_num) } if (counter % 10 == 0) { - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = item->pos.x + (Random_GetControl() - 0x4000) / 32; diff --git a/src/game/objects/traps/damocles_sword.c b/src/game/objects/traps/damocles_sword.c index ee0319eaf..a58ea2e52 100644 --- a/src/game/objects/traps/damocles_sword.c +++ b/src/game/objects/traps/damocles_sword.c @@ -82,6 +82,6 @@ void DamoclesSword_Collision( int32_t z = lara_item->pos.z + (Random_GetControl() - 0x4000) / 256; int32_t y = lara_item->pos.y - Random_GetControl() / 44; int32_t d = lara_item->rot.y + (Random_GetControl() - 0x4000) / 8; - Effect_Blood(x, y, z, lara_item->speed, d, lara_item->room_number); + Effect_Blood(x, y, z, lara_item->speed, d, lara_item->room_num); } } diff --git a/src/game/objects/traps/dart.c b/src/game/objects/traps/dart.c index b30155a49..f64982f07 100644 --- a/src/game/objects/traps/dart.c +++ b/src/game/objects/traps/dart.c @@ -35,24 +35,24 @@ void Dart_Control(int16_t item_num) Lara_TakeDamage(DART_DAMAGE, true); Effect_Blood( item->pos.x, item->pos.y, item->pos.z, g_LaraItem->speed, - g_LaraItem->rot.y, g_LaraItem->room_number); + g_LaraItem->rot.y, g_LaraItem->room_num); } int32_t old_x = item->pos.x; int32_t old_z = item->pos.z; Item_Animate(item); - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } item->floor = Room_GetHeight(sector, item->pos.x, item->pos.y, item->pos.z); if (item->pos.y >= item->floor) { Item_Kill(item_num); - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = old_x; @@ -111,7 +111,7 @@ void DartEmitter_Control(int16_t item_num) if (dart_item_num != NO_ITEM) { ITEM_INFO *dart = &g_Items[dart_item_num]; dart->object_id = O_DARTS; - dart->room_number = item->room_number; + dart->room_num = item->room_num; dart->shade = -1; dart->rot.y = item->rot.y; dart->pos.y = item->pos.y - WALL_L / 2; @@ -139,7 +139,7 @@ void DartEmitter_Control(int16_t item_num) Item_AddActive(dart_item_num); dart->status = IS_ACTIVE; - int16_t fx_num = Effect_Create(dart->room_number); + int16_t fx_num = Effect_Create(dart->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos = dart->pos; diff --git a/src/game/objects/traps/falling_block.c b/src/game/objects/traps/falling_block.c index de52e24c7..4449452fb 100644 --- a/src/game/objects/traps/falling_block.c +++ b/src/game/objects/traps/falling_block.c @@ -47,10 +47,10 @@ void FallingBlock_Control(int16_t item_num) return; } - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } diff --git a/src/game/objects/traps/flame.c b/src/game/objects/traps/flame.c index 1de4aa9ec..69f651bfc 100644 --- a/src/game/objects/traps/flame.c +++ b/src/game/objects/traps/flame.c @@ -51,15 +51,15 @@ void Flame_Control(int16_t fx_num) int32_t y = Room_GetWaterHeight( g_LaraItem->pos.x, g_LaraItem->pos.y, g_LaraItem->pos.z, - g_LaraItem->room_number); + g_LaraItem->room_num); if (y != NO_HEIGHT && fx->pos.y > y) { fx->counter = 0; Sound_StopEffect(SFX_FIRE, NULL); Effect_Kill(fx_num); } else { - if (fx->room_number != g_LaraItem->room_number) { - Effect_NewRoom(fx_num, g_LaraItem->room_number); + if (fx->room_num != g_LaraItem->room_num) { + Effect_NewRoom(fx_num, g_LaraItem->room_num); } Sound_Effect(SFX_FIRE, &fx->pos, SPM_NORMAL); Lara_TakeDamage(FLAME_ONFIRE_DAMAGE, true); @@ -84,7 +84,7 @@ void Flame_Control(int16_t fx_num) if (distance < SQUARE(300)) { fx->counter = 100; - fx_num = Effect_Create(g_LaraItem->room_number); + fx_num = Effect_Create(g_LaraItem->room_num); if (fx_num != NO_ITEM) { fx = &g_Effects[fx_num]; fx->frame_num = 0; @@ -107,7 +107,7 @@ void FlameEmitter_Control(int16_t item_num) ITEM_INFO *item = &g_Items[item_num]; if (Item_IsTriggerActive(item)) { if (!item->data) { - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = item->pos.x; diff --git a/src/game/objects/traps/lava.c b/src/game/objects/traps/lava.c index f52468bcf..b634618c6 100644 --- a/src/game/objects/traps/lava.c +++ b/src/game/objects/traps/lava.c @@ -23,7 +23,7 @@ bool Lava_TestFloor(const ITEM_INFO *const item) } // OG fix: check if floor index has lava - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, MAX_HEIGHT, item->pos.z, &room_num); return sector->is_death_sector; @@ -39,7 +39,7 @@ void Lava_Burn(ITEM_INFO *const item) return; } - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, MAX_HEIGHT, item->pos.z, &room_num); const int16_t height = @@ -56,7 +56,7 @@ void Lava_Burn(ITEM_INFO *const item) } for (int i = 0; i < 10; i++) { - const int16_t fx_num = Effect_Create(item->room_number); + const int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->object_id = O_FLAME; @@ -80,7 +80,7 @@ void Lava_Control(int16_t fx_num) fx->fall_speed += GRAVITY; fx->pos.y += fx->fall_speed; - int16_t room_num = fx->room_number; + int16_t room_num = fx->room_num; const SECTOR_INFO *const sector = Room_GetSector(fx->pos.x, fx->pos.y, fx->pos.z, &room_num); if (fx->pos.y >= Room_GetHeight(sector, fx->pos.x, fx->pos.y, fx->pos.z) @@ -90,7 +90,7 @@ void Lava_Control(int16_t fx_num) } else if (Lara_IsNearItem(&fx->pos, 200)) { Lara_TakeDamage(LAVA_EMBER_DAMAGE, true); Effect_Kill(fx_num); - } else if (room_num != fx->room_number) { + } else if (room_num != fx->room_num) { Effect_NewRoom(fx_num, room_num); } } @@ -106,7 +106,7 @@ void LavaEmitter_Setup(OBJECT_INFO *obj) void LavaEmitter_Control(int16_t item_num) { ITEM_INFO *item = &g_Items[item_num]; - int16_t fx_num = Effect_Create(item->room_number); + int16_t fx_num = Effect_Create(item->room_num); if (fx_num != NO_ITEM) { FX_INFO *fx = &g_Effects[fx_num]; fx->pos.x = item->pos.x; @@ -134,9 +134,9 @@ void LavaWedge_Control(int16_t item_num) { ITEM_INFO *item = &g_Items[item_num]; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); - if (room_num != item->room_number) { + if (room_num != item->room_num) { Item_NewRoom(item_num, room_num); } diff --git a/src/game/objects/traps/lightning_emitter.c b/src/game/objects/traps/lightning_emitter.c index f871a2810..e6a8d3f31 100644 --- a/src/game/objects/traps/lightning_emitter.c +++ b/src/game/objects/traps/lightning_emitter.c @@ -112,7 +112,7 @@ void LightningEmitter_Control(int16_t item_num) l->zapped = true; } else if (l->no_target) { const SECTOR_INFO *const sector = Room_GetSector( - item->pos.x, item->pos.y, item->pos.z, &item->room_number); + item->pos.x, item->pos.y, item->pos.z, &item->room_num); const int32_t h = Room_GetHeight(sector, item->pos.x, item->pos.y, item->pos.z); l->target.x = item->pos.x; diff --git a/src/game/objects/traps/movable_block.c b/src/game/objects/traps/movable_block.c index 11b4a2005..b36925d58 100644 --- a/src/game/objects/traps/movable_block.c +++ b/src/game/objects/traps/movable_block.c @@ -77,7 +77,7 @@ static bool MovableBlock_TestDoor(ITEM_INFO *lara_item, COLL_INFO *coll) static bool MovableBlock_TestDestination(ITEM_INFO *item, int32_t block_height) { - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); if (Room_GetHeight(sector, item->pos.x, item->pos.y, item->pos.z) @@ -103,7 +103,7 @@ static bool MovableBlock_TestPush( int32_t x = item->pos.x; int32_t y = item->pos.y; int32_t z = item->pos.z; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; switch (quadrant) { case DIR_NORTH: @@ -168,7 +168,7 @@ static bool MovableBlock_TestPull( int32_t y = item->pos.y; int32_t z = item->pos.z + z_add; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *sector = Room_GetSector(x, y, z, &room_num); COLL_INFO coll; coll.quadrant = quadrant; @@ -188,7 +188,7 @@ static bool MovableBlock_TestPull( x += x_add; z += z_add; - room_num = item->room_number; + room_num = item->room_num; sector = Room_GetSector(x, y, z, &room_num); if (Room_GetHeight(sector, x, y, z) != y) { @@ -203,7 +203,7 @@ static bool MovableBlock_TestPull( x = g_LaraItem->pos.x + x_add; y = g_LaraItem->pos.y; z = g_LaraItem->pos.z + z_add; - room_num = g_LaraItem->room_number; + room_num = g_LaraItem->room_num; sector = Room_GetSector(x, y, z, &room_num); coll.radius = LARA_RAD; coll.quadrant = (quadrant + 2) & 3; @@ -247,7 +247,7 @@ void MovableBlock_Control(int16_t item_num) Item_Animate(item); - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *sector = Room_GetSector( item->pos.x, item->pos.y - STEP_L / 2, item->pos.z, &room_num); const int32_t height = Room_GetHeight( @@ -268,7 +268,7 @@ void MovableBlock_Control(int16_t item_num) Item_RemoveActive(item_num); } - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } diff --git a/src/game/objects/traps/pendulum.c b/src/game/objects/traps/pendulum.c index 4436ce55c..379f208f5 100644 --- a/src/game/objects/traps/pendulum.c +++ b/src/game/objects/traps/pendulum.c @@ -42,11 +42,11 @@ void Pendulum_Control(int16_t item_num) int32_t z = g_LaraItem->pos.z + (Random_GetControl() - 0x4000) / 256; int32_t y = g_LaraItem->pos.y - Random_GetControl() / 44; int32_t d = g_LaraItem->rot.y + (Random_GetControl() - 0x4000) / 8; - Effect_Blood(x, y, z, g_LaraItem->speed, d, g_LaraItem->room_number); + Effect_Blood(x, y, z, g_LaraItem->speed, d, g_LaraItem->room_num); } - const SECTOR_INFO *const sector = Room_GetSector( - item->pos.x, item->pos.y, item->pos.z, &item->room_number); + const SECTOR_INFO *const sector = + Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &item->room_num); item->floor = Room_GetHeight(sector, item->pos.x, item->pos.y, item->pos.z); Item_Animate(item); diff --git a/src/game/objects/traps/rolling_ball.c b/src/game/objects/traps/rolling_ball.c index 587e66a8b..4d6741dea 100644 --- a/src/game/objects/traps/rolling_ball.c +++ b/src/game/objects/traps/rolling_ball.c @@ -36,7 +36,7 @@ void RollingBall_Initialise(int16_t item_num) data->x = item->pos.x; data->y = item->pos.y; data->z = item->pos.z; - data->room_number = item->room_number; + data->room_num = item->room_num; } void RollingBall_Control(int16_t item_num) @@ -56,10 +56,10 @@ void RollingBall_Control(int16_t item_num) int32_t oldz = item->pos.z; Item_Animate(item); - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *sector = Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } @@ -94,12 +94,12 @@ void RollingBall_Control(int16_t item_num) item->pos.x = data->x; item->pos.y = data->y; item->pos.z = data->z; - if (item->room_number != data->room_number) { + if (item->room_num != data->room_num) { Item_RemoveDrawn(item_num); - ROOM_INFO *r = &g_RoomInfo[data->room_number]; + ROOM_INFO *r = &g_RoomInfo[data->room_num]; item->next_item = r->item_number; r->item_number = item_num; - item->room_number = data->room_number; + item->room_num = data->room_num; } item->current_anim_state = TRAP_SET; item->goal_anim_state = TRAP_SET; @@ -146,13 +146,13 @@ void RollingBall_Collision( x = item->pos.x + (x << WALL_SHIFT) / 2 / d; z = item->pos.z + (z << WALL_SHIFT) / 2 / d; y = item->pos.y - WALL_L / 2 + (y << WALL_SHIFT) / 2 / d; - Effect_Blood(x, y, z, item->speed, item->rot.y, item->room_number); + Effect_Blood(x, y, z, item->speed, item->rot.y, item->room_num); } else { lara_item->hit_status = 1; if (lara_item->hit_points > 0) { lara_item->hit_points = -1; - if (lara_item->room_number != item->room_number) { - Item_NewRoom(g_Lara.item_number, item->room_number); + if (lara_item->room_num != item->room_num) { + Item_NewRoom(g_Lara.item_number, item->room_num); } lara_item->rot.x = 0; @@ -171,7 +171,7 @@ void RollingBall_Collision( z = lara_item->pos.z + (Random_GetControl() - 0x4000) / 256; y = lara_item->pos.y - Random_GetControl() / 64; d = item->rot.y + (Random_GetControl() - 0x4000) / 8; - Effect_Blood(x, y, z, item->speed * 2, d, item->room_number); + Effect_Blood(x, y, z, item->speed * 2, d, item->room_num); } } } diff --git a/src/game/objects/traps/sliding_pillar.c b/src/game/objects/traps/sliding_pillar.c index d02c61154..f39423ebc 100644 --- a/src/game/objects/traps/sliding_pillar.c +++ b/src/game/objects/traps/sliding_pillar.c @@ -34,9 +34,9 @@ void SlidingPillar_Control(int16_t item_num) Item_Animate(item); - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; Room_GetSector(item->pos.x, item->pos.y, item->pos.z, &room_num); - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(item_num, room_num); } diff --git a/src/game/objects/traps/spikes.c b/src/game/objects/traps/spikes.c index de7bd47a3..ef2cf5b59 100644 --- a/src/game/objects/traps/spikes.c +++ b/src/game/objects/traps/spikes.c @@ -42,7 +42,7 @@ void Spikes_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll) int32_t x = lara_item->pos.x + (Random_GetControl() - 0x4000) / 256; int32_t z = lara_item->pos.z + (Random_GetControl() - 0x4000) / 256; int32_t y = lara_item->pos.y - Random_GetControl() / 64; - Effect_Blood(x, y, z, 20, Random_GetControl(), item->room_number); + Effect_Blood(x, y, z, 20, Random_GetControl(), item->room_num); num--; } diff --git a/src/game/objects/traps/teeth_trap.c b/src/game/objects/traps/teeth_trap.c index e15a417b5..8357d5bfd 100644 --- a/src/game/objects/traps/teeth_trap.c +++ b/src/game/objects/traps/teeth_trap.c @@ -32,8 +32,7 @@ static void TeethTrap_BiteEffect(ITEM_INFO *item, BITE_INFO *bite) .z = bite->z, }; Collide_GetJointAbsPosition(item, &pos, bite->mesh_num); - Effect_Blood( - pos.x, pos.y, pos.z, item->speed, item->rot.y, item->room_number); + Effect_Blood(pos.x, pos.y, pos.z, item->speed, item->rot.y, item->room_num); } void TeethTrap_Setup(OBJECT_INFO *obj) diff --git a/src/game/objects/traps/thors_hammer.c b/src/game/objects/traps/thors_hammer.c index 66ceae30a..8bfc6d42e 100644 --- a/src/game/objects/traps/thors_hammer.c +++ b/src/game/objects/traps/thors_hammer.c @@ -40,7 +40,7 @@ void ThorsHandle_Initialise(int16_t item_num) int16_t head_item_num = Item_Create(); ITEM_INFO *head_item = &g_Items[head_item_num]; head_item->object_id = O_THORS_HEAD; - head_item->room_number = hand_item->room_number; + head_item->room_num = hand_item->room_num; head_item->pos = hand_item->pos; head_item->rot = hand_item->rot; head_item->shade = hand_item->shade; diff --git a/src/game/output.c b/src/game/output.c index 161566085..71dcf97f4 100644 --- a/src/game/output.c +++ b/src/game/output.c @@ -603,7 +603,7 @@ void Output_CalculateObjectLighting( Matrix_Pop(); - Output_CalculateLight(offset.x, offset.y, offset.z, item->room_number); + Output_CalculateLight(offset.x, offset.y, offset.z, item->room_num); } void Output_DrawPolygons(const int16_t *obj_ptr, int clip) diff --git a/src/game/phase/phase_demo.c b/src/game/phase/phase_demo.c index e1345cb7c..718419881 100644 --- a/src/game/phase/phase_demo.c +++ b/src/game/phase/phase_demo.c @@ -186,7 +186,7 @@ static void Phase_Demo_Start(void *arg) item->rot.z = *m_DemoPtr++; int16_t room_num = *m_DemoPtr++; - if (item->room_number != room_num) { + if (item->room_num != room_num) { Item_NewRoom(g_Lara.item_number, room_num); } diff --git a/src/game/room.c b/src/game/room.c index 0d15f2b01..dc9487dd9 100644 --- a/src/game/room.c +++ b/src/game/room.c @@ -540,7 +540,7 @@ void Room_AlterFloorHeight(ITEM_INFO *item, int32_t height) int16_t portal_room; SECTOR_INFO *sector; - const ROOM_INFO *r = &g_RoomInfo[item->room_number]; + const ROOM_INFO *r = &g_RoomInfo[item->room_num]; do { int32_t z_sector = (item->pos.z - r->z) >> WALL_SHIFT; @@ -737,7 +737,7 @@ void Room_PopulateSectorData( void Room_TestTriggers(const ITEM_INFO *const item) { const bool is_heavy = item->object_id != O_LARA; - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector(item->pos.x, MAX_HEIGHT, item->pos.z, &room_num); diff --git a/src/game/room_draw.c b/src/game/room_draw.c index 75278d12a..8b07c78ed 100644 --- a/src/game/room_draw.c +++ b/src/game/room_draw.c @@ -211,7 +211,7 @@ void Room_DrawAllRooms(int16_t base_room, int16_t target_room) } if (g_Objects[O_LARA].loaded) { - if (g_RoomInfo[g_LaraItem->room_number].flags & RF_UNDERWATER) { + if (g_RoomInfo[g_LaraItem->room_num].flags & RF_UNDERWATER) { Output_SetupBelowWater(g_Camera.underwater); } else { Output_SetupAboveWater(g_Camera.underwater); @@ -273,7 +273,7 @@ static void Room_DrawSkybox(void) void Room_DrawSingleRoom(int16_t room_num) { bool camera_underwater = - g_RoomInfo[g_Camera.pos.room_number].flags & RF_UNDERWATER; + g_RoomInfo[g_Camera.pos.room_num].flags & RF_UNDERWATER; ROOM_INFO *r = &g_RoomInfo[room_num]; if (r->flags & RF_UNDERWATER) { diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index 74895da73..485dc424c 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -88,7 +88,7 @@ static void Savegame_LoadPostprocess(void) OBJECT_INFO *obj = &g_Objects[item->object_id]; if (obj->save_position && obj->shadow_size) { - int16_t room_num = item->room_number; + int16_t room_num = item->room_num; const SECTOR_INFO *const sector = Room_GetSector( item->pos.x, item->pos.y, item->pos.z, &room_num); item->floor = diff --git a/src/game/savegame/savegame_bson.c b/src/game/savegame/savegame_bson.c index 454d978da..0c5cc7431 100644 --- a/src/game/savegame/savegame_bson.c +++ b/src/game/savegame/savegame_bson.c @@ -524,7 +524,7 @@ static bool Savegame_BSON_LoadItems( json_object_get_int(item_obj, "fall_speed", item->fall_speed); int16_t room_num = json_object_get_int(item_obj, "room_num", -1); - if (room_num != -1 && item->room_number != room_num) { + if (room_num != -1 && item->room_num != room_num) { Item_NewRoom(i, room_num); } } @@ -620,8 +620,8 @@ static bool Savegame_BSON_LoadItems( carried_item_obj, "z", carried_item->pos.z); carried_item->rot.y = json_object_get_int( carried_item_obj, "y_rot", carried_item->rot.y); - carried_item->room_number = json_object_get_int( - carried_item_obj, "room_num", carried_item->room_number); + carried_item->room_num = json_object_get_int( + carried_item_obj, "room_num", carried_item->room_num); carried_item->fall_speed = json_object_get_int( carried_item_obj, "fall_speed", carried_item->fall_speed); carried_item->status = json_object_get_int( @@ -1054,7 +1054,7 @@ static struct json_array_s *Savegame_BSON_DumpItems(void) json_object_append_int(item_obj, "x_rot", item->rot.x); json_object_append_int(item_obj, "y_rot", item->rot.y); json_object_append_int(item_obj, "z_rot", item->rot.z); - json_object_append_int(item_obj, "room_num", item->room_number); + json_object_append_int(item_obj, "room_num", item->room_num); json_object_append_int(item_obj, "speed", item->speed); json_object_append_int(item_obj, "fall_speed", item->fall_speed); } @@ -1114,8 +1114,7 @@ static struct json_array_s *Savegame_BSON_DumpItems(void) json_object_append_int(drop_obj, "y", drop_item->pos.y); json_object_append_int(drop_obj, "z", drop_item->pos.z); json_object_append_int(drop_obj, "y_rot", drop_item->rot.y); - json_object_append_int( - drop_obj, "room_num", drop_item->room_number); + json_object_append_int(drop_obj, "room_num", drop_item->room_num); json_object_append_int( drop_obj, "fall_speed", drop_item->fall_speed); @@ -1147,7 +1146,7 @@ static struct json_array_s *SaveGame_BSON_DumpFx(void) json_object_append_int(fx_obj, "x", fx->pos.x); json_object_append_int(fx_obj, "y", fx->pos.y); json_object_append_int(fx_obj, "z", fx->pos.z); - json_object_append_int(fx_obj, "room_number", fx->room_number); + json_object_append_int(fx_obj, "room_number", fx->room_num); json_object_append_int(fx_obj, "object_number", fx->object_id); json_object_append_int(fx_obj, "speed", fx->speed); json_object_append_int(fx_obj, "fall_speed", fx->fall_speed); diff --git a/src/game/savegame/savegame_legacy.c b/src/game/savegame/savegame_legacy.c index 9752f980a..065451dc4 100644 --- a/src/game/savegame/savegame_legacy.c +++ b/src/game/savegame/savegame_legacy.c @@ -580,7 +580,7 @@ bool Savegame_Legacy_LoadFromFile(MYFILE *fp, GAME_INFO *game_info) Savegame_Legacy_Read(&item->speed, sizeof(int16_t)); Savegame_Legacy_Read(&item->fall_speed, sizeof(int16_t)); - if (item->room_number != tmp16) { + if (item->room_num != tmp16) { Item_NewRoom(i, tmp16); } } @@ -755,7 +755,7 @@ void Savegame_Legacy_SaveToFile(MYFILE *fp, GAME_INFO *game_info) Savegame_Legacy_Write(&item->rot.x, sizeof(int16_t)); Savegame_Legacy_Write(&item->rot.y, sizeof(int16_t)); Savegame_Legacy_Write(&item->rot.z, sizeof(int16_t)); - Savegame_Legacy_Write(&item->room_number, sizeof(int16_t)); + Savegame_Legacy_Write(&item->room_num, sizeof(int16_t)); Savegame_Legacy_Write(&item->speed, sizeof(int16_t)); Savegame_Legacy_Write(&item->fall_speed, sizeof(int16_t)); } diff --git a/src/game/sound.c b/src/game/sound.c index 23c8c1cf8..0e58457fd 100644 --- a/src/game/sound.c +++ b/src/game/sound.c @@ -271,7 +271,7 @@ bool Sound_Effect(int32_t sfx_num, const XYZ_32 *pos, uint32_t flags) if (flags != SPM_ALWAYS && (flags & SPM_UNDERWATER) - != (g_RoomInfo[g_Camera.pos.room_number].flags & RF_UNDERWATER)) { + != (g_RoomInfo[g_Camera.pos.room_num].flags & RF_UNDERWATER)) { return false; } diff --git a/src/global/types.h b/src/global/types.h index 2544922fe..72b0aae44 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1274,7 +1274,7 @@ typedef struct CARRIED_ITEM { int16_t spawn_number; XYZ_32 pos; XYZ_16 rot; - int16_t room_number; + int16_t room_num; int16_t fall_speed; DROP_STATUS status; struct CARRIED_ITEM *next_item; @@ -1290,7 +1290,7 @@ typedef struct { int16_t required_anim_state; int16_t anim_num; int16_t frame_num; - int16_t room_number; + int16_t room_num; int16_t next_item; int16_t next_active; int16_t speed; @@ -1393,7 +1393,7 @@ typedef struct LOT_INFO { typedef struct FX_INFO { XYZ_32 pos; XYZ_16 rot; - int16_t room_number; + int16_t room_num; GAME_OBJECT_ID object_id; int16_t next_draw; int16_t next_active; @@ -1733,7 +1733,7 @@ typedef struct GAME_VECTOR { }; XYZ_32 pos; }; - int16_t room_number; + int16_t room_num; } GAME_VECTOR; typedef struct OBJECT_VECTOR { From c3cd30f959a3e16b39d015f88bb7124ee1fad2f0 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:04:35 +0200 Subject: [PATCH 5/9] types: use consistent naming for lot numbers --- src/game/box.c | 83 +++++++++++++------------- src/game/box.h | 8 +-- src/game/creature.c | 91 ++++++++++++++--------------- src/game/lara/lara_control.c | 2 +- src/game/lot.c | 14 ++--- src/game/objects/creatures/ape.c | 2 +- src/game/objects/creatures/mutant.c | 10 ++-- src/game/objects/creatures/wolf.c | 3 +- src/game/savegame/savegame_bson.c | 6 +- src/game/savegame/savegame_legacy.c | 4 +- src/global/types.h | 10 ++-- 11 files changed, 114 insertions(+), 119 deletions(-) diff --git a/src/game/box.c b/src/game/box.c index 47da9ecaa..d12c1f19c 100644 --- a/src/game/box.c +++ b/src/game/box.c @@ -30,52 +30,51 @@ bool Box_SearchLOT(LOT_INFO *LOT, int32_t expansion) int done = 0; int index = box->overlap_index & OVERLAP_INDEX; do { - int16_t box_number = g_Overlap[index++]; - if (box_number & END_BIT) { + int16_t box_num = g_Overlap[index++]; + if (box_num & END_BIT) { done = 1; - box_number &= BOX_NUMBER; + box_num &= BOX_NUMBER; } - if (search_zone != zone[box_number]) { + if (search_zone != zone[box_num]) { continue; } - int change = g_Boxes[box_number].height - box->height; + int change = g_Boxes[box_num].height - box->height; if (change > LOT->step || change < LOT->drop) { continue; } - BOX_NODE *expand = &LOT->node[box_number]; - if ((node->search_number & SEARCH_NUMBER) - < (expand->search_number & SEARCH_NUMBER)) { + BOX_NODE *expand = &LOT->node[box_num]; + if ((node->search_num & SEARCH_NUMBER) + < (expand->search_num & SEARCH_NUMBER)) { continue; } - if (node->search_number & BLOCKED_SEARCH) { - if ((node->search_number & SEARCH_NUMBER) - == (expand->search_number & SEARCH_NUMBER)) { + if (node->search_num & BLOCKED_SEARCH) { + if ((node->search_num & SEARCH_NUMBER) + == (expand->search_num & SEARCH_NUMBER)) { continue; } - expand->search_number = node->search_number; + expand->search_num = node->search_num; } else { - if ((node->search_number & SEARCH_NUMBER) - == (expand->search_number & SEARCH_NUMBER) - && !(expand->search_number & BLOCKED_SEARCH)) { + if ((node->search_num & SEARCH_NUMBER) + == (expand->search_num & SEARCH_NUMBER) + && !(expand->search_num & BLOCKED_SEARCH)) { continue; } - if (g_Boxes[box_number].overlap_index & LOT->block_mask) { - expand->search_number = - node->search_number | BLOCKED_SEARCH; + if (g_Boxes[box_num].overlap_index & LOT->block_mask) { + expand->search_num = node->search_num | BLOCKED_SEARCH; } else { - expand->search_number = node->search_number; + expand->search_num = node->search_num; expand->exit_box = LOT->head; } } - if (expand->next_expansion == NO_BOX && box_number != LOT->tail) { - LOT->node[LOT->tail].next_expansion = box_number; - LOT->tail = box_number; + if (expand->next_expansion == NO_BOX && box_num != LOT->tail) { + LOT->node[LOT->tail].next_expansion = box_num; + LOT->tail = box_num; } } while (!done); @@ -102,24 +101,24 @@ bool Box_UpdateLOT(LOT_INFO *LOT, int32_t expansion) LOT->head = LOT->target_box; } - expand->search_number = ++LOT->search_number; + expand->search_num = ++LOT->search_num; expand->exit_box = NO_BOX; } return Box_SearchLOT(LOT, expansion); } -void Box_TargetBox(LOT_INFO *LOT, int16_t box_number) +void Box_TargetBox(LOT_INFO *LOT, int16_t box_num) { - box_number &= BOX_NUMBER; + box_num &= BOX_NUMBER; - BOX_INFO *box = &g_Boxes[box_number]; + BOX_INFO *box = &g_Boxes[box_num]; LOT->target.z = box->left + WALL_L / 2 + (Random_GetControl() * (box->right - box->left - WALL_L) >> 15); LOT->target.x = box->top + WALL_L / 2 + (Random_GetControl() * (box->bottom - box->top - WALL_L) >> 15); - LOT->required_box = box_number; + LOT->required_box = box_num; if (LOT->fly) { LOT->target.y = box->height - STEP_L * 3 / 2; @@ -128,9 +127,9 @@ void Box_TargetBox(LOT_INFO *LOT, int16_t box_number) } } -bool Box_StalkBox(ITEM_INFO *item, int16_t box_number) +bool Box_StalkBox(ITEM_INFO *item, int16_t box_num) { - BOX_INFO *box = &g_Boxes[box_number]; + BOX_INFO *box = &g_Boxes[box_num]; int32_t z = ((box->left + box->right) >> 1) - g_LaraItem->pos.z; int32_t x = ((box->top + box->bottom) >> 1) - g_LaraItem->pos.x; @@ -157,9 +156,9 @@ bool Box_StalkBox(ITEM_INFO *item, int16_t box_number) return true; } -bool Box_EscapeBox(ITEM_INFO *item, int16_t box_number) +bool Box_EscapeBox(ITEM_INFO *item, int16_t box_num) { - BOX_INFO *box = &g_Boxes[box_number]; + BOX_INFO *box = &g_Boxes[box_num]; int32_t z = ((box->left + box->right) >> 1) - g_LaraItem->pos.z; int32_t x = ((box->top + box->bottom) >> 1) - g_LaraItem->pos.x; @@ -176,7 +175,7 @@ bool Box_EscapeBox(ITEM_INFO *item, int16_t box_number) return true; } -bool Box_ValidBox(ITEM_INFO *item, int16_t zone_number, int16_t box_number) +bool Box_ValidBox(ITEM_INFO *item, int16_t zone_num, int16_t box_num) { CREATURE_INFO *creature = item->data; @@ -189,11 +188,11 @@ bool Box_ValidBox(ITEM_INFO *item, int16_t zone_number, int16_t box_number) zone = g_GroundZone2[g_FlipStatus]; } - if (zone[box_number] != zone_number) { + if (zone[box_num] != zone_num) { return false; } - BOX_INFO *box = &g_Boxes[box_number]; + BOX_INFO *box = &g_Boxes[box_num]; if (box->overlap_index & creature->LOT.block_mask) { return false; } @@ -219,15 +218,15 @@ TARGET_TYPE Box_CalculateTarget(XYZ_32 *target, ITEM_INFO *item, LOT_INFO *LOT) target->y = item->pos.y; target->z = item->pos.z; - int32_t box_number = item->box_number; - if (box_number == NO_BOX) { + int32_t box_num = item->box_num; + if (box_num == NO_BOX) { return TARGET_NONE; } BOX_INFO *box; int32_t prime_free = ALL_CLIP; do { - box = &g_Boxes[box_number]; + box = &g_Boxes[box_num]; if (LOT->fly) { if (target->y > box->height - WALL_L) { @@ -359,7 +358,7 @@ TARGET_TYPE Box_CalculateTarget(XYZ_32 *target, ITEM_INFO *item, LOT_INFO *LOT) } } - if (box_number == LOT->target_box) { + if (box_num == LOT->target_box) { if (prime_free & (CLIP_LEFT | CLIP_RIGHT)) { target->z = LOT->target.z; } else if (!(prime_free & SECONDARY_CLIP)) { @@ -384,12 +383,12 @@ TARGET_TYPE Box_CalculateTarget(XYZ_32 *target, ITEM_INFO *item, LOT_INFO *LOT) return TARGET_PRIMARY; } - box_number = LOT->node[box_number].exit_box; - if (box_number != NO_BOX - && (g_Boxes[box_number].overlap_index & LOT->block_mask)) { + box_num = LOT->node[box_num].exit_box; + if (box_num != NO_BOX + && (g_Boxes[box_num].overlap_index & LOT->block_mask)) { break; } - } while (box_number != NO_BOX); + } while (box_num != NO_BOX); if (prime_free & (CLIP_LEFT | CLIP_RIGHT)) { target->z = box->left + WALL_L / 2 diff --git a/src/game/box.h b/src/game/box.h index 2ccd01a2d..5dbe9a5b7 100644 --- a/src/game/box.h +++ b/src/game/box.h @@ -7,10 +7,10 @@ bool Box_SearchLOT(LOT_INFO *LOT, int32_t expansion); bool Box_UpdateLOT(LOT_INFO *LOT, int32_t expansion); -void Box_TargetBox(LOT_INFO *LOT, int16_t box_number); -bool Box_StalkBox(ITEM_INFO *item, int16_t box_number); -bool Box_EscapeBox(ITEM_INFO *item, int16_t box_number); -bool Box_ValidBox(ITEM_INFO *item, int16_t zone_number, int16_t box_number); +void Box_TargetBox(LOT_INFO *LOT, int16_t box_num); +bool Box_StalkBox(ITEM_INFO *item, int16_t box_num); +bool Box_EscapeBox(ITEM_INFO *item, int16_t box_num); +bool Box_ValidBox(ITEM_INFO *item, int16_t zone_num, int16_t box_num); TARGET_TYPE Box_CalculateTarget(XYZ_32 *target, ITEM_INFO *item, LOT_INFO *LOT); bool Box_BadFloor( int32_t x, int32_t y, int32_t z, int16_t box_height, int16_t next_height, diff --git a/src/game/creature.c b/src/game/creature.c index d563141bd..26fb0bff0 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -52,21 +52,20 @@ void Creature_AIInfo(ITEM_INFO *item, AI_INFO *info) const ROOM_INFO *r = &g_RoomInfo[item->room_num]; int32_t z_sector = (item->pos.z - r->z) >> WALL_SHIFT; int32_t x_sector = (item->pos.x - r->x) >> WALL_SHIFT; - item->box_number = r->sectors[z_sector + x_sector * r->z_size].box; - info->zone_number = zone[item->box_number]; + item->box_num = r->sectors[z_sector + x_sector * r->z_size].box; + info->zone_num = zone[item->box_num]; r = &g_RoomInfo[g_LaraItem->room_num]; z_sector = (g_LaraItem->pos.z - r->z) >> WALL_SHIFT; x_sector = (g_LaraItem->pos.x - r->x) >> WALL_SHIFT; - g_LaraItem->box_number = r->sectors[z_sector + x_sector * r->z_size].box; - info->enemy_zone = zone[g_LaraItem->box_number]; + g_LaraItem->box_num = r->sectors[z_sector + x_sector * r->z_size].box; + info->enemy_zone = zone[g_LaraItem->box_num]; - if (g_Boxes[g_LaraItem->box_number].overlap_index - & creature->LOT.block_mask) { + if (g_Boxes[g_LaraItem->box_num].overlap_index & creature->LOT.block_mask) { info->enemy_zone |= BLOCKED; } else if ( - creature->LOT.node[item->box_number].search_number - == (creature->LOT.search_number | BLOCKED_SEARCH)) { + creature->LOT.node[item->box_num].search_num + == (creature->LOT.search_num | BLOCKED_SEARCH)) { info->enemy_zone |= BLOCKED; } @@ -98,14 +97,14 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) } LOT_INFO *LOT = &creature->LOT; - if (LOT->node[item->box_number].search_number - == (LOT->search_number | BLOCKED_SEARCH)) { + if (LOT->node[item->box_num].search_num + == (LOT->search_num | BLOCKED_SEARCH)) { LOT->required_box = NO_BOX; } if (creature->mood != MOOD_ATTACK && LOT->required_box != NO_BOX - && !Box_ValidBox(item, info->zone_number, LOT->target_box)) { - if (info->zone_number == info->enemy_zone) { + && !Box_ValidBox(item, info->zone_num, LOT->target_box)) { + if (info->zone_num == info->enemy_zone) { creature->mood = MOOD_BORED; } LOT->required_box = NO_BOX; @@ -118,14 +117,14 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) } else if (violent) { switch (mood) { case MOOD_ATTACK: - if (info->zone_number != info->enemy_zone) { + if (info->zone_num != info->enemy_zone) { creature->mood = MOOD_BORED; } break; case MOOD_BORED: case MOOD_STALK: - if (info->zone_number == info->enemy_zone) { + if (info->zone_num == info->enemy_zone) { creature->mood = MOOD_ATTACK; } else if (item->hit_status) { creature->mood = MOOD_ESCAPE; @@ -133,7 +132,7 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) break; case MOOD_ESCAPE: - if (info->zone_number == info->enemy_zone) { + if (info->zone_num == info->enemy_zone) { creature->mood = MOOD_ATTACK; } break; @@ -143,9 +142,9 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) case MOOD_ATTACK: if (item->hit_status && (Random_GetControl() < ESCAPE_CHANCE - || info->zone_number != info->enemy_zone)) { + || info->zone_num != info->enemy_zone)) { creature->mood = MOOD_ESCAPE; - } else if (info->zone_number != info->enemy_zone) { + } else if (info->zone_num != info->enemy_zone) { creature->mood = MOOD_BORED; } break; @@ -154,9 +153,9 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) case MOOD_STALK: if (item->hit_status && (Random_GetControl() < ESCAPE_CHANCE - || info->zone_number != info->enemy_zone)) { + || info->zone_num != info->enemy_zone)) { creature->mood = MOOD_ESCAPE; - } else if (info->zone_number == info->enemy_zone) { + } else if (info->zone_num == info->enemy_zone) { if (info->distance < ATTACK_RANGE || (creature->mood == MOOD_STALK && LOT->required_box == NO_BOX)) { @@ -168,7 +167,7 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) break; case MOOD_ESCAPE: - if (info->zone_number == info->enemy_zone + if (info->zone_num == info->enemy_zone && Random_GetControl() < RECOVER_CHANCE) { creature->mood = MOOD_STALK; } @@ -189,7 +188,7 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) LOT->target.x = g_LaraItem->pos.x; LOT->target.y = g_LaraItem->pos.y; LOT->target.z = g_LaraItem->pos.z; - LOT->required_box = g_LaraItem->box_number; + LOT->required_box = g_LaraItem->box_num; if (LOT->fly && g_Lara.water_status == LWS_ABOVE_WATER) { const FRAME_INFO *const frame = Item_GetBestFrame(g_LaraItem); LOT->target.y += frame->bounds.min.y; @@ -198,15 +197,14 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) break; case MOOD_BORED: { - int box_number = - LOT->node[Random_GetControl() * LOT->zone_count / 0x7FFF] - .box_number; - if (Box_ValidBox(item, info->zone_number, box_number)) { - if (Box_StalkBox(item, box_number)) { - Box_TargetBox(LOT, box_number); + int box_num = + LOT->node[Random_GetControl() * LOT->zone_count / 0x7FFF].box_num; + if (Box_ValidBox(item, info->zone_num, box_num)) { + if (Box_StalkBox(item, box_num)) { + Box_TargetBox(LOT, box_num); creature->mood = MOOD_STALK; } else if (LOT->required_box == NO_BOX) { - Box_TargetBox(LOT, box_number); + Box_TargetBox(LOT, box_num); } } break; @@ -215,15 +213,15 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) case MOOD_STALK: { if (LOT->required_box == NO_BOX || !Box_StalkBox(item, LOT->required_box)) { - int box_number = + int box_num = LOT->node[Random_GetControl() * LOT->zone_count / 0x7FFF] - .box_number; - if (Box_ValidBox(item, info->zone_number, box_number)) { - if (Box_StalkBox(item, box_number)) { - Box_TargetBox(LOT, box_number); + .box_num; + if (Box_ValidBox(item, info->zone_num, box_num)) { + if (Box_StalkBox(item, box_num)) { + Box_TargetBox(LOT, box_num); } else if (LOT->required_box == NO_BOX) { - Box_TargetBox(LOT, box_number); - if (info->zone_number != info->enemy_zone) { + Box_TargetBox(LOT, box_num); + if (info->zone_num != info->enemy_zone) { creature->mood = MOOD_BORED; } } @@ -233,17 +231,16 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) } case MOOD_ESCAPE: { - int box_number = - LOT->node[Random_GetControl() * LOT->zone_count / 0x7FFF] - .box_number; - if (Box_ValidBox(item, info->zone_number, box_number) + int box_num = + LOT->node[Random_GetControl() * LOT->zone_count / 0x7FFF].box_num; + if (Box_ValidBox(item, info->zone_num, box_num) && LOT->required_box == NO_BOX) { - if (Box_EscapeBox(item, box_number)) { - Box_TargetBox(LOT, box_number); + if (Box_EscapeBox(item, box_num)) { + Box_TargetBox(LOT, box_num); } else if ( - info->zone_number == info->enemy_zone - && Box_StalkBox(item, box_number)) { - Box_TargetBox(LOT, box_number); + info->zone_num == info->enemy_zone + && Box_StalkBox(item, box_num)) { + Box_TargetBox(LOT, box_num); creature->mood = MOOD_STALK; } } @@ -252,7 +249,7 @@ void Creature_Mood(ITEM_INFO *item, AI_INFO *info, bool violent) } if (LOT->target_box == NO_BOX) { - Box_TargetBox(LOT, item->box_number); + Box_TargetBox(LOT, item->box_num); } Box_CalculateTarget(&creature->target, item, &creature->LOT); @@ -407,7 +404,7 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt) .z = item->pos.z, }; - int32_t box_height = g_Boxes[item->box_number].height; + int32_t box_height = g_Boxes[item->box_num].height; int16_t *zone; if (LOT->fly) { @@ -447,7 +444,7 @@ bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt) int32_t pos_z; int32_t shift_x; int32_t shift_z; - if (sector->box == NO_BOX || zone[item->box_number] != zone[sector->box] + if (sector->box == NO_BOX || zone[item->box_num] != zone[sector->box] || box_height - height > LOT->step || box_height - height < LOT->drop) { pos_x = item->pos.x >> WALL_SHIFT; diff --git a/src/game/lara/lara_control.c b/src/game/lara/lara_control.c index 8d12ad23e..541da4bc6 100644 --- a/src/game/lara/lara_control.c +++ b/src/game/lara/lara_control.c @@ -39,7 +39,7 @@ static void Lara_WaterCurrent(COLL_INFO *coll) &r->sectors [((item->pos.z - r->z) >> WALL_SHIFT) + ((item->pos.x - r->x) >> WALL_SHIFT) * r->z_size]; - item->box_number = sector->box; + item->box_num = sector->box; if (Box_CalculateTarget(&target, item, &g_Lara.LOT) == TARGET_NONE) { return; diff --git a/src/game/lot.c b/src/game/lot.c index da19cbf00..7cd30b520 100644 --- a/src/game/lot.c +++ b/src/game/lot.c @@ -161,16 +161,16 @@ void LOT_CreateZone(ITEM_INFO *item) const ROOM_INFO *const r = &g_RoomInfo[item->room_num]; const int32_t z_sector = (item->pos.z - r->z) >> WALL_SHIFT; const int32_t x_sector = (item->pos.x - r->x) >> WALL_SHIFT; - item->box_number = r->sectors[z_sector + x_sector * r->z_size].box; + item->box_num = r->sectors[z_sector + x_sector * r->z_size].box; - int16_t zone_number = zone[item->box_number]; - int16_t flip_number = flip[item->box_number]; + int16_t zone_num = zone[item->box_num]; + int16_t flip_number = flip[item->box_num]; creature->LOT.zone_count = 0; BOX_NODE *node = creature->LOT.node; for (int i = 0; i < g_NumberBoxes; i++) { - if (zone[i] == zone_number || flip[i] == flip_number) { - node->box_number = i; + if (zone[i] == zone_num || flip[i] == flip_number) { + node->box_num = i; node++; creature->LOT.zone_count++; } @@ -186,7 +186,7 @@ void LOT_InitialiseLOT(LOT_INFO *LOT) void LOT_ClearLOT(LOT_INFO *LOT) { - LOT->search_number = 0; + LOT->search_num = 0; LOT->head = NO_BOX; LOT->tail = NO_BOX; LOT->target_box = NO_BOX; @@ -194,7 +194,7 @@ void LOT_ClearLOT(LOT_INFO *LOT) for (int i = 0; i < g_NumberBoxes; i++) { BOX_NODE *node = &LOT->node[i]; - node->search_number = 0; + node->search_num = 0; node->exit_box = NO_BOX; node->next_expansion = NO_BOX; } diff --git a/src/game/objects/creatures/ape.c b/src/game/objects/creatures/ape.c index 5538885f9..6f7082276 100644 --- a/src/game/objects/creatures/ape.c +++ b/src/game/objects/creatures/ape.c @@ -185,7 +185,7 @@ void Ape_Control(int16_t item_num) item->goal_anim_state = APE_ATTACK1; } else if ( !(ape->flags & APE_ATTACK_FLAG) - && info.zone_number == info.enemy_zone && info.ahead) { + && info.zone_num == info.enemy_zone && info.ahead) { int16_t random = Random_GetControl() >> 5; if (random < APE_JUMP_CHANCE) { item->goal_anim_state = APE_JUMP; diff --git a/src/game/objects/creatures/mutant.c b/src/game/objects/creatures/mutant.c index 1c3e8c767..1761b2110 100644 --- a/src/game/objects/creatures/mutant.c +++ b/src/game/objects/creatures/mutant.c @@ -139,7 +139,7 @@ void Mutant_FlyerControl(int16_t item_num) int32_t shoot2 = 0; if (item->object_id != O_WARRIOR3 && Creature_CanTargetEnemy(item, &info) - && (info.zone_number != info.enemy_zone + && (info.zone_num != info.enemy_zone || info.distance > FLYER_ATTACK_RANGE)) { if (info.angle > 0 && info.angle < PHD_45) { shoot1 = 1; @@ -151,7 +151,7 @@ void Mutant_FlyerControl(int16_t item_num) if (item->object_id == O_WARRIOR1) { if (item->current_anim_state == FLYER_FLY) { if ((flyer->flags & FLYER_FLYMODE) && flyer->mood != MOOD_ESCAPE - && info.zone_number == info.enemy_zone) { + && info.zone_num == info.enemy_zone) { flyer->flags &= ~FLYER_FLYMODE; } @@ -164,7 +164,7 @@ void Mutant_FlyerControl(int16_t item_num) flyer->LOT.fly = STEP_L / 8; Creature_AIInfo(item, &info); } else if ( - (info.zone_number != info.enemy_zone && !shoot1 && !shoot2 + (info.zone_num != info.enemy_zone && !shoot1 && !shoot2 && (!info.ahead || flyer->mood == MOOD_BORED)) || flyer->mood == MOOD_ESCAPE) { flyer->flags |= FLYER_FLYMODE; @@ -218,7 +218,7 @@ void Mutant_FlyerControl(int16_t item_num) item->goal_anim_state = FLYER_STOP; } else if (flyer->mood == MOOD_STALK) { if (info.distance < FLYER_WALK_RANGE) { - if (info.zone_number == info.enemy_zone + if (info.zone_num == info.enemy_zone || Random_GetControl() < FLYER_UNPOSE_CHANCE) { item->goal_anim_state = FLYER_WALK; } @@ -245,7 +245,7 @@ void Mutant_FlyerControl(int16_t item_num) } else if ( flyer->mood == MOOD_BORED || (flyer->mood == MOOD_STALK - && info.zone_number != info.enemy_zone)) { + && info.zone_num != info.enemy_zone)) { if (Random_GetControl() < FLYER_POSE_CHANCE) { item->goal_anim_state = FLYER_POSE; } diff --git a/src/game/objects/creatures/wolf.c b/src/game/objects/creatures/wolf.c index e122d73d6..5d06aa2c4 100644 --- a/src/game/objects/creatures/wolf.c +++ b/src/game/objects/creatures/wolf.c @@ -114,8 +114,7 @@ void Wolf_Control(int16_t item_num) switch (item->current_anim_state) { case WOLF_SLEEP: head = 0; - if (wolf->mood == MOOD_ESCAPE - || info.zone_number == info.enemy_zone) { + if (wolf->mood == MOOD_ESCAPE || info.zone_num == info.enemy_zone) { item->required_anim_state = WOLF_CROUCH; item->goal_anim_state = WOLF_STOP; } else if (Random_GetControl() < WOLF_WAKE_CHANCE) { diff --git a/src/game/savegame/savegame_bson.c b/src/game/savegame/savegame_bson.c index 0c5cc7431..6b722d0ef 100644 --- a/src/game/savegame/savegame_bson.c +++ b/src/game/savegame/savegame_bson.c @@ -736,8 +736,8 @@ static bool Savegame_BSON_LoadLOT(struct json_object_s *lot_obj, LOT_INFO *lot) lot->head = json_object_get_int(lot_obj, "head", lot->head); lot->tail = json_object_get_int(lot_obj, "tail", lot->tail); - lot->search_number = - json_object_get_int(lot_obj, "search_num", lot->search_number); + lot->search_num = + json_object_get_int(lot_obj, "search_num", lot->search_num); lot->block_mask = json_object_get_int(lot_obj, "block_mask", lot->block_mask); lot->step = json_object_get_int(lot_obj, "step", lot->step); @@ -1189,7 +1189,7 @@ static struct json_object_s *Savegame_BSON_DumpLOT(LOT_INFO *lot) // json_object_append_int(lot_obj, "node", lot->node); json_object_append_int(lot_obj, "head", lot->head); json_object_append_int(lot_obj, "tail", lot->tail); - json_object_append_int(lot_obj, "search_num", lot->search_number); + json_object_append_int(lot_obj, "search_num", lot->search_num); json_object_append_int(lot_obj, "block_mask", lot->block_mask); json_object_append_int(lot_obj, "step", lot->step); json_object_append_int(lot_obj, "drop", lot->drop); diff --git a/src/game/savegame/savegame_legacy.c b/src/game/savegame/savegame_legacy.c index 065451dc4..2888b76fa 100644 --- a/src/game/savegame/savegame_legacy.c +++ b/src/game/savegame/savegame_legacy.c @@ -292,7 +292,7 @@ static void Savegame_Legacy_WriteLOT(LOT_INFO *lot) Savegame_Legacy_Write(&lot->head, sizeof(int16_t)); Savegame_Legacy_Write(&lot->tail, sizeof(int16_t)); - Savegame_Legacy_Write(&lot->search_number, sizeof(uint16_t)); + Savegame_Legacy_Write(&lot->search_num, sizeof(uint16_t)); Savegame_Legacy_Write(&lot->block_mask, sizeof(uint16_t)); Savegame_Legacy_Write(&lot->step, sizeof(int16_t)); Savegame_Legacy_Write(&lot->drop, sizeof(int16_t)); @@ -392,7 +392,7 @@ static void Savegame_Legacy_ReadLOT(LOT_INFO *lot) Savegame_Legacy_Read(&lot->head, sizeof(int16_t)); Savegame_Legacy_Read(&lot->tail, sizeof(int16_t)); - Savegame_Legacy_Read(&lot->search_number, sizeof(uint16_t)); + Savegame_Legacy_Read(&lot->search_num, sizeof(uint16_t)); Savegame_Legacy_Read(&lot->block_mask, sizeof(uint16_t)); Savegame_Legacy_Read(&lot->step, sizeof(int16_t)); Savegame_Legacy_Read(&lot->drop, sizeof(int16_t)); diff --git a/src/global/types.h b/src/global/types.h index 72b0aae44..7324a7eb4 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1296,7 +1296,7 @@ typedef struct { int16_t speed; int16_t fall_speed; int16_t hit_points; - int16_t box_number; + int16_t box_num; int16_t timer; int16_t flags; int16_t shade; @@ -1370,16 +1370,16 @@ typedef struct AMMO_INFO { typedef struct BOX_NODE { int16_t exit_box; - uint16_t search_number; + uint16_t search_num; int16_t next_expansion; - int16_t box_number; + int16_t box_num; } BOX_NODE; typedef struct LOT_INFO { BOX_NODE *node; int16_t head; int16_t tail; - uint16_t search_number; + uint16_t search_num; uint16_t block_mask; int16_t step; int16_t drop; @@ -1850,7 +1850,7 @@ typedef struct BITE_INFO { } BITE_INFO; typedef struct AI_INFO { - int16_t zone_number; + int16_t zone_num; int16_t enemy_zone; int32_t distance; int32_t ahead; From 5e5002ae2f89a5fc023b12e81cf7e3293b5af447 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:05:22 +0200 Subject: [PATCH 6/9] types: use consistent naming for item numbers --- src/game/console_cmd.c | 2 +- src/game/creature.c | 2 +- src/game/inject.c | 4 ++-- src/game/items.c | 20 ++++++++++---------- src/game/lara/lara.c | 8 ++++---- src/game/lara/lara_cheat.c | 2 +- src/game/lara/lara_control.c | 2 +- src/game/level.c | 4 ++-- src/game/objects/creatures/trex.c | 2 +- src/game/objects/general/pickup.c | 2 +- src/game/objects/traps/rolling_ball.c | 6 +++--- src/game/phase/phase_demo.c | 2 +- src/game/room.c | 6 +++--- src/game/room_draw.c | 2 +- src/game/savegame/savegame_bson.c | 6 +++--- src/game/savegame/savegame_legacy.c | 4 ++-- src/global/types.h | 4 ++-- 17 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/game/console_cmd.c b/src/game/console_cmd.c index 2b852ad01..e89181b05 100644 --- a/src/game/console_cmd.c +++ b/src/game/console_cmd.c @@ -830,7 +830,7 @@ static COMMAND_RESULT Console_Cmd_Abortion(const char *args) return CR_UNAVAILABLE; } - Effect_ExplodingDeath(g_Lara.item_number, -1, 0); + Effect_ExplodingDeath(g_Lara.item_num, -1, 0); Sound_Effect(SFX_EXPLOSION_CHEAT, &g_LaraItem->pos, SPM_NORMAL); Sound_Effect(SFX_LARA_FALL, &g_LaraItem->pos, SPM_NORMAL); g_LaraItem->hit_points = 0; diff --git a/src/game/creature.c b/src/game/creature.c index 26fb0bff0..848742afc 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -346,7 +346,7 @@ bool Creature_CheckBaddieOverlap(int16_t item_num) int32_t z = item->pos.z; int32_t radius = SQUARE(g_Objects[item->object_id].radius); - int16_t link = g_RoomInfo[item->room_num].item_number; + int16_t link = g_RoomInfo[item->room_num].item_num; do { item = &g_Items[link]; diff --git a/src/game/inject.c b/src/game/inject.c index e10e4d78f..5cb779542 100644 --- a/src/game/inject.c +++ b/src/game/inject.c @@ -1292,8 +1292,8 @@ static void Inject_TriggeredItem(INJECTION *injection, LEVEL_INFO *level_info) return; } - int16_t item_number = Item_Create(); - ITEM_INFO *item = &g_Items[item_number]; + int16_t item_num = Item_Create(); + ITEM_INFO *item = &g_Items[item_num]; item->object_id = File_ReadS16(fp); item->room_num = File_ReadS16(fp); diff --git a/src/game/items.c b/src/game/items.c index 3c00b14fc..52a4eb24b 100644 --- a/src/game/items.c +++ b/src/game/items.c @@ -144,8 +144,8 @@ void Item_Initialise(int16_t item_num) } ROOM_INFO *const r = &g_RoomInfo[item->room_num]; - item->next_item = r->item_number; - r->item_number = item_num; + item->next_item = r->item_num; + r->item_num = item_num; const int32_t z_sector = (item->pos.z - r->z) >> WALL_SHIFT; const int32_t x_sector = (item->pos.x - r->x) >> WALL_SHIFT; const SECTOR_INFO *const sector = @@ -191,9 +191,9 @@ void Item_RemoveDrawn(int16_t item_num) ITEM_INFO *const item = &g_Items[item_num]; ROOM_INFO *const r = &g_RoomInfo[item->room_num]; - int16_t link_num = r->item_number; + int16_t link_num = r->item_num; if (link_num == item_num) { - r->item_number = item->next_item; + r->item_num = item->next_item; return; } @@ -229,9 +229,9 @@ void Item_NewRoom(int16_t item_num, int16_t room_num) ITEM_INFO *item = &g_Items[item_num]; ROOM_INFO *r = &g_RoomInfo[item->room_num]; - int16_t linknum = r->item_number; + int16_t linknum = r->item_num; if (linknum == item_num) { - r->item_number = item->next_item; + r->item_num = item->next_item; } else { for (; linknum != NO_ITEM; linknum = g_Items[linknum].next_item) { if (g_Items[linknum].next_item == item_num) { @@ -243,8 +243,8 @@ void Item_NewRoom(int16_t item_num, int16_t room_num) r = &g_RoomInfo[room_num]; item->room_num = room_num; - item->next_item = r->item_number; - r->item_number = item_num; + item->next_item = r->item_num; + r->item_num = item_num; } void Item_UpdateRoom(ITEM_INFO *item, int32_t height) @@ -256,7 +256,7 @@ void Item_UpdateRoom(ITEM_INFO *item, int32_t height) const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num); item->floor = Room_GetHeight(sector, x, y, z); if (item->room_num != room_num) { - Item_NewRoom(g_Lara.item_number, room_num); + Item_NewRoom(g_Lara.item_num, room_num); } } @@ -304,7 +304,7 @@ int32_t Item_GlobalReplace( int32_t changed = 0; for (int i = 0; i < g_RoomCount; i++) { ROOM_INFO *r = &g_RoomInfo[i]; - for (int16_t item_num = r->item_number; item_num != NO_ITEM; + for (int16_t item_num = r->item_num; item_num != NO_ITEM; item_num = g_Items[item_num].next_item) { if (g_Items[item_num].object_id == src_object_id) { g_Items[item_num].object_id = dst_object_id; diff --git a/src/game/lara/lara.c b/src/game/lara/lara.c index e8858fc59..889db5215 100644 --- a/src/game/lara/lara.c +++ b/src/game/lara/lara.c @@ -414,12 +414,12 @@ void Lara_UseItem(GAME_OBJECT_ID object_id) case O_SCION_ITEM3: case O_SCION_ITEM4: case O_SCION_OPTION: { - int16_t receptacle_item_number = Object_FindReceptacle(object_id); - if (receptacle_item_number == NO_OBJECT) { + int16_t receptacle_item_num = Object_FindReceptacle(object_id); + if (receptacle_item_num == NO_OBJECT) { Sound_Effect(SFX_LARA_NO, NULL, SPM_NORMAL); return; } - g_Lara.interact_target.item_num = receptacle_item_number; + g_Lara.interact_target.item_num = receptacle_item_num; g_Lara.interact_target.is_moving = true; g_Lara.interact_target.move_count = 0; Inv_RemoveItem(object_id); @@ -438,7 +438,7 @@ void Lara_ControlExtra(int16_t item_num) void Lara_InitialiseLoad(int16_t item_num) { - g_Lara.item_number = item_num; + g_Lara.item_num = item_num; if (item_num == NO_ITEM) { g_LaraItem = NULL; } else { diff --git a/src/game/lara/lara_cheat.c b/src/game/lara/lara_cheat.c index c017c46e5..65f8e9a20 100644 --- a/src/game/lara/lara_cheat.c +++ b/src/game/lara/lara_cheat.c @@ -113,7 +113,7 @@ void Lara_Cheat_Control(void) g_Lara.uzis.ammo = 5000; Sound_Effect(SFX_LARA_HOLSTER, NULL, SPM_ALWAYS); } else if (as == LS_SWAN_DIVE) { - Effect_ExplodingDeath(g_Lara.item_number, -1, 0); + Effect_ExplodingDeath(g_Lara.item_num, -1, 0); Sound_Effect(SFX_EXPLOSION_CHEAT, &g_LaraItem->pos, SPM_NORMAL); g_LaraItem->hit_points = 0; g_LaraItem->flags |= IS_INVISIBLE; diff --git a/src/game/lara/lara_control.c b/src/game/lara/lara_control.c index 541da4bc6..7373aeb6e 100644 --- a/src/game/lara/lara_control.c +++ b/src/game/lara/lara_control.c @@ -133,7 +133,7 @@ static void Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll) } for (int i = 0; i < numroom; i++) { - int16_t item_num = g_RoomInfo[roomies[i]].item_number; + int16_t item_num = g_RoomInfo[roomies[i]].item_num; while (item_num != NO_ITEM) { ITEM_INFO *item = &g_Items[item_num]; if (item->collidable && item->status != IS_INVISIBLE) { diff --git a/src/game/level.c b/src/game/level.c index f1460b691..fcea02af2 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -261,7 +261,7 @@ static void Level_LoadRooms(VFILE *file) current_room_info->top = Viewport_GetMaxY(); current_room_info->bottom = 0; current_room_info->right = 0; - current_room_info->item_number = NO_ITEM; + current_room_info->item_num = NO_ITEM; current_room_info->fx_number = NO_ITEM; } @@ -1086,7 +1086,7 @@ bool Level_Initialise(int32_t level_num) Level_Load(level_num); - if (g_Lara.item_number != NO_ITEM) { + if (g_Lara.item_num != NO_ITEM) { Lara_Initialise(level_num); } diff --git a/src/game/objects/creatures/trex.c b/src/game/objects/creatures/trex.c index edfe001d8..e7e4173a4 100644 --- a/src/game/objects/creatures/trex.c +++ b/src/game/objects/creatures/trex.c @@ -182,7 +182,7 @@ void TRex_LaraDeath(ITEM_INFO *item) { item->goal_anim_state = TREX_KILL; if (g_LaraItem->room_num != item->room_num) { - Item_NewRoom(g_Lara.item_number, item->room_num); + Item_NewRoom(g_Lara.item_num, item->room_num); } g_LaraItem->pos.x = item->pos.x; diff --git a/src/game/objects/general/pickup.c b/src/game/objects/general/pickup.c index 4f43cb8b8..3ee08ee7b 100644 --- a/src/game/objects/general/pickup.c +++ b/src/game/objects/general/pickup.c @@ -67,7 +67,7 @@ static void PickUp_GetItem( static void PickUp_GetAllAtLaraPos(ITEM_INFO *item, ITEM_INFO *lara_item) { - int16_t pickup_num = g_RoomInfo[item->room_num].item_number; + int16_t pickup_num = g_RoomInfo[item->room_num].item_num; while (pickup_num != NO_ITEM) { ITEM_INFO *check_item = &g_Items[pickup_num]; if (check_item->pos.x == item->pos.x && check_item->pos.z == item->pos.z diff --git a/src/game/objects/traps/rolling_ball.c b/src/game/objects/traps/rolling_ball.c index 4d6741dea..bc706b218 100644 --- a/src/game/objects/traps/rolling_ball.c +++ b/src/game/objects/traps/rolling_ball.c @@ -97,8 +97,8 @@ void RollingBall_Control(int16_t item_num) if (item->room_num != data->room_num) { Item_RemoveDrawn(item_num); ROOM_INFO *r = &g_RoomInfo[data->room_num]; - item->next_item = r->item_number; - r->item_number = item_num; + item->next_item = r->item_num; + r->item_num = item_num; item->room_num = data->room_num; } item->current_anim_state = TRAP_SET; @@ -152,7 +152,7 @@ void RollingBall_Collision( if (lara_item->hit_points > 0) { lara_item->hit_points = -1; if (lara_item->room_num != item->room_num) { - Item_NewRoom(g_Lara.item_number, item->room_num); + Item_NewRoom(g_Lara.item_num, item->room_num); } lara_item->rot.x = 0; diff --git a/src/game/phase/phase_demo.c b/src/game/phase/phase_demo.c index 718419881..4d3bdd884 100644 --- a/src/game/phase/phase_demo.c +++ b/src/game/phase/phase_demo.c @@ -187,7 +187,7 @@ static void Phase_Demo_Start(void *arg) int16_t room_num = *m_DemoPtr++; if (item->room_num != room_num) { - Item_NewRoom(g_Lara.item_number, room_num); + Item_NewRoom(g_Lara.item_num, room_num); } const SECTOR_INFO *const sector = diff --git a/src/game/room.c b/src/game/room.c index dc9487dd9..7d9cd17f5 100644 --- a/src/game/room.c +++ b/src/game/room.c @@ -125,7 +125,7 @@ static void Room_TriggerMusicTrack(int16_t track, const TRIGGER *const trigger) static void Room_AddFlipItems(ROOM_INFO *r) { - for (int16_t item_num = r->item_number; item_num != NO_ITEM; + for (int16_t item_num = r->item_num; item_num != NO_ITEM; item_num = g_Items[item_num].next_item) { ITEM_INFO *item = &g_Items[item_num]; @@ -149,7 +149,7 @@ static void Room_AddFlipItems(ROOM_INFO *r) static void Room_RemoveFlipItems(ROOM_INFO *r) { - for (int16_t item_num = r->item_number; item_num != NO_ITEM; + for (int16_t item_num = r->item_num; item_num != NO_ITEM; item_num = g_Items[item_num].next_item) { ITEM_INFO *item = &g_Items[item_num]; @@ -607,7 +607,7 @@ void Room_FlipMap(void) flipped->flipped_room = -1; // XXX: is this really necessary given the assignments above? - r->item_number = flipped->item_number; + r->item_num = flipped->item_num; r->fx_number = flipped->fx_number; Room_AddFlipItems(r); diff --git a/src/game/room_draw.c b/src/game/room_draw.c index 8b07c78ed..1707b5f7a 100644 --- a/src/game/room_draw.c +++ b/src/game/room_draw.c @@ -294,7 +294,7 @@ void Room_DrawSingleRoom(int16_t room_num) Output_DrawRoom(r->data); - for (int i = r->item_number; i != NO_ITEM; i = g_Items[i].next_item) { + for (int i = r->item_num; i != NO_ITEM; i = g_Items[i].next_item) { ITEM_INFO *item = &g_Items[i]; if (item->status != IS_INVISIBLE) { g_Objects[item->object_id].draw_routine(item); diff --git a/src/game/savegame/savegame_bson.c b/src/game/savegame/savegame_bson.c index 6b722d0ef..02c838413 100644 --- a/src/game/savegame/savegame_bson.c +++ b/src/game/savegame/savegame_bson.c @@ -764,8 +764,8 @@ static bool Savegame_BSON_LoadLara( return false; } - lara->item_number = - json_object_get_int(lara_obj, "item_number", lara->item_number); + lara->item_num = + json_object_get_int(lara_obj, "item_number", lara->item_num); lara->gun_status = json_object_get_int(lara_obj, "gun_status", lara->gun_status); lara->gun_type = json_object_get_int(lara_obj, "gun_type", lara->gun_type); @@ -1207,7 +1207,7 @@ static struct json_object_s *Savegame_BSON_DumpLara(LARA_INFO *lara) { assert(lara); struct json_object_s *lara_obj = json_object_new(); - json_object_append_int(lara_obj, "item_number", lara->item_number); + json_object_append_int(lara_obj, "item_number", lara->item_num); json_object_append_int(lara_obj, "gun_status", lara->gun_status); json_object_append_int(lara_obj, "gun_type", lara->gun_type); json_object_append_int( diff --git a/src/game/savegame/savegame_legacy.c b/src/game/savegame/savegame_legacy.c index 2888b76fa..68ba6044e 100644 --- a/src/game/savegame/savegame_legacy.c +++ b/src/game/savegame/savegame_legacy.c @@ -210,7 +210,7 @@ static void Savegame_Legacy_WriteLara(LARA_INFO *lara) { int32_t tmp32 = 0; - Savegame_Legacy_Write(&lara->item_number, sizeof(int16_t)); + Savegame_Legacy_Write(&lara->item_num, sizeof(int16_t)); Savegame_Legacy_Write(&lara->gun_status, sizeof(int16_t)); Savegame_Legacy_Write(&lara->gun_type, sizeof(int16_t)); Savegame_Legacy_Write(&lara->request_gun_type, sizeof(int16_t)); @@ -317,7 +317,7 @@ static void Savegame_Legacy_ReadLara(LARA_INFO *lara) { int32_t tmp32 = 0; - Savegame_Legacy_Read(&lara->item_number, sizeof(int16_t)); + Savegame_Legacy_Read(&lara->item_num, sizeof(int16_t)); Savegame_Legacy_Read(&lara->gun_status, sizeof(int16_t)); Savegame_Legacy_Read(&lara->gun_type, sizeof(int16_t)); Savegame_Legacy_Read(&lara->request_gun_type, sizeof(int16_t)); diff --git a/src/global/types.h b/src/global/types.h index 7324a7eb4..99a502b71 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1256,7 +1256,7 @@ typedef struct ROOM_INFO { int16_t top; int16_t bottom; int16_t bound_active; - int16_t item_number; + int16_t item_num; int16_t fx_number; int16_t flipped_room; uint16_t flags; @@ -1413,7 +1413,7 @@ typedef struct FX_INFO { } FX_INFO; typedef struct LARA_INFO { - int16_t item_number; + int16_t item_num; int16_t gun_status; LARA_GUN_TYPE gun_type; LARA_GUN_TYPE request_gun_type; From 9f06641391d5dca30cccbf0c6f1e27618ccabba2 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:07:10 +0200 Subject: [PATCH 7/9] types: use consistent naming for fx numbers --- src/game/effects.c | 18 +++++++++--------- src/game/level.c | 2 +- src/game/room.c | 2 +- src/game/room_draw.c | 2 +- src/global/types.h | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/game/effects.c b/src/game/effects.c index 4e08427c8..d58895080 100644 --- a/src/game/effects.c +++ b/src/game/effects.c @@ -51,8 +51,8 @@ int16_t Effect_Create(int16_t room_num) ROOM_INFO *r = &g_RoomInfo[room_num]; fx->room_num = room_num; - fx->next_draw = r->fx_number; - r->fx_number = fx_num; + fx->next_draw = r->fx_num; + r->fx_num = fx_num; fx->next_active = g_NextFxActive; g_NextFxActive = fx_num; @@ -78,10 +78,10 @@ void Effect_Kill(int16_t fx_num) } ROOM_INFO *r = &g_RoomInfo[fx->room_num]; - if (r->fx_number == fx_num) { - r->fx_number = fx->next_draw; + if (r->fx_num == fx_num) { + r->fx_num = fx->next_draw; } else { - int16_t linknum = r->fx_number; + int16_t linknum = r->fx_num; while (linknum != NO_ITEM) { FX_INFO *fx_link = &g_Effects[linknum]; if (fx_link->next_draw == fx_num) { @@ -101,9 +101,9 @@ void Effect_NewRoom(int16_t fx_num, int16_t room_num) FX_INFO *fx = &g_Effects[fx_num]; ROOM_INFO *r = &g_RoomInfo[fx->room_num]; - int16_t linknum = r->fx_number; + int16_t linknum = r->fx_num; if (linknum == fx_num) { - r->fx_number = fx->next_draw; + r->fx_num = fx->next_draw; } else { for (; linknum != NO_ITEM; linknum = g_Effects[linknum].next_draw) { if (g_Effects[linknum].next_draw == fx_num) { @@ -115,8 +115,8 @@ void Effect_NewRoom(int16_t fx_num, int16_t room_num) r = &g_RoomInfo[room_num]; fx->room_num = room_num; - fx->next_draw = r->fx_number; - r->fx_number = fx_num; + fx->next_draw = r->fx_num; + r->fx_num = fx_num; } void Effect_Draw(const int16_t fxnum) diff --git a/src/game/level.c b/src/game/level.c index fcea02af2..0558a0437 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -262,7 +262,7 @@ static void Level_LoadRooms(VFILE *file) current_room_info->bottom = 0; current_room_info->right = 0; current_room_info->item_num = NO_ITEM; - current_room_info->fx_number = NO_ITEM; + current_room_info->fx_num = NO_ITEM; } const int32_t fd_length = VFile_ReadS32(file); diff --git a/src/game/room.c b/src/game/room.c index 7d9cd17f5..651509691 100644 --- a/src/game/room.c +++ b/src/game/room.c @@ -608,7 +608,7 @@ void Room_FlipMap(void) // XXX: is this really necessary given the assignments above? r->item_num = flipped->item_num; - r->fx_number = flipped->fx_number; + r->fx_num = flipped->fx_num; Room_AddFlipItems(r); } diff --git a/src/game/room_draw.c b/src/game/room_draw.c index 1707b5f7a..00476517a 100644 --- a/src/game/room_draw.c +++ b/src/game/room_draw.c @@ -319,7 +319,7 @@ void Room_DrawSingleRoom(int16_t room_num) } } - for (int i = r->fx_number; i != NO_ITEM; i = g_Effects[i].next_draw) { + for (int i = r->fx_num; i != NO_ITEM; i = g_Effects[i].next_draw) { Effect_Draw(i); } diff --git a/src/global/types.h b/src/global/types.h index 99a502b71..c4a9f4ff5 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1257,7 +1257,7 @@ typedef struct ROOM_INFO { int16_t bottom; int16_t bound_active; int16_t item_num; - int16_t fx_number; + int16_t fx_num; int16_t flipped_room; uint16_t flags; } ROOM_INFO; From d71dc24273adcb9e65b6c119db42b49ef3b11e8f Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:07:22 +0200 Subject: [PATCH 8/9] types: use consistent naming for mesh numbers --- src/game/inject.c | 2 +- src/game/level.c | 6 +++--- src/game/output.c | 8 ++++---- src/game/room_draw.c | 2 +- src/global/types.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/game/inject.c b/src/game/inject.c index 5cb779542..00c17f5a0 100644 --- a/src/game/inject.c +++ b/src/game/inject.c @@ -515,7 +515,7 @@ static void Inject_TextureData( } else if (object_id - O_NUMBER_OF < STATIC_NUMBER_OF) { STATIC_INFO *object = &g_StaticObjects[object_id - O_NUMBER_OF]; object->nmeshes = num_meshes; - object->mesh_number = mesh_index + level_info->sprite_info_count; + object->mesh_num = mesh_index + level_info->sprite_info_count; object->loaded = true; } level_info->sprite_info_count -= num_meshes; diff --git a/src/game/level.c b/src/game/level.c index 0558a0437..e107ab12c 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -517,7 +517,7 @@ static void Level_LoadStaticObjects(VFILE *file) const int32_t tmp = VFile_ReadS32(file); STATIC_INFO *object = &g_StaticObjects[tmp]; - object->mesh_number = VFile_ReadS16(file); + object->mesh_num = VFile_ReadS16(file); object->p.min.x = VFile_ReadS16(file); object->p.max.x = VFile_ReadS16(file); object->p.min.y = VFile_ReadS16(file); @@ -592,7 +592,7 @@ static void Level_LoadSprites(VFILE *file) } else if (object_id - O_NUMBER_OF < STATIC_NUMBER_OF) { STATIC_INFO *object = &g_StaticObjects[object_id - O_NUMBER_OF]; object->nmeshes = num_meshes; - object->mesh_number = mesh_index; + object->mesh_num = mesh_index; object->loaded = true; } } @@ -977,7 +977,7 @@ static size_t Level_CalculateMaxVertices(void) } max_vertices = - MAX(max_vertices, *(g_Meshes[static_info->mesh_number] + 5)); + MAX(max_vertices, *(g_Meshes[static_info->mesh_num] + 5)); } for (int32_t i = 0; i < g_RoomCount; i++) { diff --git a/src/game/output.c b/src/game/output.c index 71dcf97f4..b1c11ddea 100644 --- a/src/game/output.c +++ b/src/game/output.c @@ -1070,12 +1070,12 @@ void Output_AnimateTextures(void) } const int32_t num_meshes = -static_info->nmeshes; - const PHD_SPRITE temp = g_PhdSpriteInfo[static_info->mesh_number]; + const PHD_SPRITE temp = g_PhdSpriteInfo[static_info->mesh_num]; for (int32_t j = 0; j < num_meshes - 1; j++) { - g_PhdSpriteInfo[static_info->mesh_number + j] = - g_PhdSpriteInfo[static_info->mesh_number + j + 1]; + g_PhdSpriteInfo[static_info->mesh_num + j] = + g_PhdSpriteInfo[static_info->mesh_num + j + 1]; } - g_PhdSpriteInfo[static_info->mesh_number + num_meshes - 1] = temp; + g_PhdSpriteInfo[static_info->mesh_num + num_meshes - 1] = temp; } } diff --git a/src/game/room_draw.c b/src/game/room_draw.c index 00476517a..8c996102e 100644 --- a/src/game/room_draw.c +++ b/src/game/room_draw.c @@ -312,7 +312,7 @@ void Room_DrawSingleRoom(int16_t room_num) if (clip) { Output_CalculateStaticLight(mesh->shade); Output_DrawPolygons( - g_Meshes[g_StaticObjects[mesh->static_number].mesh_number], + g_Meshes[g_StaticObjects[mesh->static_number].mesh_num], clip); } Matrix_Pop(); diff --git a/src/global/types.h b/src/global/types.h index c4a9f4ff5..b8b0083aa 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1718,7 +1718,7 @@ typedef struct SHADOW_INFO { typedef struct STATIC_INFO { bool loaded; int16_t nmeshes; - int16_t mesh_number; + int16_t mesh_num; int16_t flags; BOUNDS_16 p; BOUNDS_16 c; From 6cc5f13f723775f14124172aec3b9d352475e4a3 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 10:09:10 +0200 Subject: [PATCH 9/9] types: use consistent naming for miscellaneous numbers --- src/game/carrier.c | 14 +++++++------- src/game/collide.c | 2 +- src/game/level.c | 2 +- src/game/lot.c | 4 ++-- src/game/room_draw.c | 7 +++---- src/global/types.h | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/game/carrier.c b/src/game/carrier.c index 6e3242293..94e8878f4 100644 --- a/src/game/carrier.c +++ b/src/game/carrier.c @@ -68,7 +68,7 @@ void Carrier_InitialiseLevel(int32_t level_num) CARRIED_ITEM *drop = item->carried_item; for (int i = 0; i < data->count; i++) { drop->object_id = data->object_ids[i]; - drop->spawn_number = NO_ITEM; + drop->spawn_num = NO_ITEM; drop->room_num = NO_ROOM; drop->fall_speed = 0; @@ -137,7 +137,7 @@ DROP_STATUS Carrier_GetSaveStatus(const CARRIED_ITEM *item) // This allows us to save drops as still being carried to allow accurate // placement again in Carrier_TestItemDrops on load. if (item->status == DS_DROPPED) { - ITEM_INFO *pickup = &g_Items[item->spawn_number]; + ITEM_INFO *pickup = &g_Items[item->spawn_num]; return pickup->status == IS_INVISIBLE ? DS_COLLECTED : DS_CARRIED; } else if (item->status == DS_FALLING) { return DS_CARRIED; @@ -170,17 +170,17 @@ void Carrier_TestItemDrops(int16_t item_num) object_id = Object_GetCognate(object_id, g_GunAmmoObjectMap); } - item->spawn_number = Item_Spawn(carrier, object_id); + item->spawn_num = Item_Spawn(carrier, object_id); item->status = DS_FALLING; m_AnimatingCount++; if (item->room_num != NO_ROOM) { // Handle reloading a save with a falling or landed item. - ITEM_INFO *pickup = &g_Items[item->spawn_number]; + ITEM_INFO *pickup = &g_Items[item->spawn_num]; pickup->pos = item->pos; pickup->fall_speed = item->fall_speed; if (pickup->room_num != item->room_num) { - Item_NewRoom(item->spawn_number, item->room_num); + Item_NewRoom(item->spawn_num, item->room_num); } } @@ -238,7 +238,7 @@ static void Carrier_AnimateDrop(CARRIED_ITEM *item) return; } - ITEM_INFO *const pickup = &g_Items[item->spawn_number]; + ITEM_INFO *const pickup = &g_Items[item->spawn_num]; int16_t room_num = pickup->room_num; const SECTOR_INFO *const sector = Room_GetSector(pickup->pos.x, pickup->pos.y, pickup->pos.z, &room_num); @@ -265,7 +265,7 @@ static void Carrier_AnimateDrop(CARRIED_ITEM *item) } if (room_num != pickup->room_num) { - Item_NewRoom(item->spawn_number, room_num); + Item_NewRoom(item->spawn_num, room_num); } // Track animating status in the carrier for saving/loading. diff --git a/src/game/collide.c b/src/game/collide.c index 7d931b78d..b0bb34dcc 100644 --- a/src/game/collide.c +++ b/src/game/collide.c @@ -336,7 +336,7 @@ bool Collide_CollideStaticObjects( MESH_INFO *mesh = r->mesh; for (int j = 0; j < r->num_meshes; j++, mesh++) { - STATIC_INFO *sinfo = &g_StaticObjects[mesh->static_number]; + STATIC_INFO *sinfo = &g_StaticObjects[mesh->static_num]; if (sinfo->flags & 1) { continue; } diff --git a/src/game/level.c b/src/game/level.c index e107ab12c..89f7ebb32 100644 --- a/src/game/level.c +++ b/src/game/level.c @@ -245,7 +245,7 @@ static void Level_LoadRooms(VFILE *file) mesh->pos.z = VFile_ReadS32(file); mesh->rot.y = VFile_ReadS16(file); mesh->shade = VFile_ReadU16(file); - mesh->static_number = VFile_ReadU16(file); + mesh->static_num = VFile_ReadU16(file); } } diff --git a/src/game/lot.c b/src/game/lot.c index 7cd30b520..285949719 100644 --- a/src/game/lot.c +++ b/src/game/lot.c @@ -164,12 +164,12 @@ void LOT_CreateZone(ITEM_INFO *item) item->box_num = r->sectors[z_sector + x_sector * r->z_size].box; int16_t zone_num = zone[item->box_num]; - int16_t flip_number = flip[item->box_num]; + int16_t flip_num = flip[item->box_num]; creature->LOT.zone_count = 0; BOX_NODE *node = creature->LOT.node; for (int i = 0; i < g_NumberBoxes; i++) { - if (zone[i] == zone_num || flip[i] == flip_number) { + if (zone[i] == zone_num || flip[i] == flip_num) { node->box_num = i; node++; creature->LOT.zone_count++; diff --git a/src/game/room_draw.c b/src/game/room_draw.c index 8c996102e..b0bf75295 100644 --- a/src/game/room_draw.c +++ b/src/game/room_draw.c @@ -303,17 +303,16 @@ void Room_DrawSingleRoom(int16_t room_num) for (int i = 0; i < r->num_meshes; i++) { MESH_INFO *mesh = &r->mesh[i]; - if (g_StaticObjects[mesh->static_number].flags & 2) { + if (g_StaticObjects[mesh->static_num].flags & 2) { Matrix_Push(); Matrix_TranslateAbs(mesh->pos.x, mesh->pos.y, mesh->pos.z); Matrix_RotY(mesh->rot.y); int clip = - Output_GetObjectBounds(&g_StaticObjects[mesh->static_number].p); + Output_GetObjectBounds(&g_StaticObjects[mesh->static_num].p); if (clip) { Output_CalculateStaticLight(mesh->shade); Output_DrawPolygons( - g_Meshes[g_StaticObjects[mesh->static_number].mesh_num], - clip); + g_Meshes[g_StaticObjects[mesh->static_num].mesh_num], clip); } Matrix_Pop(); } diff --git a/src/global/types.h b/src/global/types.h index b8b0083aa..691e8f5ae 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1232,7 +1232,7 @@ typedef struct MESH_INFO { PHD_ANGLE y; } rot; uint16_t shade; - uint16_t static_number; + uint16_t static_num; } MESH_INFO; typedef struct ROOM_INFO { @@ -1271,7 +1271,7 @@ typedef enum DROP_STATUS { typedef struct CARRIED_ITEM { GAME_OBJECT_ID object_id; - int16_t spawn_number; + int16_t spawn_num; XYZ_32 pos; XYZ_16 rot; int16_t room_num;