diff --git a/code/game/g_active.c b/code/game/g_active.c index 55bfa8d..fdf1bf7 100644 --- a/code/game/g_active.c +++ b/code/game/g_active.c @@ -6,6 +6,8 @@ #include "g_spawn.h" #include "g_cmds.h" #include "g_items.h" +#include "g_combat.h" +#include "g_lua.h" extern void ammo_station_finish_spawning ( gentity_t *self ); diff --git a/code/game/g_client.c b/code/game/g_client.c index 5a726cf..646a91a 100644 --- a/code/game/g_client.c +++ b/code/game/g_client.c @@ -8,6 +8,7 @@ #include "g_main.h" #include "g_spawn.h" #include "g_items.h" +#include "g_lua.h" reconData_t g_reconData[MAX_RECON_NAMES]; //!< recon data for a limited ammount of clients int32_t g_reconNum; diff --git a/code/game/g_cmds.c b/code/game/g_cmds.c index 4771bc2..67ebc50 100644 --- a/code/game/g_cmds.c +++ b/code/game/g_cmds.c @@ -7,6 +7,7 @@ #include "g_main.h" #include "g_client.h" #include "g_logger.h" +#include "g_lua.h" //#include @@ -7444,7 +7445,6 @@ static void Cmd_Camtest_f(gentity_t *ent) { void Cmd_CamtestEnd_f(gentity_t *ent) { //Cinematic_DeactivateCameraMode(ent); - G_LuaNumThreads(); } // END CCAM diff --git a/code/game/g_combat.c b/code/game/g_combat.c index b300499..d1d4cf2 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -2,12 +2,14 @@ // // g_combat.c +#include "g_combat.h" #include "g_local.h" #include "g_breakable.h" //RPG-X | GSIO01 | 09/05/2009: needed by G_Repair #include "g_main.h" #include "g_cmds.h" #include "g_client.h" #include "g_items.h" +#include "g_lua.h" /* ============ diff --git a/code/game/g_combat.h b/code/game/g_combat.h index 0f43bdc..b0aaad9 100644 --- a/code/game/g_combat.h +++ b/code/game/g_combat.h @@ -1,2 +1,8 @@ +#ifndef G_COMBAT_H_ +#define G_COMBAT_H_ -int borgAdaptHits[WP_NUM_WEAPONS]; +#include "g_local.h" + +qboolean IsBorg( gentity_t* ent ); //GSIO01 | 08/05/2009 + +#endif /* G_COMBAT_H_ */ \ No newline at end of file diff --git a/code/game/g_local.h b/code/game/g_local.h index 65fd9ee..cccc014 100644 --- a/code/game/g_local.h +++ b/code/game/g_local.h @@ -2136,162 +2136,6 @@ int BotAIStartFrame( int time ); // g_lua.c // #ifdef G_LUA -/** - * Lua hook for InitGame event. - * - * \param leveltime level time the event occured - * \param radomseed a random seed - * \param restart is this a map restart? - */ -void LuaHook_G_InitGame(int leveltime, unsigned int randomseed, int restart); - -/** - * Lua hook for Shutdown event. - * - * \param restart is this a map restart? - */ -void LuaHook_G_Shutdown(int restart); - -/** - * Lua hook for RunFrame event. - * - * \param leveltime the level time - */ -void LuaHook_G_RunFrame(int leveltime); - -/** - * Lua hook for G_Print function. - * - * \param text text to be printed - */ -void LuaHook_G_Print(char* text); -/** - * Lua hook for G_ClientPrint function. - * - * \param text text to be printed - * \param entnum entity index for client the text gets send to - */ -void LuaHook_G_ClientPrint(char* text, int entnum); - -/** - * Lua hook for entity think function function. - * - * \param function name of function to call - * \param entnum entity index of entity the think function was called on - * \return success or fail - */ -void LuaHook_G_EntityThink(char* function, int entnum); - -/** - * Lua hook for entity touch function function. - * - * \param function name of function to call - * \param entnum entity index of entity the touch function was called on - * \param othernum entiy index of touching entity - * \return success or fail - */ -void LuaHook_G_EntityTouch(char* function, int entnum, int othernum); - -/** - * Lua hook for entity use function. - * - * \param function name of function to call - * \param entnum entity index of entity the use function was called on - * \param othernum entity index of other entity - * \param activatornum entity index of activating entity - */ -void LuaHook_G_EntityUse(char* function, int entnum, int othernum, int activatornum); - -/** - * Lua hook for entity hurt function. - * - * \param function name of function to call - * \param entnum entity index of entity the hurt function was called on - * \param inflictornum entity index of inflictor - * \param attackernum entity index of attacker - */ -void LuaHook_G_EntityHurt(char* function, int entnum, int inflictornum, int attackernum); - -/** - * Lua hook for entity die function. - * - * \param function name of function to call - * \param entnum entity index of entity the die function was called on - * \param inflictornum entity index of inflictor - * \param attackernum entity index of attacker - * \param dmg ammount of damage - * \param mod means of death - */ -void LuaHook_G_EntityDie(char* function, int entnum, int inflictornum, int attackernum, int dmg, int mod); - -/** - * Lua hook for entity free function. - * - * \param function name of function to call - * \param entnum entity index of entity the free function was called on - */ -void LuaHook_G_EntityFree(char* function, int entnum); - -/** - * Lua hook for entity trigger function. - * - * \param function name of function to call - * \param entnum entity index of entity the trigger function was called on - * \param othernum entity index of triggering entity - */ -void LuaHook_G_EntityTrigger(char* function, int entnum, int othernum); - -/** - * Lua hook for entity spawn function. - * - * \param function name of function to call - * \param entnum entity index of entity the spawn function was called on - */ -void LuaHook_G_EntitySpawn(char* function, int entnum); - -/** - * Lua hook for entity reached function. - * - * \param function name of function to call - * \param entnum entity index of entity the reached function was called on - */ -void LuaHook_G_EntityReached(char* function, int entnum); - -/** - * Lua hook for entity reached angular function. - * - * \param function name of function to call - * \param entnum entity index of entity the reached angular function was called on - */ -void LuaHook_G_EntityReachedAngular(char* function, int entnum); - -/** - * Output information about lua threads. - */ -void G_LuaNumThreads(void); - -/** - * Collect garbage in lua. - */ -void G_LuaCollectGarbage(void); - -/** - * Show lua status information. - * - * \param ent client - */ -void G_LuaStatus(gentity_t* ent); - -/** - * Initialize lua. - */ -qboolean G_LuaInit(void); - -/** - * Shutdown lua. - */ -void G_LuaShutdown(void); - extern vmCvar_t g_debugLua; extern vmCvar_t lua_allowedModules; extern vmCvar_t lua_modules; @@ -3003,13 +2847,6 @@ void trap_BotResetWeaponState(int weaponstate); int trap_GeneticParentsAndChildSelection(int numranks, float* ranks, int* parent1, int* parent2, int* child); -/*=================*\ -|| RPG-X Functions || -\*=================*/ - -qboolean LineOfSight( gentity_t* ent1, gentity_t* ent2 ); //Phenix -qboolean IsBorg( gentity_t* ent ); //GSIO01 | 08/05/2009 - //OUMS /** \typedef holoData_t diff --git a/code/game/g_lua.c b/code/game/g_lua.c index 82ce1ec..5b5d4c2 100644 --- a/code/game/g_lua.c +++ b/code/game/g_lua.c @@ -1079,8 +1079,9 @@ void LuaHook_G_EntitySpawn(char *function, int entnum) } } -void G_LuaNumThreads(void) { +unsigned G_LuaNumThreads(void) { lvm_t* vm = lVM[0]; + unsigned num = 0; if(vm) { lua_State *p; @@ -1098,8 +1099,11 @@ void G_LuaNumThreads(void) { } } } - G_Printf("Total lua thread count: %d\n", cnt); + + num = cnt; } + + return num; } void G_LuaCollectGarbage(void) { diff --git a/code/game/g_lua.h b/code/game/g_lua.h index ef4d326..ca836f0 100644 --- a/code/game/g_lua.h +++ b/code/game/g_lua.h @@ -41,18 +41,18 @@ typedef struct { extern lvm_t *lVM[NUM_VMS]; -void QDECL LUA_DEBUG(const char *fmt, ...); -void QDECL LUA_LOG(const char *fmt, ...); -qboolean G_LuaInit(void); -qboolean G_LuaCall(lvm_t *vm, char *func, int nargs, int nresults); -qboolean G_LuaResume(lvm_t *vm, lua_State *T, char *func, int nargs); -qboolean G_LuaGetFunction(lvm_t *vm, char *name); -qboolean G_LuaGetFunctionT(lua_State *T, char *name); -qboolean G_LuaStartVM(lvm_t *vm); -void G_LuaStopVM(lvm_t *vm); -void G_LuaShutdown(void); -void G_LuaStatus(gentity_t *ent); -lvm_t *G_LuaGetVM(lua_State *L); +void QDECL LUA_DEBUG(const char *fmt, ...); +void QDECL LUA_LOG(const char *fmt, ...); +qboolean G_LuaInit(void); +qboolean G_LuaCall(lvm_t *vm, char *func, int nargs, int nresults); +qboolean G_LuaResume(lvm_t *vm, lua_State *T, char *func, int nargs); +qboolean G_LuaGetFunction(lvm_t *vm, char *name); +qboolean G_LuaGetFunctionT(lua_State *T, char *name); +qboolean G_LuaStartVM(lvm_t *vm); +void G_LuaStopVM(lvm_t *vm); +void G_LuaShutdown(void); +void G_LuaStatus(gentity_t *ent); +lvm_t* G_LuaGetVM(lua_State *L); // lua_entity.c typedef struct { @@ -97,4 +97,137 @@ int Luaopen_Cinematic(lua_State *L); // lua_sound.c int Luaopen_Sound(lua_State *L); +/** + * Lua hook for InitGame event. + * + * \param leveltime level time the event occured + * \param radomseed a random seed + * \param restart is this a map restart? + */ +void LuaHook_G_InitGame(int leveltime, unsigned int randomseed, int restart); + +/** + * Lua hook for Shutdown event. + * + * \param restart is this a map restart? + */ +void LuaHook_G_Shutdown(int restart); + +/** + * Lua hook for RunFrame event. + * + * \param leveltime the level time + */ +void LuaHook_G_RunFrame(int leveltime); + +/** + * Lua hook for G_Print function. + * + * \param text text to be printed + */ +void LuaHook_G_Print(char* text); +/** + * Lua hook for G_ClientPrint function. + * + * \param text text to be printed + * \param entnum entity index for client the text gets send to + */ +void LuaHook_G_ClientPrint(char* text, int entnum); + +/** + * Lua hook for entity think function function. + * + * \param function name of function to call + * \param entnum entity index of entity the think function was called on + * \return success or fail + */ +void LuaHook_G_EntityThink(char* function, int entnum); + +/** + * Lua hook for entity touch function function. + * + * \param function name of function to call + * \param entnum entity index of entity the touch function was called on + * \param othernum entiy index of touching entity + * \return success or fail + */ +void LuaHook_G_EntityTouch(char* function, int entnum, int othernum); + +/** + * Lua hook for entity use function. + * + * \param function name of function to call + * \param entnum entity index of entity the use function was called on + * \param othernum entity index of other entity + * \param activatornum entity index of activating entity + */ +void LuaHook_G_EntityUse(char* function, int entnum, int othernum, int activatornum); + +/** + * Lua hook for entity hurt function. + * + * \param function name of function to call + * \param entnum entity index of entity the hurt function was called on + * \param inflictornum entity index of inflictor + * \param attackernum entity index of attacker + */ +void LuaHook_G_EntityHurt(char* function, int entnum, int inflictornum, int attackernum); + +/** + * Lua hook for entity die function. + * + * \param function name of function to call + * \param entnum entity index of entity the die function was called on + * \param inflictornum entity index of inflictor + * \param attackernum entity index of attacker + * \param dmg ammount of damage + * \param mod means of death + */ +void LuaHook_G_EntityDie(char* function, int entnum, int inflictornum, int attackernum, int dmg, int mod); + +/** + * Lua hook for entity free function. + * + * \param function name of function to call + * \param entnum entity index of entity the free function was called on + */ +void LuaHook_G_EntityFree(char* function, int entnum); + +/** + * Lua hook for entity trigger function. + * + * \param function name of function to call + * \param entnum entity index of entity the trigger function was called on + * \param othernum entity index of triggering entity + */ +void LuaHook_G_EntityTrigger(char* function, int entnum, int othernum); + +/** + * Lua hook for entity spawn function. + * + * \param function name of function to call + * \param entnum entity index of entity the spawn function was called on + */ +void LuaHook_G_EntitySpawn(char* function, int entnum); + +/** + * Lua hook for entity reached function. + * + * \param function name of function to call + * \param entnum entity index of entity the reached function was called on + */ +void LuaHook_G_EntityReached(char* function, int entnum); + +/** + * Lua hook for entity reached angular function. + * + * \param function name of function to call + * \param entnum entity index of entity the reached angular function was called on + */ +void LuaHook_G_EntityReachedAngular(char* function, int entnum); + +unsigned G_LuaNumThreads(void); + +void G_LuaCollectGarbage(void); + #endif diff --git a/code/game/g_main.c b/code/game/g_main.c index d4f9723..441522f 100644 --- a/code/game/g_main.c +++ b/code/game/g_main.c @@ -12,6 +12,7 @@ #include "bg_misc.h" #include "g_logger.h" #include "g_usable.h" +#include "g_lua.h" extern void BG_LoadItemNames(void); extern qboolean BG_ParseRankNames ( char* fileName, rankNames_t rankNames[], size_t size ); diff --git a/code/game/g_mover.c b/code/game/g_mover.c index a31b437..26a91c3 100644 --- a/code/game/g_mover.c +++ b/code/game/g_mover.c @@ -4,6 +4,8 @@ #include "g_local.h" #include "g_client.h" #include "g_spawn.h" +#include "g_combat.h" +#include "g_lua.h" extern qboolean G_CallSpawn(gentity_t *ent); diff --git a/code/game/g_spawn.c b/code/game/g_spawn.c index b1df080..6aa62e8 100644 --- a/code/game/g_spawn.c +++ b/code/game/g_spawn.c @@ -4,6 +4,7 @@ #include "g_local.h" #include "g_spawn.h" #include "g_items.h" +#include "g_lua.h" field_t fields[] = { {"classname", FOFS(classname), F_LSTRING}, diff --git a/code/game/g_svcmds.c b/code/game/g_svcmds.c index 5f3fbc9..84de798 100644 --- a/code/game/g_svcmds.c +++ b/code/game/g_svcmds.c @@ -5,6 +5,7 @@ #include "g_local.h" #include "g_cmds.h" +#include "g_lua.h" /* ============================================================================== diff --git a/code/game/g_target.c b/code/game/g_target.c index 3100b4e..b1e947b 100644 --- a/code/game/g_target.c +++ b/code/game/g_target.c @@ -5,6 +5,7 @@ #include "bg_misc.h" #include "g_spawn.h" #include "g_client.h" +#include "g_lua.h" //#include //TiM : WTF? diff --git a/code/game/g_trigger.c b/code/game/g_trigger.c index 1f76fb0..553f0a8 100644 --- a/code/game/g_trigger.c +++ b/code/game/g_trigger.c @@ -5,6 +5,7 @@ #include "g_local.h" #include "g_spawn.h" #include "g_client.h" +#include "g_lua.h" /*these look weired... I'd rather replace them with streight numbers. #define SF_SPECTATOR (1<<0) diff --git a/code/game/g_utils.c b/code/game/g_utils.c index 64a4bda..d3e33ba 100644 --- a/code/game/g_utils.c +++ b/code/game/g_utils.c @@ -7,6 +7,7 @@ #include "g_local.h" +#include "g_lua.h" /** * \brief Data structure for a singele shader remap. diff --git a/code/game/g_utils.h b/code/game/g_utils.h new file mode 100644 index 0000000..fd53647 --- /dev/null +++ b/code/game/g_utils.h @@ -0,0 +1,8 @@ +#ifndef G_UTILS_H_ +#define G_UTILS_H_ + +#include "g_local.h" + +qboolean LineOfSight( gentity_t* ent1, gentity_t* ent2 ); //Phenix + +#endif /* G_UTILS_H_ */