Thursday, July 23, 2009

Mysterious Icewind Port

This doesn't really have anything to do with Linux, but I needed to put this down somewhere so maybe it would help someone else. My friend and I like to play "hardcore" computer RPG games, cooperative style, across the Internet. We have a weekly session, playing for a couple of hours. It's the only way, really, that I would ever complete a game, as I just don't have the persistence to do it myself. I play a bit, and pretty much irregardless of how good or bad the game is, I'm always flying off, checking the next game.



Anyway, we finished Neverwinter Nights (we don't mind playing lagging edge games) and went on to play Sacred, which we picked up for cheap at the wonderful GoG (Grand Old Games) site. It was fun for the first few weeks, but then there started to be problems with the lobby server, as it isn't a direct connect game. It had become a bit of a grind, anyway, so we started looking about for a new game to play.



Unfortunately, classic, hard-core, cooperative RPG games are few and far between these days. The definitive site for all thing co-op, Co-optimus has almost no entries at all for even an action RPG to play co-op. Not sure why the well has dried up. So we decided to go really olde school and try the classic Baldur's Gate. Many years ago, in a galaxy far far away, I actually played this a bit across the 'net, but I've never really played it all that much. As I had two copies of it, I gave one to my buddy and we sat down to play it.



But we played the "Figure Out The Router/Firewall" game instead. For the next 2 hours, we tried to figure out why I couldn't connect to his server. This worked fine for both NWN and Sacred, but whenever I would type in his IP address, BG would just pause for a long time, and the come back with "Cannot Connect To Game Session". As my router is a virtually impossible to configure Juniper Netscreen router, he was hosting the games on his side. He made sure all the ports mentioned were opened, all to no avail. As well as the "official" ports (2300-2400 & 6073), someone also mentioned ports 1470, 15000, and, most importantly, ports 47624-49672. Not sure about those, but port 47624 is the DirectPlay port, so I'm not sure why this doesn't show up in the official docs.



But despite all these efforts, we just couldn't get our Baldur's Gate games to connect. So last night, we tried Icewind Dale. Still a wonderful RPG (in fact, I like it more than Baldur's Gate, despite, or perhaps because of, its more linear and hack-n-slash nature), but a slightly newer engine, esp. when updated with the Heart of Winter expansion and its Trials of Luremaster patch/expansion. So we were hoping the updated engine would be more cooperative.



But, alas, we were wrong. I still got the dreaded "Cannot Connect" error. So we then tried Hamachi, a free VPN software. Still no go. As he's a network wonk, I was sure the firewall and router was correct on his end. And I don't run a firewall at all (don't really need one if you are behind a NAT router), so it had to be my "user unfriendly pain in the butt to configure" Juniper Netgear NS5GT router. I fired up Wireshark (nee Ethereal) and began sniffing packets.



I hosted the game on another internal computer and sniffed the traffic, comparing it to the packets I was sending and receiving to my friend's machine. It was then I noticed something odd - my machine would send out a DirectPlay packet on port 47624, but it would get back the response on port 2300 on my internal connection but, of course, it wouldn't get it back from my friend's computer, because routers will allow a response on the same port but not a different one.



So I rolled up my sleeves, used some Black Belt Google Fu and found this page that describes the dozen or so steps(!) you need to go through to get it to work. I added 2300 & 47624 to my "Infinity Engine" Custom Service Object, and set the policy to forward it to my game playing machine. This got me connected but not for long. Turns out, I needed to add 2350 as well. I tried to add 2300-2400, as recommended somewhere, but the Juniper Netgear complained about not enough ports in the pool, whatever the hell that means.



And now it works. So, the basic fix is to make sure that both players port forward UDP and TCP traffic for the ports mentioned here (2300-2400, 6073) and 47624 (the DirectPlay port). I'm not sure what 6073 is for, as I don't think either of us have it set up - maybe that's an old DirectPlay service port? Yup, it is according to this (DirectPlay 8), while it say 47624 is "directplaysrvr". Not sure what the difference is, unless one is a fallback for the other. At the very least, forward ports 2300 & 2350 - I think it uses the second one by default and will only use a different one if it finds that port is busy.



Thursday, July 2, 2009

Creator and emacsclient

Some notes on using emacsclient on KDE, as I'm trying to integrate it with Qt Creator, because Qt Creator doesn't have Emacs key bindings (so far, my biggest gripe). There's an albeit painful keystroke to pass the current file off to an external editor, so I'm trying to get it to work with emacsclient. So far, here's my external editor command:



emacsclient -n +%l:%c %f



The -n tells it to not wait for the server to relinquish control of the file - I just want to edit it. +%l:%c says set the cursor at the line,column specified. The Info and Man pages for emacsclient don't specify this correctly, as they are both missing the colon.



Now I'm trying to figure out how to bring it to the front. Burying Emacs behind a bunch of windows isn't much help. I did come across a pretty cool KDE keyboard shortcut - Ctrl-Alt-A - which brings to the front the window "demanding attention", but that's not all that much help. Unfortunately, it doesn't look like a problem that has been solved for these window managers that don't allow "focus stealing".