Skip to content

Conversation

Kenzzer
Copy link
Member

@Kenzzer Kenzzer commented Nov 28, 2024

Another Address PR!

The idea and implementation is primarily @dvander's, this PR just makes the bridge to SM.
In order to use the new virtual address :

#define VIRTUAL_ADDRESS
#include <sourcemod>
#include <sdktools>

If enabled, plugins need to ensure their SDKCalls are using the new SDKType_VirtualAddress, whether they're on 32bits or 64bits. Otherwise the plugin will most definitively crash the server.

Marking as draft for now until I can get a few server operators to try this out. Extra natives idea are welcomed !

@rtldg
Copy link
Contributor

rtldg commented Feb 23, 2025

Can you also add this:

		} else if (vc->retinfo->vtype == Valve_VirtualAddress) {
			void *addr = (void *)vc->retbuf;
			return g_pSM->ToPseudoAddress(addr);
		} else {

to here

} else if (vc->retinfo->vtype == Valve_Bool) {
bool *addr = (bool *)vc->retbuf;
if (vc->retinfo->flags & PASSFLAG_ASPOINTER)
{
addr = *(bool **)addr;
}
return *addr ? 1 : 0;
} else {
cell_t *addr = (cell_t *)vc->retbuf;
if (vc->retinfo->flags & PASSFLAG_ASPOINTER)
{
addr = *(cell_t **)addr;
}
return *addr;

This would allow things like calling CreateInterface with SDKCall() and actually having a usable result.

@Headline
Copy link
Member

@Kenzzer @rtldg anything else you guys can think of? Going to mark ready for review - plugin interface would instead be

#include <sourcemod>
#include <sdktools>
#include <virtual_address>

@Kenzzer
Copy link
Member Author

Kenzzer commented Sep 21, 2025

I think this is great, and indeed much better than the define.

@Headline Headline added the Needs Testing untested by author label Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing untested by author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants