MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // thing/properties.h -- contains property definitions and prototypes |
| 4 | // |
| 5 | // $Id: properties.h,v 3.5 2003/08/07 15:09:33 Rikus Exp $ |
| 6 | |
| 7 | #ifndef __THING_PROPERTIES_H__ |
| 8 | #define __THING_PROPERTIES_H__ |
| 9 | |
Zesstra | 3f3e784 | 2022-01-16 22:33:03 +0100 | [diff] [blame] | 10 | // Type Flags indexing <prop> and they are used as well for Set() calls |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 11 | #define F_VALUE 0 |
| 12 | #define F_MODE 1 |
| 13 | #define F_SET_METHOD 2 |
| 14 | #define F_QUERY_METHOD 3 |
Zesstra | 3f3e784 | 2022-01-16 22:33:03 +0100 | [diff] [blame] | 15 | #define F_PROP_ENTRIES 4 // how many entries in <prop> mapping? |
Zesstra | 375df1e | 2021-04-21 11:09:06 +0200 | [diff] [blame] | 16 | |
Zesstra | f54f03a | 2021-12-29 19:55:08 +0100 | [diff] [blame] | 17 | // The following are used as type flags for Set(), but they do not index |
| 18 | // <prop>, therfore they have a negative sign. |
| 19 | // |
| 20 | // F_SET_MAPPER sets F_SET_METHOD, but additionally sets the mode SETMAPPED |
| 21 | // automatically |
| 22 | #define F_SET_MAPPER -F_SET_METHOD |
Zesstra | 375df1e | 2021-04-21 11:09:06 +0200 | [diff] [blame] | 23 | // Flags for Set() to modify/manipulate F_MODE of a property in bit-wise |
Zesstra | 3f3e784 | 2022-01-16 22:33:03 +0100 | [diff] [blame] | 24 | // manner (but are themselves not bitwise of course!). |
| 25 | #define F_MODE_AS -400 |
| 26 | #define F_MODE_AD -500 |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 27 | |
Zesstra | 3f3e784 | 2022-01-16 22:33:03 +0100 | [diff] [blame] | 28 | // and from here the mode flags for Properties |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 29 | #define SAVE 64 |
| 30 | #define PROTECTED 128 // only this_object() can change the values |
| 31 | #define SECURED 256 // like PROTECTED, but never resetable |
| 32 | #define NOSETMETHOD 512 // Keine Set-Methode => Nicht mofifizierbar |
Zesstra | f54f03a | 2021-12-29 19:55:08 +0100 | [diff] [blame] | 33 | #define SETMAPPED 0x4000 // Setmethod only maps, not sets |
Zesstra | 375df1e | 2021-04-21 11:09:06 +0200 | [diff] [blame] | 34 | // Problem with the following: shadows, default methods etc. may change the |
| 35 | // result at runtime and they do not save that much time (or even at all?) |
| 36 | // because of the apply cache of the driver. Not used since 1995. But |
| 37 | // be careful about re-using the values because of ancient (!) savefiles |
| 38 | #define SETMNOTFOUND 1024 // Keine Set-Methode gefunden. Not used. |
| 39 | #define QUERYMNOTFOUND 2048 // Keine Query-Methode gefunden. Not used. |
| 40 | #define QUERYCACHED 4096 // Not used anymore |
| 41 | #define SETCACHED 8192 // Not used anymore |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 42 | |
| 43 | #endif // __THING_PROPERTIES_H__ |
| 44 | |
| 45 | #ifdef NEED_PROTOTYPES |
| 46 | |
| 47 | #ifndef __THING_PROPERTIES_H_PROTO__ |
| 48 | #define __THING_PROPERTIES_H_PROTO__ |
| 49 | |
| 50 | // prototypes |
| 51 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 52 | // direct property access |
Zesstra | 5c0c409 | 2021-09-08 23:27:54 +0200 | [diff] [blame] | 53 | public mixed Set(string name, mixed Value, |
| 54 | int Type = F_VALUE, int drop_priv = extern_call()); |
| 55 | public mixed Query(string name, int Type = F_VALUE); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 56 | |
| 57 | // filtered property access |
Zesstra | ffcd0fe | 2021-09-08 23:33:17 +0200 | [diff] [blame] | 58 | public mixed SetProp(string name, mixed Value, int drop_priv = extern_call()); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 59 | public mixed QueryProp(string name); |
Zesstra | faebc15 | 2021-07-06 22:21:47 +0200 | [diff] [blame] | 60 | public mixed AddToProp(string pname, |
| 61 | <int|float|string|mixed*|mapping|bytes> add_value); |
| 62 | public mixed SubFromProp(string pname, |
| 63 | <int|float|string|mixed*|mapping|bytes> sub_value); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 64 | |
| 65 | // global property handling |
| 66 | public void SetProperties(mapping props); |
| 67 | public mapping QueryProperties(); |
| 68 | |
| 69 | // misc/interna |
| 70 | public mixed *__query_properties(); |
| 71 | public void _set_save_data(mixed data); |
| 72 | public mixed _get_save_data(); |
| 73 | |
| 74 | #endif // __THING_PROPERTIES_H_PROTO__ |
| 75 | |
| 76 | #endif // NEED_PROTOTYPES |