Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CF: Patch: find keys in containers
- To: crossfire (at) ifi.uio.no
- Subject: CF: Patch: find keys in containers
- From: Christian Stieber <>
- Date: Wed, 18 Feb 1998 19:01:40 +0100
- Sender:
Hi,
this is just a very simple change: it will search special keys in
containers, not just the main inventory. Avoids the annoying
"where is that stupid key...".
------------------------------ Cut ------------------------------
*** crossfire-0.94.0/server/player.c Sun Feb 8 06:26:19 1998
--- /usr/stud/stieber/crossfire/server/player.c Wed Feb 18 18:50:05 1998
***************
*** 1321,1330 ****
--- 1321,1354 ----
op->contr->count_left=0;
return;
}
}
+ /*
+ *
+ */
+
+ static object *FindKey(object *Door, object *ob)
+ {
+ while (ob!=NULL)
+ {
+ if (ob->type==CONTAINER)
+ {
+ object *t;
+
+ t=FindKey(Door,ob->inv);
+ if (t!=NULL) return t;
+ }
+ else if (ob->type==SPECIAL_KEY && ob->slaying==Door->slaying)
+ {
+ return ob;
+ }
+ ob=ob->below;
+ }
+ return NULL;
+ }
+
/* This function is just part of a breakup from move_player.
* It should keep the code cleaner.
* When this is called, the players direction has been updated
* (taking into accoutn confusion.) The player is also actually
* going to try and move (not fire weapons).
***************
*** 1393,1407 ****
/* This area deals with locked doors. These are doors that require
* special keys.
*/
if(tmp->type==LOCKED_DOOR) {
tmp2=op->inv;
while(tmp2 && (tmp2->type != SPECIAL_KEY ||
tmp2->slaying != tmp->slaying)) /* Find the key */
tmp2=tmp2->below;
!
if(tmp2) {
decrease_ob_nr(tmp2, 1); /* Use the key */
remove_door2(tmp); /* remove door without violence ;-) */
play_sound_map(op->map, op->x, op->y, SOUND_OPEN_DOOR);
} else if (tmp->msg) /* show door's message if present */
--- 1417,1434 ----
/* This area deals with locked doors. These are doors that require
* special keys.
*/
if(tmp->type==LOCKED_DOOR) {
+ #if 0
tmp2=op->inv;
while(tmp2 && (tmp2->type != SPECIAL_KEY ||
tmp2->slaying != tmp->slaying)) /* Find the key */
tmp2=tmp2->below;
! #else
! tmp2=FindKey(tmp,op->inv);
! #endif
if(tmp2) {
decrease_ob_nr(tmp2, 1); /* Use the key */
remove_door2(tmp); /* remove door without violence ;-) */
play_sound_map(op->map, op->x, op->y, SOUND_OPEN_DOOR);
} else if (tmp->msg) /* show door's message if present */
--
Christian (Icho/Gandhi/Ribald @sunbroy53.informatik.tu-muenchen.de, 13326)
[to unsubscribe etc., send mail to ]