Building the Server

From DSP Wiki
Revision as of 22:38, 30 March 2012 by Bluekirby0 (Talk | contribs) (Created page with "== Installing & Setting up the DS Server on Windows == === Prerequisites === In this section we will download every program/tool we will need to setup and maintain the serve...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Installing & Setting up the DS Server on Windows

Prerequisites

In this section we will download every program/tool we will need to setup and maintain the servers. Do not install these yet.

MySQL Community Server

Navicat Lite

Visual Studio 2010 (Full or Express)

Tortoise SVN

Visual C++ Redistributable Runtimes 2010

.Net 3.5 Runtime (already comes with Win 7)

.Net 3.5sp1 Runtime (already comes with Win 7)

.Net 4 Runtime

SQL Developer Package


Installation

MySql

Choose Typical Installation

After the main installation, select Launch the MySQL Instance Configuration Wizard

Select Detailed Configuration

Select Developer Machine

Select Multifunctional Database

Standard Installation Directory

Select Manual Setting and 1000 Concurrent connections

Select Enable TCP/IP Networking, Port Number 3306, and Enable Strict Mode

Select Best Support for Multilingualism

Select Install as Windows Service, Launch the MySQL Server automatically, and Include Bin Directory in Windows PATH.

Select Modify Security Settings, and enter a new password twice. Write down the MySQL password.

Select Next, Execute, then Finish

Navicat Lite

Use default installation options.

Visual Studio 2010

Use default installation options. You may be forced to restart (sometimes twice) during the installation.

Tortoise SVN

Use default installation options. You can skip the step to reboot since we'll reboot once everything else is installed.

Visual C++ Redistributable Runtime 2010

Use default installation options.

.Net 3.5, 3.5 SP1, and 4.0

Use default installation options.

SQL Developer Package

Don't lose it, as we'll come back to it later.


At this point everything should be installed that needs to be and you can restart your PC to finalize them.



Downloading the Server Source Code

In this section we will use Tortoise SVN to download the latest SVN source code for the server.

Open Windows Explorer (right click the start button and choose Windows Explorer)

Right click on any folder select SVN Checkout

In the "URL of repository" put in the following url:

http://onetimexi.googlecode.com/svn/trunk/

Set the "Checkout directory" to

C:\dsp.

Click OK.

Wait for the download to finish.

Click OK to close Tortoise SVN.

Close windows explorer

At this point you have downloaded all of the source code for the latest version.



Setting up the Database

In this section we will use the data that you downloaded to build a database in MySQL.

Using a command script

If you follow this step, you may skip the next one.

Paste the following into notepad and save it as DSP_Import.cmd in your dsp\sql folder:

@ECHO OFF
REM =============================================================================
REM ====== THis script will drop the DB specificed, then create the DB  =========
REM ====== specified, and then load the DS tables into the DB. This     =========
REM ====== file needs to be run from within the \dsp\sql folder (same   =========
REM ====== folder with all the .sql files. Please edit as needed. By    =========
REM ====== default it WILL DROP the standard dspdb DB, loosing all      =========
REM ====== accounts and characters. If this is not desired, then update =========
REM ====== the file to load the new DB into a new DB name.              =========
REM =============================================================================
REM =============================================================================
REM ======                                                              =========
REM ======                     by Thrydwolf   11/5/2011                 =========
REM ====== Updated with status on the last step by bluekirby0 3/30/2012 =========
REM ======                                                              =========
REM =============================================================================
REM =============================================================================



ECHO Creating Database dspdb
REM ================================================
REM ====== Update "-p" with MySQL password =========
REM ====== Update dspdb with MySQL Databse =========
REM ================================================
mysqladmin -h localhost -u root -proot DROP dspdb


ECHO Creating Database dspdb
REM ================================================
REM ====== Update "-p" with MySQL password =========
REM ====== Update dspdb with MySQL Databse =========
REM ================================================
mysqladmin -h localhost -u root -proot CREATE dspdb


ECHO Loading dspdb with tables
REM ================================================
REM ====== Update "-p" with MySQL password =========
REM ====== Update dspdb with MySQL Databse =========
REM ================================================
FOR %%X IN (*.sql) DO ECHO Importing %%X & mysql dspdb -h localhost -u root -proot < %%X

ECHO Finished!

At a minimum you will need to change -proot in the script to where root is your mysql root password. If your password is 'foo' then you would use -pfoo instead.

You can use this script any time the svn is updated, but it will drop the table and thus delete all your player data. You may want to make manual changes instead unless you are using it purely as a test server.

Using Navicat

This is the more hands-on approach, and being comfortable doing it this way may make it easier to update individual tables later without having to learn the mysql command-line interface.

Open Navicat

Click Connection (or File, New Connection)

Connection name: DarkStar

Host Name/IP: localhost

Port: 3306

User Name: root

Password: Enter the password you wrote down during the mySQL installation.

Check Save Password

Click OK


In the connections pane double click DarkStar

Right click on DarkStar and select New Database...

Name it dspdb

Use the Default character set

Select OK.


Double click dspdb

Right click on dspdb and select Execute SQL File...

Browse to C:\dsp\sql and select abilities.sql

Click Start

Continue this process for each file in the folder.


If you have an issue with the triggers.sql file then follow this step. If not, proceed to the next step (IP address for the map server):


In Navicat Open accounts table

Click File, Design Table

Click the Triggers tab

There should a line already listed with account_delete in the Name field


If not:

click Add Trigger

Name column should be account_delete

Fires column should be Before

Check the box in the Delete column

In the definition box below add the following code:

BEGIN
   DELETE FROM `accounts_banned` WHERE `accid` = OLD.id;
   DELETE FROM `chars` WHERE `accid` = OLD.id;
END

Select Save and then close the table.

Open the chars table

Click File, Design Table

Click the Triggers tab

There should already be a line listed with char_delete in the name field.


If not:

click Add Trigger

Name column should be char_delete

Fires column should be Before

Check the box in the Delete column

In the definition box below add the following code:

BEGIN
   DELETE FROM `char_exp` WHERE `charid` = OLD.charid;
   DELETE FROM `char_jobs` WHERE `charid` = OLD.charid;
   DELETE FROM `char_equip` WHERE `charid` = OLD.charid;
   DELETE FROM `char_effects` WHERE `charid` = OLD.charid;
   DELETE FROM `char_look` WHERE `charid` = OLD.charid;
   DELETE FROM `char_stats` WHERE `charid` = OLD.charid;
   DELETE FROM `char_skills` WHERE `charid` = OLD.charid;
   DELETE FROM `char_titles` WHERE `charid` = OLD.charid;
   DELETE FROM `char_inventory` WHERE `charid` = OLD.charid;
   DELETE FROM `char_vars` WHERE `charid` = OLD.charid;
   DELETE FROM `char_bazaar_msg` WHERE `charid` = OLD.charid;
END


Select Save and then close the table.

Note: Leave Navicat open for the next section.



Configure the ZoneIP for the Map Server

Now you need to determine what IP address that will be used for the Map Server, then update MySQL with it.

Most devs & enthusiasts will not have a separate map server, but will run both map server and login server on the same PC.


Determine what IP address will be used for the map server.

If the server will be public, then use your external IP in the next step.

If the server will be internal and you want it available on other PCs in your internal network, use the internal network IP (192.168.x.x) in the next step.

If you only plan to run the client and the server on the same PC, you can use the localhost address (127.0.0.1) in the next step.

Calculate the new form from the IP address.

The IP must be entered in different form, so first we must calculate the new form. Use the formula below to calculate it. I found this Scientific Calculator site useful for this.


Formula = 1st Octet + 2nd Octet * 256 + 3rd Octet *256 (squared) + 4th Octet * 256 (cubed)

Example: 127.0.0.1 = 127 + 0 + 0 + 1*256(cubed) = 16777343

Example: 192.168.1.102 = 192 + 168*256 + 1*256(squared) + 102*256(cubed) = 1711384768

Example: 67.41.45.115 = 67 + 41*256 + 45*256(squared) + 115*256(cubed) = 1932339523


In Navicat double click on the table dspdb and expand

Click on Query

Right click and select New Query

Add the following code into the empty space, inserting the value calculated above. The value in the code below (16777343) would be used if only running the client from the same PC as the server.

update zone_settings set zoneip = '16777343'

Select Run. "256 queries should be successful!" should be the result.

I recommend you save the Query in case you need to run it again later after updating the server.

Close Navicat.



Building the Servers

In this section we will be building the Dark Star servers.

Spoiler: Dark Star uses 2 servers. A Login server and a Map server. Using the ZoneIP mentioned earlier every map could have it's own server PC and IP address. If you have 4 computers each computer could run different areas as long as they were all connected to the same SQL database server.

Extract the SQL development package files we downloaded earlier. Copy the MySQL folder that was extracted. Note: there should be a "mysql" folder inside with many files. Paste that MySQL into either 32bit windows: C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include 64bit windows: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include Afterwords the folder structure should be ...Microsoft SDKs\Windows\v7.0A\Include\MySQL Open Visual Studio Build the Login Server Click File, Open, Project/Solution (or Ctrl+Shift+O) Navigate to C:\dsp\win32\DSConnect-Server Select DSConnect-server.sln (usually the first one) It may take a few minutes to load files. Click Debug then Build Server (or F7, or Ctrl+Shift+B) Building will take a few minutes. Once complete, validate that there are no Errors listed in the summary line at the bottom. It should look like this:

 Code:
==== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ====

If there are any SQL errors it is probably caused by the SQL dev package was extracted to the wrong folder. If there is a #include error, change that #include to say #include <mysql/mysql.h> Build the Map Server Click File, Open, Project/Solution (or Ctrl+Shift+O) Navigate to C:\dsp\win32\DSGame-Server Select DSGame-server.sln (usually the first one) It may take a few minutes to load files. Click Debug then Build Server (or F7, or Ctrl+Shift+B) Building will take a few minutes. Once complete, validate that there are no Errors listed in the summary line at the bottom. It should look like this:

 Code:
==== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ====

If there are any SQL errors it is probably caused by the SQL dev package was extracted to the wrong folder. If there is a #include error, change that #include to say #include <mysql/mysql.h> Validate that in the C:\dsp directory there are two new files, DSConnect-server.exe (Login Server), and DSGame-server.exe (Map Server).



Configuring the Servers

Now you will configure the Login Server and Map Server to connect to the MySQL database.

Spoiler: Do not mess with any other settings in these files unless you know what they are for and what they do.

Login Server Settings In windows explorer navigate to c:\dsp\conf Open login_darkstar.conf in a text editer (notepad) Scroll down to the bottom and validate/update the following lines:

 Code:

mysql_host: 127.0.0.1 mysql_port: 3306 mysql_login: root mysql_password: root <-- change this to your password you wrote down during the MySQL install mysql_database: dspdb Map Server Settings In windows explorer navigate to c:\dsp\conf Open map_darkstar.conf in a text editer (notepad) Scroll down to the bottom and validate/update the following lines:

 Code:

mysql_host: 127.0.0.1 mysql_port: 3306 mysql_login: root mysql_password: root <-- change this to your password you wrote down during the MySQL install mysql_database: dspdb At this point we have configured the servers to simply connect to the SQL database.



Starting the Login Server and Map Server

In this section we will launch the Login Server and Map Server

Spoiler: Navigate to c:\dsp Run DSConnect-server.exe as Admin Run DSGame-server.exe as Admin At this point if your servers fail to load, you probably missed a step. Go back through the steps and try to find out what was missed. Also it may be helpful to look at the log files located in c:\dsp\log. Note: I will be updating this guide when needed. If you still have issues or questions about setup, then read through this topic to see if someone else had the same problem. If unable to find a fix, post a reply to this topic.



Forward Ports to Allow Others to Join (& Firewall)

In this section we will provide the port numbers that need to be forwarded to the Connect/Game server. This is only needed to allow other people or your friends to join your server.

Spoiler: In your router and firewall the following ports need to be opened/forwarded to your Connect/Game server: 54230 54231 54001 If still having trouble, disable the Firewall completely for testing.


If you have any questions, feel free to post them here, or in IRC. We will do our best to answer them and then update this post as needed. Thanks!

~Cheers!!![/color]