Blog

Astro Empires / Tribal Wars – Great new way of wasting time!

Recently I’ve been playing a game that Lionel put me on to called Tribal Wars which is very good fun. Basically its a web based strategy game where you build up your village, recruit some thugs, and plunder other villages around you, eventually taking over other villages and growing your empire. To help all this you can also if you wish join a guild and enlist the help/protection of hundreds of other players. The best part of all is the fact that it is set up to play over a very long time. Building and recruiting is done over a span of hours, along with resource build up. This means that you can set something up in the morning, go to work and leave it to run its course.

After playing that for a month or two, I’ve had a look for a different one to play with a more sci-fi theme and have no found one called Astro Empires. The basics are very similar to Tribal Wars except on a larger scale. In this you set up your base and build up your structures whilst researching new technologies. Once you get to a certain level you then start sending out your scouts and outpost ships to colonise new planets. Again you have the choice of joining guilds to help you which comes in very handy if someone decides to attack you! Astro Empires is actually a lot more flexible than Tribal Wars, with a lot more scope for designing your base, the ability to set up trade routes, and also hire commanders with certain skills to help you run your bases.

Both games are free, with the choice of paying for an account upgrade (both offer free trials of upgrades) to give you various benefits such as larger construction queues and an advanced interface. Definately worth a try, click the banner below to play Astro Empires!


Play in the Park

Thankfully, on friday, we actually managed to remember that we had tickets to see a ‘play in the park’ at Williamson’s Park. Earlier in the year we’d managed to forget that we had tickets, only remembering a couple of days later!

We’d been planning on going to a play for a number of years, but this is the first time we’ve actually managed to be ‘cultured’ and go and see one. Unfortunately we didn’t fancy the Duke’s one this year, so we decided to watch a traditional Shakespeare one, a Midsummer Nights Dream by the Chapterhouse Theatre Company.

We wandered up to the park about half an hour before it started to pick up our tickets and get some good seats. I’m glad we did seeing as it got rather busy, infact I think the dell (main ampitheatre in the park) was packed by the time the show started. One of the theatre company came out and introduced the show, also telling us that in the event of rain, we’d get wet, which was nice of him! The whole play was performed by the same eight actors, who definately got a lot of practice at quick changes. It was all rather well done and you soon learnt to associate with the costumes rather than the faces of the actors.

It did attempt to rain on a couple of occasions, which was met by a lot of rustling of coats, macs and umbrellas. In fact, there were some pretty thoughtless people in the middle of the audience who seemed to think that people could see through their ‘brollies! The rain didn’t amount to much and we only got a little damp, but noone seemed to care.

All in all, it was a play not to be missed and we’ll definately be going back to watch some more when they start again next year. If you get a chance to go to one, you’d be a fool to miss it! Hopefully the Duke’s will put on a play that we both want to see as theirs are set in various locations around the park which should make it even more interesting!

Caller ID from Asterisk to all phones, MythTV’s and SqueezeBoxes

Well, I had some spare time and finally got round to getting CallerID sorted on my phones. I’ve had it enabled on the line for a while now, and even had it doing database lookups to display a name on the phone handsets as well as the number, tho’ that broke when I upgraded Asterisk. I have, however, sorted out that problem and expanded everything a little.

Now, when the phone rings, the number is looked up in a database of known numbers, then sent out to all the phone handsets as well as any active MythTV frontend or Squeezebox on the network! If we are watching the TV a box pops up with the time, date, number, and if found, name of the incoming call. Likewise if we are in the library where we can’t actually hear the phone, then the Squeezebox display will change to the name and number and we can decide wether to answer it or not!

All this is done using a feature in Asterisk call AGI, or Asterisk Gateway Interface. This is very similar to CGI scripts found on web pages. AGI scripts are run from the Asterisk dialplan to do various things. In this case the AGI perl script is run and the incoming call number is passed to it. This number is looked up in a database to see if its a known number. Wether it is known or not, the script sets the full CID info in Asterisk.

It then procedes to use a utility call cidbcast that is in the contrib directory of MythTV. This cidbcast sends out a UDP broadcast over the network to any listening machine, in this case the MythTV backend server which has the mythudprelay program running, another one from the MythTV contrib directory. This picks up the broadcast and sends the message to all MythTV frontends using mythtvosd.

Lastly the AGI script connects to the SlimServer which controls all the Squeezeboxes. Talking over the CLI port (9090) on the server it gets a list of all current players and proceeds to send a simple two line display message consisting of the number and name. The majority of this part of the script is a simple cut and paste of the relevant parts of the Squeezebox plugin written by Max Spicer.

