Archive for 2006

what does it mean to belong?

June 11th, 2006

I keep expecting to belong. Belong in my house, belong in my city, belong in my country. Maybe that is the error in my thinking right there, that I expect to. And it's not that I definitely don't belong. But neither do I convincingly belong. And that raises the question: what does it mean to belong? It's not the place alone, I know that much. I've been to Milano, Amsterdam and Paris in the last few years, all supposedly magical places, but I haven't felt the magic. And what is so special about the place where we live? Really just the fact that we live there. So what else is it? The people? Do friends make us belong, feel at home in a city? I've never found it easy to make friends. As a kid I wasn't good at it. And that's telling in a way, because it's easier to meet people now than it was then, but back then when I did make a friend, it was more likely to be someone I really got along with. Nowadays I can meet people all the time, but I don't necessarily enjoy spending time with them. I'm pretty picky at this and maybe it's just down to the fact that my standards are too high. But I just don't like spending time with people I can't really communicate with, people who don't get me. And I don't often meet people who do. Sometimes when I do I try too hard, get my hopes up and in the end it doesn't work out for one reason or another, that can be quite a let down.

I think back to being a kid and feeling that I belong. How did I feel coming home from vacation? What made me enjoy that? I'm not sure, I can't remember it specifically, it was just a feeling of belonging. Maybe it was school to some extent, feeling I belong in that class, with those people. I'm sure it was that among other things. But being part of a group has always been problematic for me. When I watch the World Cup now and I see these players playing for a team I can imagine how they travel together, train together, eat together, hang out in the hotel, all the stuff that goes with being in a group. When I think that I think "that's not for me, that's not who I am". Playing sports, sure it's fun, I've always loved that. But being part of a team, spending time with these people outside the game, I don't like them that much. That part was always a waste to me, I always used to wish in those moments that I was elsewhere. It's probably the reason I've never played on a team for a long time, it's probably what's keeping me from joining a team now.

In a sense it is a nagging feeling of "this not being all that it's supposed to be". I cannot say how many times I've felt that, felt content, felt happy, but not fulfilled. So when do I feel that it's all it can be. When I'm playing sports sometimes. When I have one of those long, meaningful conversations that go on for hours. When I'm working really hard on something just because I want to make it work, which is pretty much the feeling of hacking, making something work not because it's particularly useful, but because it matters then and there.

So where do I belong? And when will I start belonging?

and here it comes

June 9th, 2006

And so it begins, June 9 2006, the World Cup kicks off. Eight years ago we had "uno dos tres, allez allez allez", but this time it's a promise of being "the time of our lives". Can Toni Braxton keep that promise?

In the land of samba they call it "the Brazilian Cup", starring "the 3 R's", Ro-Ro-Ro, and "the two K's", Ka-Ka. On the guest list, there is a wide representation of European nations, Germany being the only permanent guest. But in Brazilian charitable fashion, they accept that the inherently Brazilian tournament is hosted all around the world, even if they're not thrilled about some of the regulations that have come into effect. The first R explains: "half my moves are gone in these moon boots, why can't we play barefoot, are there no beaches in Germany?"

But the Germans have a different tradition. In an undisclosed location somewhere in the Reich, a dark concrete basement is lit up by free standing lamps. In the very center of the room is a large table populated with chairs, where "coach" Klinsmann labors over big blueprints of the Allianz Arena battlefield, surrounded by engineers, drawing and sketching on the paper. Behind them on the wall is a big steel frame holding a life size portrait of the legendary Kaiser the Bunkerbuilder. The World Cup organizing committee has taken steps to avoid any misunderstandings, every participating stadium carries the official sticker in the player tunnel: "No tanks".

On the banks of the river Seine, a far cry from the German military tradition, a late night vigil in Notre Dame is underway. The congregation joins in chant "lord, without you we are nothing, bless us with your splendor". Among them, a pair of young men, David and Thierry, join hands in the final prayer and repent their sins. Behind the altar, a short, gray haired man in glasses holds up the chalice and then drinks from it. Behind him, a great banner of our lord, Zizou.

