Feeds:
Posts
Comments

Archive for the ‘taspring’ Category

the wiki.nixos.org mediawiki theme

for some time i am hosting muse-sequencer.org with a mediawiki but i never was able to design a nice custom layout like it is done on spring RTS [1] for example. however, i often use the ‘clean’ theme which looks much better than the standard mediawiki theme.

anyway, there are times when you need a ‘custom theme’, especially when you have to integrate a custom menu bar (as shown in the top part of the nixos-wiki-theme screenshot below). the advantage is that the wiki page feels ‘integrated’ into the page and especially as the top level menubar helps to navigate the site it can be used to get out of the wiki again.

therefore, not integrating the main navigation menu into the wiki stylesheet causes a huge hit on usability as users have to alter the URL filed in order to get back to the other pages. and the wiki not looking like the rest of the pages also degrades the look and feel.

for quite some time i did not want to learn that much CSS and php/html but lately the integration of wiki.nixos.org into the nixos.org domain made me think otherwise and so i started to hack a new stylesheet [2] based on the ‘clean’ skin [3] i already debugged for my page ‘lastlog.de’.

i needed about 9hours to make the design final and i would like to thank zmlka@irc.freenode.net#nixos for his help and fine tuningi would also like to thank viric@irc.freenode.net#nixos for his general attributions towards a nice mediawiki.nix modification which makes it easy to handle several third party mediawiki stylesheets. i might upload these modifications upstream (nixpkgs) soon – if i find the time.

i hope nixos.org folks will use the new style soon!

external and internal links

one nice thing i discovered while creating the nixos mediawiki theme was that it is very easy to add external links. i always thought this to be very complicated.

the nixos-mediawiki-theme does have two menues: a top level menu (header) and a bottom menu (footer). i used require_once(..), which is a php command, to include ‘header.php’ and ‘footer.php’.

this way the style can be extended without having to touch the the style. this is especially nice as nixos wants a stateless packages and one can set the ‘links’ from the /etc/nixos/configuration.nix context.

another nice thing is that it is very easy to add ‘internal’ links, that means: the menu generated from ‘header.php’ can be used to add links which will also end in the mediawiki:

this will create an external link:

this will create an internal link

  • <li><a href=”demo”>Demo</a></li>

conclusion

although it was very time consuming for me to write this stylesheet (except for my ‘ajax patterns’ [4] project i’ve never done that before) i learned quite much about stylesheets, thus i encourage you to do the same for your page. soon i will write a little guide how to do that in more detail.

it is also worth mentioning that CSS can be used to make the content 100% independent of the position in the page but contrary to all my expectations this might not be a default for most pages.

i would also like to recommend firefox+firebug as this helps to analyze css/html errors and also helps to make experimental modifications on the fly!

links

[1] https://springrts.com

[2] https://github.com/qknight/nixos

[3] https://github.com/qknight/clean

[4] http://lastlog.de/wiki/index.php/Ajax_patterns

Advertisements

Read Full Post »

today i wanted to play a game of spring [1] with a friend but it didn’t work. i was using windows xp (not linux but yes this is even more _usual_ there) and i downloaded spring with the nice little lobby called ‘springlobby’. i even remembered my login for the lobby interface. after connecting we wanted to use skype which didn’t work for about 15minutes (yes i was using my linux laptop and the sound there usually suckz as it tends to block the soundcard for some unknown reason quite often). but the problem was also the new account on the other end which had to be created but which didn’t work. after a couple of skype restarts on both sides it was starting to work. (not mentioning the issue of adding a new contact…).

so the lobby was running and we could talk using skype, what else could go wrong?

right after wards i hosted a game (i didn’t expect it to work since i didn’t do any manual port forwarding for the kind of random ip i usually have). i didn’t see the ‘nat traversal’ option in springlobby first (because i tend to join other games instead of hosting exactly for this kind of issue). so the game failed but to detect it – especially if several ppl join your game – you have to launch the game. so the game starts in fullscreen (it’s an opengl application) and computes some routes (waypoints or whatever) which is important for the ai (also for the own units) for pathfinding. waiting about 40 seconds to see that the connection didn’t work.

so next i rehosted the game using ‘nat traversal’ clicked. but it didn’t work either. no error message and no diagnostics of the issue. just a silent fail – which is what i tend to hate most (except a silent fail after a timeout which i even hate more).

finally my friend tried to host a game (he is also behind NAT – but who is not nowadays?). of course the same problem – it didn’t work. but skype once the audio part worked keept working. skype managed to traverse the NAT (or at least was using a relay we didn’t know of – which is the usual fallback used by skype, see [2]).

this reminded me however of the solution for this problem i was thinking of quite some time ago when i wrote a lobbyclient myself [3] together with two friends.

