mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Savegame netsync for sector colormaps; add spawn_midmap and co for comparison
This commit is contained in:
parent
032f95803d
commit
002f1bad8f
4 changed files with 60 additions and 22 deletions
|
@ -487,10 +487,16 @@ static void P_NetUnArchivePlayers(void)
|
|||
#define SD_FYOFFS 0x02
|
||||
#define SD_CXOFFS 0x04
|
||||
#define SD_CYOFFS 0x08
|
||||
#define SD_TAG 0x10
|
||||
#define SD_FLOORANG 0x20
|
||||
#define SD_CEILANG 0x40
|
||||
#define SD_TAGLIST 0x80
|
||||
#define SD_FLOORANG 0x10
|
||||
#define SD_CEILANG 0x20
|
||||
#define SD_TAG 0x40
|
||||
#define SD_DIFF3 0x80
|
||||
|
||||
// diff3 flags
|
||||
#define SD_TAGLIST 0x01
|
||||
#define SD_BOTTOMMAP 0x02
|
||||
#define SD_MIDMAP 0x04
|
||||
#define SD_TOPMAP 0x08
|
||||
|
||||
#define LD_FLAG 0x01
|
||||
#define LD_SPECIAL 0x02
|
||||
|
@ -523,7 +529,7 @@ static void P_NetArchiveWorld(void)
|
|||
mapsidedef_t *msd;
|
||||
maplinedef_t *mld;
|
||||
const sector_t *ss = sectors;
|
||||
UINT8 diff, diff2;
|
||||
UINT8 diff, diff2, diff3;
|
||||
|
||||
WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD);
|
||||
put = save_p;
|
||||
|
@ -550,7 +556,7 @@ static void P_NetArchiveWorld(void)
|
|||
|
||||
for (i = 0; i < numsectors; i++, ss++, ms++)
|
||||
{
|
||||
diff = diff2 = 0;
|
||||
diff = diff2 = diff3 = 0;
|
||||
if (ss->floorheight != SHORT(ms->floorheight)<<FRACBITS)
|
||||
diff |= SD_FLOORHT;
|
||||
if (ss->ceilingheight != SHORT(ms->ceilingheight)<<FRACBITS)
|
||||
|
@ -584,7 +590,13 @@ 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;
|
||||
diff3 |= SD_TAGLIST;
|
||||
if (ss->bottommap != ss->spawn_bottommap)
|
||||
diff3 |= SD_BOTTOMMAP;
|
||||
if (ss->midmap != ss->spawn_midmap)
|
||||
diff3 |= SD_MIDMAP;
|
||||
if (ss->topmap != ss->spawn_topmap)
|
||||
diff3 |= SD_TOPMAP;
|
||||
|
||||
// Check if any of the sector's FOFs differ from how they spawned
|
||||
if (ss->ffloors)
|
||||
|
@ -601,6 +613,9 @@ static void P_NetArchiveWorld(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (diff3)
|
||||
diff2 |= SD_DIFF3;
|
||||
|
||||
if (diff2)
|
||||
diff |= SD_DIFF2;
|
||||
|
||||
|
@ -612,6 +627,8 @@ static void P_NetArchiveWorld(void)
|
|||
WRITEUINT8(put, diff);
|
||||
if (diff & SD_DIFF2)
|
||||
WRITEUINT8(put, diff2);
|
||||
if (diff2 & SD_DIFF3)
|
||||
WRITEUINT8(put, diff3);
|
||||
if (diff & SD_FLOORHT)
|
||||
WRITEFIXED(put, ss->floorheight);
|
||||
if (diff & SD_CEILHT)
|
||||
|
@ -632,17 +649,23 @@ static void P_NetArchiveWorld(void)
|
|||
WRITEFIXED(put, ss->ceiling_xoffs);
|
||||
if (diff2 & SD_CYOFFS)
|
||||
WRITEFIXED(put, ss->ceiling_yoffs);
|
||||
if (diff2 & SD_TAG) // save only the tag
|
||||
WRITEINT16(put, ss->tag);
|
||||
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
|
||||
if (diff2 & SD_TAG) // save only the tag
|
||||
WRITEINT16(put, ss->tag);
|
||||
if (diff3 & 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);
|
||||
}
|
||||
if (diff3 & SD_BOTTOMMAP)
|
||||
WRITEINT32(put, ss->bottommap);
|
||||
if (diff3 & SD_MIDMAP)
|
||||
WRITEINT32(put, ss->midmap);
|
||||
if (diff3 & SD_TOPMAP)
|
||||
WRITEINT32(put, ss->topmap);
|
||||
|
||||
// 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
|
||||
|
@ -680,7 +703,7 @@ static void P_NetArchiveWorld(void)
|
|||
// do lines
|
||||
for (i = 0; i < numlines; i++, mld++, li++)
|
||||
{
|
||||
diff = diff2 = 0;
|
||||
diff = diff2 = diff3 = 0;
|
||||
|
||||
if (li->special != SHORT(mld->special))
|
||||
diff |= LD_SPECIAL;
|
||||
|
@ -772,7 +795,7 @@ static void P_NetUnArchiveWorld(void)
|
|||
line_t *li;
|
||||
side_t *si;
|
||||
UINT8 *get;
|
||||
UINT8 diff, diff2;
|
||||
UINT8 diff, diff2, diff3;
|
||||
|
||||
if (READUINT32(save_p) != ARCHIVEBLOCK_WORLD)
|
||||
I_Error("Bad $$$.sav at archive block World");
|
||||
|
@ -794,6 +817,10 @@ static void P_NetUnArchiveWorld(void)
|
|||
diff2 = READUINT8(get);
|
||||
else
|
||||
diff2 = 0;
|
||||
if (diff2 & SD_DIFF3)
|
||||
diff3 = READUINT8(get);
|
||||
else
|
||||
diff3 = 0;
|
||||
|
||||
if (diff & SD_FLOORHT)
|
||||
sectors[i].floorheight = READFIXED(get);
|
||||
|
@ -822,17 +849,23 @@ static void P_NetUnArchiveWorld(void)
|
|||
sectors[i].ceiling_xoffs = READFIXED(get);
|
||||
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)
|
||||
{
|
||||
sectors[i].firsttag = READINT32(get);
|
||||
sectors[i].nexttag = READINT32(get);
|
||||
}
|
||||
if (diff2 & SD_FLOORANG)
|
||||
sectors[i].floorpic_angle = READANGLE(get);
|
||||
if (diff2 & SD_CEILANG)
|
||||
sectors[i].ceilingpic_angle = READANGLE(get);
|
||||
if (diff2 & SD_TAG)
|
||||
sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag
|
||||
if (diff3 & SD_TAGLIST)
|
||||
{
|
||||
sectors[i].firsttag = READINT32(get);
|
||||
sectors[i].nexttag = READINT32(get);
|
||||
}
|
||||
if (diff3 & SD_BOTTOMMAP)
|
||||
sectors[i].bottommap = READINT32(get);
|
||||
if (diff3 & SD_MIDMAP)
|
||||
sectors[i].midmap = READINT32(get);
|
||||
if (diff3 & SD_TOPMAP)
|
||||
sectors[i].topmap = READINT32(get);
|
||||
|
||||
if (diff & SD_FFLOORS)
|
||||
{
|
||||
|
@ -891,6 +924,9 @@ static void P_NetUnArchiveWorld(void)
|
|||
diff2 = READUINT8(get);
|
||||
else
|
||||
diff2 = 0;
|
||||
|
||||
diff3 = 0;
|
||||
|
||||
if (diff & LD_FLAG)
|
||||
li->flags = READINT16(get);
|
||||
if (diff & LD_SPECIAL)
|
||||
|
|
|
@ -719,6 +719,7 @@ static void P_LoadRawSectors(UINT8 *data, size_t i)
|
|||
ss->floorpic_angle = ss->ceilingpic_angle = 0;
|
||||
ss->spawn_flrpic_angle = ss->spawn_ceilpic_angle = 0;
|
||||
ss->bottommap = ss->midmap = ss->topmap = -1;
|
||||
ss->spawn_bottommap = ss->spawn_midmap = ss->spawn_topmap = -1;
|
||||
ss->gravity = NULL;
|
||||
ss->cullheight = NULL;
|
||||
ss->verticalflip = false;
|
||||
|
@ -1477,7 +1478,7 @@ static void P_LoadRawSideDefs2(void *data)
|
|||
{
|
||||
if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')
|
||||
{
|
||||
sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
||||
sec->midmap = sec->spawn_midmap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
||||
msd->bottomtexture);
|
||||
sd->toptexture = sd->bottomtexture = 0;
|
||||
}
|
||||
|
@ -1507,7 +1508,7 @@ static void P_LoadRawSideDefs2(void *data)
|
|||
{
|
||||
char *col;
|
||||
|
||||
sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
||||
sec->midmap = sec->spawn_midmap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
||||
msd->bottomtexture);
|
||||
sd->toptexture = sd->bottomtexture = 0;
|
||||
#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0)
|
||||
|
|
|
@ -6769,7 +6769,7 @@ void P_SpawnSpecials(INT32 fromnetsave)
|
|||
|
||||
case 606: // HACK! Copy colormaps. Just plain colormaps.
|
||||
for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;)
|
||||
sectors[s].midmap = lines[i].frontsector->midmap;
|
||||
sectors[s].midmap = sectors[s].spawn_midmap = lines[i].frontsector->midmap;
|
||||
break;
|
||||
|
||||
#ifdef ESLOPE // Slope copy specials. Handled here for sanity.
|
||||
|
|
|
@ -385,6 +385,7 @@ typedef struct sector_s
|
|||
|
||||
// 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
|
||||
INT32 spawn_bottommap, spawn_midmap, spawn_topmap;
|
||||
|
||||
// offsets sector spawned with (via linedef type 7)
|
||||
fixed_t spawn_flr_xoffs, spawn_flr_yoffs;
|
||||
|
|
Loading…
Reference in a new issue