diff --git a/src/doomdata.h b/src/doomdata.h index f6e7cb584..3ac3a9530 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -203,6 +203,7 @@ typedef struct UINT16 options; INT16 z; UINT8 extrainfo; + INT16 tag; struct mobj_s *mobj; } mapthing_t; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 90733b2c6..fb6486c6c 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -788,6 +788,8 @@ static int mapthing_get(lua_State *L) number = mt->z; else if(fastcmp(field,"extrainfo")) number = mt->extrainfo; + else if(fastcmp(field,"tag")) + number = mt->tag; else if(fastcmp(field,"mobj")) { LUA_PushUserdata(L, mt->mobj, META_MOBJ); return 1; @@ -830,6 +832,8 @@ static int mapthing_set(lua_State *L) return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15); mt->extrainfo = (UINT8)extrainfo; } + else if (fastcmp(field,"tag")) + mt->tag = (INT16)luaL_checkinteger(L, 3); else if(fastcmp(field,"mobj")) mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); else diff --git a/src/p_mobj.c b/src/p_mobj.c index a8599ceb5..c2b6c65a1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12643,10 +12643,16 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean break; } case MT_SKYBOX: + if (mthing->tag < 0 || mthing->tag > 15) + { + CONS_Debug(DBG_GAMELOGIC, "P_SetupSpawnedMapThing: Skybox ID %d of mapthing %s is not between 0 and 15!\n", mthing->tag, sizeu1((size_t)(mthing - mapthings))); + break; + } + if (mthing->options & MTF_OBJECTSPECIAL) - skyboxcenterpnts[mthing->extrainfo] = mobj; + skyboxcenterpnts[mthing->tag] = mobj; else - skyboxviewpnts[mthing->extrainfo] = mobj; + skyboxviewpnts[mthing->tag] = mobj; break; case MT_EGGSTATUE: if (mthing->options & MTF_EXTRA) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index cd0a44bb4..133e1b601 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -708,9 +708,9 @@ static void Polyobj_moveToSpawnSpot(mapthing_t *anchor) vertex_t dist, sspot; size_t i; - if (!(po = Polyobj_GetForNum(anchor->angle))) + if (!(po = Polyobj_GetForNum(anchor->tag))) { - CONS_Debug(DBG_POLYOBJ, "Bad polyobject %d for anchor point\n", anchor->angle); + CONS_Debug(DBG_POLYOBJ, "Bad polyobject %d for anchor point\n", anchor->tag); return; } @@ -1562,7 +1562,7 @@ void Polyobj_InitLevel(void) { qitem = (mobjqitem_t *)M_QueueIterator(&spawnqueue); - Polyobj_spawnPolyObj(i, qitem->mo, qitem->mo->spawnpoint->angle); + Polyobj_spawnPolyObj(i, qitem->mo, qitem->mo->spawnpoint->tag); } // move polyobjects to spawn points diff --git a/src/p_setup.c b/src/p_setup.c index 3768bd47c..75923051b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1279,6 +1279,7 @@ static void P_LoadThings(UINT8 *data) mt->type = READUINT16(data); mt->options = READUINT16(data); mt->extrainfo = (UINT8)(mt->type >> 12); + mt->tag = 0; mt->type &= 4095; @@ -1498,6 +1499,8 @@ static void ParseTextmapLinedefParameter(UINT32 i, char *param, char *val) static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) { + if (fastcmp(param, "id")) + mapthings[i].tag = atol(val); if (fastcmp(param, "x")) mapthings[i].x = atol(val); else if (fastcmp(param, "y")) @@ -1690,6 +1693,7 @@ static void P_LoadTextmap(void) mt->options = 0; mt->z = 0; mt->extrainfo = 0; + mt->tag = 0; mt->mobj = NULL; TextmapParse(mapthingsPos[i], i, ParseTextmapThingParameter); @@ -2766,6 +2770,24 @@ static void P_ConvertBinaryMap(void) break; } } + + for (i = 0; i < nummapthings; i++) + { + switch (mapthings[i].type) + { + case 750: + case 760: + case 761: + case 762: + mapthings[i].tag = mapthings[i].angle; + break; + case 780: + mapthings[i].tag = mapthings[i].extrainfo; + break; + default: + break; + } + } } /** Compute MD5 message digest for bytes read from memory source diff --git a/src/p_slopes.c b/src/p_slopes.c index 46feb8c94..10cccd224 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -428,11 +428,11 @@ static pslope_t *MakeViaMapthings(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag if (mt->type != 750) // Haha, I'm hijacking the old Chaos Spawn thingtype for something! continue; - if (!vertices[0] && mt->angle == tag1) + if (!vertices[0] && mt->tag == tag1) vertices[0] = mt; - else if (!vertices[1] && mt->angle == tag2) + else if (!vertices[1] && mt->tag == tag2) vertices[1] = mt; - else if (!vertices[2] && mt->angle == tag3) + else if (!vertices[2] && mt->tag == tag3) vertices[2] = mt; }