Attacking Issues

Started by
23 comments, last by burntgorilla 20 years, 8 months ago
Hi, being pretty new to games programming, I got myself a book (Isometric with DirectX 7.0). I took one of the examples (19_2), and decided to add a small attacking feature. Basically, all it does is delete the unit from the team list and renders a tile over it. However, when I compile and run it in VC++, when I go to attack, the game closes and returns to the VC++ scrren. I ran the actual .exe, but attacking in this does nothing. The complete code is here: http://uk.briefcase.yahoo.com/ The username is burntgorilla and the password is kietas Hope you can help - I'm not sure what I'm doing wrong. --------------- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| **************************************************************** I'll try to answer here- it seems better place to be honest, I think reason of closing can bet sudden exit from function for whatever reason. try running program in debug(ging) mode so you may get more info. Hinghly likely is (may be) memory problem, since when you hit "wrong place" in memory result can be unpredictable. so check your pointers, make breakpoints, debug and HAVE FUN ! [edited by - burntgorilla on January 22, 2003 9:03:14 PM]
Advertisement
Firstly I really don''t recommend giving out that information to people, you should just of posted the code in a nice source box on here. People can now abuse your yahoo account. I can''t actually help you, but look at what you have changed. What could make it exit the program? Post the bit of code you added into this forum and..

GO CHANGE YOUR PASSWORD ON THAT ACCOUNT NOW!

=*=
If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore

=*=
Find out in WHICH command the error lies (ie the command that is executed when the program crashed). Two ways to do this : 1°/ write to a file the name of the command being executed. 2°/ comment out commands until it works.

Once you have found out what command is causing the crash, begin wondering about what this command implies : is all required data initialized? are you using a correct pointer? For all data that is used in this command, check if it is correct :
-> has it been initialized?
-> does it still exist? (you could have deleted it)
-> is it of the type required? (check the documentation for API calls)...

ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more
Well, to begin with, I only made that account for putting up the code, so I don''t really mind what happens to it. I didn''t post just the code, since I wasn''t sure which file was the error. I''ll include it here anyway. Debugging always seems to crash the PC, which makes things a little harder. Running the actual .exe doesn''t crash the program, the selected unit still flashes, etc., the commands to delete the unit don''t seem to do anything. I can''t seem to get any programs to open at the moment, so I''m restart and post the code (don''t ask why it did that, I don''t know).
Hand-debugging always works. Just work in a "scientist" fashion : experiment with your code (comment in/out lines) until it works/stops working, and then you know the last parameter you changed was responsible for the crash.

ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more
Well, there only is two lines of code releating to the attacking, and I''ve tried different combinations of commenting them out, but no luck. The units are stored in STD list (sorry if that''s incorrect), and I was wondering if it was something to do with them, although to me it seems unlikely.
this is why u should now change ure pass!

this is why u should now change ure pass!

Make sure that you don''t use an iterator after erasing what it was pointing to. The standard template library''s list.erase function returns an iterator that points to the element after the one that was erased. The iterator that was used as a parameter to erase becomes invalid after the call to erase, and using it can cause problems like the one you described (the program crashing).
I wondered how long it would take someone to work out the password!

This topic is closed to new replies.

Advertisement