Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions src/SDL_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "core/windows/SDL_windows.h"
#endif

#if defined(SDL_PLATFORM_NGAGE)
#include "core/ngage/SDL_ngage.h"
#endif

// Simple log messages in SDL

#include "SDL_log_c.h"
Expand Down Expand Up @@ -598,25 +602,6 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
return;
}

#if defined(SDL_PLATFORM_NGAGE)
extern void NGAGE_vnprintf(char *buf, size_t size, const char *fmt, va_list ap);
char buf[1024];
NGAGE_vnprintf(buf, sizeof(buf), fmt, ap);

#ifdef ENABLE_FILE_LOG
FILE* file;
file = fopen("E:/SDL_Log.txt", "a");
if (file)
{
vfprintf(file, fmt, ap);
fprintf(file, "\n");
(void)fclose(file);
}
#endif

return;
#endif

// Render into stack buffer
va_copy(aq, ap);
len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq);
Expand Down Expand Up @@ -799,7 +784,15 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
}
#elif defined(SDL_PLATFORM_NGAGE)
{
/* Nothing to do here. */
NGAGE_DebugPrintf("%s%s", GetLogPriorityPrefix(priority), message);
#ifdef ENABLE_FILE_LOG
FILE *pFile;
pFile = fopen("E:/SDL_Log.txt", "a");
if (pFile) {
(void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message);
(void)fclose(pFile);
}
#endif
}
#endif
#if defined(HAVE_STDIO_H) && \
Expand Down
19 changes: 2 additions & 17 deletions src/core/ngage/SDL_ngage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ bool NGAGE_IsClassicModel()
return (0x101f8c19 == phone_id);
}

void NGAGE_printf(const char *fmt, ...)
void NGAGE_DebugPrintf(const char *fmt, ...)
{
char buffer[512] = { 0 };

va_list ap;
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
(void)SDL_vsnprintf(buffer, sizeof(buffer), fmt, ap);
va_end(ap);

TBuf<512> buf;
Expand All @@ -51,21 +51,6 @@ void NGAGE_printf(const char *fmt, ...)
RDebug::Print(_L("%S"), &buf);
}

void NGAGE_vnprintf(char *buf, size_t size, const char *fmt, va_list ap)
{
char buffer[512] = { 0 };

vsprintf(buffer, fmt, ap);

TBuf<512> tbuf;
tbuf.Copy(TPtrC8((TText8 *)buffer));

RDebug::Print(_L("%S"), &tbuf);

strncpy(buf, buffer, size - 1);
buf[size - 1] = '\0';
}

TInt NGAGE_GetFreeHeapMemory()
{
TInt free = 0;
Expand Down
1 change: 1 addition & 0 deletions src/core/ngage/SDL_ngage.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern "C" {
#endif

bool NGAGE_IsClassicModel();
void NGAGE_DebugPrintf(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);

#ifdef __cplusplus
}
Expand Down
Loading