Planeshift Guide To Compiling with Microsoft Visual Studio
========================================== 
By Chris Ayers, based on
Planeshift Guide To Compiling with MinGW32 by Steve Cook
Updated by Arianna Benigno (02/02/2005)

This guide lists the steps necessary to download all the tools and compile Planeshift. This guide assumes that Visual C++.NET or  Visual Studio.NET is installed.  Some tools need glut, Directx 9 SDK,  and python. These features are not needed so they won't be covered here. As a result there will be some compilation errors do to missing files.   

1. Tools Download
=================  

A) Download WinCVS from http://www.wincvs.org
---------------------------------------------  

WinCVS is a free version control system that links to the source files for Planeshift and it's libraries at SourceForge.net and allows you to easily download and update the current version of all source code files.  

At the time of this howto, I recommend the WinCVS 1.3.17.2 full installer. There are problems with version 1.2.


2. Libraries Download
=====================  

A) Configure WinCVS 
-------------------

The first step is to create a directory structure for the library files. Create a root directory for the project.
(this guide will assume you use C:\development\ as your root directory)

Run WinCVS. Click "Admin.. Preferences" from the menu if the preferences window is not already open.
Enter the following information in the dialog box:

(On the General Tab) [Enter the CVSROOT] anonymous@cvs.sourceforge.net:/cvsroot/crystal Set the Authentication to 'pserver'

(On the Global Tab) uncheck Checkout Readonly

(On the CVS tab) [HOME folder (where cvs stores your passwords)] C:\development

Click OK. Select "View.. Browse Location.. Change" from the menu and select the C:\development directory.
Click OK, then select "View.. Browse Location.. Save Settings" to save this default.
You should now see your empty directory structure on the left hand window.


B) Use WinCVS to download the Crystal Space (CS) sourcecode
-----------------------------------------------------------

Downloads ~100MB

Right-click on the development subdirectory and select "Checkout module" again.
Enter 'CS', in cap, as module name and click OK to start the  download.

C) Use WinCVS to download the Crystal Entity Layer (CEL) sourcecode
-------------------------------------------------------------------

Downloads ~10MB

Go back to "Admin.. Preferences" and change [Enter the CVSROOT] to anonymous@cvs.sourceforge.net:/cvsroot/cel

Right-click on the development subdirectory and select "Checkout module" again. This time enter 'cel' as module name and click OK to start the  download.

D) Use WinCVS to download the PlaneShift sourcecode
---------------------------------------------------

Downloads ~40MB

Go back to "Admin.. Preferences" and change the [Enter the CVSROOT] to anonymous@cvs.sourceforge.net:/cvsroot/planeshift

Right-click on the development subdirectory and select "Checkout module" again. This time enter 'planeshift' as module name and click OK to start  the download.

E) Download cs-win32libs
-----------------------

Download ~3MB

Rather than having to install CS dependant components manually, Microsoft Visual C++  6 & 7, MinGW/MSYS, and Cygwin users can download a single package which contains all common headers, pre-built library files, and dynamic link libraries in pre-compiled form from the Crystal Space website, http://crystal.sf.net/

Go to the downloads section and find the download link to the cs-win32libs. (it should be under the "External utilities and libraries" section)

Run the program and install the libraries. The Default name is fine. When it asks  you for the CS directory, enter C:\development\CS. 
You only need the VC Typical Setup.

Continue the installation. Check both 'Copy DLL's to CS directory' and 'Set up VisualC support' when prompted. When it asks you if you want to install the Cal3d Library, check the appropriate VC that you have. Use C:\development\CS when it asks for the path to CS.

F) Download MySQL
-----------------

Download ~20MB

You need MySQL to run psserver, further instructions for this will follow.

Download the MySQL binary (it contains the library and header files too).

http://www.mysql.com

Select the developers tab, then downloads. Click on MySQL 4.0 (release) and select the windows build to download.

Run the setup program and install MySQL. (The defaults are fine)

G) Download cURL
-----------------

Download ~1MB

cURL is needed to compile the new updater for PlaneShift.

Download the cURL dev package (it contains the library and header files too).  http://curl.haxx.se/

It doesn't matter if you pick with or without ssl. Unzip this into  C:\development\curl. 


3. Compiling
============  

A) Set the environment variables 
--------------------------------

Right-Click My Computer and choose Properties. Under Advanced choose Environmental Variables.
Click New under either User or System variables depending on how you want it setup. If you choose System, you will have to log off to make the changes.
Variable Name: CRYSTAL (all caps) Variable Value: C:\development\CS
Variable Name: CEL (all caps) Variable Value: C:\development\cel

