From 41e805a83337cea96e5d959281d1542c8e99b47c Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 2 Apr 2022 00:38:39 +0300 Subject: [PATCH 1/5] test --- rehlds/engine/common.cpp | 21 ++++++++++++++++++++- rehlds/engine/sv_main.cpp | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/rehlds/engine/common.cpp b/rehlds/engine/common.cpp index c9f07a656..5c205aafe 100644 --- a/rehlds/engine/common.cpp +++ b/rehlds/engine/common.cpp @@ -1185,7 +1185,6 @@ void *EXT_FUNC SZ_GetSpace(sizebuf_t *buf, int length) void *data; const char *buffername = buf->buffername ? buf->buffername : "???"; - if (length < 0) { Sys_Error("%s: %i negative length on %s", __func__, length, buffername); @@ -1239,6 +1238,26 @@ void *EXT_FUNC SZ_GetSpace(sizebuf_t *buf, int length) #endif // REHLDS_FIXES Con_Printf("%s: overflow on %s\n", __func__, buffername); + + const char *p = reinterpret_cast(buf); + + { + auto pFile = FS_Open("overflowed_log.log", "a"); + + if (pFile) + { + tm *today; + time_t ltime; + char szDate[32]; + + time(<ime); + today = localtime(<ime); + strftime(szDate, ARRAYSIZE(szDate) - 1, "L %d/%m/%Y - %H:%M:%S:", today); + + FS_FPrintf(pFile, "SZ_GetSpace: %s (map \"%s\") %s\n", szDate, &pr_strings[gGlobalVariables.mapname], p); + FS_Close(pFile); + } + } SZ_Clear(buf); buf->flags |= SIZEBUF_OVERFLOWED; diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 9c9ce2966..efdd43ffb 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -4745,6 +4745,26 @@ qboolean SV_SendClientDatagram(client_t *client) SV_WriteClientdataToMessage(client, &msg); SV_WriteEntitiesToClient(client, &msg); + const char *p = reinterpret_cast(buf); + + { + auto pFile = FS_Open("overflowed_log.log", "a"); + + if (pFile) + { + tm *today; + time_t ltime; + char szDate[32]; + + time(<ime); + today = localtime(<ime); + strftime(szDate, ARRAYSIZE(szDate) - 1, "L %d/%m/%Y - %H:%M:%S:", today); + + FS_FPrintf(pFile, "SV_SendClientDatagram: %s (map \"%s\") %s\n", szDate, &pr_strings[gGlobalVariables.mapname], p); + FS_Close(pFile); + } + } + if (client->datagram.flags & SIZEBUF_OVERFLOWED) { Con_Printf("WARNING: datagram overflowed for %s\n", client->name); From b64316ca2b5370ea5918a2b9c993ffca5ec73092 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 2 Apr 2022 01:15:11 +0300 Subject: [PATCH 2/5] Update common.cpp --- rehlds/engine/common.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rehlds/engine/common.cpp b/rehlds/engine/common.cpp index 5c205aafe..62cacf37d 100644 --- a/rehlds/engine/common.cpp +++ b/rehlds/engine/common.cpp @@ -257,24 +257,28 @@ const uint32 INVBITTABLE[] = void MSG_WriteChar(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 1); + Log_Printf("WriteChar: %s\n", buf); *(char *)buf = (char)c; } void MSG_WriteByte(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 1); + Log_Printf("WriteByte: %s\n", buf); *(byte *)buf = (byte)c; } void MSG_WriteShort(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 2); + Log_Printf("WriteShort: %s\n", buf); *(int16 *)buf = (int16)c; } void MSG_WriteWord(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 2); + Log_Printf("WriteWord: %s\n", buf); *(uint16 *)buf = (uint16)c; } @@ -294,6 +298,7 @@ void MSG_WriteString(sizebuf_t *sb, const char *s) { if (s) { + Log_Printf("WriteString: %s\n", s); SZ_Write(sb, s, Q_strlen(s) + 1); } else @@ -1239,7 +1244,7 @@ void *EXT_FUNC SZ_GetSpace(sizebuf_t *buf, int length) Con_Printf("%s: overflow on %s\n", __func__, buffername); - const char *p = reinterpret_cast(buf); + const char *p = reinterpret_cast(buf->data); { auto pFile = FS_Open("overflowed_log.log", "a"); From 29df5774eff2d3b41227948af5e163f059eb02ed Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 2 Apr 2022 01:37:12 +0300 Subject: [PATCH 3/5] test2 --- rehlds/engine/common.cpp | 30 +++++------------------------- rehlds/engine/sv_main.cpp | 20 +------------------- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/rehlds/engine/common.cpp b/rehlds/engine/common.cpp index 62cacf37d..a4d28a6c1 100644 --- a/rehlds/engine/common.cpp +++ b/rehlds/engine/common.cpp @@ -257,28 +257,24 @@ const uint32 INVBITTABLE[] = void MSG_WriteChar(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 1); - Log_Printf("WriteChar: %s\n", buf); *(char *)buf = (char)c; } void MSG_WriteByte(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 1); - Log_Printf("WriteByte: %s\n", buf); *(byte *)buf = (byte)c; } void MSG_WriteShort(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 2); - Log_Printf("WriteShort: %s\n", buf); *(int16 *)buf = (int16)c; } void MSG_WriteWord(sizebuf_t *sb, int c) { unsigned char *buf = (unsigned char *)SZ_GetSpace(sb, 2); - Log_Printf("WriteWord: %s\n", buf); *(uint16 *)buf = (uint16)c; } @@ -298,7 +294,6 @@ void MSG_WriteString(sizebuf_t *sb, const char *s) { if (s) { - Log_Printf("WriteString: %s\n", s); SZ_Write(sb, s, Q_strlen(s) + 1); } else @@ -1243,33 +1238,18 @@ void *EXT_FUNC SZ_GetSpace(sizebuf_t *buf, int length) #endif // REHLDS_FIXES Con_Printf("%s: overflow on %s\n", __func__, buffername); + Log_Printf("%s, ovewflow on %s\n", __func__, buffername); - const char *p = reinterpret_cast(buf->data); - - { - auto pFile = FS_Open("overflowed_log.log", "a"); - - if (pFile) - { - tm *today; - time_t ltime; - char szDate[32]; - - time(<ime); - today = localtime(<ime); - strftime(szDate, ARRAYSIZE(szDate) - 1, "L %d/%m/%Y - %H:%M:%S:", today); - - FS_FPrintf(pFile, "SZ_GetSpace: %s (map \"%s\") %s\n", szDate, &pr_strings[gGlobalVariables.mapname], p); - FS_Close(pFile); - } - } - SZ_Clear(buf); buf->flags |= SIZEBUF_OVERFLOWED; } data = &buf->data[buf->cursize]; buf->cursize = length + buf->cursize; + + unsigned char *buf = (unsigned char *)data; + + Log_Printf("%s, ovewflow on %s | buf: %d\n", __func__, buffername, buf); return data; } diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index efdd43ffb..ac5f1d3ae 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -4744,26 +4744,8 @@ qboolean SV_SendClientDatagram(client_t *client) SV_WriteClientdataToMessage(client, &msg); SV_WriteEntitiesToClient(client, &msg); - - const char *p = reinterpret_cast(buf); - { - auto pFile = FS_Open("overflowed_log.log", "a"); - - if (pFile) - { - tm *today; - time_t ltime; - char szDate[32]; - - time(<ime); - today = localtime(<ime); - strftime(szDate, ARRAYSIZE(szDate) - 1, "L %d/%m/%Y - %H:%M:%S:", today); - - FS_FPrintf(pFile, "SV_SendClientDatagram: %s (map \"%s\") %s\n", szDate, &pr_strings[gGlobalVariables.mapname], p); - FS_Close(pFile); - } - } + Log_Printf("%s, ovewflow on %s | buf: %d\n", __func__, buffername, buf); if (client->datagram.flags & SIZEBUF_OVERFLOWED) { From e53f8a266f93efb513ee24fe1adf376f96835821 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 2 Apr 2022 01:41:02 +0300 Subject: [PATCH 4/5] Update sv_main.cpp --- rehlds/engine/sv_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index ac5f1d3ae..e18421ab4 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -4745,7 +4745,7 @@ qboolean SV_SendClientDatagram(client_t *client) SV_WriteClientdataToMessage(client, &msg); SV_WriteEntitiesToClient(client, &msg); - Log_Printf("%s, ovewflow on %s | buf: %d\n", __func__, buffername, buf); + Log_Printf("%s, ovewflow | buf: %d\n", __func__, buf); if (client->datagram.flags & SIZEBUF_OVERFLOWED) { From fed66979615cc78e4b3f434dff70c9d287db3eec Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 2 Apr 2022 01:43:27 +0300 Subject: [PATCH 5/5] Update common.cpp --- rehlds/engine/common.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/common.cpp b/rehlds/engine/common.cpp index a4d28a6c1..d51dc59ec 100644 --- a/rehlds/engine/common.cpp +++ b/rehlds/engine/common.cpp @@ -1247,9 +1247,9 @@ void *EXT_FUNC SZ_GetSpace(sizebuf_t *buf, int length) data = &buf->data[buf->cursize]; buf->cursize = length + buf->cursize; - unsigned char *buf = (unsigned char *)data; + unsigned char *wtf = (unsigned char *)data; - Log_Printf("%s, ovewflow on %s | buf: %d\n", __func__, buffername, buf); + Log_Printf("%s, ovewflow on %s | buf: %d\n", __func__, buffername, wtf); return data; }