Getting Started, read this to get started building the code

Shield
posted Quote

Below are instructions on how to get the code for War Worlds, how to build a local server, get it up and running, and also build a client that will connect to that server.

Prerequisites

You will need the following installed on your machine before you begin:

  • Eclipse + Android SDK
  • Postgresql (I use 9.3, but any recent version should work)
  • Java JDK 1.7+
  • Ant (any recent-ish version should be fine, I have 1.9.1)

The following instructions assume you're running on Linux, but it should (in theory) be possible to build & run the server on Windows or Mac OS without too much modification of the steps below. In the past, I've tried building on Windows, and the main difficulty comes from the fact that I have a few symlinks throughout the code which can be a bit painful on Windows. See this Stack Overflow post for some possible workarounds.

Getting the code

The code is available from Github: https://github.com/codeka/wwmmo

If you plan on contributing code back, I recommend you start by forking the repository by clicking the "Fork" button on that page. For the purposes of this walkthrough, I'm going to assume you haven't done that, but if you do, simply replace all instances of "codeka" with your username below.

$ cd ~/src
$ mkdir wwmmo && cd wwmmo
$ git clone git@github.com:codeka/wwmmo.git code

This will take a while as it downloads the code, but once complete you'll be ready to create your database.

Creating a database

The database schema is stored in server/scripts/db.sql. First, you'll need to create a new postgresql database:

$ psql -U postgres
postgres=# CREATE DATABASE wwmmo;
postgres=# CREATE ROLE wwmmo;
postgres=# CREATE ROLE wwmmo_user LOGIN PASSWORD 'H98765gf!s876#Hdf2%7f';
postgres=# GRANT wwmmo TO wwmmo_user;
postgres=# CREATE SCHEMA beta AUTHORIZATION wwmmo;
postgres=# \q

The above should all run without error, at which point you'll have an empty database, ready to get started. You don't need to create the tables and whatnot as the server will do that automatically the first time it starts up.

Building the server

Before building the server, you'll have to create a config file. The default scripts will be looking for a file called server/data/config-debug.json. To create this file, you can copy the config-tmpl.json file you'll find in the same directory.

$ cp server/data/config-tmpl.json server/data/config-debug.json
$ nano server/data/config-debug.json

The main thing you'll need to set is the value of "dataDirectory" and the "password" field in database.

Next, the scripts in the scripts/ folder should help with building and the various components. For example, to run the server on your local computer, you'd run:

$ ./scripts/run-server.sh

Depending on whether you've configured Android Studio/gradle previously, you may get some errors, but they should be fairly straight forward to fix up (e.g. missing local.properties file).

If that's successful, you should see a bunch of log messages printed out from the server, ending with "Next event is scheduled at "...

To build the server's .zip file and copy it to the server (assuming you have SSH access to the server) you'd run:

$ ./scripts/deploy-server.sh

Leave the server running, next up we need to build the client.

Building the client

In order to run the client on your phone, you will need to make sure you don't have the Play Store version of War Worlds installed. I tend to use a dedicated device for running my "test" builds on, but if you don't have a spare phone lying around, you can use your own device by first uninstall the Play Store version of War Worlds.

The run-client.sh script will build and deploy the client to your phone. You'll probably need to edit the script to change the paths to the Android SDK and so on.

You will also need to get the AndEngine source code from github. Be sure to use my fork (or make your own fork of my fork) because I've made some changes to the library.

$ cd
$ cd ..
$ git clone git@github.com:codeka/AndEngine.git andengine

At this point, you should have the "code" directory (which is the root of the War Worlds respository) next to the andengine folder.

Similarly, you'll need the extras/android/support/v7/appcompat folder copied from your android SDK to the same directory (assuming $ANDROID_SDK points to your Android SDK installation):

$ cp -R $ANDROID_SDK/extras/android/support/v7/appcompat .
$ $ANDROID_SDK/tools/android update project --path appcompat

The andengine project won't have a local.properties file, but we can use the one we just generated above:

$ cp appcompat/local.properties andengine/local.properties

You're now ready to build the client!

$ ./run-client.sh

If that is successful, you should see a message at the end about "BUILD SUCCESSFUL" and starting an intent. Open up your phone, and the game should already be running in debug mode (if not, you might have to start it. for some reason that "Start intent" thing doesn't always work).

You can tell you're in debug mode because there'll be a little debug output in the top-right of the screen, and the version number will be something like "0.5.830 (debug)".

Connecting to your test server

Now, you should be able to connect to the Beta realm like normal, but you probably want to connect to your debug server. You will notice on the "Select Realm" a new entry for "Debug". If you choose this realm, you probably won't be able to connect. That's because it's hard-coded to use my development machine's local IP address in the code. To remedy that, edit the file client/src/au/com/codeka/warworlds/model/RealmManager.java, and change the line that reads:

mRealms.add(new Realm(DEBUG_REALM_ID, "http://192.168.1.4:8080/realms/beta/",

Replace the IP address I have there with your own machine's IP address. Now run run-client.sh again, and this time you should be able to connect to the "Debug" realm. You'll know it's working because you'll see a bunch of log messages being printed out by your server that you had running from before. You'll have to set up a new empire (the Debug realm will be completely empty by default).

Note: You may get an exception the first time you try to create your empire, just try again and it should work the second time.

Next steps

Congratulations! At this point you should be running a debug version of the game client, connecting to your debug server. Now what?

Now you can go check out the Issues section of github, pick something to work on, and get started!

Edited by Dean,
Edited by Dean,
Edited by Dean,
Edited by Dean,
Edited by Dean,
Edited by Dean,

Shield
posted Quote

I tried to download the Eclipse+Android SDK and it took me to a page that said to click here if I hadn't downloaded it yet and it took me back to the first page.   Does someone have a link that works? 

Shield
posted Quote

You should be able to get it here: http://developer.android.com/sdk/index.html

If that doesn't work, you can install the component manually, but it's a bit of extra work. You basically install Eclipse (or just use an existing installation if you already have it), download the standalone SDK (from the link above as well), and then follow the instructions here to install the Eclipse plugin.

Shield
posted Quote

I am not able to install postgreSQL on ubuntu 14.04. Can somebody help me with this

Edited by Srinivas,

Post Reply