From ca10b38b9c587c0379bbba29185e7838d16b65a5 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 14:39:16 +0200 Subject: [PATCH 1/7] Add textmap pitch and roll parsing, and mobj pitch and roll variables. --- src/doomdata.h | 2 +- src/lua_mobjlib.c | 15 +++++++++++++++ src/p_mobj.c | 3 +++ src/p_mobj.h | 2 +- src/p_saveg.c | 10 +++++++++- src/p_setup.c | 5 +++++ 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index d9bfb43b1..7708d0bf5 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -198,7 +198,7 @@ typedef struct typedef struct { INT16 x, y; - INT16 angle; + INT16 angle, pitch, roll; UINT16 type; UINT16 options; INT16 z; diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8d2aad91e..81a6cd568 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -31,6 +31,8 @@ enum mobj_e { mobj_snext, mobj_sprev, mobj_angle, + mobj_pitch, + mobj_roll, mobj_rollangle, mobj_sprite, mobj_frame, @@ -97,6 +99,8 @@ static const char *const mobj_opt[] = { "snext", "sprev", "angle", + "pitch", + "roll", "rollangle", "sprite", "frame", @@ -198,6 +202,12 @@ static int mobj_get(lua_State *L) case mobj_angle: lua_pushangle(L, mo->angle); break; + case mobj_pitch: + lua_pushangle(L, mo->pitch); + break; + case mobj_roll: + lua_pushangle(L, mo->roll); + break; case mobj_rollangle: lua_pushangle(L, mo->rollangle); break; @@ -453,6 +463,11 @@ static int mobj_set(lua_State *L) localangle = mo->angle; else if (mo->player == &players[secondarydisplayplayer]) localangle2 = mo->angle; + case mobj_pitch: + mo->pitch = luaL_checkangle(L, 3); + break; + case mobj_roll: + mo->roll = luaL_checkangle(L, 3); break; case mobj_rollangle: mo->rollangle = luaL_checkangle(L, 3); diff --git a/src/p_mobj.c b/src/p_mobj.c index aaea9d49b..65308438b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -13083,6 +13083,9 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, if (doangle) mobj->angle = FixedAngle(mthing->angle << FRACBITS); + mobj->pitch = FixedAngle(mthing->pitch << FRACBITS); + mobj->roll = FixedAngle(mthing->roll << FRACBITS); + mthing->mobj = mobj; // ignore MTF_ flags and return early diff --git a/src/p_mobj.h b/src/p_mobj.h index 5deb288e4..c434bb29f 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -278,7 +278,7 @@ typedef struct mobj_s struct mobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr // More drawing info: to determine current sprite. - angle_t angle; // orientation + angle_t angle, pitch, roll; // orientation angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h diff --git a/src/p_saveg.c b/src/p_saveg.c index 34392886d..51d4b75d9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1451,7 +1451,9 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) if ((mobj->x != mobj->spawnpoint->x << FRACBITS) || (mobj->y != mobj->spawnpoint->y << FRACBITS) || - (mobj->angle != FixedAngle(mobj->spawnpoint->angle*FRACUNIT))) + (mobj->angle != FixedAngle(mobj->spawnpoint->angle*FRACUNIT)) || + (mobj->pitch != FixedAngle(mobj->spawnpoint->pitch*FRACUNIT)) || + (mobj->roll != FixedAngle(mobj->spawnpoint->roll*FRACUNIT)) ) diff |= MD_POS; if (mobj->info->doomednum != mobj->spawnpoint->type) @@ -1633,6 +1635,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->x); WRITEFIXED(save_p, mobj->y); WRITEANGLE(save_p, mobj->angle); + WRITEANGLE(save_p, mobj->pitch); + WRITEANGLE(save_p, mobj->roll); } if (diff & MD_MOM) { @@ -2649,12 +2653,16 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->x = READFIXED(save_p); mobj->y = READFIXED(save_p); mobj->angle = READANGLE(save_p); + mobj->pitch = READANGLE(save_p); + mobj->roll = READANGLE(save_p); } else { mobj->x = mobj->spawnpoint->x << FRACBITS; mobj->y = mobj->spawnpoint->y << FRACBITS; mobj->angle = FixedAngle(mobj->spawnpoint->angle*FRACUNIT); + mobj->pitch = FixedAngle(mobj->spawnpoint->pitch*FRACUNIT); + mobj->roll = FixedAngle(mobj->spawnpoint->roll*FRACUNIT); } if (diff & MD_MOM) { diff --git a/src/p_setup.c b/src/p_setup.c index 9014062bb..1c5119bdd 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1282,6 +1282,7 @@ static void P_LoadThings(UINT8 *data) mt->options = READUINT16(data); mt->extrainfo = (UINT8)(mt->type >> 12); mt->tag = 0; + mt->pitch = mt->roll = 0; mt->type &= 4095; @@ -1568,6 +1569,10 @@ static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) mapthings[i].z = atol(val); else if (fastcmp(param, "angle")) mapthings[i].angle = atol(val); + else if (fastcmp(param, "pitch")) + mapthings[i].pitch = atol(val); + else if (fastcmp(param, "roll")) + mapthings[i].roll = atol(val); else if (fastcmp(param, "type")) mapthings[i].type = atol(val); From 7cf08e1a0857d6cf1124fcd442f60efbd74a6ecb Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 15:18:36 +0200 Subject: [PATCH 2/7] Add mapthing scale support; fields scale, scalex and scaley set the only mapthing scale field alike. --- src/doomdata.h | 1 + src/p_mobj.c | 17 ++++++++++------- src/p_setup.c | 5 ++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index d9bfb43b1..6fe9ea383 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -203,6 +203,7 @@ typedef struct UINT16 options; INT16 z; UINT8 extrainfo; + INT32 scale; INT16 tag; struct mobj_s *mobj; } mapthing_t; diff --git a/src/p_mobj.c b/src/p_mobj.c index aaea9d49b..b6dc04f6f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11616,7 +11616,7 @@ void P_MovePlayerToStarpost(INT32 playernum) mapthing_t *huntemeralds[MAXHUNTEMERALDS]; INT32 numhuntemeralds; -static fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t offset, const boolean flip) +static fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t offset, const boolean flip, const fixed_t scale) { const subsector_t *ss = R_PointInSubsector(x, y); @@ -11627,10 +11627,10 @@ static fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, // Establish height. if (flip) return (ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : ss->sector->ceilingheight) - - offset - mobjinfo[mobjtype].height; + - FixedMul(scale, offset + mobjinfo[mobjtype].height); else return (ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : ss->sector->floorheight) - + offset; + + FixedMul(scale, offset); } static fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y) @@ -11701,7 +11701,7 @@ static fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthin return ONFLOORZ; } - return P_GetMobjSpawnHeight(mobjtype, x, y, offset, flip); + return P_GetMobjSpawnHeight(mobjtype, x, y, offset, flip, mthing->scale); } static boolean P_SpawnNonMobjMapThing(mapthing_t *mthing) @@ -13083,6 +13083,9 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, if (doangle) mobj->angle = FixedAngle(mthing->angle << FRACBITS); + P_SetScale(mobj, mthing->scale); + mobj->destscale = mthing->scale; + mthing->mobj = mobj; // ignore MTF_ flags and return early @@ -13179,7 +13182,7 @@ static void P_SpawnHoopInternal(mapthing_t *mthing, INT32 hoopsize, fixed_t size TVector v, *res; fixed_t x = mthing->x << FRACBITS; fixed_t y = mthing->y << FRACBITS; - fixed_t z = P_GetMobjSpawnHeight(MT_HOOP, x, y, mthing->z << FRACBITS, false); + fixed_t z = P_GetMobjSpawnHeight(MT_HOOP, x, y, mthing->z << FRACBITS, false, mthing->scale); hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); hoopcenter->spawnpoint = mthing; @@ -13324,7 +13327,7 @@ static void P_SpawnItemRow(mapthing_t *mthing, mobjtype_t* itemtypes, UINT8 numi itemtypes[r] = P_GetMobjtypeSubstitute(&dummything, itemtypes[r]); } } - z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, mthing->options & MTF_OBJECTFLIP); + z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, mthing->options & MTF_OBJECTFLIP, mthing->scale); for (r = 0; r < numitems; r++) { @@ -13382,7 +13385,7 @@ static void P_SpawnItemCircle(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 n itemtypes[i] = P_GetMobjtypeSubstitute(&dummything, itemtypes[i]); } } - z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, false); + z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, false, mthing->scale); for (i = 0; i < numitems; i++) { diff --git a/src/p_setup.c b/src/p_setup.c index 9014062bb..e342cd9e6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1281,6 +1281,7 @@ static void P_LoadThings(UINT8 *data) mt->type = READUINT16(data); mt->options = READUINT16(data); mt->extrainfo = (UINT8)(mt->type >> 12); + mt->scale = FRACUNIT; mt->tag = 0; mt->type &= 4095; @@ -1570,7 +1571,8 @@ static void ParseTextmapThingParameter(UINT32 i, char *param, char *val) mapthings[i].angle = atol(val); else if (fastcmp(param, "type")) mapthings[i].type = atol(val); - + else if (fastcmp(param, "scale") || fastcmp(param, "scalex") || fastcmp(param, "scaley")) + mapthings[i].scale = FLOAT_TO_FIXED(atof(val)); // Flags else if (fastcmp(param, "extra") && fastcmp("true", val)) mapthings[i].options |= MTF_EXTRA; @@ -1777,6 +1779,7 @@ static void P_LoadTextmap(void) mt->options = 0; mt->z = 0; mt->extrainfo = 0; + mt->scale = FRACUNIT; mt->tag = 0; mt->mobj = NULL; From 67acb6e498094e6068e0b7ef89e65eb300a7e766 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 15:56:06 +0200 Subject: [PATCH 3/7] Add Lua support. --- src/lua_mobjlib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8d2aad91e..5b3abe828 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -775,6 +775,8 @@ static int mapthing_get(lua_State *L) number = mt->type; else if(fastcmp(field,"options")) number = mt->options; + else if(fastcmp(field,"scale")) + number = mt->scale; else if(fastcmp(field,"z")) number = mt->z; else if(fastcmp(field,"extrainfo")) @@ -814,6 +816,8 @@ static int mapthing_set(lua_State *L) mt->type = (UINT16)luaL_checkinteger(L, 3); else if(fastcmp(field,"options")) mt->options = (UINT16)luaL_checkinteger(L, 3); + else if(fastcmp(field,"scale")) + mt->scale = luaL_checkfixed(L, 3); else if(fastcmp(field,"z")) mt->z = (INT16)luaL_checkinteger(L, 3); else if(fastcmp(field,"extrainfo")) From beb42c9499808eb12fce171e43e4a2281269aee9 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 16:00:57 +0200 Subject: [PATCH 4/7] Move the scale setting code behind the MapthingSpawn hook. --- src/p_mobj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index b6dc04f6f..b8dca52a6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -13077,15 +13077,15 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, mobj = P_SpawnMobj(x, y, z, i); mobj->spawnpoint = mthing; + P_SetScale(mobj, mthing->scale); + mobj->destscale = mthing->scale; + if (!P_SetupSpawnedMapThing(mthing, mobj, &doangle)) return mobj; if (doangle) mobj->angle = FixedAngle(mthing->angle << FRACBITS); - P_SetScale(mobj, mthing->scale); - mobj->destscale = mthing->scale; - mthing->mobj = mobj; // ignore MTF_ flags and return early From 0147320ff49d483b0bc95f479e6355a1603164e2 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 16:05:08 +0200 Subject: [PATCH 5/7] Add missed pitch and roll to precipmobj_t --- src/p_mobj.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.h b/src/p_mobj.h index c434bb29f..c7a36b05c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -398,7 +398,7 @@ typedef struct precipmobj_s struct precipmobj_s **sprev; // killough 8/11/98: change to ptr-to-ptr // More drawing info: to determine current sprite. - angle_t angle; // orientation + angle_t angle, pitch, roll; // orientation angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h From aa98eb5a4c9906a0fb5be70a80ff248943b72db7 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 17:19:04 +0200 Subject: [PATCH 6/7] Add mapthing pitch/roll Lua access as well. --- src/lua_mobjlib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 81a6cd568..02cca8a76 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -786,6 +786,10 @@ static int mapthing_get(lua_State *L) number = mt->y; else if(fastcmp(field,"angle")) number = mt->angle; + else if(fastcmp(field,"pitch")) + number = mt->pitch; + else if(fastcmp(field,"roll")) + number = mt->roll; else if(fastcmp(field,"type")) number = mt->type; else if(fastcmp(field,"options")) @@ -825,6 +829,10 @@ static int mapthing_set(lua_State *L) mt->y = (INT16)luaL_checkinteger(L, 3); else if(fastcmp(field,"angle")) mt->angle = (INT16)luaL_checkinteger(L, 3); + else if(fastcmp(field,"pitch")) + mt->pitch = (INT16)luaL_checkinteger(L, 3); + else if(fastcmp(field,"roll")) + mt->roll = (INT16)luaL_checkinteger(L, 3); else if(fastcmp(field,"type")) mt->type = (UINT16)luaL_checkinteger(L, 3); else if(fastcmp(field,"options")) From 1e4eab77a6c9b801806b9da314f24249cfa1b4a7 Mon Sep 17 00:00:00 2001 From: Nev3r Date: Sun, 19 Apr 2020 18:34:00 +0200 Subject: [PATCH 7/7] Use fixed_t on the mapthing scale for the sake of coherence. --- src/doomdata.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doomdata.h b/src/doomdata.h index 6fe9ea383..37e2186fa 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -23,6 +23,8 @@ // Some global defines, that configure the game. #include "doomdef.h" +#include "m_fixed.h" // See the mapthing_t scale. + // // Map level types. // The following data structures define the persistent format @@ -203,7 +205,7 @@ typedef struct UINT16 options; INT16 z; UINT8 extrainfo; - INT32 scale; + fixed_t scale; INT16 tag; struct mobj_s *mobj; } mapthing_t;