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.164 by root, Fri Oct 16 01:19:12 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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines