Skip to content

Commit

Permalink
Cleanup|Network|Client: Log levels and domains (continued)
Browse files Browse the repository at this point in the history
Also converted some Con_Message() calls to use LOG.
  • Loading branch information
skyjake committed Jan 9, 2014
1 parent 0a1166b commit 9d05452
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 302 deletions.
129 changes: 5 additions & 124 deletions doomsday/client/src/client/cl_frame.cpp
Expand Up @@ -132,93 +132,6 @@ float Cl_FrameGameTime(void)
return frameGameTime;
}

#if 0
/**
* Add a set number to the history.
*/
void Cl_HistoryAdd(byte set)
{
setHistory[historyIdx++] = set;

if(historyIdx >= SET_HISTORY_SIZE)
historyIdx -= SET_HISTORY_SIZE;
}

/**
* @return @c true, if the set is found in the recent set
* history.
*/
boolean Cl_HistoryCheck(byte set)
{
uint i;

for(i = 0; i < SET_HISTORY_SIZE; ++i)
{
if(setHistory[i] == set)
return true;
}
return false;
}

/**
* Add a resend ID number to the resend history.
*/
void Cl_ResendHistoryAdd(byte id)
{
resendHistory[resendHistoryIdx++] = id;

if(resendHistoryIdx >= RESEND_HISTORY_SIZE)
resendHistoryIdx -= RESEND_HISTORY_SIZE;
}

/**
* @return @c true, if the resend ID is found in the history.
*/
boolean Cl_ResendHistoryCheck(byte id)
{
uint i;

for(i = 0; i < RESEND_HISTORY_SIZE; ++i)
{
if(resendHistory[i] == id)
return true;
}
return false;
}

/**
* Converts a set identifier, which ranges from 0...255, into a logical
* ordinal. Checks for set identifier wraparounds and updates the set
* ordinal base accordingly.
*/
uint Cl_ConvertSetToOrdinal(byte set)
{
uint ordinal = 0;

if(latestSet > 185 && set < 70)
{
// We must conclude that wraparound has occured.
setOrdinalBase += 256;
#if _NETDEBUG
VERBOSE2( Con_Printf("Cl_ConvertSetToOrdinal: Wraparound, now base is %i.\n",
setOrdinalBase) );
#endif
}
ordinal = set + setOrdinalBase;

if(latestSet < 35 && set > 220)
{
// This is most likely a set that came in before wraparound.
ordinal -= 256;
}
else
{
latestSet = set;
}
return ordinal;
}
#endif

/**
* Read a PSV_FRAME2/PSV_FIRST_FRAME2 packet.
*/
Expand Down Expand Up @@ -248,44 +161,13 @@ void Cl_Frame2Received(int packetType)
return;
}

/*
#ifdef _DEBUG
VERBOSE2( Con_Printf("Cl_Frame2Received: Processing delta set %i.\n", set) );
#endif
*/

#if 0
if(packetType != PSV_FIRST_FRAME2)
{
// If this is not the first frame, it will be ignored if it arrives
// out of order.
uint ordinal = Cl_ConvertSetToOrdinal(set);

if(ordinal < latestSetOrdinal)
{
VERBOSE2( Con_Printf("==> Ignored set %i because it arrived out of order.\n",
set) );
return;
}
latestSetOrdinal = ordinal;

VERBOSE2( Con_Printf("Latest set ordinal is %i.\n", latestSetOrdinal) );
}
#endif

