Renamed Networking Functions

New names more appropriately match the size of the value they write to/read from the stream.
This commit is contained in:
Boondorl 2024-01-05 14:38:33 -05:00 committed by Christoph Oelckers
commit a8e350aed8
25 changed files with 368 additions and 368 deletions

View file

@ -264,7 +264,7 @@ static struct TicSpecial
if (streamptr)
{
CheckSpace (1);
WriteByte (it, &streamptr);
WriteInt8 (it, &streamptr);
}
return *this;
}
@ -274,7 +274,7 @@ static struct TicSpecial
if (streamptr)
{
CheckSpace (2);
WriteWord (it, &streamptr);
WriteInt16 (it, &streamptr);
}
return *this;
}
@ -284,7 +284,7 @@ static struct TicSpecial
if (streamptr)
{
CheckSpace (4);
WriteLong (it, &streamptr);
WriteInt32 (it, &streamptr);
}
return *this;
}
@ -791,7 +791,7 @@ void GetPackets (void)
{
if (playeringame[i])
{
int resend = ReadLong (&foo);
int resend = ReadInt32 (&foo);
if (i != consoleplayer)
{
resendto[nodeforplayer[i]] = resend;
@ -1246,7 +1246,7 @@ void NetUpdate (void)
// the other players.
if (l == 0)
{
WriteWord (localcmds[localstart].consistancy, &cmddata);
WriteInt16 (localcmds[localstart].consistancy, &cmddata);
// [RH] Write out special "ticcmds" before real ticcmd
if (specials.used[start])
{
@ -1261,7 +1261,7 @@ void NetUpdate (void)
int len;
uint8_t *spec;
WriteWord (netcmds[playerbytes[l]][start].consistancy, &cmddata);
WriteInt16 (netcmds[playerbytes[l]][start].consistancy, &cmddata);
spec = NetSpecs[playerbytes[l]][start].GetData (&len);
if (spec != NULL)
{
@ -1468,7 +1468,7 @@ bool DoArbitrate (void *userdata)
stream = &netbuffer[3];
startmap = ReadStringConst(&stream);
rngseed = ReadLong (&stream);
rngseed = ReadInt32 (&stream);
C_ReadCVars (&stream);
}
else if (netbuffer[0] == NCMD_SETUP+3)
@ -1536,7 +1536,7 @@ bool DoArbitrate (void *userdata)
netbuffer[2] = NetMode;
stream = &netbuffer[3];
WriteString (startmap.GetChars(), &stream);
WriteLong (rngseed, &stream);
WriteInt32 (rngseed, &stream);
C_WriteCVars (&stream, CVAR_SERVERINFO, true);
SendSetup (data->playersdetected, data->gotsetup, int(stream - netbuffer));
@ -1779,7 +1779,7 @@ void D_QuitNetGame (void)
for (i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i] && i != consoleplayer)
WriteLong (resendto[nodeforplayer[i]], &foo);
WriteInt32 (resendto[nodeforplayer[i]], &foo);
}
k = int(foo - netbuffer);
}
@ -2047,17 +2047,17 @@ void Net_NewMakeTic (void)
specials.NewMakeTic ();
}
void Net_WriteByte (uint8_t it)
void Net_WriteInt8 (uint8_t it)
{
specials << it;
}
void Net_WriteWord (short it)
void Net_WriteInt16 (short it)
{
specials << it;
}
void Net_WriteLong (int it)
void Net_WriteInt32 (int it)
{
specials << it;
}
@ -2171,7 +2171,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_SAY:
{
const char *name = players[player].userinfo.GetName();
uint8_t who = ReadByte (stream);
uint8_t who = ReadInt8 (stream);
s = ReadStringConst(stream);
if (((who & 1) == 0) || players[player].userinfo.GetTeam() == TEAM_NONE)
@ -2227,7 +2227,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_GIVECHEAT:
s = ReadStringConst(stream);
cht_Give (&players[player], s, ReadLong (stream));
cht_Give (&players[player], s, ReadInt32 (stream));
if (player != consoleplayer)
{
FString message = GStrings("TXT_X_CHEATS");
@ -2239,31 +2239,31 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_TAKECHEAT:
s = ReadStringConst(stream);
cht_Take (&players[player], s, ReadLong (stream));
cht_Take (&players[player], s, ReadInt32 (stream));
break;
case DEM_SETINV:
s = ReadStringConst(stream);
i = ReadLong(stream);
cht_SetInv(&players[player], s, i, !!ReadByte(stream));
i = ReadInt32(stream);
cht_SetInv(&players[player], s, i, !!ReadInt8(stream));
break;
case DEM_WARPCHEAT:
{
int x, y, z;
x = ReadWord (stream);
y = ReadWord (stream);
z = ReadWord (stream);
x = ReadInt16 (stream);
y = ReadInt16 (stream);
z = ReadInt16 (stream);
P_TeleportMove (players[player].mo, DVector3(x, y, z), true);
}
break;
case DEM_GENERICCHEAT:
cht_DoCheat (&players[player], ReadByte (stream));
cht_DoCheat (&players[player], ReadInt8 (stream));
break;
case DEM_CHANGEMAP2:
pos = ReadByte (stream);
pos = ReadInt8 (stream);
/* intentional fall-through */
case DEM_CHANGEMAP:
// Change to another map without disconnecting other players
@ -2312,10 +2312,10 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_INVUSE:
case DEM_INVDROP:
{
uint32_t which = ReadLong (stream);
uint32_t which = ReadInt32 (stream);
int amt = -1;
if (type == DEM_INVDROP) amt = ReadLong(stream);
if (type == DEM_INVDROP) amt = ReadInt32(stream);
if (gamestate == GS_LEVEL && !paused
&& players[player].playerstate != PST_DEAD)
@ -2357,10 +2357,10 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
s = ReadStringConst(stream);
if (type >= DEM_SUMMON2 && type <= DEM_SUMMONFOE2)
{
angle = ReadWord(stream);
tid = ReadWord(stream);
special = ReadByte(stream);
for(i = 0; i < 5; i++) args[i] = ReadLong(stream);
angle = ReadInt16(stream);
tid = ReadInt16(stream);
special = ReadInt8(stream);
for(i = 0; i < 5; i++) args[i] = ReadInt32(stream);
}
typeinfo = PClass::FindActor(s);
@ -2471,7 +2471,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
{
break;
}
Net_WriteByte (DEM_DOAUTOSAVE);
Net_WriteInt8 (DEM_DOAUTOSAVE);
break;
case DEM_DOAUTOSAVE:
@ -2506,8 +2506,8 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_RUNSCRIPT:
case DEM_RUNSCRIPT2:
{
int snum = ReadWord (stream);
int argn = ReadByte (stream);
int snum = ReadInt16 (stream);
int argn = ReadInt8 (stream);
RunScript(stream, players[player].mo, snum, argn, (type == DEM_RUNSCRIPT2) ? ACS_ALWAYS : 0);
}
@ -2516,7 +2516,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_RUNNAMEDSCRIPT:
{
s = ReadStringConst(stream);
int argn = ReadByte(stream);
int argn = ReadInt8(stream);
RunScript(stream, players[player].mo, -FName(s).GetIndex(), argn & 127, (argn & 128) ? ACS_ALWAYS : 0);
}
@ -2524,13 +2524,13 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_RUNSPECIAL:
{
int snum = ReadWord(stream);
int argn = ReadByte(stream);
int snum = ReadInt16(stream);
int argn = ReadInt8(stream);
int arg[5] = { 0, 0, 0, 0, 0 };
for (i = 0; i < argn; ++i)
{
int argval = ReadLong(stream);
int argval = ReadInt32(stream);
if ((unsigned)i < countof(arg))
{
arg[i] = argval;
@ -2565,7 +2565,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_ADDCONTROLLER:
{
uint8_t playernum = ReadByte (stream);
uint8_t playernum = ReadInt8 (stream);
players[playernum].settings_controller = true;
if (consoleplayer == playernum || consoleplayer == Net_Arbitrator)
@ -2575,7 +2575,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_DELCONTROLLER:
{
uint8_t playernum = ReadByte (stream);
uint8_t playernum = ReadInt8 (stream);
players[playernum].settings_controller = false;
if (consoleplayer == playernum || consoleplayer == Net_Arbitrator)
@ -2640,14 +2640,14 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
int pnum;
if (type == DEM_SETSLOTPNUM)
{
pnum = ReadByte(stream);
pnum = ReadInt8(stream);
}
else
{
pnum = player;
}
unsigned int slot = ReadByte(stream);
int count = ReadByte(stream);
unsigned int slot = ReadInt8(stream);
int count = ReadInt8(stream);
if (slot < NUM_WEAPON_SLOTS)
{
players[pnum].weapons.ClearSlot(slot);
@ -2662,7 +2662,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_ADDSLOT:
{
int slot = ReadByte(stream);
int slot = ReadInt8(stream);
PClassActor *wpn = Net_ReadWeapon(stream);
players[player].weapons.AddSlot(slot, wpn, player == consoleplayer);
}
@ -2670,15 +2670,15 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_ADDSLOTDEFAULT:
{
int slot = ReadByte(stream);
int slot = ReadInt8(stream);
PClassActor *wpn = Net_ReadWeapon(stream);
players[player].weapons.AddSlotDefault(slot, wpn, player == consoleplayer);
}
break;
case DEM_SETPITCHLIMIT:
players[player].MinPitch = DAngle::fromDeg(-ReadByte(stream)); // up
players[player].MaxPitch = DAngle::fromDeg(ReadByte(stream)); // down
players[player].MinPitch = DAngle::fromDeg(-ReadInt8(stream)); // up
players[player].MaxPitch = DAngle::fromDeg(ReadInt8(stream)); // down
break;
case DEM_REVERTCAMERA:
@ -2693,11 +2693,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_NETEVENT:
{
s = ReadStringConst(stream);
int argn = ReadByte(stream);
int argn = ReadInt8(stream);
int arg[3] = { 0, 0, 0 };
for (int i = 0; i < 3; i++)
arg[i] = ReadLong(stream);
bool manual = !!ReadByte(stream);
arg[i] = ReadInt32(stream);
bool manual = !!ReadInt8(stream);
primaryLevel->localEventManager->Console(player, s, arg[0], arg[1], arg[2], manual, false);
}
break;
@ -2709,14 +2709,14 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_ZSC_CMD:
{
FName cmd = ReadStringConst(stream);
unsigned int size = ReadWord(stream);
unsigned int size = ReadInt16(stream);
TArray<uint8_t> buffer = {};
if (size)
{
buffer.Grow(size);
for (unsigned int i = 0u; i < size; ++i)
buffer.Push(ReadByte(stream));
buffer.Push(ReadInt8(stream));
}
FNetworkCommand netCmd = { player, cmd, buffer };
@ -2744,7 +2744,7 @@ static void RunScript(uint8_t **stream, AActor *pawn, int snum, int argn, int al
for (i = 0; i < argn; ++i)
{
int argval = ReadLong(stream);
int argval = ReadInt32(stream);
if ((unsigned)i < countof(arg))
{
arg[i] = argval;
@ -2993,11 +2993,11 @@ static void Network_Controller (int playernum, bool add)
}
if (add)
Net_WriteByte (DEM_ADDCONTROLLER);
Net_WriteInt8 (DEM_ADDCONTROLLER);
else
Net_WriteByte (DEM_DELCONTROLLER);
Net_WriteInt8 (DEM_DELCONTROLLER);
Net_WriteByte (playernum);
Net_WriteInt8 (playernum);
}
//==========================================================================