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.161 by root, Mon Oct 12 21:27:55 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
85 /* Save some cycles - instead of calling get_map_flags(), just get the value 85 /* Save some cycles - instead of calling get_map_flags(), just get the value
86 * directly. 86 * directly.
87 */ 87 */
88 mapspace &ms = m->at (sx, sy); 88 mapspace &ms = m->at (sx, sy);
89 89
90 int mflags = ms.flags (); 90 int mflags = ms.flags ();
91 int blocked = ms.move_block; 91 int blocked = ms.move_block;
92 92
93 /* If space is currently not blocked by anything, no need to 93 /* If space is currently not blocked by anything, no need to
94 * go further. Not true for players - all sorts of special 94 * go further. Not true for players - all sorts of special
95 * things we need to do for players. 95 * things we need to do for players.
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 /* This must be before the checks below. Code for inventory checkers. */ 119 if (OB_MOVE_BLOCK (ob, tmp))
120 if (tmp->type == CHECK_INV && OB_MOVE_BLOCK (ob, tmp))
121 { 120 {
122 bool have = check_inv_recursive (ob, tmp); 121 if (tmp->type == CHECK_INV)
123
124 /* If last_sp is set, the player/monster needs an object,
125 * so we check for it. If they don't have it, they can't
126 * pass through this space.
127 */
128 if (tmp->last_sp)
129 { 122 {
130 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))
131 return 1; 137 return 1;
132 } 138 }
133 else 139 else
134 { 140 return 1; // unconditional block
135 /* In this case, the player must not have the object - 141
136 * if they do, they can't pass through.
137 */
138 if (have)
139 return 1;
140 }
141 }
142 else 142 } else {
143 { 143 // space does not block the ob, directly, but
144 /* Broke apart a big nasty if into several here to make 144 // anything alive that is not a door still
145 * this more readable. first check - if the space blocks 145 // blocks anything but wizards.
146 * movement, can't move here.
147 * second - if a monster, can't move there, unless it is a
148 * dm.
149 */
150 if (OB_MOVE_BLOCK (ob, tmp))
151 return 1;
152 146
153 if (tmp->flag [FLAG_ALIVE] 147 if (tmp->flag [FLAG_ALIVE]
154 && tmp->head_ () != ob 148 && tmp->head_ () != ob
155 && tmp != ob 149 && tmp != ob
156 && tmp->type != DOOR 150 && tmp->type != DOOR
157 && !tmp->flag [FLAG_WIZ]) 151 && !tmp->flag [FLAG_WIZPASS])
158 return 1; 152 return 1;
159 } 153 }
160 } 154 }
161 155
162 return 0; 156 return 0;
560 return items; 554 return items;
561} 555}
562 556
563/* 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
564 * the map (or something equivilent) into output_string. */ 558 * the map (or something equivilent) into output_string. */
565static void 559static const char *
566print_shop_string (maptile *m, char *output_string) 560print_shop_string (maptile *m)
567{ 561{
568 int i; 562 static dynbuf_text buf; buf.clear ();
569 char tmp[MAX_BUF];
570 563
571 strcpy (output_string, "");
572 for (i = 0; i < m->shopitems[0].index; i++) 564 for (int i = 0; i < m->shopitems[0].index; i++)
573 { 565 {
574 if (m->shopitems[i].typenum) 566 if (m->shopitems[i].typenum)
575 { 567 {
576 if (m->shopitems[i].strength) 568 if (m->shopitems[i].strength)
577 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);
578 else 570 else
579 sprintf (tmp, "%s;", m->shopitems[i].name); 571 buf.printf ("%s;", m->shopitems[i].name);
580 } 572 }
581 else 573 else
582 { 574 {
583 if (m->shopitems[i].strength) 575 if (m->shopitems[i].strength)
584 sprintf (tmp, "*:%d;", m->shopitems[i].strength); 576 buf.printf ("*:%d;", m->shopitems[i].strength);
585 else 577 else
586 sprintf (tmp, "*"); 578 buf.printf ("*");
587 } 579 }
588
589 strcat (output_string, tmp);
590 } 580 }
581
582 return buf;
591} 583}
592 584
593/* This loads the header information of the map. The header 585/* This loads the header information of the map. The header
594 * contains things like difficulty, size, timeout, etc. 586 * contains things like difficulty, size, timeout, etc.
595 * 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
730 MAP_OUT (reset_timeout); 722 MAP_OUT (reset_timeout);
731 MAP_OUT (fixed_resettime); 723 MAP_OUT (fixed_resettime);
732 MAP_OUT (no_reset); 724 MAP_OUT (no_reset);
733 MAP_OUT (no_drop); 725 MAP_OUT (no_drop);
734 MAP_OUT (difficulty); 726 MAP_OUT (difficulty);
735
736 if (default_region) MAP_OUT2 (region, default_region->name); 727 if (default_region) MAP_OUT2 (region, default_region->name);
737 728
738 if (shopitems) 729 if (shopitems) MAP_OUT2 (shopitems, print_shop_string (this));
739 {
740 char shop[MAX_BUF];
741 print_shop_string (this, shop);
742 MAP_OUT2 (shopitems, shop);
743 }
744
745 MAP_OUT (shopgreed); 730 MAP_OUT (shopgreed);
746 MAP_OUT (shopmin); 731 MAP_OUT (shopmin);
747 MAP_OUT (shopmax); 732 MAP_OUT (shopmax);
748 if (shoprace) MAP_OUT (shoprace); 733 if (shoprace) MAP_OUT (shoprace);
734
749 MAP_OUT (darkness); 735 MAP_OUT (darkness);
750 MAP_OUT (width); 736 MAP_OUT (width);
751 MAP_OUT (height); 737 MAP_OUT (height);
752 MAP_OUT (enter_x); 738 MAP_OUT (enter_x);
753 MAP_OUT (enter_y); 739 MAP_OUT (enter_y);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines