mux/src/powers.h File Reference

#include "copyright.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_SITEADMIN   0x00010000
#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 s_Guest(c)   s_Powers((c), Powers(c) | POW_GUEST)
#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) || Wizard(c))
#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) || WizRoy(c))
#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 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 Can_SiteAdmin(c)   (((Powers(c) & POW_SITEADMIN) != 0) || Wizard(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 * powers_list (dbref executor, dbref thing)
bool has_power (dbref, dbref, char *)
void decompile_powers (dbref, dbref, char *)
bool decode_power (dbref player, char *powername, POWERSET *pset)


Define Documentation

#define Announce (  )     (((Powers(c) & POW_ANNOUNCE) != 0) || Wizard(c))

Definition at line 83 of file powers.h.

Referenced by check_access().

#define Builder (  )     (((Powers2(c) & POW_BUILDER) != 0) || WizRoy(c))

Definition at line 110 of file powers.h.

Referenced by check_access(), check_command(), process_cmdent(), and return_bit().

#define Can_Boot (  )     (((Powers(c) & POW_BOOT) != 0) || Wizard(c))

Definition at line 84 of file powers.h.

Referenced by do_boot().

#define Can_Halt (  )     (((Powers(c) & POW_HALT) != 0) || Wizard(c))

Definition at line 85 of file powers.h.

Referenced by do_halt().

#define Can_Hide (  )     (((Powers(c) & POW_HIDE) != 0) || Wizard(c))

Definition at line 92 of file powers.h.

Referenced by announce_connect(), announce_disconnect(), fh_dark_bit(), FUNCTION(), nearby(), page_check(), and sweep_check().

#define Can_Idle (  )     (((Powers(c) & POW_IDLE) != 0) || Wizard(c))

Definition at line 93 of file powers.h.

Referenced by check_idle().

#define Can_Monitor (  )     (((Powers(c) & POW_MONITOR) != 0) || Wizard(c))

Definition at line 99 of file powers.h.

Referenced by fh_hear_bit().

#define Can_Poll (  )     (((Powers(c) & POW_POLL) != 0) || Wizard(c))

Definition at line 100 of file powers.h.

Referenced by do_doing().

#define Can_SiteAdmin (  )     (((Powers(c) & POW_SITEADMIN) != 0) || Wizard(c))

Definition at line 115 of file powers.h.

Referenced by do_restart(), and do_shutdown().

#define Chown_Any (  )     (((Powers(c) & POW_CHOWN_ANY) != 0) || Wizard(c))

Definition at line 82 of file powers.h.

Referenced by do_chown().

#define Comm_All (  )     (((Powers(c) & POW_COMM_ALL) != 0) || Wizard(c))

Definition at line 96 of file powers.h.

Referenced by do_cemit(), do_chanlist(), do_channelwho(), do_chboot(), do_cheader(), do_chopen(), do_createchannel(), do_destroychannel(), do_editchannel(), do_listchannels(), FUNCTION(), test_join_access(), test_receive_access(), and test_transmit_access().

#define Control_All (  )     (((Powers(c) & POW_CONTROL_ALL) != 0) || Wizard(c))

Definition at line 86 of file powers.h.

#define Find_Unfindable (  )     ((Powers(c) & POW_FIND_UNFIND) != 0)

Definition at line 89 of file powers.h.

Referenced by locatable().

#define Free_Money (  )     (((Powers(c) & POW_FREE_MONEY) != 0) || Immortal(c))

Definition at line 90 of file powers.h.

Referenced by canpayfees(), giveto(), and payfor().

#define Free_Quota (  )     (((Powers(c) & POW_FREE_QUOTA) != 0) || Wizard(c))

Definition at line 91 of file powers.h.

Referenced by FUNCTION(), pay_quota(), and show_quota().

#define Guest (  )     ((Powers(c) & POW_GUEST) != 0)

Definition at line 102 of file powers.h.

Referenced by announce_connect(), announce_disconnect(), check_access(), check_connect(), CGuests::CleanUp(), CGuests::Create(), CGuests::DestroyGuestChar(), dispatch_FreeListReconstruction(), do_dbck(), do_give(), do_list(), do_motd(), do_processcom(), main(), page_check(), return_bit(), and CGuests::StartUp().

#define Long_Fingers (  )     (((Powers(c) & POW_LONGFINGERS) != 0) || Wizard(c))

Definition at line 95 of file powers.h.

Referenced by do_enter(), do_get(), do_give(), do_kill(), do_look(), do_pemit_single(), and FUNCTION().

#define No_Destroy (  )     (((Powers(c) & POW_NO_DESTROY) != 0) || Wizard(c))

Definition at line 101 of file powers.h.

Referenced by do_toad().

#define Pass_Locks (  )     ((Powers(c) & POW_PASS_LOCKS) != 0)

