Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 08-18-2012, 01:16 AM   #1
OneManArmy
 
Join Date: Apr 2008
Reputation: 0
Posts: 339
Pure virtual function call in think function

I'm just started with modding and C++ in general (I'm experienced at Java though) and I decided to make pistol shoot in short bursts.
To do this I've defined a function BurstThink (the right word would be copied from CHLSelectFireMachineGun), which calls BaseClass::PrimaryAttack() and reschedules itself if the burst size is not exceeded. I've properly declared this function in DATADESC, however as soon as I press mouse button with pistol equipped I get strange error "Pure virtual function call". Unfortunately there was notthing like good old Java stacktrace, so I could not pinpoint the cause.
OneManArmy is offline  
Reply With Quote
Old 08-18-2012, 01:19 AM   #2
OneManArmy
 
Join Date: Apr 2008
Reputation: 0
Posts: 339
Here is the code http://pastebin.com/W5aPVyBw
OneManArmy is offline   Reply With Quote
Old 08-18-2012, 12:13 PM   #3
zombie@computer
 
Join Date: Aug 2008
Reputation: 416
Posts: 908
check here for debugging: https://developer.valvesoftware.com/...he_Source_Code

you know what a pure virtual function call is? its this

http://www.artima.com/cppsource/pure_virtual.html
zombie@computer is offline   Reply With Quote
Old 08-18-2012, 01:57 PM   #4
OneManArmy
 
Join Date: Apr 2008
Reputation: 0
Posts: 339
Yes, I'm aware of what is the pure virtual function. The thing is I don't know how to fix this. As far as I can tell the error occurs when BaseClass::PrimaryAttack() is executed from within think function when I set it up as a think function. When I call it directly everything is OK. So it seems that reference to BaseClass is invalid within think context. That said I don't even know where to start looking for the solution
OneManArmy is offline   Reply With Quote
Old 08-19-2012, 01:28 AM   #5
zombie@computer
 
Join Date: Aug 2008
Reputation: 416
Posts: 908
As far as i can tell (using google one can apparently find most of the hl2 source code, odd...) CBaseHL2MPCombatWeapon has no PrimaryAttack defined (its only declared) which would explain this behaviour. I dont know why calling it outside the think apparently works for you.
zombie@computer is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


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



All times are GMT -7. The time now is 03:43 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.