Merge branch 'thingtag' into 'udmf-next'

Implement thing tags

See merge request STJr/SRB2!730
This commit is contained in:
MascaraSnake 2020-01-27 02:34:24 -05:00
commit 85f44fce75
6 changed files with 41 additions and 8 deletions

View File

@ -203,6 +203,7 @@ typedef struct
UINT16 options;
INT16 z;
UINT8 extrainfo;
INT16 tag;
struct mobj_s *mobj;
} mapthing_t;

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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;
}