- Fixed bug in script code of LoL

- Cleanup

svn-id: r35905
This commit is contained in:
Johannes Schickel 2009-01-18 17:24:47 +00:00
parent ec5b64147d
commit c003d62429
2 changed files with 13 additions and 8 deletions

View file

@ -152,9 +152,9 @@ void EMCInterpreter::unload(EMCData *data) {
void EMCInterpreter::init(EMCState *scriptStat, const EMCData *data) {
scriptStat->dataPtr = data;
scriptStat->ip = 0;
scriptStat->stack[60] = 0;
scriptStat->bp = 62;
scriptStat->sp = 60;
scriptStat->stack[EMCState::kStackLastEntry] = 0;
scriptStat->bp = EMCState::kStackSize+1;
scriptStat->sp = EMCState::kStackLastEntry;
}
bool EMCInterpreter::start(EMCState *script, int function) {
@ -346,7 +346,7 @@ void EMCInterpreter::cmd_popRetOrPos(EMCState* script) {
break;
case 1:
if (script->sp >= 60) {
if (script->sp >= EMCState::kStackLastEntry) {
script->ip = 0;
} else {
script->bp = script->stack[script->sp++];
@ -519,12 +519,12 @@ void EMCInterpreter::cmd_eval(EMCState* script) {
}
void EMCInterpreter::cmd_setRetAndJmp(EMCState* script) {
if (script->sp >= 60) {
if (script->sp >= EMCState::kStackLastEntry) {
script->ip = 0;
} else {
script->retValue = script->stack[script->sp++];
uint16 temp = script->stack[script->sp++];
script->stack[60] = 0;
script->stack[EMCState::kStackLastEntry] = 0;
script->ip = &script->dataPtr->data[temp];
}
}

View file

@ -47,13 +47,18 @@ struct EMCData {
};
struct EMCState {
enum {
kStackSize = 100,
kStackLastEntry = kStackSize - 1
};
const uint16 *ip;
const EMCData *dataPtr;
int16 retValue;
uint16 bp;
uint16 sp;
int16 regs[30]; // VM registers
int16 stack[100]; // VM stack
int16 stack[kStackSize]; // VM stack
};
#define stackPos(x) (script->stack[script->sp+x])