#include "copyright.h"
#include "htab.h"
#include "db.h"
Include dependency graph for powers.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | power_entry |
struct | powerset |
Defines | |
#define | POWER_EXT 0x1 |
#define | POW_CHG_QUOTAS 0x00000001 |
#define | POW_CHOWN_ANY 0x00000002 |
#define | POW_ANNOUNCE 0x00000004 |
#define | POW_BOOT 0x00000008 |
#define | POW_HALT 0x00000010 |
#define | POW_CONTROL_ALL 0x00000020 |
#define | POW_WIZARD_WHO 0x00000040 |
#define | POW_EXAM_ALL 0x00000080 |
#define | POW_FIND_UNFIND 0x00000100 |
#define | POW_FREE_MONEY 0x00000200 |
#define | POW_FREE_QUOTA 0x00000400 |
#define | POW_HIDE 0x00000800 |
#define | POW_IDLE 0x00001000 |
#define | POW_SEARCH 0x00002000 |
#define | POW_LONGFINGERS 0x00004000 |
#define | POW_PROG 0x00008000 |
#define | POW_COMM_ALL 0x00080000 |
#define | POW_SEE_QUEUE 0x00100000 |
#define | POW_SEE_HIDDEN 0x00200000 |
#define | POW_MONITOR 0x00400000 |
#define | POW_POLL 0x00800000 |
#define | POW_NO_DESTROY 0x01000000 |
#define | POW_GUEST 0x02000000 |
#define | POW_PASS_LOCKS 0x04000000 |
#define | POW_STAT_ANY 0x08000000 |
#define | POW_STEAL 0x10000000 |
#define | POW_TEL_ANYWHR 0x20000000 |
#define | POW_TEL_UNRST 0x40000000 |
#define | POW_UNKILLABLE 0x80000000 |
#define | POW_BUILDER 0x00000001 |
#define | POW_MECH 0x00000002 |
#define | POW_SECURITY 0x00000004 |
#define | POW_MECHREP 0x00000008 |
#define | POW_MAP 0x00000010 |
#define | POW_TEMPLATE 0x00000020 |
#define | POW_TECH 0x00000040 |
#define | s_Change_Quotas(c) s_Powers((c), Powers(c) | POW_CHG_QUOTAS) |
#define | s_Chown_Any(c) s_Powers((c), Powers(c) | POW_CHOWN_ANY) |
#define | s_Announce(c) s_Powers((c), Powers(c) | POW_ANNOUNCE) |
#define | s_Can_Boot(c) s_Powers((c), Powers(c) | POW_BOOT) |
#define | s_Can_Halt(c) s_Powers((c), Powers(c) | POW_HALT) |
#define | s_Control_All(c) s_Powers((c), Powers(c) | POW_CONTROL_ALL) |
#define | s_Wizard_Who(c) s_Powers((c), Powers(c) | POW_WIZARD_WHO) |
#define | s_See_All(c) s_Powers((c), Powers(c) | POW_EXAM_ALL) |
#define | s_Find_Unfindable(c) s_Powers((c), Powers(c) | POW_FIND_UNFIND) |
#define | s_Free_Money(c) s_Powers((c), Powers(c) | POW_FREE_MONEY) |
#define | s_Free_Quota(c) s_Powers((c), Powers(c) | POW_FREE_QUOTA) |
#define | s_Can_Hide(c) s_Powers((c), Powers(c) | POW_HIDE) |
#define | s_Can_Idle(c) s_Powers((c), Powers(c) | POW_IDLE) |
#define | s_Search(c) s_Powers((c), Powers(c) | POW_SEARCH) |
#define | s_Long_Fingers(c) s_Powers((c), Powers(c) | POW_LONGFINGERS) |
#define | s_Prog(c) s_Powers((c), Powers(c) | POW_PROG) |
#define | s_Comm_All(c) s_Powers((c), Powers(c) | POW_COMM_ALL) |
#define | s_See_Queue(c) s_Powers((c), Powers(c) | POW_SEE_QUEUE) |
#define | s_See_Hidden(c) s_Powers((c), Powers(c) | POW_SEE_HIDDEN) |
#define | s_Can_Monitor(c) s_Powers((c), Powers(c) | POW_MONITOR) |
#define | s_Can_Poll(c) s_Powers((c), Powers(c) | POW_POLL) |
#define | s_No_Destroy(c) s_Powers((c), Powers(c) | POW_NO_DESTROY) |
#define | s_Guest(c) s_Powers((c), Powers(c) | POW_GUEST) |
#define | s_Set_Maint_Flags(c) s_Powers((c), Powers(c) | POW_SET_MFLAGS) |
#define | s_Stat_Any(c) s_Powers((c), Powers(c) | POW_STAT_ANY) |
#define | s_Steal(c) s_Powers((c), Powers(c) | POW_STEAL) |
#define | s_Tel_Anywhere(c) s_Powers((c), Powers(c) | POW_TEL_ANYWHR) |
#define | s_Tel_Anything(c) s_Powers((c), Powers(c) | POW_TEL_UNRST) |
#define | s_Unkillable(c) s_Powers((c), Powers(c) | POW_UNKILLABLE) |
#define | s_Builder(c) s_Powers2((c), Powers2(c) | POW_BUILDER) |
#define | s_Mech(c) s_Powers2((c), Powers2(c) | POW_MECH) |
#define | s_Security(c) s_Powers2((c), Powers2(c) | POW_SECURITY) |
#define | s_Mechrep(c) s_Powers2((c), Powers2(c) | POW_MECHREP) |
#define | s_Map(c) s_Powers2((c), Powers2(c) | POW_MAP) |
#define | s_Template(c) s_Powers2((c), Powers2(c) | POW_TEMPLATE) |
#define | s_Tech(c) s_Powers2((c), Powers2(c) | POW_TECH) |
#define | Quota(c) (((Powers(c) & POW_CHG_QUOTAS) != 0) || Wizard(c)) |
#define | Chown_Any(c) (((Powers(c) & POW_CHOWN_ANY) != 0) || Wizard(c)) |
#define | Announce(c) (((Powers(c) & POW_ANNOUNCE) != 0) || Wizard(c)) |
#define | Can_Boot(c) (((Powers(c) & POW_BOOT) != 0) || Wizard(c)) |
#define | Can_Halt(c) (((Powers(c) & POW_HALT) != 0) || Wizard(c)) |
#define | Control_All(c) (((Powers(c) & POW_CONTROL_ALL) != 0) || Wizard(c)) |
#define | Wizard_Who(c) (((Powers(c) & POW_WIZARD_WHO) != 0) || WizRoy(c)) |
#define | See_All(c) (((Powers(c) & POW_EXAM_ALL) != 0) || WizRoy(c)) |
#define | Find_Unfindable(c) ((Powers(c) & POW_FIND_UNFIND) != 0) |
#define | Free_Money(c) (((Powers(c) & POW_FREE_MONEY) != 0) || Immortal(c)) |
#define | Free_Quota(c) (((Powers(c) & POW_FREE_QUOTA) != 0) || Wizard(c)) |
#define | Can_Hide(c) ((Powers(c) & POW_HIDE) != 0) |
#define | Can_Idle(c) (((Powers(c) & POW_IDLE) != 0) || Wizard(c)) |
#define | Search(c) (((Powers(c) & POW_SEARCH) != 0) || WizRoy(c)) |
#define | Long_Fingers(c) (((Powers(c) & POW_LONGFINGERS) != 0) || Wizard(c)) |
#define | Comm_All(c) (((Powers(c) & POW_COMM_ALL) != 0) || Wizard(c)) |
#define | See_Queue(c) (((Powers(c) & POW_SEE_QUEUE) != 0) || WizRoy(c)) |
#define | See_Hidden(c) ((Powers(c) & POW_SEE_HIDDEN) != 0) |
#define | Can_Monitor(c) (((Powers(c) & POW_MONITOR) != 0) || Wizard(c)) |
#define | Can_Poll(c) (((Powers(c) & POW_POLL) != 0) || Wizard(c)) |
#define | No_Destroy(c) (((Powers(c) & POW_NO_DESTROY) != 0) || Wizard(c)) |
#define | Guest(c) ((Powers(c) & POW_GUEST) != 0) |
#define | Set_Maint_Flags(c) ((Powers(c) & POW_SET_MFLAGS) != 0) |
#define | Stat_Any(c) ((Powers(c) & POW_STAT_ANY) != 0) |
#define | Steal(c) (((Powers(c) & POW_STEAL) != 0) || Wizard(c)) |
#define | Tel_Anywhere(c) (((Powers(c) & POW_TEL_ANYWHR) != 0) || Tel_Anything(c)) |
#define | Tel_Anything(c) (((Powers(c) & POW_TEL_UNRST) != 0) || WizRoy(c)) |
#define | Unkillable(c) (((Powers(c) & POW_UNKILLABLE) != 0) || Immortal(c)) |
#define | Prog(c) (((Powers(c) & POW_PROG) != 0) || Wizard(c)) |
#define | Pass_Locks(c) ((Powers(c) & POW_PASS_LOCKS) != 0) |
#define | Builder(c) (((Powers2(c) & POW_BUILDER) != 0) || WizRoy(c)) |
#define | Mech(c) (((Powers2(c) & POW_MECH) != 0) || WizRoy(c)) |
#define | Security(c) (((Powers2(c) & POW_SECURITY) != 0) || WizRoy(c)) |
#define | Tech(c) (((Powers2(c) & POW_TECH) != 0) || WizRoy(c)) |
#define | Mechrep(c) (((Powers2(c) & POW_MECHREP) != 0) || WizRoy(c)) |
#define | Map(c) (((Powers2(c) & POW_MAP) != 0) || WizRoy(c)) |
#define | Template(c) (((Powers2(c) & POW_TEMPLATE) != 0) || WizRoy(c)) |
Typedefs | |
typedef power_entry | POWERENT |
typedef powerset | POWERSET |
Functions | |
void | init_powertab (void) |
void | display_powertab (dbref) |
void | power_set (dbref, dbref, char *, int) |
char * | power_description (dbref, dbref) |
POWERENT * | find_power (dbref, char *) |
int | has_power (dbref, dbref, char *) |
void | decompile_powers (dbref, dbref, char *) |
int | decode_power (dbref, char *, POWERSET *) |
Definition at line 166 of file powers.h.
Referenced by check_access(), match_status(), and process_cmdent().
Definition at line 151 of file powers.h.
Referenced by do_cemit(), do_chanlist(), do_channelwho(), do_chanobj(), do_chanstatus(), do_chboot(), do_chclose(), do_chloud(), do_chopaque(), do_chopen(), do_chsquelch(), do_chtransparent(), do_createchannel(), do_destroychannel(), do_editchannel(), do_listchannels(), do_test_access(), fun_cemit(), fun_clist(), fun_cobj(), and fun_cwho().
Definition at line 157 of file powers.h.
Referenced by announce_disconnect(), check_access(), check_connect(), destroy_guest(), do_give(), do_motd(), do_processcom(), and page_check().
Definition at line 150 of file powers.h.
Referenced by do_enter(), do_get(), do_give(), do_kill(), do_look(), do_pemit(), do_pemit_list(), and fun_name().
#define POWER_EXT 0x1 |
Definition at line 16 of file powers.h.
Referenced by decode_power(), decompile_powers(), has_power(), ph_any(), and power_description().
Definition at line 142 of file powers.h.
Referenced by do_channelwho(), do_comwho(), dump_users(), and fun_doing().
typedef struct power_entry POWERENT |
Definition at line 171 of file powers.c.
References hashfind(), mudstate, notify_printf(), POWER_EXT, power_entry::powerpower, statedata::powers_htab, power_entry::powervalue, powerset::word1, and powerset::word2.
Referenced by search_setup().
00172 { 00173 POWERENT *pent; 00174 00175 pset->word1 = 0; 00176 pset->word2 = 0; 00177 00178 pent = (POWERENT *) hashfind(powername, &mudstate.powers_htab); 00179 if(!pent) { 00180 notify_printf(player, "%s: Power not found.", powername); 00181 return 0; 00182 } 00183 if(pent->powerpower & POWER_EXT) 00184 pset->word2 = pent->powervalue; 00185 else 00186 pset->word1 = pent->powervalue; 00187 00188 return 1; 00189 }
Produce commands to set powers on target.
Definition at line 319 of file powers.c.
References CA_NO_DECOMP, check_access(), gen_powers, LBUF_SIZE, power_entry::listperm, notify_printf(), POWER_EXT, power_entry::powername, power_entry::powerpower, Powers, Powers2, power_entry::powervalue, and strip_ansi_r().
00320 { 00321 POWER f1, f2; 00322 POWERENT *fp; 00323 char new[LBUF_SIZE]; 00324 00325 /* 00326 * Report generic powers 00327 */ 00328 00329 f1 = Powers(thing); 00330 f2 = Powers2(thing); 00331 00332 for(fp = gen_powers; fp->powername; fp++) { 00333 00334 /* 00335 * Skip if we shouldn't decompile this power 00336 */ 00337 00338 if(fp->listperm & CA_NO_DECOMP) 00339 continue; 00340 00341 /* 00342 * Skip if this power is not set 00343 */ 00344 00345 if(fp->powerpower & POWER_EXT) { 00346 if(!(f2 & fp->powervalue)) 00347 continue; 00348 } else { 00349 if(!(f1 & fp->powervalue)) 00350 continue; 00351 } 00352 00353 /* 00354 * Skip if we can't see this power 00355 */ 00356 00357 if(!check_access(player, fp->listperm)) 00358 continue; 00359 00360 /* 00361 * We made it this far, report this power 00362 */ 00363 strncpy(new, thingname, LBUF_SIZE-1); 00364 notify_printf(player, "@power %s=%s", strip_ansi_r(new,thingname,strlen(thingname)), 00365 fp->powername); 00366 } 00367 }
void display_powertab | ( | dbref | player | ) |
Display available powers.
Definition at line 138 of file powers.c.
References alloc_lbuf, CA_GOD, CA_WIZARD, free_lbuf, gen_powers, God, power_entry::listperm, notify, power_entry::powername, safe_chr, safe_str, and Wizard.
Referenced by do_list().
00139 { 00140 char *buf, *bp; 00141 POWERENT *fp; 00142 00143 bp = buf = alloc_lbuf("display_powertab"); 00144 safe_str((char *) "Powers:", buf, &bp); 00145 for(fp = gen_powers; fp->powername; fp++) { 00146 if((fp->listperm & CA_WIZARD) && !Wizard(player)) 00147 continue; 00148 if((fp->listperm & CA_GOD) && !God(player)) 00149 continue; 00150 safe_chr(' ', buf, &bp); 00151 safe_str((char *) fp->powername, buf, &bp); 00152 } 00153 *bp = '\0'; 00154 notify(player, buf); 00155 free_lbuf(buf); 00156 }
Definition at line 158 of file powers.c.
References hashfind(), mudstate, statedata::powers_htab, and ToLower.
Referenced by has_power(), and power_set().
00159 { 00160 char *cp; 00161 00162 /* 00163 * Make sure the power name is valid 00164 */ 00165 00166 for(cp = powername; *cp; cp++) 00167 *cp = ToLower(*cp); 00168 return (POWERENT *) hashfind(powername, &mudstate.powers_htab); 00169 }
Does object have power visible to player?
Definition at line 246 of file powers.c.
References CA_GOD, CA_WIZARD, find_power(), God, power_entry::listperm, POWER_EXT, power_entry::powerpower, Powers, Powers2, power_entry::powervalue, and Wizard.
Referenced by fun_haspower().
00247 { 00248 POWERENT *fp; 00249 POWER fv; 00250 00251 fp = find_power(it, powername); 00252 if(fp == NULL) 00253 return 0; 00254 00255 if(fp->powerpower & POWER_EXT) 00256 fv = Powers2(it); 00257 else 00258 fv = Powers(it); 00259 00260 if(fv & fp->powervalue) { 00261 if((fp->listperm & CA_WIZARD) && !Wizard(player)) 00262 return 0; 00263 if((fp->listperm & CA_GOD) && !God(player)) 00264 return 0; 00265 return 1; 00266 } 00267 return 0; 00268 }
void init_powertab | ( | void | ) |
Initialize power hash tables.
Definition at line 119 of file powers.c.
References alloc_sbuf, free_sbuf, gen_powers, HASH_FACTOR, hashadd(), hashinit(), mudstate, power_entry::powername, statedata::powers_htab, and ToLower.
Referenced by main().
00120 { 00121 POWERENT *fp; 00122 char *nbuf, *np, *bp; 00123 00124 hashinit(&mudstate.powers_htab, 15 * HASH_FACTOR); 00125 nbuf = alloc_sbuf("init_powertab"); 00126 for(fp = gen_powers; fp->powername; fp++) { 00127 for(np = nbuf, bp = (char *) fp->powername; *bp; np++, bp++) 00128 *np = ToLower(*bp); 00129 *np = '\0'; 00130 hashadd(nbuf, (int *) fp, &mudstate.powers_htab); 00131 } 00132 free_sbuf(nbuf); 00133 }
Return an mbuf containing the type and powers on thing.
Definition at line 273 of file powers.c.
References alloc_mbuf, CA_GOD, CA_WIZARD, gen_powers, God, power_entry::listperm, POWER_EXT, power_entry::powername, power_entry::powerpower, Powers, Powers2, power_entry::powervalue, safe_mb_chr, safe_mb_str, Typeof, and Wizard.
Referenced by debug_examine(), and do_examine().
00274 { 00275 char *buff, *bp; 00276 POWERENT *fp; 00277 int otype; 00278 POWER fv; 00279 00280 /* 00281 * Allocate the return buffer 00282 */ 00283 00284 otype = Typeof(target); 00285 bp = buff = alloc_mbuf("power_description"); 00286 00287 /* 00288 * Store the header strings and object type 00289 */ 00290 00291 safe_mb_str((char *) "Powers:", buff, &bp); 00292 00293 for(fp = gen_powers; fp->powername; fp++) { 00294 if(fp->powerpower & POWER_EXT) 00295 fv = Powers2(target); 00296 else 00297 fv = Powers(target); 00298 if(fv & fp->powervalue) { 00299 if((fp->listperm & CA_WIZARD) && !Wizard(player)) 00300 continue; 00301 if((fp->listperm & CA_GOD) && !God(player)) 00302 continue; 00303 safe_mb_chr(' ', buff, &bp); 00304 safe_mb_str((char *) fp->powername, buff, &bp); 00305 } 00306 } 00307 00308 /* 00309 * Terminate the string, and return the buffer to the caller 00310 */ 00311 00312 *bp = '\0'; 00313 return buff; 00314 }
Definition at line 194 of file powers.c.
References find_power(), power_entry::handler, Name(), notify, notify_printf(), power_entry::powername, power_entry::powerpower, power_entry::powervalue, Quiet, and SET_QUIET.
Referenced by do_power().
00195 { 00196 POWERENT *fp; 00197 int negate, result; 00198 00199 /* 00200 * Trim spaces, and handle the negation character 00201 */ 00202 00203 negate = 0; 00204 while (*power && isspace(*power)) 00205 power++; 00206 if(*power == '!') { 00207 negate = 1; 00208 power++; 00209 } 00210 while (*power && isspace(*power)) 00211 power++; 00212 00213 /* 00214 * Make sure a power name was specified 00215 */ 00216 00217 if(*power == '\0') { 00218 if(negate) 00219 notify(player, "You must specify a power to clear."); 00220 else 00221 notify(player, "You must specify a power to set."); 00222 return; 00223 } 00224 fp = find_power(target, power); 00225 if(fp == NULL) { 00226 notify(player, "I don't understand that power."); 00227 return; 00228 } 00229 /* 00230 * Invoke the power handler, and print feedback 00231 */ 00232 00233 result = 00234 fp->handler(target, player, fp->powervalue, fp->powerpower, negate); 00235 if(!result) 00236 notify(player, "Permission denied."); 00237 else if(!(key & SET_QUIET) && !Quiet(player)) 00238 notify_printf(player, "%s - %s %s", Name(target), fp->powername, 00239 negate ? "removed." : "granted."); 00240 return; 00241 }