17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 */ |
18 */ |
19 |
19 |
20 /** |
20 /** |
21 * Data structures for game scheme information. |
21 * Data structures for game scheme information. |
|
22 * |
|
23 * The scheme consists of settings (integers) and mods (booleans). These are not fixed, but |
|
24 * described in a "metascheme" file, which describes how each setting and mod is sent to the |
|
25 * engine, and in which order they appear in the network protocol. |
22 */ |
26 */ |
23 |
27 |
24 #ifndef SCHEME_H_ |
28 #ifndef SCHEME_H_ |
25 #define SCHEME_H_ |
29 #define SCHEME_H_ |
26 |
30 |
27 #include <stdbool.h> |
31 #include <stdbool.h> |
28 |
32 |
29 typedef struct { |
33 typedef struct { |
30 char *name; |
34 char *name; // A name identifying this setting (used as key in the schemes file) |
31 char *engineCommand; |
35 char *engineCommand; // The command needed to send the setting to the engine. May be null if the setting is not sent to the engine (for the "health" setting) |
32 bool maxMeansInfinity; |
36 bool maxMeansInfinity; // If true, send a very high number to the engine if the setting is equal to its maximum |
33 bool times1000; |
37 bool times1000; // If true (for time-based settings), multiply the setting by 1000 before sending it to the engine. |
34 int min; |
38 int min; // The smallest allowed value |
35 int max; |
39 int max; // The highest allowed value |
36 int def; |
40 int def; // The default value |
37 } flib_metascheme_setting; |
41 } flib_metascheme_setting; |
38 |
42 |
39 typedef struct { |
43 typedef struct { |
40 char *name; |
44 char *name; // A name identifying this mod (used as key in the schemes file) |
41 int bitmaskIndex; |
45 int bitmaskIndex; // Mods are sent to the engine in a single integer, this field describes which bit of that integer is used |
|
46 // for this particular mod. |
42 } flib_metascheme_mod; |
47 } flib_metascheme_mod; |
43 |
48 |
44 /** |
49 /** |
45 * The order of the meta information in the arrays is the same as the order |
50 * The order of the meta information in the arrays is the same as the order |
46 * of the mod/setting information in the net protocol messages. |
51 * of the mod/setting information in the net protocol messages. |
91 * Create a copy of the scheme. Returns NULL on error or if NULL was passed. |
99 * Create a copy of the scheme. Returns NULL on error or if NULL was passed. |
92 */ |
100 */ |
93 flib_scheme *flib_scheme_copy(const flib_scheme *scheme); |
101 flib_scheme *flib_scheme_copy(const flib_scheme *scheme); |
94 |
102 |
95 /** |
103 /** |
96 * Increase the reference count of the object. Call this if you store a pointer to it somewhere. |
|
97 * Returns the parameter. |
|
98 */ |
|
99 flib_scheme *flib_scheme_retain(flib_scheme *scheme); |
|
100 |
|
101 /** |
|
102 * Decrease the reference count of the object and free it if this was the last reference. |
104 * Decrease the reference count of the object and free it if this was the last reference. |
103 */ |
105 */ |
104 void flib_scheme_release(flib_scheme* scheme); |
106 void flib_scheme_destroy(flib_scheme* scheme); |
105 |
107 |
106 /** |
108 /** |
107 * Retrieve a mod setting by its name. If the mod is not found, logs an error and returns false. |
109 * Retrieve a mod setting by its name. If the mod is not found, logs an error and returns false. |
108 */ |
110 */ |
109 bool flib_scheme_get_mod(flib_scheme *scheme, const char *name); |
111 bool flib_scheme_get_mod(flib_scheme *scheme, const char *name); |