lightsource.c-Dateireferenz

#include <properties.h>
#include <language.h>
#include <defines.h>
Include-Abhängigkeitsdiagramm für lightsource.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define TRUE   1
#define FALSE   0
#define bool   int
#define DFLT_FUEL   20
#define DFLT_LIGHTDESC   "brennend"
#define DFLT_LIGHT   2
#define CALL_OUT_TIME   100

Funktionen

void create ()
void test_remove ()
bool light (string str)
bool extinguish (string str)
bool unlight ()
void out_of_fuel ()
void AddFuel (int f)
static void _set_lighted (bool l)
bool _query_lighted ()
static void _set_fuel (int f)
static int _query_fuel ()
static string _query_lightdesc ()
static int _query_light ()
static int _query_total_light ()
string short ()

Variablen

inherit std thing
nosave int fuel
nosave int max_fuel
nosave bool lighted
nosave int call_time

Makro-Dokumentation

#define bool   int

Definiert in Zeile 47 der Datei lightsource.c.

#define CALL_OUT_TIME   100

Definiert in Zeile 54 der Datei lightsource.c.

Wird benutzt von light().

#define DFLT_FUEL   20

Definiert in Zeile 49 der Datei lightsource.c.

Wird benutzt von create().

#define DFLT_LIGHT   2

Definiert in Zeile 51 der Datei lightsource.c.

Wird benutzt von create().

#define DFLT_LIGHTDESC   "brennend"

Definiert in Zeile 50 der Datei lightsource.c.

Wird benutzt von create().

#define FALSE   0

Definiert in Zeile 46 der Datei lightsource.c.

#define TRUE   1

Definiert in Zeile 45 der Datei lightsource.c.


Dokumentation der Funktionen

static int _query_fuel (  )  [static]

Definiert in Zeile 277 der Datei lightsource.c.

Benutzt call_time und fuel.

Wird benutzt von _query_lightdesc().

00278 {
00279   int tmp;
00280 
00281   if ((tmp=find_call_out("out_of_fuel"))>=0)
00282     return fuel-call_time+tmp;
00283   else return fuel;
00284 }

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

static int _query_light (  )  [static]

Definiert in Zeile 299 der Datei lightsource.c.

Benutzt lighted, P_LIGHT und Query().

00300 {   return (lighted ? Query(P_LIGHT) : 0);  }

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

static string _query_lightdesc (  )  [static]

Definiert in Zeile 286 der Datei lightsource.c.

Benutzt _query_fuel(), i, max_fuel, P_LIGHTDESC und Query().

00287 {
00288   string *tmp;
00289   int n,i;
00290   
00291   tmp=Query(P_LIGHTDESC);
00292   if (!pointerp(tmp)) return (string)tmp;
00293   n=sizeof(tmp);
00294   i=n*_query_fuel()/max_fuel;
00295   if (i>=n) i=n-1;
00296   return tmp[i];
00297 }

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

bool _query_lighted (  ) 

Definiert in Zeile 268 der Datei lightsource.c.

Benutzt lighted.

00269 {  return lighted ;  }

static int _query_total_light (  )  [static]

Definiert in Zeile 302 der Datei lightsource.c.

Benutzt P_LIGHT und QueryProp().

00303 {   return QueryProp(P_LIGHT);   }

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

static void _set_fuel ( int  f  )  [static]

Definiert in Zeile 271 der Datei lightsource.c.

Benutzt fuel und max_fuel.

00272 {
00273   if (f>max_fuel) max_fuel=f;
00274   fuel = f ;
00275 }

static void _set_lighted ( bool  l  )  [static]

Definiert in Zeile 265 der Datei lightsource.c.

Benutzt lighted.

00266 {  lighted = l ;  }

void AddFuel ( int  f  ) 

Definiert in Zeile 260 der Datei lightsource.c.

Benutzt fuel.

00261 {  fuel += f ;  }

void create (  ) 

Definiert in Zeile 63 der Datei lightsource.c.

Benutzt AddCmd(), AddId(), create(), DFLT_FUEL, DFLT_LIGHT, DFLT_LIGHTDESC, FEMALE, P_DO_DESTRUCT, P_FUEL, P_GENDER, P_LIGHT, P_LIGHTDESC, P_LONG, P_NAME, P_SHORT, P_VALUE, SetProp() und TRUE.

00064 {
00065   thing::create() ;
00066   
00067   SetProp( P_NAME, "Lichtquelle" ) ;
00068   SetProp( P_SHORT, "Eine Lichtquelle" ) ;
00069   SetProp( P_LONG, "Du siehst nichts besonderes.\n" ) ;
00070   SetProp( P_GENDER, FEMALE ) ;
00071   SetProp( P_FUEL, DFLT_FUEL ) ;
00072   SetProp( P_LIGHTDESC, DFLT_LIGHTDESC ) ;
00073   SetProp( P_LIGHT, DFLT_LIGHT );
00074   SetProp( P_DO_DESTRUCT, TRUE ) ;
00075   SetProp( P_VALUE, 5 ) ;
00076   
00077   AddId( ({ "lichtquelle", "\nlichtquelle" }) ) ;
00078   AddCmd( ({ "zuende", "zuend" }), "light" );
00079   AddCmd( ({ "loesche", "loesch" }), "extinguish" );
00080 }

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

