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

misc: adopt M_ prefix for private functions #248

Merged
merged 1 commit into from
Sep 20, 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
12 changes: 6 additions & 6 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ CONFIG g_Config = { 0 };

static const char *m_ConfigPath = DIR_CONFIG "/TR2X.json5";

static void Config_Load(struct json_object_s *root_obj);
static void Config_Dump(struct json_object_s *root_obj);
static void M_Load(struct json_object_s *root_obj);
static void M_Dump(struct json_object_s *root_obj);

static void Config_Load(struct json_object_s *root_obj)
static void M_Load(struct json_object_s *root_obj)
{
ConfigFile_LoadOptions(root_obj, g_ConfigOptionMap);
}

static void Config_Dump(struct json_object_s *root_obj)
static void M_Dump(struct json_object_s *root_obj)
{
ConfigFile_DumpOptions(root_obj, g_ConfigOptionMap);
}

bool Config_Read(void)
{
return ConfigFile_Read(m_ConfigPath, &Config_Load);
return ConfigFile_Read(m_ConfigPath, &M_Load);
}

bool Config_Write(void)
{
File_CreateDirectory(DIR_CONFIG);
return ConfigFile_Write(m_ConfigPath, &Config_Dump);
return ConfigFile_Write(m_ConfigPath, &M_Dump);
}

void Config_Sanitize(void)
Expand Down
68 changes: 37 additions & 31 deletions src/decomp/decomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,28 @@

#define IDI_MAINICON 100

