… | |
… | |
153 | new_draw_info (NDI_UNIQUE, 0, this, "The exit is closed"); |
153 | new_draw_info (NDI_UNIQUE, 0, this, "The exit is closed"); |
154 | return; |
154 | return; |
155 | } |
155 | } |
156 | } |
156 | } |
157 | |
157 | |
|
|
158 | if (map) |
|
|
159 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
|
|
160 | return; |
|
|
161 | |
|
|
162 | /* If it is a player login, he has yet to be inserted anyplace. |
|
|
163 | * otherwise, we need to deal with removing the player here. |
|
|
164 | */ |
|
|
165 | remove (); |
|
|
166 | |
158 | /* try to find a spot for the player */ |
167 | /* try to find a spot for the player */ |
159 | if (ob_blocked (this, newmap, x, y)) |
168 | if (ob_blocked (this, newmap, x, y)) |
160 | { /* First choice blocked */ |
169 | { /* First choice blocked */ |
161 | /* We try to find a spot for the player, starting closest in. |
170 | /* We try to find a spot for the player, starting closest in. |
162 | * We could use find_first_free_spot, but that doesn't randomize it at all, |
171 | * We could use find_first_free_spot, but that doesn't randomize it at all, |
… | |
… | |
182 | else |
191 | else |
183 | /* not much we can do in this case. */ |
192 | /* not much we can do in this case. */ |
184 | 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); |
185 | } |
194 | } |
186 | |
195 | |
187 | if (map) |
|
|
188 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
|
|
189 | return; |
|
|
190 | |
|
|
191 | if (INVOKE_PLAYER (MAP_CHANGE, contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
196 | if (INVOKE_PLAYER (MAP_CHANGE, contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
192 | return; |
197 | return; |
193 | |
198 | |
194 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (contr), ARG_INT (x), ARG_INT (y))) |
199 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (contr), ARG_INT (x), ARG_INT (y))) |
195 | return; |
200 | return; |
196 | |
|
|
197 | /* If it is a player login, he has yet to be inserted anyplace. |
|
|
198 | * otherwise, we need to deal with removing the player here. |
|
|
199 | */ |
|
|
200 | remove (); |
|
|
201 | |
201 | |
202 | this->x = x; |
202 | this->x = x; |
203 | this->y = y; |
203 | this->y = y; |
204 | map = newmap; |
204 | map = newmap; |
205 | |
205 | |
… | |
… | |
247 | |
247 | |
248 | /* since the players map is already loaded, we don't need to worry |
248 | /* since the players map is already loaded, we don't need to worry |
249 | * about pending objects. |
249 | * about pending objects. |
250 | */ |
250 | */ |
251 | remove_all_pets (newmap); |
251 | remove_all_pets (newmap); |
252 | } |
|
|
253 | |
|
|
254 | /* clean_path takes a path and replaces all / with _ |
|
|
255 | * We do a strcpy so that we do not change the original string. |
|
|
256 | */ |
|
|
257 | char * |
|
|
258 | clean_path (const char *file) |
|
|
259 | { |
|
|
260 | static char newpath[MAX_BUF], *cp; |
|
|
261 | assign (newpath, file); |
|
|
262 | |
|
|
263 | for (cp = newpath; *cp != '\0'; cp++) |
|
|
264 | if (*cp == '/') |
|
|
265 | *cp = '_'; |
|
|
266 | |
|
|
267 | return newpath; |
|
|
268 | } |
|
|
269 | |
|
|
270 | /* unclean_path takes a path and replaces all _ with / |
|
|
271 | * This basically undoes clean path. |
|
|
272 | * We do a strcpy so that we do not change the original string. |
|
|
273 | * We are smart enough to start after the last / in case we |
|
|
274 | * are getting passed a string that points to a unique map |
|
|
275 | * path. |
|
|
276 | */ |
|
|
277 | char * |
|
|
278 | unclean_path (const char *src) |
|
|
279 | { |
|
|
280 | static char newpath[MAX_BUF], *cp; |
|
|
281 | |
|
|
282 | cp = strrchr (src, '/'); |
|
|
283 | assign (newpath, cp ? cp + 1 : src); |
|
|
284 | |
|
|
285 | for (cp = newpath; *cp != '\0'; cp++) |
|
|
286 | if (*cp == '_') |
|
|
287 | *cp = '/'; |
|
|
288 | |
|
|
289 | return newpath; |
|
|
290 | } |
252 | } |
291 | |
253 | |
292 | /* process_players1 and process_players2 do all the player related stuff. |
254 | /* process_players1 and process_players2 do all the player related stuff. |
293 | * I moved it out of process events and process_map. This was to some |
255 | * I moved it out of process events and process_map. This was to some |
294 | * extent for debugging as well as to get a better idea of the time used |
256 | * extent for debugging as well as to get a better idea of the time used |
… | |
… | |
556 | { |
518 | { |
557 | LOG (llevDebug, "cleanup begin.\n"); |
519 | LOG (llevDebug, "cleanup begin.\n"); |
558 | |
520 | |
559 | in_cleanup = true; |
521 | in_cleanup = true; |
560 | |
522 | |
561 | if (init_done) |
523 | if (init_done && !in_cleanup) |
562 | emergency_save (); |
524 | emergency_save (); |
563 | |
525 | |
564 | LOG (llevDebug, "running cleanup handlers.\n"); |
526 | LOG (llevDebug, "running cleanup handlers.\n"); |
565 | INVOKE_GLOBAL (CLEANUP); |
527 | INVOKE_GLOBAL (CLEANUP); |
566 | |
528 | |
… | |
… | |
729 | initPlugins (); |
691 | initPlugins (); |
730 | |
692 | |
731 | for (;;) |
693 | for (;;) |
732 | cfperl_main (); |
694 | cfperl_main (); |
733 | |
695 | |
734 | // unreached |
|
|
735 | cleanup (); |
696 | cleanup (true); |
736 | |
|
|
737 | return 0; |
|
|
738 | } |
697 | } |
|
|
698 | |