author | Medo <smaxein@googlemail.com> |
Thu, 05 Jul 2012 00:33:24 +0200 | |
changeset 7316 | f7b49b2c5d84 |
parent 7314 | 6171f0bad318 |
child 7320 | e704706008d4 |
permissions | -rw-r--r-- |
7314
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
1 |
/* |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com> |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
4 |
* |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
6 |
* modify it under the terms of the GNU General Public License |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
7 |
* as published by the Free Software Foundation; either version 2 |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
8 |
* of the License, or (at your option) any later version. |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
9 |
* |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
13 |
* GNU General Public License for more details. |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
14 |
* |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
18 |
*/ |
6171f0bad318
frontlib: Fixes and improvements. Added a GPLv2+ license header to all frontlib
Medo <smaxein@googlemail.com>
parents:
7275
diff
changeset
|
19 |
|
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
20 |
#include "gamesetup.h" |
7316
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
21 |
#include "../util/util.h" |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
22 |
|
7275
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
23 |
#include <stdlib.h> |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
24 |
|
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
25 |
void flib_gamesetup_destroy(flib_gamesetup *gamesetup) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
26 |
if(gamesetup) { |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
27 |
free(gamesetup->script); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
28 |
flib_cfg_release(gamesetup->gamescheme); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
29 |
flib_map_release(gamesetup->map); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
30 |
flib_teamlist_destroy(gamesetup->teamlist); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
31 |
free(gamesetup); |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
32 |
} |
15f722e0b96f
frontlib: Getting there :) Added commandline client for testing
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
33 |
} |
7316
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
34 |
|
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
35 |
flib_gamesetup *flib_gamesetup_copy(flib_gamesetup *setup) { |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
36 |
if(!setup) { |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
37 |
return NULL; |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
38 |
} |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
39 |
|
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
40 |
flib_gamesetup *result = flib_calloc(1, sizeof(flib_gamesetup)); |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
41 |
if(result) { |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
42 |
result->script = flib_strdupnull(setup->script); |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
43 |
result->gamescheme = flib_cfg_copy(setup->gamescheme); |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
44 |
result->map = flib_map_copy(setup->map); |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
45 |
result->teamlist = flib_teamlist_copy(setup->teamlist); |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
46 |
if((setup->script && !result->script) |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
47 |
|| (setup->gamescheme && !result->gamescheme) |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
48 |
|| (setup->map && !result->map) |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
49 |
|| (setup->teamlist && !result->teamlist)) { |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
50 |
flib_gamesetup_destroy(result); |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
51 |
result = NULL; |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
52 |
} |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
53 |
} |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
54 |
return result; |
f7b49b2c5d84
frontlib: Improved and unified parameter checking, moved the cmdlineClient out
Medo <smaxein@googlemail.com>
parents:
7314
diff
changeset
|
55 |
} |