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

Function ArrayThen

engine/Evaluator/express.cpp:971–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

969}
970
971static GameValue ArrayThen(const GameState* state, GameValuePar oper1, GameValuePar oper2)
972{
973 bool test = oper1;
974 const GameArrayType& array = oper2;
975
976 if (array.Size() != 2)
977 {
978 state->SetError(EvalDim, array.Size(), 2);
979 return NOTHING;
980 }
981 if (array[0].GetType() != GameString)
982 {
983 state->TypeError(GameScalar, array[0].GetType());
984 return NOTHING;
985 }
986 if (array[1].GetType() != GameString)
987 {
988 state->TypeError(GameScalar, array[1].GetType());
989 return NOTHING;
990 }
991
992 GameVarSpace local(state->GetContext());
993 state->BeginContext(&local);
994
995 RString expression = test ? array[0] : array[1];
996 GameValue ret = state->EvaluateMultiple(expression);
997 state->EndContext();
998 return ret;
999}
1000
1001[[maybe_unused]] static GameValue StringEval(const GameState* state, GameValuePar oper1)
1002{

Callers

nothing calls this directly

Calls 8

TypeErrorMethod · 0.80
BeginContextMethod · 0.80
EvaluateMultipleMethod · 0.80
EndContextMethod · 0.80
SizeMethod · 0.45
SetErrorMethod · 0.45
GetTypeMethod · 0.45
GetContextMethod · 0.45

Tested by

no test coverage detected