1

Topic: Compiling with VS2013

Hi all,

Been a while since I messed around with TeeWorlds, but I am back for the time being.

Thought I'd share with those of you that might care about compiling TeeWorlds 0.6.2 on Windows with VS2013.

I downloaded the following:

Bam 0.4.0
Python 3.3.3
TeeWorlds 0.6.2

I installed Python with no problems.

Bam compiled just fine with VS2013 after modifing the make_win32_msvc.bat to include VS12 tools:

if exist "%VS120COMNTOOLS%" (
    set VSPATH="%VS120COMNTOOLS%"
    goto set_env
)

I then proceeded to compile TeeWorlds, but had a couple errors. I was able to fix them by modifing the following files:

I commented out the following function in
src\base\math.h (line 23)

//inline int round(float f)
//{
//    if(f > 0)
//        return (int)(f+0.5f);
//    return (int)(f-0.5f);
//}

Then I also had to add a cast to the following line in
src\game\editor\layer_tiles.cpp (line 251)

int Rotation = (int)(round(360.0f*Amount/(pi*2))/90)%4;    // 0=0°, 1=90°, 2=180°, 3=270°

After those 2 changes TeeWorlds compiled perfectly with VS2013.

2

Re: Compiling with VS2013

just renaming the function would help, too. Also it would still be possible to compile using other systems/compiler.
A pull request about this was already made but not pulled yet and also there is still a discussion about the name.

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

3

Re: Compiling with VS2013

Thank you, it's quite a quick solution. But is it secure?

4

Re: Compiling with VS2013

It is the same the round function in tw was doing as you can see. So it is secure to use.
The only problem is that it will only compile with vs 2013.

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

5

Re: Compiling with VS2013

I don't know if this is what you guys do, but I also made my own VS2013 C++ project with all of the source code and was able to directly debug (F5) when in visual studio with just a few minor setting changes.

6

Re: Compiling with VS2013

ShootMe wrote:

I don't know if this is what you guys do, but I also made my own VS2013 C++ project with all of the source code and was able to directly debug (F5) when in visual studio with just a few minor setting changes.

How did you load all the source code into VS? Manually selecting every folder?

Not Luck, Just Magic.

7

Re: Compiling with VS2013

You can debug directly with Visual Studio anyway. Just do Open > Project and select the *.exe file you compiled before (of course debug version). In the project settings you can just put the parameter you want to use like "-f config.cfg" or what ever.
In case you want to set break points just pull the file into VS and set the point. wink

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^

8

Re: Compiling with VS2013

Sushi Tee wrote:

You can debug directly with Visual Studio anyway. Just do Open > Project and select the *.exe file you compiled before (of course debug version). In the project settings you can just put the parameter you want to use like "-f config.cfg" or what ever.
In case you want to set break points just pull the file into VS and set the point. wink

But you need to hook the sources to VS somehow, don't you? It's not like VS can magically find them?

Not Luck, Just Magic.

9

Re: Compiling with VS2013

This is how I setup my teeworlds directory:
http://i41.tinypic.com/24wvcds.png

I have a project for the latest code and the currently released code. They are the same except that one points to the teeworlds folder and the other points to the teeworlds-release folder.

The VS project is just an Empty Project template.
http://i39.tinypic.com/k0haug.png

With the project up, browse to the teeworlds source folder in explorer. You can then drag the "src" folder from explorer and drop it onto the VS project's name. This will add links to all the source code into the project and you should see them in both the header files folder and source files folder.
http://i40.tinypic.com/174dj6.png

I then created 2 bat files and put them in the vs directory that will get run to compile teeworlds, which you should be familiar with.

compile_debug.bat

cd /d "Your teeworlds folder path"
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
..\bam\bam debug

compile_release.bat

cd /d "Your teeworlds folder path"
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
..\bam\bam release

Then I modified the project properties. You will need to change the Configuration Type to Makefile from .exe then hit apply.
http://i39.tinypic.com/2nqgnza.png
http://i41.tinypic.com/qo8tpy.png
http://i42.tinypic.com/2ce6m11.png
http://i41.tinypic.com/f4h7vp.png

You can then setup the same thing for the release configuration.

Let me know if you have any other questions.

10

Re: Compiling with VS2013

Thank you for the detailed explanations, will certainly come in use some day.

It seems they've implemented a way to recursively add sources, I couldn't find any in the previous versions (maybe my fault) :)

Not Luck, Just Magic.

11

Re: Compiling with VS2013

Dune wrote:
Sushi Tee wrote:

You can debug directly with Visual Studio anyway. Just do Open > Project and select the *.exe file you compiled before (of course debug version). In the project settings you can just put the parameter you want to use like "-f config.cfg" or what ever.
In case you want to set break points just pull the file into VS and set the point. wink

But you need to hook the sources to VS somehow, don't you? It's not like VS can magically find them?

Actually it does find magically the source files wink
If you press "Pause" it automatically opens the file where the program currently is and as I said... just pull all the files you need into VS and done.
Nothing else is needed. Of course you wont be able to compile tw with just that but compiling tw is a double click only anyway so I wouldn't bother to actually create a project in VS.

uptee - a simple web interface for hosting and maintaining teeworlds servers
teerace - a website gathering results of trusted Race-mod servers providing global ranking and statistics
*gV* rox ^^