Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Fix crash in /set; refactor typing information #256

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased](https://github.com/LostArtefacts/TR2X/compare/stable...develop) - ××××-××-××
- added `/sfx` command
- fixed crash in the `/set` console command (regression from 0.3)

## [0.3](https://github.com/LostArtefacts/TR2X/compare/0.2-460-g4721b93...0.3) - 2024-09-20
- added new console commands:
Expand Down
1,224 changes: 612 additions & 612 deletions docs/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
738 changes: 369 additions & 369 deletions docs/progress.txt

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@
#include <libtrx/config/config_file.h>
#include <libtrx/filesystem.h>

struct json_object_s;

CONFIG g_Config = { 0 };

#define DIR_CONFIG "cfg"

static const char *m_ConfigPath = DIR_CONFIG "/TR2X.json5";

static void M_Load(struct json_object_s *root_obj);
static void M_Dump(struct json_object_s *root_obj);
static void M_Load(JSON_OBJECT *root_obj);
static void M_Dump(JSON_OBJECT *root_obj);

static void M_Load(struct json_object_s *root_obj)
static void M_Load(JSON_OBJECT *root_obj)
{
ConfigFile_LoadOptions(root_obj, g_ConfigOptionMap);
}

static void M_Dump(struct json_object_s *root_obj)
static void M_Dump(JSON_OBJECT *root_obj)
{
ConfigFile_DumpOptions(root_obj, g_ConfigOptionMap);
}
Expand Down
20 changes: 10 additions & 10 deletions src/decomp/decomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,17 +1217,17 @@ int32_t __cdecl Game_Cutscene_Control(const int32_t nframes)
g_DynamicLightCount = 0;

for (int32_t id = g_NextItemActive; id != NO_ITEM;) {
const ITEM_INFO *const item = &g_Items[id];
const OBJECT_INFO *obj = &g_Objects[item->object_id];
const ITEM *const item = &g_Items[id];
const OBJECT *obj = &g_Objects[item->object_id];
if (obj->control != NULL) {
obj->control(id);
}
id = item->next_active;
}

for (int32_t id = g_NextEffectActive; id != NO_ITEM;) {
const FX_INFO *const fx = &g_Effects[id];
const OBJECT_INFO *const obj = &g_Objects[fx->object_id];
const FX *const fx = &g_Effects[id];
const OBJECT *const obj = &g_Objects[fx->object_id];
if (obj->control != NULL) {
obj->control(id);
}
Expand Down Expand Up @@ -1262,7 +1262,7 @@ int32_t __cdecl Game_Cutscene_Control(const int32_t nframes)

void __cdecl CutscenePlayer_Control(const int16_t item_num)
{
ITEM_INFO *const item = &g_Items[item_num];
ITEM *const item = &g_Items[item_num];
item->rot.y = g_Camera.target_angle;
item->pos.x = g_Camera.pos.pos.x;
item->pos.y = g_Camera.pos.pos.y;
Expand All @@ -1289,7 +1289,7 @@ void __cdecl CutscenePlayer_Control(const int16_t item_num)

void __cdecl Lara_Control_Cutscene(const int16_t item_num)
{
ITEM_INFO *const item = &g_Items[item_num];
ITEM *const item = &g_Items[item_num];
item->rot.y = g_Camera.target_angle;
item->pos.x = g_Camera.pos.pos.x;
item->pos.y = g_Camera.pos.pos.y;
Expand All @@ -1308,12 +1308,12 @@ void __cdecl Lara_Control_Cutscene(const int16_t item_num)

void __cdecl CutscenePlayer1_Initialise(const int16_t item_num)
{
OBJECT_INFO *const obj = &g_Objects[O_LARA];
OBJECT *const obj = &g_Objects[O_LARA];
obj->draw_routine = Lara_Draw;
obj->control = Lara_Control_Cutscene;

Item_AddActive(item_num);
ITEM_INFO *const item = &g_Items[item_num];
ITEM *const item = &g_Items[item_num];
g_Camera.pos.pos.x = item->pos.x;
g_Camera.pos.pos.y = item->pos.y;
g_Camera.pos.pos.z = item->pos.z;
Expand All @@ -1334,7 +1334,7 @@ void __cdecl CutscenePlayer1_Initialise(const int16_t item_num)
void __cdecl CutscenePlayerGen_Initialise(const int16_t item_num)
{
Item_AddActive(item_num);
ITEM_INFO *const item = &g_Items[item_num];
ITEM *const item = &g_Items[item_num];
item->rot.y = 0;
item->dynamic_light = 0;
}
Expand Down Expand Up @@ -1374,7 +1374,7 @@ int32_t __cdecl Level_Initialise(
|| level_type == GFL_DEMO) {
GetCarriedItems();
}
g_Effects = game_malloc(MAX_EFFECTS * sizeof(FX_INFO), GBUF_EFFECTS_ARRAY);
g_Effects = game_malloc(MAX_EFFECTS * sizeof(FX), GBUF_EFFECTS_ARRAY);
Effect_InitialiseArray();
LOT_InitialiseArray();
Inv_InitColors();
Expand Down
8 changes: 4 additions & 4 deletions src/decomp/effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
int32_t __cdecl Effect_ExplodingDeath(
const int16_t item_num, const int32_t mesh_bits, const int16_t damage)
{
ITEM_INFO *const item = &g_Items[item_num];
const OBJECT_INFO *const object = &g_Objects[item->object_id];
ITEM *const item = &g_Items[item_num];
const OBJECT *const object = &g_Objects[item->object_id];

S_CalculateLight(item->pos.x, item->pos.y, item->pos.z, item->room_num);

Expand All @@ -36,7 +36,7 @@ int32_t __cdecl Effect_ExplodingDeath(
if ((mesh_bits & bit) && (item->mesh_bits & bit)) {
const int16_t fx_num = Effect_Create(item->room_num);
if (fx_num != NO_ITEM) {
FX_INFO *const fx = &g_Effects[fx_num];
FX *const fx = &g_Effects[fx_num];
fx->pos.x = item->pos.x + (g_MatrixPtr->_03 >> W2V_SHIFT);
fx->pos.y = item->pos.y + (g_MatrixPtr->_13 >> W2V_SHIFT);
fx->pos.z = item->pos.z + (g_MatrixPtr->_23 >> W2V_SHIFT);
Expand Down Expand Up @@ -84,7 +84,7 @@ int32_t __cdecl Effect_ExplodingDeath(
if ((mesh_bits & bit) && (item->mesh_bits & bit)) {
const int16_t fx_num = Effect_Create(item->room_num);
if (fx_num != NO_ITEM) {
FX_INFO *const fx = &g_Effects[fx_num];
FX *const fx = &g_Effects[fx_num];
fx->pos.x = item->pos.x + (g_MatrixPtr->_03 >> W2V_SHIFT);
fx->pos.y = item->pos.y + (g_MatrixPtr->_13 >> W2V_SHIFT);
fx->pos.z = item->pos.z + (g_MatrixPtr->_23 >> W2V_SHIFT);
Expand Down
2 changes: 1 addition & 1 deletion src/game/background.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void __cdecl DrawQuad(

void __cdecl BGND_DrawInGameBackground(void)
{
const OBJECT_INFO *const obj = &g_Objects[O_INV_BACKGROUND];
const OBJECT *const obj = &g_Objects[O_INV_BACKGROUND];
if (!obj->loaded) {
BGND_DrawInGameBlack();
return;
Expand Down
14 changes: 6 additions & 8 deletions src/game/box.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ void __cdecl Box_TargetBox(LOT_INFO *const lot, const int16_t box_num)
}

int32_t __cdecl Box_StalkBox(
const ITEM_INFO *const item, const ITEM_INFO *const enemy,
const int16_t box_num)
const ITEM *const item, const ITEM *const enemy, const int16_t box_num)
{
const BOX_INFO *const box = &g_Boxes[box_num];

Expand Down Expand Up @@ -178,8 +177,7 @@ int32_t __cdecl Box_StalkBox(
}

int32_t __cdecl Box_EscapeBox(
const ITEM_INFO *const item, const ITEM_INFO *const enemy,
const int16_t box_num)
const ITEM *const item, const ITEM *const enemy, const int16_t box_num)
{
const BOX_INFO *const box = &g_Boxes[box_num];
const int32_t x =
Expand All @@ -198,9 +196,9 @@ int32_t __cdecl Box_EscapeBox(
}

int32_t __cdecl Box_ValidBox(
const ITEM_INFO *const item, const int16_t zone_num, const int16_t box_num)
const ITEM *const item, const int16_t zone_num, const int16_t box_num)
{
const CREATURE_INFO *const creature = item->data;
const CREATURE *const creature = item->data;
int16_t *zone;
if (creature->lot.fly) {
zone = g_FlyZone[g_FlipStatus];
Expand All @@ -225,7 +223,7 @@ int32_t __cdecl Box_ValidBox(
}

TARGET_TYPE __cdecl Box_CalculateTarget(
XYZ_32 *const target, const ITEM_INFO *const item, LOT_INFO *const lot)
XYZ_32 *const target, const ITEM *const item, LOT_INFO *const lot)
{
Box_UpdateLOT(lot, BOX_MAX_EXPANSION);

Expand Down Expand Up @@ -396,7 +394,7 @@ int32_t __cdecl Box_BadFloor(
const int32_t x, const int32_t y, const int32_t z, const int32_t box_height,
const int32_t next_height, int16_t room_num, const LOT_INFO *const lot)
{
const SECTOR_INFO *const sector = Room_GetSector(x, y, z, &room_num);
const SECTOR *const sector = Room_GetSector(x, y, z, &room_num);
const int16_t box_num = sector->box;
if (box_num == NO_BOX) {
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/game/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ int32_t __cdecl Box_SearchLOT(LOT_INFO *lot, int32_t expansion);
int32_t __cdecl Box_UpdateLOT(LOT_INFO *lot, int32_t expansion);
void __cdecl Box_TargetBox(LOT_INFO *lot, int16_t box_num);
int32_t __cdecl Box_StalkBox(
const ITEM_INFO *item, const ITEM_INFO *enemy, int16_t box_num);
const ITEM *item, const ITEM *enemy, int16_t box_num);
int32_t __cdecl Box_EscapeBox(
const ITEM_INFO *item, const ITEM_INFO *enemy, int16_t box_num);
const ITEM *item, const ITEM *enemy, int16_t box_num);
int32_t __cdecl Box_ValidBox(
const ITEM_INFO *item, int16_t zone_num, int16_t box_num);
const ITEM *item, int16_t zone_num, int16_t box_num);
TARGET_TYPE __cdecl Box_CalculateTarget(
XYZ_32 *target, const ITEM_INFO *item, LOT_INFO *lot);
XYZ_32 *target, const ITEM *item, LOT_INFO *lot);
int32_t __cdecl Box_BadFloor(
int32_t x, int32_t y, int32_t z, int32_t box_height, int32_t next_height,
int16_t room_num, const LOT_INFO *lot);
32 changes: 16 additions & 16 deletions src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void __cdecl Camera_Move(const GAME_VECTOR *target, int32_t speed)

g_IsChunkyCamera = 0;

const SECTOR_INFO *sector = Room_GetSector(
const SECTOR *sector = Room_GetSector(
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)
Expand Down Expand Up @@ -218,10 +218,10 @@ void __cdecl Camera_Shift(
}
}

const SECTOR_INFO *__cdecl Camera_GoodPosition(
const SECTOR *__cdecl Camera_GoodPosition(
int32_t x, int32_t y, int32_t z, int16_t room_num)
{
const SECTOR_INFO *sector = Room_GetSector(x, y, z, &room_num);
const SECTOR *sector = Room_GetSector(x, y, z, &room_num);
int32_t height = Room_GetHeight(sector, x, y, z);
int32_t ceiling = Room_GetCeiling(sector, x, y, z);
if (y > height || y < ceiling) {
Expand All @@ -240,10 +240,10 @@ void __cdecl Camera_SmartShift(
{
LOS_Check(&g_Camera.target, target);

const ROOM_INFO *r = &g_Rooms[g_Camera.target.room_num];
const ROOM *r = &g_Rooms[g_Camera.target.room_num];
int32_t z_sector = (g_Camera.target.z - r->pos.z) >> WALL_SHIFT;
int32_t x_sector = (g_Camera.target.x - r->pos.x) >> WALL_SHIFT;
int16_t item_box = r->sector[z_sector + x_sector * r->z_size].box;
int16_t item_box = r->sectors[z_sector + x_sector * r->size.z].box;
const BOX_INFO *box = &g_Boxes[item_box];

int32_t left = (int32_t)box->left << WALL_SHIFT;
Expand All @@ -254,7 +254,7 @@ void __cdecl Camera_SmartShift(
r = &g_Rooms[target->room_num];
z_sector = (target->z - r->pos.z) >> WALL_SHIFT;
x_sector = (target->x - r->pos.x) >> WALL_SHIFT;
int16_t camera_box = r->sector[z_sector + x_sector * r->z_size].box;
int16_t camera_box = r->sectors[z_sector + x_sector * r->size.z].box;

if (camera_box != NO_BOX
&& (target->z < left || target->z > right || target->x < top
Expand All @@ -270,7 +270,7 @@ void __cdecl Camera_SmartShift(
int32_t edge;

test = (target->z - WALL_L) | (WALL_L - 1);
const SECTOR_INFO *good_left =
const SECTOR *good_left =
Camera_GoodPosition(target->x, target->y, test, target->room_num);
if (good_left) {
camera_box = good_left->box;
Expand All @@ -283,7 +283,7 @@ void __cdecl Camera_SmartShift(
}

test = (target->z + WALL_L) & (~(WALL_L - 1));
const SECTOR_INFO *good_right =
const SECTOR *good_right =
Camera_GoodPosition(target->x, target->y, test, target->room_num);
if (good_right) {
camera_box = good_right->box;
Expand All @@ -296,7 +296,7 @@ void __cdecl Camera_SmartShift(
}

test = (target->x - WALL_L) | (WALL_L - 1);
const SECTOR_INFO *good_top =
const SECTOR *good_top =
Camera_GoodPosition(test, target->y, target->z, target->room_num);
if (good_top) {
camera_box = good_top->box;
Expand All @@ -309,7 +309,7 @@ void __cdecl Camera_SmartShift(
}

test = (target->x + WALL_L) & (~(WALL_L - 1));
const SECTOR_INFO *good_bottom =
const SECTOR *good_bottom =
Camera_GoodPosition(test, target->y, target->z, target->room_num);
if (good_bottom) {
camera_box = good_bottom->box;
Expand Down Expand Up @@ -453,7 +453,7 @@ void __cdecl Camera_SmartShift(
Room_GetSector(target->x, target->y, target->z, &target->room_num);
}

void __cdecl Camera_Chase(const ITEM_INFO *item)
void __cdecl Camera_Chase(const ITEM *item)
{
g_Camera.target_elevation += item->rot.x;
g_Camera.target_elevation = MIN(g_Camera.target_elevation, MAX_ELEVATION);
Expand Down Expand Up @@ -489,7 +489,7 @@ int32_t __cdecl Camera_ShiftClamp(GAME_VECTOR *pos, int32_t clamp)
int32_t x = pos->x;
int32_t y = pos->y;
int32_t z = pos->z;
const SECTOR_INFO *sector = Room_GetSector(x, y, z, &pos->room_num);
const SECTOR *sector = Room_GetSector(x, y, z, &pos->room_num);
const BOX_INFO *box = &g_Boxes[sector->box];

int32_t left = ((int32_t)box->left << WALL_SHIFT) + clamp;
Expand Down Expand Up @@ -526,7 +526,7 @@ int32_t __cdecl Camera_ShiftClamp(GAME_VECTOR *pos, int32_t clamp)
return 0;
}

void __cdecl Camera_Combat(const ITEM_INFO *item)
void __cdecl Camera_Combat(const ITEM *item)
{
g_Camera.target.z = item->pos.z;
g_Camera.target.x = item->pos.x;
Expand Down Expand Up @@ -580,7 +580,7 @@ void __cdecl Camera_Combat(const ITEM_INFO *item)
Camera_Move(&target, g_Camera.speed);
}

void __cdecl Camera_Look(const ITEM_INFO *item)
void __cdecl Camera_Look(const ITEM *item)
{
XYZ_32 old = {
.x = g_Camera.target.x,
Expand Down Expand Up @@ -684,7 +684,7 @@ void __cdecl Camera_Update(void)

const int32_t fixed_camera = g_Camera.item != NULL
&& (g_Camera.type == CAM_FIXED || g_Camera.type == CAM_HEAVY);
const ITEM_INFO *const item = fixed_camera ? g_Camera.item : g_LaraItem;
const ITEM *const item = fixed_camera ? g_Camera.item : g_LaraItem;

const BOUNDS_16 *bounds = Item_GetBoundsAccurate(item);

Expand Down Expand Up @@ -773,7 +773,7 @@ void __cdecl Camera_Update(void)
g_Camera.target.y += (y - g_Camera.target.y) / 4;
}

const SECTOR_INFO *const sector = Room_GetSector(
const SECTOR *const sector = Room_GetSector(
g_Camera.target.x, y, g_Camera.target.z, &g_Camera.target.room_num);
const int32_t height = Room_GetHeight(
sector, g_Camera.target.x, g_Camera.target.y, g_Camera.target.z);
Expand Down
8 changes: 4 additions & 4 deletions src/game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ void __cdecl Camera_Clip(
void __cdecl Camera_Shift(
int32_t *x, int32_t *y, int32_t *h, int32_t target_x, int32_t target_y,
int32_t target_h, int32_t left, int32_t top, int32_t right, int32_t bottom);
const SECTOR_INFO *__cdecl Camera_GoodPosition(
const SECTOR *__cdecl Camera_GoodPosition(
int32_t x, int32_t y, int32_t z, int16_t room_num);
void __cdecl Camera_SmartShift(
GAME_VECTOR *target,
void(__cdecl *shift)(
int32_t *x, int32_t *y, int32_t *h, int32_t target_x, int32_t target_y,
int32_t target_h, int32_t left, int32_t top, int32_t right,
int32_t bottom));
void __cdecl Camera_Chase(const ITEM_INFO *item);
void __cdecl Camera_Chase(const ITEM *item);
int32_t __cdecl Camera_ShiftClamp(GAME_VECTOR *pos, int32_t clamp);
void __cdecl Camera_Combat(const ITEM_INFO *item);
void __cdecl Camera_Look(const ITEM_INFO *item);
void __cdecl Camera_Combat(const ITEM *item);
void __cdecl Camera_Look(const ITEM *item);
void __cdecl Camera_Fixed(void);
void __cdecl Camera_Update(void);
void __cdecl Camera_LoadCutsceneFrame(void);
Expand Down
Loading
Loading