Skip to content

Commit

Permalink
Cleanup|Client: Log levels and domains (continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 9, 2014
1 parent a6cc1a6 commit bbd9376
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 50 deletions.
35 changes: 13 additions & 22 deletions doomsday/client/src/m_misc.cpp
Expand Up @@ -291,6 +291,8 @@ static size_t FileReader(const char* name, char** buffer)
size_t length = 0;
int handle;

LOG_AS("FileReader");

// First try with LZSS.
LZFILE *file = lzOpen((char*) name, "rp");

Expand All @@ -308,9 +310,7 @@ static size_t FileReader(const char* name, char** buffer)

// Allocate more memory.
newBuf = (char*) Z_Malloc(length + bytesRead, PU_APPSTATIC, 0);
if(NULL == newBuf)
Con_Error("FileReader: realloc failed.");
if(NULL != buf)
if(buf != NULL)
{
memcpy(newBuf, buf, length);
Z_Free(buf);
Expand All @@ -332,15 +332,14 @@ static size_t FileReader(const char* name, char** buffer)
handle = open(name, O_RDONLY | O_BINARY, 0666);
if(handle == -1)
{
#if _DEBUG
Con_Message("Warning:FileReader: Failed opening \"%s\" for reading.", name);
#endif
LOG_RES_WARNING("Failed opening \"%s\" for reading") << name;
return length;
}

if(-1 == fstat(handle, &fileinfo))
{
Con_Error("FileReader: Couldn't read file %s\n", name);
LOG_RES_ERROR("Couldn't read file \"%s\"") << name;
return 0;
}

length = fileinfo.st_size;
Expand All @@ -351,18 +350,14 @@ static size_t FileReader(const char* name, char** buffer)
}

buf = (char *) Z_Malloc(length, PU_APPSTATIC, 0);
if(buf == NULL)
{
Con_Error("FileReader: Failed on allocation of %lu bytes for file \"%s\".\n",
(unsigned long) length, name);
}
DENG_ASSERT(buf != 0);

{ size_t bytesRead = read(handle, buf, length);
size_t bytesRead = read(handle, buf, length);
close(handle);
if(bytesRead < length)
{
Con_Error("FileReader: Couldn't read file \"%s\".\n", name);
}}
LOG_RES_ERROR("Couldn't read file \"%s\"") << name;
}
*buffer = buf;

return length;
Expand All @@ -387,19 +382,15 @@ void M_WriteCommented(FILE *file, const char* text)
*/
void M_WriteTextEsc(FILE* file, const char* text)
{
if(!file || !text)
{
Con_Error("Attempted M_WriteTextEsc with invalid reference (%s==0).", !file? "file":"text");
return; // Unreachable.
}
DENG_ASSERT(file && text);

{ size_t i;
size_t i;
for(i = 0; i < strlen(text) && text[i]; ++i)
{
if(text[i] == '"' || text[i] == '\\')
fprintf(file, "\\");
fprintf(file, "%c", text[i]);
}}
}
}

DENG_EXTERN_C int M_ScreenShot(char const *name, int bits)
Expand Down
24 changes: 11 additions & 13 deletions doomsday/client/src/unix/joystick.cpp
Expand Up @@ -72,15 +72,14 @@ static void initialize(void)

if(SDL_InitSubSystem(SDL_INIT_JOYSTICK))
{
Con_Message("SDL init failed for joystick: %s", SDL_GetError());
LOG_INPUT_ERROR("SDL init failed for joystick: %s") << SDL_GetError();
}

if((joycount = SDL_NumJoysticks()) > 0)
{
if(joydevice > joycount)
{
Con_Message("I_InitJoystick: joydevice = %i, out of range.",
joydevice);
LOG_INPUT_WARNING("Using the default joystick instead of joystick #%i") << joydevice;
joy = SDL_JoystickOpen(0);
}
else
Expand All @@ -90,26 +89,23 @@ static void initialize(void)
if(joy)
{
// Show some info.
Con_Message("I_InitJoystick: %s", SDL_JoystickName(SDL_JoystickIndex(joy)));
LOG_INPUT_MSG("Joystick name: %s" ) << SDL_JoystickName(SDL_JoystickIndex(joy));

// We'll handle joystick events manually
SDL_JoystickEventState(SDL_ENABLE);

if(verbose)
{
Con_Message("I_InitJoystick: Joystick reports %i axes, %i buttons, %i hats, "
"and %i trackballs.",
SDL_JoystickNumAxes(joy),
SDL_JoystickNumButtons(joy),
SDL_JoystickNumHats(joy),
SDL_JoystickNumBalls(joy));
LOG_INPUT_VERBOSE("Joystick reports %i axes, %i buttons, %i hats, and %i trackballs")
<< SDL_JoystickNumAxes(joy)
<< SDL_JoystickNumButtons(joy)
<< SDL_JoystickNumHats(joy)
<< SDL_JoystickNumBalls(joy);
}

joyAvailable = true;
}
else
{
Con_Message("I_InitJoystick: No joysticks found");
LOG_INPUT_NOTE("No joysticks found");
joyAvailable = false;
}
}
Expand All @@ -120,6 +116,8 @@ boolean Joystick_Init(void)
#ifndef DENG_NO_SDL
if(joyInited) return true; // Already initialized.

LOG_AS("Joystick_Init");

initialize();
joyInited = true;
#endif
Expand Down
11 changes: 1 addition & 10 deletions doomsday/server/src/server/sv_frame.cpp
Expand Up @@ -914,16 +914,7 @@ void Sv_SendFrame(int plrNum)

// Successfully written, increment counter.
deltaCount++;
/*
#ifdef _DEBUG
if(delta->state == DELTA_UNACKED)
{
Con_Printf("Resend: %i, type%i[%x], set%i, rsid%i\n",
delta->id, delta->type, delta->flags,
delta->set, delta->resend);
}
#endif
*/

// Update the sent delta's state.
if(delta->state == DELTA_NEW)
{
Expand Down
5 changes: 0 additions & 5 deletions doomsday/server/src/server/sv_pool.cpp
Expand Up @@ -2082,11 +2082,6 @@ void Sv_NewNullDeltas(cregister_t *reg, boolean doUpdate, pool_t **targets)

Sv_AddDeltaToPools(&null, targets);

/*#ifdef _DEBUG
Con_Printf("New null: %i, %s\n", obj->mo.thinker.id,
defs.states[obj->mo.state - states].id);
#endif */

if(doUpdate)
{
// Keep the register up to date.
Expand Down

0 comments on commit bbd9376

Please sign in to comment.