diff -ur src/bit.c new/bit.c --- src/bit.c Sun Mar 22 15:35:28 1998 +++ new/bit.c Sun Mar 22 15:38:18 1998 @@ -30,6 +30,7 @@ #include <time.h> #include "merc.h" #include "tables.h" +#include "lookup.h" struct flag_stat_type @@ -104,33 +105,6 @@ return FALSE; } - - -/* - * This function is Russ Taylor's creation. Thanks Russ! - * All code copyright (C) Russ Taylor, permission to use and/or distribute - * has NOT been granted. Use only in this OLC package has been granted. - */ -/***************************************************************************** - Name: flag_lookup2( flag, table ) - Purpose: Returns the value of a single, settable flag from the table. - Called by: flag_value and flag_string. - Note: This function is local and used only in bit.c. - ****************************************************************************/ -int flag_lookup2 (const char *name, const struct flag_type *flag_table) -{ - int flag; - - for (flag = 0; flag_table[flag].name != NULL; flag++) - { - if ( !str_cmp( name, flag_table[flag].name ) - && flag_table[flag].settable ) - return flag_table[flag].bit; - } - - return NO_FLAG; -} - /***************************************************************************** Name: flag_value( table, flag ) Purpose: Returns the value of the flags entered. Multi-flags accepted. @@ -147,7 +121,7 @@ { one_argument( argument, word ); - if ( ( bit = flag_lookup2( word, flag_table ) ) != NO_FLAG ) + if ( ( bit = flag_lookup( word, flag_table ) ) != 0 ) return bit; else return NO_FLAG; @@ -163,7 +137,7 @@ if ( word[0] == '\0' ) break; - if ( ( bit = flag_lookup2( word, flag_table ) ) != NO_FLAG ) + if ( ( bit = flag_lookup( word, flag_table ) ) != 0 ) { SET_BIT( marked, bit ); found = TRUE; diff -ur src/comm.c new/comm.c --- src/comm.c Sun Mar 22 15:35:35 1998 +++ new/comm.c Sun Mar 22 15:38:27 1998 @@ -2168,7 +2168,7 @@ * Reserved words. */ if ( is_name( name, - "all auto immortal self someone something the you demise balance circle loner honor") ) + "all auto immortal self someone something the you demise balance circle loner honor none") ) return FALSE; if (str_cmp(capitalize(name),"Alander") && (!str_prefix("Alan",name) diff -ur src/db.c new/db.c --- src/db.c Sun Mar 22 15:35:35 1998 +++ new/db.c Sun Mar 22 15:38:27 1998 @@ -42,6 +42,7 @@ #include "db.h" #include "recycle.h" #include "music.h" +#include "tables.h" #include "lookup.h" @@ -70,6 +71,8 @@ HELP_DATA * help_first; HELP_DATA * help_last; +HELP_AREA * had_list; + SHOP_DATA * shop_first; SHOP_DATA * shop_last; @@ -154,6 +157,7 @@ AREA_DATA * area_first; AREA_DATA * area_last; +AREA_DATA * current_area; char * string_space; char * top_string; @@ -215,7 +219,7 @@ void init_mm args( ( void ) ); void load_area args( ( FILE *fp ) ); void new_load_area args( ( FILE *fp ) ); /* OLC */ -void load_helps args( ( FILE *fp ) ); +void load_helps args( ( FILE *fp, char *fname ) ); void load_old_mob args( ( FILE *fp ) ); void load_mobiles args( ( FILE *fp ) ); void load_old_obj args( ( FILE *fp ) ); @@ -339,6 +343,8 @@ } } + current_area = NULL; + for ( ; ; ) { char *word; @@ -354,7 +360,7 @@ if ( word[0] == '$' ) break; else if ( !str_cmp( word, "AREA" ) ) load_area (fpArea); /* OLC */ else if ( !str_cmp( word, "AREADATA" ) ) new_load_area(fpArea); - else if ( !str_cmp( word, "HELPS" ) ) load_helps (fpArea); + else if ( !str_cmp( word, "HELPS" ) ) load_helps (fpArea, strArea); else if ( !str_cmp( word, "MOBOLD" ) ) load_old_mob (fpArea); else if ( !str_cmp( word, "MOBILES" ) ) load_mobiles (fpArea); else if ( !str_cmp( word, "MOBPROGS" ) ) load_mobprogs(fpArea); @@ -433,8 +439,9 @@ area_last->next = pArea; REMOVE_BIT(area_last->area_flags, AREA_LOADING); /* OLC */ } - area_last = pArea; - pArea->next = NULL; + area_last = pArea; + pArea->next = NULL; + current_area = pArea; top_area++; return; @@ -526,9 +533,11 @@ area_first = pArea; if ( area_last != NULL ) area_last->next = pArea; - area_last = pArea; - pArea->next = NULL; + area_last = pArea; + pArea->next = NULL; + current_area = pArea; top_area++; + return; } break; @@ -560,17 +569,48 @@ /* * Snarf a help section. */ -void load_helps( FILE *fp ) +void load_helps( FILE *fp, char *fname ) { HELP_DATA *pHelp; + int level; + char *keyword; for ( ; ; ) { - pHelp = alloc_perm( sizeof(*pHelp) ); - pHelp->level = fread_number( fp ); - pHelp->keyword = fread_string( fp ); - if ( pHelp->keyword[0] == '$' ) - break; + HELP_AREA * had; + + level = fread_number( fp ); + keyword = fread_string( fp ); + + if ( keyword[0] == '$' ) + break; + + if ( !had_list ) + { + had = new_had (); + had->filename = str_dup( fname ); + had->area = current_area; + if ( current_area ) + current_area->helps = had; + had_list = had; + } + else + if ( str_cmp( fname, had_list->filename ) ) + { + had = new_had (); + had->filename = str_dup( fname ); + had->area = current_area; + if ( current_area ) + current_area->helps = had; + had->next = had_list; + had_list = had; + } + else + had = had_list; + + pHelp = new_help( ); + pHelp->level = level; + pHelp->keyword = keyword; pHelp->text = fread_string( fp ); if ( !str_cmp( pHelp->keyword, "greeting" ) ) @@ -581,8 +621,18 @@ if ( help_last != NULL ) help_last->next = pHelp; - help_last = pHelp; - pHelp->next = NULL; + help_last = pHelp; + pHelp->next = NULL; + + if ( !had->first ) + had->first = pHelp; + if ( !had->last ) + had->last = pHelp; + + had->last->next_area = pHelp; + had->last = pHelp; + pHelp->next_area = NULL; + top_help++; } @@ -1173,7 +1223,6 @@ } pRoomIndex->exit[door] = pexit; - pRoomIndex->old_exit[door] = pexit; top_exit++; } else if ( letter == 'E' ) diff -ur src/db2.c new/db2.c --- src/db2.c Sun Mar 22 15:35:36 1998 +++ new/db2.c Sun Mar 22 15:38:27 1998 @@ -39,8 +39,8 @@ #include "merc.h" #include "db.h" -#include "lookup.h" #include "tables.h" +#include "lookup.h" extern int flag_lookup args((const char *name, const struct flag_type *flag_table)); @@ -296,7 +296,8 @@ pMobIndex->parts = fread_flag( fp ) | race_table[pMobIndex->race].parts; /* size */ - pMobIndex->size = size_lookup(fread_word(fp)); + CHECK_POS( pMobIndex->size, size_lookup(fread_word(fp)), "size" ); +/* pMobIndex->size = size_lookup(fread_word(fp)); */ pMobIndex->material = str_dup(fread_word( fp )); for ( ; ; ) @@ -420,8 +421,8 @@ pObjIndex->short_descr = fread_string( fp ); pObjIndex->description = fread_string( fp ); pObjIndex->material = fread_string( fp ); - - pObjIndex->item_type = item_lookup(fread_word( fp )); + + CHECK_POS(pObjIndex->item_type, item_lookup(fread_word( fp )), "item_type" ); pObjIndex->extra_flags = fread_flag( fp ); pObjIndex->wear_flags = fread_flag( fp ); switch(pObjIndex->item_type) @@ -444,7 +445,7 @@ case ITEM_FOUNTAIN: pObjIndex->value[0] = fread_number(fp); pObjIndex->value[1] = fread_number(fp); - pObjIndex->value[2] = liq_lookup(fread_word(fp)); + CHECK_POS(pObjIndex->value[2], liq_lookup(fread_word(fp)), "liq_lookup" ); pObjIndex->value[3] = fread_number(fp); pObjIndex->value[4] = fread_number(fp); break; diff -ur src/handler.c new/handler.c --- src/handler.c Sun Mar 22 15:35:36 1998 +++ new/handler.c Sun Mar 22 15:38:27 1998 @@ -116,35 +116,6 @@ return 0; } -/* returns race number */ -int race_lookup (const char *name) -{ - int race; - - for ( race = 0; race_table[race].name != NULL; race++) - { - if (LOWER(name[0]) == LOWER(race_table[race].name[0]) - && !str_prefix( name,race_table[race].name)) - return race; - } - - return 0; -} - -int liq_lookup (const char *name) -{ - int liq; - - for ( liq = 0; liq_table[liq].liq_name != NULL; liq++) - { - if (LOWER(name[0]) == LOWER(liq_table[liq].liq_name[0]) - && !str_prefix(name,liq_table[liq].liq_name)) - return liq; - } - - return -1; -} - int weapon_lookup (const char *name) { int type; @@ -171,21 +142,6 @@ } return WEAPON_EXOTIC; -} - - -int item_lookup(const char *name) -{ - int type; - - for (type = 0; item_table[type].name != NULL; type++) - { - if (LOWER(name[0]) == LOWER(item_table[type].name[0]) - && !str_prefix(name,item_table[type].name)) - return item_table[type].type; - } - - return -1; } char *item_name(int item_type) diff -ur src/lookup.c new/lookup.c --- src/lookup.c Sun Mar 22 15:35:21 1998 +++ new/lookup.c Sun Mar 22 15:38:27 1998 @@ -104,3 +104,46 @@ return -1; } + +/* returns race number */ +int race_lookup (const char *name) +{ + int race; + + for ( race = 0; race_table[race].name != NULL; race++) + { + if (LOWER(name[0]) == LOWER(race_table[race].name[0]) + && !str_prefix( name,race_table[race].name)) + return race; + } + + return 0; +} + +int item_lookup(const char *name) +{ + int type; + + for (type = 0; item_table[type].name != NULL; type++) + { + if (LOWER(name[0]) == LOWER(item_table[type].name[0]) + && !str_prefix(name,item_table[type].name)) + return item_table[type].type; + } + + return -1; +} + +int liq_lookup (const char *name) +{ + int liq; + + for ( liq = 0; liq_table[liq].liq_name != NULL; liq++) + { + if (LOWER(name[0]) == LOWER(liq_table[liq].liq_name[0]) + && !str_prefix(name,liq_table[liq].liq_name)) + return liq; + } + + return -1; +} diff -ur src/lookup.h new/lookup.h --- src/lookup.h Sun Mar 22 15:35:21 1998 +++ new/lookup.h Sun Mar 22 15:38:27 1998 @@ -30,3 +30,4 @@ int position_lookup args( (const char *name) ); int sex_lookup args( (const char *name) ); int size_lookup args( (const char *name) ); +int flag_lookup args( (const char *, const struct flag_type *) ); diff -ur src/merc.h new/merc.h --- src/merc.h Sun Mar 22 15:35:36 1998 +++ new/merc.h Sun Mar 22 15:38:27 1998 @@ -86,6 +86,7 @@ typedef struct exit_data EXIT_DATA; typedef struct extra_descr_data EXTRA_DESCR_DATA; typedef struct help_data HELP_DATA; +typedef struct help_area_data HELP_AREA; typedef struct kill_data KILL_DATA; typedef struct mem_data MEM_DATA; typedef struct mob_index_data MOB_INDEX_DATA; @@ -326,11 +327,20 @@ struct help_data { HELP_DATA * next; + HELP_DATA * next_area; sh_int level; char * keyword; char * text; }; +struct help_area_data +{ + HELP_AREA * next; + HELP_DATA * first; + HELP_DATA * last; + AREA_DATA * area; + char * filename; +}; /* @@ -1650,6 +1660,7 @@ AREA_DATA * next; RESET_DATA * reset_first; RESET_DATA * reset_last; + HELP_AREA * helps; char * file_name; char * name; char * credits; @@ -1679,7 +1690,6 @@ EXTRA_DESCR_DATA * extra_descr; AREA_DATA * area; EXIT_DATA * exit [6]; - EXIT_DATA * old_exit[6]; RESET_DATA * reset_first; /* OLC */ RESET_DATA * reset_last; /* OLC */ char * name; @@ -1864,8 +1874,11 @@ #define REMOVE_BIT(var, bit) ((var) &= ~(bit)) #define IS_NULLSTR(str) ((str) == NULL || (str)[0] == '\0') #define ENTRE(min,num,max) ( ((min) < (num)) && ((num) < (max)) ) - - +#define CHECK_POS(a, b, c) { \ + (a) = (b); \ + if ( (a) < 0 ) \ + bug( "CHECK_POS : " c " == %d < 0", a ); \ + } \ /* * Character macros. @@ -2260,15 +2273,12 @@ void deduct_cost args( (CHAR_DATA *ch, int cost) ); void affect_enchant args( (OBJ_DATA *obj) ); int check_immune args( (CHAR_DATA *ch, int dam_type) ); -int liq_lookup args( ( const char *name) ); int material_lookup args( ( const char *name) ); int weapon_lookup args( ( const char *name) ); int weapon_type args( ( const char *name) ); char *weapon_name args( ( int weapon_Type) ); -int item_lookup args( ( const char *name) ); char *item_name args( ( int item_type) ); int attack_lookup args( ( const char *name) ); -int race_lookup args( ( const char *name) ); long wiznet_lookup args( ( const char *name) ); int class_lookup args( ( const char *name) ); bool is_clan args( (CHAR_DATA *ch) ); @@ -2342,7 +2352,6 @@ char * comm_bit_name args( ( int comm_flags ) ); char * cont_bit_name args( ( int cont_flags) ); - /* interp.c */ void interpret args( ( CHAR_DATA *ch, char *argument ) ); bool is_number args( ( char *arg ) ); @@ -2419,6 +2428,11 @@ bool run_olc_editor args( ( DESCRIPTOR_DATA *d ) ); char *olc_ed_name args( ( CHAR_DATA *ch ) ); char *olc_ed_vnum args( ( CHAR_DATA *ch ) ); + +/* lookup.c */ +int race_lookup args( ( const char *name) ); +int item_lookup args( ( const char *name) ); +int liq_lookup args( ( const char *name) ); #undef CD #undef MID diff -ur src/olc.h new/olc.h --- src/olc.h Sun Mar 22 15:35:28 1998 +++ new/olc.h Sun Mar 22 15:38:18 1998 @@ -31,7 +31,7 @@ " Por Ivan Toledo (pvillanu@choapa.cic.userena.cl)\n\r" #define DATE " (Apr. 7, 1995 - ROM mod, Apr 16, 1995)\n\r" \ " (Port a ROM 2.4 - Nov 2, 1996)\n\r" \ - " Version actual : 1.7 - Mar 7, 1998\n\r" + " Version actual : 1.71 - Mar 22, 1998\n\r" #define CREDITS " Original by Surreality(cxw197@psu.edu) and Locke(locke@lm.com)" diff -ur src/olc_save.c new/olc_save.c --- src/olc_save.c Sun Mar 22 15:35:28 1998 +++ new/olc_save.c Sun Mar 22 15:38:18 1998 @@ -77,6 +77,8 @@ { FILE *fp; AREA_DATA *pArea; + extern HELP_AREA * had_list; + HELP_AREA * ha; if ( ( fp = fopen( "area.lst", "w" ) ) == NULL ) { @@ -89,11 +91,11 @@ * Add any help files that need to be loaded at * startup to this section. */ - fprintf( fp, "help.are\n" ); fprintf( fp, "social.are\n" ); /* ROM OLC */ - fprintf( fp, "rom.are\n" ); /* ROM OLC */ - fprintf( fp, "group.are\n" ); /* ROM OLC */ - fprintf( fp, "olc.hlp\n" ); + + for ( ha = had_list; ha; ha = ha->next ) + if ( ha->area == NULL ) + fprintf( fp, "%s\n", ha->filename ); for( pArea = area_first; pArea; pArea = pArea->next ) { @@ -850,7 +852,47 @@ return; } +void save_helps( FILE *fp, HELP_AREA *ha ) +{ + HELP_DATA *help = ha->first; + + fprintf( fp, "#HELPS\n" ); + + for ( ; help; help = help->next_area ) + { + fprintf( fp, "%d %s~\n", help->level, help->keyword ); + fprintf( fp, "%s~\n\n", fix_string( help->text ) ); + } + + fprintf( fp, "-1 $~\n\n" ); + + return; +} + +void save_other_helps( void ) +{ + extern HELP_AREA * had_list; + HELP_AREA *ha; + FILE *fp; + for ( ha = had_list; ha; ha = ha->next ) + if ( ha->area == NULL ) + { + fp = fopen( ha->filename, "w" ); + + if ( !fp ) + { + perror( ha->filename ); + return; + } + + save_helps( fp, ha ); + fprintf( fp, "#$\n" ); + fclose( fp ); + } + + return; +} /***************************************************************************** Name: save_area @@ -884,6 +926,9 @@ save_shops( fp, pArea ); save_mobprogs( fp, pArea ); + if ( pArea->helps && pArea->helps->first ) + save_helps( fp, pArea->helps ); + fprintf( fp, "#$\n" ); fclose( fp ); @@ -902,12 +947,18 @@ char arg1 [MAX_INPUT_LENGTH]; AREA_DATA *pArea; FILE *fp; - int value; + int value, sec; fp = NULL; if ( !ch ) /* Do an autosave */ - { + sec = 9; + else if ( !IS_NPC(ch) ) + sec = ch->pcdata->security; + else + sec = 0; + +/* { save_area_list(); for( pArea = area_first; pArea; pArea = pArea->next ) { @@ -915,92 +966,120 @@ REMOVE_BIT( pArea->area_flags, AREA_CHANGED ); } return; - } + } */ + smash_tilde( argument ); strcpy( arg1, argument ); + if ( arg1[0] == '\0' ) { - send_to_char( "Syntax:\n\r", ch ); - send_to_char( " asave <vnum> - saves a particular area\n\r", ch ); - send_to_char( " asave list - saves the area.lst file\n\r", ch ); - send_to_char( " asave area - saves the area being edited\n\r", ch ); - send_to_char( " asave changed - saves all changed zones\n\r", ch ); - send_to_char( " asave world - saves the world! (db dump)\n\r", ch ); - send_to_char( "\n\r", ch ); - return; + if (ch) + { + send_to_char( "Syntax:\n\r", ch ); + send_to_char( " asave <vnum> - saves a particular area\n\r", ch ); + send_to_char( " asave list - saves the area.lst file\n\r", ch ); + send_to_char( " asave area - saves the area being edited\n\r", ch ); + send_to_char( " asave changed - saves all changed zones\n\r", ch ); + send_to_char( " asave world - saves the world! (db dump)\n\r", ch ); + send_to_char( "\n\r", ch ); + } + + return; } /* Snarf the value (which need not be numeric). */ value = atoi( arg1 ); if ( !( pArea = get_area_data( value ) ) && is_number( arg1 ) ) { - send_to_char( "That area does not exist.\n\r", ch ); + if (ch) + send_to_char( "That area does not exist.\n\r", ch ); return; } + /* Save area of given vnum. */ /* ------------------------ */ - if ( is_number( arg1 ) ) { - if ( !IS_BUILDER( ch, pArea ) ) + if ( ch && !IS_BUILDER( ch, pArea ) ) { send_to_char( "You are not a builder for this area.\n\r", ch ); return; } + save_area_list(); save_area( pArea ); + return; } + /* Save the world, only authorized areas. */ /* -------------------------------------- */ - if ( !str_cmp( "world", arg1 ) ) { save_area_list(); for( pArea = area_first; pArea; pArea = pArea->next ) { /* Builder must be assigned this area. */ - if ( !IS_BUILDER( ch, pArea ) ) - continue; + if ( ch && !IS_BUILDER( ch, pArea ) ) + continue; save_area( pArea ); REMOVE_BIT( pArea->area_flags, AREA_CHANGED ); } - send_to_char( "You saved the world.\n\r", ch ); -/* send_to_all_char( "Database saved.\n\r" ); ROM OLC */ + + if ( ch ) + send_to_char( "You saved the world.\n\r", ch ); + + if ( sec == 9 ) + save_other_helps( ); + return; } /* Save changed areas, only authorized areas. */ /* ------------------------------------------ */ - if ( !str_cmp( "changed", arg1 ) ) { char buf[MAX_INPUT_LENGTH]; save_area_list(); - send_to_char( "Saved zones:\n\r", ch ); + if ( ch ) + send_to_char( "Saved zones:\n\r", ch ); + else + log_string( "Saved zones:" ); + sprintf( buf, "None.\n\r" ); for( pArea = area_first; pArea; pArea = pArea->next ) { /* Builder must be assigned this area. */ - if ( !IS_BUILDER( ch, pArea ) ) + if ( ch && !IS_BUILDER( ch, pArea ) ) continue; /* Save changed areas. */ if ( IS_SET(pArea->area_flags, AREA_CHANGED) ) { save_area( pArea ); - sprintf( buf, "%24s - '%s'\n\r", pArea->name, pArea->file_name ); - send_to_char( buf, ch ); + sprintf( buf, "%24s - '%s'", pArea->name, pArea->file_name ); + if ( ch ) + { + send_to_char( buf, ch ); + send_to_char( "\n\r", ch ); + } + else + log_string( buf ); REMOVE_BIT( pArea->area_flags, AREA_CHANGED ); } - } + } + if ( !str_cmp( buf, "None.\n\r" ) ) - send_to_char( buf, ch ); - return; + if ( ch ) + send_to_char( buf, ch ); + else + log_string( "None." ); + + return; } /* Save the area.lst file. */ @@ -1015,6 +1094,9 @@ /* -------------------------------------- */ if ( !str_cmp( arg1, "area" ) ) { + if ( !ch || !ch->desc ) + return; + /* Is character currently editing. */ if ( ch->desc->editor == ED_NONE ) { @@ -1058,6 +1140,8 @@ /* Show correct syntax. */ /* -------------------- */ - do_asave( ch, "" ); + if (ch) + do_asave( ch, "" ); + return; } diff -ur src/recycle.c new/recycle.c --- src/recycle.c Sun Mar 22 15:35:36 1998 +++ new/recycle.c Sun Mar 22 15:38:27 1998 @@ -673,3 +673,37 @@ mp->next = mprog_free; mprog_free = mp; } + +HELP_AREA * had_free; + +HELP_AREA * new_had ( void ) +{ + HELP_AREA * had; + + if ( had_free ) + { + had = had_free; + had_free = had_free->next; + } + else + had = alloc_perm( sizeof( *had ) ); + + return had; +} + +HELP_DATA * help_free; + +HELP_DATA * new_help ( void ) +{ + HELP_DATA * help; + + if ( help_free ) + { + help = help_free; + help_free = help_free->next; + } + else + help = alloc_perm( sizeof( *help ) ); + + return help; +} diff -ur src/recycle.h new/recycle.h --- src/recycle.h Sun Mar 22 15:35:21 1998 +++ new/recycle.h Sun Mar 22 15:38:27 1998 @@ -103,10 +103,12 @@ #undef MD /* buffer procedures */ - BUFFER *new_buf args( (void) ); BUFFER *new_buf_size args( (int size) ); void free_buf args( (BUFFER *buffer) ); bool add_buf args( (BUFFER *buffer, char *string) ); void clear_buf args( (BUFFER *buffer) ); char *buf_string args( (BUFFER *buffer) ); + +HELP_AREA * new_had args( ( void ) ); +HELP_DATA * new_help args( ( void ) ); diff -ur src/save.c new/save.c --- src/save.c Sun Mar 22 15:35:36 1998 +++ new/save.c Sun Mar 22 15:38:27 1998 @@ -37,8 +37,8 @@ #include <malloc.h> #include "merc.h" #include "recycle.h" -#include "lookup.h" #include "tables.h" +#include "lookup.h" #if !defined(macintosh) extern int _filbuf args( (FILE *) );