aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-10-21 00:17:48 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-10-21 00:17:48 +0100
commit0c729c609cd052f4e720ce885c1d5322b63c9edd (patch)
tree1e9c47ab45d9d684a8c0994e6331a6311a2ceaed
parent841881af9ea6ec73b1d505d5a8f7c1f766273724 (diff)
downloadNorthstarLauncher-0c729c609cd052f4e720ce885c1d5322b63c9edd.tar.gz
NorthstarLauncher-0c729c609cd052f4e720ce885c1d5322b63c9edd.zip
fix up squirrel sq_getentity defs
-rw-r--r--NorthstarDLL/miscserverscript.cpp4
-rw-r--r--NorthstarDLL/r2server.h11
-rw-r--r--NorthstarDLL/serverchathooks.cpp10
-rw-r--r--NorthstarDLL/squirrel.cpp16
-rw-r--r--NorthstarDLL/squirrel.h17
5 files changed, 43 insertions, 15 deletions
diff --git a/NorthstarDLL/miscserverscript.cpp b/NorthstarDLL/miscserverscript.cpp
index ca2a5b61..758323ef 100644
--- a/NorthstarDLL/miscserverscript.cpp
+++ b/NorthstarDLL/miscserverscript.cpp
@@ -20,7 +20,7 @@ SQRESULT SQ_EarlyWritePlayerPersistenceForLeave(HSquirrelVM* sqvm)
return SQRESULT_NOTNULL;
}
- R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex];
+ R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1];
if (g_pServerAuthentication->m_PlayerAuthenticationData.find(pClient) == g_pServerAuthentication->m_PlayerAuthenticationData.end())
{
g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, false);
@@ -51,7 +51,7 @@ SQRESULT SQ_IsPlayerLocalPlayer(HSquirrelVM* sqvm)
return SQRESULT_NOTNULL;
}
- R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex];
+ R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1];
g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, !strcmp(R2::g_pLocalPlayerUserID, pClient->m_UID));
return SQRESULT_NOTNULL;
}
diff --git a/NorthstarDLL/r2server.h b/NorthstarDLL/r2server.h
index 1abe822d..235dde7f 100644
--- a/NorthstarDLL/r2server.h
+++ b/NorthstarDLL/r2server.h
@@ -1,5 +1,7 @@
#pragma once
+#include "vector.h"
+
// use the R2 namespace for game funcs
namespace R2
{
@@ -14,8 +16,13 @@ namespace R2
uint32_t m_nPlayerIndex;
// +0x5C
- char pad1[0x1C75];
- char m_communityClanTag[16];
+ char pad1[0x1C34];
+ bool m_hasBadReputation; // 0x1C90
+ char m_communityName[64]; // 0x1C91
+ char m_communityClanTag[16]; // 0x1CD1
+ char m_factionName[16]; // 0x1CE1
+ char m_hardwareIcon[16]; // 0x1CF1
+ bool m_happyHourActive; // 0x1D01
};
#pragma pack(pop)
diff --git a/NorthstarDLL/serverchathooks.cpp b/NorthstarDLL/serverchathooks.cpp
index 1dd05830..31844c67 100644
--- a/NorthstarDLL/serverchathooks.cpp
+++ b/NorthstarDLL/serverchathooks.cpp
@@ -37,7 +37,7 @@ void(__fastcall* MessageWriteBool)(bool bValue);
bool bShouldCallSayTextHook = false;
// clang-format off
AUTOHOOK(_CServerGameDLL__OnReceivedSayTextMessage, server.dll + 0x1595C0,
-void, __fastcall, (CServerGameDLL* self, unsigned int senderPlayerId, const char* text, bool isTeam))
+void, __fastcall, (CServerGameDLL* self, unsigned int nSenderPlayerIndex, const char* text, bool isTeam))
// clang-format on
{
// MiniHook doesn't allow calling the base function outside of anywhere but the hook function.
@@ -45,23 +45,23 @@ void, __fastcall, (CServerGameDLL* self, unsigned int senderPlayerId, const char
if (bShouldCallSayTextHook)
{
bShouldCallSayTextHook = false;
- _CServerGameDLL__OnReceivedSayTextMessage(self, senderPlayerId, text, isTeam);
+ _CServerGameDLL__OnReceivedSayTextMessage(self, nSenderPlayerIndex, text, isTeam);
return;
}
// check chat ratelimits
- if (!g_pServerLimits->CheckChatLimits(&R2::g_pClientArray[senderPlayerId - 1]))
+ if (!g_pServerLimits->CheckChatLimits(&R2::g_pClientArray[nSenderPlayerIndex - 1]))
return;
if (g_pSquirrel<ScriptContext::SERVER>->setupfunc("CServerGameDLL_ProcessMessageStartThread") != SQRESULT_ERROR)
{
- g_pSquirrel<ScriptContext::SERVER>->pushinteger(g_pSquirrel<ScriptContext::SERVER>->m_pSQVM->sqvm, (int)senderPlayerId - 1);
+ g_pSquirrel<ScriptContext::SERVER>->pushinteger(g_pSquirrel<ScriptContext::SERVER>->m_pSQVM->sqvm, (int)nSenderPlayerIndex - 1);
g_pSquirrel<ScriptContext::SERVER>->pushstring(g_pSquirrel<ScriptContext::SERVER>->m_pSQVM->sqvm, text);
g_pSquirrel<ScriptContext::SERVER>->pushbool(g_pSquirrel<ScriptContext::SERVER>->m_pSQVM->sqvm, isTeam);
g_pSquirrel<ScriptContext::SERVER>->call(g_pSquirrel<ScriptContext::SERVER>->m_pSQVM->sqvm, 3);
}
else
- _CServerGameDLL__OnReceivedSayTextMessage(self, senderPlayerId, text, isTeam);
+ _CServerGameDLL__OnReceivedSayTextMessage(self, nSenderPlayerIndex, text, isTeam);
}
void ChatSendMessage(unsigned int playerIndex, const char* text, bool isTeam)
diff --git a/NorthstarDLL/squirrel.cpp b/NorthstarDLL/squirrel.cpp
index 23935827..d130aed7 100644
--- a/NorthstarDLL/squirrel.cpp
+++ b/NorthstarDLL/squirrel.cpp
@@ -489,7 +489,7 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module))
g_pSquirrel<ScriptContext::CLIENT>->__sq_getuserdata = module.Offset(0x63D0).As<sq_getuserdataType>();
g_pSquirrel<ScriptContext::CLIENT>->__sq_getvector = module.Offset(0x6140).As<sq_getvectorType>();
g_pSquirrel<ScriptContext::CLIENT>->__sq_getthisentity = module.Offset(0x12F80).As<sq_getthisentityType>();
- g_pSquirrel<ScriptContext::CLIENT>->__sq_getentity = module.Offset(0x6140).As<sq_getentityType>();
+ g_pSquirrel<ScriptContext::CLIENT>->__sq_getobject = module.Offset(0x6160).As<sq_getobjectType>();
g_pSquirrel<ScriptContext::UI>->__sq_getstring = g_pSquirrel<ScriptContext::CLIENT>->__sq_getstring;
g_pSquirrel<ScriptContext::UI>->__sq_getinteger = g_pSquirrel<ScriptContext::CLIENT>->__sq_getinteger;
g_pSquirrel<ScriptContext::UI>->__sq_getfloat = g_pSquirrel<ScriptContext::CLIENT>->__sq_getfloat;
@@ -499,13 +499,20 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module))
g_pSquirrel<ScriptContext::UI>->__sq_getuserdata = g_pSquirrel<ScriptContext::CLIENT>->__sq_getuserdata;
g_pSquirrel<ScriptContext::UI>->__sq_getvector = g_pSquirrel<ScriptContext::CLIENT>->__sq_getvector;
g_pSquirrel<ScriptContext::UI>->__sq_getthisentity = g_pSquirrel<ScriptContext::CLIENT>->__sq_getthisentity;
- g_pSquirrel<ScriptContext::CLIENT>->__sq_getentity = g_pSquirrel<ScriptContext::CLIENT>->__sq_getentity;
+ g_pSquirrel<ScriptContext::UI>->__sq_getobject = g_pSquirrel<ScriptContext::CLIENT>->__sq_getobject;
g_pSquirrel<ScriptContext::CLIENT>->__sq_createuserdata = module.Offset(0x38D0).As<sq_createuserdataType>();
g_pSquirrel<ScriptContext::CLIENT>->__sq_setuserdatatypeid = module.Offset(0x6490).As<sq_setuserdatatypeidType>();
g_pSquirrel<ScriptContext::UI>->__sq_createuserdata = g_pSquirrel<ScriptContext::CLIENT>->__sq_createuserdata;
g_pSquirrel<ScriptContext::UI>->__sq_setuserdatatypeid = g_pSquirrel<ScriptContext::CLIENT>->__sq_setuserdatatypeid;
+ g_pSquirrel<ScriptContext::CLIENT>->__sq_GetEntityConstant_CBaseEntity = module.Offset(0x3E49B0).As<sq_GetEntityConstantType>();
+ g_pSquirrel<ScriptContext::CLIENT>->__sq_getentityfrominstance = module.Offset(0x114F0).As<sq_getentityfrominstanceType>();
+ g_pSquirrel<ScriptContext::UI>->__sq_GetEntityConstant_CBaseEntity =
+ g_pSquirrel<ScriptContext::CLIENT>->__sq_GetEntityConstant_CBaseEntity;
+ g_pSquirrel<ScriptContext::UI>->__sq_getentityfrominstance = g_pSquirrel<ScriptContext::CLIENT>->__sq_getentityfrominstance;
+
+
MAKEHOOK(
module.Offset(0x108E0),
&RegisterSquirrelFunctionHook<ScriptContext::CLIENT>,
@@ -568,11 +575,14 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module))
g_pSquirrel<ScriptContext::SERVER>->__sq_getvector = module.Offset(0x6120).As<sq_getvectorType>();
g_pSquirrel<ScriptContext::SERVER>->__sq_get = module.Offset(0x7C00).As<sq_getType>();
g_pSquirrel<ScriptContext::SERVER>->__sq_getthisentity = module.Offset(0x203B0).As<sq_getthisentityType>();
- g_pSquirrel<ScriptContext::SERVER>->__sq_getentity = module.Offset(0x6120).As<sq_getentityType>();
+ g_pSquirrel<ScriptContext::SERVER>->__sq_getobject = module.Offset(0x6140).As<sq_getobjectType>();
g_pSquirrel<ScriptContext::SERVER>->__sq_createuserdata = module.Offset(0x38D0).As<sq_createuserdataType>();
g_pSquirrel<ScriptContext::SERVER>->__sq_setuserdatatypeid = module.Offset(0x6470).As<sq_setuserdatatypeidType>();
+ g_pSquirrel<ScriptContext::SERVER>->__sq_GetEntityConstant_CBaseEntity = module.Offset(0x418AF0).As<sq_GetEntityConstantType>();
+ g_pSquirrel<ScriptContext::SERVER>->__sq_getentityfrominstance = module.Offset(0x1E920).As<sq_getentityfrominstanceType>();
+
MAKEHOOK(
module.Offset(0x1DD10),
&RegisterSquirrelFunctionHook<ScriptContext::SERVER>,
diff --git a/NorthstarDLL/squirrel.h b/NorthstarDLL/squirrel.h
index de99b9d0..bc738428 100644
--- a/NorthstarDLL/squirrel.h
+++ b/NorthstarDLL/squirrel.h
@@ -122,12 +122,16 @@ typedef SQRESULT (*sq_getassetType)(HSquirrelVM* sqvm, SQInteger iStackpos, cons
typedef SQRESULT (*sq_getuserdataType)(HSquirrelVM* sqvm, SQInteger iStackpos, void** pData, uint64_t* pTypeId);
typedef SQFloat* (*sq_getvectorType)(HSquirrelVM* sqvm, SQInteger iStackpos);
typedef SQBool (*sq_getthisentityType)(HSquirrelVM*, void** ppEntity);
-typedef void* (*sq_getentityType)(HSquirrelVM*, SQInteger iStackPos);
+typedef void (*sq_getobjectType)(HSquirrelVM*, SQInteger iStackPos, SQObject* pOutObj);
// sq stack userpointer funcs
typedef void* (*sq_createuserdataType)(HSquirrelVM* sqvm, SQInteger iSize);
typedef SQRESULT (*sq_setuserdatatypeidType)(HSquirrelVM* sqvm, SQInteger iStackpos, uint64_t iTypeId);
+// sq misc entity funcs
+typedef void* (*sq_getentityfrominstanceType)(CSquirrelVM* sqvm, SQObject* pInstance, char** ppEntityConstant);
+typedef char** (*sq_GetEntityConstantType)();
+
template <ScriptContext context> class SquirrelManager
{
private:
@@ -171,10 +175,13 @@ template <ScriptContext context> class SquirrelManager
sq_getuserdataType __sq_getuserdata;
sq_getvectorType __sq_getvector;
sq_getthisentityType __sq_getthisentity;
- sq_getentityType __sq_getentity;
+ sq_getobjectType __sq_getobject;
sq_createuserdataType __sq_createuserdata;
sq_setuserdatatypeidType __sq_setuserdatatypeid;
+
+ sq_getentityfrominstanceType __sq_getentityfrominstance;
+ sq_GetEntityConstantType __sq_GetEntityConstant_CBaseEntity;
#pragma endregion
public:
@@ -324,7 +331,11 @@ template <ScriptContext context> class SquirrelManager
template <typename T> inline T* getentity(HSquirrelVM* sqvm, SQInteger iStackPos)
{
- return (T*)__sq_getentity(sqvm, iStackPos);
+ SQObject obj;
+ __sq_getobject(sqvm, iStackPos, &obj);
+
+ // there are entity constants for other types, but seemingly CBaseEntity's is the only one needed
+ return (T*) __sq_getentityfrominstance(m_pSQVM, &obj, __sq_GetEntityConstant_CBaseEntity());
}
#pragma endregion
};