TITANIC: Fix crash inserting photograph into star control

This commit is contained in:
Paul Gilbert 2017-05-28 14:56:44 -04:00
parent d6645f3fc9
commit 0be151d507
3 changed files with 8 additions and 6 deletions

View File

@ -98,7 +98,7 @@ bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CSt
if (count > 0) {
allocate(count);
CStarRef2 starRef(starField, &_positions);
CStarRefArray starRef(starField, &_positions);
starRef.process(surfaceArea, camera);
return true;
} else {

View File

@ -92,14 +92,16 @@ bool CStarRef1::check(const Common::Point &pt, int index) {
/*------------------------------------------------------------------------*/
bool CStarRef2::check(const Common::Point &pt, int index) {
bool CStarRefArray::check(const Common::Point &pt, int index) {
if (_index >= (int)_positions->size())
// Positions array full, so ignore
return false;
CStarPosition &sp = (*_positions)[index];
CStarPosition &sp = (*_positions)[_index++];
sp.x = pt.x;
sp.y = pt.y;
sp._index1 = sp._index2 = index;
return true;
}

View File

@ -56,15 +56,15 @@ public:
virtual bool check(const Common::Point &pt, int index);
};
class CStarRef2 : public CBaseStarRef {
class CStarRefArray : public CBaseStarRef {
private:
Common::Array<CStarPosition> *_positions;
public:
int _index;
public:
CStarRef2(CBaseStars *stars, Common::Array<CStarPosition> *positions) :
CStarRefArray(CBaseStars *stars, Common::Array<CStarPosition> *positions) :
CBaseStarRef(stars), _positions(positions), _index(0) {}
virtual ~CStarRef2() {}
virtual ~CStarRefArray() {}
virtual bool check(const Common::Point &pt, int index);
};