… | |
… | |
106 | new_draw_info (NDI_UNIQUE, 0, op, "Images and art:"); |
106 | new_draw_info (NDI_UNIQUE, 0, op, "Images and art:"); |
107 | new_draw_info (NDI_UNIQUE, 0, op, "Peter Gardner"); |
107 | new_draw_info (NDI_UNIQUE, 0, op, "Peter Gardner"); |
108 | new_draw_info (NDI_UNIQUE, 0, op, "David Gervais [david_eg@mail.com]"); |
108 | new_draw_info (NDI_UNIQUE, 0, op, "David Gervais [david_eg@mail.com]"); |
109 | new_draw_info (NDI_UNIQUE, 0, op, "Mitsuhiro Itakura [ita@gold.koma.jaeri.go.jp]"); |
109 | new_draw_info (NDI_UNIQUE, 0, op, "Mitsuhiro Itakura [ita@gold.koma.jaeri.go.jp]"); |
110 | new_draw_info (NDI_UNIQUE, 0, op, "Hansjoerg Malthaner [hansjoerg.malthaner@danet.de]"); |
110 | new_draw_info (NDI_UNIQUE, 0, op, "Hansjoerg Malthaner [hansjoerg.malthaner@danet.de]"); |
111 | new_draw_info (NDI_UNIQUE, 0, op, "Mårten Woxberg [maxmc@telia.com]"); |
111 | new_draw_info (NDI_UNIQUE, 0, op, "MÃ¥rten Woxberg [maxmc@telia.com]"); |
112 | new_draw_info (NDI_UNIQUE, 0, op, "And many more!"); |
112 | new_draw_info (NDI_UNIQUE, 0, op, "And many more!"); |
113 | } |
113 | } |
114 | |
114 | |
115 | void |
115 | void |
116 | info_keys (object *op) |
116 | info_keys (object *op) |
… | |
… | |
191 | * goes someplace. |
191 | * goes someplace. |
192 | */ |
192 | */ |
193 | void |
193 | void |
194 | enter_player_savebed (object *op) |
194 | enter_player_savebed (object *op) |
195 | { |
195 | { |
196 | mapstruct *oldmap = op->map; |
196 | maptile *oldmap = op->map; |
197 | object *tmp; |
197 | object *tmp; |
198 | |
198 | |
199 | tmp = get_object (); |
199 | tmp = get_object (); |
200 | |
200 | |
201 | EXIT_PATH (tmp) = op->contr->savebed_map; |
201 | EXIT_PATH (tmp) = op->contr->savebed_map; |
… | |
… | |
226 | * the counts on the map if needed. |
226 | * the counts on the map if needed. |
227 | */ |
227 | */ |
228 | void |
228 | void |
229 | leave_map (object *op) |
229 | leave_map (object *op) |
230 | { |
230 | { |
231 | mapstruct *oldmap = op->map; |
231 | maptile *oldmap = op->map; |
232 | |
232 | |
233 | remove_ob (op); |
233 | remove_ob (op); |
234 | |
234 | |
235 | if (oldmap) |
235 | if (oldmap) |
236 | { |
236 | { |
237 | if (!op->contr->hidden) |
237 | if (!op->contr->hidden) |
238 | oldmap->players--; |
238 | oldmap->players--; |
|
|
239 | |
239 | if (oldmap->players <= 0) |
240 | if (oldmap->players <= 0) |
240 | { /* can be less than zero due to errors in tracking this */ |
241 | /* can be less than zero due to errors in tracking this */ |
241 | set_map_timeout (oldmap); |
242 | set_map_timeout (oldmap); |
242 | } |
|
|
243 | } |
243 | } |
244 | } |
244 | } |
245 | |
245 | |
246 | /* |
246 | /* |
247 | * enter_map(): Moves the player and pets from current map (if any) to |
247 | * enter_map(): Moves the player and pets from current map (if any) to |
… | |
… | |
249 | * player to - it could be the map he just came from if the load failed for |
249 | * player to - it could be the map he just came from if the load failed for |
250 | * whatever reason. If default map coordinates are to be used, then |
250 | * whatever reason. If default map coordinates are to be used, then |
251 | * the function that calls this should figure them out. |
251 | * the function that calls this should figure them out. |
252 | */ |
252 | */ |
253 | static void |
253 | static void |
254 | enter_map (object *op, mapstruct *newmap, int x, int y) |
254 | enter_map (object *op, maptile *newmap, int x, int y) |
255 | { |
255 | { |
256 | mapstruct *oldmap = op->map; |
256 | maptile *oldmap = op->map; |
257 | |
257 | |
258 | if (out_of_map (newmap, x, y)) |
258 | if (out_of_map (newmap, x, y)) |
259 | { |
259 | { |
260 | LOG (llevError, "enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", newmap->path, x, y); |
260 | LOG (llevError, "enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", newmap->path, x, y); |
261 | x = MAP_ENTER_X (newmap); |
261 | x = MAP_ENTER_X (newmap); |
… | |
… | |
266 | newmap->path, x, y, MAP_WIDTH (newmap), MAP_HEIGHT (newmap)); |
266 | newmap->path, x, y, MAP_WIDTH (newmap), MAP_HEIGHT (newmap)); |
267 | new_draw_info (NDI_UNIQUE, 0, op, "The exit is closed"); |
267 | new_draw_info (NDI_UNIQUE, 0, op, "The exit is closed"); |
268 | return; |
268 | return; |
269 | } |
269 | } |
270 | } |
270 | } |
|
|
271 | |
271 | /* try to find a spot for the player */ |
272 | /* try to find a spot for the player */ |
272 | if (ob_blocked (op, newmap, x, y)) |
273 | if (ob_blocked (op, newmap, x, y)) |
273 | { /* First choice blocked */ |
274 | { /* First choice blocked */ |
274 | /* We try to find a spot for the player, starting closest in. |
275 | /* We try to find a spot for the player, starting closest in. |
275 | * We could use find_first_free_spot, but that doesn't randomize it at all, |
276 | * We could use find_first_free_spot, but that doesn't randomize it at all, |
… | |
… | |
284 | { |
285 | { |
285 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE2 + 1); |
286 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE2 + 1); |
286 | if (i == -1) |
287 | if (i == -1) |
287 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE); |
288 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE); |
288 | } |
289 | } |
|
|
290 | |
289 | if (i != -1) |
291 | if (i != -1) |
290 | { |
292 | { |
291 | x += freearr_x[i]; |
293 | x += freearr_x[i]; |
292 | y += freearr_y[i]; |
294 | y += freearr_y[i]; |
293 | } |
295 | } |
… | |
… | |
297 | 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); |
299 | 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); |
298 | } |
300 | } |
299 | } /* end if looking for free spot */ |
301 | } /* end if looking for free spot */ |
300 | |
302 | |
301 | if (op->map != NULL) |
303 | if (op->map != NULL) |
302 | { |
|
|
303 | INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (op->map), ARG_MAP (newmap)); |
|
|
304 | INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr)); |
304 | if (INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr))) |
305 | } |
305 | return; |
|
|
306 | |
|
|
307 | if (INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
|
|
308 | return; |
|
|
309 | |
|
|
310 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (op->contr), ARG_INT (x), ARG_INT (y))) |
|
|
311 | return; |
306 | |
312 | |
307 | /* If it is a player login, he has yet to be inserted anyplace. |
313 | /* If it is a player login, he has yet to be inserted anyplace. |
308 | * otherwise, we need to deal with removing the player here. |
314 | * otherwise, we need to deal with removing the player here. |
309 | */ |
315 | */ |
310 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
|
|
311 | remove_ob (op); |
316 | remove_ob (op); |
312 | |
317 | |
313 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
318 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
314 | op->x = x; |
319 | op->x = x; |
315 | op->y = y; |
320 | op->y = y; |
316 | op->map = newmap; |
321 | op->map = newmap; |
|
|
322 | |
317 | insert_ob_in_map (op, op->map, NULL, INS_NO_WALK_ON); |
323 | insert_ob_in_map (op, op->map, NULL, INS_NO_WALK_ON); |
318 | |
|
|
319 | INVOKE_MAP (ENTER, op->map, ARG_PLAYER (op->contr)); |
|
|
320 | |
324 | |
321 | if (!op->contr->hidden) |
325 | if (!op->contr->hidden) |
322 | newmap->players++; |
326 | newmap->players++; |
323 | |
327 | |
324 | newmap->timeout = 0; |
328 | newmap->timeout = 0; |
… | |
… | |
335 | { |
339 | { |
336 | int i = find_free_spot (op->contr->ranges[range_golem], newmap, |
340 | int i = find_free_spot (op->contr->ranges[range_golem], newmap, |
337 | x, y, 1, SIZEOFFREE); |
341 | x, y, 1, SIZEOFFREE); |
338 | |
342 | |
339 | remove_ob (op->contr->ranges[range_golem]); |
343 | remove_ob (op->contr->ranges[range_golem]); |
|
|
344 | |
340 | if (i == -1) |
345 | if (i == -1) |
341 | { |
346 | { |
342 | remove_friendly_object (op->contr->ranges[range_golem]); |
347 | remove_friendly_object (op->contr->ranges[range_golem]); |
343 | free_object (op->contr->ranges[range_golem]); |
348 | free_object (op->contr->ranges[range_golem]); |
344 | op->contr->ranges[range_golem] = NULL; |
349 | op->contr->ranges[range_golem] = NULL; |
345 | op->contr->golem_count = 0; |
350 | op->contr->golem_count = 0; |
346 | } |
351 | } |
347 | else |
352 | else |
348 | { |
353 | { |
349 | object *tmp; |
|
|
350 | |
|
|
351 | for (tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more) |
354 | for (object *tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more) |
352 | { |
355 | { |
353 | tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); |
356 | tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); |
354 | tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
357 | tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
355 | tmp->map = newmap; |
358 | tmp->map = newmap; |
356 | } |
359 | } |
|
|
360 | |
357 | insert_ob_in_map (op->contr->ranges[range_golem], newmap, NULL, 0); |
361 | insert_ob_in_map (op->contr->ranges[range_golem], newmap, NULL, 0); |
358 | op->contr->ranges[range_golem]->direction = |
362 | op->contr->ranges[range_golem]->direction = |
359 | find_dir_2 (op->x - op->contr->ranges[range_golem]->x, op->y - op->contr->ranges[range_golem]->y); |
363 | find_dir_2 (op->x - op->contr->ranges[range_golem]->x, op->y - op->contr->ranges[range_golem]->y); |
360 | } |
364 | } |
361 | } |
365 | } |
|
|
366 | |
362 | op->direction = 0; |
367 | op->direction = 0; |
363 | |
368 | |
364 | /* since the players map is already loaded, we don't need to worry |
369 | /* since the players map is already loaded, we don't need to worry |
365 | * about pending objects. |
370 | * about pending objects. |
366 | */ |
371 | */ |
… | |
… | |
381 | } |
386 | } |
382 | } |
387 | } |
383 | } |
388 | } |
384 | |
389 | |
385 | void |
390 | void |
386 | set_map_timeout (mapstruct *oldmap) |
391 | set_map_timeout (maptile *oldmap) |
387 | { |
392 | { |
388 | #if MAP_MAXTIMEOUT |
393 | #if MAP_MAXTIMEOUT |
389 | oldmap->timeout = MAP_TIMEOUT (oldmap); |
394 | oldmap->timeout = MAP_TIMEOUT (oldmap); |
390 | /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is |
395 | /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is |
391 | * lower than the min value. |
396 | * lower than the min value. |
392 | */ |
397 | */ |
393 | # if MAP_MINTIMEOUT |
398 | # if MAP_MINTIMEOUT |
394 | if (oldmap->timeout < MAP_MINTIMEOUT) |
399 | if (oldmap->timeout < MAP_MINTIMEOUT) |
395 | { |
|
|
396 | oldmap->timeout = MAP_MINTIMEOUT; |
400 | oldmap->timeout = MAP_MINTIMEOUT; |
397 | } |
|
|
398 | # endif |
401 | # endif |
|
|
402 | |
399 | if (oldmap->timeout > MAP_MAXTIMEOUT) |
403 | if (oldmap->timeout > MAP_MAXTIMEOUT) |
400 | { |
|
|
401 | oldmap->timeout = MAP_MAXTIMEOUT; |
404 | oldmap->timeout = MAP_MAXTIMEOUT; |
402 | } |
405 | |
403 | #else |
406 | #else |
404 | /* save out the map */ |
407 | /* save out the map */ |
405 | swap_map (oldmap); |
408 | swap_map (oldmap); |
406 | #endif /* MAP_MAXTIMEOUT */ |
409 | #endif /* MAP_MAXTIMEOUT */ |
407 | } |
410 | } |
… | |
… | |
452 | */ |
455 | */ |
453 | |
456 | |
454 | static void |
457 | static void |
455 | enter_random_map (object *pl, object *exit_ob) |
458 | enter_random_map (object *pl, object *exit_ob) |
456 | { |
459 | { |
457 | mapstruct *new_map; |
460 | maptile *new_map; |
458 | char newmap_name[HUGE_BUF], *cp; |
461 | char newmap_name[HUGE_BUF], *cp; |
459 | static int reference_number = 0; |
462 | static int reference_number = 0; |
460 | RMParms rp; |
463 | RMParms rp; |
461 | |
464 | |
462 | memset (&rp, 0, sizeof (RMParms)); |
465 | memset (&rp, 0, sizeof (RMParms)); |
… | |
… | |
522 | */ |
525 | */ |
523 | |
526 | |
524 | static void |
527 | static void |
525 | enter_fixed_template_map (object *pl, object *exit_ob) |
528 | enter_fixed_template_map (object *pl, object *exit_ob) |
526 | { |
529 | { |
527 | mapstruct *new_map; |
530 | maptile *new_map; |
528 | char tmpnum[32], exitpath[HUGE_BUF], resultname[HUGE_BUF], tmpstring[HUGE_BUF], *sourcemap; |
531 | char tmpnum[32], exitpath[HUGE_BUF], resultname[HUGE_BUF], tmpstring[HUGE_BUF], *sourcemap; |
529 | const char *new_map_name; |
532 | const char *new_map_name; |
530 | |
533 | |
531 | /* Split the exit path string into two parts, one |
534 | /* Split the exit path string into two parts, one |
532 | * for where to store the map, and one for were |
535 | * for where to store the map, and one for were |
… | |
… | |
541 | */ |
544 | */ |
542 | LOG (llevError, "enter_fixed_template_map: Exit %s (%d,%d) on map %s has no source template.\n", |
545 | LOG (llevError, "enter_fixed_template_map: Exit %s (%d,%d) on map %s has no source template.\n", |
543 | &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); |
546 | &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); |
544 | return; |
547 | return; |
545 | } |
548 | } |
|
|
549 | |
546 | *sourcemap++ = '\0'; |
550 | *sourcemap++ = '\0'; |
547 | |
551 | |
548 | /* If we are not coming from a template map, we can use relative directories |
552 | /* If we are not coming from a template map, we can use relative directories |
549 | * for the map to generate from. |
553 | * for the map to generate from. |
550 | */ |
554 | */ |
551 | if (!exit_ob->map->templatemap) |
555 | if (!exit_ob->map->templatemap) |
552 | { |
|
|
553 | sourcemap = path_combine_and_normalize (exit_ob->map->path, sourcemap); |
556 | sourcemap = path_combine_and_normalize (exit_ob->map->path, sourcemap); |
554 | } |
|
|
555 | |
557 | |
556 | /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord |
558 | /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord |
557 | * of the exit, and the name of the map the exit is on, respectively. |
559 | * of the exit, and the name of the map the exit is on, respectively. |
558 | */ |
560 | */ |
559 | sprintf (tmpnum, "%d", exit_ob->x); |
561 | sprintf (tmpnum, "%d", exit_ob->x); |
… | |
… | |
568 | |
570 | |
569 | /* If we are coming from another template map, use reletive paths unless |
571 | /* If we are coming from another template map, use reletive paths unless |
570 | * indicated otherwise. |
572 | * indicated otherwise. |
571 | */ |
573 | */ |
572 | if (exit_ob->map->templatemap && (resultname[0] != '/')) |
574 | if (exit_ob->map->templatemap && (resultname[0] != '/')) |
573 | { |
|
|
574 | new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname); |
575 | new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname); |
575 | } |
|
|
576 | else |
576 | else |
577 | { |
|
|
578 | new_map_name = create_template_pathname (resultname); |
577 | new_map_name = create_template_pathname (resultname); |
579 | } |
|
|
580 | |
578 | |
581 | /* Attempt to load the map, if unable to, then |
579 | /* Attempt to load the map, if unable to, then |
582 | * create the map from the template. |
580 | * create the map from the template. |
583 | */ |
581 | */ |
584 | new_map = ready_map_name (new_map_name, MAP_PLAYER_UNIQUE); |
582 | new_map = ready_map_name (new_map_name, MAP_PLAYER_UNIQUE); |
… | |
… | |
606 | LOG (llevDebug, "enter_fixed_template_map: Exit %s (%d,%d) on map %s leads no where.\n", |
604 | LOG (llevDebug, "enter_fixed_template_map: Exit %s (%d,%d) on map %s leads no where.\n", |
607 | &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); |
605 | &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path); |
608 | } |
606 | } |
609 | } |
607 | } |
610 | |
608 | |
611 | |
|
|
612 | /* The player is trying to enter a randomly generated template map. In this |
609 | /* The player is trying to enter a randomly generated template map. In this |
613 | * case, generate the map as needed. |
610 | * case, generate the map as needed. |
614 | */ |
611 | */ |
615 | |
612 | |
616 | static void |
613 | static void |
617 | enter_random_template_map (object *pl, object *exit_ob) |
614 | enter_random_template_map (object *pl, object *exit_ob) |
618 | { |
615 | { |
619 | mapstruct *new_map; |
616 | maptile *new_map; |
620 | char tmpnum[32], resultname[HUGE_BUF], tmpstring[HUGE_BUF]; |
617 | char tmpnum[32], resultname[HUGE_BUF], tmpstring[HUGE_BUF]; |
621 | const char *new_map_name; |
618 | const char *new_map_name; |
622 | RMParms rp; |
619 | RMParms rp; |
623 | |
620 | |
624 | /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord |
621 | /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord |
… | |
… | |
686 | */ |
683 | */ |
687 | static void |
684 | static void |
688 | enter_unique_map (object *op, object *exit_ob) |
685 | enter_unique_map (object *op, object *exit_ob) |
689 | { |
686 | { |
690 | char apartment[HUGE_BUF]; |
687 | char apartment[HUGE_BUF]; |
691 | mapstruct *newmap; |
688 | maptile *newmap; |
692 | |
689 | |
693 | if (EXIT_PATH (exit_ob)[0] == '/') |
690 | if (EXIT_PATH (exit_ob)[0] == '/') |
694 | { |
691 | { |
695 | sprintf (apartment, "%s/%s/%s/%s", settings.localdir, settings.playerdir, &op->name, clean_path (EXIT_PATH (exit_ob))); |
692 | sprintf (apartment, "%s/%s/%s/%s", settings.localdir, settings.playerdir, &op->name, clean_path (EXIT_PATH (exit_ob))); |
696 | newmap = ready_map_name (apartment, MAP_PLAYER_UNIQUE); |
693 | newmap = ready_map_name (apartment, MAP_PLAYER_UNIQUE); |
… | |
… | |
788 | return; |
785 | return; |
789 | |
786 | |
790 | /* First, lets figure out what map the player is going to go to */ |
787 | /* First, lets figure out what map the player is going to go to */ |
791 | if (exit_ob) |
788 | if (exit_ob) |
792 | { |
789 | { |
793 | |
|
|
794 | /* check to see if we make a template map */ |
790 | /* check to see if we make a template map */ |
795 | if (EXIT_PATH (exit_ob) && EXIT_PATH (exit_ob)[1] == '@') |
791 | if (EXIT_PATH (exit_ob) && EXIT_PATH (exit_ob)[1] == '@') |
796 | { |
792 | { |
797 | if (EXIT_PATH (exit_ob)[2] == '!') |
793 | if (EXIT_PATH (exit_ob)[2] == '!') |
798 | { |
794 | { |
… | |
… | |
819 | int x = EXIT_X (exit_ob), y = EXIT_Y (exit_ob); |
815 | int x = EXIT_X (exit_ob), y = EXIT_Y (exit_ob); |
820 | |
816 | |
821 | /* 'Normal' exits that do not do anything special |
817 | /* 'Normal' exits that do not do anything special |
822 | * Simple enough we don't need another routine for it. |
818 | * Simple enough we don't need another routine for it. |
823 | */ |
819 | */ |
824 | mapstruct *newmap; |
820 | maptile *newmap; |
825 | |
821 | |
826 | if (exit_ob->map) |
822 | if (exit_ob->map) |
827 | { |
823 | { |
828 | newmap = ready_map_name (path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob)), 0); |
824 | newmap = ready_map_name (path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob)), 0); |
829 | /* Random map was previously generated, but is no longer about. Lets generate a new |
825 | /* Random map was previously generated, but is no longer about. Lets generate a new |
… | |
… | |
918 | hit_player (op, exit_ob->stats.dam, exit_ob, exit_ob->attacktype, 1); |
914 | hit_player (op, exit_ob->stats.dam, exit_ob, exit_ob->attacktype, 1); |
919 | } |
915 | } |
920 | else |
916 | else |
921 | { |
917 | { |
922 | int flags = 0; |
918 | int flags = 0; |
923 | mapstruct *newmap; |
919 | maptile *newmap; |
924 | |
|
|
925 | |
920 | |
926 | /* Hypothetically, I guess its possible that a standard map matches |
921 | /* Hypothetically, I guess its possible that a standard map matches |
927 | * the localdir, but that seems pretty unlikely - unlikely enough that |
922 | * the localdir, but that seems pretty unlikely - unlikely enough that |
928 | * I'm not going to attempt to try to deal with that possibility. |
923 | * I'm not going to attempt to try to deal with that possibility. |
929 | * We use the fact that when a player saves on a unique map, it prepends |
924 | * We use the fact that when a player saves on a unique map, it prepends |
… | |
… | |
950 | { |
945 | { |
951 | LOG (llevError, "enter_exit: could not load emergency map? Fatal error\n"); |
946 | LOG (llevError, "enter_exit: could not load emergency map? Fatal error\n"); |
952 | abort (); |
947 | abort (); |
953 | } |
948 | } |
954 | } |
949 | } |
|
|
950 | |
955 | enter_map (op, newmap, op->x, op->y); |
951 | enter_map (op, newmap, op->x, op->y); |
956 | } |
952 | } |
957 | } |
953 | } |
958 | |
954 | |
959 | /* |
955 | /* |
… | |
… | |
964 | |
960 | |
965 | #if 0 // dead code, schmorp |
961 | #if 0 // dead code, schmorp |
966 | void |
962 | void |
967 | process_active_maps () |
963 | process_active_maps () |
968 | { |
964 | { |
969 | for (mapstruct *map = first_map; map != NULL; map = map->next) |
965 | for (maptile *map = first_map; map != NULL; map = map->next) |
970 | if (map->in_memory == MAP_IN_MEMORY) |
966 | if (map->in_memory == MAP_IN_MEMORY) |
971 | if (players_on_map (map, TRUE)) |
967 | if (players_on_map (map, TRUE)) |
972 | process_events (map); |
968 | process_events (map); |
973 | } |
969 | } |
974 | #endif |
970 | #endif |
… | |
… | |
980 | * objects have been updated, process_players2() does the processing that |
976 | * objects have been updated, process_players2() does the processing that |
981 | * is needed after the players have been updated. |
977 | * is needed after the players have been updated. |
982 | */ |
978 | */ |
983 | |
979 | |
984 | void |
980 | void |
985 | process_players1 (mapstruct *map) |
981 | process_players1 (maptile *map) |
986 | { |
982 | { |
987 | int flag; |
983 | int flag; |
988 | player *pl, *plnext; |
984 | player *pl, *plnext; |
989 | |
985 | |
990 | /* Basically, we keep looping until all the players have done their actions. */ |
986 | /* Basically, we keep looping until all the players have done their actions. */ |
… | |
… | |
1057 | /* draw(pl->ob); *//* updated in socket code */ |
1053 | /* draw(pl->ob); *//* updated in socket code */ |
1058 | } |
1054 | } |
1059 | } |
1055 | } |
1060 | |
1056 | |
1061 | void |
1057 | void |
1062 | process_players2 (mapstruct *map) |
1058 | process_players2 (maptile *map) |
1063 | { |
1059 | { |
1064 | player *pl; |
1060 | player *pl; |
1065 | |
1061 | |
1066 | /* Then check if any players should use weapon-speed instead of speed */ |
1062 | /* Then check if any players should use weapon-speed instead of speed */ |
1067 | for (pl = first_player; pl != NULL; pl = pl->next) |
1063 | for (pl = first_player; pl != NULL; pl = pl->next) |
… | |
… | |
1097 | pl->ob->speed_left = pl->ob->speed; |
1093 | pl->ob->speed_left = pl->ob->speed; |
1098 | } |
1094 | } |
1099 | } |
1095 | } |
1100 | |
1096 | |
1101 | void |
1097 | void |
1102 | process_events (mapstruct *map) |
1098 | process_events (maptile *map) |
1103 | { |
1099 | { |
1104 | object *op; |
1100 | object *op; |
1105 | tag_t tag; |
|
|
1106 | |
1101 | |
1107 | static object *marker; |
1102 | static object *marker; |
1108 | |
|
|
1109 | if (!marker) |
1103 | if (!marker) |
1110 | marker = get_object (); |
1104 | marker = get_object (); |
1111 | |
1105 | |
1112 | process_players1 (map); |
1106 | process_players1 (map); |
1113 | |
1107 | |
… | |
… | |
1120 | active_objects = marker; |
1114 | active_objects = marker; |
1121 | |
1115 | |
1122 | while (marker->active_next) |
1116 | while (marker->active_next) |
1123 | { |
1117 | { |
1124 | op = marker->active_next; |
1118 | op = marker->active_next; |
1125 | tag = op->count; |
|
|
1126 | |
1119 | |
1127 | /* Move marker forward - swap op and marker */ |
1120 | /* Move marker forward - swap op and marker */ |
1128 | op->active_prev = marker->active_prev; |
1121 | op->active_prev = marker->active_prev; |
1129 | |
1122 | |
1130 | if (op->active_prev) |
1123 | if (op->active_prev) |
… | |
… | |
1217 | LOG (llevDebug, "process_events: calling process_object with removed object %s\n", op->name ? op->name : "null"); |
1210 | LOG (llevDebug, "process_events: calling process_object with removed object %s\n", op->name ? op->name : "null"); |
1218 | } |
1211 | } |
1219 | #endif |
1212 | #endif |
1220 | --op->speed_left; |
1213 | --op->speed_left; |
1221 | process_object (op); |
1214 | process_object (op); |
|
|
1215 | |
1222 | if (was_destroyed (op, tag)) |
1216 | if (op->destroyed ()) |
1223 | continue; |
1217 | continue; |
1224 | } |
1218 | } |
|
|
1219 | |
1225 | if (settings.casting_time == TRUE && op->casting_time > 0) |
1220 | if (settings.casting_time == TRUE && op->casting_time > 0) |
1226 | op->casting_time--; |
1221 | op->casting_time--; |
|
|
1222 | |
1227 | if (op->speed_left <= 0) |
1223 | if (op->speed_left <= 0) |
1228 | op->speed_left += FABS (op->speed); |
1224 | op->speed_left += FABS (op->speed); |
1229 | } |
1225 | } |
1230 | |
1226 | |
1231 | /* Remove marker object from active list */ |
1227 | /* Remove marker object from active list */ |
… | |
… | |
1238 | } |
1234 | } |
1239 | |
1235 | |
1240 | void |
1236 | void |
1241 | clean_tmp_files (void) |
1237 | clean_tmp_files (void) |
1242 | { |
1238 | { |
1243 | mapstruct *m, *next; |
1239 | maptile *m, *next; |
1244 | |
1240 | |
1245 | LOG (llevInfo, "Cleaning up...\n"); |
1241 | LOG (llevInfo, "Cleaning up...\n"); |
1246 | |
1242 | |
1247 | /* We save the maps - it may not be intuitive why, but if there are unique |
1243 | /* We save the maps - it may not be intuitive why, but if there are unique |
1248 | * items, we need to save the map so they get saved off. Perhaps we should |
1244 | * items, we need to save the map so they get saved off. Perhaps we should |
… | |
… | |
1276 | /* clean up everything before exiting */ |
1272 | /* clean up everything before exiting */ |
1277 | void |
1273 | void |
1278 | cleanup (void) |
1274 | cleanup (void) |
1279 | { |
1275 | { |
1280 | LOG (llevDebug, "Cleanup called.\n"); |
1276 | LOG (llevDebug, "Cleanup called.\n"); |
|
|
1277 | |
|
|
1278 | for (player *pl = first_player; pl != NULL; pl = pl->next) |
|
|
1279 | save_player (pl->ob, 0); |
|
|
1280 | |
|
|
1281 | for (player *pl = first_player; pl != NULL; pl = pl->next) |
|
|
1282 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
1283 | leave_map (pl->ob); |
|
|
1284 | |
|
|
1285 | clean_tmp_files (); |
1281 | write_book_archive (); |
1286 | write_book_archive (); |
1282 | |
1287 | |
1283 | INVOKE_GLOBAL (CLEANUP); |
1288 | INVOKE_GLOBAL (CLEANUP); |
1284 | |
1289 | |
1285 | _exit (0); |
1290 | _exit (0); |