Definition at line 109 of file powers.h.

Referenced by could_doit().

#define POW_ANNOUNCE   0x00000004

Definition at line 16 of file powers.h.

#define POW_BOOT   0x00000008

Definition at line 17 of file powers.h.

#define POW_BUILDER   0x00000001

Definition at line 49 of file powers.h.

#define POW_CHG_QUOTAS   0x00000001

Definition at line 14 of file powers.h.

#define POW_CHOWN_ANY   0x00000002

Definition at line 15 of file powers.h.

#define POW_COMM_ALL   0x00080000

Definition at line 34 of file powers.h.

#define POW_CONTROL_ALL   0x00000020

Definition at line 19 of file powers.h.

#define POW_EXAM_ALL   0x00000080

Definition at line 21 of file powers.h.

#define POW_FIND_UNFIND   0x00000100

Definition at line 22 of file powers.h.

#define POW_FREE_MONEY   0x00000200

Definition at line 23 of file powers.h.

#define POW_FREE_QUOTA   0x00000400

Definition at line 24 of file powers.h.

#define POW_GUEST   0x02000000

Definition at line 40 of file powers.h.

#define POW_HALT   0x00000010

Definition at line 18 of file powers.h.

#define POW_HIDE   0x00000800

Definition at line 25 of file powers.h.

#define POW_IDLE   0x00001000

Definition at line 26 of file powers.h.

#define POW_LONGFINGERS   0x00004000

Definition at line 28 of file powers.h.

#define POW_MONITOR   0x00400000

Definition at line 37 of file powers.h.

#define POW_NO_DESTROY   0x01000000

Definition at line 39 of file powers.h.

#define POW_PASS_LOCKS   0x04000000

Definition at line 41 of file powers.h.

#define POW_POLL   0x00800000

Definition at line 38 of file powers.h.

#define POW_PROG   0x00008000

Definition at line 29 of file powers.h.

#define POW_SEARCH   0x00002000

Definition at line 27 of file powers.h.

#define POW_SEE_HIDDEN   0x00200000

Definition at line 36 of file powers.h.

#define POW_SEE_QUEUE   0x00100000

Definition at line 35 of file powers.h.

#define POW_SITEADMIN   0x00010000

Definition at line 30 of file powers.h.

#define POW_STAT_ANY   0x08000000

Definition at line 42 of file powers.h.

#define POW_STEAL   0x10000000

Definition at line 43 of file powers.h.

#define POW_TEL_ANYWHR   0x20000000

Definition at line 44 of file powers.h.

#define POW_TEL_UNRST   0x40000000

Definition at line 45 of file powers.h.

#define POW_UNKILLABLE   0x80000000

Definition at line 46 of file powers.h.

#define POW_WIZARD_WHO   0x00000040

Definition at line 20 of file powers.h.

#define POWER_EXT   0x1

Definition at line 11 of file powers.h.

Referenced by decode_power(), decompile_powers(), has_power(), ph_any(), and powers_list().

#define Prog (  )     (((Powers(c) & POW_PROG) != 0) || Wizard(c))

Definition at line 108 of file powers.h.

Referenced by do_prog(), and do_quitprog().

#define Quota (  )     (((Powers(c) & POW_CHG_QUOTAS) != 0) || Wizard(c))

Definition at line 81 of file powers.h.

Referenced by do_quota(), and FUNCTION().

#define s_Guest (  )     s_Powers((c), Powers(c) | POW_GUEST)

Definition at line 79 of file powers.h.

Referenced by CGuests::Create(), and CGuests::MakeGuestChar().

#define Search (  )     (((Powers(c) & POW_SEARCH) != 0) || WizRoy(c))

Definition at line 94 of file powers.h.

Referenced by search_setup().

#define See_All (  )     (((Powers(c) & POW_EXAM_ALL) != 0) || WizRoy(c))

Definition at line 88 of file powers.h.

Referenced by FUNCTION().

#define See_Hidden (  )     (((Powers(c) & POW_SEE_HIDDEN) != 0) || WizRoy(c))

Definition at line 98 of file powers.h.

Referenced by decode_flags(), do_channelwho(), do_comwho(), do_mail_list(), do_mail_read(), do_mail_review(), dump_info(), dump_users(), find_connected_name(), flag_description(), FUNCTION(), handle_flaglists(), has_flag(), make_port_ulist(), make_ulist(), nearby(), page_check(), and sweep_check().

#define See_Queue (  )     (((Powers(c) & POW_SEE_QUEUE) != 0) || WizRoy(c))

Definition at line 97 of file powers.h.

Referenced by do_ps().

#define Stat_Any (  )     ((Powers(c) & POW_STAT_ANY) != 0)

Definition at line 103 of file powers.h.

Referenced by get_stats().

