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.163 by root, Thu Oct 15 21:40:42 2009 UTC vs.
Revision 1.166 by root, Wed Oct 21 00:44:39 2009 UTC

80 { 80 {
81 LOG (llevError, "blocked_link: Passed map, x, y coordinates outside of map\n"); 81 LOG (llevError, "blocked_link: Passed map, x, y coordinates outside of map\n");
82 return 1; 82 return 1;
83 } 83 }
84 84
85 /* Save some cycles - instead of calling get_map_flags(), just get the value
86 * directly.
87 */
88 mapspace &ms = m->at (sx, sy); 85 mapspace &ms = m->at (sx, sy);
89 86
90 int mflags = ms.flags (); 87 int mflags = ms.flags ();
91 int blocked = ms.move_block; 88 int blocked = ms.move_block;
92 89
114 * true. If we get through the entire stack, that must mean 111 * true. If we get through the entire stack, that must mean
115 * ob is blocking it, so return 0. 112 * ob is blocking it, so return 0.
116 */ 113 */
117 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 114 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
118 { 115 {
119 bool block = OB_MOVE_BLOCK (ob, tmp); 116 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 { 117 {
124 bool have = check_inv_recursive (ob, tmp); 118 if (INVOKE_OBJECT (BLOCKED_MOVE, tmp, ob))
125 119 if (RESULT_INT (0))
126 /* If last_sp is set, the player/monster needs an object, 120 return 1;
127 * so we check for it. If they don't have it, they can't
128 * pass through this space.
129 */ 121 else
130 if (tmp->last_sp) 122 continue;
123
124 if (tmp->type == CHECK_INV)
131 { 125 {
132 if (!have) 126 bool have = check_inv_recursive (ob, tmp);
127
128 // last_sp set means we block if we don't have.
129 if (logical_xor (have, tmp->last_sp))
130 return 1;
131 }
132 else if (tmp->type == T_MATCH)
133 {
134 // T_MATCH allows "entrance" iff the match is true
135 // == blocks if the match fails
136
137 // we could have used an INVOKE_OBJECT, but decided against it, as we
138 // assume that T_MATCH is relatively common.
139 if (!match (tmp->slaying, ob, tmp, ob))
133 return 1; 140 return 1;
134 } 141 }
135 else 142 else
136 { 143 return 1; // unconditional block
137 /* In this case, the player must not have the object - 144
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 145 } else {
149 { 146 // space does not block the ob, directly, but
150 /* Broke apart a big nasty if into several here to make 147 // anything alive that is not a door still
151 * this more readable. first check - if the space blocks 148 // 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 149
159 if (tmp->flag [FLAG_ALIVE] 150 if (tmp->flag [FLAG_ALIVE]
160 && tmp->head_ () != ob 151 && tmp->head_ () != ob
161 && tmp != ob 152 && tmp != ob
162 && tmp->type != DOOR 153 && tmp->type != DOOR
163 && !tmp->flag [FLAG_WIZ]) 154 && !tmp->flag [FLAG_WIZPASS])
164 return 1; 155 return 1;
165 } 156 }
166 } 157 }
167 158
168 return 0; 159 return 0;
566 return items; 557 return items;
567} 558}
568 559
569/* opposite of parse string, this puts the string that was originally fed in to 560/* opposite of parse string, this puts the string that was originally fed in to
570 * the map (or something equivilent) into output_string. */ 561 * the map (or something equivilent) into output_string. */
571static void 562static const char *
572print_shop_string (maptile *m, char *output_string) 563print_shop_string (maptile *m)
573{ 564{
574 int i; 565 static dynbuf_text buf; buf.clear ();
575 char tmp[MAX_BUF];
576 566
577 strcpy (output_string, "");
578 for (i = 0; i < m->shopitems[0].index; i++) 567 for (int i = 0; i < m->shopitems[0].index; i++)
579 { 568 {
580 if (m->shopitems[i].typenum) 569 if (m->shopitems[i].typenum)
581 { 570 {
582 if (m->shopitems[i].strength) 571 if (m->shopitems[i].strength)
583 sprintf (tmp, "%s:%d;", m->shopitems[i].name, m->shopitems[i].strength); 572 buf.printf ("%s:%d;", m->shopitems[i].name, m->shopitems[i].strength);
584 else 573 else
585 sprintf (tmp, "%s;", m->shopitems[i].name); 574 buf.printf ("%s;", m->shopitems[i].name);
586 } 575 }
587 else 576 else
588 { 577 {
589 if (m->shopitems[i].strength) 578 if (m->shopitems[i].strength)
590 sprintf (tmp, "*:%d;", m->shopitems[i].strength); 579 buf.printf ("*:%d;", m->shopitems[i].strength);
591 else 580 else
592 sprintf (tmp, "*"); 581 buf.printf ("*");
593 } 582 }
594
595 strcat (output_string, tmp);
596 } 583 }
584
585 return buf;
597} 586}
598 587
599/* This loads the header information of the map. The header 588/* This loads the header information of the map. The header
600 * contains things like difficulty, size, timeout, etc. 589 * contains things like difficulty, size, timeout, etc.
601 * this used to be stored in the map object, but with the 590 * this used to be stored in the map object, but with the
736 MAP_OUT (reset_timeout); 725 MAP_OUT (reset_timeout);
737 MAP_OUT (fixed_resettime); 726 MAP_OUT (fixed_resettime);
738 MAP_OUT (no_reset); 727 MAP_OUT (no_reset);
739 MAP_OUT (no_drop); 728 MAP_OUT (no_drop);
740 MAP_OUT (difficulty); 729 MAP_OUT (difficulty);
741
742 if (default_region) MAP_OUT2 (region, default_region->name); 730 if (default_region) MAP_OUT2 (region, default_region->name);
743 731
744 if (shopitems) 732 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); 733 MAP_OUT (shopgreed);
752 MAP_OUT (shopmin); 734 MAP_OUT (shopmin);
753 MAP_OUT (shopmax); 735 MAP_OUT (shopmax);
754 if (shoprace) MAP_OUT (shoprace); 736 if (shoprace) MAP_OUT (shoprace);
737
755 MAP_OUT (darkness); 738 MAP_OUT (darkness);
756 MAP_OUT (width); 739 MAP_OUT (width);
757 MAP_OUT (height); 740 MAP_OUT (height);
758 MAP_OUT (enter_x); 741 MAP_OUT (enter_x);
759 MAP_OUT (enter_y); 742 MAP_OUT (enter_y);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines