mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-04-20 05:25:44 +00:00
Fix bugs related to variable getting and settingfunctions.
Add unit test functions fpr GSC builtins.
This commit is contained in:
parent
b861f5cc56
commit
ffdf2c48ba
@ -159,6 +159,112 @@ namespace gsc
|
||||
printf("Monkey number %d\n", ent.entnum);
|
||||
|
||||
});
|
||||
|
||||
function::add("inttest", []()
|
||||
{
|
||||
int answer = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0);
|
||||
answer += 69;
|
||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, answer);
|
||||
});
|
||||
function::add("floattest", []()
|
||||
{
|
||||
float answer = game::Scr_GetFloat(game::SCRIPTINSTANCE_SERVER, 0);
|
||||
answer *= 69.0f;
|
||||
game::Scr_AddFloat(game::SCRIPTINSTANCE_SERVER, answer);
|
||||
});
|
||||
function::add("stringtest", []()
|
||||
{
|
||||
char* answer = game::Scr_GetString(game::SCRIPTINSTANCE_SERVER, 0);
|
||||
|
||||
std::string string(answer);
|
||||
|
||||
string += " haha funny"s;
|
||||
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, string.data());
|
||||
});
|
||||
function::add("istringtest", []()
|
||||
{
|
||||
const char* answer = game::Scr_GetIString(game::SCRIPTINSTANCE_SERVER, 0);
|
||||
|
||||
std::string string(answer);
|
||||
|
||||
string += " haha funny"s;
|
||||
printf((string + "\n"s).data());
|
||||
game::Scr_AddIString(game::SCRIPTINSTANCE_SERVER, string.data());
|
||||
});
|
||||
|
||||
function::add("vectortest", []()
|
||||
{
|
||||
float answer[3] = {};
|
||||
game::Scr_GetVector(game::SCRIPTINSTANCE_SERVER, 0, answer);
|
||||
|
||||
answer[0] += 69.0f;
|
||||
game::Scr_AddVector(game::SCRIPTINSTANCE_SERVER, answer);
|
||||
});
|
||||
|
||||
function::add("undefinedtest", []()
|
||||
{
|
||||
game::Scr_AddUndefined(game::SCRIPTINSTANCE_SERVER);
|
||||
});
|
||||
|
||||
function::add("pathnodetest", []()
|
||||
{
|
||||
game::pathnode_t* node = game::Scr_GetPathnode(game::SCRIPTINSTANCE_SERVER);
|
||||
|
||||
printf("Node: %d\n" + node->constant.type);
|
||||
printf("Node: %f\n", node->constant.fRadius);
|
||||
|
||||
printf("Node Targetname %s\n", SL_ConvertToString( game::SCRIPTINSTANCE_SERVER, node->constant.targetname));
|
||||
|
||||
printf("0\n");
|
||||
|
||||
game::Scr_AddPathnode(game::SCRIPTINSTANCE_SERVER, node);
|
||||
});
|
||||
|
||||
function::add("numberindexedarraytest", []()
|
||||
{
|
||||
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
|
||||
|
||||
game::Scr_AddFloat(game::SCRIPTINSTANCE_SERVER, 69.0f);
|
||||
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
|
||||
|
||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 420);
|
||||
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
|
||||
|
||||
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, "ree");
|
||||
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
|
||||
});
|
||||
|
||||
function::add("stringindexedarraytest", []()
|
||||
{
|
||||
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
|
||||
|
||||
std::string key1("key1");
|
||||
|
||||
game::Scr_AddFloat(game::SCRIPTINSTANCE_SERVER, 69.0f);
|
||||
game::Scr_AddArrayStringIndexed(game::SCRIPTINSTANCE_SERVER, game::SL_GetStringOfSize(game::SCRIPTINSTANCE_SERVER, key1.data(), 0, key1.length() + 1));
|
||||
|
||||
std::string key2("key2");
|
||||
|
||||
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 420);
|
||||
game::Scr_AddArrayStringIndexed(game::SCRIPTINSTANCE_SERVER, game::SL_GetStringOfSize(game::SCRIPTINSTANCE_SERVER, key2.data(), 0, key2.length() + 1));
|
||||
|
||||
std::string key3("key3");
|
||||
|
||||
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, "ree");
|
||||
game::Scr_AddArrayStringIndexed(game::SCRIPTINSTANCE_SERVER, game::SL_GetStringOfSize(game::SCRIPTINSTANCE_SERVER, key3.data(), 0, key3.length() + 1));
|
||||
});
|
||||
|
||||
method::add("entitytest", [](game::scr_entref_s ent)
|
||||
{
|
||||
if (ent.classnum != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
game::gentity_s* ent2 = &game::g_entities[ent.entnum];
|
||||
|
||||
game::Scr_AddEntity(game::SCRIPTINSTANCE_SERVER, ent2);
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -43,6 +43,8 @@ namespace test
|
||||
{
|
||||
//printf("Biggie Spam McCheese\n");
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -83,7 +83,7 @@ namespace game
|
||||
|
||||
char* Scr_GetString(game::scriptInstance_t inst, unsigned int arg_index)
|
||||
{
|
||||
static const auto call_addr = SELECT(0x0, 0x699F30);
|
||||
static const auto call_addr = SELECT(0x0, 0x69A0D0);
|
||||
char* answer;
|
||||
|
||||
__asm
|
||||
@ -114,7 +114,7 @@ namespace game
|
||||
{
|
||||
static const auto call_addr = SELECT(0x0, 0x69A1A0); //Scr_GetConstIString
|
||||
|
||||
unsigned short id;
|
||||
int id;
|
||||
|
||||
__asm
|
||||
{
|
||||
@ -148,7 +148,7 @@ namespace game
|
||||
push arg_index;
|
||||
mov eax, inst;
|
||||
call call_addr;
|
||||
mov answer, eax;
|
||||
mov answer, cx;
|
||||
add esp, 4;
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ namespace game
|
||||
|
||||
__asm
|
||||
{
|
||||
mov esi, id;
|
||||
mov si, id;
|
||||
mov eax, inst;
|
||||
call call_addr;
|
||||
}
|
||||
@ -232,9 +232,36 @@ namespace game
|
||||
}
|
||||
}
|
||||
|
||||
int Scr_GetEntityId@<eax>(int entNum@<eax>, scriptInstance_t inst, classNum_e classnum, unsigned __int16 clientnum)
|
||||
unsigned int Scr_GetEntityId(scriptInstance_t inst, int entNum, classNum_e classnum, unsigned int clientnum)
|
||||
{
|
||||
static const auto call_addr = SELECT(0x0, 0x692520);
|
||||
|
||||
unsigned int answer;
|
||||
|
||||
__asm
|
||||
{
|
||||
push clientnum;
|
||||
push classnum;
|
||||
push inst;
|
||||
mov eax, entNum;
|
||||
call call_addr;
|
||||
add esp, 0xC;
|
||||
mov answer, eax;
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
void Scr_AddEntityNum(scriptInstance_t inst, unsigned short entid)
|
||||
{
|
||||
static const auto call_addr = SELECT(0x0, 0x69A770);
|
||||
|
||||
__asm
|
||||
{
|
||||
movzx esi, entid;
|
||||
mov eax, inst;
|
||||
call call_addr;
|
||||
}
|
||||
}
|
||||
|
||||
//Only supports getting the first argument as a path node
|
||||
@ -255,9 +282,12 @@ namespace game
|
||||
|
||||
void Scr_AddPathnode(scriptInstance_t inst, pathnode_t* node)
|
||||
{
|
||||
printf("Scr_AddPathnode Targetname %s\n", SL_ConvertToString(game::SCRIPTINSTANCE_SERVER, node->constant.targetname));
|
||||
int entnum = node - (*gameWorldCurrent)->path.nodes;
|
||||
int entid = Scr_GetEntityId(entnum >> 7, SCRIPTINSTANCE_SERVER, CLASS_NUM_PATHNODE, 0);
|
||||
Scr_AddEntityNum(SCRIPTINSTANCE_SERVER, entid);
|
||||
printf("1 entnum: %d\n", entnum);
|
||||
int entid = Scr_GetEntityId(inst, entnum, CLASS_NUM_PATHNODE, 0);
|
||||
printf("2 entid: %d\n", entid);
|
||||
Scr_AddEntityNum(inst, entid);
|
||||
}
|
||||
|
||||
void Scr_MakeArray(scriptInstance_t inst)
|
||||
@ -278,14 +308,14 @@ namespace game
|
||||
__asm
|
||||
{
|
||||
mov edi, inst;
|
||||
mov cx, id;
|
||||
movzx ecx, id;
|
||||
call call_addr;
|
||||
}
|
||||
}
|
||||
|
||||
const char* SL_ConvertToString(scriptInstance_t inst, unsigned short id)
|
||||
const char* SL_ConvertToString(scriptInstance_t inst, int id)
|
||||
{
|
||||
static const auto call_addr = SELECT(0x0, 0x699F30);
|
||||
static const auto call_addr = SELECT(0x0, 0x68D950);
|
||||
const char* answer;
|
||||
|
||||
__asm
|
||||
|
@ -28,27 +28,28 @@ namespace game
|
||||
dvar_s* Dvar_RegisterInt(const char* name, int value, int min, int max, DvarFlags flags, const char* desc);
|
||||
dvar_s* Dvar_RegisterString(const char* name, const char* value, DvarFlags flags, const char* desc);
|
||||
|
||||
int Scr_GetInt(game::scriptInstance_t inst, unsigned int arg_index);
|
||||
void Scr_AddInt(game::scriptInstance_t inst, int value);
|
||||
float Scr_GetFloat(game::scriptInstance_t inst, unsigned int arg_index);
|
||||
void Scr_AddFloat(game::scriptInstance_t inst, float value);
|
||||
char* Scr_GetString(game::scriptInstance_t inst, unsigned int arg_index);
|
||||
void Scr_AddString(game::scriptInstance_t inst, const char* string);
|
||||
const char* Scr_GetIString(game::scriptInstance_t inst, unsigned int arg_index);
|
||||
void Scr_AddIString(game::scriptInstance_t inst, const char* string);
|
||||
unsigned short Scr_GetConstString(game::scriptInstance_t inst, unsigned int arg_index);
|
||||
void Scr_AddConstString(game::scriptInstance_t inst, unsigned short id);
|
||||
void Scr_GetVector(game::scriptInstance_t inst, unsigned int arg_index, float* value);
|
||||
void Scr_AddVector(game::scriptInstance_t inst, float* value);
|
||||
void Scr_AddUndefined(game::scriptInstance_t inst);
|
||||
gentity_s* Scr_GetEntity(unsigned int arg_index);
|
||||
void Scr_AddEntity(game::scriptInstance_t inst, gentity_s* ent);
|
||||
int Scr_GetEntityId(int entNum, scriptInstance_t inst, classNum_e classnum, unsigned __int16 clientnum);
|
||||
pathnode_t* Scr_GetPathnode(scriptInstance_t inst);
|
||||
void Scr_AddPathnode(scriptInstance_t inst, pathnode_t* node);
|
||||
void Scr_MakeArray(scriptInstance_t inst);
|
||||
void Scr_AddArrayStringIndexed(scriptInstance_t inst, unsigned short id);
|
||||
const char* SL_ConvertToString(scriptInstance_t inst, unsigned short id);
|
||||
int Scr_GetInt(game::scriptInstance_t inst, unsigned int arg_index); //testing
|
||||
void Scr_AddInt(game::scriptInstance_t inst, int value); //testing
|
||||
float Scr_GetFloat(game::scriptInstance_t inst, unsigned int arg_index); //testing
|
||||
void Scr_AddFloat(game::scriptInstance_t inst, float value); //testing
|
||||
char* Scr_GetString(game::scriptInstance_t inst, unsigned int arg_index); //testing
|
||||
void Scr_AddString(game::scriptInstance_t inst, const char* string); //testing
|
||||
const char* Scr_GetIString(game::scriptInstance_t inst, unsigned int arg_index); //testing
|
||||
void Scr_AddIString(game::scriptInstance_t inst, const char* string); //testing
|
||||
unsigned short Scr_GetConstString(game::scriptInstance_t inst, unsigned int arg_index); //testing
|
||||
void Scr_AddConstString(game::scriptInstance_t inst, unsigned short id); //testing
|
||||
void Scr_GetVector(game::scriptInstance_t inst, unsigned int arg_index, float* value); //testing
|
||||
void Scr_AddVector(game::scriptInstance_t inst, float* value); //testing
|
||||
void Scr_AddUndefined(game::scriptInstance_t inst); //testing
|
||||
gentity_s* Scr_GetEntity(unsigned int arg_index); //testing
|
||||
void Scr_AddEntity(game::scriptInstance_t inst, gentity_s* ent); //testing
|
||||
unsigned int Scr_GetEntityId(scriptInstance_t inst, int entNum, classNum_e classnum, unsigned int clientnum); //testing
|
||||
void Scr_AddEntityNum(scriptInstance_t inst, unsigned short entid); //testing
|
||||
pathnode_t* Scr_GetPathnode(scriptInstance_t inst); //testing
|
||||
void Scr_AddPathnode(scriptInstance_t inst, pathnode_t* node); //testing
|
||||
void Scr_MakeArray(scriptInstance_t inst); //testing
|
||||
void Scr_AddArrayStringIndexed(scriptInstance_t inst, unsigned short id); //testing
|
||||
const char* SL_ConvertToString(scriptInstance_t inst, int id); //testing
|
||||
|
||||
template <typename T>
|
||||
class symbol
|
||||
|
@ -13,6 +13,8 @@ namespace game
|
||||
struct tagInfo_s;
|
||||
union gentity_u;
|
||||
struct animscripted_s;
|
||||
union pathnode_tree_info_t;
|
||||
struct pathnode_tree_t;
|
||||
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec2_t[2];
|
||||
@ -181,7 +183,7 @@ namespace game
|
||||
SCRIPT_INSTANCE_MAX = 0x2,
|
||||
};
|
||||
|
||||
enum classNum_e
|
||||
enum classNum_e : unsigned int
|
||||
{
|
||||
CLASS_NUM_ENTITY = 0x0,
|
||||
CLASS_NUM_HUDELEM = 0x1,
|
||||
@ -1515,7 +1517,6 @@ namespace game
|
||||
unsigned __int16* nodes;
|
||||
};
|
||||
|
||||
|
||||
union __declspec(align(4)) pathnode_tree_info_t
|
||||
{
|
||||
pathnode_tree_t* child[2];
|
||||
|
@ -10,14 +10,16 @@ namespace game
|
||||
WEAK symbol<dvar_s*(const char* name, dvarType_t type, DvarFlags flags, DvarValue dval, DvarLimits dom, const char* desc)> Dvar_RegisterVariant{ 0x0, 0x5EED90 };
|
||||
|
||||
WEAK symbol<void(scriptInstance_t inst)> Scr_AddArray { 0x0, 0x69AA50 };
|
||||
WEAK symbol<int(scriptInstance_t inst, char* string, int user, unsigned int len)> SL_GetStringOfSize { 0x0, 0x68DE50 };
|
||||
WEAK symbol<unsigned int(scriptInstance_t inst, char* string, int user, unsigned int len)> SL_GetStringOfSize { 0x0, 0x68DE50 };
|
||||
|
||||
// Variables
|
||||
|
||||
WEAK symbol<cmd_function_s*> cmd_functions{ 0x0, 0x1F416F4 };
|
||||
WEAK symbol<CmdArgs> cmd_args{ 0x0, 0x1F41670 };
|
||||
|
||||
WEAK symbol<GameWorldSp*> gameWorldCurrent{0x0, 0x8E1D80 };
|
||||
WEAK symbol<GameWorldSp*> gameWorldCurrent{ 0x0, 0x8E1D80 };
|
||||
|
||||
WEAK symbol<gentity_s> g_entities{ 0x0, 0x176C6F0 };
|
||||
|
||||
namespace plutonium
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user