1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Crash fixed, but bug still present

This commit is contained in:
AlexVinS 2015-02-14 15:43:03 +03:00
parent a6c8dcbc36
commit 7086fdc730

View File

@ -295,7 +295,7 @@ void CArtPlace::select ()
} }
/** /**
* Deselects the artifact slot. FIXME: Not used. Maybe it should? * Deselects the artifact slot.
*/ */
void CArtPlace::deselect () void CArtPlace::deselect ()
{ {
@ -303,7 +303,12 @@ void CArtPlace::deselect ()
if(ourArt && ourArt->canBeDisassembled()) //combined art returned to its slot -> restore locks if(ourArt && ourArt->canBeDisassembled()) //combined art returned to its slot -> restore locks
{ {
for(int i = 0; i < GameConstants::BACKPACK_START; i++) for(int i = 0; i < GameConstants::BACKPACK_START; i++)
ourOwner->getArtPlace(i)->pickSlot(false); {
auto place = ourOwner->getArtPlace(i);
if(nullptr != place)
place->pickSlot(false);
}
} }
CCS->curh->dragAndDropCursor(nullptr); CCS->curh->dragAndDropCursor(nullptr);
@ -647,13 +652,13 @@ CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart
std::vector<Point> slotPos = std::vector<Point> slotPos =
{ {
Point(509,30), Point(567,240), Point(509,80), Point(509,30), Point(567,240), Point(509,80), //0-2
Point(383,68), Point(564,183), Point(509,130), Point(383,68), Point(564,183), Point(509,130), //3-5
Point(431,68), Point(610,183), Point(515,295), Point(431,68), Point(610,183), Point(515,295), //6-8
Point(383,143), Point(399,194), Point(415,245), Point(383,143), Point(399,194), Point(415,245), //9-11
Point(431,296), Point(564,30), Point(610,30), Point(431,296), Point(564,30), Point(610,30), //12-14
Point(610,76), Point(610,122), Point(610,310), Point(610,76), Point(610,122), Point(610,310), //15-17
Point(381,296) Point(381,296) //18
}; };
// Create slots for worn artifacts. // Create slots for worn artifacts.
@ -836,6 +841,12 @@ CArtPlace * CArtifactsOfHero::getArtPlace(int slot)
{ {
if(slot < GameConstants::BACKPACK_START) if(slot < GameConstants::BACKPACK_START)
{ {
if(slot >= artWorn.size() || slot < 0)
{
logGlobal->errorStream() << "CArtifactsOfHero::getArtPlace: invalid slot " << slot << "; maximum is " << artWorn.size()-1;
return nullptr;
}
return artWorn[slot]; return artWorn[slot];
} }
else else