equal
deleted
inserted
replaced
20 #include "team.h" |
20 #include "team.h" |
21 |
21 |
22 #include "../util/inihelper.h" |
22 #include "../util/inihelper.h" |
23 #include "../util/util.h" |
23 #include "../util/util.h" |
24 #include "../util/logging.h" |
24 #include "../util/logging.h" |
25 #include "../util/refcounter.h" |
|
26 |
25 |
27 #include <string.h> |
26 #include <string.h> |
28 #include <stdlib.h> |
27 #include <stdlib.h> |
29 |
28 |
30 static flib_team *from_ini_handleError(flib_team *result, flib_ini *settingfile) { |
29 static flib_team *from_ini_handleError(flib_team *result, flib_ini *settingfile) { |
133 void flib_team_destroy(flib_team *team) { |
132 void flib_team_destroy(flib_team *team) { |
134 if(team) { |
133 if(team) { |
135 for(int i=0; i<HEDGEHOGS_PER_TEAM; i++) { |
134 for(int i=0; i<HEDGEHOGS_PER_TEAM; i++) { |
136 free(team->hogs[i].name); |
135 free(team->hogs[i].name); |
137 free(team->hogs[i].hat); |
136 free(team->hogs[i].hat); |
138 flib_weaponset_release(team->hogs[i].weaponset); |
137 flib_weaponset_destroy(team->hogs[i].weaponset); |
139 } |
138 } |
140 free(team->name); |
139 free(team->name); |
141 free(team->grave); |
140 free(team->grave); |
142 free(team->fort); |
141 free(team->fort); |
143 free(team->voicepack); |
142 free(team->voicepack); |
232 flib_ini_destroy(ini); |
231 flib_ini_destroy(ini); |
233 } |
232 } |
234 return result; |
233 return result; |
235 } |
234 } |
236 |
235 |
237 void flib_team_set_weaponset(flib_team *team, flib_weaponset *set) { |
236 int flib_team_set_weaponset(flib_team *team, const flib_weaponset *set) { |
238 if(team) { |
237 if(team) { |
239 for(int i=0; i<HEDGEHOGS_PER_TEAM; i++) { |
238 for(int i=0; i<HEDGEHOGS_PER_TEAM; i++) { |
240 flib_weaponset_release(team->hogs[i].weaponset); |
239 flib_weaponset_destroy(team->hogs[i].weaponset); |
241 team->hogs[i].weaponset = flib_weaponset_retain(set); |
240 team->hogs[i].weaponset = flib_weaponset_copy(set); |
242 } |
241 if(set && !team->hogs[i].weaponset) { |
243 } |
242 return -1; |
|
243 } |
|
244 } |
|
245 } |
|
246 return 0; |
244 } |
247 } |
245 |
248 |
246 void flib_team_set_health(flib_team *team, int health) { |
249 void flib_team_set_health(flib_team *team, int health) { |
247 if(team) { |
250 if(team) { |
248 for(int i=0; i<HEDGEHOGS_PER_TEAM; i++) { |
251 for(int i=0; i<HEDGEHOGS_PER_TEAM; i++) { |
273 tmpTeam->hogs[i].kills = team->hogs[i].kills; |
276 tmpTeam->hogs[i].kills = team->hogs[i].kills; |
274 tmpTeam->hogs[i].deaths = team->hogs[i].deaths; |
277 tmpTeam->hogs[i].deaths = team->hogs[i].deaths; |
275 tmpTeam->hogs[i].suicides = team->hogs[i].suicides; |
278 tmpTeam->hogs[i].suicides = team->hogs[i].suicides; |
276 tmpTeam->hogs[i].difficulty = team->hogs[i].difficulty; |
279 tmpTeam->hogs[i].difficulty = team->hogs[i].difficulty; |
277 tmpTeam->hogs[i].initialHealth = team->hogs[i].initialHealth; |
280 tmpTeam->hogs[i].initialHealth = team->hogs[i].initialHealth; |
278 tmpTeam->hogs[i].weaponset = flib_weaponset_retain(team->hogs[i].weaponset); |
281 tmpTeam->hogs[i].weaponset = flib_weaponset_copy(team->hogs[i].weaponset); |
|
282 if(team->hogs[i].weaponset && !tmpTeam->hogs[i].weaponset) { |
|
283 error = true; |
|
284 } |
279 } |
285 } |
280 |
286 |
281 tmpTeam->name = strdupWithError(team->name, &error); |
287 tmpTeam->name = strdupWithError(team->name, &error); |
282 tmpTeam->grave = strdupWithError(team->grave, &error); |
288 tmpTeam->grave = strdupWithError(team->grave, &error); |
283 tmpTeam->fort = strdupWithError(team->fort, &error); |
289 tmpTeam->fort = strdupWithError(team->fort, &error); |