mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-06-26 06:11:52 +00:00
Fix bugs related to variable getting and settingfunctions.
Add unit test functions fpr GSC builtins.
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user