B) Add the Directories to Visual Studio/C++
---------------------------------------------------

Here we will add all the directories, containing all the include and lib files  that we will need to use during this compile. Under Tools->Options look on the left hand side for the Projects folder. Under Projects choose "VC++ Directories". In the Show Directories for: choose "Include Files". Add the following directories: (click the new folder icon) C:\development\CS\include\csutil\win32 C:\mysql\include C:\development\cel\include C:\development\CS\include C:\development\curl\include

In the Show Directories for: choose "Library Files". Add the following directories: (click the new folder icon) C:\development\CS\out\debug\libs C:\development\cel\msvc\debug\libs C:\mysql\lib C:\development\curl\

C) Compile Crystal Space
------------------------------------

Note. If you are using VC 7.1 or higher, you will need to convert the solution. Make sure that your 'msvc' folder has the 'read only' box unchecked before continuing.

Open C:\development\CS\mk\msvc\wkstypical.sln with Visual Studio. Click 'yes to all' if asked to convert.

Go into the 'Build' menu, and select 'configuration manager'. Change the 'Active Solution Configuration' to 'Debug_NR'.

Right click on the solution and select 'Build Solution' To test the build of CS, run the walktest.exe in C:\development\CS If you encounter any errors, check you have done everything correctly, and then if the problem persists, you can ask for help on the CS channel:  irc.freenode.net #crystalspace

D) Compile CEL
--------------------------

Note. If you are using VC 7.1 or higher, you will need to convert the solution. Make sure that your 'msvc' folder has the 'read only' box unchecked before continuing.

Open C:\development\cel\msvc\wkscel.sln with Visual Studio.
Click 'yes to all' if asked to convert.
Build the solution.
Just ignore any Python Errors. 

E) Compile Planeshift
---------------------------------

Open C:\development\planeshift\mk\visualc7.1\psall.sln with Visual Studio. (if you have VS.NET 2k3. if not, I think you should just use visualc\psall.sln, or for VisualC 6 visualc6\psall.sln)

Do the following if you put mysql somewhere else than C:\mysql:

Right-click plgdbmysql
 	under properties->linker->general, change the "C:\mysql\lib\opt"
  	in Additional Library Directories to whatever your location of mysql is.

Build solution.

Almost done.

Now before you can debug the programs, you need to change some the of the project properties.
Right-Click apppsclient.
Under debugging change:
Command to: C:\development\planeshift\psclient.exe 
Working directory to: C:\development\planeshift\
You should be good to go now.

NOTE: you might have to copy all DLL files from your CEL directory  to your PlaneShift directory if you get problems related to CEL.  

4. Getting the Server up
========================

A) Create the Database
----------------------

Start a command prompt(Start->Run and type 'cmd') and type:
C:\mysql\bin\mysqld --console
This will start MySQL.
Now start another command prompt and type:
C:\mysql\bin\mysql -u root
create database planeshift;
GRANT ALL PRIVILEGES ON *.* TO planeshift@localhost IDENTIFIED BY 'planeshift' WITH GRANT OPTION;
quit
cd development\planeshift\src\server\database\mysql\
c:\mysql\bin\mysql -u planeshift -pplaneshift
use planeshift;
source create_all.sql;
quit

The database planeshift has now been created for planeshift to use, you can close the command prompt.

B)  Start the Server 
--------------------

Go to your PlaneShift directory(C:\development\planeshift) and run psserver.exe, this will start the server.
Once the server has been started, you should see a "PS Server:" prompt.
Type the following to load the correct map and spawn all items and NPCs:
loadmap npcroom
spawn
ready

NOTE: If you get any problems with psserver, make sure you have  the latest version of MySQL and that your libMySQL.dll file in  WINDOWS\system32 is the same as the one in mysql\lib\opt.
	If you want to investigate functions of psserver type help to get a list of all the available commands and a short of description of them.

You should now be able to start psclient.exe and log in. 
The following accounts work(user/pass):
Vengeance/keith
acraig/andrew
guest/guest

5. Getting Help
 =============== 

If you have trouble getting any of this to work, please feel free to  contact me and I will do my best to help.

Email: cayers@mchsi.com  There is also an IRC channel dedicated to providing help with building PlaneShift.
Server: irc.freenode.com
Channel #PlaneShift-Build

Chris
