pubmaster.c-Dateireferenz

#include <pub.h>
#include <properties.h>
#include <wizlevels.h>
#include <health.h>
Include-Abhängigkeitsdiagramm für pubmaster.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define SAVEFILE   "/secure/ARCH/pub"
#define CLOGFILE   "/log/ARCH/pubchange"
#define DUMPFILE   "/log/ARCH/PUBS"
#define DUMPLIST   "/log/ARCH/PUBLIST"
#define DUMPF(str)   write_file(DUMPFILE,str)
#define DUMPL(str)   write_file(DUMPLIST,str)

Funktionen

void create ()
void save_data ()
int CalcMax (mapping info, string fn)
int RegisterItem (string item, mapping info)
static private int allowed ()
int SetMaxHeal (string pub, string item, int new)
int SetMaxRate (string pub, string item, int new)
int SetPubFactor (string pub, float new)
varargs int ClearPub (string pub, string item)
int DumpPubs ()
public void CleanPublist ()

Variablen

mapping pubs
nosave string * watchprops
nosave int watchsize

Makro-Dokumentation

#define CLOGFILE   "/log/ARCH/pubchange"

Definiert in Zeile 10 der Datei pubmaster.c.

Wird benutzt von SetMaxHeal(), SetMaxRate() und SetPubFactor().

#define DUMPF ( str   )     write_file(DUMPFILE,str)

Definiert in Zeile 14 der Datei pubmaster.c.

Wird benutzt von DumpPubs().

#define DUMPFILE   "/log/ARCH/PUBS"

Definiert in Zeile 11 der Datei pubmaster.c.

#define DUMPL ( str   )     write_file(DUMPLIST,str)

Definiert in Zeile 15 der Datei pubmaster.c.

Wird benutzt von DumpPubs().

#define DUMPLIST   "/log/ARCH/PUBLIST"

Definiert in Zeile 12 der Datei pubmaster.c.

Wird benutzt von DumpPubs().

#define SAVEFILE   "/secure/ARCH/pub"

Definiert in Zeile 9 der Datei pubmaster.c.


Dokumentation der Funktionen

static private int allowed (  )  [static]

Definiert in Zeile 155 der Datei pubmaster.c.

Benutzt ARCH_SECURITY, process_call() und ROOTID.

