Skip to content

Commit

Permalink
level: allow empty SFX data while reading
Browse files Browse the repository at this point in the history
This allows reading levels that contain no SFX data.

Resolves #2460.
  • Loading branch information
lahm86 committed Feb 8, 2025
1 parent 0d4d0f3 commit efe124c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- fixed the teleporting command sometimes putting Lara in invalid flipmap rooms (#2370)
- fixed teleporting to an item on a ledge sometimes pushing Lara to the room below (#2372)
- fixed secret and enemy speech not playing if the sound effects are missing from the level file (#2458)
- fixed being unable to load a level that contains no sound effect data (#2460)
- fixed input controller remaps not being saved across game relaunches (#2422, regression from 4.6)
- fixed the upside-down camera fix to no longer limit Lara's vision (#2276, regression from 4.2)
- fixed being unable to load some old custom levels that contain certain (invalid) floor data (#2114, regression from 4.3)
Expand Down
1 change: 1 addition & 0 deletions docs/tr1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ Not all options are turned on by default. Refer to `TR1X_ConfigTool.exe` for det
- **Temple of the Cat**: converted track 12 in room 14, track 7 in room 98, and track 20 in room 100 to one shot
- **Atlantean Stronghold**: converted track 20 in room 4, track 19 in room 13, track 11 in room 17, track 15 in room 20, and track 12 in room 25 to one shot
- **The Hive**: converted track 9 in room 8, track 6 in room 18, track 12 in room 30, track 18 in room 31, track 3 in room 32, and track 20 in room 35 to one shot
- fixed being unable to load a level that contains no sound effect data

#### Mods
- added developer console (accessible with `/`, see [COMMANDS.md](COMMANDS.md) for details)
Expand Down
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- fixed the teleporting command sometimes putting Lara in invalid flipmap rooms (#2370)
- fixed teleporting to an item on a ledge sometimes pushing Lara to the room below (#2372)
- fixed the game crashing if a cinematic is triggered but the level contains no cinematic frames (#2413)
- fixed being unable to load a level that contains no sound effect data (#2460)
- fixed Lara activating triggers one frame too early (#2205, regression from 0.7)
- fixed savegame incompatibility with OG (#2271, regression from 0.8)
- fixed stopwatch showing wrong UI in some circumstances (#2221, regression from 0.8)
Expand Down
1 change: 1 addition & 0 deletions docs/tr2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ game with new enhancements and features.
- fixed wrong default music volume (being very loud on some setups)
- fixed flare sound effects not always playing when Lara is in shallow water
- fixed music not playing if triggered while the game is muted, but the volume is then increased
- fixed being unable to load a level that contains no sound effect data

#### Mods
- added developer console (accessible with `/`, see [COMMANDS.md](COMMANDS.md) for details)
Expand Down
10 changes: 0 additions & 10 deletions src/libtrx/game/level/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,6 @@ void Level_ReadSamples(
const int32_t num_sample_infos = VFile_ReadS32(file);
info->samples.info_count = num_sample_infos;
LOG_INFO("sample infos: %d", num_sample_infos);
if (num_sample_infos == 0) {
goto finish;
}

Sound_InitialiseSampleInfos(num_sample_infos + extra_sfx_count);
for (int32_t i = 0; i < num_sample_infos; i++) {
SAMPLE_INFO *const sample_info = Sound_GetSampleInfoByIdx(i);
Expand All @@ -858,9 +854,6 @@ void Level_ReadSamples(
const int32_t data_size = VFile_ReadS32(file);
info->samples.data_size = data_size;
LOG_INFO("%d sample data size", data_size);
if (data_size == 0) {
Shell_ExitSystem("No Sample Data");
}

info->samples.data =
GameBuf_Alloc(data_size + extra_data_size, GBUF_SAMPLES);
Expand All @@ -870,9 +863,6 @@ void Level_ReadSamples(
const int32_t num_offsets = VFile_ReadS32(file);
LOG_INFO("samples: %d", num_offsets);
info->samples.offset_count = num_offsets;
if (num_offsets == 0) {
goto finish;
}

info->samples.offsets =
Memory_Alloc(sizeof(int32_t) * (num_offsets + extra_offset_count));
Expand Down

0 comments on commit efe124c

Please sign in to comment.