aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/squirrel.cpp
diff options
context:
space:
mode:
authorMaya <malte.hoermeyer@web.de>2022-07-09 00:17:05 +0200
committerGitHub <noreply@github.com>2022-07-09 00:17:05 +0200
commit9f8190486e04c66483dc8cd0ca9fd92fc732789a (patch)
treecd65b6d8a74e02ce35cce30e9be706428ac246a6 /NorthstarDedicatedTest/squirrel.cpp
parent5995a7462da970ee2102a0dd0047ebbcef519dd0 (diff)
downloadNorthstarLauncher-9f8190486e04c66483dc8cd0ca9fd92fc732789a.tar.gz
NorthstarLauncher-9f8190486e04c66483dc8cd0ca9fd92fc732789a.zip
Add StringToAsset function to squirrel (#216)
* Add StringToAsset function to squirrel also added better values for return type enum because otherwise asset can't be returned without casting * Formatting * Switched to a template for the stringToAsset function also renamed files but have to do it in 2 commits because git ignores file case * Rename step 2 * change to lowercase in include * changed to lowercase in include inside dllmain
Diffstat (limited to 'NorthstarDedicatedTest/squirrel.cpp')
-rw-r--r--NorthstarDedicatedTest/squirrel.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/squirrel.cpp b/NorthstarDedicatedTest/squirrel.cpp
index b1c5b4a8..d0d54a3a 100644
--- a/NorthstarDedicatedTest/squirrel.cpp
+++ b/NorthstarDedicatedTest/squirrel.cpp
@@ -72,6 +72,9 @@ sq_pushboolType ServerSq_pushbool;
sq_pusherrorType ClientSq_pusherror;
sq_pusherrorType ServerSq_pusherror;
+sq_pushAssetType ClientSq_pushAsset;
+sq_pushAssetType ServerSq_pushAsset;
+
// sq stack get funcs
sq_getstringType ClientSq_getstring;
sq_getstringType ServerSq_getstring;
@@ -136,6 +139,7 @@ void InitialiseClientSquirrel(HMODULE baseAddress)
ClientSq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
ClientSq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
ClientSq_pusherror = (sq_pusherrorType)((char*)baseAddress + 0x8470);
+ ClientSq_pushAsset = (sq_pushAssetType)((char*)baseAddress + 0x3560);
ClientSq_getstring = (sq_getstringType)((char*)baseAddress + 0x60C0);
ClientSq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60E0);
@@ -190,6 +194,7 @@ void InitialiseServerSquirrel(HMODULE baseAddress)
ServerSq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
ServerSq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
ServerSq_pusherror = (sq_pusherrorType)((char*)baseAddress + 0x8440);
+ ServerSq_pushAsset = (sq_pushAssetType)((char*)baseAddress + 0x3560);
ServerSq_getstring = (sq_getstringType)((char*)baseAddress + 0x60A0);
ServerSq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60C0);
@@ -485,4 +490,28 @@ template <ScriptContext context> int64_t RegisterSquirrelFuncHook(void* sqvm, SQ
return ServerRegisterSquirrelFunc(sqvm, funcReg, unknown);
else
return ClientRegisterSquirrelFunc(sqvm, funcReg, unknown);
+}
+
+SQReturnTypeEnum GetReturnTypeEnumFromString(const char* returnTypeString)
+{
+
+ static std::map<std::string, SQReturnTypeEnum> sqEnumStrMap = {
+ {"bool", SqReturnBoolean},
+ {"float", SqReturnFloat},
+ {"vector", SqReturnVector},
+ {"int", SqReturnInteger},
+ {"entity", SqReturnEntity},
+ {"string", SqReturnString},
+ {"array", SqReturnArrays},
+ {"asset", SqReturnAsset},
+ {"table", SqReturnTable}};
+
+ if (sqEnumStrMap.count(returnTypeString))
+ {
+ return sqEnumStrMap[returnTypeString];
+ }
+ else
+ {
+ return SqReturnDefault; // previous default value
+ }
} \ No newline at end of file