Skip to content

Commit 021ed61

Browse files
committed
Add virtual address to remaining natives
1 parent 29aa1ff commit 021ed61

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

core/logic/smn_gameconfigs.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,10 @@ static cell_t smn_GameConfGetAddress(IPluginContext *pCtx, const cell_t *params)
155155
if (!gc->GetAddress(key, &val))
156156
return 0;
157157

158-
#ifdef KE_ARCH_X86
159-
return (cell_t)val;
160-
#else
161-
return pseudoAddr.ToPseudoAddress(val);
162-
#endif
158+
if (pCtx->GetRuntime()->FindPubvarByName("__Virtual_Address__", nullptr) == SP_ERROR_NONE) {
159+
return pseudoAddr.ToPseudoAddress(val);
160+
}
161+
return reinterpret_cast<uintptr_t>(val);
163162
}
164163

165164
static cell_t smn_GameConfGetMemSig(IPluginContext *pCtx, const cell_t *params)
@@ -187,11 +186,10 @@ static cell_t smn_GameConfGetMemSig(IPluginContext *pCtx, const cell_t *params)
187186
return 0;
188187
}
189188

190-
#ifdef KE_ARCH_X86
191-
return (cell_t)val;
192-
#else
193-
return pseudoAddr.ToPseudoAddress(val);
194-
#endif
189+
if (pCtx->GetRuntime()->FindPubvarByName("__Virtual_Address__", nullptr) == SP_ERROR_NONE) {
190+
return pseudoAddr.ToPseudoAddress(val);
191+
}
192+
return reinterpret_cast<uintptr_t>(val);
195193
}
196194

197195
static GameConfigsNatives s_GameConfigsNatives;

core/smn_entities.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,10 @@ static cell_t SetEntDataEnt2(IPluginContext *pContext, const cell_t *params)
834834

835835
static cell_t StoreEntityToHandleAddress(IPluginContext *pContext, const cell_t *params)
836836
{
837-
#ifdef KE_ARCH_X86
838837
void *addr = reinterpret_cast<void*>(params[1]);
839-
#else
840-
void *addr = g_SourceMod.FromPseudoAddress(params[1]);
841-
#endif
838+
if (pContext->GetRuntime()->FindPubvarByName("__Virtual_Address__", nullptr) == SP_ERROR_NONE) {
839+
addr = g_SourceMod.FromPseudoAddress(params[1]);
840+
}
842841

843842
if (addr == NULL)
844843
{
@@ -2771,11 +2770,10 @@ static cell_t GetEntityAddress(IPluginContext *pContext, const cell_t *params)
27712770
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
27722771
}
27732772

2774-
#ifdef KE_ARCH_X86
2775-
return reinterpret_cast<cell_t>(pEntity);
2776-
#else
2777-
return g_SourceMod.ToPseudoAddress(pEntity);
2778-
#endif
2773+
if (pContext->GetRuntime()->FindPubvarByName("__Virtual_Address__", nullptr) == SP_ERROR_NONE) {
2774+
return g_SourceMod.ToPseudoAddress(pEntity);
2775+
}
2776+
return reinterpret_cast<uintptr_t>(pEntity);
27792777
}
27802778

27812779
REGISTER_NATIVES(entityNatives)

0 commit comments

Comments
 (0)