/* Reads the actual time file from disk - Samson 1-21-99 */ void fread_timedata( FILE * fp ) { char *word = NULL; bool fMatch = FALSE; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'E': if( !str_cmp( word, "End" ) ) return; break; case 'P': KEY( "Purgetime", new_pfile_time_t, fread_number( fp ) ); break; } if( !fMatch ) { bug( "Fread_timedata: no match: %s", word ); fread_to_eol( fp ); } } }
/* Snarf a MOBprogram section from the area file. */ bool load_mobprogs( FILE *fp ) { MOB_INDEX_DATA *iMob; MPROG_DATA *original; MPROG_DATA *working; char letter; int value; int stat; bool koniec = FALSE; while ( !koniec ) { letter = fread_letter( fp ); switch ( letter ) { default: cbug( "Load_mobprogs: bad command '%c'.", letter ); return TRUE; case 'S': case 's': fread_to_eol( fp ); koniec = TRUE; break; case '*': fread_to_eol( fp ); break; case 'M': case 'm': value = fread_number( fp, &stat ); if ( ( iMob = get_mob_index( value ) ) == NULL ) { cbug( "Load_mobprogs: vnum %d doesnt exist", value ); return TRUE; } /* Go to the end of the prog command list if other commands exist */ if ( ( original = iMob->mobprogs ) ) for ( ; original->next != NULL; original = original->next ) ; working = new_mprog( ); if ( original ) original->next = working; else iMob->mobprogs = working; working = mprog_file_read( fread_word( fp, &stat, TRUE ), working, iMob, 0 ); if ( !working ) return TRUE; working->next = NULL; fread_to_eol( fp ); break; } } return FALSE; }
area_data *fread_smaugfuss_area( FILE * fp ) { area_data *tarea = nullptr; for( ;; ) { char letter; const char *word; letter = fread_letter( fp ); if( letter == '*' ) { fread_to_eol( fp ); continue; } if( letter != '#' ) { bug( "%s: # not found. Invalid format.", __func__ ); if( fBootDb ) exit( 1 ); break; } word = ( feof( fp ) ? "ENDAREA" : fread_word( fp ) ); if( word[0] == '\0' ) { bug( "%s: EOF encountered reading file!", __func__ ); word = "ENDAREA"; } if( !str_cmp( word, "AREADATA" ) ) { tarea = create_area( ); tarea->filename = str_dup( strArea ); fread_fuss_areadata( fp, tarea ); } else if( !str_cmp( word, "MOBILE" ) ) fread_fuss_mobile( fp, tarea ); else if( !str_cmp( word, "OBJECT" ) ) fread_fuss_object( fp, tarea ); else if( !str_cmp( word, "ROOM" ) ) fread_fuss_room( fp, tarea ); else if( !str_cmp( word, "ENDAREA" ) ) break; else { bug( "%s: Bad section header: %s", __func__, word ); fread_to_eol( fp ); } } return tarea; }
/* * Snarf spec proc declarations. */ void load_specials( 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 ) ); 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 ); } }
NOTE_DATA * read_log( FILE *fp ) { NOTE_DATA * log; char * word; log = alloc_mem( sizeof( NOTE_DATA ) ); for ( ; ; ) { word = fread_word( fp ); if ( !str_cmp( word, "Sender" ) ) log->sender = fread_string( fp ); else if ( !str_cmp( word, "Date" ) ) log->date = fread_string( fp ); else if ( !str_cmp( word, "Subject" ) ) log->subject = fread_string( fp ); else if ( !str_cmp( word, "Text" ) ) log->text = fread_string( fp ); else if ( !str_cmp( word, "Endlog" ) ) { fread_to_eol( fp ); log->next = NULL; return log; } else { free_mem( log, sizeof( NOTE_DATA ) ); bug( "read_log: bad key word.", 0 ); return NULL; } } }
void load_wizlist(void) { FILE *fp; WIZ_DATA *wiz_last; if ( ( fp = fopen( WIZ_FILE, "r" ) ) == NULL ) { return; } wiz_last = NULL; for ( ; ; ) { WIZ_DATA *pwiz; if ( feof(fp) ) { fclose( fp ); return; } pwiz = new_wiz(); pwiz->name = str_dup(fread_word(fp)); pwiz->level = fread_number(fp); fread_to_eol(fp); if (wiz_list == NULL) wiz_list = pwiz; else wiz_last->next = pwiz; wiz_last = pwiz; } }
void read_race_info (void) { FILE *fp; int i = 0; char wrd[256]; if ((fp = fopen ("races.dat", "r")) == NULL) { fprintf (stderr, "Races.dat could not be opened!!\n"); exit (7); } for (;;) { strcpy (wrd, fread_word (fp)); if (!str_cmp ("END", wrd)) break; if (!str_prefix ("#", wrd)) { fread_to_eol (fp); continue; } strcpy (race_info[i].name, wrd); race_info[i].bonus[0] = fread_number (fp); race_info[i].bonus[1] = fread_number (fp); race_info[i].bonus[2] = fread_number (fp); race_info[i].bonus[3] = fread_number (fp); race_info[i].bonus[4] = fread_number (fp); race_info[i].limits[0] = fread_number (fp); race_info[i].limits[1] = fread_number (fp); race_info[i].limits[2] = fread_number (fp); race_info[i].limits[3] = fread_number (fp); race_info[i].limits[4] = fread_number (fp); race_info[i].start_room = fread_number (fp); race_info[i].max_skills = fread_number (fp); race_info[i].max_spells = fread_number (fp); race_info[i].max_profs = fread_number (fp); race_info[i].height_min = fread_number (fp); race_info[i].height_max = fread_number (fp); race_info[i].affect_bits = fread_number (fp); race_info[i].affect_bits2 = fread_number (fp); race_info[i].nat_augments = fread_number (fp); race_info[i].natarmor = fread_number (fp); race_info[i].regen_hit_percent = fread_number (fp); race_info[i].regen_move_percent = fread_number (fp); race_info[i].switch_aligns = fread_number (fp); race_info[i].attack_spell_percent = fread_number (fp); race_info[i].combat_damage_bonus = fread_number (fp); race_info[i].backstab_percent = fread_number (fp); race_info[i].heal_percent = fread_number (fp); race_info[i].hps_bonus = fread_number (fp); race_info[i].mana_percent = fread_number (fp); race_info[i].nat_skills[0] = fread_number(fp); race_info[i].nat_skills[1] = fread_number(fp); race_info[i].nat_skills[2] = fread_number(fp); race_info[i].remort_race = fread_number (fp); i++; } fclose (fp); return; }
/* * Snarf a shop section. */ void load_shops( FILE *fp ) { SHOP_DATA *pShop; for ( ; ; ) { MOB_INDEX_DATA *pMobIndex; int iTrade; pShop = alloc_perm( sizeof(*pShop) ); 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->open_hour = fread_number( fp ); pShop->close_hour = fread_number( fp ); fread_to_eol( fp ); pMobIndex = get_mob_index( pShop->keeper ); pMobIndex->pShop = pShop; if ( shop_first == NULL ) shop_first = pShop; if ( shop_last != NULL ) shop_last->next = pShop; shop_last = pShop; pShop->next = NULL; top_shop++; } return; }
void load_bans(void) { FILE *fp; BAN_DATA *ban_last; strcat(boot_buf,"ators.\n\r Le"); if ( ( fp = fopen( BAN_FILE, "r" ) ) == NULL ) return; ban_last = NULL; for ( ; ; ) { BAN_DATA *pban; if ( feof(fp) ) { fclose( fp ); return; } pban = new_ban(); pban->name = str_dup(fread_word(fp)); pban->level = fread_number(fp); pban->ban_flags = fread_flag(fp); fread_to_eol(fp); if (ban_list == NULL) ban_list = pban; else ban_last->next = pban; ban_last = pban; } }
void load_materials(void) { bool fMatch; closeReserve(); FILE *fp = fopen(MATERIAL_FILE, "r"); if(!fp) return; // no materials to load. while(true) { const char *word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; if(!str_cmp(word, "End")) { break; } if(!str_cmp(word, "MAT")) { MAT_TYPE *mat = new_mat(); while(true) { word = feof( fp ) ? "End" : fread_word(fp); if(!str_cmp(word, "End")) { bug(Format("Prematurely reached end of materials data file; data corrupted!"), 0); fclose(fp); openReserve(); return; } bool finished = false; switch ( UPPER(word[0]) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'E': if(!str_cmp(word, "ENDMAT")) { mat->next = mat_list; mat_list = mat; matValue++; finished = true; break; } case 'V': KEY("VAL", mat->assignedValue, fread_number(fp) ); break; case 'N': KEYS( "NAME", mat->name, fread_string(fp) ); break; } if(finished) break; } } } fclose(fp); openReserve(); }
/* * Load a realm file */ bool load_realm_file( const char *realmfile ) { char filename[256]; realm_data *realm; FILE *fp; bool found; realm = new realm_data; clean_realm( realm ); /* Default settings so we don't get wierd ass stuff */ found = false; snprintf( filename, 256, "%s%s", REALM_DIR, realmfile ); if( ( fp = fopen( filename, "r" ) ) != nullptr ) { found = true; for( ;; ) { char letter; char *word; letter = fread_letter( fp ); if( letter == '*' ) { fread_to_eol( fp ); continue; } if( letter != '#' ) { bug( "%s: # not found.", __func__ ); break; } word = fread_word( fp ); if( !str_cmp( word, "REALM" ) ) fread_realm( realm, fp ); else if( !str_cmp( word, "ROSTER" ) ) fread_realm_memberlist( realm, fp ); else if( !str_cmp( word, "END" ) ) break; else { bug( "%s: bad section: %s.", __func__, word ); break; } } FCLOSE( fp ); } if( found ) realmlist.push_back( realm ); else deleteptr( realm ); return found; }
/* * This function reads one immortal host to a file. * Shaddai July 27, 1997 */ int fread_imm_host( FILE * fp, IMMORTAL_HOST * data ) { const char *word; bool fMatch; int temp; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case 'E': if( !str_cmp( word, "End" ) ) return rNONE; case 'H': KEY( "Host", data->host, fread_string_nohash( fp ) ); break; case 'N': KEY( "Name", data->name, fread_string_nohash( fp ) ); break; case 'P': if( !str_cmp( word, "Prefix" ) ) { temp = fread_number( fp ); if( temp ) data->prefix = TRUE; else data->prefix = FALSE; fMatch = TRUE; } break; case 'S': if( !str_cmp( word, "Suffix" ) ) { temp = fread_number( fp ); if( temp ) data->suffix = TRUE; else data->suffix = FALSE; fMatch = TRUE; } break; } if( !fMatch ) { bug( "%s: no match: %s", __func__, word ); fread_to_eol( fp ); } } }
/* * Funzione di lettura delle liste, cioè dei file *.lst. */ void fread_list( const char *list_file, const char *section, FREAD_FUN *freadfun, bool unique ) { MUD_FILE *fp; fp = mud_fopen( "", list_file, "r", TRUE ); if ( !fp ) { if ( fBootDb ) exit( EXIT_FAILURE ); return; } for ( ; ; ) { char *filename; if ( feof(fp->file) ) { send_log( fp, LOG_FREAD, "fread_: fine del file prematuro nella lettura" ); if ( fBootDb ) exit( EXIT_FAILURE ); } filename = fread_word( fp ); if ( filename[0] == '*' ) /* Salta i commenti */ { fread_to_eol( fp ); continue; } /* Se arrivato alla fine esce */ if ( !str_cmp(filename, "End") ) break; /* Legge l'area se si tratta di una sezione file di area */ if ( !str_cmp(section, "AREA_FILE") && freadfun == NULL ) { MUD_FILE *fp_area; fp_area = mud_fopen( "", filename, "r", TRUE ); if ( !fp_area ) { if ( fBootDb ) exit( EXIT_FAILURE ); return; } load_area_file( NULL, fp_area ); } else fread_section( filename, section, freadfun, unique ); /* Legge la sezione relativa al file ricavato dalla lista */ } MUD_FCLOSE( fp ); }
void load_socials( void ) { FILE *fp; int stat; char strsave [ MAX_INPUT_LENGTH ]; fclose( fpReserve ); sprintf( strsave, "%s%s", SYSTEM_DIR, SOCIAL_FILE ); if ( !( fp = fopen( strsave, "r" ) ) ) { bug( "Cannot open SOCIALS.TXT", 0 ); exit( 0 ); } for ( ; ; ) { int letter; char *word; letter = fread_letter( fp ); if ( letter == '*' ) { fread_to_eol( fp ); continue; } if ( letter != '#' ) { bug( "Load_socials: # not found.", 0 ); break; } word = fread_word( fp, &stat ); if ( !str_cmp( word, "SOCIAL" ) ) { fread_social( fp ); continue; } else if ( !str_cmp( word, "END" ) ) break; else { bug( "Load_socials: bad section.", 0 ); continue; } } fclose( fp ); fpReserve = fopen( NULL_FILE, "r" ); return; }
void load_herb_table( ) { FILE *fp; if( ( fp = fopen( HERB_FILE, "r" ) ) != NULL ) { top_herb = 0; for( ;; ) { char letter; const char *word; letter = fread_letter( fp ); if( letter == '*' ) { fread_to_eol( fp ); continue; } if( letter != '#' ) { bug( "Load_herb_table: # not found.", 0 ); break; } word = fread_word( fp ); if( !str_cmp( word, "HERB" ) ) { if( top_herb >= MAX_HERB ) { bug( "load_herb_table: more herbs than MAX_HERB %d", MAX_HERB ); fclose( fp ); return; } herb_table[top_herb++] = fread_skill( fp, FALSE ); if( herb_table[top_herb - 1]->slot == 0 ) herb_table[top_herb - 1]->slot = top_herb - 1; continue; } else if( !str_cmp( word, "END" ) ) break; else { bug( "Load_herb_table: bad section.", 0 ); continue; } } fclose( fp ); } else { bug( "Cannot open herbs.dat", 0 ); exit( 0 ); } }
/* * Load all those nasty bans up :) * Shaddai */ void load_banlist( void ) { const char *word; FILE *fp; bool fMatch = FALSE; if( !( fp = fopen( SYSTEM_DIR BAN_LIST, "r" ) ) ) { bug( "%s: Cannot open %s", __func__, BAN_LIST ); perror( BAN_LIST ); return; } for( ;; ) { word = feof( fp ) ? "END" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case 'C': if( !str_cmp( word, "CLASS" ) ) { fread_ban( fp, BAN_CLASS ); fMatch = TRUE; } break; case 'E': if( !str_cmp( word, "END" ) ) /*File should always contain END */ { fclose( fp ); log_string( "Done." ); return; } case 'R': if( !str_cmp( word, "RACE" ) ) { fread_ban( fp, BAN_RACE ); fMatch = TRUE; } break; case 'S': if( !str_cmp( word, "SITE" ) ) { fread_ban( fp, BAN_SITE ); fMatch = TRUE; } break; } if( !fMatch ) { bug( "Load_banlist: no match: %s", word ); fread_to_eol( fp ); } /* End of switch statement */ } /* End of for loop */ }
void load_disciplines( ) { FILE *fp; if( ( fp = fopen( DISCIPLINE_FILE, "r" ) ) != NULL ) { for( ;; ) { char letter; const char *word; letter = fread_letter( fp ); if( letter == '*' ) { fread_to_eol( fp ); continue; } if( letter != '#' ) { bug( "Load_disciplines: # not found.", 0 ); break; } word = fread_word( fp ); if( !str_cmp( word, "DISCIPLINE" ) ) { DISC_DATA *discipline; if( ( discipline = fread_discipline( fp ) ) == NULL ) { bug( "Huge error loading disciplines.", 0 ); fclose( fp ); return; } LINK( discipline, first_discipline, last_discipline, next, prev ); continue; } else if( !str_cmp( word, "END" ) ) break; else { bug( "Load_disciplines: bad section.", 0 ); continue; } } fclose( fp ); } else { bug( "Cannot open discipline.dat", 0 ); exit( 0 ); } return; }
/* Reads the actual time file from disk - Samson 1-21-99 */ void fread_timedata( FILE * fp ) { const char *word; bool fMatch = FALSE; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'E': if( !str_cmp( word, "End" ) ) return; break; case 'M': KEY( "Mhour", time_info.hour, fread_number( fp ) ); KEY( "Mday", time_info.day, fread_number( fp ) ); KEY( "Mmonth", time_info.month, fread_number( fp ) ); KEY( "Myear", time_info.year, fread_number( fp ) ); break; /* Uncomment if you have Samson's Pfile Cleanup Snippet installed. case 'P': KEY( "Purgetime", new_pfile_time_t, fread_number( fp ) ); break; */ } if( !fMatch ) { bug( "Fread_timedata: no match: %s", word ); fread_to_eol( fp ); } } }
void read_damages (void) { FILE *df; char buf[1000]; int lastmark= 0; bzero (&dmsg, sizeof (dmsg)); if ((df = fopen ("dam.dat", "r")) == NULL) { damt.kick_dam = str_dup ("o+2d/4m40+k/2"); write_damages (); } for (;;) { strcpy (buf, fread_word (df)); if (!str_cmp (buf, "END")) break; if (!str_cmp (buf, "Kickd")) damt.kick_dam = str_dup (fread_word (df)); if (!str_prefix ("#", buf)) { fread_to_eol (df); continue; } if (!str_cmp (buf, "GENERIC")) { dmsg.generic_range[lastmark][0] = fread_number (df); dmsg.generic_range[lastmark][1] = fread_number (df); dmsg.generic_percent[lastmark][0] = fread_number (df); dmsg.generic_percent[lastmark][1] = fread_number (df); fread_to_eol (df); dmsg.gen_m[lastmark] = fread_string_eol (df); dmsg.gen_m1[lastmark] = fread_string_eol (df); dmsg.gen_m2[lastmark]= fread_string_eol (df); lastmark++; } } fclose (df); return; }
void load_skill_table( ) { FILE *fp; if( ( fp = fopen( SKILL_FILE, "r" ) ) != NULL ) { top_sn = 0; for( ;; ) { char letter; const char *word; letter = fread_letter( fp ); if( letter == '*' ) { fread_to_eol( fp ); continue; } if( letter != '#' ) { bug( "Load_skill_table: # not found.", 0 ); break; } word = fread_word( fp ); if( !str_cmp( word, "SKILL" ) ) { if( top_sn >= MAX_SKILL ) { bug( "load_skill_table: more skills than MAX_SKILL %d", MAX_SKILL ); fclose( fp ); return; } skill_table[top_sn++] = fread_skill( fp, FALSE ); continue; } else if( !str_cmp( word, "END" ) ) break; else { bug( "Load_skill_table: bad section.", 0 ); continue; } } fclose( fp ); } else { bug( "Cannot open skills.dat", 0 ); exit( 0 ); } }
/* Read in an individual slaytype */ void fread_slay( SLAY_DATA * slay, FILE * fp ) { const char *word; bool fMatch; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'C': KEY( "Cmessage", slay->cmsg, fread_string( fp ) ); KEY( "Color", slay->color, fread_number( fp ) ); break; case 'E': if( !str_cmp( word, "End" ) ) { if( !slay->owner ) slay->owner = STRALLOC( "Any" ); return; } break; case 'O': KEY( "Owner", slay->owner, fread_string( fp ) ); break; case 'R': KEY( "Rmessage", slay->rmsg, fread_string( fp ) ); break; case 'T': KEY( "Type", slay->type, fread_string( fp ) ); break; case 'V': KEY( "Vmessage", slay->vmsg, fread_string( fp ) ); break; } if( !fMatch ) bug( "Fread_slay: no match: %s", word ); } }
void fread_realm_memberlist( realm_data * realm, FILE * fp ) { realm_roster_data *roster; roster = new realm_roster_data; for( ;; ) { const char *word = feof( fp ) ? "End" : fread_word( fp ); switch ( UPPER( word[0] ) ) { default: bug( "%s: no match: %s", __func__, word ); fread_to_eol( fp ); break; case '*': fread_to_eol( fp ); break; case 'E': if( !str_cmp( word, "End" ) ) { realm->memberlist.push_back( roster ); return; } break; case 'J': KEY( "Joined", roster->joined, fread_long( fp ) ); break; case 'N': STDSKEY( "Name", roster->name ); break; } } }
/* added for new index - 5/5/02 - Nopey */ void fread_news_type( NEWS_TYPE * type, FILE * fp ) { const char *word; bool fMatch; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fread_to_eol( fp ); break; case 'C': KEY( "Cmd_Name", type->cmd_name, fread_string( fp ) ); break; case 'E': if( !str_cmp( word, "END" ) ) { if( !type->name ) type->name = STRALLOC( "Unknown" ); return; } break; case 'H': KEY( "Header", type->header, fread_string( fp ) ); break; case 'L': KEY( "Level", type->level, fread_number( fp ) ); break; case 'N': KEY( "Name", type->name, fread_string( fp ) ); break; case 'V': KEY( "Vnum", type->vnum, fread_number( fp ) ); break; } if( !fMatch ) bug( "fread_news_type(): no match: %s", word ); } }
/* Load time information from saved file - Samson 1-21-99 */ bool load_timedata( void ) { char filename[256]; FILE *fp; bool found; found = FALSE; snprintf( filename, 256, "%stime.dat", SYSTEM_DIR ); if( ( fp = fopen( filename, "r" ) ) != NULL ) { found = TRUE; for( ;; ) { char letter = '\0'; char *word = NULL; letter = fread_letter( fp ); if( letter == '*' ) { fread_to_eol( fp ); continue; } if( letter != '#' ) { bug( "%s", "Load_timedata: # not found." ); break; } word = fread_word( fp ); if( !str_cmp( word, "TIME" ) ) { fread_timedata( fp ); break; } else if( !str_cmp( word, "END" ) ) break; else { bug( "Load_timedata: bad section - %s.", word ); break; } } fclose( fp ); } return found; }
/* * This loads the Immortal host data structure to keep certain immortals * from logging on from certain sites... IE keep hackers out of the high * level immortals. Shaddai July 27, 1997 */ int load_imm_host( ) { FILE *fp; const char *word; bool my_continue = TRUE; bool fMatch = FALSE; IMMORTAL_HOST *host; if( ( fp = fopen( IMM_HOST_FILE, "r" ) ) == NULL ) { log_string( "No immortal host data" ); return rNONE; } while( my_continue ) { word = feof( fp ) ? "#END" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '#': if( !str_cmp( word, "#END" ) ) { fclose( fp ); fMatch = TRUE; my_continue = FALSE; } break; case 'S': if( !str_cmp( word, "Start" ) ) { CREATE( host, IMMORTAL_HOST, 1 ); LINK( host, immortal_host_start, immortal_host_end, next, prev ); fread_imm_host( fp, host ); fMatch = TRUE; } break; } if( !fMatch ) { bug( "%s: no match: %s", __func__, word ); fread_to_eol( fp ); } } log_string( "Done." ); return rNONE; }
/* * Loads the ban file from the system directory. */ void load_bans(void) { FILE *fp; BAN_DATA *ban_last; if ((fp = fopen(BAN_FILE, "r")) == NULL) { global.last_boot_result = MISSING; log_string("STATUS: No ban file available to load in the system directory."); return; } ban_last = NULL; for (;;) { BAN_DATA *pban; if (feof(fp)) { if (global.last_boot_result == UNKNOWN) { global.last_boot_result = SUCCESS; } fclose(fp); return; } pban = new_ban(); pban->name = str_dup(fread_word(fp)); pban->level = fread_number(fp); pban->ban_flags = fread_flag(fp); fread_to_eol(fp); if (ban_list == NULL) { ban_list = pban; } else { ban_last->next = pban; } ban_last = pban; } if (global.last_boot_result == UNKNOWN) global.last_boot_result = SUCCESS; } // end load_bans
void load_news( ) { FILE *fpin = FileOpen( NEWS_FILE, "r" ); if ( fpin == NULL ) { bug( "Cannot open news.dat for reading." ); perror( NEWS_FILE ); return; } for ( ;; ) { char letter; char *word; NEWS_DATA *news; letter = fread_letter( fpin ); if ( letter == '*' ) { fread_to_eol( fpin ); continue; } if ( letter != '#' ) { bug( "Load_news: # not found." ); break; } word = ( feof( fpin ) ? ( char * ) "End" : fread_word( fpin ) ); if ( !str_cmp( word, "News" ) ) { news = fread_news( fpin ); if ( news != NULL ) LINK( news, first_news, last_news, next, prev ); } else if ( !str_cmp( word, "HTML" ) ) { USE_HTML_NEWS = fread_number( fpin ) == 1 ? TRUE : FALSE; } else if ( !str_cmp( word, "End" ) ) { FileClose( fpin ); break; } else { bug( "Load_news: bad section encountered." ); break; } } }
/* Read in an individual holiday */ void fread_day( HOLIDAY_DATA * day, FILE * fp ) { const char *word; bool fMatch; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'A': KEY( "Announce", day->announce, fread_string_nohash( fp ) ); break; case 'D': KEY( "Day", day->day, fread_number( fp ) ); break; case 'E': if( !str_cmp( word, "End" ) ) { if( !day->announce ) day->announce = str_dup( "Today is a holiday, but who the hell knows which one." ); return; } break; case 'M': KEY( "Month", day->month, fread_number( fp ) ); break; case 'N': KEY( "Name", day->name, fread_string_nohash( fp ) ); break; } if( !fMatch ) bug( "fread_day: no match: %s", word ); } }
void load_quest_list( void ) { FILE *fp; if ( ( fp = FileOpen( QUESTS_FILE, "r" ) ) != NULL ) { for ( ;; ) { char letter; char *word; int x; letter = fread_letter( fp ); if ( letter == '*' ) { fread_to_eol( fp ); continue; } if ( letter != '#' ) { bug( "%s", "Load_quest_list: # not found." ); break; } word = fread_word( fp ); if ( !str_cmp( word, "QUEST" ) ) { fread_quest( FALSE, fp ); continue; } else if ( !str_cmp( word, "NQUEST" ) ) { fread_quest( TRUE, fp ); continue; } else if ( !str_cmp( word, "END" ) ) break; else { bug( "%s", "Load_quest_list: bad section." ); continue; } } FileClose( fp ); } else { perror( QUESTS_FILE ); bug( "%s", "Cannot open quests.dat" ); exit( 0 ); } }
void load_commands( ) { FILE *fp; if( ( fp = fopen( COMMAND_FILE, "r" ) ) != NULL ) { for( ;; ) { char letter; const char *word; letter = fread_letter( fp ); if( letter == '*' ) { fread_to_eol( fp ); continue; } if( letter != '#' ) { bug( "Load_commands: # not found.", 0 ); break; } word = fread_word( fp ); if( !str_cmp( word, "COMMAND" ) ) { fread_command( fp ); continue; } else if( !str_cmp( word, "END" ) ) break; else { bug( "Load_commands: bad section.", 0 ); continue; } } fclose( fp ); } else { bug( "Cannot open commands.dat", 0 ); exit( 0 ); } }