View Single Post
Author Message
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 12-11-2017 , 18:58   Hooking functions without an interface string?
Reply With Quote #1

I'm writing a plugin.
The plugin's purpose is to hook CGameMovement::ProcessMovement, change gpGlobals->frametime to a different value I want, call the original ProcessMovement function and then change gpGlobals->frametime to its original value.

However, I can't figure out a few things. So here are some questions:
1. If the function I hook is in mp/src/game/shared/gamemovement.cpp, does it mean that I need to use GetServerFactory within the GET_V_IFACE_ANY macro? GetServerFactory's description says "for the GameDLL" and the class that contains the function I want to hook is in src/game/, is this correct?
2. Although I can access IGameMovement within my MM:S plugin by including gamemovement.h, I see that there isn't an interface name like there is in the rest of INTERFACEVERSION_*s.
3. I can't seem to find any function that allows me to call the original function I'm hooking from within my MM:S plugin. Do I have to paste its whole code into my plugin to achieve that?

How would I go on doing this then? Here's my current pseudocode:
Code:
IGameMovement *gamemovement = NULL;

PLUGIN_EXPOSE(TerriblePlugin, gP_TerriblePlugin);

bool TerriblePlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
	PLUGIN_SAVEVARS();

	GET_V_IFACE_ANY(GetServerFactory /* is this correct? */, gamemovement, IGameMovement, /* what do i put here? */);

	return true;
}
I apologize if any of those questions seem ignorant, this is my very first MM:S plugin and I'm feeling clueless.
__________________
retired
shavit is offline