Skip to main content
gamedev.net
🔒 Locked

function pointers in Classes.

Started by phueppl1 Apr 7, 2001 at 2:24 AM 2 replies 250+ views
Original Post
phueppl1
phueppl1
Hi there! I want to write a Server for my MMORPG and I want it to be veery flexible, so I use function pointers that will point to functions loaded from dynamic dlls... So I can recompile the .dll, reload the functions and pointers and so continue without stopping and restarting the server. Now my question is, if I''ve got a Linked List of Classes with function pointers in them do I have to update _all_ function pointers in every class or is there any trick to not having to do that? ;p cya, Phil Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

RAW!
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
WMiller
WMiller
If the function pointers are static, you need only make the change once per pointer.

If the function pointers are not static, then every instance of the class has it''s own copy; you must change them all.
phueppl1
phueppl1
so i can''t have a dynamic array with function pointers, but if I got a functionpointer variable for each function I want to point at it should work? ok... great...
thx,
cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

RAW!
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
Shannon Barber
Shannon Barber
You can make a static function handle (poitner to a pointer, in this case a pointer to an array) part of the class, and

then
hfunctions = new FuncPtr*[dwFunctions];
//load dll
hfunctions[j] = GetProcAddress(j);
//etc...

delete[] hfunctions;


now, I think you'll need to rename the dll... If you copy over it (if it lets you - which it probably won't), and tell it to load that dll again, it won't actually load it from disk again. So you'll need a second dll to load (different name), once it's loaded, you can stomp over the hfunctions array, and unload the previous dll.

Magmai Kai Holmlor
- The disgruntled & disillusioned


Edited by - Magmai Kai Holmlor on April 8, 2001 11:21:19 PM
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.