aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sludge/people.cpp69
-rw-r--r--engines/sludge/people.h13
-rw-r--r--engines/sludge/speech.cpp6
3 files changed, 46 insertions, 42 deletions
diff --git a/engines/sludge/people.cpp b/engines/sludge/people.cpp
index 27301c2126..7a70e62457 100644
--- a/engines/sludge/people.cpp
+++ b/engines/sludge/people.cpp
@@ -185,6 +185,18 @@ bool Persona::load(Common::SeekableReadStream *stream) {
return true;
}
+void OnScreenPerson::setFrames(int a) {
+ myAnim = myPersona->animation[(a * myPersona->numDirections) + direction];
+}
+
+void OnScreenPerson::makeTalker() {
+ setFrames(ANI_TALK);
+}
+
+void OnScreenPerson::makeSilent() {
+ setFrames(ANI_STAND);
+}
+
PeopleManager::PeopleManager(SludgeEngine *vm) {
_vm = vm;
_allPeople = nullptr;
@@ -200,10 +212,6 @@ PeopleManager::~PeopleManager() {
_personRegion = nullptr;
}
-void PeopleManager::setFrames(OnScreenPerson &m, int a) {
- m.myAnim = m.myPersona->animation[(a * m.myPersona->numDirections) + m.direction];
-}
-
void PeopleManager::turnMeAngle(OnScreenPerson *thisPerson, int direc) {
int d = thisPerson->myPersona->numDirections;
thisPerson->angle = direc;
@@ -254,7 +262,8 @@ bool PeopleManager::turnPersonToFace(int thisNum, int direc) {
thisPerson->walking = false;
thisPerson->spinning = false;
turnMeAngle(thisPerson, direc);
- setFrames(*thisPerson, g_sludge->_speechMan->isCurrentTalker(thisPerson) ? ANI_TALK : ANI_STAND);
+ _vm->_speechMan->isCurrentTalker(thisPerson) ?
+ thisPerson->makeTalker() : thisPerson->makeSilent();
return true;
}
return false;
@@ -497,7 +506,7 @@ void PeopleManager::drawPeople() {
OnScreenPerson *thisPerson = _allPeople;
PersonaAnimation *myAnim = NULL;
- g_sludge->_regionMan->resetOverRegion();
+ _vm->_regionMan->resetOverRegion();
while (thisPerson) {
if (thisPerson->show) {
@@ -507,7 +516,7 @@ void PeopleManager::drawPeople() {
thisPerson->frameNum = 0;
thisPerson->frameTick = myAnim->frames[0].howMany;
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
- g_sludge->_soundMan->startSound(myAnim->frames[thisPerson->frameNum].noise, false);
+ _vm->_soundMan->startSound(myAnim->frames[thisPerson->frameNum].noise, false);
thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
@@ -528,13 +537,13 @@ void PeopleManager::drawPeople() {
}
if (m != 2) {
bool r = false;
- r = g_sludge->_gfxMan->scaleSprite(myAnim->theSprites->bank.sprites[fNum], myAnim->theSprites->bank.myPalette, thisPerson, m);
+ r = _vm->_gfxMan->scaleSprite(myAnim->theSprites->bank.sprites[fNum], myAnim->theSprites->bank.myPalette, thisPerson, m);
if (r) {
if (!thisPerson->thisType->screenName.empty()) {
if (_personRegion->thisType != thisPerson->thisType)
- g_sludge->_regionMan->resetLastRegion();
+ _vm->_regionMan->resetLastRegion();
_personRegion->thisType = thisPerson->thisType;
- g_sludge->_regionMan->setOverRegion(_personRegion);
+ _vm->_regionMan->setOverRegion(_personRegion);
}
}
}
@@ -545,7 +554,7 @@ void PeopleManager::drawPeople() {
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
if (thisPerson->show && myAnim && myAnim->frames) {
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
- g_sludge->_soundMan->startSound(myAnim->frames[thisPerson->frameNum].noise, false);
+ _vm->_soundMan->startSound(myAnim->frames[thisPerson->frameNum].noise, false);
thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
@@ -562,14 +571,6 @@ void PeopleManager::drawPeople() {
}
}
-void PeopleManager::makeTalker(OnScreenPerson &me) {
- setFrames(me, ANI_TALK);
-}
-
-void PeopleManager::makeSilent(OnScreenPerson &me) {
- setFrames(me, ANI_STAND);
-}
-
bool PeopleManager::handleClosestPoint(int &setX, int &setY, int &setPoly) {
int gotX = 320, gotY = 200, gotPoly = -1, i, j, xTest1, yTest1, xTest2, yTest2, closestX, closestY, oldJ, currentDistance = 0xFFFFF, thisDistance;
@@ -670,7 +671,7 @@ bool PeopleManager::doBorderStuff(OnScreenPerson *moveMe) {
moveMe->spinning = true;
}
- setFrames(*moveMe, ANI_WALK);
+ moveMe->setFrames(ANI_WALK);
return true;
}
@@ -689,7 +690,7 @@ bool PeopleManager::walkMe(OnScreenPerson *thisPerson, bool move) {
if (ABS(maxDiff) > s) {
if (thisPerson->spinning) {
spinStep(thisPerson);
- setFrames(*thisPerson, ANI_WALK);
+ thisPerson->setFrames(ANI_WALK);
}
s = maxDiff / s;
if (move)
@@ -710,7 +711,7 @@ bool PeopleManager::walkMe(OnScreenPerson *thisPerson, bool move) {
}
thisPerson->walking = false;
- setFrames(*thisPerson, ANI_STAND);
+ thisPerson->setFrames(ANI_STAND);
moveAndScale(*thisPerson, thisPerson->walkToX, thisPerson->walkToY);
return false;
}
@@ -762,7 +763,7 @@ bool PeopleManager::stopPerson(int o) {
moveMe->continueAfterWalking = NULL;
moveMe->walking = false;
moveMe->spinning = false;
- setFrames(*moveMe, ANI_STAND);
+ moveMe->setFrames(ANI_STAND);
return true;
}
return false;
@@ -838,7 +839,7 @@ void PeopleManager::walkAllPeople() {
walkMe(thisPerson);
} else if (thisPerson->spinning) {
spinStep(thisPerson);
- setFrames(*thisPerson, ANI_STAND);
+ thisPerson->setFrames(ANI_STAND);
}
if ((!thisPerson->walking) && (!thisPerson->spinning) && thisPerson->continueAfterWalking) {
restartFunction(thisPerson->continueAfterWalking);
@@ -854,7 +855,7 @@ bool PeopleManager::addPerson(int x, int y, int objNum, Persona *p) {
return false;
// EASY STUFF
- newPerson->thisType = g_sludge->_objMan->loadObjectType(objNum);
+ newPerson->thisType = _vm->_objMan->loadObjectType(objNum);
newPerson->scale = 1;
newPerson->extra = 0;
newPerson->continueAfterWalking = NULL;
@@ -882,7 +883,7 @@ bool PeopleManager::addPerson(int x, int y, int objNum, Persona *p) {
newPerson->lastUsedAnim = 0;
newPerson->frameTick = 0;
- setFrames(*newPerson, ANI_STAND);
+ newPerson->setFrames(ANI_STAND);
// HEIGHT (BASED ON 1st FRAME OF 1st ANIMATION... INC. SPECIAL CASES)
int fNumSigned = p->animation[0]->frames[0].frameNum;
@@ -931,9 +932,9 @@ void PeopleManager::animatePerson(int obj, Persona *per) { // Set a
moveMe->myPersona = per;
rethinkAngle(moveMe);
if (moveMe->walking) {
- setFrames(*moveMe, ANI_WALK);
+ moveMe->setFrames(ANI_WALK);
} else {
- setFrames(*moveMe, ANI_STAND);
+ moveMe->setFrames(ANI_STAND);
}
}
}
@@ -946,7 +947,7 @@ void PeopleManager::kill() {
_allPeople->continueAfterWalking = NULL;
killPeople = _allPeople;
_allPeople = _allPeople->next;
- g_sludge->_objMan->removeObjectType(killPeople->thisType);
+ _vm->_objMan->removeObjectType(killPeople->thisType);
delete killPeople;
}
}
@@ -968,7 +969,7 @@ void PeopleManager::killMostPeople() {
if (killPeople->continueAfterWalking)
abortFunction(killPeople->continueAfterWalking);
killPeople->continueAfterWalking = NULL;
- g_sludge->_objMan->removeObjectType(killPeople->thisType);
+ _vm->_objMan->removeObjectType(killPeople->thisType);
delete killPeople;
}
}
@@ -978,7 +979,7 @@ void PeopleManager::removeOneCharacter(int i) {
OnScreenPerson *p = findPerson(i);
if (p) {
- ScreenRegion *overRegion = g_sludge->_regionMan->getOverRegion();
+ ScreenRegion *overRegion = _vm->_regionMan->getOverRegion();
if (overRegion == _personRegion && overRegion->thisType == p->thisType) {
overRegion = nullptr;
}
@@ -993,7 +994,7 @@ void PeopleManager::removeOneCharacter(int i) {
}
*killPeople = p->next;
- g_sludge->_objMan->removeObjectType(p->thisType);
+ _vm->_objMan->removeObjectType(p->thisType);
delete p;
}
}
@@ -1058,7 +1059,7 @@ bool PeopleManager::savePeople(Common::WriteStream *stream) {
stream->writeByte(me->colourmix);
stream->writeByte(me->transparency);
- g_sludge->_objMan->saveObjectRef(me->thisType, stream);
+ _vm->_objMan->saveObjectRef(me->thisType, stream);
me = me->next;
}
@@ -1142,7 +1143,7 @@ bool PeopleManager::loadPeople(Common::SeekableReadStream *stream) {
} else {
setMyDrawMode(me, stream->readUint16BE());
}
- me->thisType = g_sludge->_objMan->loadObjectRef(stream);
+ me->thisType = _vm->_objMan->loadObjectRef(stream);
// Anti-aliasing settings
if (ssgVersion >= VERSION(1, 6)) {
diff --git a/engines/sludge/people.h b/engines/sludge/people.h
index baf127cf7b..60ad672ef7 100644
--- a/engines/sludge/people.h
+++ b/engines/sludge/people.h
@@ -88,6 +88,10 @@ struct OnScreenPerson {
struct ObjectType *thisType;
int extra, spinSpeed;
byte r, g, b, colourmix, transparency;
+
+ void makeTalker();
+ void makeSilent();
+ void setFrames(int a);
};
class PeopleManager {
@@ -113,8 +117,6 @@ public:
void setScale(int16 h, int16 d);
// Things which affect one character
- void makeTalker(OnScreenPerson &me);
- void makeSilent(OnScreenPerson &me);
void setShown(bool h, int ob);
void setDrawMode(int h, int ob);
void setPersonTransparency(int ob, byte x);
@@ -152,14 +154,15 @@ private:
SludgeEngine *_vm;
- void setFrames(OnScreenPerson &m, int a);
+ void shufflePeople();
+ bool handleClosestPoint(int &setX, int &setY, int &setPoly);
+
+ // OnScreenPerson manipulation
void turnMeAngle(OnScreenPerson *thisPerson, int direc);
void spinStep(OnScreenPerson *thisPerson);
void rethinkAngle(OnScreenPerson *thisPerson);
void moveAndScale(OnScreenPerson &me, float x, float y);
void setMyDrawMode(OnScreenPerson *moveMe, int h);
- void shufflePeople();
- bool handleClosestPoint(int &setX, int &setY, int &setPoly);
bool doBorderStuff(OnScreenPerson *moveMe);
bool walkMe(OnScreenPerson *thisPerson, bool move = true);
};
diff --git a/engines/sludge/speech.cpp b/engines/sludge/speech.cpp
index c688bf312d..cac4a5e705 100644
--- a/engines/sludge/speech.cpp
+++ b/engines/sludge/speech.cpp
@@ -61,8 +61,8 @@ void SpeechManager::kill() {
}
if (_speech->currentTalker) {
- g_sludge->_peopleMan->makeSilent(*(_speech->currentTalker));
- _speech->currentTalker = NULL;
+ _speech->currentTalker->makeSilent();
+ _speech->currentTalker = nullptr;
}
SpeechLine *killMe;
@@ -176,7 +176,7 @@ int SpeechManager::wrapSpeechPerson(const Common::String &theText, OnScreenPerso
- thePerson.thisType->speechGap,
thePerson.thisType->wrapSpeech, sampleFile);
if (animPerson) {
- g_sludge->_peopleMan->makeTalker(thePerson);
+ thePerson.makeTalker();
_speech->currentTalker = &thePerson;
}
return i;