00156 {
00157   if (previous_object() && geteuid(previous_object())==ROOTID)
00158     return 1;
00159   if (!process_call() && previous_object() && ARCH_SECURITY)
00160     return 1;
00161   return 0;
00162 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

int CalcMax ( mapping  info,
string  fn 
)

Definiert in Zeile 48 der Datei pubmaster.c.

Benutzt ALCOHOL_DELAY, delay, DRINK_DELAY, FOOD_DELAY, heal, P_ALCOHOL, P_DRINK, P_FOOD, P_VALUE, PUB_MAXDELAY, PUB_RATEDIV1, PUB_RATEDIV2, PUB_SOAKMULT, PUB_VALUEDIV, PUB_WAITDIV1, PUB_WAITDIV2, PUB_WAITOFFS und pubs.

Wird benutzt von RegisterItem().

00049 {   float heal,delay,factor;
00050 
00051     if (!info || !mappingp(info))
00052         return 0;
00053     if ( (info[P_ALCOHOL]+info[P_DRINK]+info[P_FOOD])<=0     ||
00054          (info[P_ALCOHOL] && !(info[P_DRINK]||info[P_FOOD])) )
00055         return 0;
00056 
00057     delay = to_float(info["delay"]);
00058     if (delay>PUB_MAXDELAY)
00059         delay=PUB_MAXDELAY;
00060 
00061     if (!stringp(fn) || !member(pubs,fn)) // External query?
00062         factor=1.0;
00063     else
00064         factor=pubs[fn,1];
00065 
00066     heal = to_float( info[P_ALCOHOL]*ALCOHOL_DELAY +
00067                      info[P_DRINK]  *DRINK_DELAY   +
00068                      info[P_FOOD]   *FOOD_DELAY    ) 
00069            * PUB_SOAKMULT
00070            / to_float( ALCOHOL_DELAY + DRINK_DELAY + FOOD_DELAY );
00071     heal = heal + 
00072            to_float(info[P_VALUE])/(PUB_VALUEDIV+to_float(info["rate"])) -
00073            exp(to_float(info["rate"])/PUB_RATEDIV1)/PUB_RATEDIV2;
00074     heal = heal * factor *
00075            (PUB_WAITOFFS + (exp(delay/PUB_WAITDIV1)/PUB_WAITDIV2));
00076 
00077     return to_int(heal);
00078 }

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

public void CleanPublist (  ) 

Definiert in Zeile 300 der Datei pubmaster.c.

Benutzt m_delete(), pub, pubs und save_data().

00300                            {
00301   foreach(string pub: pubs) {
00302     if (file_size(pub+".c") <= 0)
00303       efun::m_delete(pubs,pub);
00304   }
00305   save_data();
00306 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

varargs int ClearPub ( string  pub,
string  item 
)

Definiert in Zeile 226 der Datei pubmaster.c.

Benutzt allowed, m_delete(), pubs und save_data().

00227 {
00228     if (!allowed())
00229         return -2;
00230     if (!pub || !stringp(pub) || (item && !stringp(item)))
00231         return -1;
00232     if (!member(pubs,pub))
00233         return 0;
00234     if (!item)
00235         efun::m_delete(pubs,pub);
00236     else if (!member(pubs[pub],item))
00237         return 0;
00238     else
00239       efun::m_delete(pubs[pub],item);
00240     save_data();
00241     return 1;
00242 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

void create (  ) 

Definiert in Zeile 27 der Datei pubmaster.c.

Benutzt destruct(), P_ALCOHOL, P_DRINK, P_FOOD, P_HP, P_SP, P_VALUE, pubs, restore_object(), SAVEFILE, watchprops und watchsize.

00028 {
00029     seteuid(getuid(this_object()));
00030     if (clonep(this_object()))
00031     {
00032         destruct(this_object());
00033         return;
00034     }
00035     if (!restore_object(SAVEFILE))
00036         pubs = ([]);
00037 
00038     watchprops = ({ P_HP, P_SP, P_ALCOHOL, P_DRINK, P_FOOD, P_VALUE,
00039                     "rate", "delay" });
00040     watchsize  = sizeof(watchprops);
00041 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

int DumpPubs (  ) 

Definiert in Zeile 244 der Datei pubmaster.c.

Benutzt allowed, dtime(), DUMPF, DUMPFILE, DUMPL, DUMPLIST, P_ALCOHOL, P_DRINK, P_FOOD, P_HP, P_SP, P_VALUE und pubs.

00245 {   string *publist,*itemlist;
00246     int    pubi,itemi;
00247 
00248     if (!allowed())
00249         return -2;
00250     if (file_size(DUMPFILE)>1)
00251         rm(DUMPFILE);
00252     if (file_size(DUMPLIST)>1)
00253         rm(DUMPLIST);
00254     DUMPF(sprintf("Kneipen-Menu-Liste vom %s:\n\n",dtime(time())));
00255     DUMPL(sprintf("Kneipenliste vom %s:\n\n",dtime(time())));
00256     publist=sort_array(m_indices(pubs),#'</*'*/);
00257     if ((pubi=sizeof(publist))<1)
00258     {
00259         DUMPF("No pubs in List\n");
00260         DUMPL("No pubs in List\n");
00261         return -1;
00262     }
00263     for (--pubi;pubi>=0;pubi--)
00264     {
00265         DUMPL(sprintf("%-'.'70s %6.4f\n",
00266             publist[pubi],pubs[publist[pubi],1]));
00267         DUMPF(sprintf("PUB: %s\nFAC: %6.4f\n\n",
00268             publist[pubi],pubs[publist[pubi],1]));
00269         itemlist=sort_array(m_indices(pubs[publist[pubi]]),#'</*'*/);
00270         if ((itemi=sizeof(itemlist))<1)
00271         {
00272             DUMPF("  No items in list\n\n");
00273             continue;
00274         }
00275         DUMPF(sprintf(
00276             "  %|'_'30.30s %5s %3s %3s %3s %3s %3s %2s %2s %3s %3s\n",
00277             "ITEM","VALUE","HPH","SPH","DRI","ALC","FOO","RA","MR","MAX",
00278             "FND"));
00279         for (--itemi;itemi>=0;itemi--)
00280             DUMPF(sprintf(
00281                 "  %-'.'30.30s %5d %3d %3d %3d %3d %3d %2d %2d %3d %3d\n",
00282                 (string)itemlist[itemi],
00283                 (int)pubs[publist[pubi]][itemlist[itemi]][P_VALUE],
00284                 (int)pubs[publist[pubi]][itemlist[itemi]][P_HP],
00285                 (int)pubs[publist[pubi]][itemlist[itemi]][P_SP],
00286                 (int)pubs[publist[pubi]][itemlist[itemi]][P_DRINK],
00287                 (int)pubs[publist[pubi]][itemlist[itemi]][P_ALCOHOL],
00288                 (int)pubs[publist[pubi]][itemlist[itemi]][P_FOOD],
00289                 (int)pubs[publist[pubi]][itemlist[itemi]]["rate"],
00290                 (int)pubs[publist[pubi]][itemlist[itemi]]["maxrate"],
00291                 (int)pubs[publist[pubi]][itemlist[itemi]]["maxset"],
00292                 (int)pubs[publist[pubi]][itemlist[itemi]]["maxheal"] ));
00293         DUMPF("\n");
00294     }
00295     return sizeof(publist);
00296 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

int RegisterItem ( string  item,
mapping  info 
)

Definiert in Zeile 80 der Datei pubmaster.c.

Benutzt c, CalcMax(), heal, i, P_ALCOHOL, P_DRINK, P_FOOD, P_HP, P_SP, P_VALUE, pub, pubs, save_data(), watchprops und watchsize.

00081 {   object pub;
00082     string fn;
00083     int    i,c,cmax,max,heal;
00084 
00085     if (!objectp(pub=previous_object()))
00086         return -1;
00087     if (member(inherit_list(pub), "/std/room/pub.c") == -1)
00088         return -1;
00089     if (!item || !stringp(item) || !info || !mappingp(info))
00090         return -2;
00091 
00092     if (info["rate"]<1)
00093         info["rate"]=1;
00094     if (info["delay"]<0)
00095         info["delay"]=0;
00096 
00097     // Loadname, weil VCs als ein Pub zaehlen sollen (das Tutorial hat ein
00098     // VC-Pub fuer jeden Spieler. Die sollen nicht alle einzeln hier erfasst
00099     // werden.
00100     fn = load_name(pub);
00101     c = 0;
00102 
00103     heal=info[P_HP]+info[P_SP];
00104 
00105     if (!member(pubs,fn))
00106         pubs += ([ fn : ([]); 1.0 ]);
00107 
00108     if (!member(pubs[fn],item))
00109     {
00110         max=CalcMax(info,fn);
00111         pubs[fn] += ([ 
00112             item : ([
00113                 P_HP            : info[P_HP],
00114                 P_SP            : info[P_SP],
00115                 P_VALUE         : info[P_VALUE],
00116                 P_DRINK         : info[P_DRINK],
00117                 P_ALCOHOL       : info[P_ALCOHOL],
00118                 P_FOOD          : info[P_FOOD],
00119                 "rate"          : info["rate"],
00120                 "delay"         : info["delay"],
00121                 "maxheal"       : heal,
00122                 "maxrate"       : 10
00123                 ])
00124             ]);
00125         c=1;
00126     }
00127     else
00128     {
00129         for (i=watchsize-1;i>=0;i--)
00130             if (info[watchprops[i]]!=pubs[fn][item][watchprops[i]])
00131             {
00132                 pubs[fn][item][watchprops[i]]=info[watchprops[i]];
00133                 c=1;
00134             }
00135         if (heal>pubs[fn][item]["maxheal"])
00136         {
00137             pubs[fn][item]["maxheal"]=heal;
00138             c=1;
00139         }
00140         max=pubs[fn][item]["maxset"];
00141         cmax=CalcMax(info,fn);
00142         if (cmax>max)
00143             max=cmax;
00144     }
00145 
00146     if (c)
00147         save_data();
00148 
00149     if ( heal>max || info["rate"]>pubs[fn][item]["maxrate"] )
00150         return 0;
00151 
00152     return 1;
00153 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

void save_data (  ) 

Definiert in Zeile 43 der Datei pubmaster.c.

Benutzt save_object() und SAVEFILE.

Wird benutzt von CleanPublist(), ClearPub(), RegisterItem(), SetMaxHeal(), SetMaxRate() und SetPubFactor().

00044 {
00045     save_object(SAVEFILE);
00046 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

int SetMaxHeal ( string  pub,
string  item,
int  new 
)

Definiert in Zeile 166 der Datei pubmaster.c.

Benutzt allowed, CLOGFILE, dtime(), pubs und save_data().

00167 {   int old;
00168 
00169     if (!allowed())
00170         return -2;
00171     if (!pub || !stringp(pub) || !item || !stringp(item) || !new)
00172         return -1;
00173     if (!member(pubs,pub) || !member(pubs[pub],item))
00174         return 0;
00175     old=pubs[pub][item]["maxset"];
00176     pubs[pub][item]["maxset"]=new;
00177     write_file(CLOGFILE,
00178         sprintf("%s - %s\n%s:%s HEAL %d > %d\n",
00179             dtime(time()),
00180             (this_interactive() ? getuid(this_interactive()) : "???"),
00181             pub,item,old,new));
00182     save_data();
00183     return 1;
00184 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

int SetMaxRate ( string  pub,
string  item,
int  new 
)

Definiert in Zeile 186 der Datei pubmaster.c.

Benutzt allowed, CLOGFILE, dtime(), pubs und save_data().

00187 {   int old;
00188 
00189     if (!allowed())
00190         return -2;
00191     if (!pub || !stringp(pub) || !item || !stringp(item) || !new)
00192         return -1;
00193     if (!member(pubs,pub) || !member(pubs[pub],item))
00194         return 0;
00195     old=pubs[pub][item]["maxrate"];
00196     pubs[pub][item]["maxrate"]=new;
00197     write_file(CLOGFILE,
00198         sprintf("%s - %s\n%s:%s RATE %d > %d\n",
00199             dtime(time()),
00200             (this_interactive() ? getuid(this_interactive()) : "???"),
00201             pub,item,old,new));
00202     save_data();
00203     return 1;
00204 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

int SetPubFactor ( string  pub,
float  new 
)

Definiert in Zeile 206 der Datei pubmaster.c.

Benutzt allowed, CLOGFILE, dtime(), pubs und save_data().

00207 {   float old;
00208 
00209     if (!allowed())
00210         return -2;
00211     if (!pub || !stringp(pub) || !new || !floatp(new) || new<1.0 || new>1.5)
00212         return -1;
00213     if (!member(pubs,pub))
00214         return 0;
00215     old=pubs[pub,1];
00216     pubs[pub,1]=new;
00217     write_file(CLOGFILE,
00218         sprintf("%s - %s\n%s FACT %6.4f > %6.4f\n",
00219             dtime(time()),
00220             (this_interactive() ? getuid(this_interactive()) : "???"),
00221             pub,old,new));
00222     save_data();
00223     return 1;
00224 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:


Variablen-Dokumentation

mapping pubs
nosave string* watchprops

Definiert in Zeile 24 der Datei pubmaster.c.

Wird benutzt von create() und RegisterItem().

nosave int watchsize

Definiert in Zeile 25 der Datei pubmaster.c.

Wird benutzt von create() und RegisterItem().

Erzeugt am Thu Jun 3 14:41:46 2010 für MorgenGrauen Mudlib von  doxygen 1.6.3