… | |
… | |
136 | * the function that calls this should figure them out. |
136 | * the function that calls this should figure them out. |
137 | */ |
137 | */ |
138 | void |
138 | void |
139 | object::enter_map (maptile *newmap, int x, int y) |
139 | object::enter_map (maptile *newmap, int x, int y) |
140 | { |
140 | { |
|
|
141 | if (destroyed () || !newmap) |
|
|
142 | return; |
|
|
143 | |
141 | if (out_of_map (newmap, x, y)) |
144 | if (out_of_map (newmap, x, y)) |
142 | { |
145 | { |
143 | LOG (llevError, "enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", &newmap->path, x, y); |
146 | LOG (llevError, "enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", &newmap->path, x, y); |
144 | x = newmap->enter_x; |
147 | x = newmap->enter_x; |
145 | y = newmap->enter_y; |
148 | y = newmap->enter_y; |
… | |
… | |
150 | new_draw_info (NDI_UNIQUE, 0, this, "The exit is closed"); |
153 | new_draw_info (NDI_UNIQUE, 0, this, "The exit is closed"); |
151 | return; |
154 | return; |
152 | } |
155 | } |
153 | } |
156 | } |
154 | |
157 | |
155 | if (map) |
158 | if (map && map != newmap) |
156 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
159 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
157 | return; |
160 | return; |
158 | |
161 | |
159 | /* If it is a player login, he has yet to be inserted anyplace. |
162 | /* If it is a player login, he has yet to be inserted anyplace. |
160 | * otherwise, we need to deal with removing the player here. |
163 | * otherwise, we need to deal with removing the player here. |
… | |
… | |
188 | else |
191 | else |
189 | /* not much we can do in this case. */ |
192 | /* not much we can do in this case. */ |
190 | LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", &newmap->path, x, y); |
193 | LOG (llevInfo, "enter_map: Could not find free spot for player - will dump on top of object (%s: %d, %d)\n", &newmap->path, x, y); |
191 | } |
194 | } |
192 | |
195 | |
|
|
196 | if (map != newmap && contr) |
|
|
197 | { |
193 | if (INVOKE_PLAYER (MAP_CHANGE, contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
198 | if (INVOKE_PLAYER (MAP_CHANGE, contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
194 | return; |
199 | return; |
195 | |
200 | |
196 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (contr), ARG_INT (x), ARG_INT (y))) |
201 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (contr), ARG_INT (x), ARG_INT (y))) |
197 | return; |
202 | return; |
|
|
203 | } |
198 | |
204 | |
199 | this->x = x; |
205 | this->x = x; |
200 | this->y = y; |
206 | this->y = y; |
201 | map = newmap; |
207 | map = newmap; |
202 | |
208 | |
203 | insert_ob_in_map (this, map, 0, INS_NO_WALK_ON); |
209 | insert_ob_in_map (this, map, 0, INS_NO_WALK_ON); |
204 | |
210 | |
205 | newmap->timeout = 0; |
|
|
206 | enemy = NULL; |
211 | enemy = NULL; |
207 | |
212 | |
208 | if (contr) |
213 | if (contr) |
209 | { |
214 | { |
210 | strcpy (contr->maplevel, newmap->path); |
215 | strcpy (contr->maplevel, newmap->path); |
… | |
… | |
266 | flag = 0; |
271 | flag = 0; |
267 | for_all_players (pl) |
272 | for_all_players (pl) |
268 | { |
273 | { |
269 | pl->refcnt_chk (); |
274 | pl->refcnt_chk (); |
270 | |
275 | |
271 | if (!pl->ob || !pl->ns) |
276 | if (!pl->ob || !pl->ns || !pl->ob->active ()) |
272 | continue; |
277 | continue; |
273 | |
278 | |
274 | if (pl->ob->speed_left > 0) |
279 | if (pl->ob->speed_left > 0) |
275 | if (handle_newcs_player (pl->ob)) |
280 | if (handle_newcs_player (pl->ob)) |
276 | flag = 1; |
281 | flag = 1; |
… | |
… | |
297 | } /* end of for loop for all the players */ |
302 | } /* end of for loop for all the players */ |
298 | } /* for flag */ |
303 | } /* for flag */ |
299 | |
304 | |
300 | for_all_players (pl) |
305 | for_all_players (pl) |
301 | { |
306 | { |
302 | if (!pl->ob || !pl->ns) |
307 | if (!pl->ob || !pl->ns || !pl->ob->active ()) |
303 | continue; |
308 | continue; |
304 | |
309 | |
305 | if (settings.casting_time) |
310 | if (settings.casting_time) |
306 | { |
311 | { |
307 | if (pl->ob->casting_time > 0) |
312 | if (pl->ob->casting_time > 0) |