db.c
wolfpaw4.0-release/source/betasrc/db.c · 175.3 KB
From the archive Wolfpaw4.0-Release.tgz
Download the archive « Back to the archive contents
/*--------------------------------------------------------------------------*
* ** WolfPaw 3.0 ** *
*--------------------------------------------------------------------------*
* WolfPaw 3.0 (c) 1997 - 1999 by Dale Corse *
*--------------------------------------------------------------------------*
* The WolfPaw Coding Team is headed by: Greywolf *
* With the Assitance from: Callinon, Dhamon, Sentra, Wyverns, Altrag *
* Scryn, Thoric, Justice, Tricops and Brogar. *
*--------------------------------------------------------------------------*
* Based on SMAUG 1.2a. Copyright 1994 - 1996 by Derek Snider *
* SMAUG Coding Team: Thoric, Altrag, Blodkai, Narn, Haus, Scryn, Rennard, *
* Swordbearer, Gorog, Grishnakh and Tricops. *
*--------------------------------------------------------------------------*
* Merc 2.1 Diku MUD Improvments (C) 1992 - 1993 by Michael Chastain, *
* Michael Quan, and Michael Tse. *
* Original Diku MUD (C) 1990 - 1991 by Sebastian Hammer, Michael Seifert, *
* Hans Hendrik Strfeldt, Tom Madsen, and Katja Nyboe. *
*--------------------------------------------------------------------------*
* Database management module *
****************************************************************************/
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include "mud.h"
extern int _filbuf args( (FILE *) );
#if defined(KEY)
#undef KEY
#endif
void init_supermob();
void inroom_update(void);
#define KEY( literal, field, value ) \
if ( !str_cmp( word, literal ) ) \
{ \
field = value; \
fMatch = TRUE; \
break; \
}
/*
* Globals.
*/
ZONE_DATA * zone_pointer;
WEB_DESCRIPTOR *first_webdesc;
WEB_DESCRIPTOR *last_webdesc;
int top_web_desc;
WIZENT * first_wiz;
WIZENT * last_wiz;
bool mudlog_off;
time_t last_restore_all_time = 0;
HELP_DATA * first_help;
HELP_DATA * last_help;
SHOP_DATA * first_shop;
SHOP_DATA * last_shop;
REPAIR_DATA * first_repair;
REPAIR_DATA * last_repair;
TELEPORT_DATA * first_teleport;
TELEPORT_DATA * last_teleport;
OBJ_DATA * extracted_obj_queue;
EXTRACT_CHAR_DATA * extracted_char_queue;
char bug_buf [2*MAX_INPUT_LENGTH];
CHAR_DATA * first_char;
CHAR_DATA * last_char;
char * help_greeting[3];
char * first_greeting;
char log_buf [2*MAX_INPUT_LENGTH];
SECURE_DATA * first_secure;
SECURE_DATA * last_secure;
REFFERAL_DATA * first_refferal;
REFFERAL_DATA * last_refferal;
PETITION_DATA * first_petition;
PETITION_DATA * last_petition;
MAIL_DATA * first_mail;
MAIL_DATA * last_mail;
ZONE_DATA * first_zone;
ZONE_DATA * last_zone;
/* Commented out by Greywolf, zones dont use these.*/
/*OBJ_DATA * first_object;
OBJ_DATA * last_object;*/
TIME_INFO_DATA time_info;
WEATHER_DATA weather_info;
TOPTEN_DATA * first_topten;
TOPTEN_DATA * last_topten;
bool TOPTEN_ACTIVE=FALSE;
bool MAIM_DEATH;
long lowest_toptens[10];
int cur_qobjs;
int cur_qchars;
int nummobsloaded;
int numobjsloaded;
int physicalobjects;
bool ALIENS_RAN;
bool WEBSERVER_STATUS;
bool DRAGONS_RAN;
bool FORCE_DRAGON_RUN;
bool EMAIL_AUTH;
MAP_INDEX_DATA * first_map; /* maps */
AUCTION_DATA * auction; /* auctions */
FILE * fpLOG;
FILE * fpMem;
/* weaponry */
sh_int gsn_pugilism;
sh_int gsn_long_blades;
sh_int gsn_short_blades;
sh_int gsn_flexible_arms;
sh_int gsn_talonous_arms;
sh_int gsn_bludgeons;
sh_int gsn_missile_weapons;
/* thief */
sh_int gsn_detrap;
sh_int gsn_backstab;
sh_int gsn_circle;
sh_int gsn_dodge;
sh_int gsn_hide;
sh_int gsn_peek;
sh_int gsn_pick_lock;
sh_int gsn_sneak;
sh_int gsn_steal;
sh_int gsn_gouge;
sh_int gsn_poison_weapon;
/* thief & warrior */
sh_int gsn_disarm;
sh_int gsn_enhanced_damage;
sh_int gsn_kick;
sh_int gsn_parry;
sh_int gsn_rescue;
sh_int gsn_second_attack;
sh_int gsn_third_attack;
sh_int gsn_fourth_attack;
sh_int gsn_fifth_attack;
sh_int gsn_sixth_attack;
sh_int gsn_seventh_attack;
sh_int gsn_dual_wield;
sh_int gsn_punch;
sh_int gsn_bash;
sh_int gsn_stun;
sh_int gsn_bashdoor;
sh_int gsn_grip;
sh_int gsn_berserk;
sh_int gsn_hitall;
/* vampire */
sh_int gsn_feed;
/* other */
sh_int gsn_aid;
sh_int gsn_track;
sh_int gsn_search;
sh_int gsn_dig;
sh_int gsn_mount;
sh_int gsn_bite;
sh_int gsn_claw;
sh_int gsn_sting;
sh_int gsn_tail;
sh_int gsn_scribe;
sh_int gsn_brew;
sh_int gsn_climb;
sh_int gsn_scan;
sh_int gsn_slice;
/* archmage */
sh_int gsn_ancient_lore;
/* adept */
sh_int gsn_assassinate;
/* spells */
sh_int gsn_aqua_breath;
sh_int gsn_blindness;
sh_int gsn_charm_person;
sh_int gsn_curse;
sh_int gsn_invis;
sh_int gsn_mass_invis;
sh_int gsn_poison;
sh_int gsn_sleep;
sh_int gsn_possess;
sh_int gsn_fireball;
sh_int gsn_chill_touch;
sh_int gsn_lightning_bolt;
sh_int gsn_reflect_magic;
/* languages */
sh_int gsn_common;
sh_int gsn_elven;
sh_int gsn_dwarven;
sh_int gsn_pixie;
sh_int gsn_ogre;
sh_int gsn_orcish;
sh_int gsn_trollish;
sh_int gsn_goblin;
sh_int gsn_halfling;
sh_int gsn_vampiric;
sh_int gsn_wolfish;
sh_int gsn_draconian;
sh_int gsn_satyr;
sh_int gsn_wraith;
sh_int gsn_centaur;
sh_int gsn_drider;
sh_int gsn_drowish;
sh_int gsn_minotaur;
sh_int gsn_cyclops;
sh_int gsn_arewyndel;
sh_int gsn_brownie;
sh_int gsn_leprachaun;
sh_int gsn_mrrshan;
/* for searching */
sh_int gsn_first_spell;
sh_int gsn_first_skill;
sh_int gsn_first_weapon;
sh_int gsn_first_tongue;
sh_int gsn_top_sn;
int top_zone;
/*
* Locals.
*/
/* Same Here, zone doesnt use these --GW*/
/*MOB_INDEX_DATA * mob_index_hash [MAX_KEY_HASH];
OBJ_INDEX_DATA * obj_index_hash [MAX_KEY_HASH];
ROOM_INDEX_DATA * room_index_hash [MAX_KEY_HASH];*/
WARRENT_DATA * first_warrent;
WARRENT_DATA * last_warrent;
KOMBAT_DATA * kombat;
CHALLENGE_DATA * first_challenge;
CHALLENGE_DATA * last_challenge;
ARENA_DATA * first_arena;
ARENA_DATA * last_arena;
AREA_DATA * first_area;
AREA_DATA * last_area;
AREA_DATA * first_build;
AREA_DATA * last_build;
AREA_DATA * first_asort;
AREA_DATA * last_asort;
AREA_DATA * first_bsort;
AREA_DATA * last_bsort;
SYSTEM_DATA sysdata;
int top_affect;
int top_area;
int top_zone;
int top_ed;
int top_exit;
int top_help;
int top_mob_index;
int top_obj_index;
int top_reset;
int top_room;
int top_shop;
int top_repair;
int top_vroom;
int chaos; /* CHAOS (FREE PKILL) on/off */
int doubleexp; /*double EXP*/
int war; /*WAR MODE ON/OFF*/
sh_int PULSE_PER_SECOND;
bool TURBO_FIGHT;
int TURBO_NUM;
bool noenforce;
sh_int dam_no_msg;
bool DRAGON_DROP;
long CASINO_BANK;
extern bool CR;
char BOOTED_BY[MSL];
char BOOT_TIME[MSL];
char COMPILED_TIME[MSL];
char COMPILED_BY[MSL];
char MUD_VERSION[MSL];
char VERSNUM[MSL];
bool ENABLE_DEATH_CRY;
extern bool skip_locker;
/*
* Semi-locals.
*/
bool fBootDb;
FILE * fpArea;
char strArea[MAX_INPUT_LENGTH];
/*
* Local booting procedures.
*/
void init_mm args( ( void ) );
void load_mail args( ( void ) );
void load_zone_file args( ( ZONE_DATA *tzone, char *filename ) );
void boot_log args( ( const char *str, ... ) );
void load_area args( ( FILE *fp ) );
void load_author args( ( AREA_DATA *tarea, FILE *fp ) );
void load_economy args( ( AREA_DATA *tarea, FILE *fp ) );
void load_resetmsg args( ( AREA_DATA *tarea, FILE *fp ) ); /* Rennard */
void load_flags args( ( AREA_DATA *tarea, FILE *fp ) );
void load_zone args( ( AREA_DATA *tarea, FILE *fp ) ); /* zone */
void load_helps args( ( AREA_DATA *tarea, FILE *fp ) );
void load_mobiles args( ( AREA_DATA *tarea, FILE *fp ) );
void load_objects args( ( AREA_DATA *tarea, FILE *fp ) );
void load_resets args( ( AREA_DATA *tarea, FILE *fp ) );
void load_rooms args( ( AREA_DATA *tarea, FILE *fp ) );
void load_shops args( ( AREA_DATA *tarea, FILE *fp ) );
void load_repairs args( ( AREA_DATA *tarea, FILE *fp ) );
void load_specials args( ( AREA_DATA *tarea, FILE *fp ) );
void load_vehicles args( ( AREA_DATA *tarea, FILE *fp ) );
void load_ranges args( ( AREA_DATA *tarea, FILE *fp ) );
void load_buildlist args( ( void ) );
bool load_systemdata args( ( SYSTEM_DATA *sys ) );
void load_banlist args( ( void ) );
void initialize_economy args( ( void ) );
void fix_exits args( ( void ) );
void load_refferals args( ( void ) );
void clean_pfiles args( ( void ) );
void clean_lfiles args( ( void ) );
AREA_DATA * find_room_area args( ( int vnum ) );
AREA_DATA * find_obj_area args( ( int vnum ) );
AREA_DATA * find_mob_area args( ( int vnum ) );
/*
* External booting function
*/
void load_corpses args( ( void ) );
void renumber_put_resets args( ( AREA_DATA *pArea ) );
void init_kombat args( ( void ) );
void init_challenge args( ( void ) );
void init_arenas args( ( void ) );
void load_races args( ( void ) );
void make_web_wizlist args( ( void ) );
void init_security args( ( void ) );
void load_imps args( ( void ) );
void load_mud_version( void );
void load_compile_data( void );
void load_boot_data( void );
void pk_list_cleaner( void );
void overlimit_msg( void );
void show_overlimit( CHAR_DATA *ch );
void init_upstat( void );
/*
* MUDprogram locals
*/
int mprog_name_to_type args ( ( char* name ) );
MPROG_DATA * mprog_file_read args ( ( char* f, MPROG_DATA* mprg,
MOB_INDEX_DATA *pMobIndex ) );
/* int oprog_name_to_type args ( ( char* name ) ); */
MPROG_DATA * oprog_file_read args ( ( char* f, MPROG_DATA* mprg,
OBJ_INDEX_DATA *pObjIndex ) );
/* int rprog_name_to_type args ( ( char* name ) ); */
MPROG_DATA * rprog_file_read args ( ( char* f, MPROG_DATA* mprg,
ROOM_INDEX_DATA *pRoomIndex ) );
void load_mudprogs args ( ( AREA_DATA *tarea, FILE* fp ) );
void load_objprogs args ( ( AREA_DATA *tarea, FILE* fp ) );
void load_roomprogs args ( ( AREA_DATA *tarea, FILE* fp ) );
void mprog_read_programs args ( ( FILE* fp,
MOB_INDEX_DATA *pMobIndex) );
void oprog_read_programs args ( ( FILE* fp,
OBJ_INDEX_DATA *pObjIndex) );
void rprog_read_programs args ( ( FILE* fp,
ROOM_INDEX_DATA *pRoomIndex) );
char last_function_call [MSL]; /* Last Function Call Buffer */
void examine_last_command ()
{
FILE *fp=NULL;
FILE *fp2=NULL;
FILE *fp3=NULL;
char buf [MSL];
char buf2 [MSL];
char text [MSL];
char * strtime;
char sender[MSL];
char date[MSL];
fp2 = fopen (LAST_FUNCTION_FILE, "r" );
if (!fp2)
return;
fscanf (fp2, "%[^\n]", buf2);
new_fclose (fp2);
unlink (LAST_FUNCTION_FILE);
fp = fopen (LAST_COMMAND_FILE, "r");
if (!fp)
return;
fscanf (fp, "%[^\n]", buf);
new_fclose (fp);
unlink (LAST_COMMAND_FILE);
strtime = ctime( ¤t_time );
strtime[strlen(strtime)-1] = '\0';
strcpy(date,strtime);
strcpy(sender,"CrashLog");
strcpy(text,buf);
if ( ( fp3 = fopen( CRASH_FILE, "a" ) ) == NULL )
{
bug("Cannot Open CrashLog File!",0);
perror( DIARY_FILE );
}
else
{
fprintf( fp3, "[%s] %-10s:\n[****] LAST COMMAND BEFORE CRASH [****]\n%s\n",
date,
sender,
buf
);
fprintf( fp3, "**** LAST FUNCTION CALLED WAS ****\n%s",
buf2 );
new_fclose( fp3 );
}
}
void shutdown_mud( char *reason )
{
FILE *fp;
char buf[MSL];
if ( (fp = fopen( SHUTDOWN_FILE, "a" )) != NULL )
{
fprintf( fp, "%s\n", reason );
new_fclose( fp );
}
sprintf(buf,"MUD SHUTTING DOWN: %s",reason);
log_string(buf);
}
/*
* Big mama top level function.
*/
void boot_db( bool fCopyOver )
{
sh_int wear, x;
ZONE_DATA * zone;
char zone_buf[MSL];
DIR *dp;
extern bool DISABLE_LIMIT_SCAN;
show_hash( 32 );
unlink( BOOTLOG_FILE );
unlink( BUG_FILE );
unlink( MUDLOG_FILE );
mudlog_off = TRUE;
load_limited_toggle(TRUE);
boot_log( "---------------------[ Boot Log ]--------------------" );
log_string( "Loading commands" );
load_commands();
log_string( "Loading sysdata configuration..." );
/* default values */
sysdata.read_all_mail = LEVEL_GOD;
sysdata.read_mail_free = LEVEL_IMMORTAL;
sysdata.write_mail_free = LEVEL_IMMORTAL;
sysdata.take_others_mail = LEVEL_GOD;
sysdata.imc_mail_vnum = 0;
sysdata.muse_level = LEVEL_HYPERION;
sysdata.think_level = LEVEL_HEAD_GOD;
sysdata.build_level = LEVEL_FATE;
sysdata.log_level = LEVEL_LOG;
sysdata.level_modify_proto = LEVEL_GOD;
sysdata.level_override_private = LEVEL_GOD;
sysdata.level_mset_player = LEVEL_GOD;
sysdata.stun_plr_vs_plr = 65;
sysdata.stun_regular = 15;
sysdata.max_hp = 1500;
sysdata.max_mana = 2500;
sysdata.maxaward = 500;
sysdata.segvio = 0;
sysdata.webserv = 1;
sysdata.dam_plr_vs_plr = 100;
sysdata.dam_plr_vs_mob = 100;
sysdata.dam_mob_vs_plr = 100;
sysdata.dam_mob_vs_mob = 100;
sysdata.level_getobjnotake = LEVEL_FATE;
sysdata.save_frequency = 20; /* minutes */
sysdata.save_flags = SV_DEATH | SV_PASSCHG | SV_AUTO
| SV_PUT | SV_DROP | SV_GIVE
| SV_AUCTION | SV_ZAPDROP | SV_IDLE;
sysdata.first_approve = NULL;
sysdata.last_approve = NULL;
if ( !load_systemdata(&sysdata) )
{
log_string( "Not found. Creating new configuration." );
sysdata.alltimemax = 0;
}
/* New DB Loader --GW */
load_main_db();
log_string("Loading socials");
load_socials();
log_string("Loading skill table");
load_skill_table();
sort_skill_table();
gsn_first_spell = 0;
gsn_first_skill = 0;
gsn_first_weapon = 0;
gsn_first_tongue = 0;
gsn_top_sn = top_sn;
for ( x = 0; x < top_sn; x++ )
if ( !gsn_first_spell && skill_table[x]->type == SKILL_SPELL )
gsn_first_spell = x;
else
if ( !gsn_first_skill && skill_table[x]->type == SKILL_SKILL )
gsn_first_skill = x;
else
if ( !gsn_first_weapon && skill_table[x]->type == SKILL_WEAPON )
gsn_first_weapon = x;
else
if ( !gsn_first_tongue && skill_table[x]->type == SKILL_TONGUE )
gsn_first_tongue = x;
log_string("Loading classes");
load_classes();
log_string("Loading races");
load_races();
log_string("Loading herb table");
load_herb_table();
log_string("Making wizlist");
make_wizlist();
log_string("Making Web Wizlist");
make_web_wizlist();
log_string("Loading Mail");
first_mail = NULL;
last_mail = NULL;
load_mail();
/* Never Used anyway --GW
* log_string("Loading Refferals");
* first_refferal = NULL;
* last_refferal = NULL;
* load_refferals();
*/
log_string("Initializing Kombat...");
init_kombat( );
log_string("Initializing Challenge...");
init_challenge( );
log_string("Initializing Arena(s)...");
init_arenas( );
log_string("Initializing Stocks...");
setup_shares();
log_string("Setting up TopTen..");
topten_setup();
log_string("Initializing request pipe");
init_request_pipe();
fBootDb = TRUE;
CR = FALSE;
war = 0; /* OFF is GOOD --GW */
doubleexp = 0; /* Double EXP off at reboot time =) GW */
chaos = 0; /* Chaos off at reboot is a good thing ... */
dam_no_msg = 0;
skip_locker = FALSE;
TURBO_FIGHT = FALSE; /* TURBO FIGHTING SPEED OFF .. GW */
TURBO_NUM = 4; /* 4 is normal */
WEBSERVER_STATUS = FALSE;
noenforce = FALSE; /* Enforce Laws! HELL YES! --GW */
DRAGON_DROP = TRUE; /* Dragon Dropping On! --GW */
MAIM_DEATH = FALSE;
ENABLE_DEATH_CRY = TRUE; /* Death Cry Switch */
nummobsloaded = 0;
numobjsloaded = 0;
physicalobjects = 0;
sysdata.maxplayers = 0;
sysdata.logins = 0;
first_zone = NULL;
last_zone = NULL;
first_char = NULL;
last_char = NULL;
first_area = NULL;
last_area = NULL;
first_build = NULL;
last_area = NULL;
first_shop = NULL;
last_shop = NULL;
first_repair = NULL;
last_repair = NULL;
first_teleport = NULL;
last_teleport = NULL;
first_asort = NULL;
last_asort = NULL;
extracted_obj_queue = NULL;
extracted_char_queue= NULL;
cur_qobjs = 0;
cur_qchars = 0;
cur_char = NULL;
cur_obj = 0;
cur_obj_serial = 0;
cur_char_died = FALSE;
cur_obj_extracted = FALSE;
cur_room = NULL;
quitting_char = NULL;
loading_char = NULL;
saving_char = NULL;
CREATE( auction, AUCTION_DATA, 1);
auction->item = NULL;
for ( wear = 0; wear < MAX_WEAR; wear++ )
for ( x = 0; x < MAX_LAYERS; x++ )
save_equipment[wear][x] = NULL;
/*
* Init random number generator.
*/
log_string("Initializing random number generator");
init_mm( );
/*
* Set time and weather.
*/
{
long lhour, lday, lmonth;
log_string("Setting time and weather");
lhour = (current_time - 650336715)
/ (PULSE_TICK / PULSE_PER_SECOND);
time_info.hour = lhour % 24;
lday = lhour / 24;
time_info.day = lday % 35;
lmonth = lday / 35;
time_info.month = lmonth % 17;
time_info.year = lmonth / 17;
if ( time_info.hour < 5 ) weather_info.sunlight = SUN_DARK;
else if ( time_info.hour < 6 ) weather_info.sunlight = SUN_RISE;
else if ( time_info.hour < 19 ) weather_info.sunlight = SUN_LIGHT;
else if ( time_info.hour < 20 ) weather_info.sunlight = SUN_SET;
else weather_info.sunlight = SUN_DARK;
weather_info.change = 0;
weather_info.mmhg = 960;
if ( time_info.month >= 7 && time_info.month <=12 )
weather_info.mmhg += number_range( 1, 50 );
else
weather_info.mmhg += number_range( 1, 80 );
if ( weather_info.mmhg <= 980 ) weather_info.sky = SKY_LIGHTNING;
else if ( weather_info.mmhg <= 1000 ) weather_info.sky = SKY_RAINING;
else if ( weather_info.mmhg <= 1020 ) weather_info.sky = SKY_CLOUDY;
else weather_info.sky = SKY_CLOUDLESS;
}
/*
* Assign gsn's for skills which need them.
*/
{
log_string("Assigning gsn's");
ASSIGN_GSN( gsn_pugilism, "pugilism" );
ASSIGN_GSN( gsn_long_blades, "long blades" );
ASSIGN_GSN( gsn_short_blades, "short blades" );
ASSIGN_GSN( gsn_flexible_arms, "flexible arms" );
ASSIGN_GSN( gsn_talonous_arms, "talonous arms" );
ASSIGN_GSN( gsn_bludgeons, "bludgeons" );
ASSIGN_GSN( gsn_missile_weapons,"missile weapons" );
ASSIGN_GSN( gsn_detrap, "detrap" );
ASSIGN_GSN( gsn_backstab, "backstab" );
ASSIGN_GSN( gsn_assassinate, "assassinate" );
ASSIGN_GSN( gsn_circle, "circle" );
ASSIGN_GSN( gsn_dodge, "dodge" );
ASSIGN_GSN( gsn_hide, "hide" );
ASSIGN_GSN( gsn_peek, "peek" );
ASSIGN_GSN( gsn_pick_lock, "pick lock" );
ASSIGN_GSN( gsn_sneak, "sneak" );
ASSIGN_GSN( gsn_steal, "steal" );
ASSIGN_GSN( gsn_gouge, "gouge" );
ASSIGN_GSN( gsn_poison_weapon, "poison weapon" );
ASSIGN_GSN( gsn_disarm, "disarm" );
ASSIGN_GSN( gsn_enhanced_damage, "enhanced damage" );
ASSIGN_GSN( gsn_kick, "kick" );
ASSIGN_GSN( gsn_parry, "parry" );
ASSIGN_GSN( gsn_rescue, "rescue" );
ASSIGN_GSN( gsn_second_attack, "second attack" );
ASSIGN_GSN( gsn_third_attack, "third attack" );
ASSIGN_GSN( gsn_fourth_attack, "fourth attack" );
ASSIGN_GSN( gsn_fifth_attack, "fifth attack" );
ASSIGN_GSN( gsn_sixth_attack, "sixth attack" );
ASSIGN_GSN( gsn_seventh_attack, "seventh attack" );
ASSIGN_GSN( gsn_dual_wield, "dual wield" );
ASSIGN_GSN( gsn_punch, "punch" );
ASSIGN_GSN( gsn_bash, "bash" );
ASSIGN_GSN( gsn_stun, "stun" );
ASSIGN_GSN( gsn_bashdoor, "doorbash" );
ASSIGN_GSN( gsn_grip, "grip" );
ASSIGN_GSN( gsn_berserk, "berserk" );
ASSIGN_GSN( gsn_hitall, "hitall" );
ASSIGN_GSN( gsn_feed, "feed" );
ASSIGN_GSN( gsn_ancient_lore, "ancient lore" );
ASSIGN_GSN( gsn_aid, "aid" );
ASSIGN_GSN( gsn_track, "track" );
ASSIGN_GSN( gsn_search, "search" );
ASSIGN_GSN( gsn_dig, "dig" );
ASSIGN_GSN( gsn_mount, "mount" );
ASSIGN_GSN( gsn_bite, "bite" );
ASSIGN_GSN( gsn_claw, "claw" );
ASSIGN_GSN( gsn_sting, "sting" );
ASSIGN_GSN( gsn_tail, "tail" );
ASSIGN_GSN( gsn_scribe, "scribe" );
ASSIGN_GSN( gsn_brew, "brew" );
ASSIGN_GSN( gsn_climb, "climb" );
ASSIGN_GSN( gsn_scan, "scan" );
ASSIGN_GSN( gsn_slice, "slice" );
ASSIGN_GSN( gsn_reflect_magic, "reflect magic" );
ASSIGN_GSN( gsn_fireball, "fireball" );
ASSIGN_GSN( gsn_chill_touch, "chill touch" );
ASSIGN_GSN( gsn_lightning_bolt, "lightning bolt" );
ASSIGN_GSN( gsn_aqua_breath, "aqua breath" );
ASSIGN_GSN( gsn_blindness, "blindness" );
ASSIGN_GSN( gsn_charm_person, "charm person" );
ASSIGN_GSN( gsn_curse, "curse" );
ASSIGN_GSN( gsn_invis, "invis" );
ASSIGN_GSN( gsn_mass_invis, "mass invis" );
ASSIGN_GSN( gsn_poison, "poison" );
ASSIGN_GSN( gsn_sleep, "sleep" );
ASSIGN_GSN( gsn_possess, "possess" );
ASSIGN_GSN( gsn_common, "common" );
ASSIGN_GSN( gsn_elven, "elven" );
ASSIGN_GSN( gsn_dwarven, "dwarven" );
ASSIGN_GSN( gsn_pixie, "pixie" );
ASSIGN_GSN( gsn_ogre, "ogre" );
ASSIGN_GSN( gsn_orcish, "orcish" );
ASSIGN_GSN( gsn_trollish, "trollese" );
ASSIGN_GSN( gsn_goblin, "goblin" );
ASSIGN_GSN( gsn_halfling, "halfling" );
ASSIGN_GSN( gsn_vampiric, "vampiric" );
ASSIGN_GSN( gsn_wolfish, "wolfish" );
ASSIGN_GSN( gsn_draconian, "draconian" );
ASSIGN_GSN( gsn_satyr, "satyr" );
ASSIGN_GSN( gsn_wraith, "wraith" );
ASSIGN_GSN( gsn_centaur, "centaur" );
ASSIGN_GSN( gsn_drider, "drider" );
ASSIGN_GSN( gsn_drowish, "drowish" );
ASSIGN_GSN( gsn_minotaur, "minotaur" );
ASSIGN_GSN( gsn_cyclops, "cyclops" );
ASSIGN_GSN( gsn_arewyndel, "arewyndel" );
ASSIGN_GSN( gsn_brownie, "brownie" );
ASSIGN_GSN( gsn_leprachaun, "leprachaun" );
ASSIGN_GSN( gsn_mrrshan, "mrrshan" );
}
/*
* Read in all the area files.
*/
{
FILE *fpList;
top_zone = 0;
log_string("Reading in zones...");
if ( ( fpList = fopen( ZONE_LIST, "r" ) ) == NULL )
{
perror( ZONE_LIST );
shutdown_mud( "Unable to open zone list" );
exit( 1 );
}
for ( ; ; )
{
strcpy( strArea, fread_word( fpList ) );
if ( strArea[0] == '$' )
break;
load_zone_file( last_zone, strArea );
}
new_fclose( fpList );
}
for ( zone = first_zone; zone; zone = zone->next )
{
sprintf(zone_buf,"zone%d",zone->number);
zone_pointer = zone;
zone->first_obj = NULL;
zone->last_obj = NULL;
zone->first_mob = NULL;
zone->last_mob = NULL;
if ( !(dp = opendir(zone_buf)) )
{
bug( "Load_Zones: can't open %s", zone_buf);
perror(zone_buf);
return;
}
sprintf(zone_buf,"zone%d/%s",zone->number,zone->list_filename);
/*
* Read in all the area files.
*/
{
FILE *fpList;
log_string("Reading in area files...");
if ( ( fpList = fopen( zone_buf, "r" ) ) == NULL )
{
perror( AREA_LIST );
shutdown_mud( "Unable to open area list" );
exit( 1 );
}
for ( ; ; )
{
strcpy( strArea, fread_word( fpList ) );
if ( strArea[0] == '$' )
break;
sprintf(zone_buf,"zone%d/%s",zone->number,strArea);
load_area_file( last_area, zone_buf );
/* Dont USe, --GW fold_area(last_area,zone_buf,FALSE); */
}
new_fclose( fpList );
}
closedir(dp);
}
/**/
/*
* initialize supermob.
* must be done before reset_area!
*
*/
init_supermob();
/*
* Fix up exits.
* Declare db booting over.
* Reset all areas once.
* Load up the notes file.
*/
{
log_string( "Fixing exits" );
fix_exits( );
log_string( "Initializing economy" );
initialize_economy( );
log_string( "Limit system Loading....");
load_limit_db();
if ( !DISABLE_LIMIT_SCAN )
{
log_string( "Reinitializing Limit Tables...");
reinit_limits();
log_string( "Updating Limits....");
object_limit_update();
}
log_string( "Writing Overlimit File...");
overlimit_msg();
log_string( "Resetting areas" );
area_update( );
fBootDb = FALSE;
log_string( "Loading buildlist" );
load_buildlist( );
log_string( "Loading boards" );
load_boards( );
log_string( "Loading clans" );
load_clans( );
log_string( "Setting Up PK-TRACKING" );
clan_pkill_record_setup( );
log_string( "Loading councils" );
load_deity( );
log_string( "Loading deities" );
load_councils( );
log_string( "Loading bans" );
load_banlist( );
log_string( "Loading corpses" );
load_corpses( );
log_string( "Loading Warrents" );
first_warrent = NULL;
last_warrent = NULL;
load_warrents( );
log_string("Setting up Aliens...");
ALIENS_RAN = FALSE;
log_string("Setting up Dragons...");
DRAGONS_RAN = TRUE;
FORCE_DRAGON_RUN = FALSE;
log_string( "Loading System Messages" );
load_system_messages( );
log_string( "Loading SAVE-ROOMS -- Disabled" );
/* load_save_rooms( );*/
log_string( "Disabling Email Authorization" );
EMAIL_AUTH=FALSE;
log_string( "Setting up the Casino Bank..");
setup_casino();
// log_string("Setting up CTF..");
// setup_ctf();
/* Security --GW */
log_string("Initializing Security Features..");
init_security();
log_string("WME-SECURE: Loading...");
load_imps();
/* Version/Compile/Boot Shell Stuff --GW */
log_string("Loading Compile Data..");
load_compile_data();
log_string("Loading Boot Data..");
load_boot_data();
log_string("Loading MUD Version..");
load_mud_version();
/* Upstat --GW */
init_upstat();
if ( !fCopyOver ) /* Slows CopyOver Down to much --GW */
{
/* Clean Pfiles Up */
/* clean_pfiles();*/
/* Clean Locker Files Up */
/* clean_lfiles();*/
}
MOBtrigger = TRUE;
if (fCopyOver)
{
reset_copyover_boot_time();
log_string("Running copyover_recover.");
copyover_recover();
}
}
/* init_maps ( ); */
mudlog_off = FALSE;
return;
}
/*
* Kombat Data Init Function --GW
*/
void init_kombat( void )
{
CREATE( kombat, KOMBAT_DATA, 1 );
kombat->bits = 0;
kombat->hi_lev = 0;
kombat->low_lev = 0;
return;
}
/*
* Init Areans Function --GW
*/
void init_arenas( void )
{
ARENA_DATA *arena=NULL;
first_arena = NULL;
last_arena = NULL;
/* Arena #1 */
log_string("Loading Arena #1...");
CREATE( arena, ARENA_DATA, 1 );
arena->char_room = 42;
arena->vict_room = 43;
arena->in_use = FALSE;
LINK( arena, first_arena, last_arena, next, prev );
/* Done */
log_string("Arena Loading Complete.");
return;
}
/*
* Init Challenge Function --GW
*/
void init_challenge( void )
{
first_challenge = NULL;
last_challenge = NULL;
return;
}
/*
* Load an 'area' header line.
*/
void load_area( FILE *fp )
{
AREA_DATA *pArea=NULL;
CREATE( pArea, AREA_DATA, 1 );
pArea->first_reset = NULL;
pArea->last_reset = NULL;
pArea->name = fread_string_nohash( fp );
pArea->author = STRALLOC( "unknown" );
pArea->filename = str_dup( strArea );
pArea->age = 15;
pArea->nplayer = 0;
pArea->low_r_vnum = 0;
pArea->low_o_vnum = 0;
pArea->low_m_vnum = 0;
pArea->hi_r_vnum = 0;
pArea->hi_o_vnum = 0;
pArea->hi_m_vnum = 0;
pArea->low_soft_range = 0;
pArea->hi_soft_range = MAX_LEVEL;
pArea->low_hard_range = 0;
pArea->hi_hard_range = MAX_LEVEL;
pArea->zone = zone_pointer;
pArea->version_number = 0;
pArea->version_name = STRALLOC("Unknown");
LINK( pArea, first_area, last_area, next, prev );
top_area++;
return;
}
/*
* Load an 'zone' header line.
*/
void load_zone_header( FILE *fp )
{
ZONE_DATA *pZone=NULL;
CREATE( pZone, ZONE_DATA, 1 );
pZone->name = fread_string_nohash( fp );
pZone->filename = str_dup( strArea );
LINK( pZone, first_zone, last_zone, next, prev );
return;
}
/*
* Load zones list file name .. --GW
*/
void load_zone_lname( ZONE_DATA *tzone, FILE *fp )
{
if ( !tzone )
{
bug( "Load_author: no #ZONE seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #ZONE" );
exit( 1 );
}
else
return;
}
if ( tzone->list_filename )
STRFREE( tzone->list_filename );
tzone->list_filename = fread_string( fp );
return;
}
/*
* Load zones name .. --GW
*/
void load_zone_name( ZONE_DATA *tzone, FILE *fp )
{
if ( !tzone )
{
bug( "Load_author: no #ZONE seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #ZONE" );
exit( 1 );
}
else
return;
}
if ( tzone->name )
STRFREE( tzone->name );
tzone->name = fread_string( fp );
return;
}
/*
* Load an author section. Scryn 2/1/96
*/
void load_author( AREA_DATA *tarea, FILE *fp )
{
if ( !tarea )
{
bug( "Load_author: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
if ( tarea->author )
STRFREE( tarea->author );
tarea->author = fread_string( fp );
return;
}
/*
* Map filename --GW
*/
void load_mapfile( AREA_DATA *tarea, FILE *fp )
{
if ( !tarea )
{
bug( "Load_author: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
if ( tarea->map_file )
DISPOSE( tarea->map_file );
tarea->map_file = fread_string_nohash( fp );
return;
}
/*
* Load Version Info
*/
void load_version( AREA_DATA *tarea, FILE *fp )
{
char *temp=NULL;
if ( !tarea )
{
bug( "Load_author: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
if ( tarea->version_name )
STRFREE( tarea->author );
temp = fread_string(fp);
tarea->version_number = atoi(&temp[0]);
temp++;
temp++;
tarea->version_name = STRALLOC(temp);
tarea->version_name[strlen(tarea->version_name)-1] = '\0';
return;
}
/*
* Load an club section. --GW
*/
void load_club( AREA_DATA *tarea, FILE *fp )
{
if ( !tarea )
{
bug( "Load_club: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
if ( tarea->club )
STRFREE( tarea->club );
tarea->club = fread_string( fp );
return;
}
/*
* Load an economy section. Thoric
*/
void load_economy( AREA_DATA *tarea, FILE *fp )
{
if ( !tarea )
{
bug( "Load_economy: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
tarea->high_economy = fread_number( fp );
tarea->low_economy = fread_number( fp );
return;
}
/* Reset Message Load, Rennard */
void load_resetmsg( AREA_DATA *tarea, FILE *fp )
{
if ( !tarea )
{
bug( "Load_resetmsg: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
if ( tarea->resetmsg )
DISPOSE( tarea->resetmsg );
tarea->resetmsg = fread_string_nohash( fp );
return;
}
/*
* Load area flags. Narn, Mar/96
*/
void load_flags( AREA_DATA *tarea, FILE *fp )
{
char *ln;
int x1, x2, x3, x4;
if ( !tarea )
{
bug( "Load_flags: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
ln = fread_line( fp );
x1=x2=x3=x4=0;
sscanf( ln, "%d %d %d %d",
&x1, &x2, &x3, &x4 );
tarea->flags = x1;
tarea->locklev = x2;
tarea->reset_frequency = x3;
tarea->seclev = x4;
if ( IS_SET( tarea->flags, AFLAG_STARTED ) )
REMOVE_BIT( tarea->flags, AFLAG_STARTED );
if ( x3 )
tarea->age = x3;
return;
}
/*
* Load Zone Number -- GW
*/
void load_zone_number( ZONE_DATA *tzone, FILE *fp )
{
char *ln;
int x1;
if ( !tzone )
{
bug( "Load_Zone_Number: no #ZONE seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #ZONE" );
exit( 1 );
}
else
return;
}
ln = fread_line( fp );
x1=0;
sscanf( ln, "%d",
&x1 );
tzone->number = x1;
return;
}
/*
* Adds a help page to the list if it is not a duplicate of an existing page.
* Page is insert-sorted by keyword. -Thoric
* (The reason for sorting is to keep do_hlist looking nice)
*/
void add_help( HELP_DATA *pHelp )
{
HELP_DATA *tHelp;
int match;
for ( tHelp = first_help; tHelp; tHelp = tHelp->next )
if ( pHelp->level == tHelp->level
&& strcmp(pHelp->keyword, tHelp->keyword) == 0 )
{
bug( "add_help: duplicate: %s. Deleting.", pHelp->keyword );
STRFREE( pHelp->text );
STRFREE( pHelp->keyword );
DISPOSE( pHelp );
return;
}
else
if ( (match=strcmp(pHelp->keyword[0]=='\'' ? pHelp->keyword+1 : pHelp->keyword,
tHelp->keyword[0]=='\'' ? tHelp->keyword+1 : tHelp->keyword)) < 0
|| (match == 0 && pHelp->level > tHelp->level) )
{
if ( !tHelp->prev )
first_help = pHelp;
else
tHelp->prev->next = pHelp;
pHelp->prev = tHelp->prev;
pHelp->next = tHelp;
tHelp->prev = pHelp;
break;
}
if ( !tHelp )
LINK( pHelp, first_help, last_help, next, prev );
top_help++;
}
/*
* Load a help section.
*/
void load_helps( AREA_DATA *tarea, FILE *fp )
{
HELP_DATA *pHelp=NULL;
char buf[MSL];
for ( ; ; )
{
pHelp=NULL;
CREATE( pHelp, HELP_DATA, 1 );
pHelp->level = fread_number( fp );
if( pHelp->level > MAX_LEVEL )
pHelp->level = MAX_LEVEL;
pHelp->keyword = fread_string( fp );
if ( pHelp->keyword[0] == '$' )
break;
/* DO we REALLY want to see this?? --GW */
if ( mudarg_scan('H') )
{
sprintf(buf,"Loading Help: %s",pHelp->keyword);
log_string(buf);
}
/* Added this to keep track of who does what --GW */
pHelp->update = fread_string( fp );
pHelp->text = fread_string( fp );
if ( pHelp->keyword[0] == '\0' )
{
STRFREE( pHelp->text );
STRFREE( pHelp->keyword );
DISPOSE( pHelp );
continue;
}
if ( !str_cmp( pHelp->keyword, "greeting" ) )
first_greeting = pHelp->text;
if ( !str_cmp( pHelp->keyword, "greeting1" ) )
help_greeting[0] = pHelp->text;
if ( !str_cmp( pHelp->keyword, "greeting2" ) )
help_greeting[1] = pHelp->text;
if ( !str_cmp( pHelp->keyword, "greeting3" ) )
help_greeting[2] = pHelp->text;
add_help(pHelp);
}
return;
}
/*
* Add a character to the list of all characters -Thoric
*/
void add_char( CHAR_DATA *ch )
{
LINK( ch, first_char, last_char, next, prev );
}
/*
* Load a mob section.
*/
void load_mobiles( AREA_DATA *tarea, FILE *fp )
{
MOB_INDEX_DATA *pMobIndex=NULL;
char *ln;
int x1, x2, x3, x4, x5, x6, x7, x8;
if ( !tarea )
{
bug( "Load_mobiles: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
for ( ; ; )
{
char buf[MAX_STRING_LENGTH];
sh_int vnum;
char letter;
int iHash;
bool oldmob;
bool tmpBootDb;
/* char diceletter;
char diceletter2;
diceletter = 'd';
diceletter2 = '+';
*/
letter = fread_letter( fp );
if ( letter != '#' )
{
bug( "Load_mobiles: # not found." );
if ( fBootDb )
{
shutdown_mud( "# not found" );
exit( 1 );
}
else
return;
}
vnum = fread_number( fp );
if ( vnum == 0 )
break;
tmpBootDb = fBootDb;
fBootDb = FALSE;
if ( get_mob_index( vnum,(int)tarea->zone->number ) )
{
if ( tmpBootDb )
{
bug( "Load_mobiles: vnum %d duplicated.", vnum );
shutdown_mud( "duplicate vnum" );
exit( 1 );
}
else
{
pMobIndex = get_mob_index( vnum,(int)tarea->zone->number );
sprintf( buf, "Cleaning mobile: %d", vnum );
log_string_plus( buf, LOG_BUILD, sysdata.log_level );
clean_mob( pMobIndex );
oldmob = TRUE;
}
}
else
{
oldmob = FALSE;
pMobIndex=NULL;
CREATE( pMobIndex, MOB_INDEX_DATA, 1 );
}
fBootDb = tmpBootDb;
pMobIndex->vnum = vnum;
if ( fBootDb )
{
if ( !tarea->low_m_vnum )
tarea->low_m_vnum = vnum;
if ( vnum > tarea->hi_m_vnum )
tarea->hi_m_vnum = vnum;
}
pMobIndex->player_name = fread_string( fp );
pMobIndex->short_descr = fread_string( fp );
pMobIndex->long_descr = fread_string( fp );
pMobIndex->description = fread_string( fp );
pMobIndex->area = tarea;
pMobIndex->long_descr[0] = UPPER(pMobIndex->long_descr[0]);
pMobIndex->description[0] = UPPER(pMobIndex->description[0]);
/* Modification Tracking --GW */
if ( tarea->version_number > 1 )
{
pMobIndex->modified_by = fread_string( fp );
pMobIndex->modified_date = fread_string( fp );
}
else
{
pMobIndex->modified_by = STRALLOC("Unknown");
pMobIndex->modified_date = STRALLOC("Unknown");
}
pMobIndex->act = fread_number( fp ) | ACT_IS_NPC;
pMobIndex->flags = 0;
pMobIndex->affected_by = fread_bitvector( fp );
pMobIndex->pShop = NULL;
pMobIndex->rShop = NULL;
pMobIndex->alignment = fread_number( fp );
letter = fread_letter( fp );
/* second act mob bit sting -- GW */
pMobIndex->acttwo = fread_number( fp );
pMobIndex->smart = fread_number( fp );
pMobIndex->level = fread_number( fp );
pMobIndex->mobthac0 = fread_number( fp );
pMobIndex->ac = fread_number( fp );
pMobIndex->hitnodice = fread_number( fp );
/* diceletter */ fread_letter( fp );
pMobIndex->hitsizedice = fread_number( fp );
/* diceletter2 */ fread_letter( fp );
pMobIndex->hitplus = fread_number( fp );
pMobIndex->damnodice = fread_number( fp );
/* diceletter */ fread_letter( fp );
pMobIndex->damsizedice = fread_number( fp );
/* diceletter2 */ fread_letter( fp );
pMobIndex->damplus = fread_number( fp );
pMobIndex->gold = fread_number( fp );
pMobIndex->exp = fread_number( fp );
pMobIndex->exp = 0; /* no exp on mobs man --GW*/
pMobIndex->position = fread_number( fp );
pMobIndex->defposition = fread_number( fp );
/*
* Back to meaningful values.
*/
pMobIndex->sex = fread_number( fp );
if ( letter != 'S' && letter != 'C' )
{
bug( "Load_mobiles: vnum %d: letter '%c' not S or C.", vnum,
letter );
shutdown_mud( "bad mob data" );
exit( 1 );
}
if ( letter == 'C' ) /* Realms complex mob -Thoric */
{
pMobIndex->perm_str = fread_number( fp );
pMobIndex->perm_int = fread_number( fp );
pMobIndex->perm_wis = fread_number( fp );
pMobIndex->perm_dex = fread_number( fp );
pMobIndex->perm_con = fread_number( fp );
pMobIndex->perm_cha = fread_number( fp );
pMobIndex->perm_lck = fread_number( fp );
pMobIndex->saving_poison_death = fread_number( fp );
pMobIndex->saving_wand = fread_number( fp );
pMobIndex->saving_para_petri = fread_number( fp );
pMobIndex->saving_breath = fread_number( fp );
pMobIndex->saving_spell_staff = fread_number( fp );
ln = fread_line( fp );
x1=x2=x3=x4=x5=x6=x7=0;
sscanf( ln, "%d %d %d %d %d %d %d %d",
&x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8 );
pMobIndex->race = x1;
pMobIndex->class = x2;
pMobIndex->height = x3;
pMobIndex->weight = x4;
pMobIndex->speaks = x5;
pMobIndex->speaking = x6;
pMobIndex->numattacks = x7;
/* numattacks bug fix by Greywolf */
if ( pMobIndex->numattacks < 1 )
{
sprintf(buf,"LOAD_MOBS: NUMATTACKS LESS THEN 1 mob %d",
pMobIndex->vnum );
bug(buf);
bug("Fixing...");
pMobIndex->numattacks = 1;
}
if ( race_table[pMobIndex->race] )
{
if ( !pMobIndex->speaks )
pMobIndex->speaks = race_table[pMobIndex->race]->language | LANG_COMMON;
if ( !pMobIndex->speaking )
pMobIndex->speaking = race_table[pMobIndex->race]->language;
}
else
{
pMobIndex->speaks = LANG_COMMON;
pMobIndex->speaking = LANG_COMMON;
}
ln = fread_line( fp );
x1=x2=x3=x4=x5=x6=x7=x8=0;
sscanf( ln, "%d %d %d %d %d %d %d %d",
&x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8 );
pMobIndex->hitroll = x1;
pMobIndex->damroll = x2;
pMobIndex->xflags = x3;
pMobIndex->resistant = x4;
pMobIndex->immune = x5;
pMobIndex->susceptible = x6;
pMobIndex->attacks = x7;
pMobIndex->defenses = x8;
}
else
{
pMobIndex->perm_str = 13;
pMobIndex->perm_dex = 13;
pMobIndex->perm_int = 13;
pMobIndex->perm_wis = 13;
pMobIndex->perm_cha = 13;
pMobIndex->perm_con = 13;
pMobIndex->perm_lck = 13;
pMobIndex->race = 0;
pMobIndex->class = 3;
pMobIndex->xflags = 0;
pMobIndex->resistant = 0;
pMobIndex->immune = 0;
pMobIndex->susceptible = 0;
pMobIndex->numattacks = 0;
pMobIndex->attacks = 0;
pMobIndex->defenses = 0;
}
letter = fread_letter( fp );
if ( letter == '>' )
{
ungetc( letter, fp );
mprog_read_programs( fp, pMobIndex );
}
else ungetc( letter,fp );
SET_BIT( pMobIndex->act, ACT_IS_NPC );
if ( !oldmob )
{
iHash = vnum % MAX_KEY_HASH;
pMobIndex->next = zone_pointer->mob_index_hash[iHash];
zone_pointer->mob_index_hash[iHash] = pMobIndex;
top_mob_index++;
zone_pointer->top_mob++;
}
}
return;
}
/*
* Load an obj section.
*/
void load_objects( AREA_DATA *tarea, FILE *fp )
{
OBJ_INDEX_DATA *pObjIndex=NULL;
char letter;
char *ln;
int x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11;
if ( !tarea )
{
bug( "Load_objects: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
for ( ; ; )
{
char buf[MAX_STRING_LENGTH];
int vnum;
int iHash;
bool tmpBootDb;
bool oldobj;
letter = fread_letter( fp );
if ( letter != '#' )
{
bug( "Load_objects: # not found." );
if ( fBootDb )
{
shutdown_mud( "# not found" );
exit( 1 );
}
else
return;
}
vnum = fread_number( fp );
if ( vnum == 0 )
break;
tmpBootDb = fBootDb;
fBootDb = FALSE;
if ( get_obj_index( vnum,(int)tarea->zone->number ) )
{
if ( tmpBootDb )
{
bug( "Load_objects: vnum %d duplicated.", vnum );
shutdown_mud( "duplicate vnum" );
exit( 1 );
}
else
{
pObjIndex = get_obj_index( vnum,(int)tarea->zone->number);
sprintf( buf, "Cleaning object: %d", vnum );
log_string_plus( buf, LOG_BUILD, sysdata.log_level );
clean_obj( pObjIndex );
oldobj = TRUE;
}
}
else
{
oldobj = FALSE;
pObjIndex=NULL;
CREATE( pObjIndex, OBJ_INDEX_DATA, 1 );
}
fBootDb = tmpBootDb;
pObjIndex->vnum = vnum;
if ( fBootDb )
{
if ( !tarea->low_o_vnum )
tarea->low_o_vnum = vnum;
if ( vnum > tarea->hi_o_vnum )
tarea->hi_o_vnum = vnum;
}
pObjIndex->name = fread_string( fp );
pObjIndex->short_descr = fread_string( fp );
pObjIndex->description = fread_string( fp );
pObjIndex->action_desc = fread_string( fp );
/* Modification Tracking --GW */
if ( tarea->version_number > 1 )
{
pObjIndex->modified_by = fread_string( fp );
pObjIndex->modified_date = fread_string( fp );
}
else
{
pObjIndex->modified_by = STRALLOC("Unknown");
pObjIndex->modified_date = STRALLOC("Unknown");
}
/* Commented out by Narn, Apr/96 to allow item short descs like
Bonecrusher and Oblivion */
/*pObjIndex->short_descr[0] = LOWER(pObjIndex->short_descr[0]);*/
pObjIndex->description[0] = UPPER(pObjIndex->description[0]);
pObjIndex->area = tarea;
ln = fread_line( fp );
x1=x2=x3=x4=x5=x6=x7=x8=x9=x10=x11=0;
sscanf( ln, "%d %d %d %d %d %d %d %d %d %d %d",
&x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9, &x10, &x11 );
pObjIndex->item_type = x1;
pObjIndex->extra_flags = x2;
pObjIndex->wear_flags = x3;
pObjIndex->level = x4;
pObjIndex->minlevel = x5;
pObjIndex->second_flags = x6;
/* Still in the file format .. not used tho .. maybe recylye them? =) --GW*/
pObjIndex->loaded = 0;
pObjIndex->limit = 0;
pObjIndex->has_moved = 0;
/* ------------------------------------ */
pObjIndex->ego = x10;
/* Make SURE Layers is LAST loaded! --GW */
pObjIndex->layers = x11;
ln = fread_line( fp );
x1=x2=x3=x4=x5=x6=0;
sscanf( ln, "%d %d %d %d %d %d",
&x1, &x2, &x3, &x4, &x5, &x6 );
pObjIndex->value[0] = x1;
pObjIndex->value[1] = x2;
pObjIndex->value[2] = x3;
pObjIndex->value[3] = x4;
pObjIndex->value[4] = x5;
pObjIndex->value[5] = x6;
/* Fix a DT Crasher (Damage Type) --GW */
if ( pObjIndex->item_type == ITEM_WEAPON )
{
if ( pObjIndex->value[3] > DAM_PEA )
{
bug("Weapon: %d had bad Damage Type! Setting to hit!",pObjIndex->vnum);
pObjIndex->value[3] = DAM_HIT;
}
}
pObjIndex->weight = fread_number( fp );
pObjIndex->weight = UMAX( 1, pObjIndex->weight );
pObjIndex->cost = fread_number( fp );
pObjIndex->rent = fread_number( fp );
for ( ; ; )
{
letter = fread_letter( fp );
if ( letter == 'A' )
{
AFFECT_DATA *paf=NULL;
CREATE( paf, AFFECT_DATA, 1 );
paf->type = -1;
paf->duration = -1;
paf->location = fread_number( fp );
if ( paf->location == APPLY_WEAPONSPELL
|| paf->location == APPLY_WEARSPELL
|| paf->location == APPLY_REMOVESPELL
|| paf->location == APPLY_STRIPSN )
paf->modifier = slot_lookup( fread_number(fp) );
else
paf->modifier = fread_number( fp );
xCLEAR_BITS(paf->bitvector);
LINK( paf, pObjIndex->first_affect, pObjIndex->last_affect,
next, prev );
top_affect++;
}
else if ( letter == 'E' )
{
EXTRA_DESCR_DATA *ed=NULL;
CREATE( ed, EXTRA_DESCR_DATA, 1 );
ed->keyword = fread_string( fp );
ed->description = fread_string( fp );
LINK( ed, pObjIndex->first_extradesc, pObjIndex->last_extradesc,
next, prev );
top_ed++;
}
else if ( letter == '>' )
{
ungetc( letter, fp );
oprog_read_programs( fp, pObjIndex );
}
else
{
ungetc( letter, fp );
break;
}
}
/*
* Translate spell "slot numbers" to internal "skill numbers."
*/
switch ( pObjIndex->item_type )
{
case ITEM_PILL:
case ITEM_POTION:
case ITEM_SCROLL:
pObjIndex->value[1] = slot_lookup( pObjIndex->value[1] );
pObjIndex->value[2] = slot_lookup( pObjIndex->value[2] );
pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] );
break;
case ITEM_STAFF:
case ITEM_WAND:
pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] );
break;
case ITEM_SALVE:
pObjIndex->value[4] = slot_lookup( pObjIndex->value[4] );
pObjIndex->value[5] = slot_lookup( pObjIndex->value[5] );
break;
}
/* Temp fix for area file fuckups, dont use --GW */
/* pObjIndex->layers = 0;
pObjIndex->second_flags = 0;
pObjIndex->limit = 0;
pObjIndex->loaded = 0;
pObjIndex->ego = 0;
pObjIndex->has_moved = 0;
pObjIndex->minlevel = 0;*/
if ( !oldobj )
{
iHash = vnum % MAX_KEY_HASH;
pObjIndex->next = zone_pointer->obj_index_hash[iHash];
zone_pointer->obj_index_hash[iHash] = pObjIndex;
top_obj_index++;
zone_pointer->top_obj++;
}
}
return;
}
/*
* Load a reset section.
*/
void load_resets( AREA_DATA *tarea, FILE *fp )
{
char buf[MAX_STRING_LENGTH];
bool not01 = FALSE;
int count = 0;
int zone;
if ( !tarea )
{
bug( "Load_resets: no #AREA seen yet." );
if ( fBootDb )
{
shutdown_mud( "No #AREA" );
exit( 1 );
}
else
return;
}
if ( tarea->zone )
zone = (int)tarea->zone->number;
else
zone = 1;
if ( tarea->first_reset )
{
if ( fBootDb )
{
RESET_DATA *rtmp;
bug( "load_resets: WARNING: resets already exist for this area." );
for ( rtmp = tarea->first_reset; rtmp; rtmp = rtmp->next )
++count;
}
else
{
/*
* Clean out the old resets
*/
sprintf( buf, "Cleaning resets: %s", tarea->name );
log_string_plus( buf, LOG_BUILD, sysdata.log_level );
clean_resets( tarea );
}
}
for ( ; ; )
{
ROOM_INDEX_DATA *pRoomIndex;
EXIT_DATA *pexit;
char letter;
int extra, arg1, arg2, arg3;
if ( ( letter = fread_letter( fp ) ) == 'S' )
break;
if ( letter == '*' )
{
fread_to_eol( fp );
continue;
}
extra = fread_number( fp );
arg1 = fread_number( fp );
arg2 = fread_number( fp );
arg3 = (letter == 'G' || letter == 'R')
? 0 : fread_number( fp );
fread_to_eol( fp );
++count;
/*
* Validate parameters.
* We're calling the index functions for the side effect.
*/
switch ( letter )
{
default:
bug( "Load_resets: bad command '%c'.", letter );
if ( fBootDb )
boot_log( "Load_resets: %s (%d) bad command '%c'.", tarea->filename, count, letter );
return;
case 'M':
if ( get_mob_index( arg1,zone ) == NULL && fBootDb )
boot_log( "Load_resets: %s (%d) 'M': mobile %d doesn't exist.",
tarea->filename, count, arg1 );
if ( get_room_index( arg3,zone ) == NULL && fBootDb )
boot_log( "Load_resets: %s (%d) 'M': room %d doesn't exist.",
tarea->filename, count, arg3 );
break;
case 'O':
if ( get_obj_index(arg1,zone) == NULL && !fBootDb )
boot_log( "Load_resets: %s (%d) '%c': object %d doesn't exist.",
tarea->filename, count, letter, arg1 );
if ( get_room_index(arg3,zone) == NULL && !fBootDb )
boot_log( "Load_resets: %s (%d) '%c': room %d doesn't exist.",
tarea->filename, count, letter, arg3 );
break;
case 'P':
if ( get_obj_index(arg1,zone) == NULL && !fBootDb )
boot_log( "Load_resets: %s (%d) '%c': object %d doesn't exist.",
tarea->filename, count, letter, arg1 );
if ( arg3 > 0 )
{
if ( get_obj_index(arg3,zone) == NULL && !fBootDb )
boot_log( "Load_resets: %s (%d) 'P': destination object %d doesn't exist.",
tarea->filename, count, arg3 );
}
else if ( extra > 1 )
not01 = TRUE;
break;
case 'G':
case 'E':
if ( get_obj_index(arg1,zone) == NULL && !fBootDb )
boot_log( "Load_resets: %s (%d) '%c': object %d doesn't exist.",
tarea->filename, count, letter, arg1 );
break;
case 'T':
break;
case 'H':
if ( arg1 > 0 )
if ( get_obj_index(arg1,zone) == NULL && !fBootDb )
boot_log( "Load_resets: %s (%d) 'H': object %d doesn't exist.",
tarea->filename, count, arg1 );
break;
case 'D':
pRoomIndex = get_room_index( arg1,zone );
if ( !pRoomIndex )
{
bug( "Load_resets: 'D': room %d doesn't exist.", arg1 );
bug( "Reset: %c %d %d %d %d", letter, extra, arg1, arg2,
arg3 );
if ( fBootDb )
boot_log( "Load_resets: %s (%d) 'D': room %d doesn't exist.",
tarea->filename, count, arg1 );
break;
}
if ( arg2 < 0
|| arg2 > MAX_DIR+1
|| ( pexit = get_exit(pRoomIndex, arg2)) == NULL
|| !IS_SET( pexit->exit_info, EX_ISDOOR ) )
{
bug( "Load_resets: 'D': exit %d not door.", arg2 );
bug( "Reset: %c %d %d %d %d", letter, extra, arg1, arg2,
arg3 );
if ( fBootDb )
boot_log( "Load_resets: %s (%d) 'D': exit %d not door.",
tarea->filename, count, arg2 );
}
if ( arg3 < 0 || arg3 > 2 )
{
bug( "Load_resets: 'D': bad 'locks': %d.", arg3 );
if ( fBootDb )
boot_log( "Load_resets: %s (%d) 'D': bad 'locks': %d.",
tarea->filename, count, arg3 );
}
break;
case 'R':
pRoomIndex = get_room_index( arg1, zone );
if ( !pRoomIndex && fBootDb )
boot_log( "Load_resets: %s (%d) 'R': room %d doesn't exist.",
tarea->filename, count, arg1 );
if ( arg2 < 0 || arg2 > 6 )
{
bug( "Load_resets: 'R': bad exit %d.", arg2 );
if ( fBootDb )
boot_log( "Load_resets: %s (%d) 'R': bad exit %d.",
tarea->filename, count, arg2 );
break;
}
break;
}
/* finally, add the reset */
add_reset( tarea, letter, extra, arg1, arg2, arg3 );
}
if ( !not01 )
renumber_put_resets(tarea);
return;
}
/*
* Load a room section.
*/
void load_rooms( AREA_DATA *tarea, FILE *fp )
{
ROOM_INDEX_DATA *pRoomIndex=NULL;
char buf[MAX_STRING_LENGTH];
char *ln;
int zone;
if ( !tarea )
{
bug( "Load_rooms: no #AREA seen yet." );
shutdown_mud( "No #AREA" );
exit( 1 );
}
if ( tarea->zone )
zone = tarea->zone->number;
else
zone = 1;
for ( ; ; )
{
int vnum;
char letter;
int door;
int iHash;
bool tmpBootDb;
bool oldroom;
int x1, x2, x3, x4, x5, x6, x7;
letter = fread_letter( fp );
if ( letter != '#' )
{
bug( "Load_rooms: # not found." );
if ( fBootDb )
{
shutdown_mud( "# not found" );
exit( 1 );
}
else
return;
}
vnum = fread_number( fp );
if ( vnum == 0 )
break;
tmpBootDb = fBootDb;
fBootDb = FALSE;
if ( get_room_index( vnum,zone ) != NULL )
{
if ( tmpBootDb )
{
bug( "Load_rooms: vnum %d duplicated.", vnum );
shutdown_mud( "duplicate vnum" );
exit( 1 );
}
else
{
pRoomIndex = get_room_index( vnum,zone);
sprintf( buf, "Cleaning room: %d", vnum );
log_string_plus( buf, LOG_BUILD, sysdata.log_level );
clean_room( pRoomIndex );
oldroom = TRUE;
}
}
else
{
oldroom = FALSE;
pRoomIndex=NULL;
CREATE( pRoomIndex, ROOM_INDEX_DATA, 1 );
pRoomIndex->first_person = NULL;
pRoomIndex->last_person = NULL;
pRoomIndex->first_content = NULL;
pRoomIndex->last_content = NULL;
}
fBootDb = tmpBootDb;
pRoomIndex->area = tarea;
pRoomIndex->vnum = vnum;
pRoomIndex->first_extradesc = NULL;
pRoomIndex->last_extradesc = NULL;
pRoomIndex->room_cnt = 0;
if ( fBootDb )
{
if ( !tarea->low_r_vnum )
tarea->low_r_vnum = vnum;
if ( vnum > tarea->hi_r_vnum )
tarea->hi_r_vnum = vnum;
}
pRoomIndex->name = fread_string( fp );
pRoomIndex->description = fread_string( fp );
pRoomIndex->music = fread_string( fp );
/* Modification Tracking --GW */
if ( tarea->version_number > 1 )
{
pRoomIndex->modified_by = fread_string( fp );
pRoomIndex->modified_date = fread_string( fp );
}
else
{
pRoomIndex->modified_by = STRALLOC( "Unknown" );
pRoomIndex->modified_date = STRALLOC( "Unknown" );
}
/* Area number fread_number( fp ); */
ln = fread_line( fp );
x1=x2=x3=x4=x5=x6=x7=0;
sscanf( ln, "%d %d %d %d %d %d %d",
&x1, &x2, &x3, &x4, &x5, &x6, &x7 );
pRoomIndex->room_flags = x2;
pRoomIndex->sector_type = x3;
pRoomIndex->level = x4;
if ( pRoomIndex->level > LEVEL_HYPERION )
pRoomIndex->level = LEVEL_HYPERION;
pRoomIndex->tele_vnum = x5;
pRoomIndex->tele_delay = x6;
pRoomIndex->tunnel = x7;
if (pRoomIndex->sector_type < 0 || pRoomIndex->sector_type == SECT_MAX)
{
bug( "Fread_rooms: vnum %d has bad sector_type %d.", vnum ,
pRoomIndex->sector_type);
pRoomIndex->sector_type = 1;
}
pRoomIndex->light = 0;
pRoomIndex->first_exit = NULL;
pRoomIndex->last_exit = NULL;
for ( ; ; )
{
letter = fread_letter( fp );
if ( letter == 'S' )
break;
if ( letter == 'D' )
{
EXIT_DATA *pexit;
int locks;
door = fread_number( fp );
if ( door < 0 || door > 10 )
{
bug( "Fread_rooms: vnum %d has bad door number %d.", vnum,
door );
if ( fBootDb )
exit( 1 );
}
else
{
pexit = make_exit( pRoomIndex, NULL, door );
pexit->description = fread_string( fp );
pexit->keyword = fread_string( fp );
pexit->exit_info = 0;
ln = fread_line( fp );
x1=x2=x3=x4=0;
sscanf( ln, "%d %d %d %d",
&x1, &x2, &x3, &x4 );
locks = x1;
pexit->key = x2;
pexit->vnum = x3;
pexit->vdir = door;
pexit->distance = x4;
switch ( locks )
{
case 1: pexit->exit_info = EX_ISDOOR; break;
case 2: pexit->exit_info = EX_ISDOOR | EX_PICKPROOF; break;
default: pexit->exit_info = locks;
}
}
}
else if ( letter == 'E' )
{
EXTRA_DESCR_DATA *ed=NULL;
CREATE( ed, EXTRA_DESCR_DATA, 1 );
ed->keyword = fread_string( fp );
ed->description = fread_string( fp );
LINK( ed, pRoomIndex->first_extradesc, pRoomIndex->last_extradesc,
next, prev );
top_ed++;
}
else if ( letter == 'M' ) /* Disabled */
{
int vnum,x,y;
char entry;
vnum = fread_number(fp);
x = fread_number(fp);
y = fread_number(fp);
entry = fread_letter(fp);
}
/* {
MAP_DATA *map;
MAP_INDEX_DATA *map_index;
int i, j;
CREATE( map, MAP_DATA, 1);
map->vnum = fread_number( fp );
map->x = fread_number( fp );
map->y = fread_number( fp );
map->entry = fread_letter( fp );
pRoomIndex->map = map;
if( (map_index = get_map_index(map->vnum)) == NULL )
{
CREATE( map_index, MAP_INDEX_DATA, 1);
map_index->vnum = map->vnum;
map_index->next = first_map;
first_map = map_index;
for (i = 0; i < 49; i++) {
for (j = 0; j < 79; j++) {
map_index->map_of_vnums[i][j] = -1;
}
}
}
if( (map->y <0) || (map->y >48) )
{
bug("Map y coord out of range. Room %d\n\r", map->y);
}
if( (map->x <0) || (map->x >78) )
{
bug("Map x coord out of range. Room %d\n\r", map->x);
}
if( (map->x >0)
&&(map->x <80)
&&(map->y >0)
&&(map->y <48) )
map_index->map_of_vnums[map->y][map->x]=pRoomIndex->vnum;
}
*/
else if ( letter == '>' )
{
ungetc( letter, fp );
rprog_read_programs( fp, pRoomIndex );
}
else
{
bug( "Load_rooms: vnum %d has flag '%c' not 'DES'.", vnum,
letter );
shutdown_mud( "Room flag not DES" );
exit( 1 );
}
}
if ( !oldroom )
{
iHash = vnum % MAX_KEY_HASH;
pRoomIndex->next = zone_pointer->room_index_hash[iHash];
zone_pointer->room_index_hash[iHash] = pRoomIndex;
top_room++;
zone_pointer->top_room++;
}
}
return;
}
/*
* Load a shop section.
*/
void load_shops( AREA_DATA *tarea, FILE *fp )
{
SHOP_DATA *pShop=NULL;
for ( ; ; )
{
MOB_INDEX_DATA *pMobIndex;
int iTrade;
pShop=NULL;
CREATE( pShop, SHOP_DATA, 1 );
pShop->keeper = fread_number( fp );
if ( pShop->keeper == 0 )
break;
for ( iTrade = 0; iTrade < MAX_TRADE; iTrade++ )
pShop->buy_type[iTrade] = fread_number( fp );
pShop->profit_buy = fread_number( fp );
pShop->profit_sell = fread_number( fp );
pShop->profit_buy = URANGE( pShop->profit_sell+5, pShop->profit_buy, 1000 );
pShop->profit_sell = URANGE( 0, pShop->profit_sell, pShop->profit_buy-5 );
pShop->open_hour = fread_number( fp );
pShop->close_hour = fread_number( fp );
fread_to_eol( fp );
pMobIndex = get_mob_index(pShop->keeper,(int)tarea->zone->number );
pMobIndex->pShop = pShop;
if ( !first_shop )
first_shop = pShop;
else
last_shop->next = pShop;
pShop->next = NULL;
pShop->prev = last_shop;
last_shop = pShop;
top_shop++;
}
return;
}
/*
* Load a repair shop section. -Thoric
*/
void load_repairs( AREA_DATA *tarea, FILE *fp )
{
REPAIR_DATA *rShop=NULL;
for ( ; ; )
{
MOB_INDEX_DATA *pMobIndex;
int iFix;
rShop=NULL;
CREATE( rShop, REPAIR_DATA, 1 );
rShop->keeper = fread_number( fp );
if ( rShop->keeper == 0 )
break;
for ( iFix = 0; iFix < MAX_FIX; iFix++ )
rShop->fix_type[iFix] = fread_number( fp );
rShop->profit_fix = fread_number( fp );
rShop->shop_type = fread_number( fp );
rShop->open_hour = fread_number( fp );
rShop->close_hour = fread_number( fp );
fread_to_eol( fp );
pMobIndex = get_mob_index( rShop->keeper,(int)tarea->zone->number );
pMobIndex->rShop = rShop;
if ( !first_repair )
first_repair = rShop;
else
last_repair->next = rShop;
rShop->next = NULL;
rShop->prev = last_repair;
last_repair = rShop;
top_repair++;
}
return;
}
/*
* Load Vehicle Data
*/
void load_vehicles( AREA_DATA *tarea, FILE *fp )
{
char buf[MSL];
for ( ; ; )
{
OBJ_INDEX_DATA *pObjIndex;
char letter;
switch ( letter = fread_letter( fp ) )
{
default:
bug( "Load_vehicles: letter '%c' not *MS.", letter );
exit( 1 );
case 'S':
return;
case '*':
break;
case 'V':
/* Format for Vehicle saving is :
* V <vnum> <description> <flags> --GW
*/
pObjIndex = get_obj_index ( fread_number ( fp ),tarea->zone->number );
if ( !pObjIndex )
{
bug("Load_vehicles: NULL Obj Index!",0);
continue;
}
sprintf(buf,"Loading Vehicle Data: #%d\n",pObjIndex->vnum );
log_string(buf);
CREATE( pObjIndex->vehicle, VEHICLE_DATA, 1 );
pObjIndex->vehicle->contents = NULL;
pObjIndex->vehicle->serial_number = 0;
pObjIndex->vehicle->in_room = NULL;
pObjIndex->vehicle->vehicle_flags = fread_number(fp);
pObjIndex->vehicle->obj_vnum = pObjIndex->vnum;
break;
}
fread_to_eol( fp );
}
}
/*
* Load spec proc declarations.
*/
void load_specials( AREA_DATA *tarea, FILE *fp )
{
for ( ; ; )
{
MOB_INDEX_DATA *pMobIndex;
char letter;
switch ( letter = fread_letter( fp ) )
{
default:
bug( "Load_specials: letter '%c' not *MS.", letter );
exit( 1 );
case 'S':
return;
case '*':
break;
case 'M':
pMobIndex = get_mob_index ( fread_number ( fp ),tarea->zone->number );
pMobIndex->spec_fun = spec_lookup ( fread_word ( fp ) );
if ( pMobIndex->spec_fun == 0 )
{
bug( "Load_specials: 'M': vnum %d.", pMobIndex->vnum );
exit( 1 );
}
break;
}
fread_to_eol( fp );
}
}
/*
* Load soft / hard area ranges.
*/
void load_ranges( AREA_DATA *tarea, FILE *fp )
{
int x1, x2, x3, x4;
char *ln;
if ( !tarea )
{
bug( "Load_ranges: no #AREA seen yet." );
shutdown_mud( "No #AREA" );
exit( 1 );
}
for ( ; ; )
{
ln = fread_line( fp );
if (ln[0] == '$')
break;
x1=x2=x3=x4=0;
sscanf( ln, "%d %d %d %d",
&x1, &x2, &x3, &x4 );
tarea->low_soft_range = x1;
tarea->hi_soft_range = x2;
tarea->low_hard_range = x3;
tarea->hi_hard_range = x4;
}
return;
}
/*
* Go through all areas, and set up initial economy based on mob
* levels and gold
*/
void initialize_economy( void )
{
AREA_DATA *tarea;
MOB_INDEX_DATA *mob;
int idx, gold, rng;
for ( tarea = first_area; tarea; tarea = tarea->next )
{
/* skip area if they already got some gold */
if ( tarea->high_economy > 0 || tarea->low_economy > 10000 )
continue;
rng = tarea->hi_soft_range - tarea->low_soft_range;
if ( rng )
rng /= 2;
else
rng = 25;
gold = rng * rng * 50000;
boost_economy( tarea, gold );
for ( idx = tarea->low_m_vnum; idx < tarea->hi_m_vnum; idx++ )
if ( (mob=get_mob_index(idx,(int)tarea->zone->number)) != NULL)
boost_economy( tarea, mob->gold * 10 );
}
}
/*
* Translate all room exits from virtual to real.
* Has to be done after all rooms are read in.
* Check for bad reverse exits.
*/
void fix_exits( void )
{
ROOM_INDEX_DATA *pRoomIndex;
EXIT_DATA *pexit, *pexit_next, *rev_exit;
int iHash;
ZONE_DATA *in_zone;
for ( in_zone = first_zone; in_zone; in_zone = in_zone->next )
{
for ( iHash = 0; iHash < MAX_KEY_HASH; iHash++ )
{
for ( pRoomIndex = in_zone->room_index_hash[iHash];
pRoomIndex;
pRoomIndex = pRoomIndex->next )
{
bool fexit;
fexit = FALSE;
for ( pexit = pRoomIndex->first_exit; pexit; pexit = pexit_next )
{
pexit_next = pexit->next;
pexit->rvnum = pRoomIndex->vnum;
if ( pexit->vnum <= 0 ||(pexit->to_room=get_room_index(pexit->vnum,(int)in_zone->number))== NULL)
{
if ( fBootDb )
boot_log( "Fix_exits: room %d, exit %s leads to bad vnum (%d)",
pRoomIndex->vnum, dir_name[pexit->vdir], pexit->vnum );
bug( "Deleting %s exit in room %d", dir_name[pexit->vdir],
pRoomIndex->vnum );
extract_exit( pRoomIndex, pexit );
}
else
fexit = TRUE;
}
if ( !fexit )
SET_BIT( pRoomIndex->room_flags, ROOM_NO_MOB );
}
}
/* Set all the rexit pointers -Thoric */
for ( iHash = 0; iHash < MAX_KEY_HASH; iHash++ )
{
for ( pRoomIndex = in_zone->room_index_hash[iHash];
pRoomIndex;
pRoomIndex = pRoomIndex->next )
{
for ( pexit = pRoomIndex->first_exit; pexit; pexit = pexit->next )
{
if ( pexit->to_room && !pexit->rexit )
{
rev_exit = get_exit_to( pexit->to_room, rev_dir[pexit->vdir], pRoomIndex->vnum );
if ( rev_exit )
{
pexit->rexit = rev_exit;
rev_exit->rexit = pexit;
}
}
}
}
}
}
return;
}
/*
* Get diku-compatable exit by number -Thoric
*/
EXIT_DATA *get_exit_number( ROOM_INDEX_DATA *room, int xit )
{
EXIT_DATA *pexit;
int count;
count = 0;
for ( pexit = room->first_exit; pexit; pexit = pexit->next )
if ( ++count == xit )
return pexit;
return NULL;
}
/*
* (prelude...) This is going to be fun... NOT!
* (conclusion) QSort is f*cked!
*/
int exit_comp( EXIT_DATA **xit1, EXIT_DATA **xit2 )
{
int d1, d2;
d1 = (*xit1)->vdir;
d2 = (*xit2)->vdir;
if ( d1 < d2 )
return -1;
if ( d1 > d2 )
return 1;
return 0;
}
void sort_exits( ROOM_INDEX_DATA *room )
{
EXIT_DATA *pexit; /* *texit */ /* Unused */
EXIT_DATA *exits[MAX_REXITS];
int x, nexits;
nexits = 0;
for ( pexit = room->first_exit; pexit; pexit = pexit->next )
{
exits[nexits++] = pexit;
if ( nexits > MAX_REXITS )
{
bug( "sort_exits: more than %d exits in room... fatal", nexits );
return;
}
}
qsort( &exits[0], nexits, sizeof( EXIT_DATA * ),
(int(*)(const void *, const void *)) exit_comp );
for ( x = 0; x < nexits; x++ )
{
if ( x > 0 )
exits[x]->prev = exits[x-1];
else
{
exits[x]->prev = NULL;
room->first_exit = exits[x];
}
if ( x >= (nexits - 1) )
{
exits[x]->next = NULL;
room->last_exit = exits[x];
}
else
exits[x]->next = exits[x+1];
}
}
void randomize_exits( ROOM_INDEX_DATA *room, sh_int maxdir )
{
EXIT_DATA *pexit;
int nexits, /* maxd, */ d0, d1, count, door; /* Maxd unused */
int vdirs[MAX_REXITS];
nexits = 0;
for ( pexit = room->first_exit; pexit; pexit = pexit->next )
vdirs[nexits++] = pexit->vdir;
for ( d0 = 0; d0 < nexits; d0++ )
{
if ( vdirs[d0] > maxdir )
continue;
count = 0;
while ( vdirs[(d1 = number_range( d0, nexits - 1 ))] > maxdir
|| ++count > 5 );
if ( vdirs[d1] > maxdir )
continue;
door = vdirs[d0];
vdirs[d0] = vdirs[d1];
vdirs[d1] = door;
}
count = 0;
for ( pexit = room->first_exit; pexit; pexit = pexit->next )
pexit->vdir = vdirs[count++];
sort_exits( room );
}
/*
* Repopulate areas periodically.
*/
void area_update( void )
{
AREA_DATA *pArea;
for ( pArea = first_area; pArea; pArea = pArea->next )
{
CHAR_DATA *pch;
int reset_age = pArea->reset_frequency ? pArea->reset_frequency : 15;
if ( (reset_age == -1 && pArea->age == -1)
|| ++pArea->age < (reset_age-1) )
continue;
if ( !IS_SET( pArea->flags, AFLAG_STARTED ) &&
!IS_SET( pArea->flags, AFLAG_ALWAYS_START ) )
continue;
if ( IS_SET( pArea->flags, AFLAG_NEVER_START ) )
continue;
/*
* Check for PC's.
*/
if ( pArea->nplayer > 0 && pArea->age == (reset_age-1) )
{
char buf[MAX_STRING_LENGTH];
/* Rennard */
if ( pArea->resetmsg )
sprintf( buf, "%s\n\r", pArea->resetmsg );
else
strcpy( buf, "You hear some squeaking sounds...\n\r" );
for ( pch = first_char; pch; pch = pch->next )
{
if ( !IS_NPC(pch)
&& IS_AWAKE(pch)
&& pch->in_room
&& pch->in_room->area == pArea )
{
set_char_color( AT_RESET, pch );
send_to_char( buf, pch );
}
}
}
/*
* Check age and reset.
* Note: Mud Academy resets every 3 minutes (not 15).
*/
if ( pArea->nplayer == 0 || pArea->age >= reset_age )
{
ROOM_INDEX_DATA *pRoomIndex;
if ( IS_SET( pArea->flags, AFLAG_ALWAYS_START ) )
fprintf( stderr, "AUTO-AREA-RESET: %s\n", pArea->filename );
else
fprintf( stderr, "RUNTIME-RESET: %s\n", pArea->filename );
reset_area( pArea );
if ( reset_age == -1 )
pArea->age = -1;
else
pArea->age = number_range( 0, reset_age / 5 );
pRoomIndex = get_room_index( ROOM_VNUM_SCHOOL,1 );
if ( pRoomIndex != NULL && pArea == pRoomIndex->area
&& pArea->reset_frequency == 0 )
pArea->age = 15 - 3;
}
}
return;
}
/*
* Create an instance of a mobile.
*/
CHAR_DATA *create_mobile( MOB_INDEX_DATA *pMobIndex, ZONE_DATA *zone )
{
CHAR_DATA *mob=NULL;
if ( !pMobIndex )
{
bug( "Create_mobile: NULL pMobIndex." );
return NULL;
}
CREATE( mob, CHAR_DATA, 1 );
clear_char( mob );
mob->pIndexData = pMobIndex;
mob->name = QUICKLINK( pMobIndex->player_name );
mob->short_descr = QUICKLINK( pMobIndex->short_descr );
mob->long_descr = QUICKLINK( pMobIndex->long_descr );
mob->description = QUICKLINK( pMobIndex->description );
mob->spec_fun = pMobIndex->spec_fun;
mob->mpscriptpos = 0;
mob->level = number_fuzzy( pMobIndex->level );
mob->act = pMobIndex->act;
mob->acttwo = pMobIndex->acttwo;
mob->smart = pMobIndex->smart;
mob->affected_by = pMobIndex->affected_by;
mob->alignment = pMobIndex->alignment;
mob->sex = pMobIndex->sex;
if ( !pMobIndex->ac )
mob->armor = pMobIndex->ac;
else
mob->armor = interpolate( mob->level, 100, -100 );
if ( !pMobIndex->hitnodice )
mob->max_hit = mob->level * 8 + number_range(
mob->level * mob->level / 4,
mob->level * mob->level );
else
mob->max_hit = pMobIndex->hitnodice * number_range(1, pMobIndex->hitsizedice )
+ pMobIndex->hitplus;
mob->hit = mob->max_hit;
/* lets put things back the way they used to be! -Thoric */
mob->damroll = mob->level * 1;
mob->hitroll = mob->level * 1.5;
mob->gold = pMobIndex->gold;
mob->exp = pMobIndex->exp;
mob->position = pMobIndex->position;
mob->defposition = pMobIndex->defposition;
mob->barenumdie = pMobIndex->damnodice;
mob->baresizedie = pMobIndex->damsizedice;
mob->mobthac0 = pMobIndex->mobthac0;
mob->hitplus = pMobIndex->hitplus;
mob->damplus = pMobIndex->damplus;
mob->perm_str = pMobIndex->perm_str;
mob->perm_dex = pMobIndex->perm_dex;
mob->perm_wis = pMobIndex->perm_wis;
mob->perm_int = pMobIndex->perm_int;
mob->perm_con = pMobIndex->perm_con;
mob->perm_cha = pMobIndex->perm_cha;
mob->perm_lck = pMobIndex->perm_lck;
mob->race = pMobIndex->race;
mob->class = pMobIndex->class;
mob->xflags = pMobIndex->xflags;
mob->saving_poison_death = pMobIndex->saving_poison_death;
mob->saving_wand = pMobIndex->saving_wand;
mob->saving_para_petri = pMobIndex->saving_para_petri;
mob->saving_breath = pMobIndex->saving_breath;
mob->saving_spell_staff = pMobIndex->saving_spell_staff;
mob->height = pMobIndex->height;
mob->weight = pMobIndex->weight;
mob->resistant = pMobIndex->resistant;
mob->immune = pMobIndex->immune;
mob->susceptible = pMobIndex->susceptible;
mob->attacks = pMobIndex->attacks;
mob->defenses = pMobIndex->defenses;
mob->numattacks = pMobIndex->numattacks;
mob->speaks = pMobIndex->speaks;
mob->speaking = pMobIndex->speaking;
/*
* Insert in list.
*/
/* put it in the right list, thanks Thoric, --GW */
if ( fBootDb )
LINK(mob,pMobIndex->area->zone->first_mob,pMobIndex->area->zone->last_mob,next,prev);
else
LINK(mob,zone->first_mob,zone->last_mob, next,prev);
pMobIndex->count++;
nummobsloaded++;
return mob;
}
/*
* Create an instance of an object.
*/
OBJ_DATA *create_object( OBJ_INDEX_DATA *pObjIndex, int level,ZONE_DATA *zone )
{
OBJ_DATA *obj=NULL;
extern bool LOAD_LIMITED;
if ( !pObjIndex )
{
bug( "Create_object: NULL pObjIndex." );
return NULL;
}
/*
* Limits --GW
*/
if ( LOAD_LIMITED == TRUE )
{
if ( IS_SET( pObjIndex->second_flags, ITEM2_LIMITED ) &&
!IS_SET( pObjIndex->extra_flags, ITEM_PROTOTYPE ) )
{
if ( obj_limit_check(pObjIndex)==TRUE )
return NULL;
else
adjust_limits( pObjIndex, 1, LOADED_ADJUST_UP );
}
}
CREATE( obj, OBJ_DATA, 1 );
obj->pIndexData = pObjIndex;
obj->in_room = NULL;
obj->wear_loc = -1;
/* obj->deleted = FALSE;*/
if ( level > LEVEL_HYPERION )
level = LEVEL_HYPERION;
obj->level = level;
obj->count = 1;
cur_obj_serial = UMAX((cur_obj_serial + 1 ) & (BV30-1), 1);
obj->serial = obj->pIndexData->serial = cur_obj_serial;
obj->name = QUICKLINK( pObjIndex->name );
obj->short_descr = QUICKLINK( pObjIndex->short_descr );
obj->description = QUICKLINK( pObjIndex->description );
obj->action_desc = QUICKLINK( pObjIndex->action_desc );
obj->item_type = pObjIndex->item_type;
obj->extra_flags = pObjIndex->extra_flags;
obj->second_flags = pObjIndex->second_flags;
obj->wear_flags = pObjIndex->wear_flags;
obj->minlevel = pObjIndex->minlevel;
obj->ego = pObjIndex->ego;
obj->value[0] = pObjIndex->value[0];
obj->value[1] = pObjIndex->value[1];
obj->value[2] = pObjIndex->value[2];
obj->value[3] = pObjIndex->value[3];
obj->value[4] = pObjIndex->value[4];
obj->value[5] = pObjIndex->value[5];
obj->weight = pObjIndex->weight;
obj->cost = pObjIndex->cost;
/*
obj->cost = number_fuzzy( 10 )
* number_fuzzy( level ) * number_fuzzy( level );
*/
/*
* Mess with object properties.
*/
switch ( obj->item_type )
{
default:
bug( "Read_object: vnum %d bad type.", pObjIndex->vnum );
bug( "------------------------> ", obj->item_type );
break;
case ITEM_LIGHT:
case ITEM_TREASURE:
case ITEM_FURNITURE:
case ITEM_TRASH:
case ITEM_CONTAINER:
case ITEM_DRINK_CON:
case ITEM_KEY:
break;
case ITEM_FOOD:
/*
* optional food condition (rotting food) -Thoric
* value1 is the max condition of the food
* value4 is the optional initial condition
*/
if ( obj->value[4] )
obj->timer = obj->value[4];
else
obj->timer = obj->value[1];
break;
case ITEM_BOAT:
case ITEM_CORPSE_NPC:
case ITEM_CORPSE_PC:
case ITEM_FOUNTAIN:
case ITEM_BLOOD:
case ITEM_BLOODSTAIN:
case ITEM_SCRAPS:
case ITEM_PIPE:
case ITEM_HERB_CON:
case ITEM_HERB:
case ITEM_INCENSE:
case ITEM_FIRE:
case ITEM_BOOK:
case ITEM_SWITCH:
case ITEM_LEVER:
case ITEM_PULLCHAIN:
case ITEM_BUTTON:
case ITEM_DIAL:
case ITEM_RUNE:
case ITEM_RUNEPOUCH:
case ITEM_MATCH:
case ITEM_TRAP:
case ITEM_MAP:
case ITEM_PORTAL:
case ITEM_PAPER:
case ITEM_PEN:
case ITEM_TINDER:
case ITEM_LOCKPICK:
case ITEM_SPIKE:
case ITEM_DISEASE:
case ITEM_OIL:
case ITEM_FUEL:
case ITEM_QUIVER:
case ITEM_SHOVEL:
case ITEM_LIFE_PROTECTION:
case ITEM_INSIG:
case ITEM_SHRINE:
case ITEM_PK_BOOK:
case ITEM_VEHICLE:
break;
case ITEM_SALVE:
obj->value[3] = number_fuzzy( obj->value[3] );
break;
case ITEM_SCROLL:
obj->value[0] = number_fuzzy( obj->value[0] );
break;
case ITEM_WAND:
case ITEM_STAFF:
obj->value[0] = number_fuzzy( obj->value[0] );
obj->value[1] = number_fuzzy( obj->value[1] );
obj->value[2] = obj->value[1];
break;
case ITEM_MISSILE_WEAPON:
case ITEM_PROJECTILE:
case ITEM_WEAPON:
if ( obj->value[1] && obj->value[2] )
obj->value[2] *= obj->value[1];
else
{
obj->value[1] = number_fuzzy( number_fuzzy( 1 * level / 4 + 2 ) );
obj->value[2] = number_fuzzy( number_fuzzy( 3 * level / 4 + 6 ) );
}
if (obj->value[0] == 0)
obj->value[0] = INIT_WEAPON_CONDITION;
break;
case ITEM_ARMOR:
if ( obj->value[0] == 0 )
obj->value[0] = number_fuzzy( level / 4 + 2 );
if (obj->value[1] == 0)
obj->value[1] = obj->value[0];
break;
case ITEM_POTION:
case ITEM_PILL:
obj->value[0] = number_fuzzy( number_fuzzy( obj->value[0] ) );
break;
case ITEM_MONEY:
obj->value[0] = obj->cost;
break;
}
/* put it in the right list, thanks Thoric, --GW */
if ( fBootDb )
LINK( obj,pObjIndex->area->zone->first_obj,pObjIndex->area->zone->last_obj,next, prev );
else
LINK( obj,zone->first_obj,zone->last_obj,next,prev);
++pObjIndex->count;
++numobjsloaded;
++physicalobjects;
return obj;
}
/*
* Clear a new character.
*/
void clear_char( CHAR_DATA *ch )
{
ch->hunting = NULL;
ch->fearing = NULL;
ch->hating = NULL;
ch->name = NULL;
ch->short_descr = NULL;
ch->long_descr = NULL;
ch->description = NULL;
ch->next = NULL;
ch->prev = NULL;
ch->first_carrying = NULL;
ch->last_carrying = NULL;
ch->next_in_room = NULL;
ch->prev_in_room = NULL;
ch->fighting = NULL;
ch->switched = NULL;
ch->first_affect = NULL;
ch->last_affect = NULL;
ch->dest_buf = NULL;
ch->spare_ptr = NULL;
ch->mount = NULL;
xCLEAR_BITS(ch->affected_by);
ch->armor = 100;
ch->position = POS_STANDING;
ch->practice = 0;
ch->hit = 20;
ch->max_hit = 20;
ch->mana = 100;
ch->max_mana = 100;
ch->move = 100;
ch->max_move = 100;
ch->height = 72;
ch->weight = 180;
ch->xflags = 0;
ch->race = -1;
ch->class = -1;
ch->class2 = -1;
ch->advclass = -1;
ch->speaking = LANG_COMMON;
ch->speaks = LANG_COMMON;
ch->barenumdie = 1;
ch->baresizedie = 4;
ch->substate = 0;
ch->tempnum = 0;
ch->perm_str = 13;
ch->perm_dex = 13;
ch->perm_int = 13;
ch->perm_wis = 13;
ch->perm_cha = 13;
ch->perm_con = 13;
ch->perm_lck = 13;
ch->mod_str = 0;
ch->mod_dex = 0;
ch->mod_int = 0;
ch->mod_wis = 0;
ch->mod_cha = 0;
ch->mod_con = 0;
ch->mod_lck = 0;
ch->stun_rounds = 0; /* Not stunned to start */
/* ch->deleted = FALSE; Not Extracted --GW*/
return;
}
/*
* Free a character.
*/
void free_char( CHAR_DATA *ch )
{
OBJ_DATA *obj;
AFFECT_DATA *paf;
TIMER *timer;
MPROG_ACT_LIST *mpact, *mpact_next;
NOTE_DATA *comments, *comments_next;
sh_int pos=0;
/* To Catch Stale Pointers --GW */
/* if ( ch->deleted == TRUE )
return;*/
if ( !ch )
{
bug( "Free_char: null ch!" );
return;
}
if ( ch->desc )
bug( "Free_char: char still has descriptor." );
while ( (obj = ch->last_carrying) != NULL )
extract_obj( obj );
while ( (paf = ch->last_affect) != NULL )
affect_remove( ch, paf );
while ( (timer = ch->first_timer) != NULL )
extract_timer( ch, timer );
if( ch->name )
STRFREE( ch->name );
if( ch->short_descr )
STRFREE( ch->short_descr );
if( ch->long_descr )
STRFREE( ch->long_descr );
if( ch->description )
STRFREE( ch->description );
stop_hunting( ch );
stop_hating ( ch );
stop_fearing( ch );
free_fight ( ch );
if ( ch->pcdata )
{
for ( comments = ch->pcdata->comments; comments; comments = comments_next )
{
comments_next = comments->next;
STRFREE( comments->text );
STRFREE( comments->to_list );
STRFREE( comments->subject );
STRFREE( comments->sender );
STRFREE( comments->date );
DISPOSE( comments );
}
if ( ch->pcdata->pnote )
free_note( ch->pcdata->pnote );
if ( ch->pcdata->inter_editing )
DISPOSE( ch->pcdata->inter_editing );
if ( ch->pcdata->editor )
stop_editing( ch );
if ( ch->pcdata->gladiator )
STRFREE( ch->pcdata->gladiator );
/* Free thier maps --GW */
if ( ch->pcdata->color_maps )
free_char_colormaps(ch);
/* Free Psocials --GW */
if ( ch->pcdata->personal_socials )
free_char_psocials(ch);
/* Free there offline data */
if ( ch->pcdata->offline )
free_offline_data(ch);
/* Free Site Locks */
if ( ch->pcdata->first_host )
free_hosts(ch);
if ( ch->pcdata->clan_name )
STRFREE( ch->pcdata->clan_name );
if ( ch->pcdata->council_name )
STRFREE( ch->pcdata->council_name );
if ( ch->pcdata->pwd )
DISPOSE( ch->pcdata->pwd ); /* no hash */
if ( ch->pcdata->bamfin )
DISPOSE( ch->pcdata->bamfin ); /* no hash */
if ( ch->pcdata->bamfout )
DISPOSE( ch->pcdata->bamfout ); /* no hash */
if ( ch->pcdata->rank )
DISPOSE( ch->pcdata->rank );
if ( ch->pcdata->title )
STRFREE( ch->pcdata->title );
if ( ch->pcdata->bio )
STRFREE( ch->pcdata->bio );
if ( ch->pcdata->bestowments )
DISPOSE( ch->pcdata->bestowments ); /* no hash */
if ( ch->pcdata->homepage )
DISPOSE( ch->pcdata->homepage ); /* no hash */
if ( ch->pcdata->authed_by )
STRFREE( ch->pcdata->authed_by );
if ( ch->pcdata->prompt )
STRFREE( ch->pcdata->prompt );
if ( ch->pcdata->subprompt )
STRFREE( ch->pcdata->subprompt );
if ( ch->pcdata->email )
STRFREE( ch->pcdata->email );
if ( ch->pcdata->guild_name )
STRFREE( ch->pcdata->guild_name );
if ( ch->pcdata->deity_name )
STRFREE( ch->pcdata->deity_name );
if ( ch->pcdata->stitle )
STRFREE( ch->pcdata->stitle );
if ( ch->pcdata->rreply )
STRFREE( ch->pcdata->rreply );
if ( ch->pcdata->rreply_name )
STRFREE( ch->pcdata->rreply_name );
if ( ch->pcdata->helled_by )
STRFREE( ch->pcdata->helled_by );
if ( ch->pcdata->spouse )
STRFREE( ch->pcdata->spouse );
if ( ch->pcdata->engaged )
STRFREE( ch->pcdata->engaged );
if ( ch->pcdata->challenge_char_name )
STRFREE( ch->pcdata->challenge_char_name );
if ( ch->pcdata->name )
STRFREE( ch->pcdata->name );
/* Aliases --GW */
for( pos=0; pos < MAX_ALIAS; pos++ )
{
if ( ch->pcdata->alias[pos] != NULL )
STRFREE(ch->pcdata->alias[pos]);
if ( ch->pcdata->alias_sub[pos] != NULL )
STRFREE(ch->pcdata->alias_sub[pos]);
}
/* Ignores --GW */
for( pos=0; pos < MAX_IGNORE; pos++ )
{
if ( ch->pcdata->ignore[pos] != NULL )
STRFREE(ch->pcdata->ignore[pos]);
}
/* Com-Track --GW */
for( pos=0; pos < MAX_COM; pos++ );
{
if( ch->pcdata->comtrack[pos] != NULL && ch->pcdata->comtrack[pos][0] != '\0' )
STRFREE(ch->pcdata->comtrack[pos]);
if( ch->pcdata->lastcom[pos] != NULL && ch->pcdata->lastcom[pos][0] != '\0' )
STRFREE(ch->pcdata->lastcom[pos]);
}
if ( ch->pcdata->arena_viewing )
STRFREE( ch->pcdata->arena_viewing );
if ( ch->pcdata )
DISPOSE( ch->pcdata );
}
for ( mpact = ch->mpact; mpact; mpact = mpact_next )
{
mpact_next = mpact->next;
DISPOSE( mpact->buf );
DISPOSE( mpact );
}
/* ch->deleted = TRUE;*/
DISPOSE( ch );
return;
}
/*
* Get an extra description from a list.
*/
char *get_extra_descr( const char *name, EXTRA_DESCR_DATA *ed )
{
for ( ; ed; ed = ed->next )
if ( is_name( name, ed->keyword ) )
return ed->description;
return NULL;
}
/*
* Translates mob virtual number to its mob index struct.
* Hash table lookup. -- Zone Support Added -- GW
*/
MOB_INDEX_DATA *get_mob_index( sh_int vnum, sh_int zone )
{
MOB_INDEX_DATA *pMobIndex;
ZONE_DATA *in_zone;
if ( vnum < 0 )
vnum = 0;
if ( zone <= 0 )
zone = 1;
/*find the right zone, and use that index -- GW*/
if ((in_zone = find_zone(zone))==NULL)
{
bug("Get_mob_index: ZONE ACCESS VIOLATION!! (*FATAL*)",0);
return NULL;
}
for ( pMobIndex = in_zone->mob_index_hash[vnum % MAX_KEY_HASH];
pMobIndex;
pMobIndex = pMobIndex->next )
if ( pMobIndex->vnum == vnum )
return pMobIndex;
/* if ( fBootDb ) <-- What an Annoyance. --GW
* bug( "Get_mob_index: bad vnum %d.", vnum );
*/
return NULL;
}
/*
* Translates obj virtual number to its obj index struct.
* Hash table lookup. -- Zone Support Added -- GW
*/
OBJ_INDEX_DATA *get_obj_index( int vnum, int zone )
{
OBJ_INDEX_DATA *pObjIndex;
ZONE_DATA *in_zone;
if ( vnum < 0 )
vnum = 0;
if ( zone <= 0 )
zone = 1;
/*find the right zone, and use that index -- GW*/
if ((in_zone = find_zone(zone))==NULL)
{
bug("Get_obj_index: ZONE ACCESS VIOLATION!! (*FATAL*)",0);
return NULL;
}
for ( pObjIndex = in_zone->obj_index_hash[vnum % MAX_KEY_HASH];
pObjIndex;
pObjIndex = pObjIndex->next )
if ( pObjIndex->vnum == vnum )
return pObjIndex;
return NULL;
}
/*
* Translates room virtual number to its room index struct.
* Hash table lookup. -- Zone Support Added -- GW
*/
ROOM_INDEX_DATA *get_room_index( int vnum, int zone )
{
ROOM_INDEX_DATA *pRoomIndex;
ZONE_DATA *in_zone;
if ( vnum < 0 )
vnum = 0;
if ( zone <= 0 )
zone = 1;
/*find the right zone, and use that index -- GW*/
if ((in_zone = find_zone(zone))==NULL)
{
bug("Get_room_index: ZONE ACCESS VIOLATION!! (*FATAL*)",0);
return NULL;
}
for ( pRoomIndex = in_zone->room_index_hash[vnum % MAX_KEY_HASH];
pRoomIndex;
pRoomIndex = pRoomIndex->next )
if ( pRoomIndex->vnum == vnum )
return pRoomIndex;
return NULL;
}
ZONE_DATA *find_zone( int zone )
{
ZONE_DATA *in_zone;
if ( zone > top_zone )
zone = top_zone;
if ( zone <= 0 )
zone = 1;
/* search for the zone */
for( in_zone = first_zone; in_zone; in_zone = in_zone->next)
{
if (in_zone->number == zone )
{ /* zone found, return the data */
return in_zone;
}
}
/* zone not found */
return find_zone(1);
}
/*
* Added lots of EOF checks, as most of the file crashes are based on them.
* If an area file encounters EOF, the fread_* functions will shutdown the
* MUD, as all area files should be read in in full or bad things will
* happen during the game. Any files loaded in without fBootDb which
* encounter EOF will return what they have read so far. These files
* should include player files, and in-progress areas that are not loaded
* upon bootup.
* -- Altrag
*/
/*
* Read a letter from a file.
*/
char fread_letter( FILE *fp )
{
char c;
do
{
if ( feof(fp) )
{
bug("fread_letter: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
return '\0';
}
c = getc( fp );
}
while ( isspace(c) );
return c;
}
/*
* Read a number from a file.
*/
long fread_number( FILE *fp )
{
long number;
bool sign;
char c;
do
{
if ( feof(fp) )
{
bug("fread_number: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
return 0;
}
c = getc( fp );
}
while ( isspace(c) );
number = 0;
sign = FALSE;
if ( c == '+' )
{
c = getc( fp );
}
else if ( c == '-' )
{
sign = TRUE;
c = getc( fp );
}
if ( c == '\0' )
return 0;
if ( !isdigit(c) )
{
bug( "Fread_number: bad format. (%c)", c );
if ( fBootDb )
exit( 1 );
return 0;
}
while ( isdigit(c) )
{
if ( feof(fp) )
{
bug("fread_number: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
return number;
}
number = number * 10 + c - '0';
c = getc( fp );
}
if ( sign )
number = 0 - number;
if ( c == '|' )
number += fread_number( fp );
else if ( c != ' ' )
ungetc( c, fp );
return number;
}
/*
* custom str_dup using create -Thoric
*/
char *str_dup( char const *str )
{
char *ret=NULL;
int len=0;
if ( !str )
return NULL;
len = strlen(str)+1;
CREATE( ret, char, len );
strcpy( ret, str );
return ret;
}
/*
* Read a string from file fp
*/
char *fread_string( FILE *fp )
{
char buf[MAX_STRING_LENGTH];
char *plast;
char c;
int ln;
plast = buf;
buf[0] = '\0';
ln = 0;
/*
* Skip blanks.
* Read first char.
*/
do
{
if ( feof(fp) )
{
bug("fread_string: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
return STRALLOC("");
}
c = getc( fp );
}
while ( isspace(c) );
if ( ( *plast++ = c ) == '~' )
return STRALLOC( "" );
for ( ;; )
{
if ( ln >= (MAX_STRING_LENGTH - 1) )
{
bug( "fread_string: string too long" );
*plast = '\0';
return STRALLOC( buf );
}
switch ( *plast = getc( fp ) )
{
default:
plast++; ln++;
break;
case EOF:
bug( "Fread_string: EOF" );
if ( fBootDb )
exit( 1 );
*plast = '\0';
return STRALLOC(buf);
break;
case '\n':
plast++; ln++;
*plast++ = '\r'; ln++;
break;
case '\r':
break;
case '~':
*plast = '\0';
return STRALLOC( buf );
}
}
}
/*
* Read a string from file fp using str_dup (ie: no string hashing)
*/
char *fread_string_nohash( FILE *fp )
{
char buf[MAX_STRING_LENGTH];
char *plast;
char c;
int ln;
plast = buf;
buf[0] = '\0';
ln = 0;
/*
* Skip blanks.
* Read first char.
*/
do
{
if ( feof(fp) )
{
bug("fread_string_no_hash: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
return str_dup("");
}
c = getc( fp );
}
while ( isspace(c) );
if ( ( *plast++ = c ) == '~' )
return str_dup( "" );
for ( ;; )
{
if ( ln >= (MAX_STRING_LENGTH - 1) )
{
bug( "fread_string_no_hash: string too long" );
*plast = '\0';
return str_dup( buf );
}
switch ( *plast = getc( fp ) )
{
default:
plast++; ln++;
break;
case EOF:
bug( "Fread_string_no_hash: EOF" );
if ( fBootDb )
exit( 1 );
*plast = '\0';
return str_dup(buf);
break;
case '\n':
plast++; ln++;
*plast++ = '\r'; ln++;
break;
case '\r':
break;
case '~':
*plast = '\0';
return str_dup( buf );
}
}
}
/*
* Read to end of line (for comments).
*/
void fread_to_eol( FILE *fp )
{
char c;
do
{
if ( feof(fp) )
{
bug("fread_to_eol: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
return;
}
c = getc( fp );
}
while ( c != '\n' && c != '\r' );
do
{
c = getc( fp );
}
while ( c == '\n' || c == '\r' );
ungetc( c, fp );
return;
}
/*
* Read to end of line into static buffer -Thoric
*/
char *fread_line( FILE *fp )
{
static char line[MAX_STRING_LENGTH];
char *pline;
char c;
int ln;
pline = line;
line[0] = '\0';
ln = 0;
/*
* Skip blanks.
* Read first char.
*/
do
{
if ( feof(fp) )
{
bug("fread_line: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
strcpy(line, "");
return line;
}
c = getc( fp );
}
while ( isspace(c) );
ungetc( c, fp );
do
{
if ( feof(fp) )
{
bug("fread_line: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
*pline = '\0';
return line;
}
c = getc( fp );
*pline++ = c; ln++;
if ( ln >= (MAX_STRING_LENGTH - 1) )
{
bug( "fread_line: line too long" );
break;
}
}
while ( c != '\n' && c != '\r' );
do
{
c = getc( fp );
}
while ( c == '\n' || c == '\r' );
ungetc( c, fp );
*pline = '\0';
return line;
}
/*
* Read one word (into static buffer).
*/
char *fread_word( FILE *fp )
{
static char word[MAX_INPUT_LENGTH];
char *pword;
char cEnd;
do
{
if ( feof(fp) )
{
bug("fread_word: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
word[0] = '\0';
return word;
}
cEnd = getc( fp );
}
while ( isspace( cEnd ) );
if ( cEnd == '\'' || cEnd == '"' )
{
pword = word;
}
else
{
word[0] = cEnd;
pword = word+1;
cEnd = ' ';
}
for ( ; pword < word + MAX_INPUT_LENGTH; pword++ )
{
if ( feof(fp) )
{
bug("fread_word: EOF encountered on read.\n\r");
if ( fBootDb )
exit(1);
*pword = '\0';
return word;
}
*pword = getc( fp );
if ( cEnd == ' ' ? isspace(*pword) : *pword == cEnd )
{
if ( cEnd == ' ' )
ungetc( *pword, fp );
*pword = '\0';
return word;
}
}
bug( "Fread_word: word too long" );
exit( 1 );
return NULL;
}
void do_memory( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
int hash;
CHAR_DATA *wch;
extern bool limits_off;
extern bool LOAD_LIMITED;
argument = one_argument( argument, arg );
ch_printf( ch, "Affects %5d Areas %5d\n\r", top_affect, top_area );
ch_printf( ch, "ExtDes %5d Exits %5d\n\r", top_ed, top_exit );
ch_printf( ch, "Helps %5d Resets %5d\n\r", top_help, top_reset );
ch_printf( ch, "IdxMobs %5d Mobs %5d\n\r", top_mob_index, nummobsloaded );
ch_printf( ch, "IdxObjs %5d Objs %5d (%d)\n\r", top_obj_index, numobjsloaded, physicalobjects );
ch_printf( ch, "Rooms %5d VRooms %5d\n\r", top_room, top_vroom );
ch_printf( ch, "Shops %5d RepShps %5d\n\r", top_shop, top_repair );
ch_printf( ch, "CurOq's %5d CurCq's %5d\n\r", cur_qobjs, cur_qchars );
ch_printf( ch, "Players %5d Maxplrs %5d\n\r", num_descriptors, sysdata.maxplayers );
ch_printf( ch, "MaxEver %5d Topsn %5d (%d)\n\r", sysdata.alltimemax, top_sn, MAX_SKILL );
ch_printf( ch, "MaxEver time recorded at: %s\n\r", sysdata.time_of_max );
ch_printf( ch, "Limits: %s LOAD_LIMITED: %s\n\r",
limits_off ? "OFF" : "ON", LOAD_LIMITED ? "Alter Limits As Needed" : "Donot Alter Limits at this time." );
if ( !str_cmp( arg, "check" ) )
{
#ifdef HASHSTR
send_to_char( check_hash(argument), ch );
#else
send_to_char( "Hash strings not enabled.\n\r", ch );
#endif
return;
}
if ( !str_cmp( arg, "showhigh" ) )
{
#ifdef HASHSTR
show_high_hash( atoi(argument) );
#else
send_to_char( "Hash strings not enabled.\n\r", ch );
#endif
return;
}
if ( argument[0] != '\0' )
hash = atoi(argument);
else
hash = -1;
if ( !str_cmp( arg, "hash" ) )
{
#ifdef HASHSTR
ch_printf( ch, "Hash statistics:\n\r%s", hash_stats() );
if ( hash != -1 )
hash_dump( hash );
#else
send_to_char( "Hash strings not enabled.\n\r", ch );
#endif
}
if ( !str_cmp( arg, "roomlist" ) )
{
send_to_char("Linked Char->in_room listing (ALL)\n\r",ch);
if ( !ch->in_room || !ch->in_room->first_person )
{
send_to_char("Fatal ERROR\n",ch);
return;
}
for( wch = ch->in_room->first_person; wch; wch = wch->next_in_room)
{
if (!wch)
{
send_to_char("Warning: Null Wch in List.\n",ch);
break;
}
if ( !wch->name )
send_to_char("WARNING -- NULL CHAR IN LIST HERE!\n",ch);
else
ch_printf( ch, "Ch: %s Zone: %d Vnum: %d Master: %s Area: %s\n",wch->name,wch->in_room->area->zone->number,
wch->in_room->vnum,wch->master, ch->in_room->area->filename);
}
}
if ( !str_cmp( arg, "limitlist" ) )
{
extern LIMIT_DATA *first_limit;
LIMIT_DATA *limit, *next_limit;
char limit_buf[MSL];
for( limit = first_limit; limit; limit = next_limit )
{
next_limit = limit->next;
sprintf(limit_buf,"Z:%d Vnum: %d Loaded: %d Limit: %d\n\r",limit->zone,limit->vnum,
limit->loaded, limit->limit);
send_to_char(limit_buf,ch);
}
}
if ( !str_cmp( arg, "charlist" ) )
{
send_to_char("Linked Char Listing (!NPC):\n\r",ch);
for ( wch = first_char; wch; wch = wch->next )
{
if ( !wch )
{
send_to_char("Warning: Null Wch in list.\n",ch);
continue;
}
/* if ( !IS_NPC(wch) )
{*/
if ( !wch->name )
send_to_char("WARNING -- NULL CHAR IN LIST HERE!\n",ch);
else
ch_printf( ch, "%s\n",wch->name);
/* }*/
}
}
if ( !str_cmp(arg,"cleanpk"))
pk_list_cleaner();
if ( !str_cmp(arg,"overlimit") )
{
overlimit_msg();
show_overlimit(ch);
}
if ( !str_cmp(arg,"inroomupdate"))
inroom_update();
return;
}
/*
* Stick a little fuzz on a number.
*/
int number_fuzzy( int number )
{
switch ( number_bits( 2 ) )
{
case 0: number -= 1; break;
case 3: number += 1; break;
}
return UMAX( 1, number );
}
/*
* Generate a random number.
*/
long number_range( int from, int to )
{
/* int power;
int number;*/
if ( ( to = to - from + 1 ) <= 1 )
return from;
/* for ( power = 2; power < to; power <<= 1 )
;
while ( ( number = number_mm( ) & (power - 1) ) >= to )
;
return from + number;*/
return (number_mm() % to) + from;
}
/*
* Generate a percentile roll.
*/
int number_percent( void )
{
/* int percent;
while ( ( percent = number_mm( ) & (128-1) ) > 99 )
;
return 1 + percent;*/
return number_mm() % 100;
}
/*
* Generate a random door.
*/
int number_door( void )
{
int door;
while ( ( door = number_mm( ) & (16-1) ) > 9 )
;
return door;
/* return number_mm() & 10; */
}
int number_bits( int width )
{
return number_mm( ) & ( ( 1 << width ) - 1 );
}
/*
* I've gotten too many bad reports on OS-supplied random number generators.
* This is the Mitchell-Moore algorithm from Knuth Volume II.
* Best to leave the constants alone unless you've read Knuth.
* -- Furey
*/
static int rgiState[2+55];
void init_mm( )
{
int *piState;
int iState;
piState = &rgiState[2];
piState[-2] = 55 - 55;
piState[-1] = 55 - 24;
piState[0] = ((int) current_time) & ((1 << 30) - 1);
piState[1] = 1;
for ( iState = 2; iState < 55; iState++ )
{
piState[iState] = (piState[iState-1] + piState[iState-2])
& ((1 << 30) - 1);
}
return;
}
long number_mm( void )
{
int *piState;
long iState1;
long iState2;
long iRand;
piState = &rgiState[2];
iState1 = piState[-2];
iState2 = piState[-1];
iRand = (piState[iState1] + piState[iState2])
& ((1 << 30) - 1);
piState[iState1] = iRand;
if ( ++iState1 == 55 )
iState1 = 0;
if ( ++iState2 == 55 )
iState2 = 0;
piState[-2] = iState1;
piState[-1] = iState2;
return iRand >> 6;
}
/*
* Roll some dice. -Thoric
*/
int dice( int number, int size )
{
int idice;
int sum;
switch ( size )
{
case 0: return 0;
case 1: return number;
}
for ( idice = 0, sum = 0; idice < number; idice++ )
sum += number_range( 1, size );
return sum;
}
/*
* Simple linear interpolation.
*/
int interpolate( int level, int value_00, int value_32 )
{
return value_00 + level * (value_32 - value_00) / 32;
}
/*
* Removes the tildes from a string.
* Used for player-entered strings that go into disk files.
*/
void smash_tilde( char *str )
{
for ( ; *str != '\0'; str++ )
if ( *str == '~' )
*str = '-';
return;
}
/*
* Encodes the tildes in a string. -Thoric
* Used for player-entered strings that go into disk files.
*/
void hide_tilde( char *str )
{
for ( ; *str != '\0'; str++ )
if ( *str == '~' )
*str = HIDDEN_TILDE;
return;
}
char *show_tilde( char *str )
{
static char buf[MAX_STRING_LENGTH];
char *bufptr;
bufptr = buf;
for ( ; *str != '\0'; str++, bufptr++ )
{
if ( *str == HIDDEN_TILDE )
*bufptr = '~';
else
*bufptr = *str;
}
*bufptr = '\0';
return buf;
}
/*
* Compare strings, case insensitive.
* Return TRUE if different
* (compatibility with historical functions).
*/
bool str_cmp( const char *astr, const char *bstr )
{
if ( !astr )
{
bug( "Str_cmp: null astr." );
if ( bstr )
fprintf( stderr, "str_cmp: astr: (null) bstr: %s\n", bstr );
return TRUE;
}
if ( !bstr )
{
bug( "Str_cmp: null bstr." );
bug( astr );
if ( astr )
fprintf( stderr, "str_cmp: astr: %s bstr: (null)\n", astr );
return TRUE;
}
for ( ; *astr || *bstr; astr++, bstr++ )
{
if ( LOWER(*astr) != LOWER(*bstr) )
return TRUE;
}
return FALSE;
}
/*
* Compare strings, case insensitive, for prefix matching.
* Return TRUE if astr not a prefix of bstr
* (compatibility with historical functions).
*/
bool str_prefix( const char *astr, const char *bstr )
{
if ( !astr )
{
bug( "Strn_cmp: null astr." );
return TRUE;
}
if ( !bstr )
{
bug( "Strn_cmp: null bstr." );
return TRUE;
}
for ( ; *astr; astr++, bstr++ )
{
if ( LOWER(*astr) != LOWER(*bstr) )
return TRUE;
}
return FALSE;
}
/*
* Compare strings, case insensitive, for match anywhere.
* Returns TRUE is astr not part of bstr.
* (compatibility with historical functions).
*/
bool str_infix( const char *astr, const char *bstr )
{
int sstr1;
int sstr2;
int ichar;
char c0;
if ( ( c0 = LOWER(astr[0]) ) == '\0' )
return FALSE;
sstr1 = strlen(astr);
sstr2 = strlen(bstr);
for ( ichar = 0; ichar <= sstr2 - sstr1; ichar++ )
if ( c0 == LOWER(bstr[ichar]) && !str_prefix( astr, bstr + ichar ) )
return FALSE;
return TRUE;
}
/*
* Compare strings, case insensitive, for suffix matching.
* Return TRUE if astr not a suffix of bstr
* (compatibility with historical functions).
*/
bool str_suffix( const char *astr, const char *bstr )
{
int sstr1;
int sstr2;
if ( !astr Showing the first 100 KB of 175.3 KB. Download the archive for the full file.