bool extinguish ( string  str  ) 

Definiert in Zeile 139 der Datei lightsource.c.

Benutzt _notify_fail(), call_time, CAP, env(), FALSE, fuel, lighted, name, P_PLAYER_LIGHT, PL, QueryProp(), test_remove(), TRUE, WEN und WER.

00140 {
00141   int ti;
00142   object env;
00143 
00144   _notify_fail( "Welche Lichtquelle moechtest Du loeschen?\n" ) ;
00145 
00146   if( (!str) || (!id( str )) )
00147     return FALSE ;
00148   
00149   if( !lighted )
00150   {
00151     _notify_fail( CAP( name( WER, 1 ) ) + " brennt gar nicht.\n" ) ;
00152     return FALSE ;
00153   }
00154 
00155   if( environment() != PL )
00156   {
00157     _notify_fail( "Erstmal musst Du " + name( WEN, 0 ) + " haben.\n" ) ;
00158     return FALSE ;
00159   }
00160 
00161   if( ( ti = remove_call_out( "out_of_fuel" ) ) == -1 )
00162     ti = 0 ;
00163 
00164   fuel -= (call_time - ti) ;
00165   lighted = FALSE ;
00166   env=this_object();
00167   while (objectp(env=environment(env)))
00168       // Ja. Man ruft die _set_xxx()-Funktionen eigentlich nicht direkt auf.
00169       // Aber das Lichtsystem ist schon *so* rechenintensiv und gerade der
00170       // P_LAST_CONTENT_CHANGE-Cache wird *so* oft benoetigt, dass es mir
00171       // da um jedes bisschen Rechenzeit geht.
00172       // Der Zweck heiligt ja bekanntlich die Mittel. ;-)
00173       //
00174       // Tiamak
00175       env->_set_last_content_change();
00176   if ( this_player()->QueryProp(P_PLAYER_LIGHT) == 0 )
00177   {
00178     write( "Es wird dunkel.\n" ) ;
00179     say((string)PL->Name(WER) 
00180                 + " macht das Licht aus.\n" ) ;
00181   }
00182   else
00183   {
00184     write( "Ok.\n" ) ;
00185     say((string)PL->Name(WER)
00186                 + " loescht " + name( WEN, 0 ) + " aus.\n" ) ;
00187   }
00188 
00189   if( fuel <= 0 ) test_remove() ;
00190   return TRUE ;
00191 }

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

bool light ( string  str  ) 

Definiert in Zeile 88 der Datei lightsource.c.

Benutzt _notify_fail(), call_out(), CALL_OUT_TIME, call_time, CAP, env(), FALSE, fuel, lighted, name, P_PLAYER_LIGHT, PL, test_remove(), TRUE, WEN und WER.

Wird benutzt von _query_int_light(), _query_total_light(), Request(), set_light() und StdSkill_Nightvision().

00089 {
00090   string tmp ;
00091   object env;
00092 
00093   _notify_fail( "Zuende was an?\n" ) ;
00094 
00095   if( (!str) || (!sscanf( str, "%s an", tmp )) || (!id( tmp )) )
00096     return FALSE ;
00097   
00098   if( environment() != PL ) // Player hat es nicht
00099   {
00100     _notify_fail( "Erstmal musst Du " + name( WEN, 0 ) + " haben.\n" ) ;
00101     return FALSE ;
00102   }
00103   
00104   if( lighted )
00105   {
00106     _notify_fail( CAP( name( WER, 1 ) ) + " brennt schon.\n" ) ;
00107     return FALSE ;
00108   }
00109 
00110   if( fuel <= 0 )
00111   {
00112     _notify_fail( CAP( name( WER, 1 ) ) + " ist abgebrannt.\n" ) ;
00113     test_remove() ;
00114     return FALSE ;
00115   }
00116 
00117   lighted = TRUE ;
00118   env=this_object();
00119   while (objectp(env=environment(env)))
00120       // Ja. Man ruft die _set_xxx()-Funktionen eigentlich nicht direkt auf.
00121       // Aber das Lichtsystem ist schon *so* rechenintensiv und gerade der
00122       // P_LAST_CONTENT_CHANGE-Cache wird *so* oft benoetigt, dass es mir
00123       // da um jedes bisschen Rechenzeit geht.
00124       // Der Zweck heiligt ja bekanntlich die Mittel. ;-)
00125       //
00126       // Tiamak
00127       env->_set_last_content_change();
00128   call_time = (fuel < CALL_OUT_TIME)? fuel : CALL_OUT_TIME ;
00129   call_out( "out_of_fuel", call_time ) ;
00130   if( (int)PL->QueryProp(P_PLAYER_LIGHT) == 1 )
00131     write( "Du kannst wieder etwas sehen.\n" ) ;
00132   else write( "Ok.\n" ) ;
00133   say((string)PL->Name(WER)
00134       + " zuendet " + name( WEN, 0 ) + " an.\n" ) ;
00135 
00136   return TRUE ;
00137 }

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

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

