The International Simutrans Forum

Development => Technical Documentation => Topic started by: omikron on February 05, 2012, 07:48:59 PM

Title: testing a compiled version of the code
Post by: omikron on February 05, 2012, 07:48:59 PM
This might seem like a novice question, but it is quite a long time since I did any kind of programming. I have downloaded MSVC and all the other necessary parts to help develop the gaming engine as described here: forum.simutrans.com/index.php?topic=652.0 (Thanks VS!) It is not completely up to date, but I managed to work my way around the difficulties.

Then, I even managed to compile my own version of simutrans, but it won't start, since apart from the root directory, there are no pak files etc. installed in the 'debug' directory. Can I have some help finding a solution to this problem?

Possible solutions:

a. I could copy all the subdirectories from my release version to the debug folder.
b. I could start simutrans with a different working directory (I haven't been able to find out how to do that yet though)

Can anybody help?

omikron
Title: Re: testing a compiled version of the code
Post by: prissi on February 05, 2012, 07:52:41 PM
The is the switch -use_workdir

Thus set in the debugger the workidr to "C:\Programmesimutrans" or where your exe is.

Add "-use_workdir" as first option in the command line.
Title: Re: testing a compiled version of the code
Post by: omikron on February 05, 2012, 07:58:49 PM
Thanks, prissi. Unfortunately, that won't work. I've tried numerous alternative spellings etc.

The executives are at d:\games\simutrans, but 'simutrans -use_workdir d:\games\simutrans' won't work. What am I doing wrong?

omikron

Title: Re: testing a compiled version of the code
Post by: VS on February 05, 2012, 08:25:52 PM
I tried this and thought that it is broken, but then realized that this works with inverse logic. The program starts, looks up where is the executable and does chdir to there, so that it can read the game files, regardless where is it started from. But if you add -use_workdir, it will work in the starting directory. No paths are passed as a parameter anywhere!

Of course, one has to understand that "working directory" and "directory with executable" are two things. So... yeah. Thus:

1) One solution is to copy the executable to the directory with pakset and everything, and start it from there. Can't debug, though ::(

2) The other is to add -use_workdir, so to do this:
a) Open the property/configuration editor for the project
b) Go to page "debugging"
c) Command arguments = -use_workdir, Working directory = D:\Hry\Simutrans\111.0 or whatever you use.
Title: Re: testing a compiled version of the code
Post by: omikron on February 05, 2012, 08:32:27 PM
But I want to run the version I just compiled, with the paksets etc. from the release version I have stored somewhere else.

Or maybe 'stehe ich auf dem Schlauch' ("I'm standing on the hose")

omikron

PS. Sorry, didn't see the rest of your post, VS
Title: Re: testing a compiled version of the code
Post by: VS on February 05, 2012, 08:33:35 PM
Sorry, I edited my message several times. The picture attached now is probably the best answer :D

edit: To be fair, I was rather confused first, too :)
Title: Re: testing a compiled version of the code
Post by: omikron on February 05, 2012, 09:15:11 PM
Well, I'm sorry to say, it still did not work. I'm going to sleep now, but maybe I have better luck next time I find the time to try.

If anybody has anymore tips, I'd be happy to hear them.

Good night everybody!

omikron
Title: Re: testing a compiled version of the code
Post by: prissi on February 05, 2012, 09:26:08 PM
As VS wrote: You must enter in this red box the directory, where your standard simutrans paks are.

DO NOT ENTER THE PATH TO YOUR COMPILED PROGRAM THERE!
Title: Re: testing a compiled version of the code
Post by: omikron on February 06, 2012, 02:53:57 PM
I don't want to continue bothering you, but it still doesn't work:

a. I have entered the necessary information in the Debug-Configuration properties - the same as VS had in his post (with my normal simutrans-executables folder, obviously)

b. I select 'build solution' and MSVC creates an executable and many other files (in total 212 Mb) in the 'Debug'-folder.

c. When I try to run the executable 'simutrans.exe', it tells me that '*** no pakset found *** etc.'

d. If I copy the compiled executable to the 'normal' directory, it works

I would still enjoy any tips how to enable the first version. Thanks!

omikron
Title: Re: testing a compiled version of the code
Post by: VS on February 06, 2012, 03:11:15 PM
Maybe we can try an inverse problem ;) Can you post a screenshot of this dialog, as you have it set up?

edit: One more remark! These options are used only if you start your executable from within MSVC. The green "play" button.

edit2: I have invested too much to not get to the end :P Knowing how to show this to others would be extremely helpful, as it can become a standard reply - "see: [thread link]".
Title: Re: testing a compiled version of the code
Post by: Spike on February 06, 2012, 03:11:40 PM
Try this:

- Install Simutrans 111.1 and a pak set of your choice
- Make sure it runs
- Compile your binary
- Copy the binary into your simutrans installation, e.g. as simu_new.exe
- Try to run it. It should work if your compile was good.

I haven't gotten -use_workdir to work for me eitehr, but I blamed my mix of cygwin (cygwin/unix paths) and windows (windows path) to make it fail an dhaven't debugged it further. Copying the exe is now part of my build process and works good enough for me.
Title: Re: testing a compiled version of the code
Post by: omikron on February 06, 2012, 03:45:01 PM
And again, VS, you had the tip that made my compilation work. I didn't think abuot the option of starting the game from within MSVC.....

It works now, thank you all very much. Also Hajo's suggestion worked, though...

Do you want me to write a checklist for dummies, how to make a compilation work, something akin to VS's checklist in the other thread?

omikron
Title: Re: testing a compiled version of the code
Post by: VS on February 06, 2012, 04:22:19 PM
Maybe?

BTW, you can also create a shortcut to the exe and edit it like these options :)