| 927 | } |
| 928 | |
| 929 | static GameValue ForDoOp(const GameState* state, GameValuePar oper1, GameValuePar oper2) |
| 930 | { |
| 931 | auto* toData = static_cast<const GameDataForTo*>(oper1.GetData()); |
| 932 | float from = toData->GetFrom(); |
| 933 | float to = toData->GetTo(); |
| 934 | float step = toData->GetStep(); |
| 935 | RString body = oper2; |
| 936 | |
| 937 | if (step == 0.0f) |
| 938 | { |
| 939 | state->SetError(EvalGen); |
| 940 | return NOTHING; |
| 941 | } |
| 942 | |
| 943 | GameValue exitVal = NOTHING; |
| 944 | int maxIters = 100000; |
| 945 | int count = 0; |
| 946 | for (float i = from; (step > 0 ? i <= to : i >= to); i += step) |
| 947 | { |
| 948 | if (count++ >= maxIters) |
| 949 | { |
| 950 | RptF("Max iteration count exceeded in for loop"); |
| 951 | state->SetError(EvalGen); |
| 952 | break; |
| 953 | } |
| 954 | GameVarSpace local(state->GetContext()); |
| 955 | state->BeginContext(&local); |
| 956 | state->VarSetLocal(toData->GetVar(), GameValue(i)); |
| 957 | const_cast<GameState*>(state)->Execute(body); |
| 958 | state->EndContext(); |
| 959 | if (state->GetLastError() == EvalBreak) |
| 960 | { |
| 961 | exitVal = tls_exitWithValue; |
| 962 | const_cast<GameState*>(state)->SetError(EvalOK); |
| 963 | break; |
| 964 | } |
| 965 | if (state->GetLastError() != EvalOK) |
| 966 | break; |
| 967 | } |
| 968 | return exitVal; |
| 969 | } |
| 970 | |
| 971 | static GameValue ArrayThen(const GameState* state, GameValuePar oper1, GameValuePar oper2) |
| 972 | { |
nothing calls this directly
no test coverage detected