MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / UnitCreate

Function UnitCreate

engine/Poseidon/Game/Commands/GameStateExtWorld.cpp:237–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237GameValue UnitCreate(const GameState* state, GameValuePar oper1, GameValuePar oper2)
238{
239 GameStringType type = oper1;
240 const GameArrayType& array = oper2;
241
242 Vector3 pos;
243 AIGroup* grp;
244 float skill = 0.5;
245 Rank rank = RankPrivate;
246 RString init;
247 switch (array.Size())
248 {
249 case 5:
250 {
251 if (array[4].GetType() != GameString)
252 {
253 state->TypeError(GameString, array[4].GetType());
254 return NOTHING;
255 }
256 GameStringType rankName = array[4];
257 rank = GetEnumValue<Rank>((const char*)rankName);
258 if (rank == INT_MIN)
259 {
260 rank = RankPrivate;
261 }
262 }
263 case 4:
264 {
265 if (array[3].GetType() != GameScalar)
266 {
267 state->TypeError(GameScalar, array[3].GetType());
268 return NOTHING;
269 }
270 skill = array[3];
271 }
272 case 3:
273 {
274 if (array[2].GetType() != GameString)
275 {
276 state->TypeError(GameString, array[2].GetType());
277 return NOTHING;
278 }
279 init = array[2];
280 }
281 case 2:
282 {
283 if (!GetRelPos(state, pos, array[0]))
284 {
285 // state->SetError(EvalGen);
286 return NOTHING;
287 }
288 grp = GetGroup(array[1]);
289 if (!grp)
290 {
291 return NOTHING;
292 }
293 }
294 break;

Callers

nothing calls this directly

Calls 9

GetRelPosFunction · 0.85
GetGroupFunction · 0.85
CreateUnitFunction · 0.85
TypeErrorMethod · 0.80
SizeMethod · 0.45
GetTypeMethod · 0.45
SetErrorMethod · 0.45
IsLocalMethod · 0.45
AskForCreateUnitMethod · 0.45

Tested by

no test coverage detected