command.c-Dateireferenz

#include <player/command.h>
#include <thing/properties.h>
#include <living/moving.h>
#include <player.h>
#include <language.h>
#include <new_skills.h>
#include <config.h>
#include <defines.h>
#include <wizlevels.h>
#include <logging.h>
#include <strings.h>
Include-Abhängigkeitsdiagramm für command.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define NEED_PROTOTYPES
#define CBLOG(x)   log_file(SHELLLOG("DISABLECOMMANDS"),x,200000)
#define HIST_SIZE   40
#define EPMASTER   "/secure/explorationmaster"
#define ALIFORMAT   ({" %s\t= %s", "alias %s %s"})[display_as_aliascommand]
#define ARTIKEL
#define TRENNER
#define BBMASTER   "/secure/bbmaster"

Funktionen

nomask void __set_bb (int flag)
static varargs int __auswerten (string str, string intern)
varargs int SoulComm (string str, string _verb)
varargs mixed More (string str, int fflag, string returnto)
static int _starts_with (string str, string start)
static void reallocate_histbuf ()
static private void AddHistory (string str)
static void create ()
static int replacedisplay (string str)
static int histmin (string str)
static int histlen (string str)
static void initialize ()
static mixed _set_default_notify_fail (string s)
static mixed _query_default_notify_fail ()
static int set_errormessage (string s)
void reconnect ()
static int show_hist ()
static string present_alias (mixed *ali)
static int query_aliases (int display_as_aliascommand)
static int alias (string str)
static int unalias (string str)
varargs string _unparsed_args (int level)
static string _single_spaces (string str)
static mixed _return_args (string str)
static void decay_average ()
static private void DelayPreparedSpells ()
private string parsecommand (string str)
 Interpretiert Aliase und History-Kommandos Eigentlich muesste hier noch die Umwandlung der Sonderzeichen verschiedener Zeichensaetze mit convert_charset gemacht werden, aber noch gibt es keine Moeglichkeit, den vom Spieler genutzten Zeichensatz zu identifizieren.
mixed modify_command (string str)
 Behandelt alle Sonderfaelle der Eingabe des Spielers Alle Befehle des Spielers, die nicht durch Objekte behandelt werden sollen, werden hier erkannt und ausgefuehrt.
static int do_list (string str)
int unalias_all ()
object _query_last_command_env ()
int _query_show_alias_processing ()
int _query_histmin ()
varargs void AddAction (mixed fun, mixed cmd, int flag, int lvl)
static int auswerten (mixed cmd, string str)
static string * _query_localcmds ()
int _query_command_average ()
nomask public void countCmds (int type, string key)
nomask public string * getCmds ()
int command_me (string cmd)
static mixed _query_p_lib_disablecommands ()
static mixed _set_p_lib_disablecommands (mixed data)

Variablen

private mapping aliases
private string * commands
private int hist_size
private int show_processing
private int histmin
private string default_notify_fail
private nosave string * history
private nosave string * unparsed_args
private nosave string unmodified
private nosave int hist_now
private nosave object last_command_env
private nosave int cmds_per_time
private nosave int last_chg
private nosave int max_commands
private nosave int * cmd_types
private nosave mixed disablecommands
static mixed bb

Makro-Dokumentation

#define ALIFORMAT   ({" %s\t= %s", "alias %s %s"})[display_as_aliascommand]

Definiert in Zeile 222 der Datei command.c.

Wird benutzt von alias() und query_aliases().

#define ARTIKEL
Wert:
({"das","der","die","des","dem","den","ein","eine","einer",\
                  "eines"})

Definiert in Zeile 392 der Datei command.c.

Wird benutzt von _return_args().

#define BBMASTER   "/secure/bbmaster"

Definiert in Zeile 498 der Datei command.c.

#define CBLOG ( x   )     log_file(SHELLLOG("DISABLECOMMANDS"),x,200000)

Definiert in Zeile 28 der Datei command.c.

Wird benutzt von _set_p_lib_disablecommands().

#define EPMASTER   "/secure/explorationmaster"

Definiert in Zeile 31 der Datei command.c.

#define HIST_SIZE   40

Definiert in Zeile 30 der Datei command.c.

Wird benutzt von create().

#define NEED_PROTOTYPES

Definiert in Zeile 12 der Datei command.c.

#define TRENNER
Wert:
({"in","aus","ueber","auf","unter","mit","durch","fuer",\
                  "von","vom","im","aufs","ein","weg","zurueck"})

Definiert in Zeile 395 der Datei command.c.

Wird benutzt von _return_args().


Dokumentation der Funktionen

static varargs int __auswerten ( string  str,
string  intern 
) [static]

Definiert in Zeile 794 der Datei command.c.

Benutzt auswerten(), ME, P_LOCALCMDS, query_wiz_level() und QueryProp().

Wird benutzt von modify_command().

00795 {
00796   string verb;
00797   mixed *cmd, cmds;
00798   int i,ret,lvl,l,vl;
00799 
00800   if (!intern)
00801     verb=query_verb();
00802   else
00803     verb=intern;
00804   lvl=query_wiz_level(ME);
00805   vl=strlen(verb);
00806   cmds=QueryProp(P_LOCALCMDS);
00807 
00808   for(i=sizeof(cmds)-1;i>=0;i--)
00809   {
00810     cmd=cmds[i],l=strlen(cmd[0]);
00811     if (cmd[0]==verb[0..l-1] && cmd[3]<=lvl && (cmd[2]||vl==l) &&
00812   (ret=auswerten(cmd[1],str)))
00813       return ret;
00814   }
00815   return 0;
00816 }

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

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

nomask void __set_bb ( int  flag  ) 

Definiert in Zeile 845 der Datei command.c.

Benutzt bb, BBMASTER und process_call().

00845                                 {
00846   if( previous_object()!=find_object(BBMASTER) || process_call() )
00847     return;
00848   bb=flag;
00849 }

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

int _query_command_average (  ) 

Definiert in Zeile 839 der Datei command.c.

Benutzt cmds_per_time und decay_average().

00840 {
00841   decay_average();
00842   return cmds_per_time;
00843 }

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

static mixed _query_default_notify_fail (  )  [static]

Definiert in Zeile 155 der Datei command.c.

Benutzt default_notify_fail.

00156 {
00157   return default_notify_fail;
00158 }

int _query_histmin (  ) 

Definiert in Zeile 760 der Datei command.c.

Benutzt histmin.

00761 {
00762   return histmin;
00763 }

object _query_last_command_env (  ) 

Definiert in Zeile 750 der Datei command.c.

Benutzt last_command_env.

00751 {
00752   return last_command_env;
00753 }

static string* _query_localcmds (  )  [static]

Definiert in Zeile 818 der Datei command.c.

Benutzt LEARNER_LVL, P_LOCALCMDS, Query() und SEER_LVL.

00819 {
00820   mixed *l;
00821 
00822   l=Query(P_LOCALCMDS);
00823   if (!pointerp(l))
00824     l=({});
00825   return ({
00826     ({"ali","alias",0,0}),
00827     ({"alias","alias",0,0}),
00828     ({"unali","unalias",1,0}),
00829     ({"histmin","histmin",0,0}),
00830     ({"histlen","histlen",0,0}),
00831     ({"hist","show_hist",0,0}),
00832     ({"history","show_hist",0,0}),
00833     ({"do","do_list",0,LEARNER_LVL}),
00834     ({"ersetzungsanzeige","replacedisplay",0,0}),
00835     ({"fehlermeldung","set_errormessage",0,SEER_LVL}),
00836   })+l;
00837 }

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

static mixed _query_p_lib_disablecommands (  )  [static]

Definiert in Zeile 911 der Datei command.c.

Benutzt disablecommands.

Wird benutzt von _set_p_lib_disablecommands().

00911                                             {
00912     // abgelaufen oder Objekt zerstoert? Weg damit.
00913     if (pointerp(disablecommands)
00914                 && (disablecommands[B_TIME] < time()
00915                 || !objectp(disablecommands[B_OBJECT])) )
00916                 return(disablecommands = 0);
00917 
00918     // sonst Kopie zurueck (copy(0) geht)
00919     return(copy(disablecommands));
00920 }

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

int _query_show_alias_processing (  ) 

Definiert in Zeile 755 der Datei command.c.

Benutzt show_processing.

00756 {
00757   return show_processing;
00758 }

static mixed _return_args ( string  str  )  [static]

Definiert in Zeile 403 der Datei command.c.

Benutzt _single_spaces(), ARTIKEL, i, old_explode(), show_processing, TRENNER, TRIM_BOTH und unparsed_args.

Wird benutzt von modify_command().

00404 {
00405   string *t,*t2,verb,s2;
00406   int i,l,j,l2;
00407 
00408   t=explode(trim(str,TRIM_BOTH)," ");
00409   verb=t[0];
00410   t = t[1..];
00411   if (!sizeof(t))
00412   {
00413     unparsed_args[0]=unparsed_args[1]=unparsed_args[2]=0;
00414     return str=verb;
00415   }
00416   else
00417     str = unparsed_args[0] = implode(t, " ");
00418 
00419   str=unparsed_args[1]=lower_case(_single_spaces(str));
00420   t=regexplode(str,"\\<im\\>|\\<ins\\>");
00421   for (i=1;i<sizeof(t);i+=2) t[i]="in";
00422   t=regexplode(implode(t,""),"[\\,\\!\\:][\\,\\!\\:]*");
00423   l=sizeof(t);
00424   for(i=1;i<l;i+=2) t[i]="";
00425   t=old_explode(implode(t,"")," ")-({""});
00426   for (i=sizeof(t)-2;i>=0;i--)
00427   {
00428     if (member(ARTIKEL,t[i])>=0)
00429       t=t[0..i-1]+t[i+1..];
00430   }
00431   unparsed_args[2]=implode(t," ");
00432   t=regexplode((str=implode(t," ")),"[0-9][0-9]*\\.");
00433   if ((l=sizeof(t))>2)
00434   {
00435     i=1;
00436     while (i<l-1)
00437     {
00438       t[i]=" "+t[i][0..<2]+" ";
00439       if ((l2=sizeof(t2=old_explode(t[i+1]," ")))<2)
00440   t[i+1]+=t[i];
00441       else
00442       {
00443   for (j=1;j<l2;j++)
00444   {
00445     if (member(TRENNER,t2[j])>=0)
00446     {
00447       t2[j-1]+=t[i];
00448       l2=0;
00449     }
00450   }
00451   if (!l2)
00452     t[i+1]=implode(t2," ");
00453   else
00454     t[i+1]+=t[i];
00455       }
00456       t[i]="";
00457       i+=2;
00458     }
00459     str=_single_spaces(verb+" "+implode(t," "));
00460     if (str[<1]==' ') str=str[0..<2];
00461   } else str=verb+(str==""?"":" "+str);
00462   if (show_processing>2)
00463     printf("-> {%s}\n",str);
00464   return str;
00465 }

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

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

