This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Import /hp and /pos console commands to libtrx #29
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7cc4619
console: import /pos command
rr- 6a3c3a3
strings: fix String_Match partial matches
rr- c44cc4b
strings: fix parsing integers
rr- 8306e95
console: import /hp command
rr- d9f924c
console/cmd/set-health: clamp lara's hp
rr- b95beda
tools: sort imports on pre-commit hook
rr- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#pragma once | ||
|
||
#include "math.h" | ||
|
||
#if TR_VERSION == 1 | ||
typedef struct COLL_INFO { | ||
int32_t mid_floor; | ||
int32_t mid_ceiling; | ||
int32_t mid_type; | ||
int32_t front_floor; | ||
int32_t front_ceiling; | ||
int32_t front_type; | ||
int32_t left_floor; | ||
int32_t left_ceiling; | ||
int32_t left_type; | ||
int32_t right_floor; | ||
int32_t right_ceiling; | ||
int32_t right_type; | ||
int32_t radius; | ||
int32_t bad_pos; | ||
int32_t bad_neg; | ||
int32_t bad_ceiling; | ||
XYZ_32 shift; | ||
XYZ_32 old; | ||
int16_t facing; | ||
DIRECTION quadrant; | ||
int16_t coll_type; | ||
int8_t tilt_x; | ||
int8_t tilt_z; | ||
int8_t hit_by_baddie; | ||
int8_t hit_static; | ||
uint16_t slopes_are_walls : 1; | ||
uint16_t slopes_are_pits : 1; | ||
uint16_t lava_is_pit : 1; | ||
uint16_t enable_baddie_push : 1; | ||
uint16_t enable_spaz : 1; | ||
} COLL_INFO; | ||
|
||
#elif TR_VERSION == 2 | ||
typedef struct __unaligned | ||
{ | ||
int32_t floor; | ||
int32_t ceiling; | ||
int32_t type; | ||
} | ||
COLL_SIDE; | ||
|
||
typedef struct __unaligned | ||
{ | ||
COLL_SIDE side_mid; | ||
COLL_SIDE side_front; | ||
COLL_SIDE side_left; | ||
COLL_SIDE side_right; | ||
int32_t radius; | ||
int32_t bad_pos; | ||
int32_t bad_neg; | ||
int32_t bad_ceiling; | ||
XYZ_32 shift; | ||
XYZ_32 old; | ||
int16_t old_anim_state; | ||
int16_t old_anim_num; | ||
int16_t old_frame_num; | ||
int16_t facing; | ||
int16_t quadrant; | ||
int16_t coll_type; | ||
int16_t *trigger; | ||
int8_t x_tilt; | ||
int8_t z_tilt; | ||
int8_t hit_by_baddie; | ||
int8_t hit_static; | ||
// clang-format off | ||
uint16_t slopes_are_walls: 1; // 0x01 1 | ||
uint16_t slopes_are_pits: 1; // 0x02 2 | ||
uint16_t lava_is_pit: 1; // 0x04 4 | ||
uint16_t enable_baddie_push: 1; // 0x08 8 | ||
uint16_t enable_spaz: 1; // 0x10 16 | ||
uint16_t hit_ceiling: 1; // 0x20 32 | ||
uint16_t pad: 10; | ||
// clang-format on | ||
} | ||
COLL_INFO; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_Pos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_SetHealth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <stdbool.h> | ||
|
||
typedef enum { | ||
CR_SUCCESS, | ||
CR_FAILURE, | ||
CR_UNAVAILABLE, | ||
CR_BAD_INVOCATION, | ||
} COMMAND_RESULT; | ||
|
||
typedef struct { | ||
const char *prefix; | ||
COMMAND_RESULT (*proc)(const char *args); | ||
} CONSOLE_COMMAND; | ||
|
||
void Console_Log(const char *fmt, ...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
#pragma once | ||
|
||
#define DONT_TARGET (-16384) | ||
|
||
#define PHD_ONE 0x10000 | ||
#define STEP_L 256 | ||
#define WALL_L 1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include <stdbool.h> | ||
|
||
bool Game_IsPlayable(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
GS_DEFINE(OSD_POS_GET, "Room: %d\nPosition: %.3f, %.3f, %.3f\nRotation: %.3f,%.3f,%.3f") | ||
GS_DEFINE(OSD_CURRENT_HEALTH_GET, "Current Lara's health: %d") | ||
GS_DEFINE(OSD_CURRENT_HEALTH_SET, "Lara's health set to %d") | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include "../items.h" | ||
|
||
#define LARA_MAX_HITPOINTS 1000 | ||
|
||
ITEM_INFO *Lara_GetItem(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#pragma once | ||
|
||
#include "../collision.h" | ||
#include "../items.h" | ||
#include "../math.h" | ||
#include "ids.h" | ||
|
||
#include <stdint.h> | ||
|
||
#if TR_VERSION == 1 | ||
typedef struct { | ||
XYZ_16 min; | ||
XYZ_16 max; | ||
} BOUNDS_16; | ||
|
||
typedef struct { | ||
struct { | ||
XYZ_16 min; | ||
XYZ_16 max; | ||
} shift, rot; | ||
} OBJECT_BOUNDS; | ||
|
||
typedef struct { | ||
BOUNDS_16 bounds; | ||
XYZ_16 offset; | ||
int16_t nmeshes; | ||
int32_t *mesh_rots; | ||
} FRAME_INFO; | ||
|
||
typedef struct { | ||
int16_t nmeshes; | ||
int16_t mesh_index; | ||
int32_t bone_index; | ||
FRAME_INFO *frame_base; | ||
void (*initialise)(int16_t item_num); | ||
void (*control)(int16_t item_num); | ||
int16_t (*floor_height_func)( | ||
const ITEM_INFO *item, int32_t x, int32_t y, int32_t z, int16_t height); | ||
int16_t (*ceiling_height_func)( | ||
const ITEM_INFO *item, int32_t x, int32_t y, int32_t z, int16_t height); | ||
void (*draw_routine)(ITEM_INFO *item); | ||
void (*collision)(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); | ||
const OBJECT_BOUNDS *(*bounds)(void); | ||
int16_t anim_index; | ||
int16_t hit_points; | ||
int16_t pivot_length; | ||
int16_t radius; | ||
int16_t smartness; | ||
int16_t shadow_size; | ||
uint16_t loaded : 1; | ||
uint16_t intelligent : 1; | ||
uint16_t save_position : 1; | ||
uint16_t save_hitpoints : 1; | ||
uint16_t save_flags : 1; | ||
uint16_t save_anim : 1; | ||
} OBJECT_INFO; | ||
|
||
#elif TR_VERSION == 2 | ||
typedef struct __unaligned | ||
{ | ||
int16_t mesh_count; | ||
int16_t mesh_idx; | ||
int32_t bone_idx; | ||
int16_t *frame_base; // TODO: make me FRAME_INFO | ||
|
||
void (*initialise)(int16_t item_num); | ||
void (*control)(int16_t item_num); | ||
void (*floor)( | ||
const ITEM_INFO *item, int32_t x, int32_t y, int32_t z, | ||
int32_t *height); | ||
void (*ceiling)( | ||
const ITEM_INFO *item, int32_t x, int32_t y, int32_t z, | ||
int32_t *height); | ||
void (*draw_routine)(const ITEM_INFO *item); | ||
void (*collision)(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); | ||
|
||
int16_t anim_idx; | ||
int16_t hit_points; | ||
int16_t pivot_length; | ||
int16_t radius; | ||
int16_t shadow_size; | ||
|
||
union { | ||
uint16_t flags; | ||
// clang-format off | ||
struct { | ||
uint16_t loaded: 1; // 0x01 1 | ||
uint16_t intelligent: 1; // 0x02 2 | ||
uint16_t save_position: 1; // 0x04 4 | ||
uint16_t save_hitpoints: 1; // 0x08 8 | ||
uint16_t save_flags: 1; // 0x10 16 | ||
uint16_t save_anim: 1; // 0x20 32 | ||
uint16_t semi_transparent: 1; // 0x40 64 | ||
uint16_t water_creature: 1; // 0x80 128 | ||
uint16_t pad: 8; | ||
}; | ||
// clang-format on | ||
}; | ||
} | ||
OBJECT_INFO; | ||
#endif | ||
|
||
OBJECT_INFO *Object_GetObject(GAME_OBJECT_ID object_id); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
typedef struct { | ||
char *content; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "game/console/commands/pos.h" | ||
|
||
#include "game/console/common.h" | ||
#include "game/const.h" | ||
#include "game/game_string.h" | ||
#include "game/lara/common.h" | ||
#include "game/objects/common.h" | ||
|
||
static COMMAND_RESULT Console_Cmd_Pos(const char *args); | ||
|
||
static COMMAND_RESULT Console_Cmd_Pos(const char *const args) | ||
{ | ||
const OBJECT_INFO *const object = Object_GetObject(O_LARA); | ||
if (!object->loaded) { | ||
return CR_UNAVAILABLE; | ||
} | ||
|
||
const ITEM_INFO *const lara_item = Lara_GetItem(); | ||
|
||
// clang-format off | ||
Console_Log( | ||
GS(OSD_POS_GET), | ||
lara_item->room_num, | ||
lara_item->pos.x / (float)WALL_L, | ||
lara_item->pos.y / (float)WALL_L, | ||
lara_item->pos.z / (float)WALL_L, | ||
lara_item->rot.x * 360.0f / (float)PHD_ONE, | ||
lara_item->rot.y * 360.0f / (float)PHD_ONE, | ||
lara_item->rot.z * 360.0f / (float)PHD_ONE); | ||
// clang-format on | ||
|
||
return CR_SUCCESS; | ||
} | ||
|
||
CONSOLE_COMMAND g_Console_Cmd_Pos = { | ||
.prefix = "pos", | ||
.proc = Console_Cmd_Pos, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require language translations to now translate this second file on top of the strings in the gameflow? Unless I'm reading wrong this early lol. That would be my only feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. These provide reasonable defaults in case the player or level builder removes the strings from the gameflow. Our tools automatically backpropagate these as default overrides to the gameflow files to highlight what can be overridden, but they are not strictly necessary as they ship the same strings that we provide here in the executable itself.
For a developer this means updating it only in this single place for libtrx strings, and in relevant
.def
files for TR1X and TR2X specific strings. The rest should be taken care of bytools/update_gameflow
.