the question is: “how to establish a connection before game launch?”

two answer this question we will have a look at how a game launch works right now.

  1. using springlobby to connect the the tasserver (that is the springlobby server which hosts the chat and the game preparation – a chatroom exchanging the gamedetails as map/teams and the ip of the server)
  2. in springlobby creating new game -> ‘host a game’
  3. other players see this game in a list and join it (the tasprotocol is quite ugly but this is not of interest now)
  4. now every player (not the hoster) has to click ‘ready’
  5. finally the game is launched by the hoster (the administrator of the game) and the hoster sends it’s IP along with a UDP Port to the other players.
  6. now a config file is created in every client, a special config is created for the hoster (hoster = server)
  7. the clients try to connect to the hoster (if the hoster isn’t already done with starting the game, which can take a while as seen above, the clients reconnect every few secons until a timeout of 40 seconds is reached). please note that while the player is waiting for that timeout he can’t read the chat log since he is already ingame which is usability wise a horrible thing to do. you can’t inform the player that the game won’t work (in case you know that already for some reason)
  8. now after the hoster managed to start the game the clients connect and the player label color changes from red (not connection yet) to green (player has successfully connected)
  9. in case every player is connected … the game can start

say the game connection didn’t work for at least one player and say an average game is joined by 4-8 ppl. please think of the time each player has to wait in average to detect a network issue. believe me ‘it is a lot of time‘ and this made the ‘autohost’ function very popular.

the autohost is a game hosted by a nice person which has a computer running 24/7 with some game starter script. if a programmed bot in the gameroom parses the chat of the players and detects some string as “!start” from the ‘virtual hoster’ the game is launched and spring.exe starts (that is the game binary). since spring.exe can’t be run dedicated it is not only a waste of power/bandwidth but also a waste of workspace. i expect the game to be run in the background but still this has lots of performance loss for the user.

autohosting is a nice thing for players but it seems – at least for me – be more like a workaround for a technological problem not solved properly.

the fix i was talking of is this:

when the ‘hoster’ is hosting a game the ‘hoster’ starts a udp-server on a random port (which is known after starting the server of course). the ip and port are then automatically given to the other players. now every player tries to connect to that ip:port right away without launching spring.exe and without creating a configuration file. if the connection from player to the hoster is working a green LED in the springlobby will light up and everyone sees the status immediately. when the game launches every client then connects – not the the hoster ip:port – but instead to localhost:port.

so now we need a tiny relay udp server with hole punching capabilities and as some might like UPnP network capabilities.

client1 (192.168.1.22) –lan– fritz!box (192.168.1.1) —– inet —————–many routers —————— inet —– fritz!box (192.168.1.1) —-lan— client2 (192.168.1.33)

as you can see both clients reside in the same subnets but this is no issue since both subnets (192.168.1.x/24) are in an address space which isn’t routed in the ipv4 internet definition and since both clients are routed by a router (fritzbox in this case, can be any other vendor as well) both are behind NAT (network address translation) – which is our problem in the first place.

our small udpserver (i call it “udpPuncher“) would require:

  • relaying udp packets from one ip to another, no parsing of the udp packets at all
  • libNAT (to have UPnP capabilities)
  • holepunching (a udp nat traversal technique which is quite common)
  • and some interface (either a socket or a dbus like interface) to control and query the relay
  • some easy logic to report to the springlobby that the playerX has successfully connected to the hoster

so you might say that is no new technology.

  • maybe not but don’t forget that most games are hosted by expensive servers (battle.net from blizzard or others). some games have a dedicated client (very often a even a linux client) you can install and run on a internetserver which is not behind a NAT and which has lots of bandwidth (most important aspect here is the upload speed and latency).

i’ve never seen such a udpserver or library. all i know are a couple of projects trying to solve that issue. take sip as an example – they have the same problem there and they often give you a stun server (udp holepunching) to relay connection establishment.

there was a nice project i came along [4] which checked the NAT capabilities of your own network (there was a linux and a windows client). i’m not sure about the results but this could be used to qualify the network NAT type in an attempt to write the not yet written udpPuncher.

ipv6 would be a nice solution but i doubt this will be here soon as nobody seems to have interest in ipv6.

[1] http://springrts.com/

[2] http://en.wikipedia.org/wiki/Skype_protocol

[3] http://code.google.com/p/qtlobby/

[4] http://nattest.net.in.tum.de/?mod=infos&lan=de

UPDATE:

I just found out that [4] is not new at all (maybe it is but not but at least for me it is), i’ve read [5] some long time ago but didn’t remember it. Now here is a very detailed documentation about NAT with illustrated (but not animated ;-P) examples of usage:

[5] http://www.brynosaurus.com/pub/net/p2pnat/

Read Full Post »