The Italians have different ideas altogether. Like the valedictorian who worked so hard on his speech and then forgot his notes at home, Italian coaches have a proud tradition of throwing away their notes before the tournament and "going with what's familiar". That is stocking a tight defence, crowding the midfield and sending the Big Man up front to score. A tactic that brought one Egil 'Drillo' Olsen so much fame and admiration. Meanwhile, the Azzurri faithful is almost done preparing their support banners to go on display in Germany. This time they have united under a common theme, choosing different ways of expressing the same sentiment to the world: "stop cheating us!"

Don't miss it, kickoff tonight at 18:00 CET.

today's query

June 8th, 2006

So surgeons scrub their hands very thoroughly before a surgery. And then they put on some gloves?

Am I missing something?

keeping track of train routes

June 5th, 2006

OpenTTD is an open source game based on the old classic Transport Tycoon Deluxe. The original game was reverse engineered and the code is all written from scratch. The idea of rewriting this venerable game is very good, as those who loved the original have a chance to implement all kinds of improvements they may have conceived while playing the commercial game, which of course did not allow for any hacking. Not to mention that with new code in c, it could be made cross platform (the old game only ran on Windows)! I found OpenTTD a very cool initiative, and after a relatively short period of time, the developers had managed to improve lots of little usability issues, while adding new and desirable features.

The game is about building a transportation network and there are four kinds of transportation available - aircraft, ships, buses/trucks, and trains. But this game is really mostly about trains and the magnificent networks of trains its gamers have concocted. One thing I found to be a little troublesome was to keep track of the trains as they grew in numbers, and keep track of their routes. If you build a junction such as the one shown in the screenshot, then how, by just looking at trains going by, are you going to keep track of which train has which route?

openttd_junction.png

There could be lots of ways to make this common problem less of a problem, but my idea was to keep track of routes by keeping track of names. If you were to have a set of trains called South Western 1, South Western 2 etc, all of which had the same route, then you could easily tell trains apart, and see where a train has gone where it shouldn't have. It would still require the user to set up the routes and name the trains, but from that point on, the game could assign the correct names, so if you cloned a train called New York - San Francisco 7, the clone would be assigned the name New York - San Francisco 8.

So to make that happen I wrote a patch against revision 5125 in svn.

*** vehicle.c	2006-06-05 14:59:24.000000000 +0200
--- vehicle.c	2006-06-05 15:00:35.000000000 +0200
***************
*** 30,35 ****
--- 30,37 ----
  #include "station_map.h"
  #include "water_map.h"
  
+ #include <ctype.h>
+ 
  #define INVALID_COORD (-0x8000)
  #define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0)))
  
***************
*** 1567,1572 ****
--- 1569,1580 ----
  				w_front = w;
  				w->service_interval = v->service_interval;
  				DoCommand(0, (v->index << 16) | w->index, p2 & 1 ? CO_SHARE : CO_COPY, flags, CMD_CLONE_ORDER);
+         
+ 				// if orders are shared, increment vehicle number
+ 				if (p2) {
+ 					IncrementVehicleNameOnClone(v, w, flags);
+ 				}
+         
  			}
  			w_rear = w;	// trains needs to know the last car in the train, so they can add more in next loop
  		}
***************
*** 1579,1584 ****
--- 1587,1672 ----
  	return total_cost;
  }
  
+ /** Increment the cloned' vehicles name
+ * @param v the original vehicle's index
+ * @param w the clone's index
+ */
+ void IncrementVehicleNameOnClone(Vehicle *v, Vehicle *w, uint32 flags)
+ {
+ 	int len = 32;
+ 	char vehicle_name[len];
+ 	char vehicle_number[len];
+ 	Vehicle *nvehicle;	// the next vehicle in array to check
+ 	char nvehicle_name[len];	// the next vehicle's name
+ 	uint16 e;
+ 	uint16 pool = GetVehiclePoolSize();
+ 	int i, j, f, n, largest;
+ 	int numbers[pool];	// the array of numbers our new number must fit into
+ 	
+ 	// Get the name of the old vehicle
+ 	if ((v->string_id & 0xF800) != 0x7800) {
+ 		vehicle_name[0] = '\0';
+ 	} else {
+ 		GetName(v->string_id & 0x7FF, vehicle_name);
+ 	}
+ 	
+ 	// find out how far into the name the digits start, save the index
+ 	i = 0;
+ 	while (!isdigit(vehicle_name[i]) && (i < len)) {
+ 		i++;
+ 	}
+ 	
+ 	// use the index to read an integer from the vehicle name
+ 	n = atoi(&vehicle_name[i]);
+ 	if (n != 0) {
+ 		
+ 		// find a vacant number to assign the new vehicle, check all existing
+ 		// vehicles which have the same name
+ 		memset(numbers, 0, pool);
+ 		e = 0;
+ 		j = 0;
+ 		for (e = 0; e < pool; e++) {
+ 			// verify vehicle owner and type to match this vehicle
+ 			nvehicle = GetVehicle(e);
+ 			if (CheckOwnership(nvehicle->owner) && (v->type == nvehicle->type)) {
+ 				
+ 				// get string_id
+ 				if ((nvehicle->string_id & 0xF800) != 0x7800) {
+ 					nvehicle_name[0] = '\0';
+ 				} else {
+ 					GetName(nvehicle->string_id & 0x7FF, nvehicle_name);
+ 				}
+ 				
+ 				// filter string_id's that are empty or non-equal
+ 				if (strncmp(nvehicle_name, vehicle_name, i) == 0) {
+ 					numbers[j] = atoi( &nvehicle_name[i]);
+ 					j++;
+ 				}
+ 				
+ 			}
+ 		}
+ 		
+ 		// resulting array 'numbers' has the numbers of vehicles we need to examine
+ 		largest = 0;
+ 		for (f = 0; f < j; f++) {
+ 			if (numbers[f] > largest) largest = numbers[f];
+ 		}
+ 		
+ 		// assign number to vehicle
+ 		n = largest+1;
+ 		vehicle_name[i] = '\0';
+ 		sprintf(vehicle_number, "%d", n);
+ 		strcat(vehicle_name, vehicle_number);
+ 	
+ 		// Set the name of the new vehicle
+ 		if ((flags & DC_EXEC) && vehicle_name[0] != '\0') {
+ 			_cmd_text = vehicle_name;
+ 			DoCommand(0, w->index, 0, DC_EXEC, CMD_NAME_VEHICLE);
+ 		}
+ 	}
+ 
+ }
+ 
  /*
   * move the cargo from one engine to another if possible
   */
*** vehicle.h	2006-06-05 14:59:24.000000000 +0200
--- vehicle.h	2006-06-05 14:59:52.000000000 +0200
***************
*** 297,302 ****
--- 297,304 ----
  void AgeVehicle(Vehicle *v);
  void VehicleEnteredDepotThisTick(Vehicle *v);
  
+ void IncrementVehicleNameOnClone(Vehicle *v, Vehicle *w, uint32 flags);
+ 
  void BeginVehicleMove(Vehicle *v);
  void EndVehicleMove(Vehicle *v);

It was a bit of a struggle, as I've never actually written an application in c. It also took me a while to figure out how things are done in OpenTTD, but sure enough, it does what I set out to do.

I've played the game with this patch applied, and I prefer it that way. However, the developers didn't think it was a good idea, neither for technical reasons nor gameplay, and it's not going to be an actual thing in the game. I think problem is a legitimate problem and that it should, and probably will, be addressed at some point.

from me to you

May 31st, 2006

Random fun[ny] stuff I found on reddit: