Merge remote-tracking branch 'origin/absolutehell' into lugstuff

This commit is contained in:
Alug committed 2024-07-20 19:47:37 +02:00
commit aede063266
15 files changed
+332 -78

No files matched your search

+229 -40
View File
@@ -76,6 +76,8 @@
#define MAX_REASONLENGTH 30
#define FORCECLOSE 0x8000
static long long unsigned packetstat[NUMPACKETTYPE+1] = {0};
boolean server = true; // true or false but !server == client
#define client (!server)
boolean nodownload = false;
@@ -90,6 +92,8 @@ UINT8 playernode[MAXPLAYERS];
// The actual timeout will be longer depending on the savegame length
tic_t jointimeout = (3*TICRATE);
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame?
static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again?
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
UINT16 pingmeasurecount = 1;
@@ -121,6 +125,9 @@ static UINT8 resynch_inprogress[MAXNETNODES];
static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it.
static UINT8 player_joining = false;
UINT8 hu_resynching = 0;
UINT8 hu_redownloadinggamestate = 0;
static boolean can_receive_gamestate[MAXNETNODES];
// kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks
UINT8 hu_stopped = 0;
@@ -133,6 +140,9 @@ static ticcmd_t localcmds4;
static boolean cl_packetmissed;
// here it is for the secondary local player (splitscreen)
static UINT8 mynode; // my address pointofview server
static boolean cl_redownloadinggamestate = false;
boolean is_client_saturn[MAXNETNODES];
static UINT8 localtextcmd[MAXTEXTCMD];
static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen
@@ -1702,22 +1712,26 @@ static boolean SV_SendServerConfig(INT32 node)
netbuffer->u.servercfg.gametype = (UINT8)gametype;
netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame;
// we fill these structs with FFs so that any players not in game get sent as 0xFFFF
// which is nice and easy for us to detect
memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins));
memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor));
memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers));
for (i = 0; i < MAXPLAYERS; i++)
if (!can_receive_gamestate[node])
{
netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i];
// we fill these structs with FFs so that any players not in game get sent as 0xFFFF
// which is nice and easy for us to detect
memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins));
memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor));
if (!playeringame[i])
continue;
memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers));
netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin;
netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor;
for (i = 0; i < MAXPLAYERS; i++)
{
netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i];
if (!playeringame[i])
continue;
netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin;
netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor;
}
}
netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
@@ -1725,12 +1739,21 @@ static boolean SV_SendServerConfig(INT32 node)
netbuffer->u.servercfg.discordinvites = (boolean)cv_discordinvites.value;
memcpy(netbuffer->u.servercfg.server_context, server_context, 8);
op = p = netbuffer->u.servercfg.varlengthinputs;
CV_SavePlayerNames(&p);
CV_SaveNetVars(&p, false);
if (!can_receive_gamestate[node])
{
const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op);
op = p = netbuffer->u.servercfg.varlengthinputs;
CV_SavePlayerNames(&p);
CV_SaveNetVars(&p, false);
}
{
size_t len;
if (can_receive_gamestate[node])
len = sizeof (serverconfig_pak);
else
len = sizeof (serverconfig_pak) + (size_t)(p - op);
#ifdef DEBUGFILE
if (debugfile)
@@ -1763,7 +1786,7 @@ static boolean SV_SendServerConfig(INT32 node)
#ifdef JOININGAME
#define SAVEGAMESIZE (768*1024)
static void SV_SendSaveGame(INT32 node)
static void SV_SendSaveGame(INT32 node, boolean resending)
{
size_t length, compressedlen;
UINT8 *savebuffer;
@@ -1781,7 +1804,7 @@ static void SV_SendSaveGame(INT32 node)
// Leave room for the uncompressed length.
save_p = savebuffer + sizeof(UINT32);
P_SaveNetGame();
P_SaveNetGame(resending);
length = save_p - savebuffer;
if (length > SAVEGAMESIZE)
@@ -1877,7 +1900,7 @@ static void SV_SavedGame(void)
#define TMPSAVENAME "$$$.sav"
static void CL_LoadReceivedSavegame(void)
static void CL_LoadReceivedSavegame(boolean reloading)
{
UINT8 *savebuffer = NULL;
size_t length, decompressedlen;
@@ -1921,7 +1944,7 @@ static void CL_LoadReceivedSavegame(void)
}
// load a base level
if (P_LoadNetGame())
if (P_LoadNetGame(reloading))
{
CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)));
if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0)
@@ -1936,15 +1959,6 @@ static void CL_LoadReceivedSavegame(void)
}
CON_LogMessage("\"\n");
}
else
{
CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n"));
Z_Free(savebuffer);
save_p = NULL;
if (unlink(tmpsave) == -1)
CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave);
return;
}
// done
Z_Free(savebuffer);
@@ -1953,6 +1967,34 @@ static void CL_LoadReceivedSavegame(void)
CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave);
consistancy[gametic%TICQUEUE] = Consistancy();
CON_ToggleOff();
// Tell the server we have received and reloaded the gamestate
// so they know they can resume the game
netbuffer->packettype = PT_RECEIVEDGAMESTATE;
HSendPacket(servernode, true, 0, 0);
}
static void CL_ReloadReceivedSavegame(void)
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
{
LUA_InvalidatePlayer(&players[i]);
sprintf(player_names[i], "Player %d", i + 1);
}
CL_LoadReceivedSavegame(true);
if (neededtic < gametic)
neededtic = gametic;
maketic = neededtic;
camera->subsector = R_PointInSubsector(camera->x, camera->y);
cl_redownloadinggamestate = false;
CONS_Printf(M_GetText("Game state reloaded\n"));
}
#endif
@@ -2566,7 +2608,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
if (fileneeded[0].status == FS_FOUND)
{
// Gamestate is now handled within CL_LoadReceivedSavegame()
CL_LoadReceivedSavegame();
CL_LoadReceivedSavegame(false);
cl_mode = CL_CONNECTED;
break;
} // don't break case continue to CL_CONNECTED
@@ -3116,6 +3158,17 @@ static void Command_connect(void)
botskin = 0;
CL_ConnectToServer();
}
static void Command_Packetstat(void)
{
CONS_Printf("Number of packets handled:\n");
for (UINT8 i = 0; i <= NUMPACKETTYPE; ++i)
{
CONS_Printf("%16s: %llu%s", Net_GetPacketName(i), packetstat[i], (i % 2 == 1) ? "\n" : "\t|\t");
}
}
#endif
static void ResetNode(INT32 node);
@@ -3158,10 +3211,11 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
playerpernode[node]--;
if (playerpernode[node] <= 0)
{
// If a resynch was in progress, well, it no longer needs to be.
SV_InitResynchVars(node);
SV_InitResynchVars(node); // If a resynch was in progress, well, it no longer needs to be.
nodeingame[node] = false;
is_client_saturn[node] = false;
can_receive_gamestate[node] = false;
Net_CloseConnection(node);
ResetNode(node);
}
@@ -3267,6 +3321,7 @@ void CL_Reset(void)
if (servernode > 0 && servernode < MAXNETNODES)
{
nodeingame[(UINT8)servernode] = false;
is_client_saturn[(UINT8)servernode] = false;
Net_CloseConnection(servernode);
}
D_CloseConnection(); // netgame = false
@@ -3281,6 +3336,7 @@ void CL_Reset(void)
// make sure we don't leave any fileneeded gunk over from a failed join
fileneedednum = 0;
memset(fileneeded, 0, sizeof(fileneeded));
memset(packetstat, 0, sizeof(packetstat));
#ifndef NONET
totalfilesrequestednum = 0;
@@ -3961,6 +4017,34 @@ static void Command_list_http_logins (void)
}
#endif/*HAVE_CURL*/
static void Command_ResendGamestate(void)
{
SINT8 playernum;
if (COM_Argc() == 1)
{
CONS_Printf(M_GetText("resendgamestate <playername/playernum>: resend the game state to a player\n"));
return;
}
else if (client)
{
CONS_Printf(M_GetText("Only the server can use this.\n"));
return;
}
playernum = nametonum(COM_Argv(1));
if (playernum == -1 || playernum == 0)
return;
// Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on
netbuffer->packettype = PT_WILLRESENDGAMESTATE;
if (!HSendPacket(playernode[playernum], true, 0, 0))
{
CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n"));
return;
}
}
static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}};
consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -4034,7 +4118,9 @@ void D_ClientServerInit(void)
COM_AddCommand("reloadbans", Command_ReloadBan);
COM_AddCommand("connect", Command_connect);
COM_AddCommand("nodes", Command_Nodes);
COM_AddCommand("resendgamestate", Command_ResendGamestate);
COM_AddCommand("listplayers", Command_Listplayers);
COM_AddCommand("packetstat", Command_Packetstat);
#ifdef HAVE_CURL
COM_AddCommand("set_http_login", Command_set_http_login);
COM_AddCommand("list_http_logins", Command_list_http_logins);
@@ -4071,6 +4157,12 @@ void D_ClientServerInit(void)
static void ResetNode(INT32 node)
{
nodeingame[node] = false;
nodewaiting[node] = 0;
nettics[node] = gametic;
supposedtics[node] = gametic;
is_client_saturn[node] = false;
nodetoplayer[node] = -1;
nodetoplayer2[node] = -1;
nodetoplayer3[node] = -1;
@@ -4080,6 +4172,9 @@ static void ResetNode(INT32 node)
nodewaiting[node] = 0;
playerpernode[node] = 0;
sendingsavegame[node] = false;
resendingsavegame[node] = false;
can_receive_gamestate[node] = false;
savegameresendcooldown[node] = 0;
bannednode[node].banid = SIZE_MAX;
bannednode[node].timeleft = NO_BAN_TIME;
}
@@ -4117,6 +4212,7 @@ void SV_ResetServer(void)
mynode = 0;
cl_packetmissed = false;
cl_redownloadinggamestate = false;
if (dedicated)
{
@@ -4133,6 +4229,7 @@ void SV_ResetServer(void)
// clear server_context
memset(server_context, '-', 8);
memset(packetstat, 0, sizeof(packetstat));
DEBFILE("\n-=-=-=-=-=-=-= Server Reset =-=-=-=-=-=-=-\n\n");
}
@@ -4407,6 +4504,12 @@ static boolean SV_AddWaitingPlayers(void)
return newplayer;
}
static inline void SendSaturnInfo(INT32 node)
{
netbuffer->packettype = PT_ISSATURN;
HSendPacket(node, true, 0, 0);
}
void CL_AddSplitscreenPlayer(void)
{
if (cl_mode == CL_CONNECTED)
@@ -4631,7 +4734,7 @@ static void HandleConnect(SINT8 node)
/// \note Wait what???
/// What if the gamestate takes more than one second to get downloaded?
/// Or if a lagspike happens?
/// Or if a lagspike happdsfens?
// you get a free second before desynch checks. use it wisely.
SV_InitResynchVars(node);
@@ -4660,7 +4763,7 @@ static void HandleConnect(SINT8 node)
HSendPacket(node, false, 0, 0);
if (node && newnode)
{
SV_SendSaveGame(node); // send a complete game state
SV_SendSaveGame(node, false); // send a complete game state
DEBFILE("send savegame\n");
}
SV_AddWaitingPlayers();
@@ -4729,6 +4832,44 @@ static void HandleServerInfo(SINT8 node)
}
#endif
static void PT_WillResendGamestate(void)
{
char tmpsave[264];
if (server || cl_redownloadinggamestate)
return;
// Send back a PT_CANRECEIVEGAMESTATE packet to the server
// so they know they can start sending the game state
netbuffer->packettype = PT_CANRECEIVEGAMESTATE;
if (!HSendPacket(servernode, true, 0, 0))
return;
CONS_Printf(M_GetText("Reloading game state...\n"));
sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home);
// Don't get a corrupt savegame error because tmpsave already exists
if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1)
I_Error("Can't delete %s\n", tmpsave);
CL_PrepareDownloadSaveGame(tmpsave);
cl_redownloadinggamestate = true;
}
static void PT_CanReceiveGamestate(SINT8 node)
{
if (client || sendingsavegame[node])
return;
CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]);
SV_SendSaveGame(node, true); // Resend a complete game state
resendingsavegame[node] = true;
}
/** Handles a packet received from a node that isn't in game
*
* \param node The packet sender
@@ -4917,6 +5058,8 @@ static void HandlePacketFromAwayNode(SINT8 node)
#endif
DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode));
SendSaturnInfo(node);
memset(playeringame, 0, sizeof(playeringame));
for (j = 0; j < MAXPLAYERS; j++)
{
@@ -5159,11 +5302,27 @@ static void HandlePacketFromPlayer(SINT8 node)
--resynch_delay[node];
break;
}
// Check player consistancy during the level
if (realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy))
if ((!can_receive_gamestate[node] && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)
&& !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime()))
{
SV_RequireResynch(node);
// we need to send this so the client can tell us if it can receive the savegame
netbuffer->packettype = PT_WILLRESENDGAMESTATE;
HSendPacket(node, true, 0, 0);
if (can_receive_gamestate[node])
{
resendingsavegame[node] = true;
}
else
{
CONS_Printf("resynch");
SV_RequireResynch(node);
resendingsavegame[node] = false;
}
if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250)
{
@@ -5327,6 +5486,8 @@ static void HandlePacketFromPlayer(SINT8 node)
}
Net_CloseConnection(node);
nodeingame[node] = false;
is_client_saturn[node] = false;
can_receive_gamestate[node] = false;
break;
// -------------------------------------------- CLIENT RECEIVE ----------
case PT_RESYNCHEND:
@@ -5491,7 +5652,20 @@ static void HandlePacketFromPlayer(SINT8 node)
Got_Filetxpak();
break;
case PT_ISSATURN:
CONS_Printf("hi im on saturn\n");
//CONS_Printf("hi im on saturn\n");
is_client_saturn[node] = true;
break;
case PT_CANRECEIVEGAMESTATE:
can_receive_gamestate[node] = true;
PT_CanReceiveGamestate(node);
break;
case PT_RECEIVEDGAMESTATE:
sendingsavegame[node] = false;
resendingsavegame[node] = false;
savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE;
break;
case PT_WILLRESENDGAMESTATE:
PT_WillResendGamestate();
break;
default:
DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n",
@@ -5545,6 +5719,10 @@ static void GetPackets(void)
if (netbuffer->packettype == PT_PLAYERINFO)
continue; // We do nothing with PLAYERINFO, that's for the MS browser.
// We also count unknown packets, hence "<="
if (netbuffer->packettype <= NUMPACKETTYPE)
++packetstat[netbuffer->packettype];
// Packet received from someone already playing
if (nodeingame[node])
HandlePacketFromPlayer(node);
@@ -6450,6 +6628,16 @@ void NetUpdate(void)
if (!resynch_local_inprogress)
CL_SendClientCmd(); // Send tic cmd
hu_resynching = resynch_local_inprogress;
if (cl_redownloadinggamestate)
{
// If the client just finished redownloading the game state, load it
if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND)
CL_ReloadReceivedSavegame();
CL_SendClientCmd(); // Send tic cmd
}
hu_redownloadinggamestate = cl_redownloadinggamestate;
}
else
{
@@ -6458,6 +6646,7 @@ void NetUpdate(void)
INT32 counts;
hu_resynching = false;
hu_redownloadinggamestate = false;
firstticstosend = gametic;
for (i = 0; i < MAXNETNODES; i++)
@@ -6559,7 +6748,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos)
return NULL;
save_p = rewind->savebuffer;
P_SaveNetGame();
P_SaveNetGame(true);
rewind->leveltime = leveltime;
rewind->next = rewindhead;
rewind->demopos = demopos;
@@ -6583,7 +6772,7 @@ rewind_t *CL_RewindToTime(tic_t time)
return NULL;
save_p = rewindhead->savebuffer;
P_LoadNetGame();
P_LoadNetGame(true);
wipegamestate = gamestate; // No fading back in!
timeinmap = leveltime;
+6
View File
@@ -98,7 +98,12 @@ typedef enum
PT_MOREFILESNEEDED, // Server, to client: "you need these (+ more on top of those)"
PT_PING, // Packet sent to tell clients the other client's latency to server.
PT_ISSATURN,
PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate!
PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead.
PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again!
NUMPACKETTYPE
} packettype_t;
@@ -633,6 +638,7 @@ tic_t GetLag(INT32 node);
UINT8 GetFreeXCmdSize(void);
extern UINT8 hu_resynching;
extern UINT8 hu_redownloadinggamestate;
extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
typedef struct rewind_s {
+1 -1
View File
@@ -2005,7 +2005,7 @@ void D_SRB2Main(void)
pagename = "TITLESKY";
levelstarttic = gametic;
G_SetGamestate(GS_LEVEL);
if (!P_SetupLevel(false))
if (!P_SetupLevel(false, false))
I_Quit(); // fail so reset game stuff
}
+17 -3
View File
@@ -790,7 +790,7 @@ static void fprintfstringnewline(char *s, size_t len)
}
/// \warning Keep this up-to-date if you add/remove/rename packet types
static const char *packettypename[NUMPACKETTYPE] =
const char *packettypename[NUMPACKETTYPE] =
{
"NOTHING",
"SERVERCFG",
@@ -832,14 +832,28 @@ static const char *packettypename[NUMPACKETTYPE] =
"TELLFILESNEEDED",
"MOREFILESNEEDED",
"PING"
"PING",
"ISSATURN",
"WILLRESENDGAMESTATE",
"CANRECEIVEGAMESTATE",
"RECEIVEDGAMESTATE"
};
const char *Net_GetPacketName(UINT8 packettype)
{
if (packettype >= NUMPACKETTYPE)
return "UNKNOWN";
return packettypename[packettype];
}
static void DebugPrintpacket(const char *header)
{
fprintf(debugfile, "%-12s (node %d,ack %d,ackret %d,size %d) type(%d) : %s\n",
header, doomcom->remotenode, netbuffer->ack, netbuffer->ackreturn, doomcom->datalength,
netbuffer->packettype, packettypename[netbuffer->packettype]);
netbuffer->packettype, Net_GetPacketName(netbuffer->packettype));
switch (netbuffer->packettype)
{
+1
View File
@@ -65,5 +65,6 @@ void Net_ConnectionTimeout(INT32 node);
void Net_AbortPacketType(UINT8 packettype);
void Net_SendAcks(INT32 node);
void Net_WaitAllAckReceived(UINT32 timeout);
const char *Net_GetPacketName(UINT8 packettype);
#endif
+4 -2
View File
@@ -1188,7 +1188,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
// why build a ticcmd if we're paused?
// Or, for that matter, if we're being reborn.
// Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions
if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching)
if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching || hu_redownloadinggamestate)
{
cmd->angleturn = (INT16)(lang >> 16);
cmd->aiming = G_ClipAimingPitch(&laim);
@@ -1638,7 +1638,7 @@ void G_DoLoadLevel(boolean resetplayer)
}
// Setup the level.
if (!P_SetupLevel(false))
if (!P_SetupLevel(false,false))
{
// fail so reset game stuff
Command_ExitGame_f();
@@ -1661,6 +1661,8 @@ void G_DoLoadLevel(boolean resetplayer)
Z_CheckHeap(-2);
#endif
memset(localaiming, 0, sizeof(localaiming));
for (i = 0; i <= splitscreen; i++)
{
if (camera[i].chase)
+1 -2
View File
@@ -3782,7 +3782,6 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
HWR_RotateSpritePolyToAim(spr, baseWallVerts, false);
// push it toward the camera to mitigate floor-clipping sprites
//if (!(spr->mobj->frame & FF_PAPERSPRITE) || ((spr->mobj->frame & FF_PAPERSPRITE) && spr->dispoffset))
{
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz));
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
@@ -4061,10 +4060,10 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
}*/
// Let dispoffset work first since this adjust each vertex
// ...nah
HWR_RotateSpritePolyToAim(spr, wallVerts, false);
// push it toward the camera to mitigate floor-clipping sprites
//if (!(spr->mobj->frame & FF_PAPERSPRITE) || ((spr->mobj->frame & FF_PAPERSPRITE) && spr->dispoffset))
{
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz));
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
+2 -2
View File
@@ -1253,7 +1253,7 @@ void HU_Ticker(void)
if (cechotimer > 0) --cechotimer;
// Animate the desynch dots
if (hu_resynching)
if (hu_resynching || hu_redownloadinggamestate)
resynch_ticker++; //tic tic tic tic tic
HU_TickSongCredits();
@@ -2418,7 +2418,7 @@ void HU_Drawer(void)
HU_DrawSongCredits();
// draw desynch text
if (hu_resynching)
if (hu_resynching || hu_redownloadinggamestate)
{
char resynch_text[14];
UINT32 i;
+49 -12
View File
@@ -107,7 +107,7 @@ static inline void P_UnArchivePlayer(void)
//
// P_NetArchivePlayers
//
static void P_NetArchivePlayers(void)
static void P_NetArchivePlayers(boolean resending)
{
INT32 i, j;
UINT16 flags;
@@ -117,6 +117,9 @@ static void P_NetArchivePlayers(void)
for (i = 0; i < MAXPLAYERS; i++)
{
if (resending)
WRITESINT8(save_p, (SINT8)adminplayers[i]);
if (!playeringame[i])
continue;
@@ -124,6 +127,9 @@ static void P_NetArchivePlayers(void)
// no longer send ticcmds, player name, skin, or color
if (resending)
WRITESTRINGN(save_p, player_names[i], MAXPLAYERNAME);
WRITEANGLE(save_p, players[i].aiming);
WRITEANGLE(save_p, players[i].awayviewaiming);
WRITEINT32(save_p, players[i].awayviewtics);
@@ -148,6 +154,13 @@ static void P_NetArchivePlayers(void)
WRITEUINT16(save_p, players[i].flashpal);
WRITEUINT16(save_p, players[i].flashcount);
if (resending)
{
WRITEUINT8(save_p, players[i].skincolor);
WRITEINT32(save_p, players[i].skin);
}
WRITEUINT32(save_p, players[i].score);
WRITEFIXED(save_p, players[i].dashspeed);
WRITEINT32(save_p, players[i].dashtime);
@@ -285,7 +298,7 @@ static void P_NetArchivePlayers(void)
//
// P_NetUnArchivePlayers
//
static void P_NetUnArchivePlayers(void)
static void P_NetUnArchivePlayers(boolean resending)
{
INT32 i, j;
UINT16 flags;
@@ -295,6 +308,8 @@ static void P_NetUnArchivePlayers(void)
for (i = 0; i < MAXPLAYERS; i++)
{
if (resending)
adminplayers[i] = (INT32)READSINT8(save_p);
// Do NOT memset player struct to 0
// other areas may initialize data elsewhere
//memset(&players[i], 0, sizeof (player_t));
@@ -305,6 +320,9 @@ static void P_NetUnArchivePlayers(void)
// sending player names, skin and color should not be necessary at all!
// (that data is handled in the server config now)
if (resending)
READSTRINGN(save_p, player_names[i], MAXPLAYERNAME);
players[i].aiming = READANGLE(save_p);
players[i].awayviewaiming = READANGLE(save_p);
players[i].awayviewtics = READINT32(save_p);
@@ -329,6 +347,12 @@ static void P_NetUnArchivePlayers(void)
players[i].flashpal = READUINT16(save_p);
players[i].flashcount = READUINT16(save_p);
if (resending)
{
players[i].skincolor = READUINT8(save_p);
players[i].skin = READINT32(save_p);
}
players[i].score = READUINT32(save_p);
players[i].dashspeed = READFIXED(save_p); // dashing speed
players[i].dashtime = READINT32(save_p); // dashing speed
@@ -3233,19 +3257,25 @@ static inline void P_UnArchiveSPGame(INT16 mapoverride)
playeringame[consoleplayer] = true;
}
static void P_NetArchiveMisc(void)
static void P_NetArchiveMisc(boolean resending)
{
UINT32 pig = 0;
INT32 i;
WRITEUINT32(save_p, ARCHIVEBLOCK_MISC);
if (resending)
WRITEUINT32(save_p, gametic);
WRITEINT16(save_p, gamemap);
if (gamestate != GS_LEVEL)
WRITEINT16(save_p, GS_WAITINGPLAYERS); // nice hack to put people back into waitingplayers
else
WRITEINT16(save_p, gamestate);
if (resending)
WRITEINT16(save_p, gametype);
for (i = 0; i < MAXPLAYERS; i++)
pig |= (playeringame[i] != 0)<<i;
WRITEUINT32(save_p, pig);
@@ -3328,7 +3358,7 @@ static void P_NetArchiveMisc(void)
WRITEUINT8(save_p, 0x2e);
}
FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(void)
FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(boolean reloading)
{
UINT32 pig;
INT32 i;
@@ -3336,6 +3366,9 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(void)
if (READUINT32(save_p) != ARCHIVEBLOCK_MISC)
I_Error("Bad $$$.sav at archive block Misc");
if (reloading)
gametic = READUINT32(save_p);
gamemap = READINT16(save_p);
// gamemap changed; we assume that its map header is always valid,
@@ -3345,10 +3378,14 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(void)
// tell the sound code to reset the music since we're skipping what
// normally sets this flag
mapmusflags |= MUSIC_RELOADRESET;
if (!reloading)
mapmusflags |= MUSIC_RELOADRESET;
G_SetGamestate(READINT16(save_p));
if (reloading)
gametype = READINT16(save_p);
pig = READUINT32(save_p);
for (i = 0; i < MAXPLAYERS; i++)
{
@@ -3362,7 +3399,7 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(void)
encoremode = (boolean)READUINT8(save_p);
if (!P_SetupLevel(true))
if (!P_SetupLevel(true, reloading))
{
CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n"));
return false;
@@ -3449,14 +3486,14 @@ void P_SaveGame(void)
WRITEUINT8(save_p, 0x1d); // consistency marker
}
void P_SaveNetGame(void)
void P_SaveNetGame(boolean resending)
{
thinker_t *th;
mobj_t *mobj;
INT32 i = 1; // don't start from 0, it'd be confused with a blank pointer otherwise
CV_SaveNetVars(&save_p, false);
P_NetArchiveMisc();
P_NetArchiveMisc(resending);
// Assign the mobjnumber for pointer tracking
if (gamestate == GS_LEVEL)
@@ -3474,7 +3511,7 @@ void P_SaveNetGame(void)
}
}
P_NetArchivePlayers();
P_NetArchivePlayers(resending);
if (gamestate == GS_LEVEL)
{
P_NetArchiveWorld();
@@ -3512,12 +3549,12 @@ boolean P_LoadGame(INT16 mapoverride)
return true;
}
boolean P_LoadNetGame(void)
boolean P_LoadNetGame(boolean resending)
{
CV_LoadNetVars(&save_p);
if (!P_NetUnArchiveMisc())
if (!P_NetUnArchiveMisc(resending))
return false;
P_NetUnArchivePlayers();
P_NetUnArchivePlayers(resending);
if (gamestate == GS_LEVEL)
{
P_NetUnArchiveWorld();
+2 -2
View File
@@ -22,9 +22,9 @@
// These are the load / save game routines.
void P_SaveGame(void);
void P_SaveNetGame(void);
void P_SaveNetGame(boolean resending);
boolean P_LoadGame(INT16 mapoverride);
boolean P_LoadNetGame(void);
boolean P_LoadNetGame(boolean resending);
mobj_t *P_FindNewPosition(UINT32 oldposition);
+16 -9
View File
@@ -2138,7 +2138,7 @@ lumpnum_t lastloadedmaplumpnum; // for comparative savegame
//
// Some player initialization for map start.
//
static void P_LevelInitStuff(void)
static void P_LevelInitStuff(boolean reloadinggamestate)
{
INT32 i;
@@ -2173,7 +2173,10 @@ static void P_LevelInitStuff(void)
// circuit, race and competition stuff
circuitmap = false;
numstarposts = 0;
totalrings = timeinmap = 0;
totalrings = 0;
if (!reloadinggamestate)
timeinmap = 0;
// special stage
stagefailed = false;
@@ -2274,7 +2277,7 @@ void P_LoadThingsOnly(void)
P_RemoveMobj((mobj_t *)think);
}
P_LevelInitStuff();
P_LevelInitStuff(false);
P_PrepareRawThings(vth->data);
P_LoadThings();
@@ -2593,7 +2596,7 @@ static boolean P_CanSave(void)
* \param skipprecip If true, don't spawn precipitation.
* \todo Clean up, refactor, split up; get rid of the bloat.
*/
boolean P_SetupLevel(boolean skipprecip)
boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
{
// use gamemap to get map number.
// 99% of the things already did, so.
@@ -2631,7 +2634,7 @@ boolean P_SetupLevel(boolean skipprecip)
if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#')
P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname);
P_LevelInitStuff();
P_LevelInitStuff(reloadinggamestate);
for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
@@ -2664,9 +2667,12 @@ boolean P_SetupLevel(boolean skipprecip)
// will be set by player think.
players[consoleplayer].viewz = 1;
// Cancel all d_main.c fadeouts (keep fade in though).
if (reloadinggamestate)
wipegamestate = gamestate; // Don't fade if reloading the gamestate
// Encore mode fade to pink to white
// This is handled BEFORE sounds are stopped.
if (encoremode && !prevencoremode && !demo.rewinding)
else if (encoremode && !prevencoremode && !demo.rewinding)
{
tic_t locstarttime, endtime, nowtime;
@@ -2725,13 +2731,14 @@ boolean P_SetupLevel(boolean skipprecip)
// As oddly named as this is, this handles music only.
// We should be fine starting it here.
S_Start();
if (!reloadinggamestate)
S_Start();
levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120);
// Let's fade to white here
// But only if we didn't do the encore startup wipe
if (!ranspecialwipe && !demo.rewinding)
if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate)
{
if(rendermode != render_none)
{
@@ -3020,7 +3027,7 @@ boolean P_SetupLevel(boolean skipprecip)
P_MapEnd();
// Remove the loading shit from the screen
if (rendermode != render_none)
if (rendermode != render_none && (!reloadinggamestate))
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
if (precache || dedicated)
+1 -1
View File
@@ -63,7 +63,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global);
void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum);
#endif
void P_LoadThingsOnly(void);
boolean P_SetupLevel(boolean skipprecip);
boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate);
#ifdef HWRENDER
void HWR_LoadLevel(void);
#endif
+1 -1
View File
@@ -318,7 +318,7 @@ static inline void P_RunThinkers(void)
for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next)
{
#ifdef PARANOIA
I_Assert(currentthinker->function.acp1 != NULL)
I_Assert(currentthinker->function.acp1 != NULL)
#endif
currentthinker->function.acp1(currentthinker);
}
+1 -1
View File
@@ -27,7 +27,7 @@ void Command_CountMobjs_f(void);
void P_Ticker(boolean run);
void P_PreTicker(INT32 frames);
void P_DoTeamscrambling(void);
void P_RemoveThinkerDelayed(thinker_t *thinker); //killed
void P_RemoveThinkerDelayed(thinker_t *thinker);
mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98
#endif
+1 -2
View File
@@ -43,16 +43,15 @@ void R_DrawColumn_8(void)
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
//dest = ylookup[dc_yl] + columnofs[dc_x];
dest = &topleft[dc_yl*vid.width + dc_x];
count++;
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
{