Softcode mobjinfo and states

This commit is contained in:
LJ Sonic 2024-04-06 23:28:19 +02:00
parent ec5c04f135
commit c02fcc6ce2
11 changed files with 710 additions and 28264 deletions

View file

@ -1164,6 +1164,8 @@ static void IdentifyVersion(void)
snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2waddir);
configfile[sizeof configfile - 1] = '\0';
D_AddFile(&startupwadfiles, va(pandf,srb2waddir, "info.pk3"));
// Load the IWAD
if (srb2wad != NULL && FIL_ReadFileOK(srb2wad))
D_AddFile(&startupwadfiles, srb2wad);
@ -1444,11 +1446,11 @@ void D_SRB2Main(void)
#ifndef DEVELOP // md5s last updated 22/02/20 (ddmmyy)
// Check MD5s of autoloaded files
W_VerifyFileMD5(0, ASSET_HASH_SRB2_PK3); // srb2.pk3
W_VerifyFileMD5(1, ASSET_HASH_ZONES_PK3); // zones.pk3
W_VerifyFileMD5(2, ASSET_HASH_PLAYER_DTA); // player.dta
W_VerifyFileMD5(1, ASSET_HASH_SRB2_PK3); // srb2.pk3
W_VerifyFileMD5(2, ASSET_HASH_ZONES_PK3); // zones.pk3
W_VerifyFileMD5(3, ASSET_HASH_PLAYER_DTA); // player.dta
#ifdef USE_PATCH_DTA
W_VerifyFileMD5(3, ASSET_HASH_PATCH_PK3); // patch.pk3
W_VerifyFileMD5(4, ASSET_HASH_PATCH_PK3); // patch.pk3
#endif
// don't check music.dta because people like to modify it, and it doesn't matter if they do
// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.

View file

@ -84,31 +84,31 @@ static inline int lib_freeslot(lua_State *L)
else if (fastcmp(type, "S"))
{
statenum_t i;
for (i = 0; i < NUMSTATEFREESLOTS; i++)
for (i = 0; i < NUMSTATES; i++)
if (!FREE_STATES[i]) {
CONS_Printf("State S_%s allocated.\n",word);
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_STATES[i],word);
lua_pushinteger(L, S_FIRSTFREESLOT + i);
lua_pushinteger(L, i);
r++;
break;
}
if (i == NUMSTATEFREESLOTS)
if (i == NUMSTATES)
CONS_Alert(CONS_WARNING, "Ran out of free State slots!\n");
}
else if (fastcmp(type, "MT"))
{
mobjtype_t i;
for (i = 0; i < NUMMOBJFREESLOTS; i++)
for (i = 0; i < NUMMOBJTYPES; i++)
if (!FREE_MOBJS[i]) {
CONS_Printf("MobjType MT_%s allocated.\n",word);
FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_MOBJS[i],word);
lua_pushinteger(L, MT_FIRSTFREESLOT + i);
lua_pushinteger(L, i);
r++;
break;
}
if (i == NUMMOBJFREESLOTS)
if (i == NUMMOBJTYPES)
CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n");
}
else if (fastcmp(type, "SKINCOLOR"))
@ -416,36 +416,26 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
}
else if (fastncmp("S_",word,2)) {
p = word+2;
for (i = 0; i < NUMSTATEFREESLOTS; i++) {
for (i = 0; i < NUMSTATES; i++) {
if (!FREE_STATES[i])
break;
if (fastcmp(p, FREE_STATES[i])) {
CacheAndPushConstant(L, word, S_FIRSTFREESLOT+i);
return 1;
}
}
for (i = 0; i < S_FIRSTFREESLOT; i++)
if (fastcmp(p, STATE_LIST[i]+2)) {
CacheAndPushConstant(L, word, i);
return 1;
}
}
return luaL_error(L, "state '%s' does not exist.\n", word);
}
else if (fastncmp("MT_",word,3)) {
p = word+3;
for (i = 0; i < NUMMOBJFREESLOTS; i++) {
for (i = 0; i < NUMMOBJTYPES; i++) {
if (!FREE_MOBJS[i])
break;
if (fastcmp(p, FREE_MOBJS[i])) {
CacheAndPushConstant(L, word, MT_FIRSTFREESLOT+i);
return 1;
}
}
for (i = 0; i < MT_FIRSTFREESLOT; i++)
if (fastcmp(p, MOBJTYPE_LIST[i]+3)) {
CacheAndPushConstant(L, word, i);
return 1;
}
}
return luaL_error(L, "mobjtype '%s' does not exist.\n", word);
}
else if (fastncmp("SPR_",word,4)) {

View file

@ -457,7 +457,7 @@ void readfreeslots(MYFILE *f)
}
else if (fastcmp(type, "S"))
{
for (i = 0; i < NUMSTATEFREESLOTS; i++)
for (i = 0; i < NUMSTATES; i++)
if (!FREE_STATES[i]) {
FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_STATES[i],word);
@ -466,7 +466,7 @@ void readfreeslots(MYFILE *f)
}
else if (fastcmp(type, "MT"))
{
for (i = 0; i < NUMMOBJFREESLOTS; i++)
for (i = 0; i < NUMMOBJTYPES; i++)
if (!FREE_MOBJS[i]) {
FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL);
strcpy(FREE_MOBJS[i],word);
@ -1468,7 +1468,7 @@ void readlevelheader(MYFILE *f, INT32 num)
UINT8 n;
for (n = 0; n < MAXFLICKIES && FLICKYTYPES[n].type; n++)
tmpflickies[n] = FLICKYTYPES[n].type;
tmpflickies[n] = GetMobjTypeByName(FLICKYTYPES[n].type);
header->numFlickies = n;
if (header->numFlickies) // just in case...
@ -4122,15 +4122,12 @@ mobjtype_t get_mobjtype(const char *word)
return atoi(word);
if (fastncmp("MT_",word,3))
word += 3; // take off the MT_
for (i = 0; i < NUMMOBJFREESLOTS; i++) {
for (i = 0; i < NUMMOBJTYPES; i++) {
if (!FREE_MOBJS[i])
break;
if (fastcmp(word, FREE_MOBJS[i]))
return MT_FIRSTFREESLOT+i;
}
for (i = 0; i < MT_FIRSTFREESLOT; i++)
if (fastcmp(word, MOBJTYPE_LIST[i]+3))
return i;
}
deh_warning("Couldn't find mobjtype named 'MT_%s'",word);
return MT_NULL;
}
@ -4142,15 +4139,12 @@ statenum_t get_state(const char *word)
return atoi(word);
if (fastncmp("S_",word,2))
word += 2; // take off the S_
for (i = 0; i < NUMSTATEFREESLOTS; i++) {
for (i = 0; i < NUMSTATES; i++) {
if (!FREE_STATES[i])
break;
if (fastcmp(word, FREE_STATES[i]))
return S_FIRSTFREESLOT+i;
}
for (i = 0; i < S_FIRSTFREESLOT; i++)
if (fastcmp(word, STATE_LIST[i]+2))
return i;
}
deh_warning("Couldn't find state named 'S_%s'",word);
return S_NULL;
}

File diff suppressed because it is too large Load diff

View file

@ -20,8 +20,8 @@
// Free slot names
// The crazy word-reading stuff uses these.
extern char *FREE_STATES[NUMSTATEFREESLOTS];
extern char *FREE_MOBJS[NUMMOBJFREESLOTS];
extern char *FREE_STATES[NUMSTATES];
extern char *FREE_MOBJS[NUMMOBJTYPES];
extern char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
extern bitarray_t used_spr[BIT_ARRAY_SIZE(NUMSPRITEFREESLOTS)]; // Sprite freeslots in use
@ -35,7 +35,7 @@ extern bitarray_t used_spr[BIT_ARRAY_SIZE(NUMSPRITEFREESLOTS)]; // Sprite freesl
struct flickytypes_s {
const char *name;
const mobjtype_t type;
const char *type;
};
#define MAXFLICKIES 64
@ -57,8 +57,6 @@ struct int_const_s {
extern const char NIGHTSGRADE_LIST[];
extern struct flickytypes_s FLICKYTYPES[];
extern actionpointer_t actionpointers[]; // Array mapping action names to action functions.
extern const char *const STATE_LIST[];
extern const char *const MOBJTYPE_LIST[];
extern const char *const MOBJFLAG_LIST[];
extern const char *const MOBJFLAG2_LIST[]; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2
extern const char *const MOBJEFLAG_LIST[];

21328
src/info.c

File diff suppressed because it is too large Load diff

3405
src/info.h

File diff suppressed because it is too large Load diff

View file

@ -256,71 +256,54 @@ static boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
// Set animation state
// The pflags version of this was just as convoluted.
switch(state)
{
case S_PLAY_STND:
case S_PLAY_WAIT:
case S_PLAY_NIGHTS_STAND:
if (state == S_PLAY_STND
|| state == S_PLAY_WAIT
|| state == S_PLAY_NIGHTS_STAND)
player->panim = PA_IDLE;
break;
case S_PLAY_EDGE:
else if (state == S_PLAY_EDGE)
player->panim = PA_EDGE;
break;
case S_PLAY_WALK:
case S_PLAY_SKID:
case S_PLAY_FLOAT:
else if (state == S_PLAY_WALK
|| state == S_PLAY_SKID
|| state == S_PLAY_FLOAT)
player->panim = PA_WALK;
break;
case S_PLAY_RUN:
case S_PLAY_FLOAT_RUN:
else if (state == S_PLAY_RUN
|| state == S_PLAY_FLOAT_RUN)
player->panim = PA_RUN;
break;
case S_PLAY_DASH:
else if (state == S_PLAY_DASH)
player->panim = PA_DASH;
break;
case S_PLAY_PAIN:
case S_PLAY_STUN:
else if (state == S_PLAY_PAIN
|| state == S_PLAY_STUN)
player->panim = PA_PAIN;
break;
case S_PLAY_ROLL:
//case S_PLAY_SPINDASH: -- everyone can ROLL thanks to zoom tubes...
case S_PLAY_NIGHTS_ATTACK:
else if (state == S_PLAY_ROLL
//|| state == S_PLAY_SPINDASH -- everyone can ROLL thanks to zoom tubes...
|| state == S_PLAY_NIGHTS_ATTACK)
player->panim = PA_ROLL;
break;
case S_PLAY_JUMP:
else if (state == S_PLAY_JUMP)
player->panim = PA_JUMP;
break;
case S_PLAY_SPRING:
else if (state == S_PLAY_SPRING)
player->panim = PA_SPRING;
break;
case S_PLAY_FALL:
case S_PLAY_NIGHTS_FLOAT:
else if (state == S_PLAY_FALL
|| state == S_PLAY_NIGHTS_FLOAT)
player->panim = PA_FALL;
break;
case S_PLAY_FLY:
case S_PLAY_FLY_TIRED:
case S_PLAY_SWIM:
case S_PLAY_GLIDE:
case S_PLAY_BOUNCE:
case S_PLAY_BOUNCE_LANDING:
case S_PLAY_TWINSPIN:
else if (state == S_PLAY_FLY
|| state == S_PLAY_FLY_TIRED
|| state == S_PLAY_SWIM
|| state == S_PLAY_GLIDE
|| state == S_PLAY_BOUNCE
|| state == S_PLAY_BOUNCE_LANDING
|| state == S_PLAY_TWINSPIN)
player->panim = PA_ABILITY;
break;
case S_PLAY_SPINDASH: // ...but the act of SPINDASHING is charability2 specific.
case S_PLAY_FIRE:
case S_PLAY_FIRE_FINISH:
case S_PLAY_MELEE:
case S_PLAY_MELEE_FINISH:
case S_PLAY_MELEE_LANDING:
else if (state == S_PLAY_SPINDASH // ...but the act of SPINDASHING is charability2 specific
|| state == S_PLAY_FIRE
|| state == S_PLAY_FIRE_FINISH
|| state == S_PLAY_MELEE
|| state == S_PLAY_MELEE_FINISH
|| state == S_PLAY_MELEE_LANDING)
player->panim = PA_ABILITY2;
break;
case S_PLAY_RIDE:
else if (state == S_PLAY_RIDE)
player->panim = PA_RIDE;
break;
default:
else
player->panim = PA_ETC;
break;
}
if (recursion++) // if recursion detected,
memset(seenstate = tempstate, 0, sizeof tempstate); // clear state table
@ -2245,7 +2228,7 @@ boolean P_ZMovement(mobj_t *mo)
else if (!onground)
P_SlopeLaunch(mo);
}
if (!mo->player && P_CheckDeathPitCollide(mo) && mo->health
&& !(mo->flags & MF_NOCLIPHEIGHT) && !(mo->flags2 & MF2_BOSSDEAD))
{
@ -2938,7 +2921,7 @@ boolean P_SceneryZMovement(mobj_t *mo)
mo->eflags &= ~MFE_APPLYPMOMZ;
}
mo->z += mo->momz;
if (!mo->player && P_CheckDeathPitCollide(mo) && mo->health
&& !(mo->flags & MF_NOCLIPHEIGHT) && !(mo->flags2 & MF2_BOSSDEAD))
{
@ -7347,19 +7330,12 @@ static void P_RosySceneryThink(mobj_t *mobj)
targonground = (P_IsObjectOnGround(mobj->target) && (player->panim == PA_IDLE || player->panim == PA_WALK || player->panim == PA_RUN) && player->mo->z == mobj->z);
love = (player->skin == 0 || player->skin == 5);
switch (stat)
{
case S_ROSY_IDLE1:
case S_ROSY_IDLE2:
case S_ROSY_IDLE3:
case S_ROSY_IDLE4:
if (stat == S_ROSY_IDLE1
|| stat == S_ROSY_IDLE2
|| stat == S_ROSY_IDLE3
|| stat == S_ROSY_IDLE4)
dojump = true;
break;
case S_ROSY_JUMP:
case S_ROSY_PAIN:
// handled above
break;
case S_ROSY_WALK:
else if (stat == S_ROSY_WALK)
{
fixed_t x = mobj->x, y = mobj->y, z = mobj->z;
angle_t angletoplayer = R_PointToAngle2(x, y, mobj->target->x, mobj->target->y);
@ -7423,8 +7399,8 @@ static void P_RosySceneryThink(mobj_t *mobj)
else
dojump = true;
}
break;
case S_ROSY_HUG:
else if (stat == S_ROSY_HUG)
{
if (targonground)
{
player->pflags |= PF_STASIS;
@ -7446,8 +7422,9 @@ static void P_RosySceneryThink(mobj_t *mobj)
A_DoNPCPain(mobj);
mobj->cvmem -= TICRATE;
}
break;
case S_ROSY_STND:
}
else if (stat == S_ROSY_STND)
{
if ((pdist > (mobj->radius + mobj->target->radius + 3*(mobj->scale + mobj->target->scale))))
P_SetMobjState(mobj, (stat = S_ROSY_WALK));
else if (!targonground)
@ -7465,10 +7442,6 @@ static void P_RosySceneryThink(mobj_t *mobj)
mobj->target->momy = mobj->momy;
}
}
break;
case S_ROSY_UNHAPPY:
default:
break;
}
if (stat == S_ROSY_HUG)
@ -10730,7 +10703,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
// Set shadowscale here, before spawn hook so that Lua can change it
mobj->shadowscale = P_DefaultMobjShadowScale(mobj);
// A monitor can't respawn if we're not in multiplayer,
// or if we're in co-op and it's score or a 1up
if (mobj->flags & MF_MONITOR && (!(netgame || multiplayer)

View file

@ -33,7 +33,7 @@
#include "m_cheat.h"
#ifdef PARANOIA
#include "deh_tables.h" // MOBJTYPE_LIST
#include "deh_tables.h"
#endif
tic_t leveltime;
@ -237,12 +237,10 @@ static const char *MobjTypeName(const mobj_t *mobj)
else
return "<Not a mobj>";
if (type < 0 || type >= NUMMOBJTYPES || (type >= MT_FIRSTFREESLOT && !FREE_MOBJS[type - MT_FIRSTFREESLOT]))
if (type < 0 || type >= NUMMOBJTYPES || !FREE_MOBJS[type])
return "<Invalid mobj type>";
else if (type >= MT_FIRSTFREESLOT)
return FREE_MOBJS[type - MT_FIRSTFREESLOT]; // This doesn't include "MT_"...
else
return MOBJTYPE_LIST[type];
return FREE_MOBJS[type]; // This doesn't include "MT_"...
}
static const char *MobjThinkerName(const mobj_t *mobj)

View file

@ -428,7 +428,7 @@ static void SetSkin(player_t *player, INT32 skinnum)
player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem;
player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem;
player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem;
player->revitem = skin->revitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem;
player->followitem = skin->followitem;
if (((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (player->revitem == MT_LHRT || player->spinitem == MT_LHRT || player->thokitem == MT_LHRT)) // Healers can't keep their buff.

View file

@ -65,6 +65,7 @@
#include "i_video.h" // rendermode
#include "md5.h"
#include "lua_script.h"
#include "deh_tables.h"
#ifdef SCANTHINGS
#include "p_setup.h" // P_ScanThings
#endif
@ -206,6 +207,12 @@ static void W_LoadDehackedLumpsPK3(UINT16 wadnum, boolean mainfile)
{
UINT16 posStart, posEnd;
if (!deh_loaded)
{
initfreeslots();
deh_loaded = true;
}
posStart = W_CheckNumForFullNamePK3("Init.lua", wadnum, 0);
if (posStart != INT16_MAX)
{
@ -1011,6 +1018,7 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
}
W_InvalidateLumpnumCache();
CacheInfoConstants();
return wadfile->numlumps;
}
@ -1172,6 +1180,8 @@ UINT16 W_InitFolder(const char *path, boolean mainfile, boolean startup)
W_LoadDehackedLumpsPK3(numwadfiles - 1, mainfile);
W_InvalidateLumpnumCache();
CacheInfoConstants();
return wadfile->numlumps;
}