#include <properties.h>#include <language.h>#include <defines.h>
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 |
| #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.
| static int _query_fuel | ( | ) | [static] |
Definiert in Zeile 277 der Datei lightsource.c.
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 }

| static int _query_light | ( | ) | [static] |
| 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 }

| bool _query_lighted | ( | ) |
| static int _query_total_light | ( | ) | [static] |
Definiert in Zeile 302 der Datei lightsource.c.
Benutzt P_LIGHT und QueryProp().

| static void _set_fuel | ( | int | f | ) | [static] |
| static void _set_lighted | ( | bool | l | ) | [static] |
| void AddFuel | ( | int | 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 }

| 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 }

| 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 }


| 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 }

| 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 }

| void test_remove | ( | ) |
Definiert in Zeile 82 der Datei lightsource.c.
Benutzt P_DO_DESTRUCT und QueryProp().
00083 { if (QueryProp(P_DO_DESTRUCT)) remove(); }

| 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 }

| 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 |
Definiert in Zeile 60 der Datei lightsource.c.
Wird benutzt von _query_light(), _query_lighted(), _set_lighted(), extinguish(), light(), out_of_fuel(), short() und unlight().
| 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.
1.6.3