| 2181 | } |
| 2182 | |
| 2183 | void ProcessScript(int scriptCodeStart, int jumpTableStart, byte scriptSub) |
| 2184 | { |
| 2185 | bool running = true; |
| 2186 | int scriptCodePtr = scriptCodeStart; |
| 2187 | |
| 2188 | jumpTableStackPos = 0; |
| 2189 | functionStackPos = 0; |
| 2190 | while (running) { |
| 2191 | int opcode = scriptCode[scriptCodePtr++]; |
| 2192 | int opcodeSize = functions[opcode].opcodeSize; |
| 2193 | int scriptCodeOffset = scriptCodePtr; |
| 2194 | |
| 2195 | // Get Values |
| 2196 | for (int i = 0; i < opcodeSize; ++i) { |
| 2197 | int opcodeType = scriptCode[scriptCodePtr++]; |
| 2198 | |
| 2199 | if (opcodeType == SCRIPTVAR_VAR) { |
| 2200 | int arrayVal = 0; |
| 2201 | switch (scriptCode[scriptCodePtr++]) { |
| 2202 | case VARARR_NONE: arrayVal = objectLoop; break; |
| 2203 | case VARARR_ARRAY: |
| 2204 | if (scriptCode[scriptCodePtr++] == 1) |
| 2205 | arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]]; |
| 2206 | else |
| 2207 | arrayVal = scriptCode[scriptCodePtr++]; |
| 2208 | break; |
| 2209 | case VARARR_ENTNOPLUS1: |
| 2210 | if (scriptCode[scriptCodePtr++] == 1) |
| 2211 | arrayVal = scriptEng.arrayPosition[scriptCode[scriptCodePtr++]] + objectLoop; |
| 2212 | else |
| 2213 | arrayVal = scriptCode[scriptCodePtr++] + objectLoop; |
| 2214 | break; |
| 2215 | case VARARR_ENTNOMINUS1: |
| 2216 | if (scriptCode[scriptCodePtr++] == 1) |
| 2217 | arrayVal = objectLoop - scriptEng.arrayPosition[scriptCode[scriptCodePtr++]]; |
| 2218 | else |
| 2219 | arrayVal = objectLoop - scriptCode[scriptCodePtr++]; |
| 2220 | break; |
| 2221 | default: break; |
| 2222 | } |
| 2223 | |
| 2224 | // Variables |
| 2225 | switch (scriptCode[scriptCodePtr++]) { |
| 2226 | default: break; |
| 2227 | case VAR_TEMPVALUE0: scriptEng.operands[i] = scriptEng.tempValue[0]; break; |
| 2228 | case VAR_TEMPVALUE1: scriptEng.operands[i] = scriptEng.tempValue[1]; break; |
| 2229 | case VAR_TEMPVALUE2: scriptEng.operands[i] = scriptEng.tempValue[2]; break; |
| 2230 | case VAR_TEMPVALUE3: scriptEng.operands[i] = scriptEng.tempValue[3]; break; |
| 2231 | case VAR_TEMPVALUE4: scriptEng.operands[i] = scriptEng.tempValue[4]; break; |
| 2232 | case VAR_TEMPVALUE5: scriptEng.operands[i] = scriptEng.tempValue[5]; break; |
| 2233 | case VAR_TEMPVALUE6: scriptEng.operands[i] = scriptEng.tempValue[6]; break; |
| 2234 | case VAR_TEMPVALUE7: scriptEng.operands[i] = scriptEng.tempValue[7]; break; |
| 2235 | case VAR_CHECKRESULT: scriptEng.operands[i] = scriptEng.checkResult; break; |
| 2236 | case VAR_ARRAYPOS0: scriptEng.operands[i] = scriptEng.arrayPosition[0]; break; |
| 2237 | case VAR_ARRAYPOS1: scriptEng.operands[i] = scriptEng.arrayPosition[1]; break; |
| 2238 | case VAR_GLOBAL: scriptEng.operands[i] = globalVariables[arrayVal]; break; |
| 2239 | case VAR_OBJECTENTITYNO: scriptEng.operands[i] = arrayVal; break; |
| 2240 | case VAR_OBJECTTYPE: { |
no test coverage detected