void out_of_fuel (  ) 

Definiert in Zeile 214 der Datei lightsource.c.

Benutzt call_out(), call_time, CAP, env(), FALSE, fuel, i, inv(), lighted, name, P_NAME, P_PLAYER_LIGHT, QueryProp(), test_remove(), WER und WESSEN.

00215 {
00216   int i;
00217   object *inv, env;
00218   
00219   fuel -= call_time ;
00220 
00221   if (fuel>0) {
00222     call_out( "out_of_fuel", call_time ) ;
00223     return ;
00224   }
00225   lighted=FALSE;
00226   env=this_object();
00227   while (objectp(env=environment(env)))
00228       // Immer noch nicht wirklich sauber. Aber Begruendung siehe oben.
00229       env->_set_last_content_change();
00230 
00231   if (environment())
00232   {
00233     if ( living(environment()) && environment(environment()) )
00234     {
00235       inv=(users() & all_inventory(environment(environment())))-({ environment() });
00236       for (i=sizeof(inv)-1; i>=0; i--) 
00237         if (inv[i]->QueryProp(P_PLAYER_LIGHT)<=0)
00238           tell_object(inv[i], "Es wird dunkel als " + environment()->name(WESSEN) +
00239             " " + QueryProp(P_NAME) + " erlischt.\n" ) ;
00240         else tell_object(inv[i], CAP( name( WER, 0 ) ) + " erlischt.\n" ) ;
00241       if (environment()->QueryProp(P_PLAYER_LIGHT)<=0)
00242         tell_object(environment(), 
00243           CAP( name( WER, 1 ) ) + " erlischt und es wird dunkel.\n" ) ;
00244       else tell_object(environment(), CAP( name( WER, 1 ) ) + " erlischt.\n" ) ;    
00245     }
00246     else
00247     {
00248       inv=(users() & all_inventory(environment()));
00249       for (i=sizeof(inv)-1; i>=0; i--) 
00250         if (inv[i]->QueryProp(P_PLAYER_LIGHT)<=0)
00251           tell_object(inv[i], "Es wird dunkel als " + name(WER,1)
00252           + " erlischt.\n" ) ;
00253         else tell_object(inv[i], CAP( name( WER, 0 ) ) + " erlischt.\n" ) ;
00254     }
00255   }  
00256   test_remove() ;
00257 }

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

string short (  ) 

Definiert in Zeile 308 der Datei lightsource.c.

Benutzt desc, lighted, P_LIGHTDESC, P_SHORT und QueryProp().

00309 {
00310   string s;
00311   string desc;
00312 
00313   if(!(s=QueryProp(P_SHORT)))
00314     return 0;
00315   return s + ( (lighted)? (" ("+QueryProp( P_LIGHTDESC ) +").\n") : ".\n" );
00316 }

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

void test_remove (  ) 

Definiert in Zeile 82 der Datei lightsource.c.

Benutzt P_DO_DESTRUCT und QueryProp().

00083 {  if (QueryProp(P_DO_DESTRUCT)) remove();  }

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

bool unlight (  ) 

Definiert in Zeile 193 der Datei lightsource.c.

Benutzt call_time, env(), FALSE, fuel, lighted, test_remove() und TRUE.

00194 {
00195   int ti;
00196   object env;
00197 
00198   if( !lighted )
00199     return FALSE ;
00200 
00201   if( ( ti = remove_call_out( "out_of_fuel" ) ) == -1 )
00202     ti = 0 ;
00203 
00204   fuel -= (call_time - ti) ;
00205   lighted = FALSE ;
00206   env=this_object();
00207   while (objectp(env=environment(env)))
00208       // Kommentar siehe oben ;^)
00209       env->_set_last_content_change();
00210   if( fuel <= 0 ) test_remove() ;
00211   return TRUE ;
00212 }

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


Variablen-Dokumentation

nosave int call_time

Definiert in Zeile 61 der Datei lightsource.c.

Wird benutzt von _query_fuel(), extinguish(), light(), out_of_fuel() und unlight().

nosave int fuel

Definiert in Zeile 59 der Datei lightsource.c.

Wird benutzt von _query_fuel(), _set_fuel(), AddFuel(), extinguish(), light(), out_of_fuel() und unlight().

nosave bool lighted
nosave int max_fuel

Definiert in Zeile 59 der Datei lightsource.c.

Wird benutzt von _query_lightdesc() und _set_fuel().

inherit std thing

Definiert in Zeile 39 der Datei lightsource.c.

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