[CF-Devel] Some bug fixes
crossfire-devel at archives.real-time.com
crossfire-devel at archives.real-time.com
Tue Apr 13 12:32:49 CDT 2004
Here is a new patch that attempts to find a keymaster: it tries harder
to find a keymaster. After that it tries to find a free spot. If this
too fails, it drops the key in a random place (i.e. wall).
I did some more checks with the random_map program. It found a keymaster
in over 95% of all tries. In the remaining cases it found a free spot.
The fall back case to drop the key in a wall (freeindex == -1 after the
second loop) did never occur.
Concerning the other change in patch-4.diff to drop a chest if no free
spot could be found, I think this behavior is acceptable: all callers of
place_chest() check for (or ignore) a NULL result. So it is better to
drop the chest than to place it in a arbitrary/invalid (i.e.
"x+freearr_x[-1]") location.
-------------- next part --------------
Index: random_maps/treasure.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/random_maps/treasure.c,v
retrieving revision 1.19
diff -u -w -r1.19 treasure.c
--- random_maps/treasure.c 8 Jan 2003 08:39:18 -0000 1.19
+++ random_maps/treasure.c 13 Apr 2004 17:24:05 -0000
@@ -296,7 +297,7 @@
if(door_flag==PASS_DOORS) {
int tries=0;
the_keymaster=NULL;
- while(tries<5&&the_keymaster==NULL) {
+ while(tries<15&&the_keymaster==NULL) {
i = (RANDOM()%(RP->Xsize-2))+1;
j = (RANDOM()%(RP->Ysize-2))+1;
tries++;
@@ -304,9 +305,18 @@
}
/* if we don't find a good keymaster, drop the key on the ground. */
if(the_keymaster==NULL) {
- int freeindex = find_first_free_spot(the_key->arch,map,i,j);
- kx = i + freearr_x[freeindex];
- ky = j + freearr_y[freeindex];
+ int freeindex;
+
+ freeindex = -1;
+ for(tries = 0; tries < 15 && freeindex == -1; tries++) {
+ kx = (RANDOM()%(RP->Xsize-2))+1;
+ ky = (RANDOM()%(RP->Ysize-2))+1;
+ freeindex = find_first_free_spot(the_key->arch,map,kx,ky);
+ }
+ if(freeindex != -1) {
+ kx += freearr_x[freeindex];
+ ky += freearr_y[freeindex];
+ }
}
}
else { /* NO_PASS_DOORS --we have to work harder.*/
-------------- next part --------------
_______________________________________________
crossfire-devel mailing list
crossfire-devel at lists.real-time.com
https://mailman.real-time.com/mailman/listinfo/crossfire-devel
More information about the crossfire
mailing list