ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.162 by root, Tue Oct 13 18:22:44 2009 UTC vs.
Revision 1.165 by root, Tue Oct 20 05:57:08 2009 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
114 * true. If we get through the entire stack, that must mean 114 * true. If we get through the entire stack, that must mean
115 * ob is blocking it, so return 0. 115 * ob is blocking it, so return 0.
116 */ 116 */
117 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 117 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
118 { 118 {
119 bool block = OB_MOVE_BLOCK (ob, tmp); 119 if (OB_MOVE_BLOCK (ob, tmp))
120
121 /* This must be before the checks below. Code for inventory checkers. */
122 if (block && tmp->type == CHECK_INV)
123 { 120 {
124 bool have = check_inv_recursive (ob, tmp); 121 if (tmp->type == CHECK_INV)
125
126 /* If last_sp is set, the player/monster needs an object,
127 * so we check for it. If they don't have it, they can't
128 * pass through this space.
129 */
130 if (tmp->last_sp)
131 { 122 {
132 if (!have) 123 bool have = check_inv_recursive (ob, tmp);
124
125 // last_sp set means we block if we don't have.
126 if (logical_xor (have, tmp->last_sp))
127 return 1;
128 }
129 else if (tmp->type == T_MATCH)
130 {
131 // T_MATCH allows "entrance" iff the match is true
132 // == blocks if the match fails
133
134 // we could have used an INVOKE_OBJECT, but decided against it, as we
135 // assume that T_MATCH is very common.
136 if (!match (tmp->slaying, ob, tmp, ob))
133 return 1; 137 return 1;
134 } 138 }
135 else 139 else
136 { 140 return 1; // unconditional block
137 /* In this case, the player must not have the object - 141
138 * if they do, they can't pass through.
139 */
140 if (have)
141 return 1;
142 }
143 }
144 else if (block && tmp->type == T_MATCH)
145 {
146 //TODO
147 }
148 else 142 } else {
149 { 143 // space does not block the ob, directly, but
150 /* Broke apart a big nasty if into several here to make 144 // anything alive that is not a door still
151 * this more readable. first check - if the space blocks 145 // blocks anything but wizards.
152 * movement, can't move here.
153 * second - if a monster, can't move there, unless it is a
154 * dm.
155 */
156 if (block)
157 return 1;
158 146
159 if (tmp->flag [FLAG_ALIVE] 147 if (tmp->flag [FLAG_ALIVE]
160 && tmp->head_ () != ob 148 && tmp->head_ () != ob
161 && tmp != ob 149 && tmp != ob
162 && tmp->type != DOOR 150 && tmp->type != DOOR
163 && !tmp->flag [FLAG_WIZ]) 151 && !tmp->flag [FLAG_WIZPASS])
164 return 1; 152 return 1;
165 } 153 }
166 } 154 }
167 155
168 return 0; 156 return 0;
566 return items; 554 return items;
567} 555}
568 556
569/* opposite of parse string, this puts the string that was originally fed in to 557/* opposite of parse string, this puts the string that was originally fed in to
570 * the map (or something equivilent) into output_string. */ 558 * the map (or something equivilent) into output_string. */
571static void 559static const char *
572print_shop_string (maptile *m, char *output_string) 560print_shop_string (maptile *m)
573{ 561{
574 int i; 562 static dynbuf_text buf; buf.clear ();
575 char tmp[MAX_BUF];
576 563
577 strcpy (output_string, "");
578 for (i = 0; i < m->shopitems[0].index; i++) 564 for (int i = 0; i < m->shopitems[0].index; i++)
579 { 565 {
580 if (m->shopitems[i].typenum) 566 if (m->shopitems[i].typenum)
581 { 567 {
582 if (m->shopitems[i].strength) 568 if (m->shopitems[i].strength)
583 sprintf (tmp, "%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); 569 buf.printf ("%s:%d;", m->shopitems[i].name, m->shopitems[i].strength);
584 else 570 else
585 sprintf (tmp, "%s;", m->shopitems[i].name); 571 buf.printf ("%s;", m->shopitems[i].name);
586 } 572 }
587 else 573 else
588 { 574 {
589 if (m->shopitems[i].strength) 575 if (m->shopitems[i].strength)
590 sprintf (tmp, "*:%d;", m->shopitems[i].strength); 576 buf.printf ("*:%d;", m->shopitems[i].strength);
591 else 577 else
592 sprintf (tmp, "*"); 578 buf.printf ("*");
593 } 579 }
594
595 strcat (output_string, tmp);
596 } 580 }
581
582 return buf;
597} 583}
598 584
599/* This loads the header information of the map. The header 585/* This loads the header information of the map. The header
600 * contains things like difficulty, size, timeout, etc. 586 * contains things like difficulty, size, timeout, etc.
601 * this used to be stored in the map object, but with the 587 * this used to be stored in the map object, but with the
736 MAP_OUT (reset_timeout); 722 MAP_OUT (reset_timeout);
737 MAP_OUT (fixed_resettime); 723 MAP_OUT (fixed_resettime);
738 MAP_OUT (no_reset); 724 MAP_OUT (no_reset);
739 MAP_OUT (no_drop); 725 MAP_OUT (no_drop);
740 MAP_OUT (difficulty); 726 MAP_OUT (difficulty);
741
742 if (default_region) MAP_OUT2 (region, default_region->name); 727 if (default_region) MAP_OUT2 (region, default_region->name);
743 728
744 if (shopitems) 729 if (shopitems) MAP_OUT2 (shopitems, print_shop_string (this));
745 {
746 char shop[MAX_BUF];
747 print_shop_string (this, shop);
748 MAP_OUT2 (shopitems, shop);
749 }
750
751 MAP_OUT (shopgreed); 730 MAP_OUT (shopgreed);
752 MAP_OUT (shopmin); 731 MAP_OUT (shopmin);
753 MAP_OUT (shopmax); 732 MAP_OUT (shopmax);
754 if (shoprace) MAP_OUT (shoprace); 733 if (shoprace) MAP_OUT (shoprace);
734
755 MAP_OUT (darkness); 735 MAP_OUT (darkness);
756 MAP_OUT (width); 736 MAP_OUT (width);
757 MAP_OUT (height); 737 MAP_OUT (height);
758 MAP_OUT (enter_x); 738 MAP_OUT (enter_x);
759 MAP_OUT (enter_y); 739 MAP_OUT (enter_y);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines