10017
|
1 |
/*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
18 |
*/
|
|
19 |
|
|
20 |
/**
|
|
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", which describes how each setting and mod is sent to the
|
|
25 |
* engine, and in which order they appear in the network protocol. The metascheme is defined
|
|
26 |
* in hwconsts.h
|
|
27 |
*/
|
|
28 |
|
|
29 |
#ifndef SCHEME_H_
|
|
30 |
#define SCHEME_H_
|
|
31 |
|
|
32 |
#include <stdbool.h>
|
|
33 |
#include <stddef.h>
|
|
34 |
#include "../hwconsts.h"
|
|
35 |
|
|
36 |
/**
|
|
37 |
* The settings and mods arrays have the same number and order of elements
|
|
38 |
* as the corresponding arrays in the metascheme.
|
|
39 |
*/
|
|
40 |
typedef struct {
|
|
41 |
char *name;
|
|
42 |
int *settings;
|
|
43 |
bool *mods;
|
|
44 |
} flib_scheme;
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Create a new configuration with everything set to default or false
|
|
48 |
* Returns NULL on error.
|
|
49 |
*/
|
|
50 |
flib_scheme *flib_scheme_create(const char *schemeName);
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Create a copy of the scheme. Returns NULL on error or if NULL was passed.
|
|
54 |
*/
|
|
55 |
flib_scheme *flib_scheme_copy(const flib_scheme *scheme);
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Decrease the reference count of the object and free it if this was the last reference.
|
|
59 |
*/
|
|
60 |
void flib_scheme_destroy(flib_scheme* scheme);
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Retrieve a mod setting by its name. If the mod is not found, logs an error and returns false.
|
|
64 |
*/
|
|
65 |
bool flib_scheme_get_mod(const flib_scheme *scheme, const char *name);
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Retrieve a game setting by its name. If the setting is not found, logs an error and returns def.
|
|
69 |
*/
|
|
70 |
int flib_scheme_get_setting(const flib_scheme *scheme, const char *name, int def);
|
|
71 |
|
|
72 |
#endif /* SCHEME_H_ */
|