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

Add /sfx; move various types and commands to libtrx #255

Merged
merged 10 commits into from
Sep 23, 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,4 +1,5 @@
## [Unreleased](https://github.com/LostArtefacts/TR2X/compare/stable...develop) - ××××-××-××
- added `/sfx` command

## [0.3](https://github.com/LostArtefacts/TR2X/compare/0.2-460-g4721b93...0.3) - 2024-09-20
- added new console commands:
Expand Down
4 changes: 4 additions & 0 deletions COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ Currently supported commands:

- `/exit`
Closes the game.

- `/sfx`
- `/sfx {sound}`
Plays a given sound sample.
3 changes: 3 additions & 0 deletions data/ship/cfg/TR2X_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@
"OSD_INVALID_LEVEL": "Invalid level",
"OSD_INVALID_OBJECT": "Invalid object",
"OSD_INVALID_ROOM": "Invalid room: %d. Valid rooms are 0-%d",
"OSD_INVALID_SAMPLE": "Invalid sound: %d",
"OSD_INVALID_SAVE_SLOT": "Invalid save slot %d",
"OSD_KILL": "Bye-bye!",
"OSD_KILL_ALL": "Poof! %d enemies gone!",
Expand All @@ -398,6 +399,8 @@
"OSD_POS_SET_ROOM_FAIL": "Failed to teleport to room: %d",
"OSD_SAVE_GAME": "Saved game to save slot %d",
"OSD_SAVE_GAME_FAIL": "Cannot save the game in the current state",
"OSD_SOUND_AVAILABLE_SAMPLES": "Available sounds: %s",
"OSD_SOUND_PLAYING_SAMPLE": "Playing sound %d",
"OSD_UNKNOWN_COMMAND": "Unknown command: %s",
},
}
14 changes: 7 additions & 7 deletions docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ typedef struct __unaligned {
uint8_t buffer[6272];
} SAVEGAME_INFO;

