#include <stdio.h> #include <time.h> #include <string.h> #include <sys/file.h> #include <sys/fcntl.h> #include "credits.h" #include "db.h" #include "config.h" #include "externs.h" #include "mail.h" extern time_t maze_up_time; extern time_t since_reboot; extern time_t next_dump; extern int num_reboots; extern int num_crashes; extern int con_since_boot; extern int con_since_reboot; extern time_t muse_reboot_time; extern time_t next_dbck; extern char dumpfile[200]; extern int epoch; char *get_version() { char buf[1024], end = '\0'; #ifdef ALPHA end = 'a'; #else #ifdef BETA end = 'b'; #else #ifdef FINAL end = 'f'; #endif #endif #endif sprintf(buf, "%s%d.%d%c", BASE_VERSION, MAJOR_VERSION, MINOR_VERSION, end); return(stack_string_alloc(buf, 0)); } void do_version(OBJ *player) { notify(player, tprintf("|W+|%s Version Information:", config.maze_name)); notify(player, tprintf(" |+B|Code Release Date|+W|: |+C|%s", RELEASE_DATE)); notify(player, tprintf(" |+B|Last Code Upgrade|+W|: |+C|%s", UPGRADE_DATE)); notify(player, tprintf(" |+B|Version reference|+W|: |+C|%s", get_version())); notify(player, " |+B|Softcode Version |+W|: |+C|MAZIC v1.0a"); notify(player, tprintf(" |+B|DB Format Version|+W|: |+C|MAZEv2-%d", DB_VERSION)); } char *format_time(time_t t) { int weeks, days, hours, minutes, seconds; char buf[1024]; weeks = t/604800; days = (t/86400)%7; hours = (t/3600)%24; minutes = (t/60)%60; seconds = t%60; strcpy(buf, ""); if(weeks) strcat(buf, tprintf("%dw, ", weeks)); if(days) strcat(buf, tprintf("%dd, ", days)); if(hours) strcat(buf, tprintf("%dh, ", hours)); if(minutes) strcat(buf, tprintf("%dm, ", minutes)); strcat(buf, tprintf("%ds", seconds)); return(stack_string_alloc(buf, 0)); } void do_uptime(OBJ *player) { notify(player, tprintf("|+W|%s Runtime Stats:", config.maze_name)); notify(player, tprintf("\t|+B|Current Time|+W|..: |+C|%s", mktm(now, "D", player))); notify(player, tprintf("\t|+B|MAZE Boot Time|+W|: |+C|%s", mktm(maze_up_time, "D", player))); if(num_reboots) notify(player, tprintf("\t|+B|Last Reboot at|+W|: |+C|%s", mktm(since_reboot, "D", player))); notify(player, tprintf("\n\t|+B|MAZE Online For|+W|..: |+C|%s", format_time(now-maze_up_time))); if(num_reboots) { notify(player, tprintf("\t|+B|Since Last Reboot|+W|: |+C|%s", format_time(now-since_reboot))); notify(player, tprintf("\t|+B|Number of Reboots|+W|: |+C|%d", num_reboots)); } if(num_crashes) notify(player, tprintf("\t|+B|Number of Crashes|+W|: |+C|%d", num_crashes)); notify(player, tprintf("\n\t|+B|Next DBCK at|+W|..........: |+C|%s (%s)", mktm(next_dbck, "D", player), time_format(next_dbck-now, 1))); if(config.max_mail_age) notify(player, tprintf("\t|+B|Next Old Mail Clear at|+W|: |+C|%s (%s)", mktm(next_mail_clear, "D", player), time_format(next_mail_clear-now, 1))); notify(player, tprintf("\t|+B|Next Database @dump at|+W|: |+C|%s (%s)", mktm(next_dump, "D", player), time_format(next_dump-now, 1))); notify(player, tprintf("\t|+B|Next DB Save Name|+W|.....: |+C|%s.#%d#", dumpfile, epoch+1)); notify(player, tprintf("\n\t|+B|Connections Since Boot|+W|..: |+C|%d", con_since_boot)); if(num_reboots) notify(player, tprintf("\t|+B|Connections Since Reboot|+W|: |+C|%d", con_since_reboot)); } void do_evaluate(OBJ *player, char *exp) { char buf[4096], buf2[4096]; char *p; strcpy(buf2, exp); if(!(p = is_math(buf2))) { notify(player, "Illegal expression!"); return; } *p = '\0'; if(parse_statement(buf2, buf)) { notify(player, "Bad expression."); return; } notify(player, tprintf("%s = %s", exp, buf)); }