This is a patch against Circle30bpl22+OasisOLC to implement online editing (and saving/loading) of mob, object, and room spec procs. Procedures are saved in .zon files following the 'S' after resets, similar to Merc based muds. the format on disk is: #SPECIALS [proc spec] . . $ And a proc spec looks like: M <- mob O <- object W <- room Notes: o This is against circle30bpl22 + the version of the patch for OasisOLC designed for circle30bpl21 (That means, since I fixed patch rejects, you'll likely get .rej files if you patch against a pl22 version of Oasis when that comes out) o All spec procs are listed in a 'specials table' in spec_assign.c (following the proc declarations) that mabs proc names to function names o Old-style hardcoded proc assignments still work, but any online setting overrides them o Procs can be applied by name or number, only the ones declared in the spec table with uSPEC_TAB show up in the list: this is because the muds I work with have many spec procs (most of them specialized). o This code may be buggy Major problems? You can contact me at mysidia-ccf@flame.org Original code Copyright (c) 2002 James Hess, All Rights Reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the authors nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================================================== diff -ur ../circle30bpl22_oas/src/act.wizard.c ./src/act.wizard.c --- ../circle30bpl22_oas/src/act.wizard.c Mon Oct 28 21:51:47 2002 +++ ./src/act.wizard.c Mon Oct 28 19:54:03 2002 @@ -17,6 +17,7 @@ #include "interpreter.h" #include "handler.h" #include "db.h" +#include "shop.h" #include "spells.h" #include "house.h" #include "screen.h" @@ -33,6 +34,8 @@ extern int load_into_inventory; extern int buf_switches, buf_largecount, buf_overflows; extern int top_of_p_table; +extern shop_rnum top_shop; +extern struct shop_data *shop_index; /* for chars */ extern const char *pc_class_types[]; @@ -374,16 +377,22 @@ int i, found, column; struct obj_data *j; struct char_data *k; + char *pSpec; send_to_char(ch, "Room name: %s%s%s\r\n", CCCYN(ch, C_NRM), rm->name, CCNRM(ch, C_NRM)); + pSpec = rm->func ? spec_name(rm->func) : "None"; + pSpec = !pSpec ? "Exists" : pSpec; + sprinttype(rm->sector_type, sector_types, buf2, sizeof(buf2)); send_to_char(ch, "Zone: [%3d], VNum: [%s%5d%s], RNum: [%5d], Type: %s\r\n", zone_table[rm->zone].number, CCGRN(ch, C_NRM), rm->number, CCNRM(ch, C_NRM), IN_ROOM(ch), buf2); sprintbit(rm->room_flags, room_bits, buf2, sizeof(buf2)); - send_to_char(ch, "SpecProc: %s, Flags: %s\r\n", rm->func == NULL ? "None" : "Exists", buf2); + send_to_char(ch, "SpecProc: %s%s%s, Flags: %s\r\n", + CCRED(ch, C_NRM), rm->func == NULL ? "None" : pSpec, + CCNRM(ch, C_NRM), buf2); send_to_char(ch, "Description:\r\n%s", rm->description ? rm->description : " None.\r\n"); @@ -457,16 +466,29 @@ struct obj_data *j2; struct extra_descr_data *desc; char buf[MAX_STRING_LENGTH]; + char buf2[MAX_STRING_LENGTH]; + char *pSpec; vnum = GET_OBJ_VNUM(j); send_to_char(ch, "Name: '%s%s%s', Aliases: %s\r\n", CCYEL(ch, C_NRM), j->short_description ? j->short_description : "", CCNRM(ch, C_NRM), j->name); + if (GET_OBJ_RNUM(j) >= 0) + { + pSpec = obj_index[GET_OBJ_RNUM(j)].func ? spec_name(obj_index[GET_OBJ_RNUM(j)].func) : "None"; + pSpec = !pSpec ? "Exists" : pSpec; + strcpy(buf2, pSpec); + } + else { + strcpy(buf2, "None"); + } + + sprinttype(GET_OBJ_TYPE(j), item_types, buf, sizeof(buf)); - send_to_char(ch, "VNum: [%s%5d%s], RNum: [%5d], Type: %s, SpecProc: %s\r\n", + send_to_char(ch, "VNum: [%s%5d%s], RNum: [%5d], Type: %s, SpecProc: %s%s%s\r\n", CCGRN(ch, C_NRM), vnum, CCNRM(ch, C_NRM), GET_OBJ_RNUM(j), buf, - GET_OBJ_SPEC(j) ? "Exists" : "None"); + CCRED(ch, C_NRM), buf2, CCNRM(ch, C_NRM)); if (j->ex_description) { send_to_char(ch, "Extra descs:%s", CCCYN(ch, C_NRM)); @@ -601,6 +623,7 @@ struct obj_data *j; struct follow_type *fol; struct affected_type *aff; + char *pSpec; sprinttype(GET_SEX(k), genders, buf, sizeof(buf)); send_to_char(ch, "%s %s '%s' IDNum: [%5ld], In room [%5d]\r\n", @@ -687,11 +710,28 @@ send_to_char(ch, "PRF: %s%s%s\r\n", CCGRN(ch, C_NRM), buf, CCNRM(ch, C_NRM)); } - if (IS_MOB(k)) - send_to_char(ch, "Mob Spec-Proc: %s, NPC Bare Hand Dam: %dd%d\r\n", - (mob_index[GET_MOB_RNUM(k)].func ? "Exists" : "None"), - k->mob_specials.damnodice, k->mob_specials.damsizedice); + if (IS_MOB(k)) { + extern SPECIAL(shop_keeper); + shop_rnum x; + char buf2[MAX_INPUT_LENGTH]; + + pSpec = (!GET_MOB_SPEC(k)) ? "None" : spec_name(GET_MOB_SPEC(k)); + pSpec = !pSpec ? "Exists" : pSpec; + + for (x = 0; x < top_shop; x++) { + if (SHOP_KEEPER(x) == GET_MOB_RNUM(k)) + break; + } + if ((x < top_shop) && SHOP_FUNC(x)) { + sprintf(buf2, "%s <%s>", pSpec, spec_name(SHOP_FUNC(x))); + pSpec = buf2; + } + + send_to_char(ch, "Mob Spec-Proc: %s%s%s, NPC Bare Hand Dam: %dd%d\r\n", + CCRED(ch, C_NRM), pSpec, CCNRM(ch, C_NRM), + k->mob_specials.damnodice, k->mob_specials.damsizedice); + } for (i = 0, j = k->carrying; j; j = j->next_content, i++); send_to_char(ch, "Carried: weight: %d, items: %d; Items in: inventory: %d, ", IS_CARRYING_W(k), IS_CARRYING_N(k), i); Only in ../circle30bpl22_oas/src: comm.c~ Only in ./src: conf.h Only in ../circle30bpl22_oas/src: constants.c~ diff -ur ../circle30bpl22_oas/src/db.c ./src/db.c --- ../circle30bpl22_oas/src/db.c Mon Oct 28 21:51:47 2002 +++ ./src/db.c Mon Oct 28 19:54:03 2002 @@ -82,6 +82,11 @@ struct player_special_data dummy_mob; /* dummy spec area for mobs */ struct reset_q_type reset_q; /* queue of zones to be reset */ +static struct proc_cache { + char *line; + struct proc_cache* next; +} *proc_cache_ptr; + /* local functions */ int check_bitvector_names(bitvector_t bits, size_t namecount, const char *whatami, const char *whatbits); int check_object_spell_number(struct obj_data *obj, int val); @@ -122,6 +127,9 @@ void log_zone_error(zone_rnum zone, int cmd_no, const char *message); void reset_time(void); long get_ptable_by_name(const char *name); +static void shove_proc(char *); +static char* grab_proc(); +void install_procedure(char* line); /* external functions */ void paginate_string(char *str, struct descriptor_data *d); @@ -151,6 +159,8 @@ extern room_vnum frozen_start_room; extern struct descriptor_data *descriptor_list; extern const char *unused_spellname; /* spell_parser.c */ +extern void fread_specials(FILE* fp); + /************************************************************************* * routines for booting the system * @@ -383,6 +393,7 @@ void boot_db(void) { zone_rnum i; + char* p; log("Boot db -- BEGIN."); @@ -431,7 +442,15 @@ log(" Objects."); assign_objects(); log(" Rooms."); - assign_rooms(); + assign_rooms(); + log(" Procedures stored in zone files."); + } + + while( (p = grab_proc ()) ) { + if (!no_specials) { + install_procedure(p); + } + free(p); } log("Assigning spell and skill levels."); @@ -1578,9 +1597,12 @@ * Note that if a new zone command is added to reset_zone(), this string * will need to be updated to suit. - ae. */ - while (get_line(fl, buf)) + while (get_line(fl, buf)) { if ((strchr("MOPGERD", buf[0]) && buf[1] == ' ') || (buf[0] == 'S' && buf[1] == '\0')) num_of_cmds++; + if ((buf[0] == 'S' && buf[1] == '\0')) + break; + } rewind(fl); @@ -1653,6 +1675,15 @@ cmd_no++; } + while(get_line(fl, buf)) { + if (!str_cmp(buf, "#SPECIALS")) { + fread_specials(fl); + } + if (!str_cmp(buf, "#End")) { + break; + } + } + if (num_of_cmds != cmd_no + 1) { log("SYSERR: Zone command count mismatch for %s. Estimated: %d, Actual: %d", zname, num_of_cmds, cmd_no + 1); exit(1); @@ -3017,3 +3048,139 @@ return (error); } + +void fwrite_specials(FILE* fp, zone_rnum zrn) +{ + int i, j=0; + mob_rnum mrnum; + obj_rnum ornum; + room_rnum rrnum; + char *p = NULL, chh='\0'; + bool found; + + fprintf(fp, "#SPECIALS\n"); + + for(j = 0; j < 3; j++) + for (i = zone_table[zrn].bot ; i <= zone_table[zrn].top; i++) + { + found = 0; + chh='\0'; + + switch(j) { + case 0: + if ( (mrnum = real_mobile(i)) == NOBODY ) + break; + if (!GET_MOB_SPEC(&mob_proto[mrnum])) + break; + p = spec_name(GET_MOB_SPEC(&mob_proto[mrnum])); + chh = 'M'; + found = TRUE; + break; + case 1: + if ( (ornum = real_object(i)) == NOTHING ) + break; + if (!GET_OBJ_SPEC(&obj_proto[ornum])) + break; + p = spec_name(GET_OBJ_SPEC(&obj_proto[ornum])); + chh = 'O'; + found = TRUE; + break; + case 2: + if ( (rrnum = real_room(i)) == NOTHING ) + break; + if (!world[rrnum].func) + break; + p = spec_name(world[rrnum].func); + chh = 'W'; + found = TRUE; + break; + } + + if (!found || !chh) + continue; + + if (!p || !str_cmp(p,PROC_NONE) || !str_cmp(p,PROC_UNKNOWN)) + p = NULL; + + if (p) { + fprintf(fp, "%c %d %s\n", chh, i, p); + p = NULL; + } + + } + + fprintf(fp, "$\n"); +} + +void install_procedure(char* line) +{ + int x1; + char c1; + char buf[MAX_STRING_LENGTH]; + + if (*line == 'M' && sscanf(line, "%c %d %s", &c1, &x1, buf) >= 3) + { + mob_rnum m1 = real_mobile(x1); + SPEC_FUN *fun; + + if (m1 != NOBODY && (fun = (SPEC_FUN*)get_spec_fun(buf, PROC_MOBILE))) + mob_index[m1].func = fun; + } + else if (*line == 'O' && (sscanf(line, "%c %d %s", &c1, &x1, buf) >= 3)) + { + obj_rnum o1 = real_object(x1); + SPEC_FUN *fun; + + if (o1 != NOTHING && + (fun = (SPEC_FUN*)get_spec_fun(buf, PROC_OBJECT))) + obj_index[o1].func = fun; + } + else if (*line == 'W' && (sscanf(line, "%c %d %s", &c1, &x1, buf) >= 3)) + { + room_rnum r1 = real_room(x1); + SPEC_FUN *fun; + + if (r1 != NOWHERE && (fun = (SPEC_FUN*)get_spec_fun(buf, PROC_ROOM))) + world[r1].func = fun; + } +} + +void fread_specials(FILE* fp) +{ + char line[MAX_STRING_LENGTH]; + + + while(get_line(fp, line)) { + if (isalpha(*line)) { + shove_proc(strdup(line)); + } + else if (*line == '$') + break; + } +} + +static void shove_proc(char *text) +{ + struct proc_cache* n; + + CREATE(n, struct proc_cache, 1); + n->next = proc_cache_ptr; + proc_cache_ptr = n; + + n->line = text; +} + +static char* grab_proc() +{ + struct proc_cache* n = proc_cache_ptr; + char* line; + + if (!n) + return NULL; + + proc_cache_ptr = proc_cache_ptr->next; + line = n->line; + free(n); + + return line; +} diff -ur ../circle30bpl22_oas/src/db.h ./src/db.h --- ../circle30bpl22_oas/src/db.h Thu Jan 31 18:26:51 2002 +++ ./src/db.h Mon Oct 28 18:41:08 2002 @@ -133,6 +133,11 @@ struct obj_data *read_object(obj_vnum nr, int type); int vnum_object(char *searchname, struct char_data *ch); +/* public procedures in spec_assign.c */ +struct spec_table_data *get_spec_data(char *name, int type); +char *spec_name(SPEC_FUN *func); +SPEC_FUN *get_spec_fun(char *name, int type); + #define REAL 0 #define VIRTUAL 1 diff -ur ../circle30bpl22_oas/src/genmob.c ./src/genmob.c --- ../circle30bpl22_oas/src/genmob.c Mon Oct 28 21:51:47 2002 +++ ./src/genmob.c Mon Oct 28 21:44:21 2002 @@ -53,7 +53,7 @@ add_to_save_list(zone_table[real_zone_by_thing(vnum)].number, SL_MOB); log("GenOLC: add_mobile: Updated existing mobile #%d.", vnum); - return TRUE; + return rnum; } RECREATE(mob_proto, struct char_data, top_of_mobt + 2); diff -ur ../circle30bpl22_oas/src/genolc.h ./src/genolc.h --- ../circle30bpl22_oas/src/genolc.h Mon Oct 28 21:51:47 2002 +++ ./src/genolc.h Mon Oct 28 19:58:21 2002 @@ -17,8 +17,6 @@ #define CONFIG_GENOLC_MOBPROG 0 -#define LVL_BUILDER LVL_GOD - int genolc_checkstring(struct descriptor_data *d, const char *arg); int remove_from_save_list(zone_vnum, int type); int add_to_save_list(zone_vnum, int type); diff -ur ../circle30bpl22_oas/src/genzon.c ./src/genzon.c --- ../circle30bpl22_oas/src/genzon.c Mon Oct 28 21:51:47 2002 +++ ./src/genzon.c Mon Oct 28 21:49:06 2002 @@ -20,6 +20,8 @@ extern struct index_data *mob_index; extern struct index_data *obj_index; +extern void fwrite_specials(FILE* fp, zone_rnum zrn); + /* real zone of room/mobile/object/shop given */ zone_rnum real_zone_by_thing(room_vnum vznum) { @@ -448,8 +450,10 @@ } fprintf(zfile, "%c %d %d %d %d \t(%s)\n", ZCMD(zone_num, subcmd).command, ZCMD(zone_num, subcmd).if_flag, arg1, arg2, arg3, comment); - } - fputs("S\n$\n", zfile); + } + fputs("S\n", zfile); + + fwrite_specials(zfile, zone_num); fclose(zfile); sprintf(buf2, "%s/%d.zon", ZON_PREFIX, zone_table[zone_num].number); remove(buf2); Only in ../circle30bpl22_oas/src: interpreter.c~ diff -ur ../circle30bpl22_oas/src/medit.c ./src/medit.c --- ../circle30bpl22_oas/src/medit.c Mon Oct 28 21:51:47 2002 +++ ./src/medit.c Mon Oct 28 21:42:55 2002 @@ -35,6 +35,8 @@ extern struct attack_hit_type attack_hit_text[]; extern struct shop_data *shop_index; extern struct descriptor_data *descriptor_list; +extern struct spec_table_data spec_table[]; + #if CONFIG_OASIS_MPROG extern const char *mobprog_types[]; #endif @@ -105,6 +107,7 @@ OLC_MOB(d) = mob; /* Has changed flag. (It hasn't so far, we just made it.) */ OLC_VAL(d) = FALSE; + OLC_PROC(d) = NULL; medit_disp_menu(d); } @@ -145,6 +148,8 @@ #endif OLC_MOB(d) = mob; + OLC_PROC(d) = mob_index[rmob_num].func; + medit_disp_menu(d); } @@ -190,6 +195,10 @@ return; } + if (mob_index[new_rnum].func != OLC_PROC(d)) + add_to_save_list(zone_table[OLC_ZNUM(d)].number, SL_ZON); + mob_index[new_rnum].func = OLC_PROC(d); + if (!i) /* Only renumber on new mobiles. */ return; @@ -342,6 +351,76 @@ } /*-------------------------------------------------------------------*/ +void medit_disp_proc_menu(struct descriptor_data *d) +{ + int counter = 0, counter2 = 0, i = 0; + + get_char_colors(d->character); + clear_screen(d); + write_to_output(d, "-- Special procedures:\r\n"); + + sprintf(buf, "%s%2d%s) %-18s ", grn, i++, nrm, "None" ); + counter2 = 1; + + for(counter = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_MOBILE)) + continue; + if (!(spec_table[counter].useful)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (!strn_cmp(spec_table[counter].name, "spec_", 5)) + sprintf(buf + strlen(buf), "%s%2d%s) %-18s ", + grn, i++, nrm, spec_table[counter].name+5); + else + sprintf(buf + strlen(buf), "%s%2d%s) %-18s ", + grn, i++, nrm, spec_table[counter].name); + if (!((++counter2) % 3)) + strcat(buf, "\r\n"); + } + if (counter2) + strcat(buf, "\r\n"); + strcat(buf, "Choose a procedure: "); + write_to_output(d, "%s", buf); + OLC_MODE(d) = MEDIT_PROC; +} + +/*-------------------------------------------------------------------*/ + +void medit_disp_emob_stats(struct descriptor_data *d) +{ + char *proc_point; + struct char_data *mob; + mob = OLC_MOB(d); + + proc_point = spec_name(OLC_PROC(d)); + + get_char_colors(d->character); + clear_screen(d); + sprintf(buf, + "%s-- Enhanced mob stats:\r\n" + " %sS%s) Strength [%s%-2d%s ]" " %sI%s) Intelligence [%s%-2d%s ]\r\n" + " %sW%s) Wisdom [%s%-2d%s ]" " %sD%s) Dexterity [%s%-2d%s ]\r\n" + " %sC%s) Constitution [%s%-2d%s ]" " %sH%s) Charisma [%s%-2d%s ]\r\n" + " %sP%s) Str-Add [%s%-3d%s]" " %sX%s) Special Proc [%s%s%s]\r\n" + " %s0%s) Quit\r\n" + "Enter Choice: ", + nrm, + grn, nrm, cyn, mob->real_abils.str, nrm, + grn, nrm, cyn, mob->real_abils.intel, nrm, + grn, nrm, cyn, mob->real_abils.wis, nrm, + grn, nrm, cyn, mob->real_abils.dex, nrm, + grn, nrm, cyn, mob->real_abils.con, nrm, + grn, nrm, cyn, mob->real_abils.cha, nrm, + grn, nrm, cyn, mob->real_abils.str_add, nrm, + grn, nrm, cyn, proc_point, nrm, + grn, nrm + ); + write_to_output(d, "%s", buf); + OLC_MODE(d) = MEDIT_EMOB_STATS; +} + +/*-------------------------------------------------------------------*/ /* * Display attack types menu. @@ -407,11 +486,41 @@ void medit_disp_menu(struct descriptor_data *d) { struct char_data *mob; + char ebuf[MAX_STRING_LENGTH]; mob = OLC_MOB(d); get_char_colors(d->character); clear_screen(d); + /*sprintbit(mob->mob_specials.resist, ris_bits, rbuf); + sprintbit(mob->mob_specials.immune, ris_bits, ibuf); + sprintbit(mob->mob_specials.suscept, ris_bits, sbuf);*/ + + if (/*mob->nr != NOBODY*/ 1) + { + if (mob->real_abils.str != 11 || mob->real_abils.str_add != 0 || + mob->real_abils.intel != 11 || mob->real_abils.wis != 11 || + mob->real_abils.dex != 11 || mob->real_abils.con != 11 || + mob->real_abils.cha != 11) + { + sprintf(ebuf, "%d+%d/%d/%d/%d/%d/%d", + mob->real_abils.str, mob->real_abils.str_add, + mob->real_abils.intel, mob->real_abils.wis, + mob->real_abils.dex, mob->real_abils.con, + mob->real_abils.cha); + } + else + { + if (OLC_PROC(d)) { + sprintf(ebuf, "Simple mob (Spec: %s)", + spec_name(OLC_PROC(d))); + } + else strcpy(ebuf, "Simple mob"); + } + } + else strcpy(ebuf, "Simple mob"); + + write_to_output(d, "-- Mob Number: [%s%d%s]\r\n" "%s1%s) Sex: %s%-7.7s%s %s2%s) Alias: %s%s\r\n" @@ -452,6 +561,7 @@ "%sK%s) Attack : %s%s\r\n" "%sL%s) NPC Flags : %s%s\r\n" "%sM%s) AFF Flags : %s%s\r\n" + "%sN%s) Enhance : %s%d attack(s), %s\r\n" #if CONFIG_OASIS_MPROG "%sP%s) Mob Progs : %s%s\r\n" #endif @@ -460,9 +570,10 @@ grn, nrm, yel, position_types[(int)GET_POS(mob)], grn, nrm, yel, position_types[(int)GET_DEFAULT_POS(mob)], - grn, nrm, yel, attack_hit_text[GET_ATTACK(mob)].singular, + grn, nrm, yel, attack_hit_text[(int)GET_ATTACK(mob)].singular, grn, nrm, cyn, buf1, grn, nrm, cyn, buf2, + grn, nrm, cyn, 1 /* (int)GET_MOB_ATTACKS(mob) */, ebuf, #if CONFIG_OASIS_MPROG grn, nrm, cyn, (OLC_MPROGL(d) ? "Set." : "Not Set."), #endif @@ -639,6 +750,11 @@ OLC_MODE(d) = MEDIT_AFF_FLAGS; medit_disp_aff_flags(d); return; + case 'n': + case 'N': + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; #if CONFIG_OASIS_MPROG case 'p': case 'P': @@ -719,6 +835,145 @@ medit_disp_aff_flags(d); return; /*-------------------------------------------------------------------*/ + case MEDIT_PROC: + { + int j = atoi(arg), counter, k; + + if (!*arg) { + medit_disp_emob_stats(d); + return; + } + + if (!isdigit(*arg)) { + for(counter = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_MOBILE)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (!str_cmp(spec_table[counter].name, arg)) + break; + if (!strn_cmp(spec_table[counter].name, "spec_", 5) && + !str_cmp(spec_table[counter].name+5, arg)) + break; + } + if (!spec_table[counter].name) { + write_to_output(d, "%s", "Must be a numeric value or an item in the list.\r\nTry again: "); + return; + } + OLC_VAL(d) = 1; + OLC_PROC(d) = spec_table[counter].func; + medit_disp_emob_stats(d); + return; + } + + if (j == 0) { + OLC_PROC(d) = NULL; + medit_disp_emob_stats(d); + i++; + return; + } + for(counter = 0, k = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_MOBILE)) + continue; + if (!(spec_table[counter].useful)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (++k == j) + break; + } + + if (!spec_table[counter].name) { + write_to_output(d, "No such proc.\r\nTry again: "); + return; + } + OLC_PROC(d) = spec_table[counter].func; + medit_disp_emob_stats(d); + i++; + return; + } + break; +/*-------------------------------------------------------------------*/ + case MEDIT_EMOB_STATS: + switch (*arg) { + case 'q': + case 'Q': + case '0': + OLC_MODE(d) = MEDIT_MAIN_MENU; + break; +/* case 'a': + case 'A': + OLC_MODE(d) = MEDIT_NATTACKS; + send_to_char( d->character, "Enter new numattacks: " ); + i++; + return;*/ + case 's': + case 'S': + OLC_MODE(d) = MEDIT_STR; + send_to_char( d->character, "Enter new strength: " ); + i++; + return; + case 'i': + case 'I': + OLC_MODE(d) = MEDIT_INT; + send_to_char( d->character, "Enter new intelligence: " ); + i++; + return; + case 'w': + case 'W': + OLC_MODE(d) = MEDIT_WIS; + send_to_char( d->character, "Enter new wisdom: " ); + i++; + return; + case 'd': + case 'D': + OLC_MODE(d) = MEDIT_DEX; + send_to_char( d->character, "Enter new dexterity: " ); + i++; + return; + case 'c': + case 'C': + OLC_MODE(d) = MEDIT_CON; + send_to_char( d->character, "Enter new constitution: " ); + i++; + return; + case 'h': + case 'H': + OLC_MODE(d) = MEDIT_CHA; + send_to_char( d->character, "Enter new charisma: " ); + i++; + return; + case 'p': + case 'P': + OLC_MODE(d) = MEDIT_STRADD; + send_to_char( d->character, "Enter new strength damage bonus: " ); + i++; + return; + case 'x': + case 'X': + do { + int counter; + + for(counter = 0; spec_table[counter].name; counter++) + if (OLC_PROC(d) == spec_table[counter].func) + break; + if (GET_REAL_LEVEL(d->character) != LVL_IMPL && spec_table[counter].name && + (spec_table[counter].edit_level > GET_REAL_LEVEL(d->character))) { + write_to_output(d, "You aren't godly enough to remove this proc.\r\n"); + + OLC_MODE(d) = MEDIT_EMOB_STATS; + return; + } + } while(0); + OLC_MODE(d) = MEDIT_PROC; + medit_disp_proc_menu(d); + return; + default: + medit_disp_emob_stats(d); + return; + } + break; +/*-------------------------------------------------------------------*/ #if CONFIG_OASIS_MPROG case MEDIT_MPROG: if ((i = atoi(arg)) == 0) @@ -877,6 +1132,65 @@ case MEDIT_ALIGNMENT: GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000); break; + + case MEDIT_STR: + OLC_MOB(d)->real_abils.str = OLC_MOB(d)->aff_abils.str = MIN(25, MAX(3, atoi(arg)) ); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_INT: + OLC_MOB(d)->real_abils.intel = OLC_MOB(d)->aff_abils.intel = MIN(25, MAX(3, atoi(arg)) ); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_WIS: + OLC_MOB(d)->real_abils.wis = OLC_MOB(d)->aff_abils.wis = MIN(25, MAX(3, atoi(arg)) ); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_DEX: + OLC_MOB(d)->real_abils.dex = OLC_MOB(d)->aff_abils.dex = MIN(25, MAX(3, atoi(arg)) ); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_CON: + OLC_MOB(d)->real_abils.con = OLC_MOB(d)->aff_abils.con = MIN(25, MAX(3, atoi(arg)) ); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_CHA: + OLC_MOB(d)->real_abils.cha = OLC_MOB(d)->aff_abils.cha = MIN(25, MAX(3, atoi(arg)) ); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_STRADD: + OLC_MOB(d)->real_abils.str_add = OLC_MOB(d)->aff_abils.str_add = MIN(100, MAX(0, atoi(arg)) ); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; +/* + case MEDIT_NATTACKS: + GET_MOB_ATTACKS(OLC_MOB(d)) = MAX(0, MIN(10, atoi(arg))); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_CLAN: + GET_MOB_CLAN(OLC_MOB(d)) = MAX(0, MIN(MAX_CLANS - 1, i)); + OLC_MODE(d) = MEDIT_EMOB_STATS; + medit_disp_emob_stats(d); + return; + case MEDIT_MANA: + GET_MAX_MANA(OLC_MOB(d)) = MAX(-1, MIN(5000, atoi(arg))); + OLC_MODE(d) = MEDIT_FIELD; + medit_disp_field_ed(d); + return; + case MEDIT_MOVE: + GET_MAX_MOVE(OLC_MOB(d)) = MAX(-1, MIN(5000, atoi(arg))); + OLC_MODE(d) = MEDIT_FIELD; + medit_disp_field_ed(d); + return; + */ + /*-------------------------------------------------------------------*/ default: diff -ur ../circle30bpl22_oas/src/oasis.c ./src/oasis.c --- ../circle30bpl22_oas/src/oasis.c Mon Oct 28 21:51:47 2002 +++ ./src/oasis.c Mon Oct 28 20:33:10 2002 @@ -298,6 +298,8 @@ if (d->olc == NULL) return; + OLC_PROC(d) = NULL; + /* * Check for a room. free_room doesn't perform * sanity checks, we must be careful here. diff -ur ../circle30bpl22_oas/src/oasis.h ./src/oasis.h --- ../circle30bpl22_oas/src/oasis.h Mon Oct 28 21:51:47 2002 +++ ./src/oasis.h Mon Oct 28 20:51:58 2002 @@ -102,6 +102,7 @@ struct mob_prog_data *mprog; struct mob_prog_data *mprogl; #endif + SPEC_FUN* proc; }; /* @@ -127,6 +128,7 @@ #define OLC_MOB(d) (OLC(d)->mob) /* Mob structure. */ #define OLC_SHOP(d) (OLC(d)->shop) /* Shop structure. */ #define OLC_DESC(d) (OLC(d)->desc) /* Extra description. */ +#define OLC_PROC(d) (OLC(d)->proc) /* Spec proc */ #if CONFIG_OASIS_MPROG #define OLC_MPROG(d) (OLC(d)->mprog) /* Temporary MobProg. */ #define OLC_MPROGL(d) (OLC(d)->mprogl) /* MobProg list. */ @@ -174,6 +176,7 @@ #define OEDIT_EXTRADESC_MENU 24 #define OEDIT_LEVEL 25 #define OEDIT_PERM 26 +#define OEDIT_PROC 27 /* * Submodes of REDIT connectedness. @@ -194,6 +197,7 @@ #define REDIT_EXTRADESC_MENU 14 #define REDIT_EXTRADESC_KEY 15 #define REDIT_EXTRADESC_DESCRIPTION 16 +#define REDIT_PROC 17 /* * Submodes of ZEDIT connectedness. @@ -225,6 +229,8 @@ #define MEDIT_NPC_FLAGS 5 #define MEDIT_AFF_FLAGS 6 #define MEDIT_CONFIRM_SAVESTRING 7 +#define MEDIT_EMOB_STATS 8 + /* * Numerical responses. */ @@ -253,6 +259,15 @@ #define MEDIT_MPROG_TYPE 31 #define MEDIT_PURGE_MPROG 32 #endif +#define MEDIT_STR 33 +#define MEDIT_INT 34 +#define MEDIT_WIS 35 +#define MEDIT_DEX 36 +#define MEDIT_CON 37 +#define MEDIT_CHA 38 +#define MEDIT_STRADD 39 +#define MEDIT_PROC 40 + /* * Submodes of SEDIT connectedness. diff -ur ../circle30bpl22_oas/src/oedit.c ./src/oedit.c --- ../circle30bpl22_oas/src/oedit.c Mon Oct 28 21:51:47 2002 +++ ./src/oedit.c Mon Oct 28 21:19:13 2002 @@ -38,6 +38,7 @@ extern struct spell_info_type spell_info[]; extern struct board_info_type board_info[]; extern struct descriptor_data *descriptor_list; +extern struct spec_table_data spec_table[]; /*------------------------------------------------------------------------*/ @@ -61,6 +62,7 @@ GET_OBJ_WEAR(OLC_OBJ(d)) = ITEM_WEAR_TAKE; OLC_VAL(d) = 0; oedit_disp_menu(d); + OLC_PROC(d) = NULL; } /*------------------------------------------------------------------------*/ @@ -80,6 +82,7 @@ */ OLC_OBJ(d) = obj; OLC_VAL(d) = 0; + OLC_PROC(d) = obj_index[real_num].func; oedit_disp_menu(d); } @@ -98,6 +101,11 @@ return; } + if (obj_index[robj_num].func != OLC_PROC(d)) + add_to_save_list(zone_table[OLC_ZNUM(d)].number, SL_ZON); + + obj_index[robj_num].func = OLC_PROC(d); + if (!i) /* If it's not a new object, don't renumber. */ return; @@ -468,6 +476,43 @@ } /* + * Object procedure + */ +void oedit_disp_proc_menu(struct descriptor_data *d) +{ + int counter = 0, counter2 = 0, i = 0; + + get_char_colors(d->character); + clear_screen(d); + write_to_output(d, "-- Special procedures:\r\n"); + + sprintf(buf, "%s%2d%s) %-18s ", grn, i++, nrm, "None" ); + counter2 = 1; + + for(counter = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_OBJECT)) + continue; + if (!(spec_table[counter].useful)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (!strn_cmp(spec_table[counter].name, "spec_", 5)) + sprintf(buf + strlen(buf), "%s%2d%s) %-18s ", + grn, i++, nrm, spec_table[counter].name+5); + else + sprintf(buf + strlen(buf), "%s%2d%s) %-18s ", + grn, i++, nrm, spec_table[counter].name); + if (!((++counter2) % 3)) + strcat(buf, "\r\n"); + } + if (counter2) + strcat(buf, "\r\n"); + strcat(buf, "Choose a procedure: "); + write_to_output(d, "%s", buf); + OLC_MODE(d) = OEDIT_PROC; +} + +/* * Object perm flags. */ void oedit_disp_perm_menu(struct descriptor_data *d) @@ -562,6 +607,7 @@ "%sE%s) Extra descriptions menu\r\n" "%sM%s) Min Level : %s%d\r\n" "%sP%s) Perm Affects: %s%s\r\n" + "%sX%s) Spec proc : %s%s\r\n" "%sQ%s) Quit\r\n" "Enter choice : ", @@ -577,6 +623,7 @@ grn, nrm, grn, nrm, grn, nrm, cyn, GET_OBJ_LEVEL(obj), grn, nrm, cyn, buf2, + grn, nrm, cyn, OLC_PROC(d) ? spec_name(OLC_PROC(d)) : "None", grn, nrm ); OLC_MODE(d) = OEDIT_MAIN_MENU; @@ -714,6 +761,11 @@ oedit_disp_perm_menu(d); OLC_MODE(d) = OEDIT_PERM; break; + case 'x': + case 'X': + oedit_disp_proc_menu(d); + OLC_MODE(d) = OEDIT_PROC; + break; default: oedit_disp_menu(d); break; @@ -809,6 +861,69 @@ TOGGLE_BIT(GET_OBJ_PERM(OLC_OBJ(d)), 1 << (number - 1)); oedit_disp_perm_menu(d); return; + +/*-------------------------------------------------------------------*/ + case OEDIT_PROC: + { + int j = atoi(arg), counter, k, i=0; + + if (!*arg) { + oedit_disp_menu(d); + return; + } + + if (!isdigit(*arg)) { + for(counter = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_OBJECT)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (!str_cmp(spec_table[counter].name, arg)) + break; + if (!strn_cmp(spec_table[counter].name, "spec_", 5) && + !str_cmp(spec_table[counter].name+5, arg)) + break; + } + if (!spec_table[counter].name) { + write_to_output(d, "Must be a numeric value or an item in the list.\r\nTry again: "); + return; + } + if (OLC_PROC(d) != spec_table[counter].func) + OLC_VAL(d) = 1; + OLC_PROC(d) = spec_table[counter].func; + oedit_disp_menu(d); + return; + } + + if (j == 0) { + OLC_PROC(d) = NULL; + oedit_disp_menu(d); + i++; + break; + } + + for(counter = 0, k = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_OBJECT)) + continue; + if (!(spec_table[counter].useful)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (++k == j) + break; + } + + if (!spec_table[counter].name) { + write_to_output(d, "No such proc.\r\nTry again: "); + return; + } + OLC_PROC(d) = spec_table[counter].func; + oedit_disp_menu(d); + i++; + break; + } + return; +/*-------------------------------------------------------------------*/ case OEDIT_VALUE_1: /* diff -ur ../circle30bpl22_oas/src/redit.c ./src/redit.c --- ../circle30bpl22_oas/src/redit.c Mon Oct 28 21:51:47 2002 +++ ./src/redit.c Mon Oct 28 21:45:24 2002 @@ -38,6 +38,7 @@ extern room_vnum immort_start_room; extern room_vnum frozen_start_room; extern struct descriptor_data *descriptor_list; +extern struct spec_table_data spec_table[]; /*------------------------------------------------------------------------*/ @@ -55,6 +56,7 @@ OLC_ROOM(d)->number = NOWHERE; redit_disp_menu(d); OLC_VAL(d) = 0; + OLC_PROC(d) = NULL; } /*------------------------------------------------------------------------*/ @@ -64,6 +66,8 @@ struct room_data *room; int counter; + OLC_PROC(d) = world[real_num].func; + /* * Build a copy of the room for editing. */ @@ -139,6 +143,10 @@ /* FIXME: Why is this not set elsewhere? */ OLC_ROOM(d)->zone = OLC_ZNUM(d); + if (OLC_ROOM(d)->func != OLC_PROC(d)) + add_to_save_list(zone_table[OLC_ZNUM(d)].number, SL_ZON); + OLC_ROOM(d)->func = OLC_PROC(d); + if ((room_num = add_room(OLC_ROOM(d))) < 0) { write_to_output(d, "Something went wrong...\r\n"); log("SYSERR: redit_save_internally: Something failed! (%d)", room_num); @@ -325,6 +333,45 @@ } /* + * Room procedure + */ +void redit_disp_proc_menu(struct descriptor_data *d) +{ + int counter = 0, counter2 = 0, i = 0; + + get_char_colors(d->character); + clear_screen(d); + write_to_output(d, "-- Special procedures:\r\n"); + + sprintf(buf, "%s%2d%s) %-18s ", grn, i++, nrm, "None" ); + counter2 = 1; + + for(counter = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_ROOM)) + continue; + if (!(spec_table[counter].useful)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (!strn_cmp(spec_table[counter].name, "spec_", 5)) + sprintf(buf + strlen(buf), "%s%2d%s) %-18s ", + grn, i++, nrm, spec_table[counter].name+5); + else + sprintf(buf + strlen(buf), "%s%2d%s) %-18s ", + grn, i++, nrm, spec_table[counter].name); + if (!((++counter2) % 3)) + strcat(buf, "\r\n"); + } + if (counter2) + strcat(buf, "\r\n"); + strcat(buf, "Choose a procedure: "); + write_to_output(d, "%s", buf); + OLC_MODE(d) = REDIT_PROC; +} + + + +/* * For sector type. */ void redit_disp_sector_menu(struct descriptor_data *d) @@ -365,6 +412,7 @@ "%s8%s) Exit west : %s%d\r\n" "%s9%s) Exit up : %s%d\r\n" "%sA%s) Exit down : %s%d\r\n" + "%sX%s) Procedure : %s%s%s\r\n" "%sB%s) Extra descriptions menu\r\n" "%sQ%s) Quit\r\n" "Enter choice : ", @@ -393,7 +441,9 @@ grn, nrm, cyn, room->dir_option[DOWN] && room->dir_option[DOWN]->to_room != -1 ? world[room->dir_option[DOWN]->to_room].number : -1, - grn, nrm, grn, nrm + grn, nrm, cyn, OLC_PROC(d) ? spec_name(OLC_PROC(d)) : "none", nrm, + grn, nrm, + grn, nrm ); OLC_MODE(d) = REDIT_MAIN_MENU; @@ -502,6 +552,11 @@ OLC_DESC(d) = OLC_ROOM(d)->ex_description; redit_disp_extradesc_menu(d); break; + case 'x': + case 'X': + redit_disp_proc_menu(d); + OLC_MODE(d) = REDIT_PROC; + break; default: write_to_output(d, "Invalid choice!"); redit_disp_menu(d); @@ -654,7 +709,69 @@ OLC_DESC(d)->keyword = strdup(arg); redit_disp_extradesc_menu(d); return; +/*-------------------------------------------------------------------*/ + case REDIT_PROC: + { + int j = atoi(arg), counter, k, i=0; + + if (!*arg) { + redit_disp_menu(d); + return; + } + + if (!isdigit(*arg)) { + for(counter = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_ROOM)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (!str_cmp(spec_table[counter].name, arg)) + break; + if (!strn_cmp(spec_table[counter].name, "spec_", 5) && + !str_cmp(spec_table[counter].name+5, arg)) + break; + } + if (!spec_table[counter].name) { + write_to_output(d, "Must be a numeric value or an item in the list.\r\nTry again: "); + return; + } + if (OLC_PROC(d) != spec_table[counter].func) + OLC_VAL(d) = 1; + OLC_PROC(d) = spec_table[counter].func; + redit_disp_menu(d); + break; + } + + if (j == 0) { + OLC_PROC(d) = NULL; + redit_disp_menu(d); + i++; + break; + } + + for(counter = 0, k = 0; spec_table[counter].name; counter++) { + if (!(spec_table[counter].type & PROC_ROOM)) + continue; + if (!(spec_table[counter].useful)) + continue; + if (spec_table[counter].assign_level > GET_REAL_LEVEL(d->character)) + continue; + if (++k == j) + break; + } + + if (!spec_table[counter].name) { + write_to_output(d, "No such proc.\r\nTry again: "); + return; + } + OLC_PROC(d) = spec_table[counter].func; + redit_disp_menu(d); + i++; + break; + } + return; +/*-------------------------------------------------------------------*/ case REDIT_EXTRADESC_MENU: switch ((number = atoi(arg))) { case 0: diff -ur ../circle30bpl22_oas/src/spec_assign.c ./src/spec_assign.c --- ../circle30bpl22_oas/src/spec_assign.c Tue Dec 4 06:22:54 2001 +++ ./src/spec_assign.c Mon Oct 28 20:23:50 2002 @@ -22,8 +22,11 @@ extern int mini_mud; /* external functions */ -SPECIAL(dump); +void assign_kings_castle(void); + +/* spec funcs */ SPECIAL(pet_shops); +SPECIAL(dump); SPECIAL(postmaster); SPECIAL(cityguard); SPECIAL(receptionist); @@ -39,7 +42,7 @@ SPECIAL(magic_user); SPECIAL(bank); SPECIAL(gen_board); -void assign_kings_castle(void); +SPECIAL(shop_keeper); /* local functions */ void assign_mobiles(void); @@ -48,6 +51,114 @@ void ASSIGNROOM(room_vnum room, SPECIAL(fname)); void ASSIGNMOB(mob_vnum mob, SPECIAL(fname)); void ASSIGNOBJ(obj_vnum obj, SPECIAL(fname)); + + +#define SPEC_TAB(p, t, l1, l2) { #p, t, l1, l2, p, 0 } +#define uSPEC_TAB(p, t, l1, l2) { #p, t, l1, l2, p, 1 } + +/* + * Table presently only for recognition; olc-assignment of procs not + * included + * + * SPEC_TAB( , + * , + * , + * ) + * + */ +struct spec_table_data spec_table[] = { + /* Mobile entries */ + uSPEC_TAB( fido, PROC_MOBILE, LVL_IMMORT, 0 ), + uSPEC_TAB( janitor, PROC_MOBILE, LVL_IMMORT, 0 ), + uSPEC_TAB( snake, PROC_MOBILE, LVL_IMMORT, 0 ), + uSPEC_TAB( thief, PROC_MOBILE, LVL_IMMORT, 0 ), + uSPEC_TAB( magic_user, PROC_MOBILE, LVL_IMMORT, 0 ), + uSPEC_TAB( postmaster, PROC_MOBILE, LVL_GOD, 0 ), + uSPEC_TAB( cityguard, PROC_MOBILE, LVL_GOD, 0 ), + uSPEC_TAB( receptionist, PROC_MOBILE, LVL_GOD, 0 ), + uSPEC_TAB( cryogenicist, PROC_MOBILE, LVL_GOD, 0 ), + SPEC_TAB( guild_guard, PROC_MOBILE, LVL_IMPL, 0 ), + SPEC_TAB( guild, PROC_MOBILE, LVL_IMPL, 0 ), + SPEC_TAB( puff, PROC_MOBILE, LVL_IMPL, 0 ), + SPEC_TAB( mayor, PROC_MOBILE, LVL_IMPL, 0 ), + + /* Room entries */ + SPEC_TAB( dump, PROC_ROOM, LVL_IMPL, 0 ), + uSPEC_TAB( pet_shops, PROC_ROOM, LVL_GOD, 0 ), + + + SPEC_TAB( gen_board, PROC_OBJECT, LVL_IMPL, 0 ), + + uSPEC_TAB( bank, PROC_ROOM| + PROC_OBJECT, LVL_IMPL, 0 ), + + /* Note: leave PROC_NONE */ + SPEC_TAB( shop_keeper, PROC_NONE, LVL_IMPL, 0 ), + + { NULL, 0, 0, 0, (SPEC_FUN *) 0, 0 } +}; + +#define shop_keeper ___error___ /* This proc should never be manually assigned */ + +/* utility functions for procedure naming */ + +/** + * @brief Get name of proc reprsented by func. + * @pre `func' is a pointer to a valid function of type + * int (struct char_data*, void*, int, char*) + * @return Name of function if it's an indexed procedure, + * or a string in angle-brackets suitable for error display. + */ +char *spec_name(SPEC_FUN *func) { + int i = 0; + for (i = 0; spec_table[i].name; i++) + if (spec_table[i].func == func) + return spec_table[i].name; + if (!func) + return PROC_NONE; + return PROC_UNKNOWN; +} + + +/** + * @brief Get function pointer from proc name + * @pre `name' is a valid asciiz string, type is a bitvector + * of values from PROC_ALL + * @return (SPECPTR)0 if no function available, + * or a pointer to the proc + */ +SPEC_FUN *get_spec_fun(char *name, int type) { + int i = 0; + if (!name) + return NULL; + + for (i = 0; spec_table[i].name; i++) + if (!str_cmp(spec_table[i].name, name) && + (!type || (IS_SET(spec_table[i].type, type)))) + return spec_table[i].func; + return NULL; +} + +/** + * @brief Get spec data given name and type + * @pre `name' is a valid asciiz string, type is a bitvector + * of values taken from PROC_ALL + * @return (SPECPTR)0 if no function available, + * or a pointer to the proc + */ +struct spec_table_data *get_spec_data(char *name, int type) +{ + int i = 0; + if (!name) + return NULL; + + for (i = 0; spec_table[i].name; i++) + if (!str_cmp(spec_table[i].name, name) && + (!type || (IS_SET(spec_table[i].type, type)))) + return &spec_table[i]; + return NULL; +} + /* functions to perform assignments */ diff -ur ../circle30bpl22_oas/src/structs.h ./src/structs.h --- ../circle30bpl22_oas/src/structs.h Mon Oct 28 21:51:47 2002 +++ ./src/structs.h Mon Oct 28 20:16:20 2002 @@ -30,6 +30,7 @@ #define USE_AUTOEQ 0 /* TRUE/FALSE aren't defined yet. */ + /* preamble *************************************************************/ /* @@ -215,6 +216,8 @@ #define PRF_NOGRATZ (1 << 20) /* Can't hear grats channel */ #define PRF_ROOMFLAGS (1 << 21) /* Can see room flags (ROOM_x) */ #define PRF_DISPAUTO (1 << 22) /* Show prompt HP, MP, MV when < 30%. */ +#define PRF_CLS (1 << 23) /* Clear screen in OasisOLC */ + /* Affect bits: used in char_data.char_specials.saved.affected_by */ /* WARNING: In the world files, NEVER set the bits marked "R" ("Reserved") */ @@ -531,6 +534,15 @@ #error See the comment near these errors for more explanation. #endif +/* Spec-proc types */ +#define PROC_MOBILE 0x1 +#define PROC_OBJECT 0x2 +#define PROC_ROOM 0x4 +#define PROC_ALL (PROC_MOBILE|PROC_OBJECT|PROC_ROOM) +#define PROC_UNKNOWN "" +#define PROC_NONE "" + + /********************************************************************** * Structures * **********************************************************************/ @@ -562,6 +574,9 @@ typedef IDXTYPE zone_rnum; typedef IDXTYPE shop_rnum; +struct char_data; + +typedef int SPEC_FUN(struct char_data*, void*, int, char*); /* * Bitvector type for 32 bit unsigned long bitvectors. @@ -1022,8 +1037,17 @@ void *olc; }; - /* other miscellaneous structures ***************************************/ + + +struct spec_table_data { + char *name; /* name of the procedure */ + int type; /* type of proc obj, mob, room, all? */ + int assign_level; /* level required to stamp this proc on something */ + int edit_level; /* level required to edit obj with this proc */ + SPEC_FUN *func; /* the function to assign/execute */ + int useful; /*!< Common proc? */ +}; struct msg_type { Only in ../circle30bpl22_oas/src: structs.h~ Only in ./src/util: Makefile.rej