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.160 by root, Mon Oct 12 14:00:57 2009 UTC vs.
Revision 1.161 by root, Mon Oct 12 21:27:55 2009 UTC

71 * by the caller. 71 * by the caller.
72 */ 72 */
73int 73int
74blocked_link (object *ob, maptile *m, int sx, int sy) 74blocked_link (object *ob, maptile *m, int sx, int sy)
75{ 75{
76 object *tmp;
77 int mflags, blocked;
78
79 /* Make sure the coordinates are valid - they should be, as caller should 76 /* Make sure the coordinates are valid - they should be, as caller should
80 * have already checked this. 77 * have already checked this.
81 */ 78 */
82 if (OUT_OF_REAL_MAP (m, sx, sy)) 79 if (OUT_OF_REAL_MAP (m, sx, sy))
83 { 80 {
86 } 83 }
87 84
88 /* 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
89 * directly. 86 * directly.
90 */ 87 */
91 mflags = m->at (sx, sy).flags (); 88 mapspace &ms = m->at (sx, sy);
92 89
93 blocked = GET_MAP_MOVE_BLOCK (m, sx, sy); 90 int mflags = ms.flags ();
91 int blocked = ms.move_block;
94 92
95 /* If space is currently not blocked by anything, no need to 93 /* If space is currently not blocked by anything, no need to
96 * go further. Not true for players - all sorts of special 94 * go further. Not true for players - all sorts of special
97 * things we need to do for players. 95 * things we need to do for players.
98 */ 96 */
99 if (ob->type != PLAYER && !(mflags & P_IS_ALIVE) && (blocked == 0)) 97 if (ob->type != PLAYER && !(mflags & P_IS_ALIVE) && (blocked == 0))
100 return 0; 98 return 0;
101 99
102 /* if there isn't anytyhing alive on this space, and this space isn't 100 /* if there isn't anything alive on this space, and this space isn't
103 * otherwise blocked, we can return now. Only if there is a living 101 * otherwise blocked, we can return now. Only if there is a living
104 * creature do we need to investigate if it is part of this creature 102 * creature do we need to investigate if it is part of this creature
105 * or another. Likewise, only if something is blocking us do we 103 * or another. Likewise, only if something is blocking us do we
106 * need to investigate if there is a special circumstance that would 104 * need to investigate if there is a special circumstance that would
107 * let the player through (inventory checkers for example) 105 * let the player through (inventory checkers for example)
114 /* We basically go through the stack of objects, and if there is 112 /* We basically go through the stack of objects, and if there is
115 * some other object that has NO_PASS or FLAG_ALIVE set, return 113 * some other object that has NO_PASS or FLAG_ALIVE set, return
116 * true. If we get through the entire stack, that must mean 114 * true. If we get through the entire stack, that must mean
117 * ob is blocking it, so return 0. 115 * ob is blocking it, so return 0.
118 */ 116 */
119 for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) 117 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
120 { 118 {
121
122 /* This must be before the checks below. Code for inventory checkers. */ 119 /* This must be before the checks below. Code for inventory checkers. */
123 if (tmp->type == CHECK_INV && OB_MOVE_BLOCK (ob, tmp)) 120 if (tmp->type == CHECK_INV && OB_MOVE_BLOCK (ob, tmp))
124 { 121 {
122 bool have = check_inv_recursive (ob, tmp);
123
125 /* If last_sp is set, the player/monster needs an object, 124 /* If last_sp is set, the player/monster needs an object,
126 * so we check for it. If they don't have it, they can't 125 * so we check for it. If they don't have it, they can't
127 * pass through this space. 126 * pass through this space.
128 */ 127 */
129 if (tmp->last_sp) 128 if (tmp->last_sp)
130 { 129 {
131 if (check_inv_recursive (ob, tmp) == NULL) 130 if (!have)
132 return 1; 131 return 1;
133 else
134 continue;
135 } 132 }
136 else 133 else
137 { 134 {
138 /* In this case, the player must not have the object - 135 /* In this case, the player must not have the object -
139 * if they do, they can't pass through. 136 * if they do, they can't pass through.
140 */ 137 */
141 if (check_inv_recursive (ob, tmp) != NULL) /* player has object */ 138 if (have)
142 return 1; 139 return 1;
143 else
144 continue;
145 } 140 }
146 } /* if check_inv */ 141 }
147 else 142 else
148 { 143 {
149 /* Broke apart a big nasty if into several here to make 144 /* Broke apart a big nasty if into several here to make
150 * this more readable. first check - if the space blocks 145 * this more readable. first check - if the space blocks
151 * movement, can't move here. 146 * movement, can't move here.
152 * second - if a monster, can't move there, unless it is a 147 * second - if a monster, can't move there, unless it is a
153 * hidden dm 148 * dm.
154 */ 149 */
155 if (OB_MOVE_BLOCK (ob, tmp)) 150 if (OB_MOVE_BLOCK (ob, tmp))
156 return 1; 151 return 1;
157 152
158 if (tmp->flag [FLAG_ALIVE] 153 if (tmp->flag [FLAG_ALIVE]
159 && tmp->head_ () != ob 154 && tmp->head_ () != ob
160 && tmp != ob 155 && tmp != ob
161 && tmp->type != DOOR 156 && tmp->type != DOOR
162 && !(tmp->flag [FLAG_WIZ] && tmp->contr->hidden)) 157 && !tmp->flag [FLAG_WIZ])
163 return 1; 158 return 1;
164 } 159 }
165
166 } 160 }
161
167 return 0; 162 return 0;
168} 163}
169 164
170/* 165/*
171 * Returns qthe blocking object if the given object can't fit in the given 166 * Returns qthe blocking object if the given object can't fit in the given

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines