diff options
author | Florian Kagerer | 2009-10-18 12:47:54 +0000 |
---|---|---|
committer | Florian Kagerer | 2009-10-18 12:47:54 +0000 |
commit | 8b993ce86381352e022641896fd28f3472f083bf (patch) | |
tree | 9fb883eefc29ae356cd22403cb6a47167139ddb2 | |
parent | 0fd3a2f842bfee04b9423ee683445d98189369c6 (diff) | |
download | scummvm-rg350-8b993ce86381352e022641896fd28f3472f083bf.tar.gz scummvm-rg350-8b993ce86381352e022641896fd28f3472f083bf.tar.bz2 scummvm-rg350-8b993ce86381352e022641896fd28f3472f083bf.zip |
LOL: this should fix a valgrind warning
svn-id: r45221
-rw-r--r-- | engines/kyra/items_lol.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/lol.h | 6 | ||||
-rw-r--r-- | engines/kyra/script_lol.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/sprites_lol.cpp | 16 |
4 files changed, 20 insertions, 18 deletions
diff --git a/engines/kyra/items_lol.cpp b/engines/kyra/items_lol.cpp index d65fe5e28e..5b566d51db 100644 --- a/engines/kyra/items_lol.cpp +++ b/engines/kyra/items_lol.cpp @@ -245,7 +245,7 @@ ItemInPlay *LoLEngine::findObject(uint16 index) { return &_itemsInPlay[index]; } -void LoLEngine::runItemScript(int charNum, int item, int sub, int next, int reg4) { +void LoLEngine::runItemScript(int charNum, int item, int flags, int next, int reg4) { EMCState scriptState; memset(&scriptState, 0, sizeof(EMCState)); @@ -256,14 +256,14 @@ void LoLEngine::runItemScript(int charNum, int item, int sub, int next, int reg4 _emc->init(&scriptState, &_itemScript); _emc->start(&scriptState, func); - scriptState.regs[0] = sub; + scriptState.regs[0] = flags; scriptState.regs[1] = charNum; scriptState.regs[2] = item; scriptState.regs[3] = next; scriptState.regs[4] = reg4; if (_emc->isValid(&scriptState)) { - if (*(scriptState.ip - 1) & sub) { + if (*(scriptState.ip - 1) & flags) { while (_emc->isValid(&scriptState)) _emc->run(&scriptState); } diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index bbf6b71fda..9e4258f657 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -633,8 +633,8 @@ private: // emc scripts void runInitScript(const char *filename, int optionalFunc); void runInfScript(const char *filename); - void runLevelScript(int block, int sub); - void runLevelScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4); + void runLevelScript(int block, int flags); + void runLevelScriptCustom(int block, int flags, int charNum, int item, int reg3, int reg4); bool checkSceneUpdateNeed(int func); EMCData _scriptData; @@ -1204,7 +1204,7 @@ private: bool testUnkItemFlags(int itemIndex); void deleteItem(int itemIndex); ItemInPlay *findObject(uint16 index); - void runItemScript(int charNum, int item, int sub, int next, int reg4); + void runItemScript(int charNum, int item, int flags, int next, int reg4); void setHandItem(uint16 itemIndex); bool itemEquipped(int charNum, uint16 itemType); diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp index 7f1bd16f22..56ab913a4a 100644 --- a/engines/kyra/script_lol.cpp +++ b/engines/kyra/script_lol.cpp @@ -64,11 +64,11 @@ void LoLEngine::runInfScript(const char *filename) { runLevelScript(0x400, -1); } -void LoLEngine::runLevelScript(int block, int sub) { - runLevelScriptCustom(block, sub, -1, 0, 0, 0); +void LoLEngine::runLevelScript(int block, int flags) { + runLevelScriptCustom(block, flags, -1, 0, 0, 0); } -void LoLEngine::runLevelScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4) { +void LoLEngine::runLevelScriptCustom(int block, int flags, int charNum, int item, int reg3, int reg4) { EMCState scriptState; memset(&scriptState, 0, sizeof(EMCState)); @@ -76,7 +76,7 @@ void LoLEngine::runLevelScriptCustom(int block, int sub, int charNum, int item, _emc->init(&scriptState, &_scriptData); _emc->start(&scriptState, block); - scriptState.regs[0] = sub; + scriptState.regs[0] = flags; scriptState.regs[1] = charNum; scriptState.regs[2] = item; scriptState.regs[3] = reg3; @@ -85,7 +85,7 @@ void LoLEngine::runLevelScriptCustom(int block, int sub, int charNum, int item, scriptState.regs[6] = _scriptDirection; if (_emc->isValid(&scriptState)) { - if (*(scriptState.ip - 1) & sub) { + if (*(scriptState.ip - 1) & flags) { while (_emc->isValid(&scriptState)) _emc->run(&scriptState); } diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp index 4fb7622a71..3279560650 100644 --- a/engines/kyra/sprites_lol.cpp +++ b/engines/kyra/sprites_lol.cpp @@ -71,16 +71,15 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy } _monsterAnimType[monsterIndex] = animType & 0xff; - uint8 *tsh = _screen->makeShapeCopy(p, 16); + uint8 *palShape = _screen->makeShapeCopy(p, 16); _screen->clearPage(3); - _screen->drawShape(2, tsh, 0, 0, 0, 0); + _screen->drawShape(2, palShape, 0, 0, 0, 0); uint8 *tmpPal1 = new uint8[64]; uint8 *tmpPal2 = new uint8[256]; uint16 *tmpPal3 = new uint16[256]; memset(tmpPal1, 0, 64); - memset(tmpPal2, 0, 256); for (int i = 0; i < 64; i++) { tmpPal1[i] = *p; @@ -91,8 +90,10 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy for (int i = 0; i < 16; i++) { int pos = (monsterIndex << 4) + i; - memcpy(tmpPal2, _monsterShapes[pos] + 10, 256); - memset(tmpPal3, 0xff, 512); + uint16 sz = MIN(_screen->getShapeSize(_monsterShapes[pos]) - 10, 256); + memset(tmpPal2, 0, 256); + memcpy(tmpPal2, _monsterShapes[pos] + 10, sz); + memset(tmpPal3, 0xff, 256 * sizeof(uint16)); uint8 numCol = *tmpPal2; for (int ii = 0; ii < numCol; ii++) { @@ -103,7 +104,8 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy } for (int ii = 0; ii < 8; ii++) { - memcpy(tmpPal2, _monsterShapes[pos] + 10, 256); + memset(tmpPal2, 0, 256); + memcpy(tmpPal2, _monsterShapes[pos] + 10, sz); for (int iii = 0; iii < numCol; iii++) { if (tmpPal3[iii] == 0xffff) continue; @@ -117,7 +119,7 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy delete[] tmpPal1; delete[] tmpPal2; delete[] tmpPal3; - delete[] tsh; + delete[] palShape; } void LoLEngine::releaseMonsterShapes(int monsterIndex) { |