Skip to content
Snippets Groups Projects
Select Git revision
  • next default protected
  • wad-start-and-end-from-srb2classic
  • fix-emerald-hunt
  • woof-midi-port
  • fix-1425
  • expose-path-traverse
  • can-hurt-self-score-fix
  • post-mobj-thinker
  • hms-useragent
  • gitlab-ci
  • nightshoopsanity
  • fullscreen-toggle
  • next-test
  • bbox
  • cmake-enable-cxx
  • master
  • more-use-afters-frees
  • cmake-clang-tidy
  • cmake-valgrind
  • font_drawer
  • SRB2_release_2.2.10
  • SRB2_release_2.2.9
  • SRB2_release_2.2.8
  • SRB2_release_2.2.7
  • SRB2_release_2.2.6
  • SRB2_release_2.2.5
  • SRB2_release_2.2.4
  • SRB2_release_2.2.3
  • SRB2_release_2.2.2
  • SRB2_release_2.2.1
  • SRB2_release_2.2.0
  • SRB2_release_2.1.25
  • SRB2_release_2.1.24
  • SRB2_release_2.1.23
  • SRB2_release_2.1.22
  • SRB2_release_2.1.21
  • SRB2_release_2.1.20
  • SRB2_release_2.1.19
  • SRB2_release_2.1.18
  • td-release-v1.0.0
40 results

lua_hooklib.c

Blame
  • Forked from STJr / SRB2
    1883 commits behind the upstream repository.
    lua_hooklib.c 26.42 KiB
    // SONIC ROBO BLAST 2
    //-----------------------------------------------------------------------------
    // Copyright (C) 2012-2016 by John "JTE" Muniz.
    // Copyright (C) 2012-2023 by Sonic Team Junior.
    //
    // This program is free software distributed under the
    // terms of the GNU General Public License, version 2.
    // See the 'LICENSE' file for more details.
    //-----------------------------------------------------------------------------
    /// \file  lua_hooklib.c
    /// \brief hooks for Lua scripting
    
    #include "doomdef.h"
    #include "doomstat.h"
    #include "p_mobj.h"
    #include "g_game.h"
    #include "r_skins.h"
    #include "b_bot.h"
    #include "z_zone.h"
    
    #include "lua_script.h"
    #include "lua_libs.h"
    #include "lua_hook.h"
    #include "lua_hud.h" // hud_running errors
    
    #include "m_perfstats.h"
    #include "netcode/d_netcmd.h" // for cv_perfstats
    #include "i_system.h" // I_GetPreciseTime
    
    /* =========================================================================
                                      ABSTRACTION
       ========================================================================= */
    
    #define LIST(id, M) \
    	static const char * const id [] = { M (TOSTR)  NULL }
    
    LIST   (mobjHookNames,   MOBJ_HOOK_LIST);
    LIST       (hookNames,        HOOK_LIST);
    LIST    (hudHookNames,    HUD_HOOK_LIST);
    LIST (stringHookNames, STRING_HOOK_LIST);
    
    #undef LIST
    
    typedef struct {
    	int numHooks;
    	int *ids;
    } hook_t;
    
    typedef struct {
    	int numGeneric;
    	int ref;
    } stringhook_t;
    
    static hook_t hookIds[HOOK(MAX)];
    static hook_t hudHookIds[HUD_HOOK(MAX)];
    static hook_t mobjHookIds[NUMMOBJTYPES][MOBJ_HOOK(MAX)];
    
    // Lua tables are used to lookup string hook ids.
    static stringhook_t stringHooks[STRING_HOOK(MAX)];
    
    // This will be indexed by hook id, the value of which fetches the registry.
    static int * hookRefs;
    static int   nextid;
    
    // After a hook errors once, don't print the error again.
    static UINT8 * hooksErrored;
    
    static int errorRef;
    
    static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type)