Ok guys... Below this will come the files spec_names.c and spec_names.h . To implement, read spec_names.c for information on how to add the names of the spec_procs. If you want to use the functions: just #include spec_names.h in whatever file you want it. I have it in act.wizard.c for do_stat and do_set; Just use get_spec_name(proc), that will always give a valid char*. I also added it in db.c so I could name spec_procs in the world files. Add something like if the last line is "P", then the next line should be the name of a spec proc -> if(!(proto->func = get_spec_proc(blabla))) { complain; } Catch my drift? Ok, have fun with it now... PS: we had a very messy imp once, whose room was full of junk the whole time, so I just did a set <room> specproc dump :) it took him quite a while to figure out :) (what? nothing in spec_assign? :]) -----8<-----spec_names.c------ /* ************************************************************************ * File: spec_names.c Part of CircleMUD * * Usage: Keep the names of the spec procs handy for stats and stuff * * like that * * * * By Gekke Eekhoorn of BUG, march 1995. * * * * All rights reserved. See license.doc for complete information. * * * * Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * ************************************************************************ */ #include <string.h> #include "structs.h" #include "utils.h" #include "comm.h" #include "spec_names.h" /* definition of proctype */ SPECIAL(postmaster); SPECIAL(cityguard); SPECIAL(receptionist); SPECIAL(cryogenicist); SPECIAL(guild_guard); SPECIAL(guild); SPECIAL(puff); SPECIAL(fido); SPECIAL(janitor); SPECIAL(mayor); SPECIAL(snake); SPECIAL(thief); SPECIAL(magic_user); SPECIAL(bank); SPECIAL(gen_board); SPECIAL(dump); SPECIAL(pet_shops); SPECIAL(CastleGuard); SPECIAL(James); SPECIAL(cleaning); SPECIAL(DicknDavid); SPECIAL(tim); SPECIAL(tom); SPECIAL(king_welmar); SPECIAL(training_master); SPECIAL(peter); SPECIAL(jerry); SPECIAL(shop_keeper); struct spec_list { char name[25]; SPECIAL(*func); }; /* Here's the deal: if you have a lot of names to do, just copy the SPECIAL assigns to them to where you want the names to come and run the file through awk with the following awk program: (The SPECIALS should be between the BEGIN and STOP comments) (Don't forget the shopkeeper: He isn't used in spec_assign, nor castle) ----cut here----file: namesbuild---- BEGIN { f=0 FS="\n" OFS="" } /BEGIN HERE/ {f=1} /STOP HERE/ {f=0} { if (f && $0 ~ /SPECIAL/) { name = substr($0,index($0, "(")+1, index($0, ")")-index($0,"(")-1); print " {\"",name, "\", ", name, "}," } else print } -------------- awk -f namesbuild spec_names.c>out should do it. afterwards, move out to spec_names.c. so to add the special SPECIAL(foo) you would write SPECIAL(foo); to where you want the name to come in the list. */ struct spec_list spec_names[] = { /* BEGIN HERE */ {"postmaster", postmaster}, {"cityguard", cityguard}, {"receptionist", receptionist}, {"cryogenicist", cryogenicist}, {"guild_guard", guild_guard}, {"guild", guild}, {"puff", puff}, {"fido", fido}, {"janitor", janitor}, {"mayor", mayor}, {"snake", snake}, {"thief", thief}, {"magic_user", magic_user}, {"bank", bank}, {"gen_board", gen_board}, {"dump", dump}, {"pet_shops", pet_shops}, {"CastleGuard", CastleGuard}, {"James", James}, {"cleaning", cleaning}, {"DicknDavid", DicknDavid}, {"tim", tim}, {"tom", tom}, {"king_welmar", king_welmar}, {"training_master", training_master}, {"peter", peter}, {"jerry", jerry}, {"shop_keeper", shop_keeper}, /* STOP HERE */ {"Unknown; exists", NULL} /* Terminator */ }; /* Get the name of a special proc. */ char *get_spec_name(SPECIAL(func)) { int i=0; if (!func) return "None"; for (; spec_names[i].func && spec_names[i].func!=func; i++); return spec_names[i].name; } /* Get a pointer to the function when you have a name */ proctype get_spec_proc(char *name) { int i=0; for (; spec_names[i].func && str_cmp(name, spec_names[i].name); i++); return spec_names[i].func; } /* Show all specprocs */ /* Don't ask me; I haven't got the foggiest idea why I put this in. Debugging maybe... :] */ void list_spec_procs(struct char_data *ch) { int i=0; for(; spec_names[i].func; i++) { send_to_char(spec_names[i].name, ch); if (i%4==3) send_to_char("\r\n", ch); else send_to_char("\t\t", ch); } send_to_char("\r\n", ch); } ------------------------------ -----8<-----spec_names.h------ /* spec_names.h defines etc for spec_names.c */ #ifndef SPECIAL #error structs.h must be included! #else typedef SPECIAL(*proctype); char *get_spec_name(SPECIAL(func)); proctype get_spec_proc(char *name); void list_spec_procs(struct char_data *ch); #endif ------------------------------ Gekke Eekhoorn of BUG.
This archive was generated by hypermail 2b30 : 12/18/00 PST