From 7db3e16a97c8c6d8eb104d4d5693290e6c3417c7 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 27 May 2022 14:39:29 +0200 Subject: [PATCH] Align and use SQVM struct for builds below S3 --- r5dev/squirrel/sqapi.cpp | 8 ++------ r5dev/squirrel/sqvm.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/r5dev/squirrel/sqapi.cpp b/r5dev/squirrel/sqapi.cpp index 7b557a49..7f845125 100644 --- a/r5dev/squirrel/sqapi.cpp +++ b/r5dev/squirrel/sqapi.cpp @@ -11,17 +11,13 @@ //--------------------------------------------------------------------------------- SQChar* sq_getstring(HSQUIRRELVM v, SQInteger i) { - std::uintptr_t thisptr = reinterpret_cast(v); - - return *(char**)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8) + 0x40; + return *(char**)(*(std::int64_t*)(v->_stackbase) + 0x10 * i + 0x8) + 0x40; } //--------------------------------------------------------------------------------- SQInteger sq_getinteger(HSQUIRRELVM v, SQInteger i) { - std::uintptr_t thisptr = reinterpret_cast(v); - - return *(SQInteger*)(*(std::int64_t*)(thisptr + 0x58) + 0x10 * i + 0x8); + return *(SQInteger*)(*(std::int64_t*)(v->_stackbase) + 0x10 * i + 0x8); } //--------------------------------------------------------------------------------- diff --git a/r5dev/squirrel/sqvm.h b/r5dev/squirrel/sqvm.h index 29bd139f..da7b4297 100644 --- a/r5dev/squirrel/sqvm.h +++ b/r5dev/squirrel/sqvm.h @@ -23,8 +23,8 @@ struct SQVM #if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2) SQCONTEXT _contextidx; _BYTE gap001[8]; -#endif _BYTE gap002[4]; +#endif void* _ncvftable; void* _table; _BYTE gap003[14];