http://tron.plantpeanuts.co.uk/viewtopic.php?t=42
Well I spoke to PTA, and he's happy for me to release the code so anyone else who wants a crack at a map rotation tron server can have a go, using the same tools that we use.
I am no computer genius, I have a basic understanding of linux and using a ssh connection to admin a server. Anyone who has this can run a similar server, it aint Rocket Science.
I will first explain how I install and run armagetronad-dedicated. As I have about 7 tron servers, believe it or not, that are up or down at any one time. So I need an easy way to control these.
My English skills are poor, my head screwy (I should have spent more time in school, less time taking drugs), but I'll do my best to put a tutorial together that anyone with some basic computer skills can follow. Starting with installation, ending with the map rotation script. Not saying my way is the best way, it certainly isn't the only way. But it does work.
I don't have root access to the server that runs CT Wild. This is not necessary. I compile armagetron-dedicated from source using the --prefix option. I have changed the names and colours of the teams on my server, just for fun. If you want to do this you need to do this before compiling:
http://forums.armagetronad.net/viewtopic.php?t=3045
I then compile using:
./configure --prefix /home/ed/tron --disable-glout
after this run make && make install to install the thing.
This will install armagetron-dedicated ONLY into dir /home/ed/tron
For each server I run I have a directory dedicated to them. So, wild has a dir: /home/ed/wild
within here I create 3 dir's: config, log and var
Then we need the config. All the settings I use are more or less the same as standard Bugfarm fortress, which are all ready to use in the basic install.
You need to copy all the files from the default config files into /home/ed/wild/config. In my case I copied them from: /home/ed/tron/etc/games/armagetronad-dedicated/
I now have all the default config files within /home/ed/wild/config make sure it's these ones you modify, that way if you mess them up, you can always go back to the original.
Although it's not considered good practice and the file itself tells you not to do it, I go ahead and modify the file settings_dedicated, changing TALK_TO_MASTER to 1 so your server appears on the main server list. And change server name, etc to your own. And a few others I add, like:
CYCLE_RUBBER_WALL_SHRINK 0.5
CYCLE_RUBBER_WALL_SHRINK_OVERRIDE 0
the important line to add at the base of the file is:
Include examples/cvs_test/fortress_complete.cfg
This will set the server up as a clone of fortress. Everything else is added to that. I won't go into great detail about the settings I change, nothing major, just change winzone to dz, alter dz timeout settings, etc. If anyone wants a copy of my config files, just ask.
to run this server I have a simple bash script to make it easier for myself. This looks like:
Code: Select all
#!/bin/sh
tron="/home/ed/tron/bin/armagetronad-dedicated"
config="/home/ed/wild/config"
var="/home/ed/wild/var"
log="/home/ed/wild/log/wildlog.txt"
$tron --configdir $config --vardir $var | tee -a $log
The "tee" program running there simply outputs to screen as well as writing to the log - so I can see any problems.
I run all this in a screen session, as I'm connecting via ssh.
with this we now have a clone of Bugfarm Fortress, with the exceptions of any modifications made to the config files. In my case, very few.
Now let's get onto the map rotation.
One problem with changing settings in each round is that let's say I wanted to change a setting for chico's eye, which uses
<Setting name="CYCLE_BRAKE" value="-50"/>
meaning brake will actually act as a boost.
Unless I tell tron server to change that setting back to default it will continue to use this setting for the next map, and the next one, etc. Not something we want.
I get around this by having 2 everytime.cfg files. One at:
/home/ed/wild/config/everytime.cfg
This file is loaded at the end of every round and contains every setting that I use that changes from map to map. It looks like this:
Code: Select all
FORTRESS_CONQUERED_KILL_MIN 0
FORTRESS_CONQUEST_DECAY_RATE .1
FORTRESS_CONQUEST_RATE .3
FORTRESS_DEFEND_RATE .2
WIN_ZONE_INITIAL_SIZE 40
WIN_ZONE_RANDOMNESS 0
WIN_ZONE_DEATHS 1
WIN_ZONE_EXPANSION 4
CYCLE_BRAKE 30
CYCLE_BRAKE_REFILL .1
CYCLE_BRAKE_DEPLETE 1
SP_WALLS_LENGTH 400
WALLS_LENGTH 400
CYCLE_ACCEL_RIM 0
CYCLE_ACCEL 20
CYCLE_SPEED 30
CYCLE_START_SPEED 20
CYCLE_SPEED_MIN .25
CYCLE_RUBBER 5
CYCLE_TURN_SPEED_FACTOR .95
So after each round all settings are set back to default. The new map then loads with it's unique settings. Then after the round they are set back again, etc.
That is why, if you play there, you see settings changing all over the place.
The second everytime.cfg is kept in:
/home/ed/wild/var/everytime.cfg
This is the one that changes the map file at the end of every round. I just copied from it now and it says:
Code: Select all
MAP_FILE ed/fortress/slingshot-0.0.1.aamap.xml
ROUND_CENTER_MESSAGE Round 5 - Slingshot
Code: Select all
MAP_FILE ed/fortress/chico_time-0.1.4.aamap.xml
ROUND_CENTER_MESSAGE Round 6 - It's Chico Time
So all we have to do it look at the log file that is being written to. See what round we're on and update /home/ed/wild/var/everytime.cfg with a map and center message.
I created a folder called /home/ed/mapscript
in here we have four files:
start_map.sh
mapcycle2.sh
tron.class.php
tron.php
It all starts with the bash script start_map.sh that looks like this. I run this one in a new screen session:
Code: Select all
#!/bin/sh
log="/home/ed/wild/log/wildlog.txt"
tail -n1 -f $log | /home/ed/mapscript/mapcycle2.sh
Code: Select all
#!/bin/bash
while true
do
line=""
read line
echo $line
/home/ed/mapscript/tron.php "$line"
done
Code: Select all
#!/usr/bin/php
<?php
$line=$argv[1];
include("tron.class.php");
$tron=new tron;
$tron->mysql_start();
if (substr($line,0,13)=="[0] Go (round"){
for ($i=1;$i<13;$i++){
if ($line=="[0] Go (round ".$i." of 12 )!"){
if ($i==12){
$tron->map_cycle(1);
} else {
$tron->map_cycle($i+1);
}
}
}
}
?>
Code: Select all
class tron {
//
// Start Config
var $cfg_host="localhost";
var $cfg_user="mysqlusername";
var $cfg_pw="mysqlpassword";
var $cfg_db="tron";
var $cfg_file="/home/ed/wild/var/everytime.cfg";
//
//
// End Config
//
//
function mysql_start(){
mysql_connect($this->cfg_host,$this->cfg_user,$this->cfg_pw);
mysql_select_db($this->cfg_db);
}
function mysql_stop(){
mysql_close();
}
function map_cycle($round){
$mapquery=mysql_query('SELECT * FROM maps WHERE round="'.$round.'"');
$maps=mysql_num_rows($mapquery);
srand ((double)microtime()*1000000);
$mapnumber = rand(0,$maps-1);
$mapname=mysql_result($mapquery,$mapnumber,'maps.mapname');
$mapfile=mysql_result($mapquery,$mapnumber,'maps.mapfile');
if ($round==12){
$content='MAP_FILE '.$mapfile."\nROUND_CENTER_MESSAGE Final Round - ".$mapname."\n";
}else{
$content='MAP_FILE '.$mapfile."\nROUND_CENTER_MESSAGE Round ".$round.' - '.$mapname."\n";
}
$this->filewrite($content,'new');
}
function filewrite($content,$mode){
if ($mode=="new") {
$execfile=fopen ($this->cfg_file,'w+');
} else if ($mode=="add"){
$execfile=fopen ($this->cfg_file,'a+');
}
fputs($execfile,$content);
fclose($execfile);
echo $content;
}
}
?>
What does the maps table look like?
If I run a query SELECT * FROM maps;
I get this:
Code: Select all
mysql> select * from maps;
+----+-------+----------------------------------------------------------+-------------------------+---------------+
| id | round | mapfile | mapname | server |
+----+-------+----------------------------------------------------------+-------------------------+---------------+
| 1 | 1 | ed/fortress/pillar-0.0.7.aamap.xml | Pillar | wildfortress1 |
| 2 | 1 | ed/fortress/lookout-0.0.6.aamap.xml | Look Out! | wildfortress1 |
| 3 | 1 | ed/fortress/johnny-0.0.2.aamap.xml | Hello, my name's Johnny | wildfortress1 |
| 4 | 2 | ed/fortress/minefield-0.0.7.aamap.xml | Minefield | wildfortress1 |
| 5 | 2 | ed/fortress/minepillars-0.0.3.aamap.xml | Mine Pillars | wildfortress1 |
| 6 | 2 | ed/fortress/hairbrush-0.0.2.aamap.xml | HairBrush | wildfortress1 |
| 7 | 3 | ed/fortress/octazigzag-0.0.3.aamap.xml | Octagon Wiggle! | wildfortress1 |
| 8 | 3 | ed/fortress/octagon-0.0.2.aamap.xml | Octagon Fortress! | wildfortress1 |
| 9 | 10 | ed/fortress/hexagon_triangles-0.0.3.aamap.xml | Hexagonal Triangles | wildfortress1 |
| 10 | 3 | ed/fortress/octagoneloopy-0.0.1.aamap.xml | Octa Gone Loopy! | wildfortress1 |
| 11 | 4 | ed/fortress/arcanoid-0.0.6.aamap.xml | Arcanoid | wildfortress1 |
| 12 | 4 | ed/fortress/behind_you-0.0.9.aamap.xml | Behind You | wildfortress1 |
| 13 | 5 | ed/fortress/slingshot-0.0.1.aamap.xml | Slingshot | wildfortress1 |
| 14 | 5 | ed/fortress/speed_dome-0.0.7.aamap.xml | Speed Kills | wildfortress1 |
| 15 | 5 | ed/fortress/speed_city-0.0.2.aamap.xml | Speed City | wildfortress1 |
| 16 | 6 | ed/fortress/chico_time-0.1.4.aamap.xml | It's Chico Time | wildfortress1 |
| 17 | 6 | ed/fortress/chico_teamsumo-0.0.4.aamap.xml | It's Chico Sumo | wildfortress1 |
| 18 | 6 | ed/fortress/hourglass-0.0.4.aamap.xml | Chico's Hourglass | wildfortress1 |
| 19 | 7 | ed/fortress/boxes-0.0.6.aamap.xml | Little Boxes | wildfortress1 |
| 20 | 7 | ed/fortress/columns-0.0.1.aamap.xml | Little Columns | wildfortress1 |
| 21 | 7 | ed/fortress/circles-0.0.3.aamap.xml | Little Circles | wildfortress1 |
| 22 | 7 | ed/fortress/little_spiral-0.0.5.aamap.xml | Little Spirals | wildfortress1 |
| 23 | 13 | ed/fortress/mini-0.0.6.aamap.xml | Mini | wildfortress1 |
| 24 | 8 | ed/fortress/nano-0.0.4.aamap.xml | Nano | wildfortress1 |
| 25 | 11 | ed/fortress/chico_clover-0.0.4.aamap.xml | Chico's Clover | wildfortress1 |
| 26 | 11 | ed/fortress/chicoeye-0.0.3.aamap.xml | Chico's Eye - Brake! | wildfortress1 |
| 27 | 11 | ed/fortress/houreye-0.0.2.aamap.xml | Chico's Wild Ride | wildfortress1 |
| 28 | 12 | ed/fortress/diamond_death-0.0.8.aamap.xml | Diamond Death | wildfortress1 |
| 29 | 12 | ed/fortress/diamond_sumo-0.0.5.aamap.xml | Diamond Sumo | wildfortress1 |
| 30 | 3 | ed/fortress/octagon_weasel-0.0.1.aamap.xml | Octagon Weasel | wildfortress1 |
| 31 | 9 | ed/fortress/desperate_housewives-0.0.1.aamap.xml | Desperate Housewives | wildfortress1 |
| 32 | 12 | ed/fortress/diamond_masacre-0.0.1.aamap.xml | Diamond Massacre | wildfortress1 |
| 33 | 9 | ed/fortress/grand_designs-0.0.1.aamap.xml | Grand Designs | wildfortress1 |
| 34 | 13 | ed/fortress/magic_roundabout-0.0.2.aamap.xml | Magic Roundabout | wildfortress1 |
| 35 | 13 | ed/fortress/little_bear-0.0.2.aamap.xml | Little Bear | wildfortress1 |
| 36 | 8 | ed/fortress/nano_knightmare-0.0.5.aamap.xml | Nano Knightmare | wildfortress1 |
| 37 | 4 | ed/fortress/crossfire-0.0.1.aamap.xml | Crossfire | wildfortress1 |
| 38 | 9 | ed/fortress/staff-0.0.1.aamap.xml | The Mighty Staff | wildfortress1 |
| 39 | 6 | ed/fortress/chico_nano-0.0.5.aamap.xml | Chico in Nanoland | wildfortress1 |
| 40 | 10 | ed/fortress/three_deadly_hexagonal_sumos-0.0.7.aamap.xml | Three Deadly Hex Sumo's | wildfortress1 |
| 41 | 8 | ed/fortress/nano_sumo-0.1.2.aamap.xml | Nan's Team Sumo | wildfortress1 |
| 42 | 10 | ed/fortress/death_of_hex-0.0.3.aamap.xml | Death of Hex | wildfortress1 |
| 43 | 9 | ed/fortress/staffs_tomb-0.0.2.aamap.xml | Staffs Tomb | wildfortress1 |
+----+-------+----------------------------------------------------------+-------------------------+---------------+
43 rows in set (0.00 sec)
And I think that's it. If you spot any errors, let me know. I hope it's useful to someone.
As I said this is just the way I do it. There are many alternative ways.