From a0d095e70735f8237ccfd4b6a7fce35408c08bf1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 3 Jan 2017 18:47:46 +0000 Subject: [PATCH 1/4] Fix sector floordata/ceilingdata/lightingdata pointers not being NULL when they should be This fixes ERCZ's lava falls not moving after joining a netgame at that stage. Possibly explains other various floor/ceiling related netgame quirks that haven't been noticed until now, maybe even in multiplayer levels. --- src/p_saveg.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 14386ff15..66fc118a7 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2607,6 +2607,7 @@ static void P_NetUnArchiveThinkers(void) thinker_t *next; UINT8 tclass; UINT8 restoreNum = false; + UINT32 i; if (READUINT32(save_p) != ARCHIVEBLOCK_THINKERS) I_Error("Bad $$$.sav at archive block Thinkers"); @@ -2627,6 +2628,12 @@ static void P_NetUnArchiveThinkers(void) iquetail = iquehead = 0; P_InitThinkers(); + // clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity + for (i = 0; i < numsectors; i++) + { + sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; + } + // read in saved thinkers for (;;) { From b768c4b9611e916d2190f09420b48738af7a5ec8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 3 Jan 2017 20:48:39 +0000 Subject: [PATCH 2/4] Sync sector tags and tag list variables properly Dunno who thought it was a good idea to lump tag, nexttag and firsttag together in $$$.sav, but that meant changing sector tags caused SRB2 to stop responding since it lead to the tag lists being broken --- src/p_saveg.c | 19 +++++++++++-------- src/p_setup.c | 1 + src/p_spec.c | 2 ++ src/r_defs.h | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 66fc118a7..d20628200 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -460,6 +460,7 @@ static void P_NetUnArchivePlayers(void) #define SD_TAG 0x10 #define SD_FLOORANG 0x20 #define SD_CEILANG 0x40 +#define SD_TAGLIST 0x80 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -535,6 +536,8 @@ static void P_NetArchiveWorld(void) if (ss->tag != SHORT(ms->tag)) diff2 |= SD_TAG; + if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) + diff2 |= SD_TAGLIST; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -582,16 +585,17 @@ static void P_NetArchiveWorld(void) WRITEFIXED(put, ss->ceiling_xoffs); if (diff2 & SD_CYOFFS) WRITEFIXED(put, ss->ceiling_yoffs); - if (diff2 & SD_TAG) - { + if (diff2 & SD_TAG) // save only the tag WRITEINT16(put, ss->tag); - WRITEINT32(put, ss->firsttag); - WRITEINT32(put, ss->nexttag); - } if (diff2 & SD_FLOORANG) WRITEANGLE(put, ss->floorpic_angle); if (diff2 & SD_CEILANG) WRITEANGLE(put, ss->ceilingpic_angle); + if (diff2 & SD_TAGLIST) // save both firsttag and nexttag + { // either of these could be changed even if tag isn't + WRITEINT32(put, ss->firsttag); + WRITEINT32(put, ss->nexttag); + } // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed @@ -774,12 +778,11 @@ static void P_NetUnArchiveWorld(void) if (diff2 & SD_CYOFFS) sectors[i].ceiling_yoffs = READFIXED(get); if (diff2 & SD_TAG) + sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag + if (diff2 & SD_TAGLIST) { - INT16 tag; - tag = READINT16(get); sectors[i].firsttag = READINT32(get); sectors[i].nexttag = READINT32(get); - P_ChangeSectorTag(i, tag); } if (diff2 & SD_FLOORANG) sectors[i].floorpic_angle = READANGLE(get); diff --git a/src/p_setup.c b/src/p_setup.c index d65637355..224a31bb4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -614,6 +614,7 @@ static void P_LoadSectors(lumpnum_t lumpnum) ss->special = SHORT(ms->special); ss->tag = SHORT(ms->tag); ss->nexttag = ss->firsttag = -1; + ss->spawn_nexttag = ss->spawn_firsttag = -1; memset(&ss->soundorg, 0, sizeof(ss->soundorg)); ss->validcount = 0; diff --git a/src/p_spec.c b/src/p_spec.c index b04c55881..325dcd5dc 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1519,6 +1519,8 @@ static inline void P_InitTagLists(void) size_t j = (unsigned)sectors[i].tag % numsectors; sectors[i].nexttag = sectors[j].firsttag; sectors[j].firsttag = (INT32)i; + sectors[i].spawn_nexttag = sectors[i].nexttag; + sectors[j].spawn_firsttag = sectors[j].firsttag; } for (i = numlines - 1; i != (size_t)-1; i--) diff --git a/src/r_defs.h b/src/r_defs.h index 3669ec8f3..082bb8cab 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -383,6 +383,7 @@ typedef struct sector_s #endif // these are saved for netgames, so do not let Lua touch these! + INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed // offsets sector spawned with (via linedef type 7) fixed_t spawn_flr_xoffs, spawn_flr_yoffs; From 4d8ca41e653d78a329d3f112d08f55019f237963 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 3 Jan 2017 22:43:46 +0000 Subject: [PATCH 3/4] Fix player colors mysteriously turning red if a resynch occurs outside of CTF/Team Match. Not technically a $$$.sav fix, but still netplay related of course At least, I assume this is how it's happening for some, I haven't been able to get the full info since WHERE IS EVERYBODY? --- src/d_clisrv.c | 21 +++++---------------- src/d_clisrv.h | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7e9dcf8ef..2a2d5fead 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -868,12 +868,13 @@ static inline void resynch_write_others(resynchend_pak *rst) { UINT8 i; - rst->ingame = rst->ctfteam = 0; + rst->ingame = 0; for (i = 0; i < MAXPLAYERS; ++i) { if (!playeringame[i]) { + rst->ctfteam[i] = 0; rst->score[i] = 0; rst->numboxes[i] = 0; rst->totalring[i] = 0; @@ -883,11 +884,8 @@ static inline void resynch_write_others(resynchend_pak *rst) } if (!players[i].spectator) - { rst->ingame |= (1< 1) - rst->ctfteam |= (1<ctfteam[i] = (INT32)LONG(players[i].ctfteam); rst->score[i] = (UINT32)LONG(players[i].score); rst->numboxes[i] = SHORT(players[i].numboxes); rst->totalring[i] = SHORT(players[i].totalring); @@ -904,21 +902,12 @@ static inline void resynch_read_others(resynchend_pak *p) { UINT8 i; UINT32 loc_ingame = (UINT32)LONG(p->ingame); - UINT32 loc_ctfteam = (UINT32)LONG(p->ctfteam); for (i = 0; i < MAXPLAYERS; ++i) { // We don't care if they're in the game or not, just write all the data. - if (loc_ingame & (1<ctfteam[i]); // no, 0 does not mean spectator, at least not in Match players[i].score = (UINT32)LONG(p->score[i]); players[i].numboxes = SHORT(p->numboxes[i]); players[i].totalring = SHORT(p->totalring[i]); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index fe80be1be..02a037387 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -133,7 +133,7 @@ typedef struct fixed_t flagz[2]; UINT32 ingame; // Spectator bit for each player - UINT32 ctfteam; // If not spectator, then which team? + INT32 ctfteam[MAXPLAYERS]; // Which team? (can't be 1 bit, since in regular Match there are no teams) // Resynch game scores and the like all at once UINT32 score[MAXPLAYERS]; // Everyone's score From f2a58a74ef0deb2ce13a3efd871d00e68cc111b4 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 3 Jan 2017 22:48:06 +0000 Subject: [PATCH 4/4] Stupid me --- src/d_clisrv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2a2d5fead..124845563 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -895,7 +895,6 @@ static inline void resynch_write_others(resynchend_pak *rst) // endian safeness rst->ingame = (UINT32)LONG(rst->ingame); - rst->ctfteam = (UINT32)LONG(rst->ctfteam); } static inline void resynch_read_others(resynchend_pak *p)