Skip to content

Commit

Permalink
tr1/game-flow: improve level type processing
Browse files Browse the repository at this point in the history
- Removes the need to supply "normal" level type
- Makes it not possible to override levels placed in their dedicated
  sequences
- Makes it not possible to override level types to arbitrary level types
  (eg two title levels)
  • Loading branch information
rr- committed Jan 25, 2025
1 parent e19bd30 commit c7b9f45
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 45 deletions.
15 changes: 0 additions & 15 deletions data/tr1/ship/cfg/TR1X_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
// Level 1: Caves
{
"path": "data/level1.phd",
"type": "normal",
"music_track": 57,
"injections": [
"data/injections/caves_fd.bin",
Expand All @@ -91,7 +90,6 @@
// Level 2: City of Vilcabamba
{
"path": "data/level2.phd",
"type": "normal",
"music_track": 57,
"injections": [
"data/injections/vilcabamba_itemrots.bin",
Expand All @@ -109,7 +107,6 @@
// Level 3: Lost Valley
{
"path": "data/level3a.phd",
"type": "normal",
"music_track": 57,
"injections": [
"data/injections/braid_valley.bin",
Expand All @@ -129,7 +126,6 @@
// Level 4: Tomb of Qualopec
{
"path": "data/level3b.phd",
"type": "normal",
"music_track": 57,
"injections": [
"data/injections/larson_textures.bin",
Expand All @@ -150,7 +146,6 @@
// Level 5: St. Francis' Folly
{
"path": "data/level4.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/folly_fd.bin",
Expand All @@ -170,7 +165,6 @@
// Level 6: Colosseum
{
"path": "data/level5.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/colosseum_door.bin",
Expand All @@ -191,7 +185,6 @@
// Level 7: Palace Midas
{
"path": "data/level6.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/midas_itemrots.bin",
Expand All @@ -210,7 +203,6 @@
// Level 8: The Cistern
{
"path": "data/level7a.phd",
"type": "normal",
"music_track": 58,
"injections": [
"data/injections/cistern_fd.bin",
Expand All @@ -230,7 +222,6 @@
// Level 9: Tomb of Tihocan
{
"path": "data/level7b.phd",
"type": "normal",
"music_track": 58,
"injections": [
"data/injections/cistern_plants.bin",
Expand All @@ -254,7 +245,6 @@
// Level 10: City of Khamoon
{
"path": "data/level8a.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/khamoon_fd.bin",
Expand All @@ -274,7 +264,6 @@
// Level 11: Obelisk of Khamoon
{
"path": "data/level8b.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/obelisk_fd.bin",
Expand All @@ -295,7 +284,6 @@
// Level 12: Sanctuary of the Scion
{
"path": "data/level8c.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/sanctuary_fd.bin",
Expand All @@ -314,7 +302,6 @@
// Level 13: Natla's Mines
{
"path": "data/level10a.phd",
"type": "normal",
"music_track": 58,
"injections": [
"data/injections/cowboy_textures.bin",
Expand Down Expand Up @@ -348,7 +335,6 @@
// Level 14: Atlantis
{
"path": "data/level10b.phd",
"type": "normal",
"music_track": 60,
"injections": [
"data/injections/atlantis_fd.bin",
Expand All @@ -372,7 +358,6 @@
// Level 15: The Great Pyramid
{
"path": "data/level10c.phd",
"type": "normal",
"music_track": 60,
"injections": [
"data/injections/pyramid_fd.bin",
Expand Down
1 change: 0 additions & 1 deletion data/tr1/ship/cfg/TR1X_gameflow_demo_pc.json5
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
// Level 2: City of Vilcabamba
{
"path": "data_demo_pc/level2.phd",
"type": "normal",
"music_track": 0,
"injections": [
"data/injections/vilcabamba_itemrots.bin",
Expand Down
5 changes: 0 additions & 5 deletions data/tr1/ship/cfg/TR1X_gameflow_ub.json5
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

"title": {
"path": "data/title.phd",
"type": "title",
"music_track": 2,
"inherit_injections": false,
"injections": [
Expand All @@ -48,7 +47,6 @@
// Level 0: Return to Egypt
{
"path": "data/egypt.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/egypt_cameras.bin",
Expand All @@ -69,7 +67,6 @@
// Level 1: Temple of the Cat
{
"path": "data/cat.phd",
"type": "normal",
"music_track": 59,
"injections": [
"data/injections/cat_cameras.bin",
Expand All @@ -91,7 +88,6 @@
// Level 2: Atlantean Stronghold
{
"path": "data/end.phd",
"type": "normal",
"music_track": 60,
"injections": [
"data/injections/stronghold_fd.bin",
Expand All @@ -110,7 +106,6 @@
// Level 3: The Hive
{
"path": "data/end2.phd",
"type": "normal",
"music_track": 60,
"injections": [
"data/injections/hive_fd.bin",
Expand Down
16 changes: 3 additions & 13 deletions docs/tr1/GAMEFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ Following are each of the properties available within a level.
```json5
{
"path": "data/example.phd",
"type": "normal",
"music_track": 57,
"lara_type": 0,
"water_color": [0.7, 0.5, 0.85],
Expand Down Expand Up @@ -367,9 +366,10 @@ Following are each of the properties available within a level.
<code>type</code>
</td>
<td rowspan="8">String</td>
<td rowspan="8">Yes</td>
<td rowspan="8">No</td>
<td colspan="2">
The level type, which must be one of the following values.
Defaults to normal level.
</td>
</tr>
<tr valign="top">
Expand Down Expand Up @@ -402,7 +402,7 @@ Following are each of the properties available within a level.
</tr>
<tr valign="top">
<td>
<code>legacy</code>
<code>dummy</code>
</td>
<td>A placeholder level necessary to read TombATI's save files.</td>
</tr>
Expand All @@ -422,12 +422,6 @@ Following are each of the properties available within a level.
</td>
<td>A standard level.</td>
</tr>
<tr valign="top">
<td>
<code>title</code>
</td>
<td>The main menu level. One - and only one - of these must be defined.</td>
</tr>
<tr valign="top">
<td>
<code>unobtainable_kills</code>
Expand Down Expand Up @@ -793,7 +787,6 @@ game will exit to title.

{
"path": "data/level1.phd",
"type": "normal",
"music_track": 57,
"sequence": [
{"type": "load_level"},
Expand All @@ -805,7 +798,6 @@ game will exit to title.

{
"path": "data/level2.phd",
"type": "normal",
"music_track": 57,
"sequence": [
{"type": "load_level"},
Expand All @@ -817,7 +809,6 @@ game will exit to title.

{
"path": "data/level3.phd",
"type": "normal",
"music_track": 57,
"sequence": [
{"type": "load_level"},
Expand Down Expand Up @@ -904,7 +895,6 @@ the engine's overall item limit).
```json5
{
"path": "data/example.phd",
"type": "normal",
"music_track": 57,
"item_drops": [
{"enemy_num": 17, "object_ids": [86]},
Expand Down
29 changes: 18 additions & 11 deletions src/tr1/game/game_flow/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,25 +484,31 @@ static void M_LoadLevel(
level->num = idx;

{
level->type = (GAME_FLOW_LEVEL_TYPE)(intptr_t)user_arg;
const JSON_VALUE *const tmp_v = JSON_ObjectGetValue(jlvl_obj, "type");
if (tmp_v == NULL) {
if ((int32_t)(intptr_t)user_arg != -1) {
level->type = (GAME_FLOW_LEVEL_TYPE)(intptr_t)user_arg;
} else {
Shell_ExitSystemFmt(
"level %d: 'type' must be a string", level->num);
}
} else {
if (tmp_v != NULL) {
const char *const tmp =
JSON_ValueGetString(tmp_v, JSON_INVALID_STRING);
if (tmp == JSON_INVALID_STRING) {
Shell_ExitSystemFmt(
"level %d: 'type' must be a string", level->num);
}
level->type = ENUM_MAP_GET(GAME_FLOW_LEVEL_TYPE, tmp, -1);
if (level->type == (GAME_FLOW_LEVEL_TYPE)-1) {
const GAME_FLOW_LEVEL_TYPE user_type =
ENUM_MAP_GET(GAME_FLOW_LEVEL_TYPE, tmp, -1);
if (user_type == (GAME_FLOW_LEVEL_TYPE)-1) {
Shell_ExitSystemFmt("unrecognized type '%s'", tmp);
}

if (level->type != GFL_NORMAL
|| (user_type != GFL_NORMAL && user_type != GFL_BONUS
&& user_type != GFL_GYM && user_type != GFL_CURRENT
&& user_type != GFL_DUMMY)) {
Shell_ExitSystemFmt(
"cannot override level type=%s to %s",
ENUM_MAP_TO_STRING(GAME_FLOW_LEVEL_TYPE, level->type),
ENUM_MAP_TO_STRING(GAME_FLOW_LEVEL_TYPE, user_type));
}
level->type = user_type;
}
}

Expand Down Expand Up @@ -608,7 +614,8 @@ static void M_LoadLevels(JSON_OBJECT *const obj, GAME_FLOW *const gf)

M_LoadArray(
obj, "levels", sizeof(GAME_FLOW_LEVEL), (M_LOAD_ARRAY_FUNC)M_LoadLevel,
gf, &gf->level_count, (void **)&gf->levels, (void *)(intptr_t)-1);
gf, &gf->level_count, (void **)&gf->levels,
(void *)(intptr_t)GFL_NORMAL);
}

static void M_LoadCutscenes(JSON_OBJECT *const obj, GAME_FLOW *const gf)
Expand Down

0 comments on commit c7b9f45

Please sign in to comment.