#define Steal (  )     (((Powers(c) & POW_STEAL) != 0) || Wizard(c))

Definition at line 104 of file powers.h.

Referenced by give_money().

#define Tel_Anything (  )     (((Powers(c) & POW_TEL_UNRST) != 0) || WizRoy(c))

Definition at line 106 of file powers.h.

Referenced by do_teleport_single().

#define Tel_Anywhere (  )     (((Powers(c) & POW_TEL_ANYWHR) != 0) || Tel_Anything(c))

Definition at line 105 of file powers.h.

Referenced by do_teleport(), and do_teleport_single().

#define Unkillable (  )     (((Powers(c) & POW_UNKILLABLE) != 0) || Immortal(c))

Definition at line 107 of file powers.h.

Referenced by do_kill().

#define Wizard_Who (  )     (((Powers(c) & POW_WIZARD_WHO) != 0) || WizRoy(c))

Definition at line 87 of file powers.h.

Referenced by do_channelwho(), do_comwho(), dump_users(), and FUNCTION().


Typedef Documentation

typedef struct power_entry POWERENT

typedef struct powerset POWERSET


Function Documentation

bool decode_power ( dbref  player,
char *  powername,
POWERSET pset 
)

Definition at line 208 of file powers.cpp.

References hashfindLEN(), mudstate, notify, POWER_EXT, power_entry::powerpower, statedata::powers_htab, power_entry::powervalue, tprintf(), powerset::word1, and powerset::word2.

00209 {
00210     pset->word1 = 0;
00211     pset->word2 = 0;
00212 
00213     POWERENT *pent = (POWERENT *)hashfindLEN(powername, strlen(powername), &mudstate.powers_htab);
00214     if (!pent)
00215     {
00216         notify(player, tprintf("%s: Power not found.", powername));
00217         return false;
00218     }
00219     if (pent->powerpower & POWER_EXT)
00220     {
00221         pset->word2 = pent->powervalue;
00222     }
00223     else
00224     {
00225         pset->word1 = pent->powervalue;
00226     }
00227     return true;
00228 }

void decompile_powers ( dbref  ,
dbref  ,
char *   
)

Definition at line 386 of file powers.cpp.

References CA_NO_DECOMP, gen_powers, power_entry::listperm, POWER_EXT, power_entry::powername, power_entry::powerpower, Powers, Powers2, and power_entry::powervalue.

00387 {
00388     POWERENT *fp;
00389 
00390     // Report generic powers.
00391     //
00392     POWER f1 = Powers(thing);
00393     POWER f2 = Powers2(thing);
00394 
00395     for (fp = gen_powers; fp->powername; fp++)
00396     {
00397         // Skip if we shouldn't decompile this power
00398         //
00399         if (fp->listperm & CA_NO_DECOMP)
00400         {
00401             continue;
00402         }
00403 
00404         // Skip if this power is not set.
00405         //
00406         if (fp->powerpower & POWER_EXT)
00407         {
00408             if (!(f2 & fp->powervalue))
00409             {
00410                 continue;
00411             }
00412         }
00413         else
00414         {
00415             if (!(f1 & fp->powervalue))
00416             {
00417                 continue;
00418             }
00419         }
00420 
00421         // Skip if we can't see this power.
00422         //
00423         if (!check_access(player, fp->listperm))
00424         {
00425             continue;
00426         }
00427 
00428         // We made it this far, report this power.
00429         //
00430         notify(player, tprintf("@power %s=%s", strip_ansi(thingname), fp->powername));
00431     }
00432 }

void display_powertab ( dbref   ) 

Definition at line 168 of file powers.cpp.

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().

00169 {
00170     char *buf, *bp;
00171     POWERENT *fp;
00172 
00173     bp = buf = alloc_lbuf("display_powertab");
00174     safe_str("Powers:", buf, &bp);
00175     for (fp = gen_powers; fp->powername; fp++)
00176     {
00177         if ((fp->listperm & CA_WIZARD) && !Wizard(player))
00178         {
00179             continue;
00180         }
00181         if ((fp->listperm & CA_GOD) && !God(player))
00182         {
00183             continue;
00184         }
00185         safe_chr(' ', buf, &bp);
00186         safe_str(fp->powername, buf, &bp);
00187     }
00188     *bp = '\0';
00189     notify(player, buf);
00190     free_lbuf(buf);
00191 }

bool has_power ( dbref  ,
dbref  ,
char *   
)

Definition at line 293 of file powers.cpp.

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 FUNCTION().

