Sign in to follow this  
tashaklikedi

visual c++ version runs differently than the exe in explorer!

Recommended Posts

Hello everyone, I have a strange issue ( noob programmer here )

Some of my game's collisions do not work when I click on the exe that is located in the "release" folder from windows explorer, but they work when I do "build and compile" from visual c++. I made sure I compiled in release mode, and the data folder is copy paste in both folders. 

I really don't understand. 

Share this post


Link to post
Share on other sites

That is because the working directory is different when you run from the debugger (it goes to the path of the solution).

You have 2 options:

1: Change the debugger settings to set the working directory to be the same as the executable‘s directory and then move all of your resources respectively.

2: Force the working directory for your executable to be that of the executable’s at run-time via SetCurrentDirectory() and then move all of your resources respectively.

 

 

L. Spiro

Edited by L. Spiro

Share this post


Link to post
Share on other sites

I tried 1- and it didn't work.

the weird thing is, there is a defaults.sav file which holds all the default settings, which includes an entity which is an electric wire, which is supposed to be a solid body. It loads its sprite as it should, but it does not load its collisions... from the same file

Share this post


Link to post
Share on other sites

I found the problem: there is a bitwise flag that does not work in the actual exe:

 

it goes like: 

 

if(CEntityManager::currentMapEntities[i]->flags & ENTITY_GAIA) 

 

this condition is always negative in the original exe, but it works in debug mode. Why could this happen?

Share this post


Link to post
Share on other sites

Debug builds automatically initialize (or zero out) your variables for you, while Release builds retain whatever garbage value is presently set at that location in memory your variables refer to.

 

Whenever you create a new map entity object, set flags = 0 in the constructor.  That should do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this