PDA

View Full Version : FireEvent virtual??


Penumbra
06-14-2007, 06:30 AM
Hello there,

I've got a problem with the firing of GameEvents that I created myself (nifv_victim_info):
"modevents"
{
"nifv_victim_info" // sending victim information from server to client
{
"airway" "bool"
"breathing" "string"
"circulation_hr" "string"
}
}
On both the server and client side, I've loaded this event in the GameEventManager:
gameeventmanager->LoadEventsFromFile( "resource/ModEvents.res" );
Here is the piece of code to create and fire the event from the server side:
IGameEvent *event = gameeventmanager->CreateEvent( "nifv_victim_info" );
if( event )
{
event->SetBool( "airway", true );

char *szMessage = new char [ 4 ];
Q_snprintf( szMessage, 4, "%i", 20 );
event->SetString( "breathing", szMessage );

Q_snprintf( szMessage, 4, "%i", 120 );
event->SetString( "circulation_hr", szMessage );

if( !gameeventmanager->FireEvent( pEvent ) )
{
Warning( "Could not fire 'nifv_victim_info' event!\n" );
gameeventmanager->FreeEvent( pEvent );
}
}

Now the problem lies in that when I try to send the event, Source crashes with the message: pure virtual function call.

I narrowed it down to the FireEvent, so somewhere inside this function (or the function itself) something is 'wrong'!

Does anyone of you have this same problem, or am I doing something stupid? :confused:

Penumbra
06-17-2007, 06:42 AM
No-one has any ideas... ? :(

Marine
06-17-2007, 07:17 AM
No-one has any ideas... ? :(
Did you track it down in the debugger?

Penumbra
06-17-2007, 09:28 AM
Yes I did, and this pointed to the FireGameEvent call...

But the good news is that I've fixed the bug!!! :D
There was an error in the receiving side of the event... I re-wrote the code and came to the surprisingly conclusion that the problem was fixed.

The only thing that was left out was the copying of strings (Q_snprintf), which apparently gave an internal virtual function call.

So, instead of server side, there was a problem in the client side..

Conclusion: The MDMP debugger isn't the greatest tool to find an error ;)

Marine
06-17-2007, 09:52 AM
Yes I did, and this pointed to the FireGameEvent call...

But the good news is that I've fixed the bug!!! :D
There was an error in the receiving side of the event... I re-wrote the code and came to the surprisingly conclusion that the problem was fixed.

The only thing that was left out was the copying of strings (Q_snprintf), which apparently gave an internal virtual function call.

So, instead of server side, there was a problem in the client side..

Conclusion: The MDMP debugger isn't the greatest tool to find an error ;)

Hehe, why don't you attach VS to your game and debug it from there, its quicker and you can edit + continue in some code.


Also the callstack is an invaluable tool, usually the function it debugs into isnt the faulty one (As i found out trying to find an error in VALVe's engine header :S)

Penumbra
06-17-2007, 11:43 AM
OK, but how do I do that?!

The only thing I know is to open the MDMP file while the system has crashed..

Marine
06-17-2007, 01:18 PM
In your project, right click CLIENT_HL2(HL2MP) click Set as Startup Project.

Right click, click Properties > Debugging

Follow the screenshot. Set the Command to the game you are running your mod as (215 - Source sdk base - steamapps\username\source sdk base\hl2.exe) etc. And set "Attach" to "yes" then when you run your mod with "run_mod.bat" you can click the start debugging button in VS and it will attach to your game. Then when it crashes, it will debug in VS.

http://img523.imageshack.us/img523/227/debuggingmj1.jpg

Penumbra
06-18-2007, 02:49 AM
OK, thanks for your help!!
Now I can make errors without worrying! :cool:

Marine
06-18-2007, 03:58 AM
:D

lolz 10 chars