Skip to content

Commit

Permalink
inject: add the ability to insert floor data (#944)
Browse files Browse the repository at this point in the history
Added an injection function to allow inserting new floor data values.
Added an injection file for Tomb of Tihocan to restore a missing rat
trigger.

Resolves #751.
  • Loading branch information
lahm86 authored Aug 25, 2023
1 parent e88e698 commit 259c040
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- fixed walk-run-jump at times breaking when TR2 jumping is enabled (OG bug in TR2+) (#934)
- fixed the reset and unbind progress bars in the controls menu for non-default bar scaling (#930)
- fixed original data issues where music triggers are not set as one shot (#939)
- fixed a missing enemy trigger in Tomb of Tihocan (#751)
- improve spanish localization and added translation for rotated pickups

## [2.15.3](https://github.com/rr-/Tomb1Main/compare/2.15.2...2.15.3) - 2023-08-15
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
- fixed Natla's gun moving while she is in her semi death state
- fixed the bear pat attack so it does not miss Lara
- fixed dead centaurs exploding again after saving and reloading
- fixed the following floor data issues:
- **Tomb of Tihocan**: missing trigger in room 62 for enemy 34

#### Cheats
- added a fly cheat
Expand Down
1 change: 1 addition & 0 deletions bin/cfg/Tomb1Main_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
"type": "normal",
"music": 58,
"injections": [
"data/tihocan_fd.bin",
"data/tihocan_itemrots.bin",
"data/tihocan_textures.bin",
],
Expand Down
Binary file added bin/data/tihocan_fd.bin
Binary file not shown.
35 changes: 32 additions & 3 deletions src/game/inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ typedef struct MESH_EDIT {
typedef enum FLOOR_EDIT_TYPE {
FET_TRIGGER_PARAM = 0,
FET_MUSIC_ONESHOT = 1,
FET_FD_INSERT = 2,
} FLOOR_EDIT_TYPE;

typedef enum ROOM_MESH_EDIT_TYPE {
Expand Down Expand Up @@ -120,10 +121,12 @@ static void Inject_MeshEdits(INJECTION *injection, uint8_t *palette_map);
static void Inject_TextureOverwrites(
INJECTION *injection, LEVEL_INFO *level_info, uint8_t *palette_map);

static void Inject_FloorDataEdits(INJECTION *injection);
static void Inject_FloorDataEdits(INJECTION *injection, LEVEL_INFO *level_info);
static void Inject_TriggerParameterChange(
INJECTION *injection, FLOOR_INFO *floor);
static void Inject_SetMusicOneShot(FLOOR_INFO *floor);
static void Inject_InsertFloorData(
INJECTION *injection, FLOOR_INFO *floor, LEVEL_INFO *level_info);

static void Inject_RoomMeshEdits(INJECTION *injection);
static void Inject_TextureRoomFace(INJECTION *injection);
Expand Down Expand Up @@ -325,7 +328,7 @@ void Inject_AllInjections(LEVEL_INFO *level_info)

Inject_MeshEdits(injection, palette_map);
Inject_TextureOverwrites(injection, level_info, palette_map);
Inject_FloorDataEdits(injection);
Inject_FloorDataEdits(injection, level_info);
Inject_RoomMeshEdits(injection);
Inject_RoomDoorEdits(injection);
Inject_AnimRangeEdits(injection);
Expand Down Expand Up @@ -958,7 +961,7 @@ static void Inject_TextureOverwrites(
}
}

static void Inject_FloorDataEdits(INJECTION *injection)
static void Inject_FloorDataEdits(INJECTION *injection, LEVEL_INFO *level_info)
{
INJECTION_INFO *inj_info = injection->info;
MYFILE *fp = injection->fp;
Expand Down Expand Up @@ -998,6 +1001,9 @@ static void Inject_FloorDataEdits(INJECTION *injection)
case FET_MUSIC_ONESHOT:
Inject_SetMusicOneShot(floor);
break;
case FET_FD_INSERT:
Inject_InsertFloorData(injection, floor, level_info);
break;
default:
LOG_WARNING("Unknown floor data edit type: %d", edit_type);
break;
Expand Down Expand Up @@ -1138,6 +1144,29 @@ static void Inject_SetMusicOneShot(FLOOR_INFO *floor)
}
}

static void Inject_InsertFloorData(
INJECTION *injection, FLOOR_INFO *floor, LEVEL_INFO *level_info)
{
MYFILE *fp = injection->fp;

int32_t data_length;
File_Read(&data_length, sizeof(int32_t), 1, fp);

int16_t data[data_length];
File_Read(&data, sizeof(int16_t), data_length, fp);

if (!floor) {
return;
}

floor->index = level_info->floor_data_size;
for (int i = 0; i < data_length; i++) {
g_FloorData[level_info->floor_data_size + i] = data[i];
}

level_info->floor_data_size += data_length;
}

uint32_t Inject_GetExtraRoomMeshSize(int32_t room_index)
{
uint32_t size = 0;
Expand Down

0 comments on commit 259c040

Please sign in to comment.