static bool InsertDisplayModeInListSorted(
static bool M_InsertDisplayModeInListSorted(
DISPLAY_MODE_LIST *mode_list, DISPLAY_MODE *src_mode);

static void DisplayModeListInit(DISPLAY_MODE_LIST *mode_list);
static void DisplayModeListDelete(DISPLAY_MODE_LIST *mode_list);
static bool DisplayModeListCopy(DISPLAY_MODE_LIST *dst, DISPLAY_MODE_LIST *src);
static DISPLAY_MODE *InsertDisplayMode(
static void M_DisplayModeListInit(DISPLAY_MODE_LIST *mode_list);
static void M_DisplayModeListDelete(DISPLAY_MODE_LIST *mode_list);
static bool M_DisplayModeListCopy(
DISPLAY_MODE_LIST *dst, DISPLAY_MODE_LIST *src);
static DISPLAY_MODE *M_InsertDisplayMode(
DISPLAY_MODE_LIST *mode_list, DISPLAY_MODE_NODE *before);
static DISPLAY_MODE *InsertDisplayModeInListHead(DISPLAY_MODE_LIST *mode_list);
static DISPLAY_MODE *InsertDisplayModeInListTail(DISPLAY_MODE_LIST *mode_list);
static DISPLAY_MODE *M_InsertDisplayModeInListHead(
DISPLAY_MODE_LIST *mode_list);
static DISPLAY_MODE *M_InsertDisplayModeInListTail(
DISPLAY_MODE_LIST *mode_list);

static void DisplayModeListInit(DISPLAY_MODE_LIST *mode_list)
static void M_DisplayModeListInit(DISPLAY_MODE_LIST *mode_list)
{
mode_list->head = NULL;
mode_list->tail = NULL;
mode_list->count = 0;
}

static void DisplayModeListDelete(DISPLAY_MODE_LIST *mode_list)
static void M_DisplayModeListDelete(DISPLAY_MODE_LIST *mode_list)
{
DISPLAY_MODE_NODE *node;
DISPLAY_MODE_NODE *nextNode;
Expand All @@ -64,28 +67,29 @@ static void DisplayModeListDelete(DISPLAY_MODE_LIST *mode_list)
nextNode = node->next;
free(node);
}
DisplayModeListInit(mode_list);
M_DisplayModeListInit(mode_list);
}

static bool DisplayModeListCopy(DISPLAY_MODE_LIST *dst, DISPLAY_MODE_LIST *src)
static bool M_DisplayModeListCopy(
DISPLAY_MODE_LIST *dst, DISPLAY_MODE_LIST *src)
{
if (dst == NULL || src == NULL || dst == src) {
return false;
}

DisplayModeListDelete(dst);
M_DisplayModeListDelete(dst);
for (DISPLAY_MODE_NODE *node = src->head; node != NULL; node = node->next) {
DISPLAY_MODE *dst_mode = InsertDisplayModeInListTail(dst);
DISPLAY_MODE *dst_mode = M_InsertDisplayModeInListTail(dst);
*dst_mode = node->body;
}
return true;
}

static DISPLAY_MODE *InsertDisplayMode(
static DISPLAY_MODE *M_InsertDisplayMode(
DISPLAY_MODE_LIST *mode_list, DISPLAY_MODE_NODE *before)
{
if (!before || !before->previous) {
return InsertDisplayModeInListHead(mode_list);
return M_InsertDisplayModeInListHead(mode_list);
}

DISPLAY_MODE_NODE *node = malloc(sizeof(DISPLAY_MODE_NODE));
Expand All @@ -103,7 +107,7 @@ static DISPLAY_MODE *InsertDisplayMode(
return &node->body;
}

static DISPLAY_MODE *InsertDisplayModeInListHead(DISPLAY_MODE_LIST *mode_list)
static DISPLAY_MODE *M_InsertDisplayModeInListHead(DISPLAY_MODE_LIST *mode_list)
{
DISPLAY_MODE_NODE *node = malloc(sizeof(DISPLAY_MODE_NODE));
if (!node) {
Expand All @@ -126,7 +130,7 @@ static DISPLAY_MODE *InsertDisplayModeInListHead(DISPLAY_MODE_LIST *mode_list)
return &node->body;
}

static DISPLAY_MODE *InsertDisplayModeInListTail(DISPLAY_MODE_LIST *mode_list)
static DISPLAY_MODE *M_InsertDisplayModeInListTail(DISPLAY_MODE_LIST *mode_list)
{
DISPLAY_MODE_NODE *node = malloc(sizeof(DISPLAY_MODE_NODE));
if (!node) {
Expand All @@ -149,24 +153,24 @@ static DISPLAY_MODE *InsertDisplayModeInListTail(DISPLAY_MODE_LIST *mode_list)
return &node->body;
}

static bool InsertDisplayModeInListSorted(
static bool M_InsertDisplayModeInListSorted(
DISPLAY_MODE_LIST *mode_list, DISPLAY_MODE *src_mode)
{
DISPLAY_MODE *dst_mode = NULL;

if (mode_list->head == NULL
|| CompareVideoModes(src_mode, &mode_list->head->body)) {
dst_mode = InsertDisplayModeInListHead(mode_list);
dst_mode = M_InsertDisplayModeInListHead(mode_list);
goto finish;
}
for (DISPLAY_MODE_NODE *node = mode_list->head; node != NULL;
node = node->next) {
if (CompareVideoModes(src_mode, &node->body)) {
dst_mode = InsertDisplayMode(mode_list, node);
dst_mode = M_InsertDisplayMode(mode_list, node);
goto finish;
}
}
dst_mode = InsertDisplayModeInListTail(mode_list);
dst_mode = M_InsertDisplayModeInListTail(mode_list);

finish:
if (dst_mode == NULL) {
Expand Down Expand Up @@ -2424,11 +2428,13 @@ HRESULT __stdcall EnumDisplayModesCallback(
if (adapter->hw_render_supported
&& (render_bit_depth & adapter->hw_device_desc.dwDeviceRenderBitDepth)
!= 0) {
InsertDisplayModeInListSorted(&adapter->hw_disp_mode_list, &video_mode);
M_InsertDisplayModeInListSorted(
&adapter->hw_disp_mode_list, &video_mode);
}

if (sw_renderer_supported) {
InsertDisplayModeInListSorted(&adapter->sw_disp_mode_list, &video_mode);
M_InsertDisplayModeInListSorted(
&adapter->sw_disp_mode_list, &video_mode);
}

return DDENUMRET_OK;
Expand All @@ -2452,8 +2458,8 @@ bool __cdecl WinVidGetDisplayAdapters(void)
*next_node = NULL;
node != NULL; node = next_node) {
next_node = node->next;
DisplayModeListDelete(&node->body.sw_disp_mode_list);
DisplayModeListDelete(&node->body.hw_disp_mode_list);
M_DisplayModeListDelete(&node->body.sw_disp_mode_list);
M_DisplayModeListDelete(&node->body.hw_disp_mode_list);
S_FlaggedString_Delete(&node->body.driver_name);
S_FlaggedString_Delete(&node->body.driver_desc);
free(node);
Expand Down Expand Up @@ -2508,8 +2514,8 @@ BOOL WINAPI EnumDisplayAdaptersCallback(
list_node->previous = adapter_list->tail;

S_FlaggedString_InitAdapter(&list_node->body);
DisplayModeListInit(&list_node->body.hw_disp_mode_list);
DisplayModeListInit(&list_node->body.sw_disp_mode_list);
M_DisplayModeListInit(&list_node->body.hw_disp_mode_list);
M_DisplayModeListInit(&list_node->body.sw_disp_mode_list);

if (!adapter_list->head) {
adapter_list->head = list_node;
Expand Down Expand Up @@ -2913,13 +2919,13 @@ void __cdecl WinVidStart(void)
S_FlaggedString_Copy(
&g_CurrentDisplayAdapter.driver_name, &preferred->driver_name);

DisplayModeListInit(&g_CurrentDisplayAdapter.hw_disp_mode_list);
DisplayModeListCopy(
M_DisplayModeListInit(&g_CurrentDisplayAdapter.hw_disp_mode_list);
M_DisplayModeListCopy(
&g_CurrentDisplayAdapter.hw_disp_mode_list,
&preferred->hw_disp_mode_list);

DisplayModeListInit(&g_CurrentDisplayAdapter.sw_disp_mode_list);
DisplayModeListCopy(
M_DisplayModeListInit(&g_CurrentDisplayAdapter.sw_disp_mode_list);
M_DisplayModeListCopy(
&g_CurrentDisplayAdapter.sw_disp_mode_list,
&preferred->sw_disp_mode_list);

Expand Down
4 changes: 2 additions & 2 deletions src/decomp/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef struct {
uint8_t medipacks;
} STATS;

static STATS Stats_GetEndGameStats(void)
static STATS M_GetEndGameStats(void)
{
STATS result = { 0 };

Expand Down Expand Up @@ -238,7 +238,7 @@ void __cdecl ShowEndStatsText(void)
&g_StatsRequester, g_GF_GameStrings[GF_S_GAME_MISC_FINAL_STATISTICS], 0,
0, 0);

const STATS stats = Stats_GetEndGameStats();
const STATS stats = M_GetEndGameStats();

const int32_t sec = stats.timer / FRAMES_PER_SECOND;
sprintf(
Expand Down
48 changes: 24 additions & 24 deletions src/game/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ static const double m_LogScale = 0.8;
static const char m_ValidPromptChars[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.- ";

static void Console_ShutdownPrompt(void);
static void Console_ShutdownLogs(void);
static void Console_UpdatePromptTextstring(void);
static void Console_UpdateCaretTextstring(void);
static COMMAND_RESULT Console_Eval(const char *cmdline);
static void M_ShutdownPrompt(void);
static void M_ShutdownLogs(void);
static void M_UpdatePromptTextstring(void);
static void M_UpdateCaretTextstring(void);
static COMMAND_RESULT M_Eval(const char *cmdline);

extern CONSOLE_COMMAND *g_ConsoleCommands[];
static void Console_ShutdownPrompt(void)
static void M_ShutdownPrompt(void)
{
if (m_Prompt.prompt_ts != NULL) {
Text_Remove(m_Prompt.prompt_ts);
Expand All @@ -64,20 +64,20 @@ static void Console_ShutdownPrompt(void)
}
}

static void Console_ShutdownLogs(void)
static void M_ShutdownLogs(void)
{
for (int32_t i = 0; i < MAX_LOG_LINES; i++) {
Text_Remove(m_Logs[i].ts);
m_Logs[i].ts = NULL;
}
}

static void Console_UpdatePromptTextstring(void)
static void M_UpdatePromptTextstring(void)
{
Text_ChangeText(m_Prompt.prompt_ts, m_Prompt.text);
}

static void Console_UpdateCaretTextstring(void)
static void M_UpdateCaretTextstring(void)
{
const char old = m_Prompt.prompt_ts->text[m_Prompt.caret];
m_Prompt.prompt_ts->text[m_Prompt.caret] = '\0';
Expand All @@ -87,7 +87,7 @@ static void Console_UpdateCaretTextstring(void)
Text_SetPos(m_Prompt.caret_ts, MARGIN + width, -MARGIN);
}

static COMMAND_RESULT Console_Eval(const char *const cmdline)
static COMMAND_RESULT M_Eval(const char *const cmdline)
{
const char *args = NULL;
const CONSOLE_COMMAND *matching_cmd = NULL;
Expand Down Expand Up @@ -155,14 +155,14 @@ void Console_Init(void)
void Console_Shutdown(void)
{
m_IsOpened = false;
Console_ShutdownPrompt();
Console_ShutdownLogs();
M_ShutdownPrompt();
M_ShutdownLogs();
}

void Console_Open(void)
{
if (m_IsOpened) {
Console_ShutdownPrompt();
M_ShutdownPrompt();
} else {
LOG_DEBUG("opening console!");
}
Expand All @@ -181,15 +181,15 @@ void Console_Open(void)
m_Prompt.prompt_ts, PHD_ONE * m_PromptScale, PHD_ONE * m_PromptScale);
Text_AlignBottom(m_Prompt.prompt_ts, true);

Console_UpdateCaretTextstring();
M_UpdateCaretTextstring();
}

void Console_Close(void)
{
LOG_DEBUG("closing console!");
m_IsOpened = false;
strcpy(m_Prompt.text, "");
Console_ShutdownPrompt();
M_ShutdownPrompt();
}

bool Console_IsOpened(void)
Expand All @@ -205,7 +205,7 @@ void Console_Confirm(void)
}

LOG_INFO("executing command: %s", m_Prompt.text);
Console_Eval(m_Prompt.text);
M_Eval(m_Prompt.text);
Console_Close();
}

Expand All @@ -225,7 +225,7 @@ bool Console_HandleKeyDown(const uint32_t key)
}
if (m_Prompt.caret > 0) {
m_Prompt.caret--;
Console_UpdateCaretTextstring();
M_UpdateCaretTextstring();
}
return true;

Expand All @@ -235,7 +235,7 @@ bool Console_HandleKeyDown(const uint32_t key)
}
if (m_Prompt.caret < (int32_t)strlen(m_Prompt.text)) {
m_Prompt.caret++;
Console_UpdateCaretTextstring();
M_UpdateCaretTextstring();
}
return true;

Expand All @@ -244,15 +244,15 @@ bool Console_HandleKeyDown(const uint32_t key)
return false;
}
m_Prompt.caret = 0;
Console_UpdateCaretTextstring();
M_UpdateCaretTextstring();
return true;

case VK_END:
if (!m_IsOpened) {
return false;
}
m_Prompt.caret = strlen(m_Prompt.text);
Console_UpdateCaretTextstring();
M_UpdateCaretTextstring();
return true;

case VK_BACK:
Expand All @@ -264,8 +264,8 @@ bool Console_HandleKeyDown(const uint32_t key)
m_Prompt.text[i - 1] = m_Prompt.text[i];
}
m_Prompt.caret--;
Console_UpdatePromptTextstring();
Console_UpdateCaretTextstring();
M_UpdatePromptTextstring();
M_UpdateCaretTextstring();
}
return true;
}
Expand Down Expand Up @@ -304,8 +304,8 @@ void Console_HandleChar(const uint32_t char_)

m_Prompt.caret += insert_length;
m_Prompt.text[MAX_PROMPT_LENGTH - 1] = '\0';
Console_UpdatePromptTextstring();
Console_UpdateCaretTextstring();
M_UpdatePromptTextstring();
M_UpdateCaretTextstring();
}

void Console_Log(const char *fmt, ...)
Expand Down
Loading
Loading