All in all this is a fairly simple thing to implement, but is very useful for those as lazy as me!

Script

#!/usr/bin/perl

use DBI;
use IO::Socket;

# MySQL settings for asterisk
my $dbhost = 'localhost';
my $dbuser = 'asterisk';
my $dbpass = 'asterisk';
my $dbname = 'asterisk';

# Slimserver Settings
my $serverAddress = 'mythbe-1';
my $serverPort = 9090;
my $maxVolume = 75;
my $displayTime = 30;
my $debug = 0;

# Mythtv Setting
my $mythxmlfile = '/usr/lib/asterisk/cidbcast.xml';



################
# Get name from mysql for the incoming number
#
$|=1;

#Get the initial data
     my %input;
     while() {
         chomp;
         last unless length($_);
         if (/^agi_(\w+)\:\s+(.*)$/) {
         $input{$1} = $2;
     }
}

my $dbh = DBI->connect ("dbi:mysql:host=$dbhost:database=$dbname","$dbuser","$dbpass") or die "Can't connect to database: $DBI::errstr\n";
my $sth = $dbh->prepare( "SELECT cid FROM known_numbers WHERE source='$input{callerid}'" );
$sth->execute();
@row = $sth->fetchrow_array();
$cidname = @row[0];
print "SET CALLERID \"@row\"<$input{callerid}>";

###############
# Broadcast info to MythTV
my $command;
$command = "cidbcast --once --file=$mythxmlfile 6947 $input{callerid} \"$cidname\" line";
system("$command &> /dev/null");

################
# Send out to squeezeboxes
# Code ripped from Squeezebox CID plugin by Max Spicer
# http://www.thespicers.net/cid.html
#

my $socket = IO::Socket::INET->new (PeerAddr => $serverAddress,
                                    PeerPort => $serverPort,
                                    Proto    => 'tcp',
                                    Type     => SOCK_STREAM)
or die 'Couldn\'t connect to server';

# Get the number of players
my $playerCount = sendAndReceive('player count ?');
$debug && print "$playerCount players found\n";

# Display message on each player and adjust volume if necessary
for (my $i = 0; $i < $playerCount; $i++) { my $playerId = sendAndReceive("player id $i ?"); # Put the players display at max brightness if it's currently 0 my $powerState = sendAndReceive("$playerId power ?"); my $brightnessPref = $powerState ? 'powerOnBrightness' : 'powerOffBrightness'; my $brightness = sendAndReceive("$playerId playerpref $brightnessPref ?"); $debug && print "brightness: $brightness\n"; if ($brightness == 0) { sendAndReceive("$playerId playerpref $brightnessPref 4"); } $cidname =~ s/\s/%20/g; $debug && print("Sending: $playerId display Incoming%20call:%20$input{callerid} $cidname $displayTime\n"); sendAndReceive("$playerId display Incoming%20call:%20$input{callerid} $cidname $displayTime"); # Drop the volume if necessary my $playerMode = sendAndReceive("$playerId mode ?"); $debug && print "playerMode: $playerMode\n"; if ($playerMode eq "play" && sendAndReceive("$playerId mixer volume ?") > $maxVolume) {
    $debug && print "Decreasing volume\n";
    sendAndReceive("$playerId mixer volume $maxVolume");
  }
}
$debug && print "\n";
exit 1;

# Send given cmd to $socket and return answer with original command removed from
# front if present.  Routine nicked from code by Felix Mueller. :-)
sub sendAndReceive {
  my $cmd = shift;
  return if( $cmd eq "");

  print $socket "$cmd\n";
  $debug > 1 && print "Sent $cmd to server\n";
  my $answer = <$socket>;
  $debug > 1 && print "Server replied: $answer\n";
  $answer =~ s/$cmd //i;
  $answer =~ s/\n//;

  return $answer;
}

Database table structure

mysql> describe known_numbers;
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| source | varchar(13) |      | PRI |         |       |
| cid    | varchar(26) |      |     |         |       |
+--------+-------------+------+-----+---------+-------+

When two heads aren’t enough!

Just having a dual head display just wasn’t enough. I went the whole hog, bought myself a PCI graphics cards and another identical monitor!

Its all up and running, but I just can’t get 3d acceleration to work on it properly. I’ve only had a quick go, and everything seems to be right, but glxgears just crashes. Its only really a problem if I want to play games, and for the time being I’ve got too many other things to do!

I’ve got two heads!

I’ve been meaning to do it for a while, but I’ve finally bought myself a second head! No, not one to go on my neck, Zaphod style, but another LCD monitor on my computer.

Two heads are better than one!

