Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Vector Troubles

Author
Message
CLICK
15
Years of Service
User Offline
Joined: 27th Feb 2009
Location:
Posted: 5th Aug 2009 13:04
A little while back i had some issues with how i was going to store my towers and enemies in my tower defence game, the kind posters on this forum gave me the advice to use a Vector. This is exactly what i need however i seem to get random crashes when ever i try to look inside the contents of the Vector. I have tried to fix within my game but that didnt work, so i made a test project which only has the vector related code within it.

The Error message that it gives is "The program '[1888] Vector Test.exe: Native' has exited with code -1073740777 (0xc0000417)"


Anything u notice i most likely havent so please feel free to point it out (including bad habits,ineffient code practices and potential errors
thanks, CLICK

People dont kill People, Lag Kills People
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 5th Aug 2009 16:37 Edited at: 5th Aug 2009 16:38
Quote: "int i;"


You don't initialize this.

Quote: "dbPrint ((double)Enemies.Life );"
(forum fail, it kept your italics [ i ] from the code.)

You do no bounds checking here.

Also, storing enemy names like that is generally a bad idea. If your enemy dies then what do you do with the allocated memory? In this case it's not an issue as they are literal strings but if you ever allow the user to input names or something then you'll most likely dynamically allocate memory and when the enemy dies you'll either get a memory leak or you could free the memory at the pointer but that would break using such literal strings. It would be best to copy the name across and manage it in the class, i.e. using a std::string or something.

Your indentation is also inconsistent, as with your usage of curly braces for the scopes.

Login to post a reply

Server time is: 2024-10-01 10:35:21
Your offset time is: 2024-10-01 10:35:21