mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 01:55:19 -04:00
Don't print garbage characters after actual debug messages to MSVC debug window
This commit is contained in:
parent
ae2443bb91
commit
6b8a9cc1e3
@ -234,7 +234,7 @@ static void OnHacksChanged(void* obj) {
|
||||
struct HacksComp* h = &LocalPlayer_Instance.Hacks;
|
||||
/* Leave third person if not allowed anymore */
|
||||
if (!h->CanUseThirdPerson || !h->Enabled) Camera_CycleActive();
|
||||
/* Check if third person camers is allowed to be scrolled out */
|
||||
/* Check if third person camera is allowed to be scrolled out */
|
||||
if (Camera.Active->isThirdPerson) ThirdPersonCamera_Zoom(0);
|
||||
}
|
||||
|
||||
|
@ -175,12 +175,11 @@ void Platform_Log4(const char* format, const void* a1, const void* a2, const voi
|
||||
String_InitArray(msg, msgBuffer);
|
||||
|
||||
String_Format4(&msg, format, a1, a2, a3, a4);
|
||||
Platform_Log(&msg);
|
||||
Platform_Log(msg.buffer, msg.length);
|
||||
}
|
||||
|
||||
void Platform_LogConst(const char* message) {
|
||||
String msg = String_FromReadonly(message);
|
||||
Platform_Log(&msg);
|
||||
Platform_Log(message, String_Length(message));
|
||||
}
|
||||
|
||||
/* TODO: check this is actually accurate */
|
||||
@ -198,17 +197,23 @@ cc_uint64 Stopwatch_ElapsedMilliseconds(cc_uint64 beg, cc_uint64 end) {
|
||||
static HANDLE conHandle;
|
||||
static BOOL hasDebugger;
|
||||
|
||||
void Platform_Log(const String* message) {
|
||||
void Platform_Log(const char* msg, int len) {
|
||||
char tmp[2048 + 1];
|
||||
DWORD wrote;
|
||||
|
||||
if (conHandle) {
|
||||
WriteFile(conHandle, message->buffer, message->length, &wrote, NULL);
|
||||
WriteFile(conHandle, "\n", 1, &wrote, NULL);
|
||||
}
|
||||
if (hasDebugger) {
|
||||
/* TODO: This reads past the end of the buffer */
|
||||
OutputDebugStringA(message->buffer);
|
||||
OutputDebugStringA("\n");
|
||||
WriteFile(conHandle, msg, len, &wrote, NULL);
|
||||
WriteFile(conHandle, "\n", 1, &wrote, NULL);
|
||||
}
|
||||
if (!hasDebugger) return;
|
||||
|
||||
len = min(len, 2048);
|
||||
Mem_Copy(tmp, msg, len);
|
||||
tmp[len] = '\0';
|
||||
|
||||
/* TODO: This reads past the end of the buffer */
|
||||
OutputDebugStringA(tmp);
|
||||
OutputDebugStringA("\n");
|
||||
}
|
||||
|
||||
#define FILETIME_EPOCH 50491123200000ULL
|
||||
@ -254,18 +259,18 @@ cc_uint64 Stopwatch_Measure(void) {
|
||||
/* log to android logcat */
|
||||
#ifdef CC_BUILD_ANDROID
|
||||
#include <android/log.h>
|
||||
void Platform_Log(const String* message) {
|
||||
String tmp; char tmpBuffer[4001];
|
||||
String_InitArray_NT(tmp, tmpBuffer);
|
||||
void Platform_Log(const char* msg, int len) {
|
||||
char tmp[2048 + 1];
|
||||
len = min(len, 2048);
|
||||
|
||||
String_Copy(&tmp, message);
|
||||
tmp.buffer[tmp.length] = '\0';
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "ClassiCube", tmp.buffer);
|
||||
Mem_Copy(tmp, msg, len);
|
||||
tmp[len] = '\0';
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "ClassiCube", tmp);
|
||||
}
|
||||
#else
|
||||
void Platform_Log(const String* message) {
|
||||
write(STDOUT_FILENO, message->buffer, message->length);
|
||||
write(STDOUT_FILENO, "\n", 1);
|
||||
void Platform_Log(const char* msg, int len) {
|
||||
write(STDOUT_FILENO, msg, len);
|
||||
write(STDOUT_FILENO, "\n", 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -120,7 +120,7 @@ void Mem_Set(void* dst, cc_uint8 value, cc_uint32 numBytes);
|
||||
void Mem_Copy(void* dst, const void* src, cc_uint32 numBytes);
|
||||
|
||||
/* Logs a debug message to console. */
|
||||
void Platform_Log(const String* message);
|
||||
void Platform_Log(const char* msg, int len);
|
||||
void Platform_LogConst(const char* message);
|
||||
void Platform_Log1(const char* format, const void* a1);
|
||||
void Platform_Log2(const char* format, const void* a1, const void* a2);
|
||||
|
@ -270,7 +270,7 @@ static void WoM_ParseConfig(struct HttpRequest* item) {
|
||||
Stream_ReadonlyMemory(&mem, item->data, item->size);
|
||||
|
||||
while (!Stream_ReadLine(&mem, &line)) {
|
||||
Platform_Log(&line);
|
||||
Platform_Log(line.buffer, line.length);
|
||||
if (!String_UNSAFE_Separate(&line, '=', &key, &value)) continue;
|
||||
|
||||
if (String_CaselessEqualsConst(&key, "environment.cloud")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user