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

Commit

Permalink
console/cmd: import /demo
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 22, 2024
1 parent 9dd6c5c commit 948f57c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions include/libtrx/game/console/cmd/play_demo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_PlayDemo;
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ sources = [
'src/game/console/cmd/give_item.c',
'src/game/console/cmd/heal.c',
'src/game/console/cmd/kill.c',
'src/game/console/cmd/play_demo.c',
'src/game/console/cmd/pos.c',
'src/game/console/cmd/set_health.c',
'src/game/console/cmd/sfx.c',
Expand Down
6 changes: 5 additions & 1 deletion src/game/console/cmd/give_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
for (int32_t i = 0; i < match_count; i++) {
const GAME_OBJECT_ID object_id = matching_objs[i];
if (Object_GetObject(object_id)->loaded) {
const char *obj_name = Object_GetName(object_id);
if (obj_name == NULL) {
obj_name = args;
}
Backpack_AddItemNTimes(object_id, num);
Console_Log(GS(OSD_GIVE_ITEM), Object_GetName(object_id) || args);
Console_Log(GS(OSD_GIVE_ITEM), obj_name);
found = true;
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/game/console/cmd/play_demo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "game/console/cmd/play_demo.h"

#include "game/gameflow/common.h"

static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);

static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
Gameflow_OverrideCommand((GAMEFLOW_COMMAND) { .action = GF_START_DEMO });
return CR_SUCCESS;
}

CONSOLE_COMMAND g_Console_Cmd_PlayDemo = {
.prefix = "demo",
.proc = M_Entrypoint,
};
7 changes: 5 additions & 2 deletions src/game/console/cmd/teleport.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ static COMMAND_RESULT M_TeleportToObject(const char *const user_input)
return CR_FAILURE;
}

const char *const obj_name =
Object_GetName(best_item->object_id) || user_input;
const char *obj_name = Object_GetName(best_item->object_id);
if (obj_name == NULL) {
obj_name = user_input;
}

if (Lara_Cheat_Teleport(
best_item->pos.x, best_item->pos.y - STEP_L, best_item->pos.z)) {
Console_Log(GS(OSD_POS_SET_ITEM), obj_name);
Expand Down

0 comments on commit 948f57c

Please sign in to comment.