Skip to content

Commit

Permalink
objects: extract vars module
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 21, 2024
1 parent acccb72 commit f7c5121
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 217 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ sources = [
'src/game/objects/traps/teeth_trap.c',
'src/game/objects/traps/thors_hammer_handle.c',
'src/game/objects/traps/thors_hammer_head.c',
'src/game/objects/vars.c',
'src/game/option/option.c',
'src/game/option/option_compass.c',
'src/game/option/option_control.c',
Expand Down
2 changes: 1 addition & 1 deletion src/game/carrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "game/gameflow.h"
#include "game/inventory.h"
#include "game/items.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"
#include "game/room.h"
#include "global/const.h"
#include "global/types.h"
Expand Down
1 change: 1 addition & 0 deletions src/game/console/cmd/teleport.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "game/lara/cheat.h"
#include "game/objects/common.h"
#include "game/objects/names.h"
#include "game/objects/vars.h"
#include "game/random.h"
#include "game/room.h"
#include "global/const.h"
Expand Down
1 change: 1 addition & 0 deletions src/game/creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "game/los.h"
#include "game/lot.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"
#include "game/random.h"
#include "game/room.h"
#include "global/vars.h"
Expand Down
1 change: 1 addition & 0 deletions src/game/inventory/inventory_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "game/inventory/inventory_vars.h"
#include "game/items.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"
#include "global/const.h"
#include "global/types.h"
#include "global/vars.h"
Expand Down
1 change: 1 addition & 0 deletions src/game/lara/cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "game/lara/common.h"
#include "game/lot.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"
#include "game/room.h"
#include "game/sound.h"
#include "game/viewport.h"
Expand Down
1 change: 1 addition & 0 deletions src/game/lara/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "game/music.h"
#include "game/objects/common.h"
#include "game/objects/effects/splash.h"
#include "game/objects/vars.h"
#include "game/room.h"
#include "game/savegame.h"
#include "game/sound.h"
Expand Down
204 changes: 0 additions & 204 deletions src/game/objects/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,181 +17,6 @@
#include <assert.h>
#include <stddef.h>

const GAME_OBJECT_ID g_EnemyObjects[] = {
// clang-format off
O_WOLF,
O_BEAR,
O_BAT,
O_CROCODILE,
O_ALLIGATOR,
O_LION,
O_LIONESS,
O_PUMA,
O_APE,
O_RAT,
O_VOLE,
O_TREX,
O_RAPTOR,
O_WARRIOR_1,
O_WARRIOR_2,
O_WARRIOR_3,
O_CENTAUR,
O_MUMMY,
O_TORSO,
O_DINO_WARRIOR,
O_FISH,
O_LARSON,
O_PIERRE,
O_SKATEKID,
O_COWBOY,
O_BALDY,
O_NATLA,
O_SCION_ITEM_3,
O_STATUE,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_ID g_AllyObjects[] = {
// clang-format off
O_LARA,
NO_OBJECT,
// Lara's social skills: still loading...
// clang-format on
};

const GAME_OBJECT_ID g_BossObjects[] = {
// clang-format off
O_TREX,
O_LARSON,
O_PIERRE,
O_SKATEKID,
O_COWBOY,
O_BALDY,
O_NATLA,
O_TORSO,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_ID g_PlaceholderObjects[] = {
// clang-format off
O_STATUE,
O_PODS,
O_BIG_POD,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_ID g_PickupObjects[] = {
// clang-format off
O_PISTOL_ITEM,
O_SHOTGUN_ITEM,
O_MAGNUM_ITEM,
O_UZI_ITEM,
O_PISTOL_AMMO_ITEM,
O_SG_AMMO_ITEM,
O_MAG_AMMO_ITEM,
O_UZI_AMMO_ITEM,
O_MEDI_ITEM,
O_BIGMEDI_ITEM,
O_EXPLOSIVE_ITEM,
O_PUZZLE_ITEM_1,
O_PUZZLE_ITEM_2,
O_PUZZLE_ITEM_3,
O_PUZZLE_ITEM_4,
O_KEY_ITEM_1,
O_KEY_ITEM_2,
O_KEY_ITEM_3,
O_KEY_ITEM_4,
O_PICKUP_ITEM_1,
O_PICKUP_ITEM_2,
O_LEADBAR_ITEM,
O_SCION_ITEM_1,
O_SCION_ITEM_2,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_ID g_GunObjects[] = {
// clang-format off
O_PISTOL_ITEM,
O_SHOTGUN_ITEM,
O_MAGNUM_ITEM,
O_UZI_ITEM,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_ID g_DoorObjects[] = {
// clang-format off
O_DOOR_TYPE_1,
O_DOOR_TYPE_2,
O_DOOR_TYPE_3,
O_DOOR_TYPE_4,
O_DOOR_TYPE_5,
O_DOOR_TYPE_6,
O_DOOR_TYPE_7,
O_DOOR_TYPE_8,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_ID g_TrapdoorObjects[] = {
// clang-format off
O_TRAPDOOR_1,
O_TRAPDOOR_2,
O_BIGTRAPDOOR,
O_DRAWBRIDGE,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_ID g_InvObjects[] = {
// clang-format off
O_PISTOL_OPTION,
O_SHOTGUN_OPTION,
O_MAGNUM_OPTION,
O_UZI_OPTION,
O_SG_AMMO_OPTION,
O_MAG_AMMO_OPTION,
O_UZI_AMMO_OPTION,
O_EXPLOSIVE_OPTION,
O_MEDI_OPTION,
O_BIGMEDI_OPTION,
O_PUZZLE_OPTION_1,
O_PUZZLE_OPTION_2,
O_PUZZLE_OPTION_3,
O_PUZZLE_OPTION_4,
O_LEADBAR_OPTION,
O_KEY_OPTION_1,
O_KEY_OPTION_2,
O_KEY_OPTION_3,
O_KEY_OPTION_4,
O_PICKUP_OPTION_1,
O_PICKUP_OPTION_2,
O_SCION_OPTION,
O_DETAIL_OPTION,
O_SOUND_OPTION,
O_CONTROL_OPTION,
O_GAMMA_OPTION,
O_PASSPORT_OPTION,
O_MAP_OPTION,
O_PHOTO_OPTION,
NO_OBJECT,
// clang-format on
};

const GAME_OBJECT_PAIR g_GunAmmoObjectMap[] = {
// clang-format off
{ O_PISTOL_ITEM, O_PISTOL_AMMO_ITEM },
{ O_SHOTGUN_ITEM, O_SG_AMMO_ITEM },
{ O_MAGNUM_ITEM, O_MAG_AMMO_ITEM },
{ O_UZI_ITEM, O_UZI_AMMO_ITEM },
{ NO_OBJECT, NO_OBJECT },
// clang-format on
};

static const GAME_OBJECT_PAIR m_KeyItemToReceptacleMap[] = {
// clang-format off
{ O_KEY_OPTION_1, O_KEY_HOLE_1 },
Expand All @@ -207,35 +32,6 @@ static const GAME_OBJECT_PAIR m_KeyItemToReceptacleMap[] = {
// clang-format on
};

const GAME_OBJECT_PAIR g_ItemToInvObjectMap[] = {
// clang-format off
{ O_PISTOL_ITEM, O_PISTOL_OPTION },
{ O_SHOTGUN_ITEM, O_SHOTGUN_OPTION },
{ O_MAGNUM_ITEM, O_MAGNUM_OPTION },
{ O_UZI_ITEM, O_UZI_OPTION },
{ O_SG_AMMO_ITEM, O_SG_AMMO_OPTION },
{ O_MAG_AMMO_ITEM, O_MAG_AMMO_OPTION },
{ O_UZI_AMMO_ITEM, O_UZI_AMMO_OPTION },
{ O_EXPLOSIVE_ITEM, O_EXPLOSIVE_OPTION },
{ O_MEDI_ITEM, O_MEDI_OPTION },
{ O_BIGMEDI_ITEM, O_BIGMEDI_OPTION },
{ O_PUZZLE_ITEM_1, O_PUZZLE_OPTION_1 },
{ O_PUZZLE_ITEM_2, O_PUZZLE_OPTION_2 },
{ O_PUZZLE_ITEM_3, O_PUZZLE_OPTION_3 },
{ O_PUZZLE_ITEM_4, O_PUZZLE_OPTION_4 },
{ O_LEADBAR_ITEM, O_LEADBAR_OPTION },
{ O_KEY_ITEM_1, O_KEY_OPTION_1 },
{ O_KEY_ITEM_2, O_KEY_OPTION_2 },
{ O_KEY_ITEM_3, O_KEY_OPTION_3 },
{ O_KEY_ITEM_4, O_KEY_OPTION_4 },
{ O_PICKUP_ITEM_1, O_PICKUP_OPTION_1 },
{ O_PICKUP_ITEM_2, O_PICKUP_OPTION_2 },
{ O_SCION_ITEM_1, O_SCION_OPTION },
{ O_SCION_ITEM_2, O_SCION_OPTION },
{ NO_OBJECT, NO_OBJECT },
// clang-format on
};

OBJECT_INFO *Object_GetObject(GAME_OBJECT_ID object_id)
{
return &g_Objects[object_id];
Expand Down
12 changes: 0 additions & 12 deletions src/game/objects/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ typedef struct GAME_OBJECT_PAIR {
const GAME_OBJECT_ID value_id;
} GAME_OBJECT_PAIR;

extern const GAME_OBJECT_ID g_EnemyObjects[];
extern const GAME_OBJECT_ID g_AllyObjects[];
extern const GAME_OBJECT_ID g_BossObjects[];
extern const GAME_OBJECT_ID g_PlaceholderObjects[];
extern const GAME_OBJECT_ID g_PickupObjects[];
extern const GAME_OBJECT_ID g_GunObjects[];
extern const GAME_OBJECT_ID g_DoorObjects[];
extern const GAME_OBJECT_ID g_TrapdoorObjects[];
extern const GAME_OBJECT_ID g_InvObjects[];
extern const GAME_OBJECT_PAIR g_GunAmmoObjectMap[];
extern const GAME_OBJECT_PAIR g_ItemToInvObjectMap[];

GAME_OBJECT_ID Object_GetCognate(
GAME_OBJECT_ID key_id, const GAME_OBJECT_PAIR *test_map);
GAME_OBJECT_ID Object_GetCognateInverse(
Expand Down
1 change: 1 addition & 0 deletions src/game/objects/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "game/inventory.h"
#include "game/inventory/inventory_vars.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"

#include <libtrx/memory.h>
#include <libtrx/strings.h>
Expand Down
1 change: 1 addition & 0 deletions src/game/objects/traps/movable_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "game/items.h"
#include "game/lara/common.h"
#include "game/objects/common.h"
#include "game/objects/vars.h"
#include "game/room.h"
#include "game/sound.h"
#include "global/const.h"
Expand Down
Loading

0 comments on commit f7c5121

Please sign in to comment.