View Full Version : Virtual functions for CvPlayerAI class problems?


NikG
May 10, 2006, 07:24 AM
Okay I added a new function for the CvPlayerAI class, made it virtual for the CvPlayer class, however, the game kept crashing, then after some long error-correcting with recompiling, I made it work.

Now I finally got the debugger up and running (YEAH! it would have taken me 5 sec. to find the problem with the debugger), and testing my initial code. Somehow the problem were from the virtual function, but it wasnt anywhere near it when it crashes, it calls DLL function from the exe which in turn calls a few other functions and last it begins to read the 0x0 memory location ??? REALLY STRANGE!

Well first I would like to hear if any have had the same problem and eventually solved it without a hack (placing the virtual function in CvPlayer and not making it virtual), and if noone have had the same problem, well I just like to warn you, because I have used 10 hours solving this little shitty problem! ARGH!!!!:eek: :mad: :nuke: :nuke: :nuke:

NikG
May 11, 2006, 03:03 PM
Well nobody seems to have encountered this? Or I am just a bit to technical? :D

primem0ver
Jan 12, 2007, 02:49 PM
sounds like your function has a null reference (pointer). Also, virtual functions do not always have a body. If they are not overridden in an inherited class, this can cause a problem, maybe even the one you were having. However... I would think your compiler would catch that issue before you ran the code... very strange.

How did you fix it? That may shed some light on the problem.

primem0ver
Jan 12, 2007, 02:52 PM
p.s. I found this thread on a search... looking up another issue. I just realized how long ago it was posted. Well... if it helps, I guess it was worth it!