{
//VERBOSE2( Con_Printf("Starting to process deltas in set %i.\n", set) );

// Read and process the message.
while(!Reader_AtEnd(msgReader))
{
deltaType = Reader_ReadByte(msgReader);
skip = false;
/*
#ifdef _DEBUG
Con_Message("Received delta %i.", deltaType);
#endif
*/

switch(deltaType)
{
case DT_CREATE_MOBJ:
Expand Down Expand Up @@ -329,17 +211,16 @@ void Cl_Frame2Received(int packetType)
break;

default:
Con_Error("Cl_Frame2Received: Unknown delta type %i (numtypes=%i; message size %i).\n",
deltaType, NUM_DELTA_TYPES, netBuffer.length);
LOG_NET_ERROR("Received unknown delta type %i (message size: %i bytes)")
<< deltaType << netBuffer.length;
return;
}
}

#ifdef _DEBUG
if(!gotFrame)
{
Con_Message("Cl_Frame2Received: First frame received.");
LOGDEV_NET_NOTE("First frame received");
}
#endif

// We have now received a frame.
gotFrame = true;
Expand Down
10 changes: 4 additions & 6 deletions doomsday/client/src/client/cl_infine.cpp
Expand Up @@ -43,6 +43,8 @@ void Cl_Finale(Reader* msg)
int len;
finaleid_t finaleId = Reader_ReadUInt32(msg);

LOG_AS("Cl_Finale");

if(flags & FINF_SCRIPT)
{
// Read the script into map-scope memory. It will be freed
Expand All @@ -58,9 +60,7 @@ void Cl_Finale(Reader* msg)
// Start the script.
currentFinale = FI_Execute((const char*)script, FF_LOCAL);
remoteFinale = finaleId;
#ifdef _DEBUG
Con_Message("Cl_Finale: Started finale %i (remote id %i).", currentFinale, remoteFinale);
#endif
LOGDEV_NET_MSG("Started finale %i (remote id %i)") << currentFinale << remoteFinale;
}

/// @todo Wouldn't hurt to make sure that the server is talking about the
Expand Down Expand Up @@ -89,9 +89,7 @@ void Cl_RequestFinaleSkip(void)
Writer_WriteUInt16(msgWriter, 1); // skip
Msg_End();

#ifdef _DEBUG
Con_Message("Cl_RequestFinaleSkip: Requesting skip on finale %i.", remoteFinale);
#endif
LOGDEV_NET_MSG("Requesting skip on finale %i") << remoteFinale;

Net_SendBuffer(0, 0);
}
45 changes: 22 additions & 23 deletions doomsday/client/src/client/cl_main.cpp
Expand Up @@ -51,7 +51,7 @@ void Cl_InitID(void)
if((i = CommandLine_CheckWith("-id", 1)) != 0)
{
clientID = strtoul(CommandLine_At(i + 1), 0, 0);
Con_Message("Cl_InitID: Using custom id 0x%08x.", clientID);
LOG_NET_NOTE("Using custom client ID: 0x%08x") << clientID;
return;
}

Expand Down Expand Up @@ -86,7 +86,7 @@ int Cl_GameReady(void)

