From ff115a17538436d5ca823fd26cbe76b034cde95b Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 16 Jan 2020 14:33:34 +1100 Subject: [PATCH] Minor tidyup in Chat.c --- src/Chat.c | 46 +++++++++++++++++++++++----------------------- src/Logger.c | 2 +- src/Server.c | 10 +++++----- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Chat.c b/src/Chat.c index f00c7420a..7924f56ca 100644 --- a/src/Chat.c +++ b/src/Chat.c @@ -35,7 +35,7 @@ static TimeMS defaultLogTimes[CHAT_LOGTIMES_DEF_ELEMS]; static int logTimesCapacity = CHAT_LOGTIMES_DEF_ELEMS, logTimesCount; TimeMS* Chat_LogTime = defaultLogTimes; -static void Chat_AppendLogTime(void) { +static void AppendChatLogTime(void) { TimeMS now = DateTime_CurrentUTC_MS(); if (logTimesCount == logTimesCapacity) { @@ -46,11 +46,11 @@ static void Chat_AppendLogTime(void) { } #ifdef CC_BUILD_WEB -static void Chat_ResetLog(void) { } -static void Chat_CloseLog(void) { } +static void ResetLogFile(void) { } +static void CloseLogFile(void) { } void Chat_SetLogName(const String* name) { } -static void Chat_OpenLog(struct DateTime* now) { } -static void Chat_AppendLog(const String* text) { } +static void OpenChatLog(struct DateTime* now) { } +static void AppendChatLog(const String* text) { } #else static char logNameBuffer[STRING_SIZE]; static String logName = String_FromArray(logNameBuffer); @@ -61,7 +61,7 @@ static struct Stream logStream; static struct DateTime lastLogDate; /* Resets log name to empty and last log date to 0 */ -static void Chat_ResetLog(void) { +static void ResetLogFile(void) { logName.length = 0; lastLogDate.day = 0; lastLogDate.month = 0; @@ -69,7 +69,7 @@ static void Chat_ResetLog(void) { } /* Closes handle to the chat log file */ -static void Chat_CloseLog(void) { +static void CloseLogFile(void) { cc_result res; if (!logStream.Meta.File) return; @@ -78,7 +78,7 @@ static void Chat_CloseLog(void) { } /* Whether the given character is an allowed in a log filename */ -static cc_bool Chat_AllowedLogChar(char c) { +static cc_bool AllowedLogNameChar(char c) { return c == '{' || c == '}' || c == '[' || c == ']' || c == '(' || c == ')' || (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); @@ -92,7 +92,7 @@ void Chat_SetLogName(const String* name) { for (i = 0; i < name->length; i++) { c = name->buffer[i]; - if (Chat_AllowedLogChar(c)) { + if (AllowedLogNameChar(c)) { String_Append(&logName, c); } else if (c == '&') { i++; /* skip over following colour code */ @@ -100,15 +100,15 @@ void Chat_SetLogName(const String* name) { } } -static void Chat_DisableLogging(void) { +static void DisableChatLogging(void) { Chat_Logging = false; Chat_AddRaw("&cDisabling chat logging"); } -static void Chat_OpenLog(struct DateTime* now) { +static void OpenChatLog(struct DateTime* now) { cc_result res; int i; - if (!Utils_EnsureDirectory("logs")) { Chat_DisableLogging(); return; } + if (!Utils_EnsureDirectory("logs")) { DisableChatLogging(); return; } /* Ensure multiple instances do not end up overwriting each other's log entries. */ for (i = 0; i < 20; i++) { @@ -123,7 +123,7 @@ static void Chat_OpenLog(struct DateTime* now) { res = Stream_AppendFile(&logStream, &logPath); if (res && res != ReturnCode_FileShareViolation) { - Chat_DisableLogging(); + DisableChatLogging(); Logger_Warn2(res, "appending to", &logPath); return; } @@ -133,11 +133,11 @@ static void Chat_OpenLog(struct DateTime* now) { } logStream.Meta.File = 0; - Chat_DisableLogging(); + DisableChatLogging(); Chat_Add1("&cFailed to open a chat log file after %i tries, giving up", &i); } -static void Chat_AppendLog(const String* text) { +static void AppendChatLog(const String* text) { String str; char strBuffer[STRING_SIZE * 2]; struct DateTime now; cc_result res; @@ -146,8 +146,8 @@ static void Chat_AppendLog(const String* text) { DateTime_CurrentLocal(&now); if (now.day != lastLogDate.day || now.month != lastLogDate.month || now.year != lastLogDate.year) { - Chat_CloseLog(); - Chat_OpenLog(&now); + CloseLogFile(); + OpenChatLog(&now); } lastLogDate = now; @@ -160,7 +160,7 @@ static void Chat_AppendLog(const String* text) { res = Stream_WriteLine(&logStream, &str); if (!res) return; - Chat_DisableLogging(); + DisableChatLogging(); Logger_Warn2(res, "writing to", &logPath); } #endif @@ -191,8 +191,8 @@ void Chat_Add(const String* text) { Chat_AddOf(text, MSG_TYPE_NORMAL); } void Chat_AddOf(const String* text, int msgType) { if (msgType == MSG_TYPE_NORMAL) { StringsBuffer_Add(&Chat_Log, text); - Chat_AppendLogTime(); - Chat_AppendLog(text); + AppendChatLogTime(); + AppendChatLog(text); } else if (msgType >= MSG_TYPE_STATUS_1 && msgType <= MSG_TYPE_STATUS_3) { /* Status[0] is for texture pack downloading message */ String_Copy(&Chat_Status[1 + (msgType - MSG_TYPE_STATUS_1)], text); @@ -607,8 +607,8 @@ static void Chat_Init(void) { } static void Chat_Reset(void) { - Chat_CloseLog(); - Chat_ResetLog(); + CloseLogFile(); + ResetLogFile(); /* reset CPE messages */ Chat_AddOf(&String_Empty, MSG_TYPE_ANNOUNCEMENT); @@ -621,7 +621,7 @@ static void Chat_Reset(void) { } static void Chat_Free(void) { - Chat_CloseLog(); + CloseLogFile(); cmds_head = NULL; if (Chat_LogTime != defaultLogTimes) Mem_Free(Chat_LogTime); diff --git a/src/Logger.c b/src/Logger.c index e259e6535..19d26b7d5 100644 --- a/src/Logger.c +++ b/src/Logger.c @@ -247,7 +247,7 @@ static int Logger_GetFrames(CONTEXT* ctx, cc_uintptr* addrs, int max) { frame.AddrFrame.Offset = ctx->Rsp; frame.AddrStack.Offset = ctx->Rsp; #else - #error "Unknown machine type" + #error "Unknown CPU architecture" #endif HANDLE process = GetCurrentProcess(); diff --git a/src/Server.c b/src/Server.c index 4cdc2aee0..6fdd8c88b 100644 --- a/src/Server.c +++ b/src/Server.c @@ -152,7 +152,7 @@ static void SPConnection_BeginConnect(void) { GeneratingScreen_Show(); } -static char SPConnection_LastCol = '\0'; +static char sp_lastCol = '\0'; static void SPConnection_AddPart(const String* text) { String tmp; char tmpBuffer[STRING_SIZE * 2]; char col; @@ -160,9 +160,9 @@ static void SPConnection_AddPart(const String* text) { String_InitArray(tmp, tmpBuffer); /* Prepend colour codes for subsequent lines of multi-line chat */ - if (!Drawer2D_IsWhiteCol(SPConnection_LastCol)) { + if (!Drawer2D_IsWhiteCol(sp_lastCol)) { String_Append(&tmp, '&'); - String_Append(&tmp, SPConnection_LastCol); + String_Append(&tmp, sp_lastCol); } String_AppendString(&tmp, text); @@ -173,7 +173,7 @@ static void SPConnection_AddPart(const String* text) { String_UNSAFE_TrimEnd(&tmp); col = Drawer2D_LastCol(&tmp, tmp.length); - if (col) SPConnection_LastCol = col; + if (col) sp_lastCol = col; Chat_Add(&tmp); } @@ -185,7 +185,7 @@ static void SPConnection_SendChat(const String* text) { String left, part; if (!text->length) return; - SPConnection_LastCol = '\0'; + sp_lastCol = '\0'; left = *text; while (left.length > STRING_SIZE) {