MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Scenario_Load_Structure

Function Scenario_Load_Structure

src/scenario.c:204–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204static void Scenario_Load_Structure(const char *key, char *settings)
205{
206 uint8 index, houseType, structureType;
207 uint16 hitpoints, position;
208 char *split;
209
210 /* 'GEN' marked keys are Slabs and Walls, where the number following indicates the position on the map */
211 if (strncasecmp(key, "GEN", 3) == 0) {
212 /* Position on the map is in the key */
213 position = atoi(key + 3);
214
215 /* The value should have two values separated by a ',' */
216 split = strchr(settings, ',');
217 if (split == NULL) return;
218 *split = '\0';
219 /* First value is the House type */
220 houseType = House_StringToType(settings);
221 if (houseType == HOUSE_INVALID) return;
222
223 /* Second value is the Structure type */
224 settings = split + 1;
225 structureType = Structure_StringToType(settings);
226 if (structureType == STRUCTURE_INVALID) return;
227
228 Structure_Create(STRUCTURE_INDEX_INVALID, structureType, houseType, position);
229 return;
230 }
231
232 /* The key should start with 'ID', followed by the index */
233 index = atoi(key + 2);
234
235 /* The value should have four values separated by a ',' */
236 split = strchr(settings, ',');
237 if (split == NULL) return;
238 *split = '\0';
239
240 /* First value is the House type */
241 houseType = House_StringToType(settings);
242 if (houseType == HOUSE_INVALID) return;
243
244 /* Find the next value in the ',' separated list */
245 settings = split + 1;
246 split = strchr(settings, ',');
247 if (split == NULL) return;
248 *split = '\0';
249
250 /* Second value is the Structure type */
251 structureType = Structure_StringToType(settings);
252 if (structureType == STRUCTURE_INVALID) return;
253
254 /* Find the next value in the ',' separated list */
255 settings = split + 1;
256 split = strchr(settings, ',');
257 if (split == NULL) return;
258 *split = '\0';
259
260 /* Third value is the Hitpoints in percent (in base 256) */
261 hitpoints = atoi(settings);

Callers

nothing calls this directly

Calls 4

House_StringToTypeFunction · 0.85
Structure_StringToTypeFunction · 0.85
Structure_CreateFunction · 0.85

Tested by

no test coverage detected