… | |
… | |
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) |
… | |
… | |
158 | * simple case at top - no encryption - makes it easier to read. |
158 | * simple case at top - no encryption - makes it easier to read. |
159 | */ |
159 | */ |
160 | char * |
160 | char * |
161 | crypt_string (char *str, char *salt) |
161 | crypt_string (char *str, char *salt) |
162 | { |
162 | { |
163 | #if defined(WIN32) || (defined(__FreeBSD__) && !defined(HAVE_LIBDES)) |
163 | #if (defined(__FreeBSD__) && !defined(HAVE_LIBDES)) |
164 | return (str); |
164 | return (str); |
165 | #else |
165 | #else |
166 | static char *c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; |
166 | static char *c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; |
167 | char s[2]; |
167 | char s[2]; |
168 | |
168 | |
… | |
… | |
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 = object::create (); |
200 | |
200 | |
201 | EXIT_PATH (tmp) = op->contr->savebed_map; |
201 | EXIT_PATH (tmp) = op->contr->savebed_map; |
202 | EXIT_X (tmp) = op->contr->bed_x; |
202 | EXIT_X (tmp) = op->contr->bed_x; |
203 | EXIT_Y (tmp) = op->contr->bed_y; |
203 | EXIT_Y (tmp) = op->contr->bed_y; |
204 | enter_exit (op, tmp); |
204 | enter_exit (op, tmp); |
… | |
… | |
217 | EXIT_PATH (tmp) = op->contr->savebed_map; |
217 | EXIT_PATH (tmp) = op->contr->savebed_map; |
218 | EXIT_X (tmp) = op->contr->bed_x; |
218 | EXIT_X (tmp) = op->contr->bed_x; |
219 | EXIT_Y (tmp) = op->contr->bed_y; |
219 | EXIT_Y (tmp) = op->contr->bed_y; |
220 | enter_exit (op, tmp); |
220 | enter_exit (op, tmp); |
221 | } |
221 | } |
222 | free_object (tmp); |
222 | |
|
|
223 | tmp->destroy (); |
223 | } |
224 | } |
224 | |
225 | |
225 | /* All this really is is a glorified remove_object that also updates |
226 | /* All this really is is a glorified remove_object that also updates |
226 | * the counts on the map if needed. |
227 | * the counts on the map if needed. |
227 | */ |
228 | */ |
228 | void |
229 | void |
229 | leave_map (object *op) |
230 | leave_map (object *op) |
230 | { |
231 | { |
231 | mapstruct *oldmap = op->map; |
232 | maptile *oldmap = op->map; |
232 | |
233 | |
233 | remove_ob (op); |
234 | op->remove (); |
234 | |
235 | |
235 | if (oldmap) |
236 | if (oldmap) |
236 | { |
237 | { |
237 | if (!op->contr->hidden) |
238 | if (!op->contr->hidden) |
238 | oldmap->players--; |
239 | oldmap->players--; |
|
|
240 | |
239 | if (oldmap->players <= 0) |
241 | if (oldmap->players <= 0) |
240 | { /* can be less than zero due to errors in tracking this */ |
242 | /* can be less than zero due to errors in tracking this */ |
241 | set_map_timeout (oldmap); |
243 | set_map_timeout (oldmap); |
242 | } |
|
|
243 | } |
244 | } |
244 | } |
245 | } |
245 | |
246 | |
246 | /* |
247 | /* |
247 | * enter_map(): Moves the player and pets from current map (if any) to |
248 | * 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 |
250 | * 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 |
251 | * whatever reason. If default map coordinates are to be used, then |
251 | * the function that calls this should figure them out. |
252 | * the function that calls this should figure them out. |
252 | */ |
253 | */ |
253 | static void |
254 | static void |
254 | enter_map (object *op, mapstruct *newmap, int x, int y) |
255 | enter_map (object *op, maptile *newmap, int x, int y) |
255 | { |
256 | { |
256 | mapstruct *oldmap = op->map; |
257 | maptile *oldmap = op->map; |
257 | |
258 | |
258 | if (out_of_map (newmap, x, y)) |
259 | if (out_of_map (newmap, x, y)) |
259 | { |
260 | { |
260 | LOG (llevError, "enter_map: supplied coordinates are not within the map! (%s: %d, %d)\n", newmap->path, x, y); |
261 | 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); |
262 | x = MAP_ENTER_X (newmap); |
… | |
… | |
266 | newmap->path, x, y, MAP_WIDTH (newmap), MAP_HEIGHT (newmap)); |
267 | newmap->path, x, y, MAP_WIDTH (newmap), MAP_HEIGHT (newmap)); |
267 | new_draw_info (NDI_UNIQUE, 0, op, "The exit is closed"); |
268 | new_draw_info (NDI_UNIQUE, 0, op, "The exit is closed"); |
268 | return; |
269 | return; |
269 | } |
270 | } |
270 | } |
271 | } |
|
|
272 | |
271 | /* try to find a spot for the player */ |
273 | /* try to find a spot for the player */ |
272 | if (ob_blocked (op, newmap, x, y)) |
274 | if (ob_blocked (op, newmap, x, y)) |
273 | { /* First choice blocked */ |
275 | { /* First choice blocked */ |
274 | /* We try to find a spot for the player, starting closest in. |
276 | /* 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, |
277 | * We could use find_first_free_spot, but that doesn't randomize it at all, |
… | |
… | |
284 | { |
286 | { |
285 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE2 + 1); |
287 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE2 + 1); |
286 | if (i == -1) |
288 | if (i == -1) |
287 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE); |
289 | i = find_free_spot (op, newmap, x, y, 1, SIZEOFFREE); |
288 | } |
290 | } |
|
|
291 | |
289 | if (i != -1) |
292 | if (i != -1) |
290 | { |
293 | { |
291 | x += freearr_x[i]; |
294 | x += freearr_x[i]; |
292 | y += freearr_y[i]; |
295 | y += freearr_y[i]; |
293 | } |
296 | } |
… | |
… | |
296 | /* not much we can do in this case. */ |
299 | /* not much we can do in this case. */ |
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); |
300 | 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 | } |
301 | } |
299 | } /* end if looking for free spot */ |
302 | } /* end if looking for free spot */ |
300 | |
303 | |
301 | if (op->map != NULL) |
304 | if (op->map) |
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)); |
305 | if (INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr))) |
305 | } |
306 | return; |
|
|
307 | |
|
|
308 | if (INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (newmap), ARG_INT (x), ARG_INT (y))) |
|
|
309 | return; |
|
|
310 | |
|
|
311 | if (INVOKE_MAP (ENTER, newmap, ARG_PLAYER (op->contr), ARG_INT (x), ARG_INT (y))) |
|
|
312 | return; |
306 | |
313 | |
307 | /* If it is a player login, he has yet to be inserted anyplace. |
314 | /* If it is a player login, he has yet to be inserted anyplace. |
308 | * otherwise, we need to deal with removing the player here. |
315 | * otherwise, we need to deal with removing the player here. |
309 | */ |
316 | */ |
310 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
317 | op->remove (); |
311 | remove_ob (op); |
|
|
312 | |
318 | |
313 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
319 | /* remove_ob clears these so they must be reset after the remove_ob call */ |
314 | op->x = x; |
320 | op->x = x; |
315 | op->y = y; |
321 | op->y = y; |
316 | op->map = newmap; |
322 | op->map = newmap; |
|
|
323 | |
317 | insert_ob_in_map (op, op->map, NULL, INS_NO_WALK_ON); |
324 | insert_ob_in_map (op, op->map, NULL, INS_NO_WALK_ON); |
318 | |
|
|
319 | INVOKE_MAP (ENTER, op->map, ARG_PLAYER (op->contr)); |
|
|
320 | |
325 | |
321 | if (!op->contr->hidden) |
326 | if (!op->contr->hidden) |
322 | newmap->players++; |
327 | newmap->players++; |
323 | |
328 | |
324 | newmap->timeout = 0; |
329 | newmap->timeout = 0; |
… | |
… | |
334 | if (op->type == PLAYER && op->contr->ranges[range_golem] != NULL) |
339 | if (op->type == PLAYER && op->contr->ranges[range_golem] != NULL) |
335 | { |
340 | { |
336 | int i = find_free_spot (op->contr->ranges[range_golem], newmap, |
341 | int i = find_free_spot (op->contr->ranges[range_golem], newmap, |
337 | x, y, 1, SIZEOFFREE); |
342 | x, y, 1, SIZEOFFREE); |
338 | |
343 | |
339 | remove_ob (op->contr->ranges[range_golem]); |
344 | op->contr->ranges[range_golem]->remove (); |
|
|
345 | |
340 | if (i == -1) |
346 | if (i == -1) |
341 | { |
347 | { |
342 | remove_friendly_object (op->contr->ranges[range_golem]); |
348 | remove_friendly_object (op->contr->ranges[range_golem]); |
343 | free_object (op->contr->ranges[range_golem]); |
349 | op->contr->ranges[range_golem]->destroy (); |
344 | op->contr->ranges[range_golem] = NULL; |
350 | op->contr->ranges[range_golem] = 0; |
345 | 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); |
… | |
… | |
780 | #define PORTAL_DESTINATION_NAME "Town portal destination" /* this one should really be in a header file */ |
777 | #define PORTAL_DESTINATION_NAME "Town portal destination" /* this one should really be in a header file */ |
781 | object *tmp; |
778 | object *tmp; |
782 | |
779 | |
783 | /* It may be nice to support other creatures moving across |
780 | /* It may be nice to support other creatures moving across |
784 | * exits, but right now a lot of the code looks at op->contr, |
781 | * exits, but right now a lot of the code looks at op->contr, |
785 | * so thta is an RFE. |
782 | * so that is an RFE. |
786 | */ |
783 | */ |
787 | if (op->type != PLAYER) |
784 | if (op->type != PLAYER) |
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 |
… | |
… | |
897 | if (tmp->type == FORCE && tmp->slaying && !strcmp (tmp->slaying, PORTAL_DESTINATION_NAME)) |
893 | if (tmp->type == FORCE && tmp->slaying && !strcmp (tmp->slaying, PORTAL_DESTINATION_NAME)) |
898 | break; |
894 | break; |
899 | } |
895 | } |
900 | if (tmp) |
896 | if (tmp) |
901 | { |
897 | { |
902 | remove_ob (tmp); |
898 | tmp->remove (); |
903 | free_object (tmp); |
899 | tmp->destroy (); |
904 | } |
900 | } |
905 | |
901 | |
906 | strcpy (op->contr->savebed_map, path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob))); |
902 | strcpy (op->contr->savebed_map, path_combine_and_normalize (exit_ob->map->path, EXIT_PATH (exit_ob))); |
907 | op->contr->bed_x = EXIT_X (exit_ob), op->contr->bed_y = EXIT_Y (exit_ob); |
903 | op->contr->bed_x = EXIT_X (exit_ob), op->contr->bed_y = EXIT_Y (exit_ob); |
908 | save_player (op, 1); |
904 | save_player (op, 1); |
… | |
… | |
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 | |
|
|
959 | /* |
|
|
960 | * process_active_maps(): Works like process_events(), but it only |
|
|
961 | * processes maps which a player is on. |
|
|
962 | * |
|
|
963 | */ |
|
|
964 | |
|
|
965 | #if 0 // dead code, schmorp |
|
|
966 | void |
|
|
967 | process_active_maps () |
|
|
968 | { |
|
|
969 | for (mapstruct *map = first_map; map != NULL; map = map->next) |
|
|
970 | if (map->in_memory == MAP_IN_MEMORY) |
|
|
971 | if (players_on_map (map, TRUE)) |
|
|
972 | process_events (map); |
|
|
973 | } |
|
|
974 | #endif |
|
|
975 | |
954 | |
976 | /* process_players1 and process_players2 do all the player related stuff. |
955 | /* process_players1 and process_players2 do all the player related stuff. |
977 | * I moved it out of process events and process_map. This was to some |
956 | * I moved it out of process events and process_map. This was to some |
978 | * extent for debugging as well as to get a better idea of the time used |
957 | * extent for debugging as well as to get a better idea of the time used |
979 | * by the various functions. process_players1() does the processing before |
958 | * by the various functions. process_players1() does the processing before |
980 | * objects have been updated, process_players2() does the processing that |
959 | * objects have been updated, process_players2() does the processing that |
981 | * is needed after the players have been updated. |
960 | * is needed after the players have been updated. |
982 | */ |
961 | */ |
983 | |
962 | static void |
984 | void |
963 | process_players1 () |
985 | process_players1 (mapstruct *map) |
|
|
986 | { |
964 | { |
987 | int flag; |
965 | int flag; |
988 | player *pl, *plnext; |
|
|
989 | |
|
|
990 | /* Basically, we keep looping until all the players have done their actions. */ |
966 | /* Basically, we keep looping until all the players have done their actions. */ |
991 | for (flag = 1; flag != 0;) |
967 | for (flag = 1; flag != 0;) |
992 | { |
968 | { |
993 | flag = 0; |
969 | flag = 0; |
994 | for (pl = first_player; pl != NULL; pl = plnext) |
970 | for (player *plnext, *pl = first_player; pl; pl = plnext) |
995 | { |
971 | { |
996 | plnext = pl->next; /* In case a player exits the game in handle_player() */ |
972 | plnext = pl->next; /* In case a player exits the game in handle_player() */ |
997 | |
973 | |
998 | if (pl->ob == NULL) |
974 | if (!pl->ob) |
999 | continue; |
|
|
1000 | |
|
|
1001 | if (map != NULL && pl->ob->map != map) |
|
|
1002 | continue; |
975 | continue; |
1003 | |
976 | |
1004 | if (pl->ob->speed_left > 0) |
977 | if (pl->ob->speed_left > 0) |
1005 | { |
978 | { |
1006 | if (handle_newcs_player (pl->ob)) |
979 | if (handle_newcs_player (pl->ob)) |
… | |
… | |
1020 | /* check for ST_PLAYING state so that we don't try to save off when |
993 | /* check for ST_PLAYING state so that we don't try to save off when |
1021 | * the player is logging in. |
994 | * the player is logging in. |
1022 | */ |
995 | */ |
1023 | if ((pl->last_save_tick + AUTOSAVE) < (uint32) pticks && pl->state == ST_PLAYING) |
996 | if ((pl->last_save_tick + AUTOSAVE) < (uint32) pticks && pl->state == ST_PLAYING) |
1024 | { |
997 | { |
1025 | /* Don't save the player on unholy ground. Instead, increase the |
|
|
1026 | * tick time so it will be about 10 seconds before we try and save |
|
|
1027 | * again. |
|
|
1028 | */ |
|
|
1029 | // if (get_map_flags(pl->ob->map, NULL, pl->ob->x, pl->ob->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1030 | // pl->last_save_tick += 100; |
|
|
1031 | // } else { |
|
|
1032 | save_player (pl->ob, 1); |
998 | save_player (pl->ob, 1); |
1033 | pl->last_save_tick = pticks; |
999 | pl->last_save_tick = pticks; |
1034 | // } |
|
|
1035 | } |
1000 | } |
1036 | #endif |
1001 | #endif |
1037 | } /* end of for loop for all the players */ |
1002 | } /* end of for loop for all the players */ |
1038 | } /* for flag */ |
1003 | } /* for flag */ |
|
|
1004 | |
1039 | for (pl = first_player; pl != NULL; pl = pl->next) |
1005 | for (player *pl = first_player; pl; pl = pl->next) |
1040 | { |
1006 | { |
1041 | if (map != NULL && (pl->ob == NULL || pl->ob->map != map)) |
|
|
1042 | continue; |
|
|
1043 | if (settings.casting_time == TRUE) |
1007 | if (settings.casting_time) |
1044 | { |
1008 | { |
1045 | if (pl->ob->casting_time > 0) |
1009 | if (pl->ob->casting_time > 0) |
1046 | { |
1010 | { |
1047 | pl->ob->casting_time--; |
1011 | pl->ob->casting_time--; |
1048 | pl->ob->start_holding = 1; |
1012 | pl->ob->start_holding = 1; |
1049 | } |
1013 | } |
|
|
1014 | |
1050 | /* set spell_state so we can update the range in stats field */ |
1015 | /* set spell_state so we can update the range in stats field */ |
1051 | if ((pl->ob->casting_time == 0) && (pl->ob->start_holding == 1)) |
1016 | if ((pl->ob->casting_time == 0) && (pl->ob->start_holding == 1)) |
1052 | { |
|
|
1053 | pl->ob->start_holding = 0; |
1017 | pl->ob->start_holding = 0; |
1054 | } |
1018 | } |
1055 | } |
1019 | |
1056 | do_some_living (pl->ob); |
1020 | do_some_living (pl->ob); |
1057 | /* draw(pl->ob); *//* updated in socket code */ |
|
|
1058 | } |
1021 | } |
1059 | } |
1022 | } |
1060 | |
1023 | |
1061 | void |
1024 | static void |
1062 | process_players2 (mapstruct *map) |
1025 | process_players2 () |
1063 | { |
1026 | { |
1064 | player *pl; |
|
|
1065 | |
|
|
1066 | /* Then check if any players should use weapon-speed instead of speed */ |
1027 | /* Then check if any players should use weapon-speed instead of speed */ |
1067 | for (pl = first_player; pl != NULL; pl = pl->next) |
1028 | for (player *pl = first_player; pl; pl = pl->next) |
1068 | { |
1029 | { |
1069 | if (map != NULL) |
|
|
1070 | { |
|
|
1071 | if (pl->ob == NULL || QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
1072 | continue; |
|
|
1073 | else if (pl->loading != NULL) /* Player is blocked */ |
|
|
1074 | pl->ob->speed_left -= pl->ob->speed; |
|
|
1075 | if (pl->ob->map != map) |
|
|
1076 | continue; |
|
|
1077 | } |
|
|
1078 | |
|
|
1079 | /* The code that did weapon_sp handling here was out of place - |
1030 | /* The code that did weapon_sp handling here was out of place - |
1080 | * this isn't called until after the player has finished there |
1031 | * this isn't called until after the player has finished there |
1081 | * actions, and is thus out of place. All we do here is bounds |
1032 | * actions, and is thus out of place. All we do here is bounds |
1082 | * checking. |
1033 | * checking. |
1083 | */ |
1034 | */ |
… | |
… | |
1089 | /* This needs to be here - if the player is running, we need to |
1040 | /* This needs to be here - if the player is running, we need to |
1090 | * clear this each tick, but new commands are not being received |
1041 | * clear this each tick, but new commands are not being received |
1091 | * so execute_newserver_command() is never called |
1042 | * so execute_newserver_command() is never called |
1092 | */ |
1043 | */ |
1093 | pl->has_hit = 0; |
1044 | pl->has_hit = 0; |
1094 | |
|
|
1095 | } |
1045 | } |
1096 | else if (pl->ob->speed_left > pl->ob->speed) |
1046 | else if (pl->ob->speed_left > pl->ob->speed) |
1097 | pl->ob->speed_left = pl->ob->speed; |
1047 | pl->ob->speed_left = pl->ob->speed; |
1098 | } |
1048 | } |
1099 | } |
1049 | } |
1100 | |
1050 | |
1101 | void |
1051 | void |
1102 | process_events (mapstruct *map) |
1052 | process_events () |
1103 | { |
1053 | { |
1104 | object *op; |
1054 | object *op; |
1105 | tag_t tag; |
|
|
1106 | |
1055 | |
1107 | static object *marker; |
1056 | static object *marker; |
1108 | |
1057 | |
1109 | if (!marker) |
1058 | if (!marker) |
1110 | marker = get_object (); |
1059 | marker = object::create (); |
1111 | |
1060 | |
1112 | process_players1 (map); |
1061 | process_players1 (); |
1113 | |
1062 | |
1114 | marker->active_next = active_objects; |
1063 | marker->active_next = active_objects; |
1115 | |
1064 | |
1116 | if (marker->active_next) |
1065 | if (marker->active_next) |
1117 | marker->active_next->active_prev = marker; |
1066 | marker->active_next->active_prev = marker; |
… | |
… | |
1120 | active_objects = marker; |
1069 | active_objects = marker; |
1121 | |
1070 | |
1122 | while (marker->active_next) |
1071 | while (marker->active_next) |
1123 | { |
1072 | { |
1124 | op = marker->active_next; |
1073 | op = marker->active_next; |
1125 | tag = op->count; |
|
|
1126 | |
1074 | |
1127 | /* Move marker forward - swap op and marker */ |
1075 | /* Move marker forward - swap op and marker */ |
1128 | op->active_prev = marker->active_prev; |
1076 | op->active_prev = marker->active_prev; |
1129 | |
1077 | |
1130 | if (op->active_prev) |
1078 | if (op->active_prev) |
… | |
… | |
1160 | * around. |
1108 | * around. |
1161 | */ |
1109 | */ |
1162 | if (QUERY_FLAG (op, FLAG_REMOVED) && op->type != PLAYER && op->map && op->map->in_memory != MAP_IN_MEMORY) |
1110 | if (QUERY_FLAG (op, FLAG_REMOVED) && op->type != PLAYER && op->map && op->map->in_memory != MAP_IN_MEMORY) |
1163 | { |
1111 | { |
1164 | LOG (llevError, "BUG: process_events(): Removed object on list\n"); |
1112 | LOG (llevError, "BUG: process_events(): Removed object on list\n"); |
1165 | dump_object (op); |
1113 | char *dump = dump_object (op); |
1166 | LOG (llevError, errmsg); |
1114 | LOG (llevError, dump); |
1167 | free_object (op); |
1115 | free (dump); |
|
|
1116 | op->destroy (); |
1168 | continue; |
1117 | continue; |
1169 | } |
1118 | } |
1170 | |
1119 | |
1171 | if (!op->speed) |
1120 | if (!op->speed) |
1172 | { |
1121 | { |
1173 | LOG (llevError, "BUG: process_events(): Object %s has no speed, " "but is on active list\n", &op->arch->name); |
1122 | LOG (llevError, "BUG: process_events(): Object %s has no speed, " |
|
|
1123 | "but is on active list\n", &op->arch->name); |
1174 | update_ob_speed (op); |
1124 | update_ob_speed (op); |
1175 | continue; |
1125 | continue; |
1176 | } |
1126 | } |
1177 | |
1127 | |
1178 | if (op->map == NULL && op->env == NULL && op->name && op->type != MAP && map == NULL) |
1128 | if (op->map == NULL && op->env == NULL && op->name && op->type != MAP) |
1179 | { |
1129 | { |
1180 | LOG (llevError, "BUG: process_events(): Object without map or " "inventory is on active list: %s (%d)\n", &op->name, op->count); |
1130 | LOG (llevError, "BUG: process_events(): Object without map or " |
|
|
1131 | "inventory is on active list: %s (%d)\n", &op->name, op->count); |
1181 | op->speed = 0; |
1132 | op->speed = 0; |
1182 | update_ob_speed (op); |
1133 | update_ob_speed (op); |
1183 | continue; |
1134 | continue; |
1184 | } |
1135 | } |
1185 | |
1136 | |
1186 | if (map != NULL && op->map != map) |
|
|
1187 | continue; |
|
|
1188 | |
|
|
1189 | /* Animate the object. Bug of feature that andim_speed |
1137 | /* Animate the object. Bug or feature that anim_speed |
1190 | * is based on ticks, and not the creatures speed? |
1138 | * is based on ticks, and not the creatures speed? |
1191 | */ |
1139 | */ |
1192 | if (op->anim_speed && op->last_anim >= op->anim_speed) |
1140 | if (op->anim_speed && op->last_anim >= op->anim_speed) |
1193 | { |
1141 | { |
1194 | if ((op->type == PLAYER) || (op->type == MONSTER)) |
1142 | if ((op->type == PLAYER) || (op->type == MONSTER)) |
… | |
… | |
1217 | LOG (llevDebug, "process_events: calling process_object with removed object %s\n", op->name ? op->name : "null"); |
1165 | LOG (llevDebug, "process_events: calling process_object with removed object %s\n", op->name ? op->name : "null"); |
1218 | } |
1166 | } |
1219 | #endif |
1167 | #endif |
1220 | --op->speed_left; |
1168 | --op->speed_left; |
1221 | process_object (op); |
1169 | process_object (op); |
|
|
1170 | |
1222 | if (was_destroyed (op, tag)) |
1171 | if (op->destroyed ()) |
1223 | continue; |
1172 | continue; |
1224 | } |
1173 | } |
|
|
1174 | |
1225 | if (settings.casting_time == TRUE && op->casting_time > 0) |
1175 | if (settings.casting_time == TRUE && op->casting_time > 0) |
1226 | op->casting_time--; |
1176 | op->casting_time--; |
|
|
1177 | |
1227 | if (op->speed_left <= 0) |
1178 | if (op->speed_left <= 0) |
1228 | op->speed_left += FABS (op->speed); |
1179 | op->speed_left += FABS (op->speed); |
1229 | } |
1180 | } |
1230 | |
1181 | |
1231 | /* Remove marker object from active list */ |
1182 | /* Remove marker object from active list */ |
1232 | if (marker->active_prev != NULL) |
1183 | if (marker->active_prev != NULL) |
1233 | marker->active_prev->active_next = NULL; |
1184 | marker->active_prev->active_next = NULL; |
1234 | else |
1185 | else |
1235 | active_objects = NULL; |
1186 | active_objects = NULL; |
1236 | |
1187 | |
1237 | process_players2 (map); |
1188 | process_players2 (); |
1238 | } |
1189 | } |
1239 | |
1190 | |
1240 | void |
1191 | void |
1241 | clean_tmp_files (void) |
1192 | clean_tmp_files (void) |
1242 | { |
1193 | { |
1243 | mapstruct *m, *next; |
1194 | maptile *m, *next; |
1244 | |
1195 | |
1245 | LOG (llevInfo, "Cleaning up...\n"); |
1196 | LOG (llevInfo, "Cleaning up...\n"); |
1246 | |
1197 | |
1247 | /* We save the maps - it may not be intuitive why, but if there are unique |
1198 | /* 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 |
1199 | * items, we need to save the map so they get saved off. Perhaps we should |
… | |
… | |
1276 | /* clean up everything before exiting */ |
1227 | /* clean up everything before exiting */ |
1277 | void |
1228 | void |
1278 | cleanup (void) |
1229 | cleanup (void) |
1279 | { |
1230 | { |
1280 | LOG (llevDebug, "Cleanup called.\n"); |
1231 | LOG (llevDebug, "Cleanup called.\n"); |
|
|
1232 | |
|
|
1233 | for (player *pl = first_player; pl != NULL; pl = pl->next) |
|
|
1234 | save_player (pl->ob, 0); |
|
|
1235 | |
|
|
1236 | for (player *pl = first_player; pl != NULL; pl = pl->next) |
|
|
1237 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
1238 | leave_map (pl->ob); |
|
|
1239 | |
|
|
1240 | clean_tmp_files (); |
1281 | write_book_archive (); |
1241 | write_book_archive (); |
1282 | |
1242 | |
1283 | INVOKE_GLOBAL (CLEANUP); |
1243 | INVOKE_GLOBAL (CLEANUP); |
1284 | |
1244 | |
1285 | _exit (0); |
1245 | _exit (0); |
… | |
… | |
1294 | * cleanup. We also leave that loop to actually handle the freeing |
1254 | * cleanup. We also leave that loop to actually handle the freeing |
1295 | * of the data. |
1255 | * of the data. |
1296 | */ |
1256 | */ |
1297 | if (pl->ob->type != DEAD_OBJECT) |
1257 | if (pl->ob->type != DEAD_OBJECT) |
1298 | { |
1258 | { |
1299 | pl->socket.status = Ns_Dead; |
1259 | pl->socket->status = Ns_Dead; |
1300 | |
1260 | |
1301 | /* If a hidden dm dropped connection do not create |
1261 | /* If a hidden dm dropped connection do not create |
1302 | * inconsistencies by showing that they have left the game |
1262 | * inconsistencies by showing that they have left the game |
1303 | */ |
1263 | */ |
1304 | if (!(QUERY_FLAG (pl->ob, FLAG_WIZ) && pl->ob->contr->hidden) |
1264 | if (!(QUERY_FLAG (pl->ob, FLAG_WIZ) && pl->ob->contr->hidden) |
1305 | && draw_exit && (pl->state != ST_GET_NAME && pl->state != ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) |
1265 | && draw_exit && (pl->state != ST_GET_NAME && pl->state != ST_GET_PASSWORD && pl->state != ST_CONFIRM_PASSWORD)) |
1306 | { |
1266 | { |
1307 | if (pl->ob->map) |
1267 | if (pl->ob->map) |
1308 | { |
1268 | { |
1309 | INVOKE_PLAYER (LOGOUT, pl); |
1269 | INVOKE_PLAYER (LOGOUT, pl); |
1310 | LOG (llevInfo, "LOGOUT: Player named %s from ip %s\n", &pl->ob->name, pl->socket.host); |
1270 | LOG (llevInfo, "LOGOUT: Player named %s from ip %s\n", &pl->ob->name, pl->socket->host); |
1311 | } |
1271 | } |
1312 | |
1272 | |
1313 | char buf[MAX_BUF]; |
1273 | char buf[MAX_BUF]; |
1314 | |
1274 | |
1315 | sprintf (buf, "%s left the game.", &pl->ob->name); |
1275 | sprintf (buf, "%s left the game.", &pl->ob->name); |
… | |
… | |
1391 | extern unsigned long todtick; |
1351 | extern unsigned long todtick; |
1392 | |
1352 | |
1393 | void |
1353 | void |
1394 | do_specials (void) |
1354 | do_specials (void) |
1395 | { |
1355 | { |
1396 | |
|
|
1397 | #ifdef WATCHDOG |
|
|
1398 | if (!(pticks % 503)) |
|
|
1399 | watchdog (); |
|
|
1400 | #endif |
|
|
1401 | |
|
|
1402 | if (!(pticks % PTICKS_PER_CLOCK)) |
1356 | if (!(pticks % PTICKS_PER_CLOCK)) |
1403 | tick_the_clock (); |
1357 | tick_the_clock (); |
1404 | |
1358 | |
1405 | if (!(pticks % 7)) |
1359 | if (!(pticks % 7)) |
1406 | shstr::gc (); |
1360 | shstr::gc (); |
… | |
… | |
1409 | flush_old_maps (); /* Clears the tmp-files of maps which have reset */ |
1363 | flush_old_maps (); /* Clears the tmp-files of maps which have reset */ |
1410 | |
1364 | |
1411 | if (!(pticks % 2503)) |
1365 | if (!(pticks % 2503)) |
1412 | fix_weight (); /* Hack to fix weightproblems caused by bugs */ |
1366 | fix_weight (); /* Hack to fix weightproblems caused by bugs */ |
1413 | |
1367 | |
1414 | if (!(pticks % 2521)) |
|
|
1415 | metaserver_update (); /* 2500 ticks is about 5 minutes */ |
|
|
1416 | |
|
|
1417 | if (!(pticks % 5003)) |
1368 | if (!(pticks % 5003)) |
1418 | write_book_archive (); |
1369 | write_book_archive (); |
1419 | |
1370 | |
1420 | if (!(pticks % 5009)) |
1371 | if (!(pticks % 5009)) |
1421 | clean_friendly_list (); |
1372 | clean_friendly_list (); |
… | |
… | |
1430 | void |
1381 | void |
1431 | server_tick () |
1382 | server_tick () |
1432 | { |
1383 | { |
1433 | nroferrors = 0; |
1384 | nroferrors = 0; |
1434 | |
1385 | |
|
|
1386 | // first do the user visible stuff |
1435 | doeric_server (); |
1387 | doeric_server (); |
1436 | INVOKE_GLOBAL (CLOCK); |
1388 | INVOKE_GLOBAL (CLOCK); |
1437 | process_events (NULL); /* "do" something with objects with speed */ |
1389 | process_events (); /* "do" something with objects with speed */ |
1438 | flush_sockets (); |
1390 | flush_sockets (); |
|
|
1391 | |
|
|
1392 | // then do some bookkeeping, should not really be here |
1439 | check_active_maps (); /* Removes unused maps after a certain timeout */ |
1393 | check_active_maps (); /* Removes unused maps after a certain timeout */ |
1440 | do_specials (); /* Routines called from time to time. */ |
1394 | do_specials (); /* Routines called from time to time. */ |
1441 | object::free_mortals (); |
1395 | object::free_mortals (); |
1442 | |
1396 | |
1443 | ++pticks; |
1397 | ++pticks; |
… | |
… | |
1447 | main (int argc, char **argv) |
1401 | main (int argc, char **argv) |
1448 | { |
1402 | { |
1449 | settings.argc = argc; |
1403 | settings.argc = argc; |
1450 | settings.argv = argv; |
1404 | settings.argv = argv; |
1451 | |
1405 | |
1452 | cfperl_init (); |
|
|
1453 | |
|
|
1454 | init (argc, argv); |
1406 | init (argc, argv); |
1455 | |
1407 | |
1456 | initPlugins (); |
1408 | initPlugins (); |
1457 | |
1409 | |
1458 | for (;;) |
1410 | for (;;) |