• entries
109
378
• views
127970

# Could it be? Map bugs finally fixed?

79 views

Just after I posted the yesterday's journal entry, I discovered that the bug I thought I fixed wasn't really fixed. I was very dissapointed, of course. After 2 hours of reviewing all the code responsible for loading and saving maps, and fixing a minor problem, the bug was still there. So I just went to bed, and decided to start the bug hunt today.
After I came home, I took a look at some different code, the code responsible for clearing the sectors, and there was my problem. Some wrong objects were cleared, while letting an instance of the objects that were supposed to be cleared. Very annoying. And this bug wasn't even mine.
So anyway, I found out that there are two things that help me work better:
1. Having satellite radio is great, since I can listen to whatever kind of music I want, without being distracted by commercials and all kind of other, non music related bullshit. Listening to radio is better than playing your own music, since you hear all kind of music you didn't even know it exist (new bands, new songs, etc.)
2. Incense sticks. They are great for setting a more relaxed mood, and by using them while coding, the brain gets into some sort of 'coding phase' when you light them (it associates that smell with programming).
What I am going to work at next is to implement NPC names. Basically, the server will load a list with NPC names, at startup. Whenever a new NPC is added (such as, for example, when a city 'buys' an NPC to take care of a building (clerk, blacksmith, etc.)) the server will automagically assign it a name. For a while I was thinking whether or not the players should be able to name their NPCs as they wish, but I decided against it because, well, it's not like the players OWN the NPCs. This will also avoid all kind of possibly stupid or offending NPC names, such as "XAragonX12", "Neo", etc.

 Since this bug was a client side bug, and the client is OSS anyway, I'll post the code with the problem:

/*void clear_sector(Uint16 sector){	int i;	// 3d objects	for(i=0;i		if(sectors[sector].e3d_local!=-1){			destroy_3d_object(sectors[sector].e3d_local);			sectors[sector].e3d_local=-1;		}	}	//2d objects	for(i=0;i		if(sectors[sector].e2d_local!=-1){			free(obj_2d_list);			obj_2d_list=0;			sectors[sector].e2d_local=-1;		}	}	//lights	for(i=0;i		if(sectors[sector].lights_local!=-1){			free(lights_list);			lights_list=0;			sectors[sector].lights_local=-1;		}	}	//particles	for(i=0;i		if(sectors[sector].particles_local!=-1){			free(particles_list);			particles_list=0;			sectors[sector].particles_local=-1;		}	}}*/void clear_sector(Uint16 sector){	int i;	// 3d objects	for(i=0;i		if(sectors[sector].e3d_local!=-1){			destroy_3d_object(sectors[sector].e3d_local);			sectors[sector].e3d_local=-1;		}	}	//2d objects	for(i=0;i		if(sectors[sector].e2d_local!=-1){			free(obj_2d_list[sectors[sector].e2d_local]);			obj_2d_list[sectors[sector].e2d_local]=0;			sectors[sector].e2d_local=-1;		}	}	//lights	for(i=0;i		if(sectors[sector].lights_local!=-1){			free(lights_list[sectors[sector].lights_local]);			lights_list[sectors[sector].lights_local]=0;			sectors[sector].lights_local=-1;		}	}	//particles	for(i=0;i		if(sectors[sector].particles_local!=-1){			free(particles_list[sectors[sector].particles_local]);			particles_list[sectors[sector].particles_local]=0;			sectors[sector].particles_local=-1;		}	}}

The commented out code is the old (buggy) one, and the non commented code is the working version.

There are no comments to display.