ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/main.C
(Generate patch)

Comparing deliantra/server/server/main.C (file contents):
Revision 1.28 by root, Thu Sep 14 23:13:49 2006 UTC vs.
Revision 1.37 by root, Sat Dec 9 16:11:09 2006 UTC

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
115void 115void
116info_keys (object *op) 116info_keys (object *op)
191 * goes someplace. 191 * goes someplace.
192 */ 192 */
193void 193void
194enter_player_savebed (object *op) 194enter_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 */
228void 228void
229leave_map (object *op) 229leave_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 */
253static void 253static void
254enter_map (object *op, mapstruct *newmap, int x, int y) 254enter_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] = 0;
345 op->contr->golem_count = 0;
346 } 350 }
347 else 351 else
348 { 352 {
349 object *tmp;
350
351 for (tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more) 353 for (object *tmp = op->contr->ranges[range_golem]; tmp != NULL; tmp = tmp->more)
352 { 354 {
353 tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); 355 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); 356 tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y);
355 tmp->map = newmap; 357 tmp->map = newmap;
356 } 358 }
359
357 insert_ob_in_map (op->contr->ranges[range_golem], newmap, NULL, 0); 360 insert_ob_in_map (op->contr->ranges[range_golem], newmap, NULL, 0);
358 op->contr->ranges[range_golem]->direction = 361 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); 362 find_dir_2 (op->x - op->contr->ranges[range_golem]->x, op->y - op->contr->ranges[range_golem]->y);
360 } 363 }
361 } 364 }
365
362 op->direction = 0; 366 op->direction = 0;
363 367
364 /* since the players map is already loaded, we don't need to worry 368 /* since the players map is already loaded, we don't need to worry
365 * about pending objects. 369 * about pending objects.
366 */ 370 */
381 } 385 }
382 } 386 }
383} 387}
384 388
385void 389void
386set_map_timeout (mapstruct *oldmap) 390set_map_timeout (maptile *oldmap)
387{ 391{
388#if MAP_MAXTIMEOUT 392#if MAP_MAXTIMEOUT
389 oldmap->timeout = MAP_TIMEOUT (oldmap); 393 oldmap->timeout = MAP_TIMEOUT (oldmap);
390 /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is 394 /* Do MINTIMEOUT first, so that MAXTIMEOUT is used if that is
391 * lower than the min value. 395 * lower than the min value.
392 */ 396 */
393# if MAP_MINTIMEOUT 397# if MAP_MINTIMEOUT
394 if (oldmap->timeout < MAP_MINTIMEOUT) 398 if (oldmap->timeout < MAP_MINTIMEOUT)
395 {
396 oldmap->timeout = MAP_MINTIMEOUT; 399 oldmap->timeout = MAP_MINTIMEOUT;
397 }
398# endif 400# endif
401
399 if (oldmap->timeout > MAP_MAXTIMEOUT) 402 if (oldmap->timeout > MAP_MAXTIMEOUT)
400 {
401 oldmap->timeout = MAP_MAXTIMEOUT; 403 oldmap->timeout = MAP_MAXTIMEOUT;
402 } 404
403#else 405#else
404 /* save out the map */ 406 /* save out the map */
405 swap_map (oldmap); 407 swap_map (oldmap);
406#endif /* MAP_MAXTIMEOUT */ 408#endif /* MAP_MAXTIMEOUT */
407} 409}
452 */ 454 */
453 455
454static void 456static void
455enter_random_map (object *pl, object *exit_ob) 457enter_random_map (object *pl, object *exit_ob)
456{ 458{
457 mapstruct *new_map; 459 maptile *new_map;
458 char newmap_name[HUGE_BUF], *cp; 460 char newmap_name[HUGE_BUF], *cp;
459 static int reference_number = 0; 461 static int reference_number = 0;
460 RMParms rp; 462 RMParms rp;
461 463
462 memset (&rp, 0, sizeof (RMParms)); 464 memset (&rp, 0, sizeof (RMParms));
522 */ 524 */
523 525
524static void 526static void
525enter_fixed_template_map (object *pl, object *exit_ob) 527enter_fixed_template_map (object *pl, object *exit_ob)
526{ 528{
527 mapstruct *new_map; 529 maptile *new_map;
528 char tmpnum[32], exitpath[HUGE_BUF], resultname[HUGE_BUF], tmpstring[HUGE_BUF], *sourcemap; 530 char tmpnum[32], exitpath[HUGE_BUF], resultname[HUGE_BUF], tmpstring[HUGE_BUF], *sourcemap;
529 const char *new_map_name; 531 const char *new_map_name;
530 532
531 /* Split the exit path string into two parts, one 533 /* Split the exit path string into two parts, one
532 * for where to store the map, and one for were 534 * for where to store the map, and one for were
541 */ 543 */
542 LOG (llevError, "enter_fixed_template_map: Exit %s (%d,%d) on map %s has no source template.\n", 544 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); 545 &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path);
544 return; 546 return;
545 } 547 }
548
546 *sourcemap++ = '\0'; 549 *sourcemap++ = '\0';
547 550
548 /* If we are not coming from a template map, we can use relative directories 551 /* If we are not coming from a template map, we can use relative directories
549 * for the map to generate from. 552 * for the map to generate from.
550 */ 553 */
551 if (!exit_ob->map->templatemap) 554 if (!exit_ob->map->templatemap)
552 {
553 sourcemap = path_combine_and_normalize (exit_ob->map->path, sourcemap); 555 sourcemap = path_combine_and_normalize (exit_ob->map->path, sourcemap);
554 }
555 556
556 /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord 557 /* 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. 558 * of the exit, and the name of the map the exit is on, respectively.
558 */ 559 */
559 sprintf (tmpnum, "%d", exit_ob->x); 560 sprintf (tmpnum, "%d", exit_ob->x);
568 569
569 /* If we are coming from another template map, use reletive paths unless 570 /* If we are coming from another template map, use reletive paths unless
570 * indicated otherwise. 571 * indicated otherwise.
571 */ 572 */
572 if (exit_ob->map->templatemap && (resultname[0] != '/')) 573 if (exit_ob->map->templatemap && (resultname[0] != '/'))
573 {
574 new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname); 574 new_map_name = path_combine_and_normalize (exit_ob->map->path, resultname);
575 }
576 else 575 else
577 {
578 new_map_name = create_template_pathname (resultname); 576 new_map_name = create_template_pathname (resultname);
579 }
580 577
581 /* Attempt to load the map, if unable to, then 578 /* Attempt to load the map, if unable to, then
582 * create the map from the template. 579 * create the map from the template.
583 */ 580 */
584 new_map = ready_map_name (new_map_name, MAP_PLAYER_UNIQUE); 581 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", 603 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); 604 &exit_ob->name, exit_ob->x, exit_ob->y, exit_ob->map->path);
608 } 605 }
609} 606}
610 607
611
612/* The player is trying to enter a randomly generated template map. In this 608/* The player is trying to enter a randomly generated template map. In this
613 * case, generate the map as needed. 609 * case, generate the map as needed.
614 */ 610 */
615 611
616static void 612static void
617enter_random_template_map (object *pl, object *exit_ob) 613enter_random_template_map (object *pl, object *exit_ob)
618{ 614{
619 mapstruct *new_map; 615 maptile *new_map;
620 char tmpnum[32], resultname[HUGE_BUF], tmpstring[HUGE_BUF]; 616 char tmpnum[32], resultname[HUGE_BUF], tmpstring[HUGE_BUF];
621 const char *new_map_name; 617 const char *new_map_name;
622 RMParms rp; 618 RMParms rp;
623 619
624 /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord 620 /* Do replacement of %x, %y, and %n to the x coord of the exit, the y coord
686 */ 682 */
687static void 683static void
688enter_unique_map (object *op, object *exit_ob) 684enter_unique_map (object *op, object *exit_ob)
689{ 685{
690 char apartment[HUGE_BUF]; 686 char apartment[HUGE_BUF];
691 mapstruct *newmap; 687 maptile *newmap;
692 688
693 if (EXIT_PATH (exit_ob)[0] == '/') 689 if (EXIT_PATH (exit_ob)[0] == '/')
694 { 690 {
695 sprintf (apartment, "%s/%s/%s/%s", settings.localdir, settings.playerdir, &op->name, clean_path (EXIT_PATH (exit_ob))); 691 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); 692 newmap = ready_map_name (apartment, MAP_PLAYER_UNIQUE);
788 return; 784 return;
789 785
790 /* First, lets figure out what map the player is going to go to */ 786 /* First, lets figure out what map the player is going to go to */
791 if (exit_ob) 787 if (exit_ob)
792 { 788 {
793
794 /* check to see if we make a template map */ 789 /* check to see if we make a template map */
795 if (EXIT_PATH (exit_ob) && EXIT_PATH (exit_ob)[1] == '@') 790 if (EXIT_PATH (exit_ob) && EXIT_PATH (exit_ob)[1] == '@')
796 { 791 {
797 if (EXIT_PATH (exit_ob)[2] == '!') 792 if (EXIT_PATH (exit_ob)[2] == '!')
798 { 793 {
819 int x = EXIT_X (exit_ob), y = EXIT_Y (exit_ob); 814 int x = EXIT_X (exit_ob), y = EXIT_Y (exit_ob);
820 815
821 /* 'Normal' exits that do not do anything special 816 /* 'Normal' exits that do not do anything special
822 * Simple enough we don't need another routine for it. 817 * Simple enough we don't need another routine for it.
823 */ 818 */
824 mapstruct *newmap; 819 maptile *newmap;
825 820
826 if (exit_ob->map) 821 if (exit_ob->map)
827 { 822 {
828 newmap = ready_map_name (path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob)), 0); 823 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 824 /* 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); 913 hit_player (op, exit_ob->stats.dam, exit_ob, exit_ob->attacktype, 1);
919 } 914 }
920 else 915 else
921 { 916 {
922 int flags = 0; 917 int flags = 0;
923 mapstruct *newmap; 918 maptile *newmap;
924
925 919
926 /* Hypothetically, I guess its possible that a standard map matches 920 /* Hypothetically, I guess its possible that a standard map matches
927 * the localdir, but that seems pretty unlikely - unlikely enough that 921 * the localdir, but that seems pretty unlikely - unlikely enough that
928 * I'm not going to attempt to try to deal with that possibility. 922 * 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 923 * We use the fact that when a player saves on a unique map, it prepends
950 { 944 {
951 LOG (llevError, "enter_exit: could not load emergency map? Fatal error\n"); 945 LOG (llevError, "enter_exit: could not load emergency map? Fatal error\n");
952 abort (); 946 abort ();
953 } 947 }
954 } 948 }
949
955 enter_map (op, newmap, op->x, op->y); 950 enter_map (op, newmap, op->x, op->y);
956 } 951 }
957} 952}
958 953
959/* 954/*
964 959
965#if 0 // dead code, schmorp 960#if 0 // dead code, schmorp
966void 961void
967process_active_maps () 962process_active_maps ()
968{ 963{
969 for (mapstruct *map = first_map; map != NULL; map = map->next) 964 for (maptile *map = first_map; map != NULL; map = map->next)
970 if (map->in_memory == MAP_IN_MEMORY) 965 if (map->in_memory == MAP_IN_MEMORY)
971 if (players_on_map (map, TRUE)) 966 if (players_on_map (map, TRUE))
972 process_events (map); 967 process_events (map);
973} 968}
974#endif 969#endif
980 * objects have been updated, process_players2() does the processing that 975 * objects have been updated, process_players2() does the processing that
981 * is needed after the players have been updated. 976 * is needed after the players have been updated.
982 */ 977 */
983 978
984void 979void
985process_players1 (mapstruct *map) 980process_players1 (maptile *map)
986{ 981{
987 int flag; 982 int flag;
988 player *pl, *plnext; 983 player *pl, *plnext;
989 984
990 /* Basically, we keep looping until all the players have done their actions. */ 985 /* Basically, we keep looping until all the players have done their actions. */
1057 /* draw(pl->ob); *//* updated in socket code */ 1052 /* draw(pl->ob); *//* updated in socket code */
1058 } 1053 }
1059} 1054}
1060 1055
1061void 1056void
1062process_players2 (mapstruct *map) 1057process_players2 (maptile *map)
1063{ 1058{
1064 player *pl; 1059 player *pl;
1065 1060
1066 /* Then check if any players should use weapon-speed instead of speed */ 1061 /* Then check if any players should use weapon-speed instead of speed */
1067 for (pl = first_player; pl != NULL; pl = pl->next) 1062 for (pl = first_player; pl != NULL; pl = pl->next)
1097 pl->ob->speed_left = pl->ob->speed; 1092 pl->ob->speed_left = pl->ob->speed;
1098 } 1093 }
1099} 1094}
1100 1095
1101void 1096void
1102process_events (mapstruct *map) 1097process_events (maptile *map)
1103{ 1098{
1104 object *op; 1099 object *op;
1105 1100
1106 static object *marker; 1101 static object *marker;
1107 if (!marker) 1102 if (!marker)
1157 * around. 1152 * around.
1158 */ 1153 */
1159 if (QUERY_FLAG (op, FLAG_REMOVED) && op->type != PLAYER && op->map && op->map->in_memory != MAP_IN_MEMORY) 1154 if (QUERY_FLAG (op, FLAG_REMOVED) && op->type != PLAYER && op->map && op->map->in_memory != MAP_IN_MEMORY)
1160 { 1155 {
1161 LOG (llevError, "BUG: process_events(): Removed object on list\n"); 1156 LOG (llevError, "BUG: process_events(): Removed object on list\n");
1162 dump_object (op); 1157 char *dump = dump_object (op);
1163 LOG (llevError, errmsg); 1158 LOG (llevError, dump);
1159 free (dump);
1164 free_object (op); 1160 free_object (op);
1165 continue; 1161 continue;
1166 } 1162 }
1167 1163
1168 if (!op->speed) 1164 if (!op->speed)
1238} 1234}
1239 1235
1240void 1236void
1241clean_tmp_files (void) 1237clean_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 */
1277void 1273void
1278cleanup (void) 1274cleanup (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);
1409 flush_old_maps (); /* Clears the tmp-files of maps which have reset */ 1414 flush_old_maps (); /* Clears the tmp-files of maps which have reset */
1410 1415
1411 if (!(pticks % 2503)) 1416 if (!(pticks % 2503))
1412 fix_weight (); /* Hack to fix weightproblems caused by bugs */ 1417 fix_weight (); /* Hack to fix weightproblems caused by bugs */
1413 1418
1414 if (!(pticks % 2521))
1415 metaserver_update (); /* 2500 ticks is about 5 minutes */
1416
1417 if (!(pticks % 5003)) 1419 if (!(pticks % 5003))
1418 write_book_archive (); 1420 write_book_archive ();
1419 1421
1420 if (!(pticks % 5009)) 1422 if (!(pticks % 5009))
1421 clean_friendly_list (); 1423 clean_friendly_list ();
1447main (int argc, char **argv) 1449main (int argc, char **argv)
1448{ 1450{
1449 settings.argc = argc; 1451 settings.argc = argc;
1450 settings.argv = argv; 1452 settings.argv = argv;
1451 1453
1452 cfperl_init ();
1453
1454 init (argc, argv); 1454 init (argc, argv);
1455 1455
1456 initPlugins (); 1456 initPlugins ();
1457 1457
1458 for (;;) 1458 for (;;)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines