config.c
demise/src/config.c · 3.5 KB
From the archive dodbackup-final.tar.gz
Download the archive « Back to the archive contents
/***************************************************************************
* God Wars Mud originally written by KaVir aka Richard Woolcock. *
* Changes done to the code done by Sage aka Walter Howard, this mud is *
* for the public, however if you run this code it means you agree *
* to the license.low, license.gw, and license.merc have fun. :) *
***************************************************************************/
// For.. Configuration.. To be... vague.
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "merc.h"
void load_config args ((void));
void
initialise_config ()
{
if (mudconfig == NULL)
mudconfig = alloc_perm (sizeof (*mudconfig));
mudconfig->armtimer = 0;
mudconfig->world_affects = 0;
mudconfig->mobattacks = 0;
mudconfig->mobhitdam = 0;
mudconfig->catchmode = 0;
mudconfig->doubletimer = 0;
mudconfig->cdtimer = 0;
mudconfig->bounty = 0;
mudconfig->pkcounter = 0;
mudconfig->hcrtimer = 0;
mudconfig->hexptimer = 0;
mudconfig->hdctimer = 0;
mudconfig->htrtimer = 0;
mudconfig->dtrtimer = 0;
mudconfig->dtrpayd = 0;
mudconfig->dcrtimer = 0;
mudconfig->dcrpayd = 0;
mudconfig->ddctimer = 0;
mudconfig->ddcpayd = 0;
mudconfig->dexptimer = 0;
mudconfig->dexppayd = 0;
mudconfig->hellstorm = 0;
mudconfig->helltimer = 0;
mudconfig->maxemp = 0;
mudconfig->wonder = 0;
load_config ();
}
void
load_config ()
{
FILE *fp;
if ((fp = fopen ("../txt/config.sys", "r")) == NULL)
{
bug ("Creating config.sys", 0);
save_config ();
return;
}
mudconfig->armtimer = fread_number (fp);
mudconfig->world_affects = fread_number (fp);
mudconfig->mobattacks = fread_number (fp);
mudconfig->mobhitdam = fread_number (fp);
mudconfig->catchmode = fread_number (fp);
mudconfig->doubletimer = fread_number (fp);
mudconfig->cdtimer = fread_number (fp);
mudconfig->bounty = fread_number (fp);
mudconfig->pkcounter = fread_number (fp);
mudconfig->hcrtimer = fread_number (fp);
mudconfig->hexptimer = fread_number (fp);
mudconfig->hdctimer = fread_number (fp);
mudconfig->htrtimer = fread_number (fp);
mudconfig->dtrtimer = fread_number (fp);
mudconfig->dtrpayd = fread_number (fp);
mudconfig->dcrtimer = fread_number (fp);
mudconfig->dcrpayd = fread_number (fp);
mudconfig->ddctimer = fread_number (fp);
mudconfig->ddcpayd = fread_number (fp);
mudconfig->dexptimer = fread_number (fp);
mudconfig->dexppayd = fread_number (fp);
mudconfig->hellstorm = fread_number (fp);
mudconfig->helltimer = fread_number (fp);
mudconfig->wonder = fread_number (fp);
mudconfig->maxemp = fread_number (fp);
fclose (fp);
}
void
save_config ()
{
FILE *fp;
if ((fp = fopen ("../txt/config.sys", "w")) == NULL)
{
bug ("Error saving to config.sys", 0);
return;
}
fprintf (fp,
"%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",
mudconfig->armtimer, mudconfig->world_affects,
mudconfig->mobattacks, mudconfig->mobhitdam, mudconfig->catchmode,
mudconfig->doubletimer, mudconfig->cdtimer, mudconfig->bounty,
mudconfig->pkcounter, mudconfig->hcrtimer, mudconfig->hexptimer,
mudconfig->hdctimer, mudconfig->htrtimer, mudconfig->dtrtimer,
mudconfig->dtrpayd, mudconfig->dcrtimer, mudconfig->dcrpayd,
mudconfig->ddctimer, mudconfig->ddcpayd, mudconfig->dexptimer,
mudconfig->dexppayd, mudconfig->hellstorm, mudconfig->helltimer,
mudconfig->wonder, mudconfig->maxemp);
fclose (fp);
}