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

Function ListCountCond

engine/Evaluator/express.cpp:1019–1043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1017}
1018
1019static GameValue ListCountCond(const GameState* state, GameValuePar oper1, GameValuePar oper2)
1020{
1021 GameVarSpace local(state->GetContext());
1022 int count = 0;
1023 state->BeginContext(&local);
1024 RString expression = oper1;
1025 const GameArrayType& array = oper2;
1026 for (int i = 0; i < array.Size(); i++)
1027 {
1028 const GameValue& val = array[i];
1029 // set local varible - will be deleted on EndContext
1030 state->VarSetLocal("_x", val, true);
1031 if (state->EvaluateBool(expression))
1032 {
1033 count++;
1034 }
1035 if (state->GetLastError())
1036 {
1037 state->EndContext();
1038 return GameValue();
1039 }
1040 }
1041 state->EndContext();
1042 return (float)count;
1043}
1044
1045static GameValue ListForEach(const GameState* state, GameValuePar oper1, GameValuePar oper2)
1046{

Callers

nothing calls this directly

Calls 8

BeginContextMethod · 0.80
VarSetLocalMethod · 0.80
EvaluateBoolMethod · 0.80
GetLastErrorMethod · 0.80
EndContextMethod · 0.80
GameValueClass · 0.70
GetContextMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected