MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // thing/description.c -- Lichtsystemkomponenten fuer Standardobjekte |
| 4 | // |
| 5 | // $Id: description.c 7635 2010-08-19 21:21:30Z Zesstra $ |
| 6 | |
| 7 | #pragma strict_types |
| 8 | #pragma save_types,rtt_checks |
| 9 | #pragma range_check |
| 10 | #pragma no_clone |
| 11 | #pragma pedantic |
| 12 | |
| 13 | #define NEED_PROTOTYPES |
| 14 | #include <thing/properties.h> |
| 15 | #include <thing/language.h> |
| 16 | #include <hook.h> |
| 17 | #undef NEED_PROTOTYPES |
| 18 | |
| 19 | #include <thing/lighttypes.h> |
| 20 | #include <properties.h> |
| 21 | |
| 22 | // ##################### |
| 23 | //######################## System-Funktionen ############################ |
| 24 | // ##################### |
| 25 | |
| 26 | // Objekt erzeugen |
| 27 | protected void create() |
| 28 | { |
| 29 | Set( P_LIGHT, 0 ); |
| 30 | Set( P_LIGHT_TYPE, LT_MISC); |
| 31 | } |
| 32 | |
| 33 | protected void create_super() { |
| 34 | set_next_reset(-1); |
| 35 | } |
| 36 | |
| 37 | // Lichtsy ... sys ... |
| 38 | static int _query_total_light() { return QueryProp(P_LIGHT); } |
| 39 | |
| 40 | static int _set_light( int light ) |
| 41 | { |
| 42 | object env = this_object(); |
| 43 | |
| 44 | // TODO: Temporaer Lichtlevel in geeignete Wertefenster zwingen. |
| 45 | if (light > 100) |
| 46 | light = 100; |
| 47 | else if (light < -100) |
| 48 | light = -100; |
| 49 | |
| 50 | while ( objectp(env = environment(env)) ) |
| 51 | // Ja. Man ruft die _set_xxx()-Funktionen eigentlich nicht direkt auf. |
| 52 | // Aber das Lichtsystem ist schon *so* rechenintensiv und gerade der |
| 53 | // P_LAST_CONTENT_CHANGE-Cache wird *so* oft benoetigt, dass es mir |
| 54 | // da um jedes bisschen Rechenzeit geht. |
| 55 | // Der Zweck heiligt ja bekanntlich die Mittel. ;-) |
| 56 | // |
| 57 | // Tiamak |
| 58 | env->_set_last_content_change(); |
| 59 | |
| 60 | return Set( P_LIGHT, light, F_VALUE); |
| 61 | } |
| 62 | |