[Scummvm-cvs-logs] SF.net SVN: scummvm:[53740] scummvm/trunk/engines/kyra
athrxx at users.sourceforge.net
athrxx at users.sourceforge.net
Sat Oct 23 18:01:40 CEST 2010
Revision: 53740
http://scummvm.svn.sourceforge.net/scummvm/?rev=53740&view=rev
Author: athrxx
Date: 2010-10-23 16:01:40 +0000 (Sat, 23 Oct 2010)
Log Message:
-----------
LOL: - fix invalid mem access
- also extend LordHoto's recent item code changes to LOL
Modified Paths:
--------------
scummvm/trunk/engines/kyra/items_lol.cpp
scummvm/trunk/engines/kyra/lol.cpp
scummvm/trunk/engines/kyra/lol.h
scummvm/trunk/engines/kyra/saveload_lol.cpp
scummvm/trunk/engines/kyra/screen.h
scummvm/trunk/engines/kyra/screen_hof.h
scummvm/trunk/engines/kyra/screen_lok.h
scummvm/trunk/engines/kyra/screen_lol.h
scummvm/trunk/engines/kyra/screen_mr.h
scummvm/trunk/engines/kyra/script_lol.cpp
scummvm/trunk/engines/kyra/sprites_lol.cpp
scummvm/trunk/engines/kyra/text_lol.cpp
scummvm/trunk/engines/kyra/text_lol.h
Modified: scummvm/trunk/engines/kyra/items_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_lol.cpp 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/items_lol.cpp 2010-10-23 16:01:40 UTC (rev 53740)
@@ -110,10 +110,10 @@
}
}
-int LoLEngine::makeItem(int itemType, int curFrame, int flags) {
+Item LoLEngine::makeItem(int itemType, int curFrame, int flags) {
int cnt = 0;
int r = 0;
- int i = 1;
+ Item i = 1;
for (; i < 400; i++) {
if (_itemsInPlay[i].shpCurFrame_flg & 0x8000) {
@@ -130,7 +130,7 @@
continue;
bool t = false;
- int ii = i;
+ Item ii = i;
while (ii && !t) {
t = testUnkItemFlags(ii);
if (t)
@@ -145,7 +145,7 @@
}
}
- int slot = i;
+ Item slot = i;
if (cnt) {
slot = r;
if (testUnkItemFlags(r)) {
@@ -178,7 +178,7 @@
return slot;
}
-void LoLEngine::placeMoveLevelItem(int itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight) {
+void LoLEngine::placeMoveLevelItem(Item itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight) {
calcCoordinates(_itemsInPlay[itemIndex].x, _itemsInPlay[itemIndex].y, block, xOffs, yOffs);
if (_itemsInPlay[itemIndex].block)
@@ -194,7 +194,7 @@
}
}
-bool LoLEngine::addItemToInventory(int itemIndex) {
+bool LoLEngine::addItemToInventory(Item itemIndex) {
int pos = 0;
int i = 0;
@@ -222,7 +222,7 @@
return true;
}
-bool LoLEngine::testUnkItemFlags(int itemIndex) {
+bool LoLEngine::testUnkItemFlags(Item itemIndex) {
if (!(_itemsInPlay[itemIndex].shpCurFrame_flg & 0x4000))
return false;
@@ -233,7 +233,7 @@
}
-void LoLEngine::deleteItem(int itemIndex) {
+void LoLEngine::deleteItem(Item itemIndex) {
memset(&_itemsInPlay[itemIndex], 0, sizeof(ItemInPlay));
_itemsInPlay[itemIndex].shpCurFrame_flg |= 0x8000;
}
@@ -245,7 +245,7 @@
return &_itemsInPlay[index];
}
-void LoLEngine::runItemScript(int charNum, int item, int flags, int next, int reg4) {
+void LoLEngine::runItemScript(int charNum, Item item, int flags, int next, int reg4) {
EMCState scriptState;
memset(&scriptState, 0, sizeof(EMCState));
@@ -271,9 +271,6 @@
}
void LoLEngine::setHandItem(Item itemIndex) {
- if (itemIndex == -1)
- return;
-
if (itemIndex && _itemProperties[_itemsInPlay[itemIndex].itemPropertyIndex].flags & 0x80) {
runItemScript(-1, itemIndex, 0x400, 0, 0);
if (_itemsInPlay[itemIndex].shpCurFrame_flg & 0x8000)
@@ -310,7 +307,7 @@
return false;
}
-void LoLEngine::setItemPosition(int item, uint16 x, uint16 y, int flyingHeight, int b) {
+void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int b) {
if (!flyingHeight) {
x = (x & 0xffc0) | 0x40;
y = (y & 0xffc0) | 0x40;
@@ -337,7 +334,7 @@
checkSceneUpdateNeed(block);
}
-void LoLEngine::removeLevelItem(int item, int block) {
+void LoLEngine::removeLevelItem(Item item, int block) {
removeAssignedObjectFromBlock(&_levelBlockProperties[block], item);
removeDrawObjectFromBlock(&_levelBlockProperties[block], item);
runLevelScriptCustom(block, 0x100, -1, item, 0, 0);
@@ -345,7 +342,7 @@
_itemsInPlay[item].level = 0;
}
-bool LoLEngine::launchObject(int objectType, int item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c) {
+bool LoLEngine::launchObject(int objectType, Item item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c) {
int sp = checkDrawObjectSpace(_partyPosX, _partyPosY, startX, startY);
FlyingObject *t = _flyingObjects;
int slot = -1;
Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/lol.cpp 2010-10-23 16:01:40 UTC (rev 53740)
@@ -1930,11 +1930,11 @@
return 1;
}
-void LoLEngine::giveItemToMonster(MonsterInPlay *monster, uint16 item) {
+void LoLEngine::giveItemToMonster(MonsterInPlay *monster, Item item) {
uint16 *c = &monster->assignedItems;
while (*c)
c = &_itemsInPlay[*c].nextAssignedObject;
- *c = item;
+ *c = (uint16)item;
_itemsInPlay[item].nextAssignedObject = 0;
}
Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/lol.h 2010-10-23 16:01:40 UTC (rev 53740)
@@ -225,7 +225,7 @@
uint8 enable;
uint8 objectType;
uint16 attackerId;
- uint16 item;
+ Item item;
uint16 x;
uint16 y;
uint8 flyingHeight;
@@ -1202,19 +1202,19 @@
// items
void giveCredits(int credits, int redraw);
void takeCredits(int credits, int redraw);
- int makeItem(int itemType, int curFrame, int flags);
- void placeMoveLevelItem(int itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight);
- bool addItemToInventory(int itemIndex);
- bool testUnkItemFlags(int itemIndex);
- void deleteItem(int itemIndex);
+ Item makeItem(int itemType, int curFrame, int flags);
+ void placeMoveLevelItem(Item itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight);
+ bool addItemToInventory(Item itemIndex);
+ bool testUnkItemFlags(Item itemIndex);
+ void deleteItem(Item itemIndex);
ItemInPlay *findObject(uint16 index);
- void runItemScript(int charNum, int item, int flags, int next, int reg4);
+ void runItemScript(int charNum, Item item, int flags, int next, int reg4);
void setHandItem(Item itemIndex);
bool itemEquipped(int charNum, uint16 itemType);
- void setItemPosition(int item, uint16 x, uint16 y, int flyingHeight, int b);
- void removeLevelItem(int item, int block);
- bool launchObject(int objectType, int item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c);
+ void setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int b);
+ void removeLevelItem(Item item, int block);
+ bool launchObject(int objectType, Item item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c);
void endObjectFlight(FlyingObject *t, int x, int y, int objectOnNextBlock);
void processObjectFlight(FlyingObject *t, int x, int y);
void updateObjectFlightPosition(FlyingObject *t);
@@ -1231,9 +1231,9 @@
ItemInPlay *_itemsInPlay;
ItemProperty *_itemProperties;
- int _itemInHand;
- uint16 _inventory[48];
- int _inventoryCurItem;
+ Item _itemInHand;
+ Item _inventory[48];
+ Item _inventoryCurItem;
int _currentControlMode;
int _specialSceneFlag;
int _lastCharInventory;
@@ -1269,10 +1269,10 @@
int calcMonsterDirection(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void setMonsterDirection(MonsterInPlay *monster, int dir);
void monsterDropItems(MonsterInPlay *monster);
- void removeAssignedObjectFromBlock(LevelBlockProperty *l, int id);
- void removeDrawObjectFromBlock(LevelBlockProperty *l, int id);
- void assignMonsterToBlock(uint16 *assignedBlockObjects, int id);
- void giveItemToMonster(MonsterInPlay *monster, uint16 item);
+ void removeAssignedObjectFromBlock(LevelBlockProperty *l, uint16 id);
+ void removeDrawObjectFromBlock(LevelBlockProperty *l, uint16 id);
+ void assignMonsterToBlock(uint16 *assignedBlockObjects, uint16 id);
+ void giveItemToMonster(MonsterInPlay *monster, Item item);
int checkBlockBeforeObjectPlacement(uint16 x, uint16 y, uint16 objectWidth, uint16 testFlag, uint16 wallFlag);
int checkBlockForWallsAndSufficientSpace(int block, int x, int y, int objectWidth, int testFlag, int wallFlag);
int calcMonsterSkillLevel(int id, int a);
Modified: scummvm/trunk/engines/kyra/saveload_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload_lol.cpp 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/saveload_lol.cpp 2010-10-23 16:01:40 UTC (rev 53740)
@@ -117,7 +117,7 @@
_selectedCharacter = in.readSByte();
_currentLevel = in.readByte();
for (int i = 0; i < 48; i++)
- _inventory[i] = in.readUint16BE();
+ _inventory[i] = in.readSint16BE();
_inventoryCurItem = in.readSint16BE();
_itemInHand = in.readSint16BE();
_lastMouseRegion = in.readSint16BE();
@@ -243,7 +243,7 @@
m->enable = in.readByte();
m->objectType = in.readByte();
m->attackerId = in.readUint16BE();
- m->item = in.readUint16BE();
+ m->item = in.readSint16BE();
m->x = in.readUint16BE();
m->y = in.readUint16BE();
m->flyingHeight = in.readByte();
@@ -340,7 +340,7 @@
out->writeSByte(_selectedCharacter);
out->writeByte(_currentLevel);
for (int i = 0; i < 48; i++)
- out->writeUint16BE(_inventory[i]);
+ out->writeSint16BE(_inventory[i]);
out->writeSint16BE(_inventoryCurItem);
out->writeSint16BE(_itemInHand);
out->writeSint16BE(_lastMouseRegion);
@@ -423,7 +423,7 @@
out->writeByte(m->enable);
out->writeByte(m->objectType);
out->writeUint16BE(m->attackerId);
- out->writeUint16BE(m->item);
+ out->writeSint16BE(m->item);
out->writeUint16BE(m->x);
out->writeUint16BE(m->y);
out->writeByte(m->flyingHeight);
Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/screen.h 2010-10-23 16:01:40 UTC (rev 53740)
@@ -423,6 +423,7 @@
virtual void setScreenDim(int dim) = 0;
virtual const ScreenDim *getScreenDim(int dim) = 0;
+ virtual int screenDimTableCount() const = 0;
const ScreenDim *_curDim;
Modified: scummvm/trunk/engines/kyra/screen_hof.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_hof.h 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/screen_hof.h 2010-10-23 16:01:40 UTC (rev 53740)
@@ -39,6 +39,7 @@
void setScreenDim(int dim);
const ScreenDim *getScreenDim(int dim);
+ int screenDimTableCount() const { return _screenDimTableCount; }
// sequence player
void generateGrayOverlay(const Palette &pal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool flag);
Modified: scummvm/trunk/engines/kyra/screen_lok.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_lok.h 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/screen_lok.h 2010-10-23 16:01:40 UTC (rev 53740)
@@ -43,6 +43,7 @@
void setScreenDim(int dim);
const ScreenDim *getScreenDim(int dim);
+ int screenDimTableCount() const { return _screenDimTableCount; }
void setTextColorMap(const uint8 *cmap);
Modified: scummvm/trunk/engines/kyra/screen_lol.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_lol.h 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/screen_lol.h 2010-10-23 16:01:40 UTC (rev 53740)
@@ -43,8 +43,9 @@
void setScreenDim(int dim);
const ScreenDim *getScreenDim(int dim);
- int curDimIndex() { return _curDimIndex; }
+ int curDimIndex() const { return _curDimIndex; }
void modifyScreenDim(int dim, int x, int y, int w, int h);
+ int screenDimTableCount() const { return _screenDimTableCount; }
void fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) GCC_PRINTF(2, 8);
void fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...) GCC_PRINTF(2, 9);
Modified: scummvm/trunk/engines/kyra/screen_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_mr.h 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/screen_mr.h 2010-10-23 16:01:40 UTC (rev 53740)
@@ -39,6 +39,7 @@
void setScreenDim(int dim);
const ScreenDim *getScreenDim(int dim);
+ int screenDimTableCount() const { return _screenDimTableCount; }
int getLayer(int x, int y);
Modified: scummvm/trunk/engines/kyra/script_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_lol.cpp 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/script_lol.cpp 2010-10-23 16:01:40 UTC (rev 53740)
@@ -700,7 +700,7 @@
break;
case 3:
- setHandItem((Item)b);
+ setHandItem(b);
break;
case 4:
@@ -1066,8 +1066,7 @@
if (_itemInHand)
return 0;
- uint16 itm = makeItem(stackPos(0), stackPos(1), stackPos(2));
- setHandItem((Item)itm);
+ setHandItem(makeItem(stackPos(0), stackPos(1), stackPos(2)));
return 1;
}
@@ -2087,7 +2086,7 @@
_inventoryCurItem = i;
int r = _itemInHand;
- setHandItem((Item)_inventory[i]);
+ setHandItem(_inventory[i]);
_inventory[i] = r;
if (stackPos(1))
Modified: scummvm/trunk/engines/kyra/sprites_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sprites_lol.cpp 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/sprites_lol.cpp 2010-10-23 16:01:40 UTC (rev 53740)
@@ -350,7 +350,7 @@
}
}
-void LoLEngine::removeAssignedObjectFromBlock(LevelBlockProperty *l, int id) {
+void LoLEngine::removeAssignedObjectFromBlock(LevelBlockProperty *l, uint16 id) {
uint16 *blockItemIndex = &l->assignedObjects;
ItemInPlay *i = 0;
@@ -367,7 +367,7 @@
}
}
-void LoLEngine::removeDrawObjectFromBlock(LevelBlockProperty *l, int id) {
+void LoLEngine::removeDrawObjectFromBlock(LevelBlockProperty *l, uint16 id) {
uint16 *blockItemIndex = &l->drawObjects;
ItemInPlay *i = 0;
@@ -384,7 +384,7 @@
}
}
-void LoLEngine::assignMonsterToBlock(uint16 *assignedBlockObjects, int id) {
+void LoLEngine::assignMonsterToBlock(uint16 *assignedBlockObjects, uint16 id) {
ItemInPlay *t = findObject(id);
t->nextAssignedObject = *assignedBlockObjects;
*assignedBlockObjects = id;
Modified: scummvm/trunk/engines/kyra/text_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_lol.cpp 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/text_lol.cpp 2010-10-23 16:01:40 UTC (rev 53740)
@@ -46,7 +46,9 @@
_currentLine = new char[85];
memset(_currentLine, 0, 85);
- for (int i = 0; i < 14; i++){
+ _textDimData = new TextDimData[_screen->screenDimTableCount()];
+
+ for (int i = 0; i < _screen->screenDimTableCount(); i++){
const ScreenDim *d = _screen->getScreenDim(i);
_textDimData[i].color1 = d->unk8;
_textDimData[i].color2 = d->unkA;
@@ -59,6 +61,7 @@
delete[] _buffer;
delete[] _dialogueBuffer;
delete[] _currentLine;
+ delete[] _textDimData;
}
void TextDisplayer_LoL::setupField(bool mode) {
Modified: scummvm/trunk/engines/kyra/text_lol.h
===================================================================
--- scummvm/trunk/engines/kyra/text_lol.h 2010-10-23 15:47:23 UTC (rev 53739)
+++ scummvm/trunk/engines/kyra/text_lol.h 2010-10-23 16:01:40 UTC (rev 53740)
@@ -90,7 +90,7 @@
uint8 line;
};
- TextDimData _textDimData[14];
+ TextDimData *_textDimData;
};
} // End of namespace Kyra
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list