author | Medo <smaxein@googlemail.com> |
Tue, 19 Jun 2012 21:17:05 +0200 | |
changeset 7234 | 613998625a3c |
parent 7230 | 240620f46dd7 |
child 7271 | 5608ac657362 |
permissions | -rw-r--r-- |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1 |
#include "ipcprotocol.h" |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
2 |
#include "../util/util.h" |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
3 |
#include "../util/logging.h" |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
4 |
|
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
5 |
#include <stdio.h> |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
6 |
#include <stdbool.h> |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
7 |
#include <string.h> |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
8 |
#include <inttypes.h> |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
9 |
#include <stdlib.h> |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
10 |
|
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
11 |
int flib_ipc_append_message(flib_vector *vec, const char *fmt, ...) { |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
12 |
int result = -1; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
13 |
if(!vec || !fmt) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
14 |
flib_log_e("null parameter in flib_ipc_appendmessage"); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
15 |
} else { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
16 |
// 1 byte size prefix, 255 bytes max message length, 1 0-byte for vsnprintf |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
17 |
char msgbuffer[257]; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
18 |
|
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
19 |
// Format the message, leaving one byte at the start for the length |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
20 |
va_list argp; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
va_start(argp, fmt); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
22 |
int msgSize = vsnprintf(msgbuffer+1, 256, fmt, argp); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
23 |
va_end(argp); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
24 |
|
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
25 |
if(msgSize > 255) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
26 |
flib_log_e("Message too long (%u bytes) in flib_ipc_appendmessage", (unsigned)msgSize); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
} else if(msgSize<0) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
flib_log_e("printf error in flib_ipc_appendmessage"); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
29 |
} else { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
30 |
// Add the length prefix |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
31 |
((uint8_t*)msgbuffer)[0] = msgSize; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
32 |
|
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
33 |
// Append it to the vector |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
34 |
if(flib_vector_append(vec, msgbuffer, msgSize+1) == msgSize+1) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
35 |
result = 0; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
36 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
37 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
38 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
39 |
return result; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
40 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
41 |
|
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
42 |
int flib_ipc_append_mapconf(flib_vector *vec, const flib_map *map, bool mappreview) { |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
43 |
int result = -1; |
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
44 |
flib_vector *tempvector = flib_vector_create(); |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
45 |
if(!vec || !map) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
46 |
flib_log_e("null parameter in flib_ipc_append_mapconf"); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
47 |
} else if(tempvector) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
48 |
bool error = false; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
49 |
|
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
50 |
if(map->mapgen == MAPGEN_NAMED) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
51 |
error |= flib_ipc_append_message(tempvector, "emap %s", map->name); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
52 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
53 |
if(map->theme && !mappreview) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
54 |
error |= flib_ipc_append_message(tempvector, "etheme %s", map->theme); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
55 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
56 |
error |= flib_ipc_append_message(tempvector, "e$template_filter %i", map->templateFilter); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
57 |
error |= flib_ipc_append_message(tempvector, "e$mapgen %i", map->mapgen); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
58 |
|
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
59 |
if(map->mapgen == MAPGEN_MAZE) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
60 |
error |= flib_ipc_append_message(tempvector, "e$maze_size %i", map->mazeSize); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
61 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
62 |
if(map->mapgen == MAPGEN_DRAWN) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
63 |
/* |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
64 |
* We have to split the drawn map data into several edraw messages here because |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
65 |
* it can be longer than the maximum message size. |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
66 |
*/ |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
67 |
const char *edraw = "edraw "; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
68 |
int edrawlen = strlen(edraw); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
69 |
for(int offset=0; offset<map->drawDataSize; offset+=200) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
70 |
int bytesRemaining = map->drawDataSize-offset; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
71 |
int fragmentsize = bytesRemaining < 200 ? bytesRemaining : 200; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
72 |
uint8_t messagesize = edrawlen + fragmentsize; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
73 |
error |= (flib_vector_append(tempvector, &messagesize, 1) != 1); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
74 |
error |= (flib_vector_append(tempvector, edraw, edrawlen) != edrawlen); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
75 |
error |= (flib_vector_append(tempvector, map->drawData+offset, fragmentsize) != fragmentsize); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
76 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
77 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
78 |
|
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
79 |
if(!error) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
80 |
// Message created, now we can copy everything. |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
81 |
flib_constbuffer constbuf = flib_vector_as_constbuffer(tempvector); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
82 |
if(flib_vector_append(vec, constbuf.data, constbuf.size) == constbuf.size) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
83 |
result = 0; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
84 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
85 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
86 |
} |
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
87 |
flib_vector_destroy(tempvector); |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
88 |
return result; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
89 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
90 |
|
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
91 |
int flib_ipc_append_seed(flib_vector *vec, const char *seed) { |
7177
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
92 |
if(!vec || !seed) { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
93 |
flib_log_e("null parameter in flib_ipc_append_seed"); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
94 |
return -1; |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
95 |
} else { |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
96 |
return flib_ipc_append_message(vec, "eseed %s", seed); |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
97 |
} |
bf6cf4dd847a
Implemented public API for letting the engine render maps
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
98 |
} |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
99 |
|
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
100 |
int flib_ipc_append_gamescheme(flib_vector *vec, const flib_cfg *scheme) { |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
101 |
int result = -1; |
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
102 |
flib_vector *tempvector = flib_vector_create(); |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
103 |
if(!vec || !scheme) { |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
104 |
flib_log_e("null parameter in flib_ipc_append_gamescheme"); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
105 |
} else if(tempvector) { |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
106 |
const flib_cfg_meta *meta = scheme->meta; |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
107 |
bool error = false; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
108 |
uint32_t gamemods = 0; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
109 |
for(int i=0; i<meta->modCount; i++) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
110 |
if(scheme->mods[i]) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
111 |
gamemods |= (1<<meta->mods[i].bitmaskIndex); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
112 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
113 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
114 |
error |= flib_ipc_append_message(tempvector, "e$gmflags %"PRIu32, gamemods); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
115 |
for(int i=0; i<meta->settingCount; i++) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
116 |
int value = scheme->settings[i]; |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
117 |
if(meta->settings[i].maxMeansInfinity) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
118 |
value = value>=meta->settings[i].max ? 9999 : value; |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
119 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
120 |
if(meta->settings[i].times1000) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
121 |
value *= 1000; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
122 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
123 |
error |= flib_ipc_append_message(tempvector, "%s %i", meta->settings[i].engineCommand, value); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
124 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
125 |
|
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
126 |
if(!error) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
127 |
// Message created, now we can copy everything. |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
128 |
flib_constbuffer constbuf = flib_vector_as_constbuffer(tempvector); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
129 |
if(flib_vector_append(vec, constbuf.data, constbuf.size) == constbuf.size) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
130 |
result = 0; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
131 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
132 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
133 |
} |
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
134 |
flib_vector_destroy(tempvector); |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
135 |
return result; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
136 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
137 |
|
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
138 |
static int appendWeaponSet(flib_vector *vec, flib_weaponset *set) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
139 |
return flib_ipc_append_message(vec, "eammloadt %s", set->loadout) |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
140 |
|| flib_ipc_append_message(vec, "eammprob %s", set->crateprob) |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
141 |
|| flib_ipc_append_message(vec, "eammdelay %s", set->delay) |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
142 |
|| flib_ipc_append_message(vec, "eammreinf %s", set->crateammo); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
143 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
144 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
145 |
int flib_ipc_append_addteam(flib_vector *vec, const flib_team *team, bool perHogAmmo, bool noAmmoStore) { |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
146 |
int result = -1; |
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
147 |
flib_vector *tempvector = flib_vector_create(); |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
148 |
if(!vec || !team) { |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
149 |
flib_log_e("invalid parameter in flib_ipc_append_addteam"); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
150 |
} else if(tempvector) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
151 |
bool error = false; |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
152 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
153 |
if(!perHogAmmo && !noAmmoStore) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
154 |
error |= appendWeaponSet(tempvector, team->hogs[0].weaponset); |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
155 |
error |= flib_ipc_append_message(tempvector, "eammstore"); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
156 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
157 |
|
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
158 |
char *hash = team->hash ? team->hash : "00000000000000000000000000000000"; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
159 |
error |= flib_ipc_append_message(tempvector, "eaddteam %s %"PRIu32" %s", hash, team->color, team->name); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
160 |
|
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
161 |
if(team->remoteDriven) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
162 |
error |= flib_ipc_append_message(tempvector, "erdriven"); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
163 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
164 |
|
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
165 |
error |= flib_ipc_append_message(tempvector, "egrave %s", team->grave); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
166 |
error |= flib_ipc_append_message(tempvector, "efort %s", team->fort); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
167 |
error |= flib_ipc_append_message(tempvector, "evoicepack %s", team->voicepack); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
168 |
error |= flib_ipc_append_message(tempvector, "eflag %s", team->flag); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
169 |
|
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
170 |
for(int i=0; i<team->bindingCount; i++) { |
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
171 |
error |= flib_ipc_append_message(tempvector, "ebind %s %s", team->bindings[i].binding, team->bindings[i].action); |
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
172 |
} |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
173 |
|
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
174 |
for(int i=0; i<team->hogsInGame; i++) { |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
175 |
if(perHogAmmo && !noAmmoStore) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
176 |
error |= appendWeaponSet(tempvector, team->hogs[i].weaponset); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
177 |
} |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
178 |
error |= flib_ipc_append_message(tempvector, "eaddhh %i %i %s", team->hogs[i].difficulty, team->hogs[i].initialHealth, team->hogs[i].name); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
179 |
error |= flib_ipc_append_message(tempvector, "ehat %s", team->hogs[i].hat); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
180 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
181 |
|
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
182 |
if(!error) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
183 |
// Message created, now we can copy everything. |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
184 |
flib_constbuffer constbuf = flib_vector_as_constbuffer(tempvector); |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
185 |
if(flib_vector_append(vec, constbuf.data, constbuf.size) == constbuf.size) { |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
186 |
result = 0; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
187 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
188 |
} |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
189 |
} |
7224
5143861c83bd
Cleanup, refactoring and generally more development in the frontlib
Medo <smaxein@googlemail.com>
parents:
7179
diff
changeset
|
190 |
flib_vector_destroy(tempvector); |
7179
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
191 |
return result; |
f84805e6df03
Implemented game launching API for the frontlib.
Medo <smaxein@googlemail.com>
parents:
7177
diff
changeset
|
192 |
} |
7230
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
193 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
194 |
static bool getGameMod(const flib_cfg *conf, int maskbit) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
195 |
for(int i=0; i<conf->meta->modCount; i++) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
196 |
if(conf->meta->mods[i].bitmaskIndex == maskbit) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
197 |
return conf->mods[i]; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
198 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
199 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
200 |
flib_log_e("Unable to find game mod with mask bit %i", maskbit); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
201 |
return false; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
202 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
203 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
204 |
int flib_ipc_append_fullconfig(flib_vector *vec, const flib_gamesetup *setup, bool netgame) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
205 |
int result = -1; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
206 |
flib_vector *tempvector = flib_vector_create(); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
207 |
if(!vec || !setup) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
208 |
flib_log_e("null parameter in flib_ipc_append_fullconfig"); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
209 |
} else if(tempvector) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
210 |
bool error = false; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
211 |
bool perHogAmmo = false; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
212 |
bool sharedAmmo = false; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
213 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
214 |
error |= flib_ipc_append_message(vec, netgame ? "TN" : "TL"); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
215 |
error |= flib_ipc_append_seed(vec, setup->seed); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
216 |
if(setup->map) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
217 |
error |= flib_ipc_append_mapconf(tempvector, setup->map, false); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
218 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
219 |
if(setup->script) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
220 |
error |= flib_ipc_append_message(tempvector, "escript %s", setup->script); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
221 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
222 |
if(setup->gamescheme) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
223 |
error |= flib_ipc_append_gamescheme(tempvector, setup->gamescheme); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
224 |
sharedAmmo = getGameMod(setup->gamescheme, GAMEMOD_SHAREDAMMO_MASKBIT); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
225 |
// Shared ammo has priority over per-hog ammo |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
226 |
perHogAmmo = !sharedAmmo && getGameMod(setup->gamescheme, GAMEMOD_PERHOGAMMO_MASKBIT); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
227 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
228 |
if(setup->teams && setup->teamcount>0) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
229 |
uint32_t *clanColors = flib_calloc(setup->teamcount, sizeof(uint32_t)); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
230 |
if(!clanColors) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
231 |
error = true; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
232 |
} else { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
233 |
int clanCount = 0; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
234 |
for(int i=0; i<setup->teamcount; i++) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
235 |
flib_team *team = setup->teams[i]; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
236 |
bool newClan = false; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
237 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
238 |
// Find the clan index of this team (clans are identified by color). |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
239 |
// The upper 8 bits (alpha) are ignored in the engine as well. |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
240 |
uint32_t color = team->color&UINT32_C(0x00ffffff); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
241 |
int clan = 0; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
242 |
while(clan<clanCount && clanColors[clan] != color) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
243 |
clan++; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
244 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
245 |
if(clan==clanCount) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
246 |
newClan = true; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
247 |
clanCount++; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
248 |
clanColors[clan] = color; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
249 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
250 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
251 |
// If shared ammo is active, only add an ammo store for the first team in each clan. |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
252 |
bool noAmmoStore = sharedAmmo&&!newClan; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
253 |
error |= flib_ipc_append_addteam(tempvector, setup->teams[i], perHogAmmo, noAmmoStore); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
254 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
255 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
256 |
free(clanColors); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
257 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
258 |
error |= flib_ipc_append_message(tempvector, "!"); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
259 |
|
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
260 |
if(!error) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
261 |
// Message created, now we can copy everything. |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
262 |
flib_constbuffer constbuf = flib_vector_as_constbuffer(tempvector); |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
263 |
if(flib_vector_append(vec, constbuf.data, constbuf.size) == constbuf.size) { |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
264 |
result = 0; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
265 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
266 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
267 |
} |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
268 |
return result; |
240620f46dd7
Changed frontlib to use the existing ini file formats of the QtFrontend
Medo <smaxein@googlemail.com>
parents:
7224
diff
changeset
|
269 |
} |