mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Merge branch 'UnknownShadow200:master' into add-cpe-plugin-message
This commit is contained in:
commit
6a1d6bdaa3
25
src/Chat.c
25
src/Chat.c
@ -53,6 +53,15 @@ static void AppendChatLogTime(void) {
|
||||
Chat_LogTime[logTimesCount++] = now;
|
||||
}
|
||||
|
||||
static void ClearChatLogs(void) {
|
||||
if (Chat_LogTime != defaultLogTimes) Mem_Free(Chat_LogTime);
|
||||
Chat_LogTime = defaultLogTimes;
|
||||
logTimesCount = 0;
|
||||
logTimesCapacity = CHAT_LOGTIMES_DEF_ELEMS;
|
||||
|
||||
StringsBuffer_Clear(&Chat_Log);
|
||||
}
|
||||
|
||||
static char logNameBuffer[STRING_SIZE];
|
||||
static cc_string logName = String_FromArray(logNameBuffer);
|
||||
static char logPathBuffer[FILENAME_SIZE];
|
||||
@ -211,6 +220,15 @@ void Chat_Add(const cc_string* text) { Chat_AddOf(text, MSG_TYPE_NORMAL); }
|
||||
|
||||
void Chat_AddOf(const cc_string* text, int msgType) {
|
||||
if (msgType == MSG_TYPE_NORMAL) {
|
||||
/* Check for chat overflow (see issue #837) */
|
||||
/* This happens because Offset/Length are packed into a single 32 bit value, */
|
||||
/* with 9 bits used for length. Hence if offset exceeds 2^23 (8388608), it */
|
||||
/* overflows and earlier chat messages start wrongly appearing instead */
|
||||
if (Chat_Log.totalLength > 8388000) {
|
||||
ClearChatLogs();
|
||||
Chat_AddRaw("&cChat log cleared as it hit 8.3 million character limit");
|
||||
}
|
||||
|
||||
StringsBuffer_Add(&Chat_Log, text);
|
||||
AppendChatLogTime();
|
||||
AppendChatLog(text);
|
||||
@ -665,12 +683,7 @@ static void OnFree(void) {
|
||||
ClearCPEMessages();
|
||||
cmds_head = NULL;
|
||||
|
||||
if (Chat_LogTime != defaultLogTimes) Mem_Free(Chat_LogTime);
|
||||
Chat_LogTime = defaultLogTimes;
|
||||
logTimesCount = 0;
|
||||
logTimesCapacity = CHAT_LOGTIMES_DEF_ELEMS;
|
||||
|
||||
StringsBuffer_Clear(&Chat_Log);
|
||||
ClearChatLogs();
|
||||
StringsBuffer_Clear(&Chat_InputLog);
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,7 @@ static void CreateDeviceAndSwapChain(void) {
|
||||
desc.BufferCount = 1;
|
||||
// todo see if BGRA slightly faster
|
||||
desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.BufferDesc.RefreshRate.Numerator = 60; // TODO just leave at 0? check DXGI docs again
|
||||
desc.BufferDesc.RefreshRate.Denominator = 1;
|
||||
// RefreshRate intentionally left at 0 so display's refresh rate is used
|
||||
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
desc.OutputWindow = WindowInfo.Handle;
|
||||
desc.SampleDesc.Count = 1;
|
||||
@ -94,9 +93,13 @@ void Gfx_Free(void) {
|
||||
Gfx_FreeState();
|
||||
IDXGISwapChain_Release(swapchain);
|
||||
ID3D11DeviceContext_Release(context);
|
||||
#ifndef _DEBUG
|
||||
ID3D11Device_Release(device);
|
||||
|
||||
#ifdef _DEBUG
|
||||
#else
|
||||
ULONG refCount = ID3D11Device_Release(device);
|
||||
if (refCount == 0) return; // device destroyed with no issues
|
||||
|
||||
ID3D11Debug *d3dDebug;
|
||||
static const GUID guid_d3dDebug = { 0x79cf2233, 0x7536, 0x4948,{ 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } };
|
||||
HRESULT hr = ID3D11Device_QueryInterface(device, &guid_d3dDebug, &d3dDebug);
|
||||
@ -1011,9 +1014,10 @@ finished:
|
||||
}
|
||||
|
||||
void Gfx_SetFpsLimit(cc_bool vsync, float minFrameMs) {
|
||||
gfx_vsync = vsync;
|
||||
gfx_minFrameMs = minFrameMs;
|
||||
gfx_vsync = vsync;
|
||||
}
|
||||
void Gfx_BeginFrame(void) { }
|
||||
void Gfx_BeginFrame(void) { frameStart = Stopwatch_Measure(); }
|
||||
void Gfx_Clear(void) { OM_Clear(); }
|
||||
|
||||
void Gfx_EndFrame(void) {
|
||||
@ -1028,6 +1032,7 @@ void Gfx_EndFrame(void) {
|
||||
|
||||
EndReducedPerformance();
|
||||
if (hr) Logger_Abort2(hr, "Failed to swap buffers");
|
||||
if (gfx_minFrameMs) LimitFPS();
|
||||
}
|
||||
|
||||
cc_bool Gfx_WarnIfNecessary(void) { return false; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user