mirror of
https://github.com/ineedbots/cod2m.git
synced 2025-04-19 16:02:53 +00:00
Added custom gsc calls
This commit is contained in:
parent
aa485079de
commit
e0b9522e34
@ -3,14 +3,47 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
Game::xmethod_t* Script::Player_GetMethod_Hook(const char** name)
|
std::unordered_map<std::string, Game::scr_function_t> Script::CustomScrFunctions;
|
||||||
|
std::unordered_map<std::string, Game::scr_method_t> Script::CustomScrMethods;
|
||||||
|
|
||||||
|
void Script::AddFunction(const char* name, Game::xfunction_t func, int type)
|
||||||
{
|
{
|
||||||
return Game::Player_GetMethod(name);
|
Game::scr_function_t toAdd;
|
||||||
|
toAdd.call = func;
|
||||||
|
toAdd.name = name;
|
||||||
|
toAdd.developer = type;
|
||||||
|
|
||||||
|
CustomScrFunctions.insert_or_assign(name, toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::xfunction_t* Script::Scr_GetFunction_Hook(const char** name, int* isDev)
|
void Script::AddMethod(const char* name, Game::xmethod_t func, int type)
|
||||||
{
|
{
|
||||||
|
Game::scr_method_t toAdd;
|
||||||
|
toAdd.call = func;
|
||||||
|
toAdd.name = name;
|
||||||
|
toAdd.developer = type;
|
||||||
|
|
||||||
|
CustomScrMethods.insert_or_assign(name, toAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
Game::xmethod_t Script::Player_GetMethod_Hook(const char** name)
|
||||||
|
{
|
||||||
|
auto got = CustomScrMethods.find(*name);
|
||||||
|
|
||||||
|
if (got == CustomScrMethods.end())
|
||||||
|
return Game::Player_GetMethod(name);
|
||||||
|
|
||||||
|
return got->second.call;
|
||||||
|
}
|
||||||
|
|
||||||
|
Game::xfunction_t Script::Scr_GetFunction_Hook(const char** name, int* isDev)
|
||||||
|
{
|
||||||
|
auto got = CustomScrFunctions.find(*name);
|
||||||
|
|
||||||
|
if (got == CustomScrFunctions.end())
|
||||||
return Game::Scr_GetFunction(name, isDev);
|
return Game::Scr_GetFunction(name, isDev);
|
||||||
|
|
||||||
|
return got->second.call;
|
||||||
}
|
}
|
||||||
|
|
||||||
Script::Script()
|
Script::Script()
|
||||||
@ -21,5 +54,7 @@ namespace Components
|
|||||||
|
|
||||||
Script::~Script()
|
Script::~Script()
|
||||||
{
|
{
|
||||||
|
CustomScrFunctions.clear();
|
||||||
|
CustomScrMethods.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,15 @@ namespace Components
|
|||||||
class Script : public Component
|
class Script : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static void AddFunction(const char*, Game::xfunction_t, int = 0);
|
||||||
|
static void AddMethod(const char*, Game::xmethod_t, int = 0);
|
||||||
Script();
|
Script();
|
||||||
~Script();
|
~Script();
|
||||||
private:
|
private:
|
||||||
static Game::xmethod_t* Player_GetMethod_Hook(const char**);
|
static std::unordered_map<std::string, Game::scr_function_t> CustomScrFunctions;
|
||||||
static Game::xfunction_t* Scr_GetFunction_Hook(const char**, int*);
|
static std::unordered_map<std::string, Game::scr_method_t> CustomScrMethods;
|
||||||
|
|
||||||
|
static Game::xmethod_t Player_GetMethod_Hook(const char**);
|
||||||
|
static Game::xfunction_t Scr_GetFunction_Hook(const char**, int*);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,10 @@ namespace Game
|
|||||||
|
|
||||||
extern bgs_s** bgs_ptr;
|
extern bgs_s** bgs_ptr;
|
||||||
|
|
||||||
typedef Game::xmethod_t* (Player_GetMethod_t)(const char**);
|
typedef Game::xmethod_t (Player_GetMethod_t)(const char**);
|
||||||
extern Player_GetMethod_t* Player_GetMethod;
|
extern Player_GetMethod_t* Player_GetMethod;
|
||||||
|
|
||||||
typedef Game::xfunction_t* (Scr_GetFunction_t)(const char**, int*);
|
typedef Game::xfunction_t (Scr_GetFunction_t)(const char**, int*);
|
||||||
extern Scr_GetFunction_t* Scr_GetFunction;
|
extern Scr_GetFunction_t* Scr_GetFunction;
|
||||||
|
|
||||||
extern void G_SelectWeaponIndex(int, int);
|
extern void G_SelectWeaponIndex(int, int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user