typedef struct __unaligned {
typedef struct __unaligned { // decompiled
uint16_t idx;
int16_t box;
uint8_t pit_room;
Expand Down Expand Up @@ -883,20 +883,20 @@ typedef struct { // decompiled
int16_t link_frame_num;
} ANIM_RANGE;

typedef struct __unaligned {
typedef struct __unaligned { // decompiled
int16_t room;
int16_t x;
int16_t y;
int16_t z;
XYZ_16 vertex[4];
} DOOR_INFO;

typedef struct __unaligned {
typedef struct __unaligned { // decompiled
int16_t count;
DOOR_INFO door[];
} DOOR_INFOS;

typedef struct __unaligned {
typedef struct __unaligned { // decompiled
int32_t x;
int32_t y;
int32_t z;
Expand All @@ -906,7 +906,7 @@ typedef struct __unaligned {
int32_t falloff2;
} LIGHT_INFO;

typedef struct __unaligned {
typedef struct __unaligned { // decompiled
int32_t x;
int32_t y;
int32_t z;
Expand All @@ -929,7 +929,7 @@ typedef struct __unaligned {
int16_t block;
} DOORPOS_DATA;

typedef struct __unaligned {
typedef struct __unaligned { // decompiled
int16_t *data;
DOOR_INFOS *doors;
SECTOR_INFO *sector;
Expand Down Expand Up @@ -1645,7 +1645,7 @@ typedef enum { // decompiled
IF_KILLED = 0x8000,
} ITEM_FLAG;

typedef enum {
typedef enum { // decompiled
IS_INACTIVE = 0,
IS_ACTIVE = 1,
IS_DEACTIVATED = 2,
Expand Down
5 changes: 0 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,10 @@ dll_sources = [
'src/game/camera.c',
'src/game/clock.c',
'src/game/collide.c',
'src/game/console/cmd/end_level.c',
'src/game/console/cmd/exit_game.c',
'src/game/console/cmd/exit_to_title.c',
'src/game/console/cmd/flipmap.c',
'src/game/console/cmd/load_game.c',
'src/game/console/cmd/play_demo.c',
'src/game/console/cmd/play_level.c',
'src/game/console/cmd/save_game.c',
'src/game/console/cmd/teleport.c',
'src/game/console/common.c',
'src/game/console/setup.c',
'src/game/creature.c',
Expand Down
21 changes: 0 additions & 21 deletions src/game/console/cmd/end_level.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/game/console/cmd/end_level.h

This file was deleted.

16 changes: 0 additions & 16 deletions src/game/console/cmd/exit_game.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/game/console/cmd/exit_game.h

This file was deleted.

16 changes: 0 additions & 16 deletions src/game/console/cmd/exit_to_title.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/game/console/cmd/exit_to_title.h

This file was deleted.

8 changes: 4 additions & 4 deletions src/game/console/cmd/flipmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <libtrx/strings.h>

static COMMAND_RESULT M_Entrypoint(const char *args);
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);

static COMMAND_RESULT M_Entrypoint(const char *const args)
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
if (g_GameInfo.current_level.type == GFL_TITLE
|| g_GameInfo.current_level.type == GFL_DEMO
Expand All @@ -18,9 +18,9 @@ static COMMAND_RESULT M_Entrypoint(const char *const args)
}

bool new_state;
if (String_Equivalent(args, "")) {
if (String_Equivalent(ctx->args, "")) {
new_state = !g_FlipStatus;
} else if (!String_ParseBool(args, &new_state)) {
} else if (!String_ParseBool(ctx->args, &new_state)) {
return CR_BAD_INVOCATION;
}

Expand Down
6 changes: 3 additions & 3 deletions src/game/console/cmd/load_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#include <libtrx/strings.h>

static COMMAND_RESULT M_Entrypoint(const char *args);
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);

static COMMAND_RESULT M_Entrypoint(const char *const args)
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
int32_t slot_num;
if (!String_ParseInteger(args, &slot_num)) {
if (!String_ParseInteger(ctx->args, &slot_num)) {
return CR_BAD_INVOCATION;
}

Expand Down
16 changes: 0 additions & 16 deletions src/game/console/cmd/play_demo.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/game/console/cmd/play_demo.h

This file was deleted.

12 changes: 6 additions & 6 deletions src/game/console/cmd/play_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@

#include <stdio.h>

static COMMAND_RESULT M_Entrypoint(const char *args);
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);

static COMMAND_RESULT M_Entrypoint(const char *const args)
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
int32_t level_to_load = -1;

if (level_to_load == -1) {
int32_t num = 0;
if (sscanf(args, "%d", &num) == 1) {
if (sscanf(ctx->args, "%d", &num) == 1) {
level_to_load = num;
}
}

if (level_to_load == -1 && strlen(args) >= 2) {
if (level_to_load == -1 && strlen(ctx->args) >= 2) {
for (int i = 0; i < g_GameFlow.num_levels; i++) {
if (String_CaseSubstring(g_GF_LevelNames[i], args) != NULL) {
if (String_CaseSubstring(g_GF_LevelNames[i], ctx->args) != NULL) {
level_to_load = i;
break;
}
}
}

if (level_to_load == -1 && String_Equivalent(args, "gym")) {
if (level_to_load == -1 && String_Equivalent(ctx->args, "gym")) {
level_to_load = LV_GYM;
}

Expand Down
6 changes: 3 additions & 3 deletions src/game/console/cmd/save_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

#include <libtrx/strings.h>

static COMMAND_RESULT M_Entrypoint(const char *args);
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);

static COMMAND_RESULT M_Entrypoint(const char *const args)
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
int32_t slot_num;
if (!String_ParseInteger(args, &slot_num)) {
if (!String_ParseInteger(ctx->args, &slot_num)) {
return CR_BAD_INVOCATION;
}

Expand Down
Loading
Loading