Big net::msg conversion

This commit is contained in:
iikorni
2026-08-30 12:38:12 -05:00
parent 216dd1aecd
commit df2b863d72
36 changed files with 2860 additions and 2764 deletions
+137 -141
View File
@@ -148,32 +148,32 @@ void CL_ParseStartSoundPacket(void) {
float attenuation;
int i;
field_mask = MSG_ReadByte();
field_mask = net_message.read_byte().value();
if (field_mask & SND_VOLUME)
volume = MSG_ReadByte();
volume = net_message.read_byte().value();
else
volume = DEFAULT_SOUND_PACKET_VOLUME;
if (field_mask & SND_ATTENUATION)
attenuation = MSG_ReadByte() / 64.0;
attenuation = net_message.read_byte().value() / 64.0;
else
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
//johnfitz -- PROTOCOL_FITZQUAKE
if (field_mask & SND_LARGEENTITY) {
ent = (unsigned short) MSG_ReadShort();
channel = MSG_ReadByte();
ent = (unsigned short) net_message.read_short().value();
channel = net_message.read_byte().value();
} else {
channel = (unsigned short) MSG_ReadShort();
channel = (unsigned short) net_message.read_short().value();
ent = channel >> 3;
channel &= 7;
}
if (field_mask & SND_LARGESOUND)
sound_num = (unsigned short) MSG_ReadShort();
sound_num = (unsigned short) net_message.read_short().value();
else
sound_num = MSG_ReadByte();
sound_num = net_message.read_byte().value();
//johnfitz
//johnfitz -- check soundnum
@@ -185,7 +185,7 @@ void CL_ParseStartSoundPacket(void) {
Host_Error("CL_ParseStartSoundPacket: ent = %i", ent);
for (i = 0; i < 3; i++)
pos[i] = MSG_ReadCoord(cl.protocolflags);
pos[i] = net_message.read_coord(static_cast<net::rmq_flags>(cl.protocolflags)).value();
S_StartSound(ent, channel, cl.sound_precache[sound_num], pos, volume / 255.0, attenuation);
}
@@ -198,8 +198,8 @@ CL_ParseLocalSound - for 2021 rerelease
void CL_ParseLocalSound(void) {
int field_mask, sound_num;
field_mask = MSG_ReadByte();
sound_num = (field_mask & SND_LARGESOUND) ? MSG_ReadShort() : MSG_ReadByte();
field_mask = net_message.read_byte().value();
sound_num = (field_mask & SND_LARGESOUND) ? net_message.read_short().value() : net_message.read_byte().value();
if (sound_num >= MAX_SOUNDS)
Host_Error("CL_ParseLocalSound: %i > MAX_SOUNDS", sound_num);
@@ -220,8 +220,6 @@ void CL_KeepaliveMessage(void) {
float time;
static float lastmsg;
int ret;
sizebuf_t old;
byte *olddata;
if (sv.active)
return; // no need if server is local
@@ -229,9 +227,7 @@ void CL_KeepaliveMessage(void) {
return;
// read messages from server, should just be nops
olddata = net_olddata;
old = net_message;
memcpy(olddata, net_message.data, net_message.cursize);
auto old = net_message;
do {
ret = CL_GetMessage();
@@ -244,14 +240,13 @@ void CL_KeepaliveMessage(void) {
Host_Error("CL_KeepaliveMessage: received a message");
break;
case 2:
if (MSG_ReadByte() != svc_nop)
if (net_message.read_byte().value() != svc_nop)
Host_Error("CL_KeepaliveMessage: datagram wasn't a nop");
break;
}
} while (ret);
net_message = old;
memcpy(net_message.data, olddata, net_message.cursize);
// check time
time = Sys_DoubleTime();
@@ -262,9 +257,9 @@ void CL_KeepaliveMessage(void) {
// write out a nop
console::info("--> client to server keepalive\n");
MSG_WriteByte(&cls.message, clc_nop);
NET_SendMessage(cls.netcon, &cls.message);
SZ_Clear(&cls.message);
cls.message.write_byte(clc_nop);
NET_SendMessage(cls.netcon, cls.message);
cls.message.clear();
}
/*
@@ -273,7 +268,6 @@ CL_ParseServerInfo
==================
*/
void CL_ParseServerInfo(void) {
const char *str;
int i;
int nummodels, numsounds;
char model_precache[MAX_MODELS][MAX_QPATH];
@@ -292,7 +286,7 @@ void CL_ParseServerInfo(void) {
CL_ClearState();
// parse protocol version number
i = MSG_ReadLong();
i = net_message.read_long().value();
//johnfitz -- support multiple protocols
if (i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE && i != PROTOCOL_RMQ) {
console::info("\n"); //because there's no newline after serverinfo print
@@ -307,7 +301,7 @@ void CL_ParseServerInfo(void) {
PRFL_SHORTANGLE | PRFL_FLOATANGLE | PRFL_24BITCOORD | PRFL_FLOATCOORD | PRFL_EDICTSCALE | PRFL_INT32COORD);
// mh - read protocol flags from server so that we know what protocol features to expect
cl.protocolflags = (unsigned int) MSG_ReadLong();
cl.protocolflags = (unsigned int) net_message.read_long().value();
if (0 != (cl.protocolflags & (~supportedflags))) {
console::warn("PROTOCOL_RMQ protocolflags %i contains unsupported flags\n", cl.protocolflags);
@@ -315,22 +309,22 @@ void CL_ParseServerInfo(void) {
} else cl.protocolflags = 0;
// parse maxclients
cl.maxclients = MSG_ReadByte();
cl.maxclients = net_message.read_byte().value();
if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD) {
Host_Error("Bad maxclients (%u) from server", cl.maxclients);
}
cl.scores = (scoreboard_t *) Hunk_AllocName(cl.maxclients * sizeof(*cl.scores), "scores");
// parse gametype
cl.gametype = MSG_ReadByte();
cl.gametype = net_message.read_byte().value();
// parse signon message
str = MSG_ReadString();
std::strncpy(cl.levelname, str, sizeof(cl.levelname));
auto str = net_message.read_string().value();
std::strncpy(cl.levelname, str.c_str(), sizeof(cl.levelname));
// seperate the printfs so the server message can have a color
console::info("\n%s\n", Con_Quakebar(40)); //johnfitz
console::info("%c%s\n", 2, str);
console::info("%c%s\n", 2, str.c_str());
//johnfitz -- tell user which protocol this is
console::info("Using protocol %i\n", i);
@@ -342,14 +336,14 @@ void CL_ParseServerInfo(void) {
// precache models
memset(cl.model_precache, 0, sizeof(cl.model_precache));
for (nummodels = 1; ; nummodels++) {
str = MSG_ReadString();
str = net_message.read_string().value();
if (!str[0])
break;
if (nummodels == MAX_MODELS) {
Host_Error("Server sent too many model precaches");
}
std::strncpy(model_precache[nummodels], str, MAX_QPATH);
Mod_TouchModel(str);
std::strncpy(model_precache[nummodels], str.c_str(), MAX_QPATH);
Mod_TouchModel(str.c_str());
}
//johnfitz -- check for excessive models
@@ -360,14 +354,14 @@ void CL_ParseServerInfo(void) {
// precache sounds
memset(cl.sound_precache, 0, sizeof(cl.sound_precache));
for (numsounds = 1; ; numsounds++) {
str = MSG_ReadString();
str = net_message.read_string().value();
if (!str[0])
break;
if (numsounds == MAX_SOUNDS) {
Host_Error("Server sent too many sound precaches");
}
std::strncpy(sound_precache[numsounds], str, MAX_QPATH);
S_TouchSound(str);
std::strncpy(sound_precache[numsounds], str.c_str(), MAX_QPATH);
S_TouchSound(str.c_str());
}
//johnfitz -- check for excessive sounds
@@ -404,7 +398,7 @@ void CL_ParseServerInfo(void) {
//johnfitz -- clear out string; we don't consider identical
//messages to be duplicates if the map has changed in between
con_lastcenterstring[0] = 0;
console::last_center_string.clear();
//johnfitz
Hunk_Check(); // make sure nothing is hurt
@@ -444,23 +438,23 @@ void CL_ParseUpdate(int bits) {
}
if (bits & U_MOREBITS) {
i = MSG_ReadByte();
i = net_message.read_byte().value();
bits |= (i << 8);
}
//johnfitz -- PROTOCOL_FITZQUAKE
if (cl.protocol == PROTOCOL_FITZQUAKE || cl.protocol == PROTOCOL_RMQ) {
if (bits & U_EXTEND1)
bits |= MSG_ReadByte() << 16;
bits |= net_message.read_byte().value() << 16;
if (bits & U_EXTEND2)
bits |= MSG_ReadByte() << 24;
bits |= net_message.read_byte().value() << 24;
}
//johnfitz
if (bits & U_LONGENTITY)
num = MSG_ReadShort();
num = net_message.read_short().value();
else
num = MSG_ReadByte();
num = net_message.read_byte().value();
ent = CL_EntityNum(num);
@@ -478,19 +472,19 @@ void CL_ParseUpdate(int bits) {
ent->msgtime = cl.mtime[0];
if (bits & U_MODEL) {
modnum = MSG_ReadByte();
modnum = net_message.read_byte().value();
if (modnum >= MAX_MODELS)
Host_Error("CL_ParseModel: bad modnum");
} else
modnum = ent->baseline.modelindex;
if (bits & U_FRAME)
ent->frame = MSG_ReadByte();
ent->frame = net_message.read_byte().value();
else
ent->frame = ent->baseline.frame;
if (bits & U_COLORMAP)
i = MSG_ReadByte();
i = net_message.read_byte().value();
else
i = ent->baseline.colormap;
if (!i)
@@ -501,7 +495,7 @@ void CL_ParseUpdate(int bits) {
ent->colormap = cl.scores[i - 1].translations;
}
if (bits & U_SKIN)
skin = MSG_ReadByte();
skin = net_message.read_byte().value();
else
skin = ent->baseline.skin;
if (skin != ent->skinnum) {
@@ -510,7 +504,7 @@ void CL_ParseUpdate(int bits) {
R_TranslateNewPlayerSkin(num - 1); //johnfitz -- was R_TranslatePlayerSkin
}
if (bits & U_EFFECTS)
ent->effects = MSG_ReadByte();
ent->effects = net_message.read_byte().value();
else
ent->effects = ent->baseline.effects;
@@ -519,29 +513,29 @@ void CL_ParseUpdate(int bits) {
VectorCopy(ent->msg_angles[0], ent->msg_angles[1]);
if (bits & U_ORIGIN1)
ent->msg_origins[0][0] = MSG_ReadCoord(cl.protocolflags);
ent->msg_origins[0][0] = net_message.read_coord(static_cast<net::rmq_flags>(cl.protocolflags)).value();
else
ent->msg_origins[0][0] = ent->baseline.origin[0];
if (bits & U_ANGLE1)
ent->msg_angles[0][0] = MSG_ReadAngle(cl.protocolflags);
ent->msg_angles[0][0] = net_message.read_angle(static_cast<net::rmq_flags>(cl.protocolflags)).value();
else
ent->msg_angles[0][0] = ent->baseline.angles[0];
if (bits & U_ORIGIN2)
ent->msg_origins[0][1] = MSG_ReadCoord(cl.protocolflags);
ent->msg_origins[0][1] = net_message.read_coord(static_cast<net::rmq_flags>(cl.protocolflags)).value();
else
ent->msg_origins[0][1] = ent->baseline.origin[1];
if (bits & U_ANGLE2)
ent->msg_angles[0][1] = MSG_ReadAngle(cl.protocolflags);
ent->msg_angles[0][1] = net_message.read_angle(static_cast<net::rmq_flags>(cl.protocolflags)).value();
else
ent->msg_angles[0][1] = ent->baseline.angles[1];
if (bits & U_ORIGIN3)
ent->msg_origins[0][2] = MSG_ReadCoord(cl.protocolflags);
ent->msg_origins[0][2] = net_message.read_coord(static_cast<net::rmq_flags>(cl.protocolflags)).value();
else
ent->msg_origins[0][2] = ent->baseline.origin[2];
if (bits & U_ANGLE3)
ent->msg_angles[0][2] = MSG_ReadAngle(cl.protocolflags);
ent->msg_angles[0][2] = net_message.read_angle(static_cast<net::rmq_flags>(cl.protocolflags)).value();
else
ent->msg_angles[0][2] = ent->baseline.angles[2];
@@ -556,19 +550,19 @@ void CL_ParseUpdate(int bits) {
//johnfitz -- PROTOCOL_FITZQUAKE and PROTOCOL_NEHAHRA
if (cl.protocol == PROTOCOL_FITZQUAKE || cl.protocol == PROTOCOL_RMQ) {
if (bits & U_ALPHA)
ent->alpha = MSG_ReadByte();
ent->alpha = net_message.read_byte().value();
else
ent->alpha = ent->baseline.alpha;
if (bits & U_SCALE)
ent->scale = MSG_ReadByte();
ent->scale = net_message.read_byte().value();
else
ent->scale = ent->baseline.scale;
if (bits & U_FRAME2)
ent->frame = (ent->frame & 0x00FF) | (MSG_ReadByte() << 8);
ent->frame = (ent->frame & 0x00FF) | (net_message.read_byte().value() << 8);
if (bits & U_MODEL2)
modnum = (modnum & 0x00FF) | (MSG_ReadByte() << 8);
modnum = (modnum & 0x00FF) | (net_message.read_byte().value() << 8);
if (bits & U_LERPFINISH) {
ent->lerpfinish = ent->msgtime + ((float) (MSG_ReadByte()) / 255);
ent->lerpfinish = ent->msgtime + ((float) (net_message.read_byte().value()) / 255);
ent->lerpflags |= LERP_FINISH;
} else
ent->lerpflags &= ~LERP_FINISH;
@@ -582,10 +576,10 @@ void CL_ParseUpdate(int bits) {
warn_about_nehahra_protocol = false;
}
a = MSG_ReadFloat();
b = MSG_ReadFloat(); //alpha
a = net_message.read_float().value();
b = net_message.read_float().value(); //alpha
if (a == 2)
MSG_ReadFloat(); //fullbright (not using this yet)
net_message.read_float().value(); //fullbright (not using this yet)
ent->alpha = ENTALPHA_ENCODE(b);
} else
ent->alpha = ent->baseline.alpha;
@@ -634,20 +628,20 @@ void CL_ParseBaseline(entity_t *ent, int version) //johnfitz -- added argument
int bits; //johnfitz
//johnfitz -- PROTOCOL_FITZQUAKE
bits = (version == 2) ? MSG_ReadByte() : 0;
ent->baseline.modelindex = (bits & B_LARGEMODEL) ? MSG_ReadShort() : MSG_ReadByte();
ent->baseline.frame = (bits & B_LARGEFRAME) ? MSG_ReadShort() : MSG_ReadByte();
bits = (version == 2) ? net_message.read_byte().value() : 0;
ent->baseline.modelindex = (bits & B_LARGEMODEL) ? net_message.read_short().value() : net_message.read_byte().value();
ent->baseline.frame = (bits & B_LARGEFRAME) ? net_message.read_short().value() : net_message.read_byte().value();
//johnfitz
ent->baseline.colormap = MSG_ReadByte();
ent->baseline.skin = MSG_ReadByte();
ent->baseline.colormap = net_message.read_byte().value();
ent->baseline.skin = net_message.read_byte().value();
for (i = 0; i < 3; i++) {
ent->baseline.origin[i] = MSG_ReadCoord(cl.protocolflags);
ent->baseline.angles[i] = MSG_ReadAngle(cl.protocolflags);
ent->baseline.origin[i] = net_message.read_coord(static_cast<net::rmq_flags>(cl.protocolflags)).value();
ent->baseline.angles[i] = net_message.read_angle(static_cast<net::rmq_flags>(cl.protocolflags)).value();
}
ent->baseline.alpha = (bits & B_ALPHA) ? MSG_ReadByte() : ENTALPHA_DEFAULT; //johnfitz -- PROTOCOL_FITZQUAKE
ent->baseline.scale = (bits & B_SCALE) ? MSG_ReadByte() : ENTSCALE_DEFAULT;
ent->baseline.alpha = (bits & B_ALPHA) ? net_message.read_byte().value() : ENTALPHA_DEFAULT; //johnfitz -- PROTOCOL_FITZQUAKE
ent->baseline.scale = (bits & B_SCALE) ? net_message.read_byte().value() : ENTSCALE_DEFAULT;
}
@@ -662,34 +656,34 @@ void CL_ParseClientdata(void) {
int i, j;
int bits; //johnfitz
bits = (unsigned short) MSG_ReadShort(); //johnfitz -- read bits here isntead of in CL_ParseServerMessage()
bits = (unsigned short) net_message.read_short().value(); //johnfitz -- read bits here isntead of in CL_ParseServerMessage()
//johnfitz -- PROTOCOL_FITZQUAKE
if (bits & SU_EXTEND1)
bits |= (MSG_ReadByte() << 16);
bits |= (net_message.read_byte().value() << 16);
if (bits & SU_EXTEND2)
bits |= (MSG_ReadByte() << 24);
bits |= (net_message.read_byte().value() << 24);
//johnfitz
if (bits & SU_VIEWHEIGHT)
cl.viewheight = MSG_ReadChar();
cl.viewheight = net_message.read_char().value();
else
cl.viewheight = DEFAULT_VIEWHEIGHT;
if (bits & SU_IDEALPITCH)
cl.idealpitch = MSG_ReadChar();
cl.idealpitch = net_message.read_char().value();
else
cl.idealpitch = 0;
VectorCopy(cl.mvelocity[0], cl.mvelocity[1]);
for (i = 0; i < 3; i++) {
if (bits & (SU_PUNCH1 << i))
cl.punchangle[i] = MSG_ReadChar();
cl.punchangle[i] = net_message.read_char().value();
else
cl.punchangle[i] = 0;
if (bits & (SU_VELOCITY1 << i))
cl.mvelocity[0][i] = MSG_ReadChar() * 16;
cl.mvelocity[0][i] = net_message.read_char().value() * 16;
else
cl.mvelocity[0][i] = 0;
}
@@ -703,7 +697,7 @@ void CL_ParseClientdata(void) {
//johnfitz
// [always sent] if (bits & SU_ITEMS)
i = MSG_ReadLong();
i = net_message.read_long().value();
if (cl.items != i) {
// set flash times
@@ -718,12 +712,12 @@ void CL_ParseClientdata(void) {
cl.inwater = (bits & SU_INWATER) != 0;
if (bits & SU_WEAPONFRAME)
cl.stats[STAT_WEAPONFRAME] = MSG_ReadByte();
cl.stats[STAT_WEAPONFRAME] = net_message.read_byte().value();
else
cl.stats[STAT_WEAPONFRAME] = 0;
if (bits & SU_ARMOR)
i = MSG_ReadByte();
i = net_message.read_byte().value();
else
i = 0;
if (cl.stats[STAT_ARMOR] != i) {
@@ -732,7 +726,7 @@ void CL_ParseClientdata(void) {
}
if (bits & SU_WEAPON)
i = MSG_ReadByte();
i = net_message.read_byte().value();
else
i = 0;
if (cl.stats[STAT_WEAPON] != i) {
@@ -740,27 +734,27 @@ void CL_ParseClientdata(void) {
Sbar_Changed();
}
i = MSG_ReadShort();
i = net_message.read_short().value();
if (cl.stats[STAT_HEALTH] != i) {
cl.stats[STAT_HEALTH] = i;
Sbar_Changed();
}
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (cl.stats[STAT_AMMO] != i) {
cl.stats[STAT_AMMO] = i;
Sbar_Changed();
}
for (i = 0; i < 4; i++) {
j = MSG_ReadByte();
j = net_message.read_byte().value();
if (cl.stats[STAT_SHELLS + i] != j) {
cl.stats[STAT_SHELLS + i] = j;
Sbar_Changed();
}
}
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (standard_quake) {
if (cl.stats[STAT_ACTIVEWEAPON] != i) {
@@ -776,23 +770,23 @@ void CL_ParseClientdata(void) {
//johnfitz -- PROTOCOL_FITZQUAKE
if (bits & SU_WEAPON2)
cl.stats[STAT_WEAPON] |= (MSG_ReadByte() << 8);
cl.stats[STAT_WEAPON] |= (net_message.read_byte().value() << 8);
if (bits & SU_ARMOR2)
cl.stats[STAT_ARMOR] |= (MSG_ReadByte() << 8);
cl.stats[STAT_ARMOR] |= (net_message.read_byte().value() << 8);
if (bits & SU_AMMO2)
cl.stats[STAT_AMMO] |= (MSG_ReadByte() << 8);
cl.stats[STAT_AMMO] |= (net_message.read_byte().value() << 8);
if (bits & SU_SHELLS2)
cl.stats[STAT_SHELLS] |= (MSG_ReadByte() << 8);
cl.stats[STAT_SHELLS] |= (net_message.read_byte().value() << 8);
if (bits & SU_NAILS2)
cl.stats[STAT_NAILS] |= (MSG_ReadByte() << 8);
cl.stats[STAT_NAILS] |= (net_message.read_byte().value() << 8);
if (bits & SU_ROCKETS2)
cl.stats[STAT_ROCKETS] |= (MSG_ReadByte() << 8);
cl.stats[STAT_ROCKETS] |= (net_message.read_byte().value() << 8);
if (bits & SU_CELLS2)
cl.stats[STAT_CELLS] |= (MSG_ReadByte() << 8);
cl.stats[STAT_CELLS] |= (net_message.read_byte().value() << 8);
if (bits & SU_WEAPONFRAME2)
cl.stats[STAT_WEAPONFRAME] |= (MSG_ReadByte() << 8);
cl.stats[STAT_WEAPONFRAME] |= (net_message.read_byte().value() << 8);
if (bits & SU_WEAPONALPHA)
cl.viewent.alpha = MSG_ReadByte();
cl.viewent.alpha = net_message.read_byte().value();
else
cl.viewent.alpha = ENTALPHA_DEFAULT;
//johnfitz
@@ -887,17 +881,17 @@ void CL_ParseStaticSound(int version) //johnfitz -- added argument
int i;
for (i = 0; i < 3; i++)
org[i] = MSG_ReadCoord(cl.protocolflags);
org[i] = net_message.read_coord(static_cast<net::rmq_flags>(cl.protocolflags)).value();
//johnfitz -- PROTOCOL_FITZQUAKE
if (version == 2)
sound_num = MSG_ReadShort();
sound_num = net_message.read_short().value();
else
sound_num = MSG_ReadByte();
sound_num = net_message.read_byte().value();
//johnfitz
vol = MSG_ReadByte();
atten = MSG_ReadByte();
vol = net_message.read_byte().value();
atten = net_message.read_byte().value();
S_StaticSound(cl.sound_precache[sound_num], org, vol, atten);
}
@@ -934,7 +928,7 @@ static void CL_DumpPacket(void) {
}
#endif /* CL_DumpPacket */
#define SHOWNET(x) if(cl_shownet.value==2)console::info ("%3i:%s\n", msg_readcount-1, x);
#define SHOWNET(x) if(cl_shownet.value==2)console::info ("%3i:%s\n", net_message.offset()-1, x);
/*
=====================
@@ -944,14 +938,14 @@ CL_ParseServerMessage
void CL_ParseServerMessage(void) {
int cmd;
int i;
const char *str; //johnfitz
std::string str{}; //johnfitz
int total, j, lastcmd; //johnfitz
//
// if recording demos, copy the message out
//
if (cl_shownet.value == 1)
console::info("%i ", net_message.cursize);
console::info("%i ", net_message.size());
else if (cl_shownet.value == 2)
console::info("------------------\n");
@@ -960,20 +954,22 @@ void CL_ParseServerMessage(void) {
//
// parse the message
//
MSG_BeginReading();
net_message.begin_reading();
lastcmd = 0;
while (1) {
if (msg_badread)
while (true) {
if (net_message.eos())
Host_Error("CL_ParseServerMessage: Bad server message");
cmd = MSG_ReadByte();
auto cmdv = net_message.read_byte();
if (cmd == -1) {
if (!cmdv.has_value()) {
SHOWNET("END OF MESSAGE");
return; // end of message
}
cmd = cmdv.value();
// if the high bit of the command byte is set, it is a fast update
if (cmd & U_SIGNAL) //johnfitz -- was 128, changed for clarity
{
@@ -1000,7 +996,7 @@ void CL_ParseServerMessage(void) {
case svc_time:
cl.mtime[1] = cl.mtime[0];
cl.mtime[0] = MSG_ReadFloat();
cl.mtime[0] = net_message.read_float().value();
break;
case svc_clientdata:
@@ -1009,7 +1005,7 @@ void CL_ParseServerMessage(void) {
break;
case svc_version:
i = MSG_ReadLong();
i = net_message.read_long().value();
//johnfitz -- support multiple protocols
if (i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE && i != PROTOCOL_RMQ)
Host_Error("Server returned version %i, not %i or %i or %i", i, PROTOCOL_NETQUAKE,
@@ -1022,19 +1018,19 @@ void CL_ParseServerMessage(void) {
Host_EndGame("Server disconnected\n");
case svc_print:
console::info("%s", MSG_ReadString());
console::info("%s", net_message.read_string().value().c_str());
break;
case svc_centerprint:
//johnfitz -- log centerprints to console
str = MSG_ReadString();
SCR_CenterPrint(str);
Con_LogCenterPrint(str);
str = net_message.read_string().value();
SCR_CenterPrint(str.c_str());
Con_LogCenterPrint(str.c_str());
//johnfitz
break;
case svc_stufftext:
command::buffer::add_text(MSG_ReadString());
command::buffer::add_text(net_message.read_string().value());
break;
case svc_damage:
@@ -1048,18 +1044,18 @@ void CL_ParseServerMessage(void) {
case svc_setangle:
for (i = 0; i < 3; i++)
cl.viewangles[i] = MSG_ReadAngle(cl.protocolflags);
cl.viewangles[i] = net_message.read_angle(static_cast<net::rmq_flags>(cl.protocolflags)).value();
break;
case svc_setview:
cl.viewentity = MSG_ReadShort();
cl.viewentity = net_message.read_short().value();
break;
case svc_lightstyle:
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (i >= MAX_LIGHTSTYLES)
Sys_Error("svc_lightstyle > MAX_LIGHTSTYLES");
q_strlcpy(cl_lightstyle[i].map, MSG_ReadString(), MAX_STYLESTRING);
q_strlcpy(cl_lightstyle[i].map, net_message.read_string().value().c_str(), MAX_STYLESTRING);
cl_lightstyle[i].length = std::strlen(cl_lightstyle[i].map);
//johnfitz -- save extra info
if (cl_lightstyle[i].length) {
@@ -1080,32 +1076,32 @@ void CL_ParseServerMessage(void) {
break;
case svc_stopsound:
i = MSG_ReadShort();
i = net_message.read_short().value();
S_StopSound(i >> 3, i & 7);
break;
case svc_updatename:
Sbar_Changed();
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (i >= cl.maxclients)
Host_Error("CL_ParseServerMessage: svc_updatename > MAX_SCOREBOARD");
q_strlcpy(cl.scores[i].name, MSG_ReadString(), MAX_SCOREBOARDNAME);
q_strlcpy(cl.scores[i].name, net_message.read_string().value().c_str(), MAX_SCOREBOARDNAME);
break;
case svc_updatefrags:
Sbar_Changed();
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (i >= cl.maxclients)
Host_Error("CL_ParseServerMessage: svc_updatefrags > MAX_SCOREBOARD");
cl.scores[i].frags = MSG_ReadShort();
cl.scores[i].frags = net_message.read_short().value();
break;
case svc_updatecolors:
Sbar_Changed();
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (i >= cl.maxclients)
Host_Error("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD");
cl.scores[i].colors = MSG_ReadByte();
cl.scores[i].colors = net_message.read_byte().value();
CL_NewTranslation(i);
break;
@@ -1114,7 +1110,7 @@ void CL_ParseServerMessage(void) {
break;
case svc_spawnbaseline:
i = MSG_ReadShort();
i = net_message.read_short().value();
// must use CL_EntityNum() to force cl.num_entities up
CL_ParseBaseline(CL_EntityNum(i), 1); // johnfitz -- added second parameter
break;
@@ -1128,7 +1124,7 @@ void CL_ParseServerMessage(void) {
break;
case svc_setpause:
cl.paused = MSG_ReadByte();
cl.paused = net_message.read_byte().value();
if (cl.paused) {
CDAudio_Pause();
music::pause();
@@ -1139,7 +1135,7 @@ void CL_ParseServerMessage(void) {
break;
case svc_signonnum:
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (i <= cls.signon)
Host_Error("Received signon %i when at %i", i, cls.signon);
cls.signon = i;
@@ -1163,10 +1159,10 @@ void CL_ParseServerMessage(void) {
break;
case svc_updatestat:
i = MSG_ReadByte();
i = net_message.read_byte().value();
if (i < 0 || i >= MAX_CL_STATS)
Sys_Error("svc_updatestat: %i is invalid", i);
cl.stats[i] = MSG_ReadLong();;
cl.stats[i] = net_message.read_long().value();;
break;
case svc_spawnstaticsound:
@@ -1174,8 +1170,8 @@ void CL_ParseServerMessage(void) {
break;
case svc_cdtrack:
cl.cdtrack = MSG_ReadByte();
cl.looptrack = MSG_ReadByte();
cl.cdtrack = net_message.read_byte().value();
cl.looptrack = net_message.read_byte().value();
if ((cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1))
music::play_cd_track((byte) cls.forcetrack, true);
else
@@ -1194,9 +1190,9 @@ void CL_ParseServerMessage(void) {
cl.completed_time = cl.time;
vid.recalc_refdef = true; // go to full screen
//johnfitz -- log centerprints to console
str = MSG_ReadString();
SCR_CenterPrint(str);
Con_LogCenterPrint(str);
str = net_message.read_string().value();
SCR_CenterPrint(str.c_str());
Con_LogCenterPrint(str.c_str());
//johnfitz
V_RestoreAngles();
break;
@@ -1206,9 +1202,9 @@ void CL_ParseServerMessage(void) {
cl.completed_time = cl.time;
vid.recalc_refdef = true; // go to full screen
//johnfitz -- log centerprints to console
str = MSG_ReadString();
SCR_CenterPrint(str);
Con_LogCenterPrint(str);
str = net_message.read_string().value();
SCR_CenterPrint(str.c_str());
Con_LogCenterPrint(str.c_str());
//johnfitz
V_RestoreAngles();
break;
@@ -1219,7 +1215,7 @@ void CL_ParseServerMessage(void) {
//johnfitz -- new svc types
case svc_skybox:
Sky_LoadSkyBox(MSG_ReadString());
Sky_LoadSkyBox(net_message.read_string().value().c_str());
break;
case svc_bf:
@@ -1231,7 +1227,7 @@ void CL_ParseServerMessage(void) {
break;
case svc_spawnbaseline2: //PROTOCOL_FITZQUAKE
i = MSG_ReadShort();
i = net_message.read_short().value();
// must use CL_EntityNum() to force cl.num_entities up
CL_ParseBaseline(CL_EntityNum(i), 2);
break;
@@ -1247,8 +1243,8 @@ void CL_ParseServerMessage(void) {
//used by the 2021 rerelease
case svc_achievement:
str = MSG_ReadString();
console::debug("Ignoring svc_achievement (%s)\n", str);
str = net_message.read_string().value();
console::debug("Ignoring svc_achievement (%s)\n", str.c_str());
break;
case svc_localsound:
CL_ParseLocalSound();