diff --git a/src/p_saveg.c b/src/p_saveg.c index 4449a9d2b..ebdc251e6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -798,7 +798,7 @@ static boolean P_AreStringArgsEqual(const line_t *li, const line_t *spawnli) // static void P_NetArchiveWorld(void) { - size_t i; + size_t i, j; INT32 statsec = 0, statline = 0; const line_t *li = lines; const line_t *spawnli = spawnlines; @@ -849,7 +849,7 @@ static void P_NetArchiveWorld(void) if (ss->ceilingpic_angle != spawnss->ceilingpic_angle) diff2 |= SD_CEILANG; - if (ss->tag != spawnss->tag) + if (!Tag_Compare(&ss->tags, &spawnss->tags)) diff2 |= SD_TAG; if (ss->nexttag != spawnss->nexttag || ss->firsttag != spawnss->firsttag) diff3 |= SD_TAGLIST; @@ -912,7 +912,12 @@ static void P_NetArchiveWorld(void) WRITEANGLE(put, ss->floorpic_angle); if (diff2 & SD_CEILANG) WRITEANGLE(put, ss->ceilingpic_angle); - if (diff2 & SD_TAG) // save only the tag + if (diff2 & SD_TAG) + { + WRITEUINT32(put, ss->tags.count); + for (j = 0; j < ss->tags.count; j++) + WRITEINT16(put, ss->tags.tags[j]); + } WRITEINT16(put, ss->tag); if (diff3 & SD_TAGLIST) // save both firsttag and nexttag { // either of these could be changed even if tag isn't @@ -1076,7 +1081,7 @@ static void P_NetArchiveWorld(void) // static void P_NetUnArchiveWorld(void) { - UINT16 i; + UINT16 i, j; line_t *li; side_t *si; UINT8 *get; @@ -1150,6 +1155,17 @@ static void P_NetUnArchiveWorld(void) if (diff2 & SD_CEILANG) sectors[i].ceilingpic_angle = READANGLE(get); if (diff2 & SD_TAG) + { + size_t ncount = READUINT32(get); + if (ncount != sectors[i].tags.count) + { + sectors[i].tags.count = ncount; + sectors[i].tags.tags = Z_Realloc(sectors[i].tags.tags, ncount*sizeof(mtag_t), PU_LEVEL, NULL); + } + + for (j = 0; j < ncount; j++) + sectors[i].tags.tags[j] = READINT16(get); + } sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag if (diff3 & SD_TAGLIST) { diff --git a/src/p_setup.c b/src/p_setup.c index 2cbc2ceae..d92eb929c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -936,7 +936,7 @@ static void P_LoadSectors(UINT8 *data) ss->lightlevel = SHORT(ms->lightlevel); ss->special = SHORT(ms->special); ss->tag = SHORT(ms->tag); - Tag_FSet(&ss->tags, ss->tag); + Tag_FSet(&ss->tags, SHORT(ms->tag)); ss->floor_xoffs = ss->floor_yoffs = 0; ss->ceiling_xoffs = ss->ceiling_yoffs = 0; @@ -1051,7 +1051,7 @@ static void P_LoadLinedefs(UINT8 *data) ld->flags = SHORT(mld->flags); ld->special = SHORT(mld->special); ld->tag = SHORT(mld->tag); - Tag_FSet(&ld->tags, ld->tag); + Tag_FSet(&ld->tags, SHORT(mld->tag)); memset(ld->args, 0, NUMLINEARGS*sizeof(*ld->args)); memset(ld->stringargs, 0x00, NUMLINESTRINGARGS*sizeof(*ld->stringargs)); ld->alpha = FRACUNIT; @@ -1282,7 +1282,7 @@ static void P_LoadThings(UINT8 *data) mt->options = READUINT16(data); mt->extrainfo = (UINT8)(mt->type >> 12); mt->tag = 0; - Tag_FSet(&mt->tags, mt->tag); + Tag_FSet(&mt->tags, 0); mt->type &= 4095; @@ -2921,6 +2921,7 @@ static boolean P_LoadMapFromFile(void) { virtres_t *virt = vres_GetMap(lastloadedmaplumpnum); virtlump_t *textmap = vres_Find(virt, "TEXTMAP"); + size_t i; udmf = textmap != NULL; if (!P_LoadMapData(virt)) @@ -2942,6 +2943,10 @@ static boolean P_LoadMapFromFile(void) memcpy(spawnlines, lines, numlines * sizeof(*lines)); memcpy(spawnsides, sides, numsides * sizeof(*sides)); + for (i = 0; i < numsectors; i++) + if (sectors[i].tags.count) + spawnsectors[i].tags.tags = memcpy(Z_Malloc(sectors[i].tags.count*sizeof(mtag_t), PU_LEVEL, NULL), sectors[i].tags.tags, sectors[i].tags.count*sizeof(mtag_t)); + P_MakeMapMD5(virt, &mapmd5); vres_Free(virt);