static mixed _set_default_notify_fail ( string  s  )  [static]

Definiert in Zeile 144 der Datei command.c.

Benutzt default_notify_fail.

Wird benutzt von set_errormessage().

00145 {
00146   if (stringp(s)&&s!="")
00147   {
00148     if (s[<1]!='\n') s+="\n";
00149     return default_notify_fail=s;
00150   }
00151   else if (!s||s=="")
00152     return (default_notify_fail=0);
00153 }

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

static mixed _set_p_lib_disablecommands ( mixed  data  )  [static]

Definiert in Zeile 922 der Datei command.c.

Benutzt _query_p_lib_disablecommands(), CBLOG, disablecommands und strftime().

00922                                                     {
00923 
00924   // setzendes Objekt ermitteln, da diese Funktion nur per SetProp() gerufen
00925   // werden sollte (!), ist das PO(1);
00926   object origin = previous_object(1);
00927   // wenn nicht existent, direkt abbruch
00928   if (!objectp(origin))
00929     return _query_p_lib_disablecommands();
00930 
00931   // Prop loeschen? Explizit loeschen darf jeder, allerdings nicht direkt
00932   // ungeprueft ueberschreiben.
00933   if (!data) {
00934       return (disablecommands = 0 );
00935   }
00936   // mal direkt buggen bei falschen Datentyp, damits auffaellt.
00937   if (!pointerp(data) || sizeof(data) != 2 || !intp(data[0])
00938       || (!stringp(data[1]) && !closurep(data[1])) )
00939       raise_error(sprintf(
00940             "Wrong data type for P_DISABLECOMMANDS. Expected Array with "
00941             "2 elements (int, string|closure), got %.25O\n", data));
00942 
00943   // Wenn abgelaufen oder gleiches Objekt wie letztes Mal: eintragen.
00944   if (!disablecommands || (disablecommands[B_TIME] < time()
00945   || !objectp(disablecommands[B_OBJECT]) 
00946   || disablecommands[B_OBJECT] == origin) ) {
00947       // Loggen, wenn eine Closure eingetragen wird. Reduziert den Logscroll
00948       // und Strings haben deutlich weniger Missbrauchspotential.
00949       if (closurep(data[1])) {
00950         CBLOG(sprintf("[%s] CB gesetzt von %O, gueltig bis %s, Daten: %O\n",
00951         strftime("%Y%m%d-%H:%M:%S"),origin,
00952         strftime("%Y%m%d-%H:%M:%S",data[0]),
00953         (stringp(data[1]) ? regreplace(data[1],"\n","\\n",0)
00954                           : data[1])));
00955       }
00956       disablecommands = ({ origin, data[0], data[1] });
00957       return(copy(disablecommands));
00958   }
00959 
00960   return(_query_p_lib_disablecommands());
00961 }

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

static string _single_spaces ( string  str  )  [static]

Definiert in Zeile 398 der Datei command.c.

Wird benutzt von _return_args() und parsecommand().

00399 {
00400   return regreplace(str, "  *", " ", 1);
00401 }

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

static int _starts_with ( string  str,
string  start 
) [static]

Definiert in Zeile 243 der Datei command.c.

00244 {
00245   return (strlen(start)>strlen(str) ? 0
00246     : str[0..strlen(start)-1]==start);
00247 }

varargs string _unparsed_args ( int  level  ) 
varargs void AddAction ( mixed  fun,
mixed  cmd,
int  flag,
int  lvl 
)

Definiert in Zeile 765 der Datei command.c.

Benutzt cmds, dtime(), i, log_file, P_LOCALCMDS, Query() und Set().

00766 {
00767   int i;
00768   mixed *cmds;
00769 
00770   log_file( "ARCH/ADD_ACTION", sprintf(
00771                 "%s:\n  TO: %O TP: %O PO: %O\n   fun: %O cmd: %O flag: %O lvl: %O",
00772         dtime(time()), this_object(), this_player(), previous_object(),
00773                 fun, cmd, flag, lvl));
00774 
00775   if (!(cmds=Query(P_LOCALCMDS))) cmds=({});
00776 
00777   if (!pointerp(cmd)) cmd=({cmd});
00778 
00779   for (i = sizeof(cmd)-1; i>=0; i--)
00780     cmds += ({({ cmd[i] , fun, flag, lvl})});
00781 
00782   Set(P_LOCALCMDS, cmds);
00783 }

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

static private void AddHistory ( string  str  )  [static]

Definiert in Zeile 52 der Datei command.c.

Benutzt hist_now, hist_size, histmin, history und reallocate_histbuf().

Wird benutzt von modify_command().

00053 {
00054   if (!stringp(str) || str=="" || str[0]=='&' || str[0]=='^' ||
00055       str=="hist")
00056     return;
00057   if (!hist_size) return;
00058   if (!pointerp(history) || sizeof(history)!=hist_size)
00059     reallocate_histbuf();
00060   if (strlen(str)>=histmin && history[(hist_size+hist_now-1)%hist_size]!=str)
00061     history[(hist_now++)%hist_size]=str;
00062 }

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

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

static int alias ( string  str  )  [static]

Definiert in Zeile 249 der Datei command.c.

Benutzt _unparsed_args(), aliases, ALIFORMAT, command, More(), old_explode(), present_alias(), query_aliases() und unmodified.

Wird benutzt von parsecommand().

