mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Expose Chat_LogTime directly instead of Chat_GetLogTime function
This commit is contained in:
parent
445ff1c5a3
commit
3d82f65f45
20
src/Chat.c
20
src/Chat.c
@ -31,22 +31,17 @@ bool Chat_Logging;
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
#define CHAT_LOGTIMES_DEF_ELEMS 256
|
#define CHAT_LOGTIMES_DEF_ELEMS 256
|
||||||
static TimeMS defaultLogTimes[CHAT_LOGTIMES_DEF_ELEMS];
|
static TimeMS defaultLogTimes[CHAT_LOGTIMES_DEF_ELEMS];
|
||||||
static TimeMS* logTimes = defaultLogTimes;
|
|
||||||
static int logTimesCapacity = CHAT_LOGTIMES_DEF_ELEMS, logTimesCount;
|
static int logTimesCapacity = CHAT_LOGTIMES_DEF_ELEMS, logTimesCount;
|
||||||
|
TimeMS* Chat_LogTime = defaultLogTimes;
|
||||||
TimeMS Chat_GetLogTime(int i) {
|
|
||||||
if (i < 0 || i >= logTimesCount) Logger_Abort("Tried to get time past LogTime end");
|
|
||||||
return logTimes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Chat_AppendLogTime(void) {
|
static void Chat_AppendLogTime(void) {
|
||||||
TimeMS now = DateTime_CurrentUTC_MS();
|
TimeMS now = DateTime_CurrentUTC_MS();
|
||||||
|
|
||||||
if (logTimesCount == logTimesCapacity) {
|
if (logTimesCount == logTimesCapacity) {
|
||||||
Utils_Resize((void**)&logTimes, &logTimesCapacity,
|
Utils_Resize((void**)&Chat_LogTime, &logTimesCapacity,
|
||||||
sizeof(TimeMS), CHAT_LOGTIMES_DEF_ELEMS, 512);
|
sizeof(TimeMS), CHAT_LOGTIMES_DEF_ELEMS, 512);
|
||||||
}
|
}
|
||||||
logTimes[logTimesCount++] = now;
|
Chat_LogTime[logTimesCount++] = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CC_BUILD_WEB
|
#ifdef CC_BUILD_WEB
|
||||||
@ -64,6 +59,7 @@ static String logPath = String_FromArray(logPathBuffer);
|
|||||||
static struct Stream logStream;
|
static struct Stream logStream;
|
||||||
static struct DateTime lastLogDate;
|
static struct DateTime lastLogDate;
|
||||||
|
|
||||||
|
/* Resets log name to empty and last log date to 0 */
|
||||||
static void Chat_ResetLog(void) {
|
static void Chat_ResetLog(void) {
|
||||||
logName.length = 0;
|
logName.length = 0;
|
||||||
lastLogDate.Day = 0;
|
lastLogDate.Day = 0;
|
||||||
@ -71,6 +67,7 @@ static void Chat_ResetLog(void) {
|
|||||||
lastLogDate.Year = 0;
|
lastLogDate.Year = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Closes handle to the chat log file */
|
||||||
static void Chat_CloseLog(void) {
|
static void Chat_CloseLog(void) {
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
if (!logStream.Meta.File) return;
|
if (!logStream.Meta.File) return;
|
||||||
@ -79,6 +76,7 @@ static void Chat_CloseLog(void) {
|
|||||||
if (res) { Logger_Warn2(res, "closing", &logPath); }
|
if (res) { Logger_Warn2(res, "closing", &logPath); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Whether the given character is an allowed in a log filename */
|
||||||
static bool Chat_AllowedLogChar(char c) {
|
static bool Chat_AllowedLogChar(char c) {
|
||||||
return
|
return
|
||||||
c == '{' || c == '}' || c == '[' || c == ']' || c == '(' || c == ')' ||
|
c == '{' || c == '}' || c == '[' || c == ']' || c == '(' || c == ')' ||
|
||||||
@ -194,8 +192,8 @@ void Chat_Add(const String* text) { Chat_AddOf(text, MSG_TYPE_NORMAL); }
|
|||||||
void Chat_AddOf(const String* text, int msgType) {
|
void Chat_AddOf(const String* text, int msgType) {
|
||||||
if (msgType == MSG_TYPE_NORMAL) {
|
if (msgType == MSG_TYPE_NORMAL) {
|
||||||
StringsBuffer_Add(&Chat_Log, text);
|
StringsBuffer_Add(&Chat_Log, text);
|
||||||
Chat_AppendLog(text);
|
|
||||||
Chat_AppendLogTime();
|
Chat_AppendLogTime();
|
||||||
|
Chat_AppendLog(text);
|
||||||
} else if (msgType >= MSG_TYPE_STATUS_1 && msgType <= MSG_TYPE_STATUS_3) {
|
} else if (msgType >= MSG_TYPE_STATUS_1 && msgType <= MSG_TYPE_STATUS_3) {
|
||||||
/* Status[0] is for texture pack downloading message */
|
/* Status[0] is for texture pack downloading message */
|
||||||
String_Copy(&Chat_Status[1 + (msgType - MSG_TYPE_STATUS_1)], text);
|
String_Copy(&Chat_Status[1 + (msgType - MSG_TYPE_STATUS_1)], text);
|
||||||
@ -611,8 +609,8 @@ static void Chat_Free(void) {
|
|||||||
Chat_CloseLog();
|
Chat_CloseLog();
|
||||||
cmds_head = NULL;
|
cmds_head = NULL;
|
||||||
|
|
||||||
if (logTimes != defaultLogTimes) Mem_Free(logTimes);
|
if (Chat_LogTime != defaultLogTimes) Mem_Free(Chat_LogTime);
|
||||||
logTimes = defaultLogTimes;
|
Chat_LogTime = defaultLogTimes;
|
||||||
logTimesCount = 0;
|
logTimesCount = 0;
|
||||||
|
|
||||||
StringsBuffer_Clear(&Chat_Log);
|
StringsBuffer_Clear(&Chat_Log);
|
||||||
|
@ -21,14 +21,17 @@ enum MsgType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern String Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2], Chat_Announcement;
|
extern String Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2], Chat_Announcement;
|
||||||
extern StringsBuffer Chat_Log, Chat_InputLog;
|
/* All chat messages received. */
|
||||||
|
extern StringsBuffer Chat_Log;
|
||||||
|
/* Time each chat message was received at. */
|
||||||
|
extern TimeMS* Chat_LogTime;
|
||||||
|
/* All chat entered by the user. */
|
||||||
|
extern StringsBuffer Chat_InputLog;
|
||||||
/* Whether chat messages are logged to disc. */
|
/* Whether chat messages are logged to disc. */
|
||||||
extern bool Chat_Logging;
|
extern bool Chat_Logging;
|
||||||
|
|
||||||
/* Time at which last announcement message was received. */
|
/* Time at which last announcement message was received. */
|
||||||
extern TimeMS Chat_AnnouncementReceived;
|
extern TimeMS Chat_AnnouncementReceived;
|
||||||
/* Gets the time the ith chat message was received at. */
|
|
||||||
TimeMS Chat_GetLogTime(int i);
|
|
||||||
|
|
||||||
struct ChatCommand;
|
struct ChatCommand;
|
||||||
/* Represents a client-side command/action. */
|
/* Represents a client-side command/action. */
|
||||||
|
@ -832,6 +832,7 @@ ReturnCode Gfx_TakeScreenshot(struct Stream* output) {
|
|||||||
IDirect3DSurface9* backbuffer = NULL;
|
IDirect3DSurface9* backbuffer = NULL;
|
||||||
IDirect3DSurface9* temp = NULL;
|
IDirect3DSurface9* temp = NULL;
|
||||||
D3DSURFACE_DESC desc;
|
D3DSURFACE_DESC desc;
|
||||||
|
D3DLOCKED_RECT rect;
|
||||||
Bitmap bmp;
|
Bitmap bmp;
|
||||||
ReturnCode res;
|
ReturnCode res;
|
||||||
|
|
||||||
@ -844,8 +845,7 @@ ReturnCode Gfx_TakeScreenshot(struct Stream* output) {
|
|||||||
if (res) goto finished; /* TODO: For DX 8 use IDirect3DDevice8::CreateImageSurface */
|
if (res) goto finished; /* TODO: For DX 8 use IDirect3DDevice8::CreateImageSurface */
|
||||||
res = IDirect3DDevice9_GetRenderTargetData(device, backbuffer, temp);
|
res = IDirect3DDevice9_GetRenderTargetData(device, backbuffer, temp);
|
||||||
if (res) goto finished;
|
if (res) goto finished;
|
||||||
|
|
||||||
D3DLOCKED_RECT rect;
|
|
||||||
res = IDirect3DSurface9_LockRect(temp, &rect, NULL, D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE);
|
res = IDirect3DSurface9_LockRect(temp, &rect, NULL, D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE);
|
||||||
if (res) goto finished;
|
if (res) goto finished;
|
||||||
{
|
{
|
||||||
|
@ -980,7 +980,7 @@ static void HUDScreen_DrawChat(struct HUDScreen* s, double delta) {
|
|||||||
if (!tex.ID) continue;
|
if (!tex.ID) continue;
|
||||||
|
|
||||||
if (logIdx < 0 || logIdx >= Chat_Log.count) continue;
|
if (logIdx < 0 || logIdx >= Chat_Log.count) continue;
|
||||||
if (Chat_GetLogTime(logIdx) + (10 * 1000) >= now) Texture_Render(&tex);
|
if (Chat_LogTime[logIdx] + (10 * 1000) >= now) Texture_Render(&tex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,9 @@ void Window_Init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
void Window_Create(int width, int height) {
|
||||||
|
ATOM atom;
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
win_instance = GetModuleHandle(NULL);
|
win_instance = GetModuleHandle(NULL);
|
||||||
/* TODO: UngroupFromTaskbar(); */
|
/* TODO: UngroupFromTaskbar(); */
|
||||||
width = Display_ScaleX(width);
|
width = Display_ScaleX(width);
|
||||||
@ -437,7 +439,7 @@ void Window_Create(int width, int height) {
|
|||||||
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
|
||||||
ATOM atom = RegisterClassEx(&wc);
|
atom = RegisterClassEx(&wc);
|
||||||
if (!atom) Logger_Abort2(GetLastError(), "Failed to register window class");
|
if (!atom) Logger_Abort2(GetLastError(), "Failed to register window class");
|
||||||
|
|
||||||
win_handle = CreateWindowEx(0, MAKEINTATOM(atom), NULL, CC_WIN_STYLE,
|
win_handle = CreateWindowEx(0, MAKEINTATOM(atom), NULL, CC_WIN_STYLE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user