void Cl_CleanUp()
{
Con_Printf("Cl_CleanUp.\n");
LOG_NET_MSG("Cleaning up client state");

clientPaused = false;
handshakeReceived = false;
Expand All @@ -104,16 +104,16 @@ void Cl_CleanUp()

void Cl_SendHello()
{
LOG_AS("Cl_SendHello");

Msg_Begin(PCL_HELLO2);
Writer_WriteUInt32(msgWriter, clientID);

// The game mode is included in the hello packet.
char buf[256]; zap(buf);
strncpy(buf, App_CurrentGame().identityKey().toUtf8().constData(), sizeof(buf) - 1);

#ifdef _DEBUG
Con_Message("Cl_SendHello: game mode = %s", buf);
#endif
LOGDEV_NET_VERBOSE("game mode = %s") << buf;

Writer_Write(msgWriter, buf, 16);
Msg_End();
Expand All @@ -129,6 +129,8 @@ void Cl_AnswerHandshake(void)
float remoteGameTime = Reader_ReadFloat(msgReader);
int i;

LOG_AS("Cl_AnswerHandshake");

// Immediately send an acknowledgement. This lets the server evaluate
// an approximate ping time.
Msg_Begin(PCL_ACK_SHAKE);
Expand All @@ -138,8 +140,8 @@ void Cl_AnswerHandshake(void)
// Check the version number.
if(remoteVersion != SV_VERSION)
{
Con_Message("Cl_AnswerHandshake: Version conflict! (you:%i, server:%i)",
SV_VERSION, remoteVersion);
LOG_NET_ERROR("Version conflict! (you:%i, server:%i)")
<< SV_VERSION << remoteVersion;
Con_Execute(CMDS_DDAY, "net disconnect", false, false);
Demo_StopPlayback();
Con_Open(true);
Expand Down Expand Up @@ -179,8 +181,8 @@ void Cl_AnswerHandshake(void)
gameReady = false;
Cl_InitFrame();

Con_Message("Cl_AnswerHandshake: myConsole:%i, remoteGameTime:%f.",
myConsole, remoteGameTime);
LOGDEV_NET_MSG("Answering handshake: myConsole:%i, remoteGameTime:%.2f")
<< myConsole << remoteGameTime;

/**
* Tell the game that we have arrived. The map will be changed when the
Expand Down Expand Up @@ -210,9 +212,7 @@ void Cl_HandlePlayerInfo(void)
memset(name, 0, sizeof(name));
Reader_Read(msgReader, name, len);

#ifdef _DEBUG
Con_Message("Cl_HandlePlayerInfo: console:%i name:%s", console, name);
#endif
LOG_NET_VERBOSE("Player %i named \"%s\"") << console << name;

// Is the console number valid?
if(console >= DDMAXPLAYERS)
Expand All @@ -235,7 +235,7 @@ void Cl_HandlePlayerInfo(void)

void Cl_PlayerLeaves(int plrNum)
{
Con_Printf("Cl_PlayerLeaves: player %i has left.\n", plrNum);
LOG_NET_NOTE("Player %i has left the game") << plrNum;
ddPlayers[plrNum].shared.inGame = false;
gx.NetPlayerEvent(plrNum, DDPE_EXIT, 0);
}
Expand Down Expand Up @@ -299,7 +299,7 @@ void Cl_GetPackets(void)
// The server updates our time. Latency has been taken into
// account, so...
gameTime = Reader_ReadFloat(msgReader);
Con_Printf("PSV_SYNC: gameTime=%.3f\n", gameTime);
LOGDEV_NET_VERBOSE("PSV_SYNC: gameTime=%.3f") << gameTime;
DD_ResetTimer();
break;

Expand Down Expand Up @@ -377,9 +377,7 @@ void Cl_GetPackets(void)
}
else
{
#ifdef _DEBUG
Con_Message("Cl_GetPackets: Packet (type %i) was discarded!", netBuffer.msg.type);
#endif
LOG_NET_WARNING("Packet was discarded (unknown type %i)") << netBuffer.msg.type;
}
}

Expand Down Expand Up @@ -407,27 +405,28 @@ void Cl_Assertions(int plrNum)
if(!s->clMobjId || !plr->shared.mo)
return;

LOG_AS("Cl_Assertions");

clmo = ClMobj_Find(s->clMobjId);
if(!clmo)
{
Con_Message("Cl_Assertions: client %i does not have a clmobj yet [%i].", plrNum, s->clMobjId);
LOGDEV_NET_NOTE("Client %i does not have a clmobj yet [%i]") << plrNum << s->clMobjId;
return;
}
mo = plr->shared.mo;

/*
Con_Message("Assert: client %i, clmo %i (flags 0x%x)",
plrNum, clmo->thinker.id, clmo->ddFlags);
*/
("Assert: client %i, clmo %i (flags 0x%x)", plrNum, clmo->thinker.id, clmo->ddFlags);
*/

// Make sure the flags are correctly set for a client.
if(mo->ddFlags & DDMF_REMOTE)
{
Con_Message("Cl_Assertions: client %i, mobj should not be remote!", plrNum);
LOGDEV_NET_NOTE("Client %i's mobj should not be remote") << plrNum;
}
if(clmo->ddFlags & DDMF_SOLID)
{
Con_Message("Cl_Assertions: client %i, clmobj should not be solid (when player is alive)!", plrNum);
LOGDEV_NET_NOTE("Client %i's clmobj should not be solid (when player is alive)") << plrNum;
}
}

Expand Down

0 comments on commit 9d05452

Please sign in to comment.