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

Function Scenario_Load_Unit

src/scenario.c:113–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static void Scenario_Load_Unit(const char *key, char *settings)
114{
115 uint8 houseType, unitType, actionType;
116 int8 orientation;
117 uint16 hitpoints;
118 tile32 position;
119 Unit *u;
120 char *split;
121
122 VARIABLE_NOT_USED(key);
123
124 /* The value should have 6 values separated by a ',' */
125 split = strchr(settings, ',');
126 if (split == NULL) return;
127 *split = '\0';
128
129 /* First value is the House type */
130 houseType = House_StringToType(settings);
131 if (houseType == HOUSE_INVALID) return;
132
133 /* Find the next value in the ',' separated list */
134 settings = split + 1;
135 split = strchr(settings, ',');
136 if (split == NULL) return;
137 *split = '\0';
138
139 /* Second value is the Unit type */
140 unitType = Unit_StringToType(settings);
141 if (unitType == UNIT_INVALID) return;
142
143 /* Find the next value in the ',' separated list */
144 settings = split + 1;
145 split = strchr(settings, ',');
146 if (split == NULL) return;
147 *split = '\0';
148
149 /* Third value is the Hitpoints in percent (in base 256) */
150 hitpoints = atoi(settings);
151
152 /* Find the next value in the ',' separated list */
153 settings = split + 1;
154 split = strchr(settings, ',');
155 if (split == NULL) return;
156 *split = '\0';
157
158 /* Fourth value is the position on the map */
159 position = Tile_UnpackTile(atoi(settings));
160
161 /* Find the next value in the ',' separated list */
162 settings = split + 1;
163 split = strchr(settings, ',');
164 if (split == NULL) return;
165 *split = '\0';
166
167 /* Fifth value is orientation */
168 orientation = (int8)((uint8)atoi(settings));
169
170 /* Sixth value is the current state of the unit */

Callers

nothing calls this directly

Calls 11

House_StringToTypeFunction · 0.85
Unit_StringToTypeFunction · 0.85
Tile_UnpackTileFunction · 0.85
Unit_ActionStringToTypeFunction · 0.85
Unit_AllocateFunction · 0.85
Map_IsValidPositionFunction · 0.85
Unit_FreeFunction · 0.85
Unit_SetActionFunction · 0.85
Unit_HouseUnitCount_AddFunction · 0.85
Unit_SetOrientationFunction · 0.85
Unit_SetSpeedFunction · 0.85

Tested by

no test coverage detected