aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/squirrel.h
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.h
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.h')
-rw-r--r--NorthstarDedicatedTest/squirrel.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/NorthstarDedicatedTest/squirrel.h b/NorthstarDedicatedTest/squirrel.h
index d6dfcc57..cbdf0c8c 100644
--- a/NorthstarDedicatedTest/squirrel.h
+++ b/NorthstarDedicatedTest/squirrel.h
@@ -18,6 +18,20 @@ const SQRESULT SQRESULT_NOTNULL = 1;
typedef SQInteger (*SQFunction)(void* sqvm);
+enum SQReturnTypeEnum
+{
+ SqReturnFloat = 0x1,
+ SqReturnVector = 0x3,
+ SqReturnInteger = 0x5,
+ SqReturnBoolean = 0x6,
+ SqReturnEntity = 0xD,
+ SqReturnString = 0x21,
+ SqReturnDefault = 0x20,
+ SqReturnArrays = 0x25,
+ SqReturnAsset = 0x28,
+ SqReturnTable = 0x26,
+};
+
struct CompileBufferState
{
const SQChar* buffer;
@@ -43,7 +57,7 @@ struct SQFuncRegistration
__int32 devLevel;
const char* shortNameMaybe;
__int32 unknown2;
- __int32 returnTypeEnum;
+ SQReturnTypeEnum returnTypeEnum;
__int32* externalBufferPointer;
__int64 externalBufferSize;
__int64 unknown3;
@@ -53,10 +67,12 @@ struct SQFuncRegistration
SQFuncRegistration()
{
memset(this, 0, sizeof(SQFuncRegistration));
- this->returnTypeEnum = 32;
+ this->returnTypeEnum = SqReturnDefault;
}
};
+SQReturnTypeEnum GetReturnTypeEnumFromString(const char* returnTypeString);
+
// core sqvm funcs
typedef SQRESULT (*sq_compilebufferType)(void* sqvm, CompileBufferState* compileBuffer, const char* file, int a1, ScriptContext a2);
extern sq_compilebufferType ClientSq_compilebuffer;
@@ -105,6 +121,10 @@ typedef SQInteger (*sq_pusherrorType)(void* sqvm, const SQChar* error);
extern sq_pusherrorType ClientSq_pusherror;
extern sq_pusherrorType ServerSq_pusherror;
+typedef SQRESULT (*sq_pushAssetType)(void* sqvm, const SQChar* assetName, SQInteger nameLength);
+extern sq_pushAssetType ServerSq_pushAsset;
+extern sq_pushAssetType ClientSq_pushAsset;
+
// sq stack get funcs
typedef const SQChar* (*sq_getstringType)(void* sqvm, SQInteger stackpos);
extern sq_getstringType ClientSq_getstring;
@@ -277,6 +297,7 @@ template <ScriptContext context> class SquirrelManager
reg->returnTypeString = new char[returnType.size() + 1];
strcpy((char*)reg->returnTypeString, returnType.c_str());
+ reg->returnTypeEnum = GetReturnTypeEnumFromString(returnType.c_str());
reg->argTypes = new char[argTypes.size() + 1];
strcpy((char*)reg->argTypes, argTypes.c_str());