2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
2022-02-27 07:53:44 -05:00
|
|
|
#include <Game/Structs.hpp>
|
2017-01-20 08:36:52 -05:00
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class Script : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Script();
|
2022-05-05 10:03:14 -04:00
|
|
|
|
2022-04-12 08:34:51 -04:00
|
|
|
static void AddFunction(const char* name, Game::BuiltinFunction func, int type = 0);
|
|
|
|
static void AddMethod(const char* name, Game::BuiltinMethod func, int type = 0);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
2022-02-01 07:29:27 -05:00
|
|
|
static Game::client_t* GetClient(const Game::gentity_t* gentity);
|
2020-07-22 23:36:35 -04:00
|
|
|
|
2022-06-14 14:43:19 -04:00
|
|
|
static const char* GetCodePosForParam(int index);
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
private:
|
|
|
|
static std::string ScriptName;
|
2022-02-23 06:38:37 -05:00
|
|
|
static std::unordered_map<std::string, Game::BuiltinFunctionDef> CustomScrFunctions;
|
|
|
|
static std::unordered_map<std::string, Game::BuiltinMethodDef> CustomScrMethods;
|
2017-01-19 16:23:59 -05:00
|
|
|
static std::vector<std::string> ScriptNameStack;
|
|
|
|
static unsigned short FunctionName;
|
2020-12-04 17:42:47 -05:00
|
|
|
static std::unordered_map<std::string, std::string> ScriptStorage;
|
2020-12-16 22:49:26 -05:00
|
|
|
static std::unordered_map<int, std::string> ScriptBaseProgramNum;
|
2022-06-25 08:22:13 -04:00
|
|
|
static int LastFrameTime;
|
|
|
|
|
|
|
|
static std::vector<int> ScriptMainHandles;
|
|
|
|
static std::vector<int> ScriptInitHandles;
|
|
|
|
|
2021-11-13 08:15:27 -05:00
|
|
|
static std::unordered_map<const char*, const char*> ReplacedFunctions;
|
|
|
|
static const char* ReplacedPos;
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
static void CompileError(unsigned int offset, const char* message, ...);
|
|
|
|
static void PrintSourcePos(const char* filename, unsigned int offset);
|
|
|
|
|
|
|
|
static void FunctionError();
|
|
|
|
static void StoreFunctionNameStub();
|
2022-01-23 14:32:20 -05:00
|
|
|
static void RuntimeError(const char* codePos, unsigned int index, const char* msg, const char* dialogMessage);
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
static void StoreScriptName(const char* name);
|
|
|
|
static void StoreScriptNameStub();
|
|
|
|
|
|
|
|
static void RestoreScriptName();
|
|
|
|
static void RestoreScriptNameStub();
|
|
|
|
|
2022-06-25 08:22:13 -04:00
|
|
|
static void Scr_LoadGameType_Stub();
|
|
|
|
static void Scr_StartupGameType_Stub();
|
|
|
|
static void GScr_LoadGameTypeScript_Stub();
|
2017-04-29 17:08:41 -04:00
|
|
|
|
2022-04-12 08:34:51 -04:00
|
|
|
static Game::BuiltinFunction BuiltIn_GetFunctionStub(const char** pName, int* type);
|
|
|
|
static Game::BuiltinMethod BuiltIn_GetMethod(const char** pName, int* type);
|
2017-05-13 06:09:58 -04:00
|
|
|
|
2020-12-08 17:14:47 -05:00
|
|
|
static void StoreScriptBaseProgramNumStub();
|
|
|
|
static void StoreScriptBaseProgramNum();
|
|
|
|
static void Scr_PrintPrevCodePosStub();
|
|
|
|
static void Scr_PrintPrevCodePos(int);
|
2017-05-14 14:14:52 -04:00
|
|
|
|
2021-11-13 08:22:06 -05:00
|
|
|
static unsigned int SetExpFogStub();
|
2020-12-04 17:42:47 -05:00
|
|
|
|
2021-11-13 08:15:27 -05:00
|
|
|
static void GetReplacedPos(const char* pos);
|
|
|
|
static void SetReplacedPos(const char* what, const char* with);
|
|
|
|
static void VMExecuteInternalStub();
|
|
|
|
|
2020-12-04 17:42:47 -05:00
|
|
|
static void AddFunctions();
|
2017-01-19 16:23:59 -05:00
|
|
|
};
|
|
|
|
}
|