nakedmudv3.6/
nakedmudv3.6/lib/
nakedmudv3.6/lib/help/A/
nakedmudv3.6/lib/help/B/
nakedmudv3.6/lib/help/C/
nakedmudv3.6/lib/help/D/
nakedmudv3.6/lib/help/G/
nakedmudv3.6/lib/help/H/
nakedmudv3.6/lib/help/J/
nakedmudv3.6/lib/help/L/
nakedmudv3.6/lib/help/M/
nakedmudv3.6/lib/help/O/
nakedmudv3.6/lib/help/P/
nakedmudv3.6/lib/help/R/
nakedmudv3.6/lib/help/S/
nakedmudv3.6/lib/help/W/
nakedmudv3.6/lib/logs/
nakedmudv3.6/lib/misc/
nakedmudv3.6/lib/players/
nakedmudv3.6/lib/txt/
nakedmudv3.6/lib/world/
nakedmudv3.6/lib/world/examples/
nakedmudv3.6/lib/world/examples/mproto/
nakedmudv3.6/lib/world/examples/oproto/
nakedmudv3.6/lib/world/examples/reset/
nakedmudv3.6/lib/world/examples/rproto/
nakedmudv3.6/lib/world/examples/trigger/
nakedmudv3.6/lib/world/limbo/
nakedmudv3.6/lib/world/limbo/room/
nakedmudv3.6/lib/world/limbo/rproto/
nakedmudv3.6/src/alias/
nakedmudv3.6/src/dyn_vars/
nakedmudv3.6/src/editor/
nakedmudv3.6/src/example_module/
nakedmudv3.6/src/help2/
nakedmudv3.6/src/set_val/
nakedmudv3.6/src/socials/
nakedmudv3.6/src/time/
//*****************************************************************************
//
// numbers.c
//
// This provides a wrapper around integers, doubles, and longs so we can pass
// them around as pointers.
//
//*****************************************************************************

#include "mud.h"
#include "numbers.h"



//*****************************************************************************
// integers
//*****************************************************************************
struct int_struct {
  int val;
};

INTEGER *newInteger(int val) {
  INTEGER *integer = malloc(sizeof(INTEGER));
  integer->val = val;
  return integer;
}

void deleteInteger(INTEGER *integer) {
  free(integer);
}

int integerGetVal(INTEGER *integer) {
  return integer->val;
}

void integerSetVal(INTEGER *integer, int val) {
  integer->val = val;
}

int integerCmp(INTEGER *int1, INTEGER *int2) {
  if(int1->val == int2->val)
    return 0;
  else if(int1->val > int2->val)
    return 1;
  else
    return -1;
}



//*****************************************************************************
// doubles
//*****************************************************************************
struct double_struct {
  double val;
};

DOUBLE *newDouble(double val) {
  DOUBLE *dbl = malloc(sizeof(DOUBLE));
  dbl->val = val;
  return dbl;
}

void deleteDouble(DOUBLE *dbl) {
  free(dbl);
}

double doubleGetVal(DOUBLE *dbl) {
  return dbl->val;
}

void doubleSetVal(DOUBLE *dbl, double val) {
  dbl->val = val;
}

int doubleCmp(DOUBLE *dbl1, DOUBLE *dbl2) {
  if(dbl1->val == dbl2->val)
    return 0;
  else if(dbl1->val > dbl2->val)
    return 1;
  else
    return -1;
}



//*****************************************************************************
// longs
//*****************************************************************************
struct long_struct {
  long val;
};

LONG *newLong(long val) {
  LONG *lng = malloc(sizeof(LONG));
  lng->val  = val;
  return lng;
}

void deleteLong(LONG *lng) {
  free(lng);
}

long longGetVal(LONG *lng) {
  return lng->val;
}

void longSetVal(LONG *lng, long val) {
  lng->val = val;
}

int longCmp(LONG *lng1, LONG *lng2) {
  if(lng1->val == lng2->val)
    return 0;
  else if(lng1->val > lng2->val)
    return 1;
  else
    return -1;
}



//*****************************************************************************
// booleans
//*****************************************************************************
struct boolean_struct {
  bool val;
};

BOOLEAN *newBoolean(bool val) {
  BOOLEAN *bl = malloc(sizeof(BOOLEAN));
  bl->val  = val;
  return bl;
}

void deleteBoolean(BOOLEAN *bl) {
  free(bl);
}

bool booleanGetVal(BOOLEAN *bl) {
  return bl->val;
}

void booleanSetVal(BOOLEAN *bl, bool val) {
  bl->val = val;
}

int booleanCmp(BOOLEAN *bl1, BOOLEAN *bl2) {
  if(bl1->val == bl2->val)
    return 0;
  else if(bl1->val > bl2->val)
    return 1;
  else
    return -1;
}