nakedmud-mod/
nakedmud-mod/html/tutorials/
nakedmud-mod/html/tutorials/building_extras/
nakedmud-mod/html/tutorials/c/
nakedmud-mod/html/tutorials/reference/
nakedmud-mod/html/tutorials/scripting/
nakedmud-mod/html/tutorials/scripting_extras/
nakedmud-mod/lib/
nakedmud-mod/lib/help/A/
nakedmud-mod/lib/help/B/
nakedmud-mod/lib/help/C/
nakedmud-mod/lib/help/D/
nakedmud-mod/lib/help/G/
nakedmud-mod/lib/help/H/
nakedmud-mod/lib/help/J/
nakedmud-mod/lib/help/L/
nakedmud-mod/lib/help/M/
nakedmud-mod/lib/help/O/
nakedmud-mod/lib/help/P/
nakedmud-mod/lib/help/R/
nakedmud-mod/lib/help/S/
nakedmud-mod/lib/help/W/
nakedmud-mod/lib/logs/
nakedmud-mod/lib/misc/
nakedmud-mod/lib/players/
nakedmud-mod/lib/pymodules/polc/
nakedmud-mod/lib/txt/
nakedmud-mod/lib/world/
nakedmud-mod/lib/world/zones/examples/
nakedmud-mod/lib/world/zones/examples/mproto/
nakedmud-mod/lib/world/zones/examples/oproto/
nakedmud-mod/lib/world/zones/examples/reset/
nakedmud-mod/lib/world/zones/examples/rproto/
nakedmud-mod/lib/world/zones/examples/trigger/
nakedmud-mod/lib/world/zones/limbo/
nakedmud-mod/lib/world/zones/limbo/room/
nakedmud-mod/lib/world/zones/limbo/rproto/
nakedmud-mod/src/alias/
nakedmud-mod/src/dyn_vars/
nakedmud-mod/src/editor/
nakedmud-mod/src/example_module/
nakedmud-mod/src/help2/
nakedmud-mod/src/set_val/
nakedmud-mod/src/socials/
nakedmud-mod/src/time/
//*****************************************************************************
//
// mud.c
//
// a bunch of variables and settings associated with the functioning, limits,
// and such of the MUD.
//
//*****************************************************************************

#include "mud.h"
#include "utils.h"
#include "storage.h"


//*****************************************************************************
// local defines, variables, and datastructures
//*****************************************************************************

//
// the file where we store all of our mud settings
#define MUD_DATA       "../lib/muddata"

//
// our storage set of mud settings
STORAGE_SET *settings = NULL;

//
// for generating unique IDs to characters, rooms, objects, exits, etc
int next_available_uid = START_UID;
int next_uid(void) {
  return next_available_uid++;
}

int top_uid(void) {
  if(next_available_uid == START_UID)
    return NOTHING;
  return next_available_uid - 1;
}



//*****************************************************************************
// implementation of functions in mud.h
//*****************************************************************************
void init_mud_settings() {
  settings = storage_read(MUD_DATA);

  // make sure we have initial values for some stuff
  if(!*mudsettingGetString("start_room"))
    mudsettingSetString("start_room", DFLT_START_ROOM);
  if(mudsettingGetInt("pulses_per_second") == 0)
    mudsettingSetInt("pulses_per_second", DFLT_PULSES_PER_SECOND);
}

void mudsettingSetString(const char *key, const char *val) {
  store_string(settings,  key, val);
  storage_write(settings, MUD_DATA);  
}

void mudsettingSetDouble(const char *key, double val) {
  store_double(settings, key, val);
  storage_write(settings, MUD_DATA);
}

void mudsettingSetInt(const char *key, int val) {
  store_int(settings, key, val);
  storage_write(settings, MUD_DATA);
}

void mudsettingSetLong(const char *key, long val) {
  store_long(settings, key, val);
  storage_write(settings, MUD_DATA);
}

void mudsettingSetBool(const char *key, bool val) {
  store_bool(settings, key, val);
  storage_write(settings, MUD_DATA);
}

const char *mudsettingGetString(const char *key) {
  return read_string(settings, key);
}

double mudsettingGetDouble(const char *key) {
  return read_double(settings, key);
}

int mudsettingGetInt(const char *key) {
  return read_int(settings, key);
}

long mudsettingGetLong(const char *key) {
  return read_long(settings, key);
}

bool mudsettingGetBool(const char *key) {
  return read_bool(settings, key);
}