00250 {
00251   string command;
00252   string *tmp,um,*hits;
00253   int num, l, pos, cont;
00254   int display_as_aliascommand;
00255 
00256   if (unmodified&&unmodified!="")
00257     um=implode(old_explode(unmodified," ")[1..]," ");
00258   if (um=="") um=0;
00259   if(!(str=um||_unparsed_args()) || str=="*") return query_aliases(0);
00260 
00261     if (str=="-a" || strstr(str, "-a ")==0 )  {
00262     str=str[2..];
00263     if (str && str!="" && str[0]==' ') str=str[1..];
00264     if (!str || str=="" || str=="*") return query_aliases(1);
00265     display_as_aliascommand=1;
00266   }
00267 
00268   if ((pos=member(str,' '))<0) // 1 Arg only
00269   {
00270     if ((tmp=aliases[str]))
00271       printf(ALIFORMAT+"\n",str,present_alias(tmp));
00272     else
00273       if (str[<1]=='*')
00274       {
00275         str=str[0..<2];
00276         hits=filter(m_indices(aliases), #'_starts_with, str);
00277         if (!sizeof(hits))
00278         {
00279           printf("Du hast kein Alias, das mit \"%s\" anfaengt.\n", str);
00280           return 1;
00281         }
00282         hits=sort_array(hits, #'>);
00283         for (l=sizeof(hits); l--;)
00284           hits[l]=sprintf(ALIFORMAT, hits[l], present_alias(aliases[hits[l]]));
00285         More("Folgende Aliase beginnen mit \""+str+"\":\n"+implode(hits,"\n"));
00286       }
00287     else
00288       printf("Du hast kein Alias \"%s\" definiert.\n",str);
00289     return 1;
00290   }
00291   if (!pos)
00292   {
00293     write("Fehler: Blanc am Alias-Anfang\n");
00294     return 1;
00295   }
00296   if ((command=str[0..pos-1])=="unalias")
00297   {
00298     write
00299       ("Es nicht moeglich, den Befehl unalias zu ueberladen (waer dumm :))\n");
00300     return 1;
00301   }
00302   str=str[pos+1..],tmp=({});
00303   while (l=strlen(str)) {
00304     pos=0,cont=1;
00305     while (cont) {
00306       if (pos<l) {
00307         if(str[pos]=='\\') {
00308           str=str[0..pos-1]+str[pos+1..];
00309           l--;
00310         } else {
00311           if (str[pos]=='&' || str[pos]=='$') {
00312             cont=0;
00313             if (pos>0) {
00314               tmp+=({str[0..pos-1]});
00315             }
00316             if (pos==l-1) {
00317               printf("Fehler: %c am Zeilenende\n",str[pos]);
00318               return 1;
00319             }
00320             if ((num=str[++pos])=='*') {
00321               num=1;
00322               pos--;
00323             } else {
00324               num-='0';
00325             }
00326             if (num<0 || num>9) {
00327               printf("Fehler: Nach %c muss Ziffer oder * folgen\n",
00328                str[pos-1]);
00329               return 1;
00330             }
00331             if ((str=str[pos+1..])!=""&&str[0]=='*') {
00332               str=str[1..];
00333               num=-num;
00334             }
00335             tmp+=({num});
00336           }
00337         }
00338         pos++;
00339       } else {
00340         cont=0;
00341         if (str!="") tmp+=({str});
00342         str="";
00343       }
00344     }
00345   }
00346   if ((!aliases[command]) && (sizeof(aliases)>2000))
00347     printf("Du hast schon genuegend Aliase definiert!\n");
00348   else
00349   {
00350     aliases[command]=tmp;
00351     printf("Neues Alias: %s\t= %s\n",command,present_alias(tmp));
00352   }
00353   return 1;
00354 }

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

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

static int auswerten ( mixed  cmd,
string  str 
) [static]

Definiert in Zeile 785 der Datei command.c.

Wird benutzt von __auswerten().

00786 {
00787   if (closurep(cmd))
00788     return funcall(cmd,str);
00789   if (stringp(cmd))
00790     return call_other(this_object(),cmd,str);
00791   return 0;
00792 }

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

int command_me ( string  cmd  ) 

Definiert in Zeile 887 der Datei command.c.

Benutzt command, IS_LEARNER, ME, name und query_wiz_level().

00888 {
00889   if (IS_LEARNER(ME))
00890   {
00891     if (!this_interactive() || !previous_object())
00892       return 0;
00893     if( geteuid(ME)!=geteuid(this_interactive())
00894         || geteuid(ME)!=geteuid(previous_object()) )
00895     {
00896       if( query_wiz_level(ME)<query_wiz_level(previous_object()))
00897         tell_object(ME,previous_object()->name()+" zwingt Dich zu: "
00898                     + cmd + ".\n");
00899       else
00900       {
00901         tell_object(ME,previous_object()->name()
00902                     + " versucht, Dich zu " + cmd + " zu zwingen.\n" );
00903         return 0;
00904       }
00905     }
00906   }
00907   return command(cmd);
00908 }

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

nomask public void countCmds ( int  type,
string  key 
)

Definiert in Zeile 852 der Datei command.c.

Benutzt cmd_types, commands und max_commands.

00853 {
00854     string tmp;
00855 
00856     if ( this_player() != this_interactive()
00857          || this_interactive() != this_object()
00858          || member( cmd_types, type ) < 0 )
00859         return;
00860 
00861     tmp = sprintf( "%d\n%s", type, key );
00862 
00863     commands -= ({ tmp });
00864     commands += ({ tmp });
00865     commands = commands[0..max_commands-1];
00866 }

static void create (  )  [static]

Definiert in Zeile 64 der Datei command.c.

Benutzt F_MODE_AS, hist_now, HIST_SIZE, hist_size, histmin, last_chg, P_LOCALCMDS, PROTECTED, Set(), show_processing und unparsed_args.

00065 {
00066   last_chg=0;
00067   histmin=hist_now=0;
00068   Set(P_LOCALCMDS,({}));
00069   Set(P_LOCALCMDS,PROTECTED,F_MODE_AS);
00070   show_processing=1;
00071   unparsed_args=({0,0,0});
00072   hist_size=HIST_SIZE;
00073 }

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

static void decay_average (  )  [static]

Definiert in Zeile 467 der Datei command.c.

Benutzt absolute_hb_count(), cmds_per_time und last_chg.

Wird benutzt von _query_command_average() und modify_command().

00468 {
00469   if (absolute_hb_count()-last_chg>14)
00470   {
00471     last_chg=absolute_hb_count()-last_chg;
00472     if (last_chg>3000)
00473       last_chg=absolute_hb_count(),cmds_per_time=0;
00474     else
00475     {
00476       while (last_chg>14)
00477   cmds_per_time=cmds_per_time*9/10, last_chg-=15;
00478       last_chg=absolute_hb_count()-last_chg;
00479     }
00480   }
00481 }

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

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

static private void DelayPreparedSpells (  )  [static]

Definiert in Zeile 483 der Datei command.c.

Benutzt P_PREPARED_SPELL, QueryProp() und SetProp().

Wird benutzt von modify_command().

00483                                           {
00484   mixed ps;
00485 
00486   if (pointerp(ps=QueryProp(P_PREPARED_SPELL))
00487       && sizeof(ps)>=1 && intp(ps[0])) {
00488     ps[0]++;
00489     SetProp(P_PREPARED_SPELL,ps);
00490     write("Die Ausfuehrung Deines vorbereiteten Spruches wird verzoegert.\n");
00491   } else if (ps) {
00492     SetProp(P_PREPARED_SPELL,0);
00493   }
00494 }

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

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

static int do_list ( string  str  )  [static]

Definiert in Zeile 724 der Datei command.c.

Benutzt _unparsed_args(), command, i, old_explode(), P_WANTS_TO_LEARN, QueryProp() und show_processing.

00725 {
00726   string *cmdlist;
00727   int i;
00728 
00729   if (!QueryProp(P_WANTS_TO_LEARN))
00730     return 0;
00731   cmdlist=old_explode(_unparsed_args()||"",";")-({ "" });
00732   for (i=0;i<sizeof(cmdlist);i++)
00733   {
00734     cmdlist[i]=implode(old_explode(cmdlist[i]," ")-({}), " ");
00735     if (show_processing)
00736       write("["+cmdlist[i]+"]\n");
00737     command(cmdlist[i]);
00738   }
00739   return 1;
00740 }

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

nomask public string* getCmds (  ) 

Definiert in Zeile 869 der Datei command.c.

Benutzt BBMASTER und commands.

00870 {
00871     string *tmp;
00872 
00873     if ( previous_object() != find_object(BBMASTER) )
00874         return ({});
00875 
00876     tmp = commands;
00877     commands = ({});
00878 
00879     return tmp;
00880 }

static int histlen ( string  str  )  [static]

Definiert in Zeile 113 der Datei command.c.

Benutzt hist_size und reallocate_histbuf().

00114 {
00115   int d;
00116   if (!str||!sscanf(str,"%d",d)||d<0||d>40)
00117   {
00118     write("Benutzung: histlen ZAHL\nZAHL muss zwischen 0 und 40 liegen.\n");
00119     printf("Deine History-Buffer-Laenge liegt bei %d Befehlen.\n",hist_size);
00120     return 1;
00121   }
00122   hist_size=d;
00123   printf("Deine History-Buffer-Laenge liegt jetzt bei %d Befehlen.\n",
00124    hist_size);
00125   reallocate_histbuf();
00126   return 1;
00127 }

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

static int histmin ( string  str  )  [static]

Definiert in Zeile 86 der Datei command.c.

Benutzt histmin und len.

00087 {
00088   int len;
00089 
00090   if (!str||!sscanf(str,"%d",len)||len<0)
00091   {
00092     write("Benutzung: histmin ZAHL\nLegt die Mindestlaenge fest, die eine \
00093 Befehlszeile haben muss, um in den\nHistory-Puffer zu gelangen. Derzeit \
00094 eingestellt auf "+(string)histmin+" Zeichen.\n");
00095     return 1;
00096   }
00097   histmin=len;
00098   write("Mindestlaenge auf "+(string)len+" eingestellt.\n");
00099   return 1;
00100 }

static void initialize (  )  [static]

Definiert in Zeile 129 der Datei command.c.

Benutzt aliases, cmd_types, commands, EPMASTER, hist_size, history, max_commands und reallocate_histbuf().

00130 {
00131   if (!pointerp(history)||sizeof(history)!=hist_size)
00132     reallocate_histbuf();
00133   add_action("__auswerten","",1);
00134     max_commands = EPMASTER->QueryCommands();
00135     cmd_types = EPMASTER->QueryCmdTypes() || ({});
00136 
00137     if ( !mappingp(aliases) )
00138         aliases = ([]);
00139 
00140     if ( !pointerp(commands) )
00141         commands = ({});
00142 }

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

mixed modify_command ( string  str  ) 

Behandelt alle Sonderfaelle der Eingabe des Spielers Alle Befehle des Spielers, die nicht durch Objekte behandelt werden sollen, werden hier erkannt und ausgefuehrt.

Dazu gehoert auch die Interpretation von Aliases und History- befehlen.

Parameter:
[in] str string: Kommando des Spielers
Rückgabe:
auszufuehrendes Kommando oder 0 fuer ein nicht interpretierbares Kommando oder 1 fuer ein bereits durchgefuehrtes Kommando

Definiert in Zeile 630 der Datei command.c.

Benutzt _return_args(), AddHistory(), bb, BBMASTER, cmds_per_time, decay_average(), DelayPreparedSpells(), disablecommands, hist_now, hist_size, history, IS_LEARNING, last_command_env, ME, parsecommand(), PL, post, process_call(), show_processing, TakeFollowers(), TRIM_BOTH, TRIM_RIGHT, unmodified und unparsed_args.

Wird benutzt von modify_command().

00631 {
00632 
00633   if (extern_call() && previous_object() &&
00634       (previous_object()!=this_object() || process_call()) )
00635   {
00636     return 0;
00637   }
00638 
00639   // Leerzeichen an den Enden abschneiden.
00640   str = trim(str, TRIM_BOTH);
00641 
00642   if (bb)
00643     BBMASTER->BBWrite(trim(str,TRIM_RIGHT,"\n"), 0);
00644 
00645   decay_average();
00646   cmds_per_time+=10000;
00647 
00648   unparsed_args[0]=unparsed_args[1]=unparsed_args[2]=unmodified=""; 
00649 
00650   // Kommando wird geparst
00651   unmodified=parsecommand(str);
00652 
00653   // Environment schonmal merken.
00654   last_command_env=environment();
00655 
00656   if (unmodified == "")
00657       return "";
00658   // Kommando in History merken, auch wenn es im Kommandoblock abgebrochen
00659   // wird.
00660   AddHistory(unmodified);
00661 
00662   // pruefen, ob Kommandoblock gesetzt ist.
00663   // (Fuer Magier mit mschau ein wird das ignoriert.)
00664   // BTW: Es wird absichtlich nicht das Ergebnis der Closure zurueckgegeben,
00665   // sonst wuerde man beliebigen Objekten nicht nur das Abbrechen, sondern
00666   // auch das Aendern von Kommandos ermoeglichen.
00667   if (disablecommands && !IS_LEARNING(ME) )
00668   {
00669     if (disablecommands[B_TIME] >= time()
00670       && objectp(disablecommands[B_OBJECT]))
00671     {
00672       // disablecommands valid
00673       if (closurep(disablecommands[B_VALUE]))
00674       {
00675         if (funcall(disablecommands[B_VALUE],_return_args(unmodified)))
00676         {
00677           // Non-zero Closure-Ergebnis, Abbruch. Die gerufene Funktion ist
00678           // fuer eine geeignete Meldung an den Spieler verantwortlich.
00679           return 1;
00680         }
00681       }
00682       else if (stringp(disablecommands[B_VALUE]))
00683       {
00684         // meldung ausgeben...
00685         tell_object(PL, disablecommands[B_VALUE]);
00686         // und Ende...
00687         return 1;
00688       }
00689     }
00690     else disablecommands=0;
00691   }
00692 
00693   // Verfolger direkt ins Env reinholen.
00694   if (remove_call_out("TakeFollowers")>=0)
00695     catch(TakeFollowers();publish);
00696 
00697   DelayPreparedSpells();
00698 
00699   // Historyeintrag korrigieren
00700   if (unmodified[0]=='^')
00701   {
00702     string *oldnew,pre,post;
00703     if (sizeof(oldnew=explode(unmodified,"^"))>2)
00704     {
00705       int hist_idx = (hist_now-1)%hist_size;
00706       sscanf(history[hist_idx],"%s"+oldnew[1]+"%s", pre, post);
00707       unmodified = pre+oldnew[2]+post;
00708       if (show_processing)
00709         write("["+unmodified+"]\n");
00710       // korrigiertes Kommando natuerlich auch in die History.
00711       AddHistory(unmodified);
00712     }
00713   }
00714 
00715   if( bb )
00716     BBMASTER->BBWrite(" -> " + unmodified, 1);
00717 
00718   if (show_processing>1)
00719     printf("[%s]\n",unmodified);
00720 
00721   return _return_args(unmodified);
00722 }

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

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

varargs mixed More ( string  str,
int  fflag,
string  returnto 
)
private string parsecommand ( string  str  ) 

Interpretiert Aliase und History-Kommandos Eigentlich muesste hier noch die Umwandlung der Sonderzeichen verschiedener Zeichensaetze mit convert_charset gemacht werden, aber noch gibt es keine Moeglichkeit, den vom Spieler genutzten Zeichensatz zu identifizieren.

Parameter:
[in] str string - Kommando des Spielers
Rückgabe:
interpretiertes Alias bzw. korrektes Kommando aus der History

Definiert in Zeile 509 der Datei command.c.

Benutzt _single_spaces(), alias(), aliases, hist_now, hist_size, history, i, input, notify_fail(), output, show_processing und TRIM_RIGHT.

Wird benutzt von modify_command().

00510 {
00511   if (str[0]=='\\')
00512   {
00513     // Kommando soll nicht interpretiert werden
00514     return str[1..];
00515   }
00516   else if (str[0]=='&')
00517   {
00518     // Kommando aus der History
00519     string cmd = str[1..];
00520     int cmd_size = strlen(cmd);
00521     int cmd_found = 0;
00522     if (cmd_size)
00523     {
00524       // Test ob &<text> etwas findet
00525       for (int i=0;i<hist_size-1 && !cmd_found;i++)
00526       {
00527         int idx = (hist_size-i+hist_now-1)%hist_size;
00528         if (history[idx][0..cmd_size-1]==cmd)
00529         {
00530           str = history[idx];
00531           cmd_found = 1;
00532         }
00533         if (cmd_found)
00534         {
00535           if (show_processing)
00536             printf("[%s]\n",str);
00537         }
00538       }
00539     }
00540     if (!cmd_found)
00541     {
00542       // Test, ob &<nr> klappt
00543       int nummer;
00544       if (str=="&&")
00545         str = "&-0";
00546       if (sscanf(str,"&%d",nummer))
00547       {
00548         if (nummer<0 || (!nummer && str[1]=='-'))
00549         {
00550           if (nummer<-(hist_size-1))
00551             nummer=-1;
00552           else
00553             nummer=(hist_now+nummer-1+hist_size)%hist_size;
00554         }
00555         else
00556         {
00557           if (nummer>hist_now || hist_now-nummer>hist_size)
00558             nummer=-1;
00559           else
00560             nummer=nummer%hist_size;
00561         }
00562         cmd = history[nummer];
00563         if (nummer<0 || cmd=="\n\n")
00564           notify_fail("Der Befehl ist nicht in der History!\n");
00565         else
00566         {
00567           str = cmd;
00568           if (show_processing)
00569             printf("[%s]\n",str);
00570         }
00571       }
00572     }
00573   }
00574   switch (str)
00575   {
00576     case "n": return "norden";
00577     case "s": return "sueden";
00578     case "w": return "westen";
00579     case "o": return "osten";
00580     case "nw": return "nordwesten";
00581     case "sw": return "suedwesten";
00582     case "so": return "suedosten";
00583     case "no": return "nordosten";
00584     case "ob": return "oben";
00585     case "u": return "unten";
00586   }
00587   // Test auf Alias
00588   string output = "";
00589   string* input = explode(str," ");
00590   int input_size = sizeof(input);
00591   mixed alias = aliases[input[0]];
00592   if (!alias)
00593     return str;
00594   foreach (mixed a:alias)
00595   {
00596     if (!intp(a))
00597       output += a;
00598     else
00599     {
00600       if (a >= 0)
00601       {
00602         if (input_size > a)
00603           output += input[a];
00604       }
00605       else
00606       {
00607         a = -a;
00608         if (input_size > a)
00609           output += implode(input[a..]," ");
00610       }
00611     }
00612   }
00613   output = _single_spaces(output);
00614   str = trim(output,TRIM_RIGHT);
00615   if (show_processing>1)
00616     printf("[%s]\n",str);
00617   return str;
00618 }

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

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

static string present_alias ( mixed *  ali  )  [static]

Definiert in Zeile 203 der Datei command.c.

Wird benutzt von alias() und query_aliases().

00204 {
00205   int j,k;
00206   string s,s2;
00207 
00208   for (s="",j=sizeof(ali)-1;j>=0;j--)
00209     if (intp(ali[j]))
00210       if ((k=ali[j])<0)
00211   s="$"+(k==-1?"":(string)-k)+"*"+s;
00212       else
00213   s="$"+(string)k+s;
00214     else
00215       {
00216          s2=implode(explode(ali[j],"\\"),"\\\\");
00217          s=implode(explode(s2,"$"),"\\$")+s;
00218       }
00219   return s;
00220 }

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

static int query_aliases ( int  display_as_aliascommand  )  [static]

Definiert in Zeile 226 der Datei command.c.

Benutzt aliases, ALIFORMAT, i, More() und present_alias().

Wird benutzt von alias().

00227 {
00228   int i;
00229   string *a,*ali;
00230 
00231   if(i=sizeof(ali=sort_array(m_indices(aliases),#'<))) //')))
00232   {
00233     for(a=({}),i--; i>=0; i--)
00234         a+=({sprintf(ALIFORMAT, ali[i], present_alias( aliases[ali[i]] ) ) });
00235     More("Du hast folgende Aliase definiert:\n"+implode(a,"\n"));
00236   }
00237   else
00238     write("Du hast keine Aliase definiert.\n");
00239   return 1;
00240 }

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

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

static void reallocate_histbuf (  )  [static]

Definiert in Zeile 102 der Datei command.c.

Benutzt hist_now, hist_size, history und i.

Wird benutzt von AddHistory(), histlen() und initialize().

00103 {
00104   int i;
00105 
00106   history=allocate(hist_size);
00107   hist_now=0;
00108   for (i=0;i<hist_size;i++)
00109     if (!stringp(history[i]))
00110       history[i]="\n\n";
00111 }

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

void reconnect (  ) 

Definiert in Zeile 175 der Datei command.c.

Benutzt aliases, cmd_types, commands, EPMASTER und max_commands.

Wird benutzt von Reconnect().

00176 {
00177   if (!mappingp(aliases)) aliases=([]);
00178 
00179     if ( !pointerp(commands) )
00180         commands = ({});
00181 
00182     max_commands = EPMASTER->QueryCommands();
00183     cmd_types = EPMASTER->QueryCmdTypes() || ({});
00184 
00185     set_modify_command(0);
00186     set_modify_command(this_object());
00187 }

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

static int replacedisplay ( string  str  )  [static]

Definiert in Zeile 75 der Datei command.c.

Benutzt IS_WIZARD, ME und show_processing.

00076 {
00077   if (!str || str=="" || !sscanf(str,"%d",show_processing))
00078     printf("Unzulaessige Eingabe!\n%s 0|1|2\n",query_verb());
00079     printf("Ersetzungsanzeige auf Level %d.\nLevel 0: Nichts anzeigen\n"+
00080      "Level 1: Nur History-Ersetzungen anzeigen\n"+
00081      "Level 2: History- und Alias-Ersetzungen anzeigen\n",show_processing);
00082   if (show_processing>2&&!IS_WIZARD(ME)) show_processing=2;
00083   return 1;
00084 }

static int set_errormessage ( string  s  )  [static]

Definiert in Zeile 160 der Datei command.c.

Benutzt _set_default_notify_fail(), _unparsed_args() und break_string().

00161 {
00162   if (!(s=_unparsed_args()))
00163   {
00164     (void)_set_default_notify_fail(0);
00165     write("Standard-Fehlermeldung auf \"Wie bitte?\" gesetzt.\n");
00166   } else
00167   {
00168     write(break_string(sprintf("Standard-Fehlermeldung auf %s gesetzt.\n",
00169              s),78));
00170     (void)_set_default_notify_fail(s);
00171   }
00172   return 1;
00173 }

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

static int show_hist (  )  [static]

Definiert in Zeile 189 der Datei command.c.

Benutzt comm, hist_now, hist_size, history, i und ME.

00190 {
00191   int i;
00192   string comm;
00193 
00194   tell_object( ME, "Die History-Liste enthaelt folgende Kommandos:\n" );
00195 
00196   for( i = 0; i < hist_size; i++ )
00197       if ((comm=history[(hist_now+i)% hist_size])!= "\n\n")
00198           tell_object( ME, " &"+(hist_now+i-hist_size)+"/-"+ (hist_size-i-1)
00199       +"\t= "+comm+"\n");
00200   return 1;
00201 }

varargs int SoulComm ( string  str,
string  _verb 
)

Wird benutzt von modify_command().

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

static int unalias ( string  str  )  [static]

Definiert in Zeile 356 der Datei command.c.

Benutzt _unparsed_args(), aliases, break_string(), i, m_delete(), old_explode() und unmodified.

00356                                {
00357   int i;
00358   string *als,um;
00359 
00360   if (unmodified&&unmodified!="")
00361     um=implode(old_explode(unmodified," ")[1..]," ");
00362   if (um=="") um=0;
00363   if ( !(str=um || _unparsed_args())) return 0;
00364   if (str == "*") {
00365     write(break_string(
00366       "Versuchs mal mit 'unalias .*', wenn Du wirklich alle Alias entfernen "
00367       "willst.",78));
00368     return 1;
00369   }
00370   if (!member(aliases,str)) {
00371     als=regexp(m_indices(aliases),("^"+str+"$"));
00372     if (!(i=sizeof(als))) {
00373       write("So ein Alias hast Du nicht definiert.\n");
00374       return 1;
00375     }
00376     for (--i;i>=0;i--)
00377       efun::m_delete(aliases,als[i]);
00378     write(break_string(("Du entfernst folgende Aliase: "+
00379       implode(als," ")+".\n"),75));
00380     return 1;
00381   }
00382   efun::m_delete(aliases,str);
00383   write("Du entfernst das Alias \""+str+"\".\n");
00384   return 1;
00385 }

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

int unalias_all (  ) 

Definiert in Zeile 744 der Datei command.c.

Benutzt aliases und IS_ELDER.

00745 {
00746   if (IS_ELDER(this_interactive())) aliases=([]);
00747   return 1;
00748 }


Variablen-Dokumentation

private mapping aliases

Definiert in Zeile 33 der Datei command.c.

Wird benutzt von alias(), initialize(), parsecommand(), query_aliases(), reconnect(), unalias() und unalias_all().

mixed bb [static]

Definiert in Zeile 496 der Datei command.c.

Wird benutzt von __set_bb() und modify_command().

private nosave int * cmd_types

Definiert in Zeile 40 der Datei command.c.

Wird benutzt von countCmds(), initialize() und reconnect().

private nosave int cmds_per_time

Definiert in Zeile 40 der Datei command.c.

Wird benutzt von _query_command_average(), decay_average() und modify_command().

private string* commands

Definiert in Zeile 34 der Datei command.c.

private string default_notify_fail

Definiert in Zeile 36 der Datei command.c.

Wird benutzt von _query_default_notify_fail() und _set_default_notify_fail().

private nosave mixed disablecommands

Definiert in Zeile 42 der Datei command.c.

Wird benutzt von _query_p_lib_disablecommands(), _set_p_lib_disablecommands() und modify_command().

private nosave int hist_now

Definiert in Zeile 38 der Datei command.c.

Wird benutzt von AddHistory(), create(), modify_command(), parsecommand(), reallocate_histbuf() und show_hist().

private int hist_size
private int histmin

Definiert in Zeile 35 der Datei command.c.

Wird benutzt von _query_histmin(), AddHistory(), create() und histmin().

private nosave string* history

Definiert in Zeile 37 der Datei command.c.

private nosave int last_chg

Definiert in Zeile 40 der Datei command.c.

Wird benutzt von create() und decay_average().

private nosave object last_command_env

Definiert in Zeile 39 der Datei command.c.

Wird benutzt von _query_last_command_env() und modify_command().

private nosave int max_commands

Definiert in Zeile 40 der Datei command.c.

Wird benutzt von countCmds(), initialize() und reconnect().

private int show_processing
private nosave string unmodified

Definiert in Zeile 37 der Datei command.c.

Wird benutzt von alias(), modify_command() und unalias().

private nosave string * unparsed_args

Definiert in Zeile 37 der Datei command.c.

Wird benutzt von _return_args(), _unparsed_args(), create() und modify_command().

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