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