Skip to content

Commit

Permalink
Change debug level comparisons to >= for readability.
Browse files Browse the repository at this point in the history
(cherry picked from commit 29a72c5)
  • Loading branch information
skullernet authored and res2k committed Jan 2, 2025
1 parent 26ca8ce commit e0c584d
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 51 deletions.
10 changes: 5 additions & 5 deletions inc/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,19 @@ void Sys_Printf(const char *fmt, ...) q_printf(1, 2);
#if USE_DEBUG
#define COM_DEVELOPER (developer->integer)
#define Com_DPrintf(...) \
do { if (developer && developer->integer > 0) \
do { if (developer && developer->integer >= 1) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__); } while (0)
#define Com_DDPrintf(...) \
do { if (developer && developer->integer > 1) \
do { if (developer && developer->integer >= 2) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__); } while (0)
#define Com_DDDPrintf(...) \
do { if (developer && developer->integer > 2) \
do { if (developer && developer->integer >= 3) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__); } while (0)
#define Com_DDDDPrintf(...) \
do { if (developer && developer->integer > 3) \
do { if (developer && developer->integer >= 4) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__); } while (0)
#define Com_DWPrintf(...) \
do { if (developer && developer->integer > 0) \
do { if (developer && developer->integer >= 1) \
Com_LPrintf(PRINT_WARNING, __VA_ARGS__); } while (0)
#else
#define COM_DEVELOPER 0
Expand Down
4 changes: 2 additions & 2 deletions src/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,10 @@ extern cvar_t *cl_shadowlights;

#if USE_DEBUG
#define SHOWNET(level, ...) \
do { if (cl_shownet->integer > level) \
do { if (cl_shownet->integer >= level) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__); } while (0)
#define SHOWCLAMP(level, ...) \
do { if (cl_showclamp->integer > level) \
do { if (cl_showclamp->integer >= level) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__); } while (0)
#define SHOWMISS(...) \
do { if (cl_showmiss->integer) \
Expand Down
12 changes: 6 additions & 6 deletions src/client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2941,35 +2941,35 @@ static void CL_SetClientTime(void)

prevtime = cl.servertime - CL_FRAMETIME;
if (cl.time > cl.servertime) {
SHOWCLAMP(1, "high clamp %i\n", cl.time - cl.servertime);
SHOWCLAMP(2, "high clamp %i\n", cl.time - cl.servertime);
cl.time = cl.servertime;
cl.lerpfrac = 1.0f;
} else if (cl.time < prevtime) {
SHOWCLAMP(1, "low clamp %i\n", prevtime - cl.time);
SHOWCLAMP(2, "low clamp %i\n", prevtime - cl.time);
cl.time = prevtime;
cl.lerpfrac = 0;
} else {
cl.lerpfrac = (cl.time - prevtime) * CL_1_FRAMETIME;
}

SHOWCLAMP(2, "time %d %d, lerpfrac %.3f\n",
SHOWCLAMP(3, "time %d %d, lerpfrac %.3f\n",
cl.time, cl.servertime, cl.lerpfrac);

#if USE_FPS
prevtime = cl.keyservertime - BASE_FRAMETIME;
if (cl.keytime > cl.keyservertime) {
SHOWCLAMP(1, "high keyclamp %i\n", cl.keytime - cl.keyservertime);
SHOWCLAMP(2, "high keyclamp %i\n", cl.keytime - cl.keyservertime);
cl.keytime = cl.keyservertime;
cl.keylerpfrac = 1.0f;
} else if (cl.keytime < prevtime) {
SHOWCLAMP(1, "low keyclamp %i\n", prevtime - cl.keytime);
SHOWCLAMP(2, "low keyclamp %i\n", prevtime - cl.keytime);
cl.keytime = prevtime;
cl.keylerpfrac = 0;
} else {
cl.keylerpfrac = (cl.keytime - prevtime) * BASE_1_FRAMETIME;
}

SHOWCLAMP(2, "keytime %d %d keylerpfrac %.3f\n",
SHOWCLAMP(3, "keytime %d %d keylerpfrac %.3f\n",
cl.keytime, cl.keyservertime, cl.keylerpfrac);
#endif
}
Expand Down
26 changes: 13 additions & 13 deletions src/client/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void CL_ParsePacketEntities(const server_frame_t *oldframe, server_frame_

while (oldnum < newnum) {
// one or more entities from the old packet are unchanged
SHOWNET(3, " unchanged:%i\n", oldnum);
SHOWNET(4, " unchanged:%i\n", oldnum);
CL_ParseDeltaEntity(frame, oldnum, oldstate, NULL);

oldindex++;
Expand Down Expand Up @@ -235,7 +235,7 @@ static void CL_ParsePacketEntities(const server_frame_t *oldframe, server_frame_
// any remaining entities in the old frame are copied over
while (oldnum != MAX_EDICTS) {
// one or more entities from the old packet are unchanged
SHOWNET(3, " unchanged:%i\n", oldnum);
SHOWNET(4, " unchanged:%i\n", oldnum);
CL_ParseDeltaEntity(frame, oldnum, oldstate, NULL);

oldindex++;
Expand Down Expand Up @@ -465,7 +465,7 @@ static void CL_ParseFrame(const q2proto_svc_frame_t *frame_msg)

apply_playerfog_change(&fog_change);

SHOWNET(2, "%3u:packetentities\n", msg_read.readcount);
SHOWNET(3, "%3u:packetentities\n", msg_read.readcount);

// parse packetentities
CL_ParsePacketEntities(oldframe, &frame);
Expand All @@ -474,7 +474,7 @@ static void CL_ParseFrame(const q2proto_svc_frame_t *frame_msg)
cl.frames[currentframe & UPDATE_MASK] = frame;

#if USE_DEBUG
if (cl_shownet->integer > 2) {
if (cl_shownet->integer >= 3) {
int seq = cls.netchan.incoming_acknowledged & CMD_MASK;
int rtt = cls.demo.playback ? 0 : cls.realtime - cl.history[seq].sent;
Com_LPrintf(PRINT_DEVELOPER, "%3u:frame:%d delta:%d rtt:%d\n",
Expand Down Expand Up @@ -535,7 +535,7 @@ static void CL_ParseConfigstring(const q2proto_svc_configstring_t *configstring)
maxlen = Com_ConfigstringSize(&cl.csr, configstring->index);
q2pslcpy(s, maxlen, &configstring->value);

SHOWNET(2, " %d \"%s\"\n", configstring->index, Com_MakePrintable(configstring->value.str));
SHOWNET(3, " %d \"%s\"\n", configstring->index, Com_MakePrintable(configstring->value.str));

if (configstring->value.len >= maxlen) {
Com_WPrintf(
Expand Down Expand Up @@ -863,7 +863,7 @@ static void CL_ParseStartSoundPacket(const q2proto_svc_sound_t* sound)
Com_Error(ERR_DROP, "%s: bad index: %d", __func__, snd.index);
if (snd.entity >= cl.csr.max_edicts)
Com_Error(ERR_DROP, "%s: bad entity: %d", __func__, snd.entity);
SHOWNET(2, " %s\n", cl.configstrings[cl.csr.sounds + snd.index]);
SHOWNET(3, " %s\n", cl.configstrings[cl.csr.sounds + snd.index]);
}

static void CL_ParseReconnect(void)
Expand Down Expand Up @@ -1030,7 +1030,7 @@ static void CL_ParseCenterPrint(const q2proto_svc_centerprint_t *centerprint)

q2pslcpy(s, sizeof(s), &centerprint->message);

SHOWNET(2, " \"%s\"\n", Com_MakePrintable(s));
SHOWNET(3, " \"%s\"\n", Com_MakePrintable(s));
cgame->ParseCenterPrint(s, 0, false);

if (!cls.demo.playback && cl.serverstate != ss_broadcast) {
Expand All @@ -1044,14 +1044,14 @@ static void CL_ParseStuffText(const q2proto_svc_stufftext_t *stufftext)
char s[MAX_STRING_CHARS];

q2pslcpy(s, sizeof(s), &stufftext->string);
SHOWNET(2, " \"%s\"\n", Com_MakePrintable(s));
SHOWNET(3, " \"%s\"\n", Com_MakePrintable(s));
Cbuf_AddText(&cl_cmdbuf, s);
}

static void CL_ParseLayout(const q2proto_svc_layout_t *layout)
{
q2pslcpy(cl.cgame_data.layout, sizeof(cl.cgame_data.layout), &layout->layout_str);
SHOWNET(2, " \"%s\"\n", Com_MakePrintable(cl.cgame_data.layout));
SHOWNET(3, " \"%s\"\n", Com_MakePrintable(cl.cgame_data.layout));
}

static void CL_ParseInventory(const q2proto_svc_inventory_t *inventory)
Expand Down Expand Up @@ -1244,7 +1244,7 @@ void CL_ParseServerMessage(void)
#if USE_DEBUG
if (cl_shownet->integer == 1) {
Com_LPrintf(PRINT_DEVELOPER, "%u ", msg_read.cursize);
} else if (cl_shownet->integer > 1) {
} else if (cl_shownet->integer >= 2) {
Com_LPrintf(PRINT_DEVELOPER, "------------------\n");
}
#endif
Expand All @@ -1260,7 +1260,7 @@ void CL_ParseServerMessage(void)
q2proto_svc_message_t svc_msg;
q2proto_error_t err = q2proto_client_read(&cls.q2proto_ctx, Q2PROTO_IOARG_CLIENT_READ, &svc_msg);
if (err == Q2P_ERR_NO_MORE_INPUT) {
SHOWNET(1, "%3u:END OF MESSAGE\n", readcount);
SHOWNET(2, "%3u:END OF MESSAGE\n", readcount);
break;
}

Expand Down Expand Up @@ -1407,7 +1407,7 @@ bool CL_SeekDemoMessage(void)
#if USE_DEBUG
if (cl_shownet->integer == 1) {
Com_LPrintf(PRINT_DEVELOPER, "%u ", msg_read.cursize);
} else if (cl_shownet->integer > 1) {
} else if (cl_shownet->integer >= 2) {
Com_LPrintf(PRINT_DEVELOPER, "------------------\n");
}
#endif
Expand All @@ -1421,7 +1421,7 @@ bool CL_SeekDemoMessage(void)
q2proto_svc_message_t svc_msg;
q2proto_error_t err = q2proto_client_read(&cls.q2proto_ctx, Q2PROTO_IOARG_CLIENT_READ, &svc_msg);
if (err == Q2P_ERR_NO_MORE_INPUT) {
SHOWNET(1, "%3u:END OF MESSAGE\n", msg_read.readcount);
SHOWNET(2, "%3u:END OF MESSAGE\n", msg_read.readcount);
break;
}
switch(svc_msg.type)
Expand Down
2 changes: 1 addition & 1 deletion src/server/entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static bool SV_TruncPacketEntities(client_t *client, const client_frame_t *from,
if (!sv_trunc_packet_entities->integer || client->netchan.type)
return false;

SV_DPrintf(0, "Truncating frame %d at %u bytes for %s\n",
SV_DPrintf(1, "Truncating frame %d at %u bytes for %s\n",
client->framenum, msg_write.cursize, client->name);

if (!from)
Expand Down
28 changes: 14 additions & 14 deletions src/server/mvd/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static bool match_ended_hack;

#if USE_DEBUG
#define SHOWNET(level, ...) \
do { if (mvd_shownet->integer > level) \
do { if (mvd_shownet->integer >= level) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__); } while (0)

static const char *MVD_ServerCommandString(int cmd)
Expand Down Expand Up @@ -371,7 +371,7 @@ static void MVD_ParseUnicast(mvd_t *mvd, bool reliable, int extrabits)
while (msg_read.readcount < last) {
cmd = MSG_ReadByte();

SHOWNET(1, "%3u:%s\n", msg_read.readcount - 1, MSG_ServerCommandString(cmd, PROTOCOL_VERSION_MVD));
SHOWNET(2, "%3u:%s\n", msg_read.readcount - 1, MSG_ServerCommandString(cmd, PROTOCOL_VERSION_MVD));

switch (cmd) {
case svc_layout:
Expand All @@ -387,7 +387,7 @@ static void MVD_ParseUnicast(mvd_t *mvd, bool reliable, int extrabits)
MVD_UnicastStuff(mvd, reliable, player);
break;
default:
SHOWNET(1, "%3u:SKIPPING UNICAST\n", msg_read.readcount - 1);
SHOWNET(2, "%3u:SKIPPING UNICAST\n", msg_read.readcount - 1);
// send remaining data and return
data = msg_read.data + msg_read.readcount - 1;
length = last - msg_read.readcount + 1;
Expand All @@ -398,7 +398,7 @@ static void MVD_ParseUnicast(mvd_t *mvd, bool reliable, int extrabits)
}
}

SHOWNET(1, "%3u:END OF UNICAST\n", msg_read.readcount);
SHOWNET(2, "%3u:END OF UNICAST\n", msg_read.readcount);

if (msg_read.readcount > last) {
MVD_Destroyf(mvd, "%s: read past end of unicast", __func__);
Expand Down Expand Up @@ -657,7 +657,7 @@ static void MVD_ParsePacketEntities(mvd_t *mvd)
ent = &mvd->edicts[number];

#if USE_DEBUG
if (mvd_shownet->integer > 2) {
if (mvd_shownet->integer >= 3) {
Com_LPrintf(PRINT_DEVELOPER, "%3u:%s:%d ", readcount,
ent->inuse ? "delta" : "baseline", number);
MSG_ShowDeltaEntityBits(bits);
Expand All @@ -677,7 +677,7 @@ static void MVD_ParsePacketEntities(mvd_t *mvd)

// shuffle current origin to old if removed
if (bits & U_REMOVE) {
SHOWNET(2, "%3u:remove:%d\n", readcount, number);
SHOWNET(3, "%3u:remove:%d\n", readcount, number);
if (!(ent->s.renderfx & RF_BEAM)) {
VectorCopy(ent->s.origin, ent->s.old_origin);
}
Expand Down Expand Up @@ -731,7 +731,7 @@ static void MVD_ParsePacketPlayers(mvd_t *mvd)
}

#if USE_DEBUG
if (mvd_shownet->integer > 2) {
if (mvd_shownet->integer >= 3) {
Com_LPrintf(PRINT_DEVELOPER, "%3u:%s:%d ", readcount,
player->inuse ? "delta" : "baseline", number);
MSG_ShowDeltaPlayerstateBits_Packet(bits);
Expand All @@ -743,7 +743,7 @@ static void MVD_ParsePacketPlayers(mvd_t *mvd)
MSG_ParseDeltaPlayerstate_Packet(&player->ps, &fog_change, bits, mvd->psFlags);

if (bits & PPS_REMOVE) {
SHOWNET(2, "%3u:remove:%d\n", readcount, number);
SHOWNET(3, "%3u:remove:%d\n", readcount, number);
player->inuse = false;
continue;
}
Expand Down Expand Up @@ -771,11 +771,11 @@ static void MVD_ParseFrame(mvd_t *mvd)
if (!mvd->demoseeking)
CM_SetPortalStates(&mvd->cm, data, length);

SHOWNET(1, "%3u:playerinfo\n", msg_read.readcount);
SHOWNET(2, "%3u:playerinfo\n", msg_read.readcount);
MVD_ParsePacketPlayers(mvd);
SHOWNET(1, "%3u:packetentities\n", msg_read.readcount);
SHOWNET(2, "%3u:packetentities\n", msg_read.readcount);
MVD_ParsePacketEntities(mvd);
SHOWNET(1, "%3u:frame:%u\n", msg_read.readcount, mvd->framenum);
SHOWNET(2, "%3u:frame:%u\n", msg_read.readcount, mvd->framenum);
MVD_PlayerToEntityStates(mvd);

// update clients now so that effects datagram that
Expand Down Expand Up @@ -1071,7 +1071,7 @@ bool MVD_ParseMessage(mvd_t *mvd)
#if USE_DEBUG
if (mvd_shownet->integer == 1) {
Com_LPrintf(PRINT_DEVELOPER, "%u ", msg_read.cursize);
} else if (mvd_shownet->integer > 1) {
} else if (mvd_shownet->integer >= 2) {
Com_LPrintf(PRINT_DEVELOPER, "------------------\n");
}
#endif
Expand All @@ -1085,15 +1085,15 @@ bool MVD_ParseMessage(mvd_t *mvd)
MVD_Destroyf(mvd, "Read past end of message");
}
if (msg_read.readcount == msg_read.cursize) {
SHOWNET(1, "%3u:END OF MESSAGE\n", msg_read.readcount);
SHOWNET(2, "%3u:END OF MESSAGE\n", msg_read.readcount);
break;
}

cmd = MSG_ReadByte();
extrabits = cmd >> SVCMD_BITS;
cmd &= SVCMD_MASK;

SHOWNET(1, "%3u:%s\n", msg_read.readcount - 1, MVD_ServerCommandString(cmd));
SHOWNET(2, "%3u:%s\n", msg_read.readcount - 1, MVD_ServerCommandString(cmd));

switch (cmd) {
case mvd_serverdata:
Expand Down
18 changes: 9 additions & 9 deletions src/server/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static bool SV_RateDrop(client_t *client)
#endif

if (total > client->rate) {
SV_DPrintf(0, "Frame %d suppressed for %s (total = %zu)\n",
SV_DPrintf(1, "Frame %d suppressed for %s (total = %zu)\n",
client->framenum, client->name, total);
client->frameflags |= FF_SUPPRESSED;
client->suppress_count++;
Expand Down Expand Up @@ -376,11 +376,11 @@ void SV_ClientAddMessage(client_t *client, int flags)

if (compress && (len = compress_message(client)) && len < msg_write.cursize) {
client->AddMessage(client, get_compressed_data(), len, flags & MSG_RELIABLE);
SV_DPrintf(0, "Compressed %sreliable message to %s: %u into %d\n",
SV_DPrintf(1, "Compressed %sreliable message to %s: %u into %d\n",
(flags & MSG_RELIABLE) ? "" : "un", client->name, msg_write.cursize, len);
} else {
client->AddMessage(client, msg_write.data, msg_write.cursize, flags & MSG_RELIABLE);
SV_DPrintf(1, "Added %sreliable message to %s: %u bytes\n",
SV_DPrintf(2, "Added %sreliable message to %s: %u bytes\n",
(flags & MSG_RELIABLE) ? "" : "un", client->name, msg_write.cursize);
}

Expand Down Expand Up @@ -512,7 +512,7 @@ static void emit_snd(client_t *client, const message_packet_t *msg)

// check if position needs to be explicitly sent
if (!(flags & SND_POS) && !check_entity(client, entnum)) {
SV_DPrintf(1, "Forcing position on entity %d for %s\n",
SV_DPrintf(2, "Forcing position on entity %d for %s\n",
entnum, client->name);
flags |= SND_POS; // entity is not present in frame
}
Expand Down Expand Up @@ -584,7 +584,7 @@ static void write_reliables_old(client_t *client, unsigned maxsize)
int count;

if (client->netchan.reliable_length) {
SV_DPrintf(1, "%s to %s: unacked\n", __func__, client->name);
SV_DPrintf(2, "%s to %s: unacked\n", __func__, client->name);
return; // there is still outgoing reliable message pending
}

Expand All @@ -601,7 +601,7 @@ static void write_reliables_old(client_t *client, unsigned maxsize)
break;
}

SV_DPrintf(1, "%s to %s: writing msg %d: %d bytes\n",
SV_DPrintf(2, "%s to %s: writing msg %d: %d bytes\n",
__func__, client->name, count, msg->cursize);

SZ_Write(&client->netchan.message, msg->data, msg->cursize);
Expand Down Expand Up @@ -690,7 +690,7 @@ static void write_datagram_old(client_t *client)
// send over all the relevant entity_state_t
// and the player_state_t
if (!client->WriteFrame(client, maxsize)) {
SV_DPrintf(0, "Frame %d overflowed for %s\n", client->framenum, client->name);
SV_DPrintf(1, "Frame %d overflowed for %s\n", client->framenum, client->name);
SZ_Clear(&msg_write);
}

Expand Down Expand Up @@ -962,7 +962,7 @@ void SV_SendAsyncPackets(void)
// make sure all fragments are transmitted first
if (netchan->fragment_pending) {
cursize = Netchan_TransmitNextFragment(netchan);
SV_DPrintf(1, "%s: frag: %d\n", client->name, cursize);
SV_DPrintf(2, "%s: frag: %d\n", client->name, cursize);
goto calctime;
}

Expand Down Expand Up @@ -990,7 +990,7 @@ void SV_SendAsyncPackets(void)
if (netchan->message.cursize || netchan->reliable_ack_pending ||
netchan->reliable_length || retransmit) {
cursize = Netchan_Transmit(netchan, 0, NULL, 1);
SV_DPrintf(1, "%s: send: %d\n", client->name, cursize);
SV_DPrintf(2, "%s: send: %d\n", client->name, cursize);
calctime:
SV_CalcSendTime(client, cursize);
}
Expand Down
Loading

0 comments on commit e0c584d

Please sign in to comment.