equal
deleted
inserted
replaced
|
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 |
1 #include "cfg.h" |
20 #include "cfg.h" |
2 |
21 |
3 #include "../util/inihelper.h" |
22 #include "../util/inihelper.h" |
4 #include "../util/logging.h" |
23 #include "../util/logging.h" |
5 #include "../util/util.h" |
24 #include "../util/util.h" |
192 void flib_cfg_release(flib_cfg *cfg) { |
211 void flib_cfg_release(flib_cfg *cfg) { |
193 if(cfg && flib_release(&cfg->_referenceCount, "flib_cfg")) { |
212 if(cfg && flib_release(&cfg->_referenceCount, "flib_cfg")) { |
194 flib_cfg_destroy(cfg); |
213 flib_cfg_destroy(cfg); |
195 } |
214 } |
196 } |
215 } |
|
216 |
|
217 bool flib_cfg_get_mod(flib_cfg *cfg, const char *name) { |
|
218 for(int i=0; i<cfg->meta->modCount; i++) { |
|
219 if(!strcmp(cfg->meta->mods[i].name, name)) { |
|
220 return cfg->mods[i]; |
|
221 } |
|
222 } |
|
223 flib_log_e("Unable to find game mod %s", name); |
|
224 return false; |
|
225 } |
|
226 |
|
227 int flib_cfg_get_setting(flib_cfg *cfg, const char *name, int def) { |
|
228 for(int i=0; i<cfg->meta->settingCount; i++) { |
|
229 if(!strcmp(cfg->meta->settings[i].name, name)) { |
|
230 return cfg->settings[i]; |
|
231 } |
|
232 } |
|
233 flib_log_e("Unable to find game setting %s", name); |
|
234 return def; |
|
235 } |