00294 {
00295     POWERENT *fp = find_power(it, powername);
00296     if (!fp)
00297     {
00298         return false;
00299     }
00300 
00301     POWER fv;
00302     if (fp->powerpower & POWER_EXT)
00303     {
00304         fv = Powers2(it);
00305     }
00306     else
00307     {
00308         fv = Powers(it);
00309     }
00310 
00311     if (fv & fp->powervalue)
00312     {
00313         if ((fp->listperm & CA_WIZARD) && !Wizard(player))
00314         {
00315             return false;
00316         }
00317         if ((fp->listperm & CA_GOD) && !God(player))
00318         {
00319             return false;
00320         }
00321         return true;
00322     }
00323     return false;
00324 }

void init_powertab ( void   ) 

Definition at line 145 of file powers.cpp.

References alloc_sbuf, gen_powers, hashaddLEN(), hashfindLEN(), mudstate, mux_strlwr(), power_entry::powername, statedata::powers_htab, and SBUF_SIZE.

Referenced by main().

00146 {
00147     POWERENT *fp;
00148     char *nbuf = alloc_sbuf("init_powertab");
00149 
00150     for (fp = gen_powers; fp->powername; fp++)
00151     {
00152         strncpy(nbuf, fp->powername, SBUF_SIZE);
00153         nbuf[SBUF_SIZE-1] = '\0';
00154         mux_strlwr(nbuf);
00155 
00156         if (!hashfindLEN(nbuf, strlen(nbuf), &mudstate.powers_htab))
00157         {
00158             hashaddLEN(nbuf, strlen(nbuf), fp, &mudstate.powers_htab);
00159         }
00160     }
00161     free_sbuf(nbuf);
00162 }

void power_set ( dbref  ,
dbref  ,
char *  ,
int   
)

Definition at line 234 of file powers.cpp.

References find_power(), power_entry::handler, mux_isspace, NOPERM_MESSAGE, notify, power_entry::powerpower, power_entry::powervalue, Quiet, and SET_QUIET.

Referenced by do_power().

00235 {
00236     // Trim spaces, and handle the negation character.
00237     //
00238     while (mux_isspace(*power))
00239     {
00240         power++;
00241     }
00242 
00243     bool negate = false;
00244     if (*power == '!')
00245     {
00246         negate = true;
00247         power++;
00248     }
00249     while (mux_isspace(*power))
00250     {
00251         power++;
00252     }
00253 
00254     // Make sure a power name was specified.
00255     //
00256     if (*power == '\0')
00257     {
00258         if (negate)
00259         {
00260             notify(player, "You must specify a power to clear.");
00261         }
00262         else
00263         {
00264             notify(player, "You must specify a power to set.");
00265         }
00266         return;
00267     }
00268     POWERENT *fp = find_power(target, power);
00269     if (fp == NULL)
00270     {
00271         notify(player, "I don't understand that power.");
00272         return;
00273     }
00274 
00275     // Invoke the power handler, and print feedback.
00276     //
00277     bool result = fp->handler(target, player, fp->powervalue,
00278                  fp->powerpower, negate);
00279     if (!result)
00280     {
00281         notify(player, NOPERM_MESSAGE);
00282     }
00283     else if (!(key & SET_QUIET) && !Quiet(player))
00284     {
00285         notify(player, (negate ? "Cleared." : "Set."));
00286     }
00287 }

char* powers_list ( dbref  executor,
dbref  thing 
)

Definition at line 330 of file powers.cpp.

References alloc_lbuf, CA_GOD, CA_WIZARD, gen_powers, God, power_entry::listperm, POWER_EXT, power_entry::powername, power_entry::powerpower, Powers, Powers2, power_entry::powervalue, safe_chr, safe_str, and Wizard.

Referenced by debug_examine(), do_examine(), and FUNCTION().

00331 {
00332     // Allocate the return buffer.
00333     //
00334     char *buff = alloc_lbuf("powers_list");
00335     char *bp = buff;
00336 
00337     bool bFirst = true;
00338     POWERENT *fp;
00339     for (fp = gen_powers; fp->powername; fp++)
00340     {
00341         POWER fv;
00342         if (fp->powerpower & POWER_EXT)
00343         {
00344             fv = Powers2(target);
00345         }
00346         else
00347         {
00348             fv = Powers(target);
00349         }
00350 
00351         if (fv & fp->powervalue)
00352         {
00353             if (  (fp->listperm & CA_WIZARD)
00354                && !Wizard(player))
00355             {
00356                 continue;
00357             }
00358             if (  (fp->listperm & CA_GOD)
00359                && !God(player))
00360             {
00361                 continue;
00362             }
00363             if (bFirst)
00364             {
00365                 bFirst = false;
00366             }
00367             else
00368             {
00369                 safe_chr(' ', buff, &bp);
00370             }
00371             safe_str(fp->powername, buff, &bp);
00372         }
00373     }
00374 
00375     // Terminate the string, and return the buffer to the caller.
00376     //
00377     *bp = '\0';
00378     return buff;
00379 }


Generated on Mon May 28 04:40:21 2007 for MUX by  doxygen 1.4.7