Raised This Month: $12 Target: $400
 3% 

Hooking functions without an interface string?


Post New Thread Reply   
 
Thread Tools Display Modes
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
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode