Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build cleanup #2237

Merged
merged 2 commits into from
Jan 9, 2025
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
2 changes: 1 addition & 1 deletion src/libtrx/config/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ int32_t Config_SubscribeChanges(
void Config_UnsubscribeChanges(const int32_t listener_id)
{
ASSERT(m_EventManager != NULL);
return EventManager_Unsubscribe(m_EventManager, listener_id);
EventManager_Unsubscribe(m_EventManager, listener_id);
}
4 changes: 2 additions & 2 deletions src/libtrx/game/input/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const char *Input_GetKeyName(

void Input_ResetLayout(const INPUT_BACKEND backend, const INPUT_LAYOUT layout)
{
return M_GetBackend(backend)->reset_layout(layout);
M_GetBackend(backend)->reset_layout(layout);
}

void Input_EnterListenMode(void)
Expand Down Expand Up @@ -228,7 +228,7 @@ bool Input_AssignFromJSONObject(
if (role == (INPUT_ROLE)-1) {
role = ENUM_MAP_GET(
INPUT_ROLE, JSON_ObjectGetString(bind_obj, "role", ""),
(INPUT_ROLE)-1);
(int32_t)(INPUT_ROLE)-1);
}

if (role == (INPUT_ROLE)-1) {
Expand Down
2 changes: 1 addition & 1 deletion src/libtrx/game/math/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int16_t Math_DirectionToAngle(const DIRECTION dir)
case DIR_WEST:
return DEG_90;
case DIR_SOUTH:
return DEG_180;
return -DEG_180;
case DIR_EAST:
return -DEG_90;
default:
Expand Down
23 changes: 14 additions & 9 deletions src/libtrx/game/shell/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ static void M_SetupHiDPI(void)
PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS;

// Windows 8.1 and later
void *const shcore_dll = SDL_LoadObject("SHCORE.DLL");
if (shcore_dll == NULL) {
return;
}

#pragma GCC diagnostic ignored "-Wpedantic"
HRESULT(WINAPI * SetProcessDpiAwareness)
(PROCESS_DPI_AWARENESS dpiAwareness); // Windows 8.1 and later
void *shcore_dll = SDL_LoadObject("SHCORE.DLL");
if (shcore_dll) {
SetProcessDpiAwareness =
(HRESULT(WINAPI *)(PROCESS_DPI_AWARENESS))SDL_LoadFunction(
shcore_dll, "SetProcessDpiAwareness");
if (SetProcessDpiAwareness) {
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
}
(PROCESS_DPI_AWARENESS) =
(HRESULT(WINAPI *)(PROCESS_DPI_AWARENESS))SDL_LoadFunction(
shcore_dll, "SetProcessDpiAwareness");
#pragma GCC diagnostic pop
if (SetProcessDpiAwareness == NULL) {
return;
}
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/libtrx/game/ui/widgets/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static int32_t M_GetHeight(const UI_CONSOLE *const self)

static void M_SetPosition(UI_CONSOLE *const self, int32_t x, int32_t y)
{
return self->container->set_position(self->container, x, y);
self->container->set_position(self->container, x, y);
}

static void M_Control(UI_CONSOLE *const self)
Expand Down
2 changes: 1 addition & 1 deletion src/libtrx/game/ui/widgets/requester.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int32_t M_GetHeight(const UI_REQUESTER *const self)
static void M_SetPosition(
UI_REQUESTER *const self, const int32_t x, const int32_t y)
{
return self->window->set_position(self->window, x, y);
self->window->set_position(self->window, x, y);
}

static void M_Control(UI_REQUESTER *const self)
Expand Down
4 changes: 2 additions & 2 deletions src/libtrx/include/libtrx/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
do { \
if (!(x)) { \
LOG_DEBUG("Assertion failed: %s", #x); \
*(int *)0 = 0; \
__builtin_trap(); \
} \
} while (0)

#define ASSERT_FAIL(x) \
do { \
LOG_DEBUG("Assertion failed"); \
*(int *)0 = 0; \
__builtin_trap(); \
} while (0)
2 changes: 1 addition & 1 deletion src/libtrx/include/libtrx/game/inventory_ring/priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "./types.h"

#define INV_RING_FRAMES 2
#define INV_RING_OPEN_ROTATION DEG_180
#define INV_RING_OPEN_ROTATION -DEG_180
#define INV_RING_ROTATE_DURATION 24
#define INV_RING_OPEN_FRAMES 32
#define INV_RING_CAMERA_HEIGHT (-0x100) // = -256
Expand Down
4 changes: 2 additions & 2 deletions src/libtrx/json/bson_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,8 @@ JSON_VALUE *BSON_ParseEx(
state.dom += sizeof(JSON_VALUE);
M_HandleObjectValue(&state, value);

ASSERT(state.dom == allocation + state.dom_size);
ASSERT(state.data == allocation + state.dom_size + state.data_size);
ASSERT(state.dom == (char *)allocation + state.dom_size);
ASSERT(state.data == (char *)allocation + state.dom_size + state.data_size);

return value;
}
Expand Down
1 change: 1 addition & 0 deletions src/libtrx/log_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void Log_Init_Extra(const char *path)
{
signal(SIGSEGV, M_SignalHandler);
signal(SIGFPE, M_SignalHandler);
signal(SIGILL, M_SignalHandler);
}

void Log_Shutdown_Extra(void)
Expand Down
5 changes: 4 additions & 1 deletion src/libtrx/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ c_compiler = meson.get_compiler('c')
relative_dir = fs.relative_to(meson.current_source_dir(), meson.global_build_root())
build_opts = [
'-fmacro-prefix-map=@0@/=libtrx/'.format(relative_dir),
'-Wall',
'-Wpedantic',
'-Wno-unused',
'-Wno-address-of-packed-member',
'-Wno-unused-parameter',
'-Wno-microsoft-anon-tag',
'-DMESON_BUILD',
'-DDWST_STATIC',
'-DPCRE2_STATIC',
Expand Down
1 change: 0 additions & 1 deletion src/tr1/game/objects/general/keyhole.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static const OBJECT_BOUNDS m_KeyHoleBounds = {
};

static void M_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
;
static const OBJECT_BOUNDS *M_Bounds(void);

static void M_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll)
Expand Down
6 changes: 3 additions & 3 deletions src/tr1/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static void M_DrawRoomSprites(const ROOM_MESH *const mesh)
static bool M_CalcObjectVertices(
const XYZ_16 *const vertices, const int16_t count)
{
int16_t total_clip = -1;
uint16_t total_clip = 0xFFFF;
for (int i = 0; i < count; i++) {
const XYZ_16 *const vertex = &vertices[i];
// clang-format off
Expand All @@ -269,7 +269,7 @@ static bool M_CalcObjectVertices(
m_VBuf[i].yv = yv;
m_VBuf[i].zv = zv;

int16_t clip_flags;
uint16_t clip_flags;
if (zv < Output_GetNearZ()) {
clip_flags = 0x8000;
} else {
Expand Down Expand Up @@ -439,7 +439,7 @@ static void M_CalcRoomVertices(const ROOM_MESH *const mesh)
vbuf->g = vertex->shade & MAX_LIGHTING;

if (zv < Output_GetNearZ()) {
vbuf->clip = 0x8000;
vbuf->clip = (int16_t)0x8000;
} else {
int16_t clip_flags = 0;
const int32_t depth = zv_int >> W2V_SHIFT;
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/ui/widgets/paginator.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int32_t M_GetHeight(const UI_PAGINATOR *const self)

static void M_SetPosition(UI_PAGINATOR *const self, int32_t x, int32_t y)
{
return self->window->set_position(self->window, x, y);
self->window->set_position(self->window, x, y);
}

static bool M_SelectPage(UI_PAGINATOR *const self, const int32_t new_page)
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/ui/widgets/photo_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int32_t M_GetHeight(const UI_PHOTO_MODE *const self)

static void M_SetPosition(UI_PHOTO_MODE *const self, int32_t x, int32_t y)
{
return self->window->set_position(self->window, x, y);
self->window->set_position(self->window, x, y);
}

static void M_Control(UI_PHOTO_MODE *const self)
Expand Down
4 changes: 4 additions & 0 deletions src/tr1/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ c_compiler = meson.get_compiler('c')
fs = import('fs')
relative_dir = fs.relative_to(meson.current_source_dir(), meson.global_build_root())
build_opts = [
'-Wall',
'-Wpedantic',
'-Wno-unused',
'-Wno-unused-parameter',
'-Wno-microsoft-anon-tag',
'-DMESON_BUILD',
'-DTR_VERSION=1',
'-fno-omit-frame-pointer',
Expand Down
20 changes: 10 additions & 10 deletions src/tr2/decomp/savegame.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
#define SAVE_CREATURE (1 << 7)

#define SPECIAL_READ_WRITES \
SPECIAL_READ_WRITE(S8, int8_t); \
SPECIAL_READ_WRITE(S16, int16_t); \
SPECIAL_READ_WRITE(S32, int32_t); \
SPECIAL_READ_WRITE(U8, uint8_t); \
SPECIAL_READ_WRITE(U16, uint16_t); \
SPECIAL_READ_WRITE(U32, uint32_t);
SPECIAL_READ_WRITE(S8, int8_t) \
SPECIAL_READ_WRITE(S16, int16_t) \
SPECIAL_READ_WRITE(S32, int32_t) \
SPECIAL_READ_WRITE(U8, uint8_t) \
SPECIAL_READ_WRITE(U16, uint16_t) \
SPECIAL_READ_WRITE(U32, uint32_t)

static int32_t m_BufPos = 0;
static char *m_BufPtr = NULL;
Expand All @@ -43,7 +43,7 @@ static uint32_t m_ReqFlags2[MAX_REQUESTER_ITEMS];
static void M_Read(void *ptr, size_t size);
#undef SPECIAL_READ_WRITE
#define SPECIAL_READ_WRITE(name, type) static type M_Read##name(void);
SPECIAL_READ_WRITES;
SPECIAL_READ_WRITES
static void M_Skip(size_t size);
static void M_ReadItems(void);
static void M_ReadLara(LARA_INFO *lara);
Expand All @@ -54,7 +54,7 @@ static void M_ReadFlares(void);
static void M_Write(const void *ptr, size_t size);
#undef SPECIAL_READ_WRITE
#define SPECIAL_READ_WRITE(name, type) static void M_Write##name(type value);
SPECIAL_READ_WRITES;
SPECIAL_READ_WRITES
static void M_WriteItems(void);
static void M_WriteLara(const LARA_INFO *lara);
static void M_WriteLaraArm(const LARA_ARM *arm);
Expand All @@ -74,15 +74,15 @@ static void M_Read(void *ptr, const size_t size)
ReadSG(&result, sizeof(type)); \
return result; \
}
SPECIAL_READ_WRITES;
SPECIAL_READ_WRITES

#undef SPECIAL_READ_WRITE
#define SPECIAL_READ_WRITE(name, type) \
static void M_Write##name(type value) \
{ \
M_Write(&value, sizeof(type)); \
}
SPECIAL_READ_WRITES;
SPECIAL_READ_WRITES

static void M_Skip(const size_t size)
{
Expand Down
1 change: 0 additions & 1 deletion src/tr2/decomp/skidoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,6 @@ void Skidoo_Animation(
M_IsArmed(skidoo_data) ? MX_BATTLE_THEME : MX_SKIDOO_THEME;
if (!(g_MusicTrackFlags[music_track] & IF_ONE_SHOT)) {
Music_Play(music_track, MPM_ALWAYS);
g_LaraItem = g_LaraItem;
g_MusicTrackFlags[music_track] |= IF_ONE_SHOT;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tr2/game/creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ int32_t Creature_Vault(
}
} else if (old_x_sector == x_sector) {
if (old_z_sector >= z_sector) {
item->rot.y = PHD_180;
item->rot.y = -PHD_180;
item->pos.z = (old_z_sector << WALL_SHIFT) + shift;
} else {
item->rot.y = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/tr2/game/inventory_ring/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static GAME_FLOW_COMMAND M_Control(INV_RING *const ring)
InvRing_MotionRadius(ring, 0);
InvRing_MotionCameraPos(ring, INV_RING_CAMERA_START_HEIGHT);
InvRing_MotionRotation(
ring, PHD_180, ring->ring_pos.rot.y + PHD_180);
ring, -PHD_180, ring->ring_pos.rot.y + PHD_180);
g_Input = (INPUT_STATE) { 0 };
g_InputDB = (INPUT_STATE) { 0 };
}
Expand Down Expand Up @@ -317,7 +317,7 @@ static GAME_FLOW_COMMAND M_Control(INV_RING *const ring)
ring, RNG_CLOSING, RNG_OPTION2MAIN, 24);
InvRing_MotionRadius(ring, 0);
InvRing_MotionRotation(
ring, PHD_180, ring->ring_pos.rot.y + PHD_180);
ring, -PHD_180, ring->ring_pos.rot.y + PHD_180);
InvRing_MotionCameraPitch(ring, 0x2000);
ring->motion.misc = 0x2000;
}
Expand All @@ -328,7 +328,7 @@ static GAME_FLOW_COMMAND M_Control(INV_RING *const ring)
ring, RNG_CLOSING, RNG_MAIN2KEYS, 24);
InvRing_MotionRadius(ring, 0);
InvRing_MotionRotation(
ring, PHD_180, ring->ring_pos.rot.y + PHD_180);
ring, -PHD_180, ring->ring_pos.rot.y + PHD_180);
InvRing_MotionCameraPitch(ring, 0x2000);
ring->motion.misc = 0x2000;
}
Expand All @@ -344,7 +344,7 @@ static GAME_FLOW_COMMAND M_Control(INV_RING *const ring)
ring, RNG_CLOSING, RNG_KEYS2MAIN, 24);
InvRing_MotionRadius(ring, 0);
InvRing_MotionRotation(
ring, PHD_180, ring->ring_pos.rot.y + PHD_180);
ring, -PHD_180, ring->ring_pos.rot.y + PHD_180);
InvRing_MotionCameraPitch(ring, -0x2000);
ring->motion.misc = -0x2000;
}
Expand All @@ -357,7 +357,7 @@ static GAME_FLOW_COMMAND M_Control(INV_RING *const ring)
ring, RNG_CLOSING, RNG_MAIN2OPTION, 24);
InvRing_MotionRadius(ring, 0);
InvRing_MotionRotation(
ring, PHD_180, ring->ring_pos.rot.y + PHD_180);
ring, -PHD_180, ring->ring_pos.rot.y + PHD_180);
InvRing_MotionCameraPitch(ring, -0x2000);
ring->motion.misc = -0x2000;
}
Expand Down Expand Up @@ -538,7 +538,7 @@ static GAME_FLOW_COMMAND M_Control(INV_RING *const ring)
InvRing_MotionRadius(ring, 0);
InvRing_MotionCameraPos(ring, INV_RING_CAMERA_START_HEIGHT);
InvRing_MotionRotation(
ring, PHD_180, ring->ring_pos.rot.y + PHD_180);
ring, -PHD_180, ring->ring_pos.rot.y + PHD_180);
}
break;

Expand Down
Loading
Loading