equal
deleted
inserted
replaced
32 flib_team_release(result); |
32 flib_team_release(result); |
33 return NULL; |
33 return NULL; |
34 } |
34 } |
35 |
35 |
36 flib_team *flib_team_from_ini(const char *filename) { |
36 flib_team *flib_team_from_ini(const char *filename) { |
|
37 if(log_badargs_if(filename==NULL)) { |
|
38 return NULL; |
|
39 } |
|
40 |
37 flib_team *result = flib_team_retain(flib_calloc(1, sizeof(flib_team))); |
41 flib_team *result = flib_team_retain(flib_calloc(1, sizeof(flib_team))); |
38 flib_ini *ini = NULL; |
42 flib_ini *ini = NULL; |
39 |
|
40 if(!filename) { |
|
41 flib_log_e("null parameter in flib_team_from_ini"); |
|
42 return from_ini_handleError(result, ini); |
|
43 } |
|
44 |
43 |
45 if(!result) { |
44 if(!result) { |
46 return from_ini_handleError(result, ini); |
45 return from_ini_handleError(result, ini); |
47 } |
46 } |
48 |
47 |
192 return 0; |
191 return 0; |
193 } |
192 } |
194 |
193 |
195 int flib_team_to_ini(const char *filename, const flib_team *team) { |
194 int flib_team_to_ini(const char *filename, const flib_team *team) { |
196 int result = -1; |
195 int result = -1; |
197 if(!filename || !team) { |
196 if(!log_badargs_if2(filename==NULL, team==NULL)) { |
198 flib_log_e("null parameter in flib_team_to_ini"); |
|
199 } else { |
|
200 flib_ini *ini = flib_ini_create(filename); |
197 flib_ini *ini = flib_ini_create(filename); |
201 bool error = false; |
198 bool error = false; |
202 error |= writeTeamSection(team, ini); |
199 error |= writeTeamSection(team, ini); |
203 error |= writeHogSections(team, ini); |
200 error |= writeHogSections(team, ini); |
204 error |= writeBindingSection(team, ini); |
201 error |= writeBindingSection(team, ini); |
256 team->hogs[i].initialHealth = health; |
253 team->hogs[i].initialHealth = health; |
257 } |
254 } |
258 } |
255 } |
259 } |
256 } |
260 |
257 |
261 char *strdupWithError(const char *in, bool *error) { |
258 static char *strdupWithError(const char *in, bool *error) { |
262 char *out = flib_strdupnull(in); |
259 char *out = flib_strdupnull(in); |
263 if(in && !out) { |
260 if(in && !out) { |
264 *error = true; |
261 *error = true; |
265 } |
262 } |
266 return out; |
263 return out; |