Turn dispoffset into a mobj field

This commit is contained in:
lachablock 2022-01-13 18:53:26 +11:00
parent 93512ae9f9
commit d764d68d02
8 changed files with 25 additions and 5 deletions

View file

@ -84,7 +84,7 @@ typedef struct gl_vissprite_s
//Hurdler: 25/04/2000: now support colormap in hardware mode
UINT8 *colormap;
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
INT32 dispoffset; // copy of mobj->dispoffset, affects ordering but not drawing
patch_t *gpatch;
mobj_t *mobj; // NOTE: This is a precipmobj_t if precip is true !!! Watch out.

View file

@ -5052,7 +5052,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
return;
}
dispoffset = thing->info->dispoffset;
dispoffset = thing->dispoffset;
this_scale = FIXED_TO_FLOAT(thing->scale);
spritexscale = FIXED_TO_FLOAT(thing->spritexscale);

View file

@ -96,7 +96,8 @@ enum mobj_e {
mobj_standingslope,
mobj_colorized,
mobj_mirrored,
mobj_shadowscale
mobj_shadowscale,
mobj_dispoffset
};
static const char *const mobj_opt[] = {
@ -173,6 +174,7 @@ static const char *const mobj_opt[] = {
"colorized",
"mirrored",
"shadowscale",
"dispoffset",
NULL};
#define UNIMPLEMENTED luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", mobj_opt[field])
@ -439,6 +441,9 @@ static int mobj_get(lua_State *L)
case mobj_shadowscale:
lua_pushfixed(L, mo->shadowscale);
break;
case mobj_dispoffset:
lua_pushinteger(L, mo->dispoffset);
break;
default: // extra custom variables in Lua memory
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
I_Assert(lua_istable(L, -1));
@ -803,6 +808,9 @@ static int mobj_set(lua_State *L)
case mobj_shadowscale:
mo->shadowscale = luaL_checkfixed(L, 3);
break;
case mobj_dispoffset:
mo->dispoffset = luaL_checkinteger(L, 3);
break;
default:
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
I_Assert(lua_istable(L, -1));

View file

@ -10499,6 +10499,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->reactiontime = info->reactiontime;
mobj->dispoffset = info->dispoffset;
mobj->lastlook = -1; // stuff moved in P_enemy.P_LookForPlayer
// do not set the state with P_SetMobjState,

View file

@ -390,6 +390,7 @@ typedef struct mobj_s
boolean colorized; // Whether the mobj uses the rainbow colormap
boolean mirrored; // The object's rotations will be mirrored left to right, e.g., see frame AL from the right and AR from the left
fixed_t shadowscale; // If this object casts a shadow, and the size relative to radius
INT32 dispoffset; // copy of info->dispoffset, so mobjs can be sorted independently of their type
// WARNING: New fields must be added separately to savegame and Lua.
} mobj_t;

View file

@ -1486,6 +1486,7 @@ typedef enum
MD2_SPRITEXOFFSET = 1<<20,
MD2_SPRITEYOFFSET = 1<<21,
MD2_FLOORSPRITESLOPE = 1<<22,
MD2_DISPOFFSET = 1<<23
} mobj_diff2_t;
typedef enum
@ -1720,6 +1721,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
|| (slope->normal.z != FRACUNIT))
diff2 |= MD2_FLOORSPRITESLOPE;
}
if (mobj->dispoffset != mobj->info->dispoffset)
diff2 |= MD2_DISPOFFSET;
if (diff2 != 0)
diff |= MD_MORE;
@ -1895,6 +1898,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
WRITEFIXED(save_p, slope->normal.y);
WRITEFIXED(save_p, slope->normal.z);
}
if (diff2 & MD2_DISPOFFSET)
WRITEINT32(save_p, mobj->dispoffset);
WRITEUINT32(save_p, mobj->mobjnum);
}
@ -2942,6 +2947,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
slope->normal.y = READFIXED(save_p);
slope->normal.z = READFIXED(save_p);
}
if (diff2 & MD2_DISPOFFSET)
mobj->dispoffset = READINT32(save_p);
else
mobj->dispoffset = mobj->info->dispoffset;
if (diff & MD_REDFLAG)
{

View file

@ -1437,7 +1437,7 @@ static void R_ProjectSprite(mobj_t *thing)
fixed_t paperoffset = 0, paperdistance = 0;
angle_t centerangle = 0;
INT32 dispoffset = thing->info->dispoffset;
INT32 dispoffset = thing->dispoffset;
//SoM: 3/17/2000
fixed_t gz = 0, gzt = 0;

View file

@ -209,7 +209,7 @@ typedef struct vissprite_s
INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH];
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
INT32 dispoffset; // copy of mobj->dispoffset, affects ordering but not drawing
} vissprite_t;
extern UINT32 visspritecount;