… | |
… | |
147 | |
147 | |
148 | // remove, so stupid ob_locked does not trigger a failure |
148 | // remove, so stupid ob_locked does not trigger a failure |
149 | remove (); |
149 | remove (); |
150 | |
150 | |
151 | /* try to find a spot for the player */ |
151 | /* try to find a spot for the player */ |
152 | if (ob_blocked (this, newmap, x, y)) |
152 | if (blocked (newmap, x, y)) |
153 | { /* First choice blocked */ |
153 | { /* First choice blocked */ |
154 | /* We try to find a spot for the player, starting closest in. |
154 | /* We try to find a spot for the player, starting closest in. |
155 | * We could use find_first_free_spot, but that doesn't randomize it at all, |
155 | * We could use find_first_free_spot, but that doesn't randomize it at all, |
156 | * So for example, if the north space is free, you would always end up there even |
156 | * So for example, if the north space is free, you would always end up there even |
157 | * if other spaces around are available. |
157 | * if other spaces around are available. |
… | |
… | |
393 | cfperl_cleanup (make_core); |
393 | cfperl_cleanup (make_core); |
394 | _exit (1); |
394 | _exit (1); |
395 | } |
395 | } |
396 | else |
396 | else |
397 | { |
397 | { |
398 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "Maps and players successfully saved, exiting."); |
398 | new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "Maps and players successfully saved, exiting."); |
399 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "And again: " CLEANUP_MESSAGE); |
399 | new_draw_info_format (NDI_REPLY | NDI_UNIQUE | NDI_ALL | NDI_GREEN, 0, 0, "And again: " CLEANUP_MESSAGE); |
400 | client::flush_sockets (); |
400 | client::flush_sockets (); |
401 | cfperl_cleanup (make_core); |
401 | cfperl_cleanup (make_core); |
402 | _exit (0); |
402 | _exit (0); |
403 | } |
403 | } |
404 | } |
|
|
405 | |
|
|
406 | int |
|
|
407 | forbid_play (void) |
|
|
408 | { |
|
|
409 | #if !defined(_IBMR2) && !defined(___IBMR2) && defined(PERM_FILE) |
|
|
410 | char buf[MAX_BUF], day[MAX_BUF]; |
|
|
411 | FILE *fp; |
|
|
412 | time_t clock; |
|
|
413 | struct tm *tm; |
|
|
414 | int i, start, stop, forbit = 0, comp; |
|
|
415 | |
|
|
416 | clock = time (NULL); |
|
|
417 | tm = (struct tm *) localtime (&clock); |
|
|
418 | |
|
|
419 | sprintf (buf, "%s/%s", settings.confdir, PERM_FILE); |
|
|
420 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
|
|
421 | return 0; |
|
|
422 | |
|
|
423 | while (fgets (buf, MAX_BUF, fp)) |
|
|
424 | { |
|
|
425 | if (buf[0] == '#') |
|
|
426 | continue; |
|
|
427 | |
|
|
428 | if (!strncmp (buf, "msg", 3)) |
|
|
429 | { |
|
|
430 | if (forbit) |
|
|
431 | while (fgets (buf, MAX_BUF, fp)) /* print message */ |
|
|
432 | fputs (buf, logfile); |
|
|
433 | break; |
|
|
434 | } |
|
|
435 | else if (sscanf (buf, "%s %d%*c%d\n", day, &start, &stop) != 3) |
|
|
436 | { |
|
|
437 | LOG (llevDebug, "Warning: Incomplete line in permission file ignored.\n"); |
|
|
438 | continue; |
|
|
439 | } |
|
|
440 | |
|
|
441 | for (i = 0; i < 7; i++) |
|
|
442 | { |
|
|
443 | if (!strncmp (buf, days[i], 3) && (tm->tm_wday == i) && (tm->tm_hour >= start) && (tm->tm_hour < stop)) |
|
|
444 | forbit = 1; |
|
|
445 | } |
|
|
446 | } |
|
|
447 | |
|
|
448 | close_and_delete (fp, comp); |
|
|
449 | |
|
|
450 | return forbit; |
|
|
451 | #else |
|
|
452 | return 0; |
|
|
453 | #endif |
|
|
454 | } |
404 | } |
455 | |
405 | |
456 | /* |
406 | /* |
457 | * do_specials() is a collection of functions to call from time to time. |
407 | * do_specials() is a collection of functions to call from time to time. |
458 | * Modified 2000-1-14 MSW to use the global pticks count to determine how |
408 | * Modified 2000-1-14 MSW to use the global pticks count to determine how |
… | |
… | |
568 | for (;;) |
518 | for (;;) |
569 | cfperl_main (); |
519 | cfperl_main (); |
570 | } |
520 | } |
571 | #endif |
521 | #endif |
572 | |
522 | |
|
|
523 | #if 0 |
|
|
524 | int xyzzy () |
|
|
525 | { |
|
|
526 | return rndm(8); |
|
|
527 | } |
|
|
528 | |
|
|
529 | void xyzzy (object_ptr &a, object_ptr &o) |
|
|
530 | { |
|
|
531 | asm volatile ("int3"); |
|
|
532 | a = o; |
|
|
533 | asm volatile ("int3"); |
|
|
534 | } |
|
|
535 | #endif |
|
|
536 | |