mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 21:50:48 +00:00
Merge branch 'next' of https://git.do.srb2.org/STJr/SRB2 into expose-selectheading
This commit is contained in:
commit
7fde15d066
12 changed files with 640 additions and 314 deletions
|
@ -277,6 +277,9 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum)
|
|||
if (!luafiletransfers)
|
||||
I_Error("No Lua file transfer\n");
|
||||
|
||||
lua_settop(gL, 0); // Just in case...
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
// Retrieve the callback and push it on the stack
|
||||
lua_pushfstring(gL, FMT_FILECALLBACKID, luafiletransfers->id);
|
||||
lua_gettable(gL, LUA_REGISTRYINDEX);
|
||||
|
@ -304,7 +307,8 @@ void Got_LuaFile(UINT8 **cp, INT32 playernum)
|
|||
lua_pushstring(gL, luafiletransfers->filename);
|
||||
|
||||
// Call the callback
|
||||
LUA_Call(gL, 2);
|
||||
LUA_Call(gL, 2, 0, 1);
|
||||
lua_settop(gL, 0);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
|
|
@ -686,3 +686,12 @@ void LUA_SetActionByName(void *state, const char *actiontocompare)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum actionnum LUA_GetActionNumByName(const char *actiontocompare)
|
||||
{
|
||||
size_t z;
|
||||
for (z = 0; actionpointers[z].name; z++)
|
||||
if (fasticmp(actiontocompare, actionpointers[z].name))
|
||||
return z;
|
||||
return z;
|
||||
}
|
||||
|
|
|
@ -16,4 +16,6 @@
|
|||
boolean LUA_SetLuaAction(void *state, const char *actiontocompare);
|
||||
const char *LUA_GetActionName(void *action);
|
||||
void LUA_SetActionByName(void *state, const char *actiontocompare);
|
||||
enum actionnum LUA_GetActionNumByName(const char *actiontocompare);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
|
||||
#include "deh_tables.h"
|
||||
|
||||
char *FREE_STATES[NUMSTATEFREESLOTS];
|
||||
char *FREE_MOBJS[NUMMOBJFREESLOTS];
|
||||
char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
|
||||
UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
|
||||
|
||||
const char NIGHTSGRADE_LIST[] = {
|
||||
'F', // GRADE_F
|
||||
'E', // GRADE_E
|
||||
|
@ -61,9 +66,8 @@ struct flickytypes_s FLICKYTYPES[] = {
|
|||
{NULL, 0}
|
||||
};
|
||||
|
||||
/** Array mapping action names to action functions.
|
||||
* Names must be in ALL CAPS for case insensitive comparisons.
|
||||
*/
|
||||
// IMPORTANT!
|
||||
// DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONNUM ENUM IN INFO.H
|
||||
actionpointer_t actionpointers[] =
|
||||
{
|
||||
{{A_Explode}, "A_EXPLODE"},
|
||||
|
@ -323,7 +327,7 @@ actionpointer_t actionpointers[] =
|
|||
{{A_PterabyteHover}, "A_PTERABYTEHOVER"},
|
||||
{{A_RolloutSpawn}, "A_ROLLOUTSPAWN"},
|
||||
{{A_RolloutRock}, "A_ROLLOUTROCK"},
|
||||
{{A_DragonbomberSpawn}, "A_DRAGONBOMERSPAWN"},
|
||||
{{A_DragonbomberSpawn}, "A_DRAGONBOMBERSPAWN"},
|
||||
{{A_DragonWing}, "A_DRAGONWING"},
|
||||
{{A_DragonSegment}, "A_DRAGONSEGMENT"},
|
||||
{{A_ChangeHeight}, "A_CHANGEHEIGHT"},
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
#include "doomdef.h" // Constants
|
||||
#include "d_think.h" // actionf_t
|
||||
#include "info.h" // Mobj, state, sprite, etc constants
|
||||
#include "lua_script.h"
|
||||
|
||||
// Free slot names
|
||||
// The crazy word-reading stuff uses these.
|
||||
char *FREE_STATES[NUMSTATEFREESLOTS];
|
||||
char *FREE_MOBJS[NUMMOBJFREESLOTS];
|
||||
char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
|
||||
UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
|
||||
extern char *FREE_STATES[NUMSTATEFREESLOTS];
|
||||
extern char *FREE_MOBJS[NUMMOBJFREESLOTS];
|
||||
extern char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
|
||||
extern UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
|
||||
|
||||
#define initfreeslots() {\
|
||||
memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\
|
||||
|
|
270
src/info.h
270
src/info.h
|
@ -22,6 +22,274 @@
|
|||
// deh_tables.c now has lists for the more named enums! PLEASE keep them up to date!
|
||||
// For great modding!!
|
||||
|
||||
// IMPORTANT!
|
||||
// DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONPOINTERS ARRAY IN DEH_TABLES.C
|
||||
enum actionnum
|
||||
{
|
||||
A_EXPLODE = 0,
|
||||
A_PAIN,
|
||||
A_FALL,
|
||||
A_MONITORPOP,
|
||||
A_GOLDMONITORPOP,
|
||||
A_GOLDMONITORRESTORE,
|
||||
A_GOLDMONITORSPARKLE,
|
||||
A_LOOK,
|
||||
A_CHASE,
|
||||
A_FACESTABCHASE,
|
||||
A_FACESTABREV,
|
||||
A_FACESTABHURL,
|
||||
A_FACESTABMISS,
|
||||
A_STATUEBURST,
|
||||
A_FACETARGET,
|
||||
A_FACETRACER,
|
||||
A_SCREAM,
|
||||
A_BOSSDEATH,
|
||||
A_CUSTOMPOWER,
|
||||
A_GIVEWEAPON,
|
||||
A_RINGBOX,
|
||||
A_INVINCIBILITY,
|
||||
A_SUPERSNEAKERS,
|
||||
A_BUNNYHOP,
|
||||
A_BUBBLESPAWN,
|
||||
A_FANBUBBLESPAWN,
|
||||
A_BUBBLERISE,
|
||||
A_BUBBLECHECK,
|
||||
A_AWARDSCORE,
|
||||
A_EXTRALIFE,
|
||||
A_GIVESHIELD,
|
||||
A_GRAVITYBOX,
|
||||
A_SCORERISE,
|
||||
A_ATTRACTCHASE,
|
||||
A_DROPMINE,
|
||||
A_FISHJUMP,
|
||||
A_THROWNRING,
|
||||
A_SETSOLIDSTEAM,
|
||||
A_UNSETSOLIDSTEAM,
|
||||
A_SIGNSPIN,
|
||||
A_SIGNPLAYER,
|
||||
A_OVERLAYTHINK,
|
||||
A_JETCHASE,
|
||||
A_JETBTHINK,
|
||||
A_JETGTHINK,
|
||||
A_JETGSHOOT,
|
||||
A_SHOOTBULLET,
|
||||
A_MINUSDIGGING,
|
||||
A_MINUSPOPUP,
|
||||
A_MINUSCHECK,
|
||||
A_CHICKENCHECK,
|
||||
A_MOUSETHINK,
|
||||
A_DETONCHASE,
|
||||
A_CAPECHASE,
|
||||
A_ROTATESPIKEBALL,
|
||||
A_SLINGAPPEAR,
|
||||
A_UNIDUSBALL,
|
||||
A_ROCKSPAWN,
|
||||
A_SETFUSE,
|
||||
A_CRAWLACOMMANDERTHINK,
|
||||
A_SMOKETRAILER,
|
||||
A_RINGEXPLODE,
|
||||
A_OLDRINGEXPLODE,
|
||||
A_MIXUP,
|
||||
A_RECYCLEPOWERS,
|
||||
A_BOSS1CHASE,
|
||||
A_FOCUSTARGET,
|
||||
A_BOSS2CHASE,
|
||||
A_BOSS2POGO,
|
||||
A_BOSSZOOM,
|
||||
A_BOSSSCREAM,
|
||||
A_BOSS2TAKEDAMAGE,
|
||||
A_BOSS7CHASE,
|
||||
A_GOOPSPLAT,
|
||||
A_BOSS2POGOSFX,
|
||||
A_BOSS2POGOTARGET,
|
||||
A_BOSSJETFUME,
|
||||
A_EGGMANBOX,
|
||||
A_TURRETFIRE,
|
||||
A_SUPERTURRETFIRE,
|
||||
A_TURRETSTOP,
|
||||
A_JETJAWROAM,
|
||||
A_JETJAWCHOMP,
|
||||
A_POINTYTHINK,
|
||||
A_CHECKBUDDY,
|
||||
A_HOODFIRE,
|
||||
A_HOODTHINK,
|
||||
A_HOODFALL,
|
||||
A_ARROWBONKS,
|
||||
A_SNAILERTHINK,
|
||||
A_SHARPCHASE,
|
||||
A_SHARPSPIN,
|
||||
A_SHARPDECEL,
|
||||
A_CRUSHSTACEANWALK,
|
||||
A_CRUSHSTACEANPUNCH,
|
||||
A_CRUSHCLAWAIM,
|
||||
A_CRUSHCLAWLAUNCH,
|
||||
A_VULTUREVTOL,
|
||||
A_VULTURECHECK,
|
||||
A_VULTUREHOVER,
|
||||
A_VULTUREBLAST,
|
||||
A_VULTUREFLY,
|
||||
A_SKIMCHASE,
|
||||
A_1UPTHINKER,
|
||||
A_SKULLATTACK,
|
||||
A_LOBSHOT,
|
||||
A_FIRESHOT,
|
||||
A_SUPERFIRESHOT,
|
||||
A_BOSSFIRESHOT,
|
||||
A_BOSS7FIREMISSILES,
|
||||
A_BOSS1LASER,
|
||||
A_BOSS4REVERSE,
|
||||
A_BOSS4SPEEDUP,
|
||||
A_BOSS4RAISE,
|
||||
A_SPARKFOLLOW,
|
||||
A_BUZZFLY,
|
||||
A_GUARDCHASE,
|
||||
A_EGGSHIELD,
|
||||
A_SETREACTIONTIME,
|
||||
A_BOSS1SPIKEBALLS,
|
||||
A_BOSS3TAKEDAMAGE,
|
||||
A_BOSS3PATH,
|
||||
A_BOSS3SHOCKTHINK,
|
||||
A_LINEDEFEXECUTE,
|
||||
A_PLAYSEESOUND,
|
||||
A_PLAYATTACKSOUND,
|
||||
A_PLAYACTIVESOUND,
|
||||
A_SPAWNOBJECTABSOLUTE,
|
||||
A_SPAWNOBJECTRELATIVE,
|
||||
A_CHANGEANGLERELATIVE,
|
||||
A_CHANGEANGLEABSOLUTE,
|
||||
A_ROLLANGLE,
|
||||
A_CHANGEROLLANGLERELATIVE,
|
||||
A_CHANGEROLLANGLEABSOLUTE,
|
||||
A_PLAYSOUND,
|
||||
A_FINDTARGET,
|
||||
A_FINDTRACER,
|
||||
A_SETTICS,
|
||||
A_SETRANDOMTICS,
|
||||
A_CHANGECOLORRELATIVE,
|
||||
A_CHANGECOLORABSOLUTE,
|
||||
A_DYE,
|
||||
A_MOVERELATIVE,
|
||||
A_MOVEABSOLUTE,
|
||||
A_THRUST,
|
||||
A_ZTHRUST,
|
||||
A_SETTARGETSTARGET,
|
||||
A_SETOBJECTFLAGS,
|
||||
A_SETOBJECTFLAGS2,
|
||||
A_RANDOMSTATE,
|
||||
A_RANDOMSTATERANGE,
|
||||
A_DUALACTION,
|
||||
A_REMOTEACTION,
|
||||
A_TOGGLEFLAMEJET,
|
||||
A_ORBITNIGHTS,
|
||||
A_GHOSTME,
|
||||
A_SETOBJECTSTATE,
|
||||
A_SETOBJECTTYPESTATE,
|
||||
A_KNOCKBACK,
|
||||
A_PUSHAWAY,
|
||||
A_RINGDRAIN,
|
||||
A_SPLITSHOT,
|
||||
A_MISSILESPLIT,
|
||||
A_MULTISHOT,
|
||||
A_INSTALOOP,
|
||||
A_CUSTOM3DROTATE,
|
||||
A_SEARCHFORPLAYERS,
|
||||
A_CHECKRANDOM,
|
||||
A_CHECKTARGETRINGS,
|
||||
A_CHECKRINGS,
|
||||
A_CHECKTOTALRINGS,
|
||||
A_CHECKHEALTH,
|
||||
A_CHECKRANGE,
|
||||
A_CHECKHEIGHT,
|
||||
A_CHECKTRUERANGE,
|
||||
A_CHECKTHINGCOUNT,
|
||||
A_CHECKAMBUSH,
|
||||
A_CHECKCUSTOMVALUE,
|
||||
A_CHECKCUSVALMEMO,
|
||||
A_SETCUSTOMVALUE,
|
||||
A_USECUSVALMEMO,
|
||||
A_RELAYCUSTOMVALUE,
|
||||
A_CUSVALACTION,
|
||||
A_FORCESTOP,
|
||||
A_FORCEWIN,
|
||||
A_SPIKERETRACT,
|
||||
A_INFOSTATE,
|
||||
A_REPEAT,
|
||||
A_SETSCALE,
|
||||
A_REMOTEDAMAGE,
|
||||
A_HOMINGCHASE,
|
||||
A_TRAPSHOT,
|
||||
A_VILETARGET,
|
||||
A_VILEATTACK,
|
||||
A_VILEFIRE,
|
||||
A_BRAKCHASE,
|
||||
A_BRAKFIRESHOT,
|
||||
A_BRAKLOBSHOT,
|
||||
A_NAPALMSCATTER,
|
||||
A_SPAWNFRESHCOPY,
|
||||
A_FLICKYSPAWN,
|
||||
A_FLICKYCENTER,
|
||||
A_FLICKYAIM,
|
||||
A_FLICKYFLY,
|
||||
A_FLICKYSOAR,
|
||||
A_FLICKYCOAST,
|
||||
A_FLICKYHOP,
|
||||
A_FLICKYFLOUNDER,
|
||||
A_FLICKYCHECK,
|
||||
A_FLICKYHEIGHTCHECK,
|
||||
A_FLICKYFLUTTER,
|
||||
A_FLAMEPARTICLE,
|
||||
A_FADEOVERLAY,
|
||||
A_BOSS5JUMP,
|
||||
A_LIGHTBEAMRESET,
|
||||
A_MINEEXPLODE,
|
||||
A_MINERANGE,
|
||||
A_CONNECTTOGROUND,
|
||||
A_SPAWNPARTICLERELATIVE,
|
||||
A_MULTISHOTDIST,
|
||||
A_WHOCARESIFYOURSONISABEE,
|
||||
A_PARENTTRIESTOSLEEP,
|
||||
A_CRYINGTOMOMMA,
|
||||
A_CHECKFLAGS2,
|
||||
A_BOSS5FINDWAYPOINT,
|
||||
A_DONPCSKID,
|
||||
A_DONPCPAIN,
|
||||
A_PREPAREREPEAT,
|
||||
A_BOSS5EXTRAREPEAT,
|
||||
A_BOSS5CALM,
|
||||
A_BOSS5CHECKONGROUND,
|
||||
A_BOSS5CHECKFALLING,
|
||||
A_BOSS5PINCHSHOT,
|
||||
A_BOSS5MAKEITRAIN,
|
||||
A_BOSS5MAKEJUNK,
|
||||
A_LOOKFORBETTER,
|
||||
A_BOSS5BOMBEXPLODE,
|
||||
A_DUSTDEVILTHINK,
|
||||
A_TNTEXPLODE,
|
||||
A_DEBRISRANDOM,
|
||||
A_TRAINCAMEO,
|
||||
A_TRAINCAMEO2,
|
||||
A_CANARIVOREGAS,
|
||||
A_KILLSEGMENTS,
|
||||
A_SNAPPERSPAWN,
|
||||
A_SNAPPERTHINKER,
|
||||
A_SALOONDOORSPAWN,
|
||||
A_MINECARTSPARKTHINK,
|
||||
A_MODULOTOSTATE,
|
||||
A_LAVAFALLROCKS,
|
||||
A_LAVAFALLLAVA,
|
||||
A_FALLINGLAVACHECK,
|
||||
A_FIRESHRINK,
|
||||
A_SPAWNPTERABYTES,
|
||||
A_PTERABYTEHOVER,
|
||||
A_ROLLOUTSPAWN,
|
||||
A_ROLLOUTROCK,
|
||||
A_DRAGONBOMBERSPAWN,
|
||||
A_DRAGONWING,
|
||||
A_DRAGONSEGMENT,
|
||||
A_CHANGEHEIGHT,
|
||||
NUMACTIONS
|
||||
};
|
||||
|
||||
// IMPORTANT NOTE: If you add/remove from this list of action
|
||||
// functions, don't forget to update them in deh_tables.c!
|
||||
void A_Explode();
|
||||
|
@ -286,6 +554,8 @@ void A_DragonWing();
|
|||
void A_DragonSegment();
|
||||
void A_ChangeHeight();
|
||||
|
||||
extern boolean actionsoverridden[NUMACTIONS];
|
||||
|
||||
// ratio of states to sprites to mobj types is roughly 6 : 1 : 1
|
||||
#define NUMMOBJFREESLOTS 512
|
||||
#define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS
|
||||
|
|
|
@ -40,6 +40,10 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
|||
// like sending random junk lua commands to crash the server
|
||||
|
||||
if (!gL) goto deny;
|
||||
|
||||
lua_settop(gL, 0); // Just in case...
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command
|
||||
if (!lua_istable(gL, -1)) goto deny;
|
||||
|
||||
|
@ -76,7 +80,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
|||
READSTRINGN(*cp, buf, 255);
|
||||
lua_pushstring(gL, buf);
|
||||
}
|
||||
LUA_Call(gL, (int)argc); // argc is 1-based, so this will cover the player we passed too.
|
||||
LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too.
|
||||
return;
|
||||
|
||||
deny:
|
||||
|
@ -98,6 +102,10 @@ void COM_Lua_f(void)
|
|||
INT32 playernum = consoleplayer;
|
||||
|
||||
I_Assert(gL != NULL);
|
||||
|
||||
lua_settop(gL, 0); // Just in case...
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
||||
|
@ -167,7 +175,7 @@ void COM_Lua_f(void)
|
|||
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
||||
for (i = 1; i < COM_Argc(); i++)
|
||||
lua_pushstring(gL, COM_Argv(i));
|
||||
LUA_Call(gL, (int)COM_Argc()); // COM_Argc is 1-based, so this will cover the player we passed too.
|
||||
LUA_Call(gL, (int)COM_Argc(), 0, 1); // COM_Argc is 1-based, so this will cover the player we passed too.
|
||||
}
|
||||
|
||||
// Wrapper for COM_AddCommand
|
||||
|
@ -277,6 +285,9 @@ static void Lua_OnChange(void)
|
|||
|
||||
/// \todo Network this! XD_LUAVAR
|
||||
|
||||
lua_settop(gL, 0); // Just in case...
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
// From CV_OnChange registry field, get the function for this cvar by name.
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
@ -288,7 +299,7 @@ static void Lua_OnChange(void)
|
|||
lua_getfield(gL, -1, cvname); // get consvar_t* userdata.
|
||||
lua_remove(gL, -2); // pop the CV_Vars table.
|
||||
|
||||
LUA_Call(gL, 1); // call function(cvar)
|
||||
LUA_Call(gL, 1, 0, 1); // call function(cvar)
|
||||
lua_pop(gL, 1); // pop CV_OnChange table
|
||||
}
|
||||
|
||||
|
|
|
@ -1261,7 +1261,9 @@ void LUAh_GameHUD(player_t *stplayr)
|
|||
return;
|
||||
|
||||
hud_running = true;
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
@ -1283,9 +1285,9 @@ void LUAh_GameHUD(player_t *stplayr)
|
|||
lua_pushvalue(gL, -5); // graphics library (HUD[1])
|
||||
lua_pushvalue(gL, -5); // stplayr
|
||||
lua_pushvalue(gL, -5); // camera
|
||||
LUA_Call(gL, 3);
|
||||
LUA_Call(gL, 3, 0, 1);
|
||||
}
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
hud_running = false;
|
||||
}
|
||||
|
||||
|
@ -1295,7 +1297,9 @@ void LUAh_ScoresHUD(void)
|
|||
return;
|
||||
|
||||
hud_running = true;
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
@ -1308,9 +1312,9 @@ void LUAh_ScoresHUD(void)
|
|||
lua_pushnil(gL);
|
||||
while (lua_next(gL, -3) != 0) {
|
||||
lua_pushvalue(gL, -3); // graphics library (HUD[1])
|
||||
LUA_Call(gL, 1);
|
||||
LUA_Call(gL, 1, 0, 1);
|
||||
}
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
hud_running = false;
|
||||
}
|
||||
|
||||
|
@ -1320,7 +1324,9 @@ void LUAh_TitleHUD(void)
|
|||
return;
|
||||
|
||||
hud_running = true;
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
@ -1333,9 +1339,9 @@ void LUAh_TitleHUD(void)
|
|||
lua_pushnil(gL);
|
||||
while (lua_next(gL, -3) != 0) {
|
||||
lua_pushvalue(gL, -3); // graphics library (HUD[1])
|
||||
LUA_Call(gL, 1);
|
||||
LUA_Call(gL, 1, 0, 1);
|
||||
}
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
hud_running = false;
|
||||
}
|
||||
|
||||
|
@ -1345,7 +1351,9 @@ void LUAh_TitleCardHUD(player_t *stplayr)
|
|||
return;
|
||||
|
||||
hud_running = true;
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
@ -1366,10 +1374,10 @@ void LUAh_TitleCardHUD(player_t *stplayr)
|
|||
lua_pushvalue(gL, -6); // stplayr
|
||||
lua_pushvalue(gL, -6); // lt_ticker
|
||||
lua_pushvalue(gL, -6); // lt_endtime
|
||||
LUA_Call(gL, 4);
|
||||
LUA_Call(gL, 4, 0, 1);
|
||||
}
|
||||
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
hud_running = false;
|
||||
}
|
||||
|
||||
|
@ -1379,7 +1387,9 @@ void LUAh_IntermissionHUD(void)
|
|||
return;
|
||||
|
||||
hud_running = true;
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
@ -1392,8 +1402,8 @@ void LUAh_IntermissionHUD(void)
|
|||
lua_pushnil(gL);
|
||||
while (lua_next(gL, -3) != 0) {
|
||||
lua_pushvalue(gL, -3); // graphics library (HUD[1])
|
||||
LUA_Call(gL, 1);
|
||||
LUA_Call(gL, 1, 0, 1);
|
||||
}
|
||||
lua_pop(gL, -1);
|
||||
lua_settop(gL, 0);
|
||||
hud_running = false;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "fastcmp.h"
|
||||
#include "info.h"
|
||||
#include "dehacked.h"
|
||||
#include "deh_tables.h"
|
||||
#include "deh_lua.h"
|
||||
#include "p_mobj.h"
|
||||
#include "p_local.h"
|
||||
|
@ -32,7 +33,7 @@
|
|||
extern CV_PossibleValue_t Color_cons_t[];
|
||||
extern UINT8 skincolor_modified[];
|
||||
|
||||
boolean LUA_CallAction(const char *action, mobj_t *actor);
|
||||
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor);
|
||||
state_t *astate;
|
||||
|
||||
enum sfxinfo_read {
|
||||
|
@ -65,6 +66,8 @@ const char *const sfxinfo_wopt[] = {
|
|||
"caption",
|
||||
NULL};
|
||||
|
||||
boolean actionsoverridden[NUMACTIONS] = {false};
|
||||
|
||||
//
|
||||
// Sprite Names
|
||||
//
|
||||
|
@ -377,7 +380,7 @@ static int lib_setSpriteInfo(lua_State *L)
|
|||
if (hud_running)
|
||||
return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!");
|
||||
if (hook_cmd_running)
|
||||
return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!");
|
||||
return luaL_error(L, "Do not alter spriteinfo_t in CMD building code!");
|
||||
|
||||
lua_remove(L, 1);
|
||||
{
|
||||
|
@ -623,6 +626,9 @@ static void A_Lua(mobj_t *actor)
|
|||
boolean found = false;
|
||||
I_Assert(actor != NULL);
|
||||
|
||||
lua_settop(gL, 0); // Just in case...
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
// get the action for this state
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, LREG_STATEACTION);
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
|
@ -651,7 +657,7 @@ static void A_Lua(mobj_t *actor)
|
|||
LUA_PushUserdata(gL, actor, META_MOBJ);
|
||||
lua_pushinteger(gL, var1);
|
||||
lua_pushinteger(gL, var2);
|
||||
LUA_Call(gL, 3);
|
||||
LUA_Call(gL, 3, 0, 1);
|
||||
|
||||
if (found)
|
||||
{
|
||||
|
@ -806,36 +812,33 @@ boolean LUA_SetLuaAction(void *stv, const char *action)
|
|||
return true; // action successfully set.
|
||||
}
|
||||
|
||||
boolean LUA_CallAction(const char *csaction, mobj_t *actor)
|
||||
boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor)
|
||||
{
|
||||
I_Assert(csaction != NULL);
|
||||
I_Assert(actor != NULL);
|
||||
|
||||
if (!gL) // Lua isn't loaded,
|
||||
if (!actionsoverridden[actionnum]) // The action is not overriden,
|
||||
return false; // action not called.
|
||||
|
||||
if (superstack && fasticmp(csaction, superactions[superstack-1])) // the action is calling itself,
|
||||
if (superstack && fasticmp(actionpointers[actionnum].name, superactions[superstack-1])) // the action is calling itself,
|
||||
return false; // let it call the hardcoded function instead.
|
||||
|
||||
lua_pushcfunction(gL, LUA_GetErrorMessage);
|
||||
|
||||
// grab function by uppercase name.
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, LREG_ACTIONS);
|
||||
{
|
||||
char *action = Z_StrDup(csaction);
|
||||
strupr(action);
|
||||
lua_getfield(gL, -1, action);
|
||||
Z_Free(action);
|
||||
}
|
||||
lua_getfield(gL, -1, actionpointers[actionnum].name);
|
||||
lua_remove(gL, -2); // pop LREG_ACTIONS
|
||||
|
||||
if (lua_isnil(gL, -1)) // no match
|
||||
{
|
||||
lua_pop(gL, 1); // pop nil
|
||||
lua_pop(gL, 2); // pop nil and error handler
|
||||
return false; // action not called.
|
||||
}
|
||||
|
||||
if (superstack == MAXRECURSION)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "Max Lua Action recursion reached! Cool it on the calling A_Action functions from inside A_Action functions!\n");
|
||||
lua_pop(gL, 2); // pop function and error handler
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -846,10 +849,11 @@ boolean LUA_CallAction(const char *csaction, mobj_t *actor)
|
|||
lua_pushinteger(gL, var1);
|
||||
lua_pushinteger(gL, var2);
|
||||
|
||||
superactions[superstack] = csaction;
|
||||
superactions[superstack] = actionpointers[actionnum].name;
|
||||
++superstack;
|
||||
|
||||
LUA_Call(gL, 3);
|
||||
LUA_Call(gL, 3, 0, -(2 + 3));
|
||||
lua_pop(gL, -1); // Error handler
|
||||
|
||||
--superstack;
|
||||
superactions[superstack] = NULL;
|
||||
|
|
|
@ -134,6 +134,19 @@ int LUA_GetErrorMessage(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex)
|
||||
{
|
||||
int err = lua_pcall(L, nargs, nresults, errorhandlerindex);
|
||||
|
||||
if (err)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "%s\n", lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
// Moved here from lib_getenum.
|
||||
int LUA_PushGlobals(lua_State *L, const char *word)
|
||||
{
|
||||
|
@ -427,6 +440,7 @@ static int setglobals(lua_State *L)
|
|||
{
|
||||
const char *csname;
|
||||
char *name;
|
||||
enum actionnum actionnum;
|
||||
|
||||
lua_remove(L, 1); // we're not gonna be using _G
|
||||
csname = lua_tostring(L, 1);
|
||||
|
@ -445,6 +459,10 @@ static int setglobals(lua_State *L)
|
|||
lua_rawset(L, -3); // rawset doesn't trigger this metatable again.
|
||||
// otherwise we would've used setfield, obviously.
|
||||
|
||||
actionnum = LUA_GetActionNumByName(name);
|
||||
if (actionnum < NUMACTIONS)
|
||||
actionsoverridden[actionnum] = true;
|
||||
|
||||
Z_Free(name);
|
||||
return 0;
|
||||
}
|
||||
|
@ -476,7 +494,7 @@ static void LUA_ClearState(void)
|
|||
|
||||
// open base libraries
|
||||
luaL_openlibs(L);
|
||||
lua_pop(L, -1);
|
||||
lua_settop(L, 0);
|
||||
|
||||
// make LREG_VALID table for all pushed userdata cache.
|
||||
lua_newtable(L);
|
||||
|
@ -679,7 +697,7 @@ fixed_t LUA_EvalMath(const char *word)
|
|||
*b = '\0';
|
||||
|
||||
// eval string.
|
||||
lua_pop(L, -1);
|
||||
lua_settop(L, 0);
|
||||
if (luaL_dostring(L, buf))
|
||||
{
|
||||
p = lua_tostring(L, -1);
|
||||
|
|
|
@ -40,6 +40,7 @@ void LUA_ClearExtVars(void);
|
|||
extern INT32 lua_lumploading; // is LUA_LoadLump being called?
|
||||
|
||||
int LUA_GetErrorMessage(lua_State *L);
|
||||
int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex);
|
||||
void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults);
|
||||
#ifdef LUA_ALLOW_BYTECODE
|
||||
void LUA_DumpFile(const char *filename);
|
||||
|
@ -65,14 +66,6 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc);
|
|||
// Console wrapper
|
||||
void COM_Lua_f(void);
|
||||
|
||||
#define LUA_Call(L,a)\
|
||||
{\
|
||||
if (lua_pcall(L, a, 0, 0)) {\
|
||||
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(L,-1));\
|
||||
lua_pop(L, 1);\
|
||||
}\
|
||||
}
|
||||
|
||||
#define LUA_ErrInvalid(L, type) luaL_error(L, "accessed " type " doesn't exist anymore, please check 'valid' before using " type ".");
|
||||
|
||||
// Deprecation warnings
|
||||
|
|
522
src/p_enemy.c
522
src/p_enemy.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue