Modifiying ghost.exe

From GHost++
Jump to: navigation, search

This Tutorial is designed to give yourself an understanding of what people mean when they say things like "edit game.cpp", modify code, recompile ghost, compile ghost, edit code, etc.

For Windows Users

Further instructions for Windows users only below.

Getting your computer ready

Download GHost Source

Method 1

Download the official, unmodified Ghost in zipped format. Extract the contents of the .zip you downloaded to a folder, remember where this folder is. Sometimes when you extract files from a .zip archive the program will create an additional folder based on the filename of the .zip file is. Keep that in mind when you look for these files.

Method 2

Download GHost++ from the SVN. 1) Download "Tortoise SVN". 2) Create a new empty folder, name it whatever you want. Right click on it and select "SVN Checkout". 3) In the dialogue popping up you enter the url to the GHost++ code repository hosted at googlecode (http://ghostplusplus.googlecode.com/svn/trunk/) as the repository URL and click "OK".

You are now presented with the progress of downloading the sourcecode of GHost to your computer. Once it says it's finished you can browse into the "ghost" folder inside the directory you just created. In it you see lot's of *.cpp and *.h files, this is what you'll be editing.

Download a compiler

You now need to download a C++ compiler onto your computer. It's recommended that you download Microsoft's Visual Studio 2008 C++ Express Edition as it's free. In this guide we will be assuming that you are using this compiler.

Turn on file extension viewing

In Windows XP, open any folder and go to Tools --> Folder Options.. --> Click the View tab, and ensure that Hide extensions for known file types is unchecked.

In Windows Vista, open any folder and click Organize --> Folder and Search Options --> Click the View tab, and ensure that Hide extensions for known file types is unchecked.

Making your changes

1) Go to the folder that you previously downloaded. In that main folder, open the ghost.sln file with you compiler, I am assuming you are using Microsoft's Visual Studio.

2) On the left panel of the program you should have the Solution Explorer. In it you should have BNCSutil and ghost with + signs next to them. Click the + sign next to ghost, and then click the Source Files folder + sign. It will expand and reveal to you all the *.cpp files you seek.

3) Modifications will vary, so I'll leave this part to the community help as to what you should modify. However, here's an example: If you want to change the welcome message for GHost, beyond that which you can do in motd.txt, look in game_base.cpp for the welcoming message:

 void CBaseGame :: SendWelcomeMessage( CGamePlayer *player )
 {
    SendChat( player, " " );
    SendChat( player, " " );
    SendChat( player, " " );
    SendChat( player, " " );
    SendChat( player, "GHost++                                        http://www.codelain.com/forum/" );
    SendChat( player, "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" );
    SendChat( player, "          Game Name:     " + m_GameName );
 }

4) Download the boost header library from boost.org 1.38 Libraries. Extract it somewhere. For example to "C:\", i.e now the library is in "C:\boost_1_38_0\boost". Now open the start menu and navigate there to "Visual C++ 2008 Express Edition" and then to "Visual Studio Tools" and run Visual Studio 2008 Command Prompt. This should have opened a new command prompt. In the command prompt change the directory to the boost directory, for example if you extracted it in "C:\boost_1_38_0\boost", you would do "cd C:\boost_1_38_0\boost\". Now type ".\bootstrap" and hit enter. It should tell you it is building the Boost.Jam engine. After that is completed, type ".\bjam" and hit enter. This will take a while, but it will compile the boost libraries that you need.

Back in Visual Studio, at the top of the screen you have your standard menu, with headings File - Edit - View - Project - Build - Debug - Tools - Window - Help

Go to Tools -> Options -> Projects and Solutions (click the triangle to expand it and click)-> VC++ Directories. In the top right corner, there is an option called Show directories for:. Select Include files from the drop-down list. Now add the path to the boost folder, removing the boost folder from the path. If you did what was suggested, you would put C:\boost_1_38_0. Visual Studio will automatically look for a boost folder inside the boost_1_38_0 folder when you compile, and it will now work.

Click Ok to close the Options menu.

5) Download the precompiled headers here. Unzip the contents of this archive to the "boost\lib\" subdirectory of your GHost++ folder. Visual C++ will automatically link to them when you compile.

6) At the top of the screen you have your standard menu, with headings File - Edit - View - Project - Build - Debug - Tools - Window - Help

Go to Build -> Configuration Manager.. and the Active solution configuration is probably set to Debug, change that to Release MySQL. Click Close. Press F7 to compile it to GHost.exe. When it is done you will find a Ghost.exe in a folder called Release which is found in the same directory where Ghost.sln was (ex. Ghost\Ghost.sln & GHost\Release\Ghost.exe).

7) Take the Ghost.exe from the Release folder and put it in place of Ghost.exe wherever your Ghost folder is. You wouldn't believe how many people follow the steps then say they can't find it. There's two different Release folders, you may be in one Ghost folder too far.

For Linux Users

Will be added shortly.

If you already compiled GHost++ on Linux one time, then it is rather easy to recompile it. Just go to the /ghost folder. Then you edit the necessary files with your favorite editor. Then you just type in "make" and it recompiles, with the changes you made.

That should be it!

If you have any additional questions first check out the customization section of the FAQ. If your problem still persists make a topic at the forums GHost++ Customization Discussion & Help section.