This means that I now have to monitors side by side, with the ability to simply move my mouse from one to the other. It makes using my computer a lot easier. I can just keep my email and such like open on one screen, and carry on my work on the other. Windows can be picked up from one screen and dragged over to the other, even being left in the middle of the two, tho’ this makes it harder to use due to the surroundings of the monitors.

Both monitors are the same model. I got one last year to replace my old one that seemed to be getting watermarks on it and have been very impressed with it. The model is AG Neovo F419, and I may well be getting another one for full triple header wonderfullness!

Setting this up is very easy, just needing a couple of extra configuration parameters in the X config file. I’m using a GeForce Quadro 4 card with Dual DVI outputs which gives fantastic performance. Running glxgears gives me 1900+ FPS, even when the gears window is moved from screen to screen.

Changes needed to get it working were in the /etc/X11/xorg.conf file under Kubuntu 6.06 in the ‘Device’ section for the graphics card:

Section "Device"
        Identifier      "NVIDIA Corporation NV28GL [Quadro4 980 XGL]"
        Driver           "nvidia"
        BusID           "PCI:1:0:0"
        Option          "NvAGP" "1"
        Option          "RenderAccel" "true"
        Option          "TwinView" "true"
        Option          "MetaModes" "1280x1024,1280x1024;1024x768,1024x768"
        Option          "TwinViewOrientation" "DFP-0 LeftOf DFP-1"
        Option          "ConnectedMonitor" "DFP,DFP"
EndSection

The magic lines are from the ‘TwinView’ option down. TwinView basically makes the two screens act as one extra long one as far as the computer and the window manager are concerned. The ‘MetaModes’ line then splits the new big screen back into two smaller ones. It does this so that things that know how to handle seperate monitors can program them both seperately such as allowing different wallpapers etc. It also makes sure that 3d games don’t try and use both screens, which with only two monitors means that, for example in FPS games, the view point is right in the middle of the two monitors. The ‘TwinViewOrientation’ simply tells the computer where the two monitors are in respect to each other so that you can place the second one on the left or right of the main one. The last line ‘ConnectedMonitor’ should not really be needed, being auto detected, but I put it in just to make sure. It simply says that the two monitors connected are digital flat panels.

All in all the setup took about 20 mins from getting the monitor out of the box, wiring it up (realising that my original monitor was actually connected to the second output, so had to switch them round), getting the brightness and contrast set to the same on both monitors (quite important to make it look good, and very easy to do with identical monitors) and reconfiguring X.

I’m definately going to look into getting a third one at some point, but I’d then need a second PCI graphics card. Or maybe I’ll take the chance to upgrade my PC and get a PCI-X based system with multiple graphics cards! 🙂 I’ll also have to rearrange my cellar to fit 3 monitors on my desk!

LugRadio Live 2006

As most people know, I’m a linux geek and a member of the Lancaster Linux User Group (LUG). Well, Martyn and I travelled down to the LUGRadio Live meeting in Wolverhampton last weekend. If you don’t know what LUGRadio is, it is a podcast run by four rather funny linux guys. Once a year they have a get together for all their listeners and lay on all sorts of entertainment, speakers, and exhibits. To read about what went on, take a look at the Lancaster LUG website.

We’ve got a library!


Between us, we’ve got one or two books! Too many for the current amount of shelves, so books were starting to pile up everywhere and finding them was getting increasingly hard. I also wanted somewhere to chill, with (nearly) no electronics. The only gadgets in the room are a squeezebox (and speakers) from Slimdevices. Its a fantastic bit of kit, which not only lets me play all my MP3s off my server in the cellar, but also listen to pod casts, streaming radio stations (including Radio 1, 2, 3, etc) and play tetris! It doubles as a handy clock too! The other gadgety type things in the library are a dimmer switch and remote power switch, both using X10, a protocol to control electrical goods over your existing wiring. Eventually, the speakers attatched to the squeezebox will be powered on and off automagically when needed.

Thanks go to my parents who bought me the worlds most comfy chair for my birthday. Believe it or not, it is from Argos, but is exactly what we were looking for. It is quite easy to fall asleep in, as a few people have already found out. Argos number: 6409492

Thanks to the Emilys and co. too for the fantastic reading lamp they bought for Joy’s birthday. It was exactly what we needed, but that could be due to Joy being with you when you bought it!

The room is nearly finished. The curtains went up yesterday and I may (yeah, right) get round to tidying up the network cable to the squeezebox this week whilst I’m off. The only major job left to do is paint the radiator cover, but thats a job for the artist!

Feel free to come round and have a look! Friends are equally free to come and relax if they need to get away and read for an hour or two!

Darren.