SAGA2: Move playerList to Saga2Engine

This commit is contained in:
a/ 2021-07-17 11:23:24 +09:00
parent 8b28cb61b3
commit 500916b5ca
8 changed files with 69 additions and 75 deletions

View File

@ -74,8 +74,6 @@ extern int32 actorListSize;
extern int16 actorLimboCount;
extern PlayerActor playerList[]; // Master list of all PlayerActors
bool unstickObject(GameObject *obj);
extern ObjectSoundFXs *objectSoundFXTable; // the global object sound effects table
@ -798,15 +796,15 @@ void ActorProto::doBackgroundUpdate(GameObject *obj) {
switch (actorID) {
case ActorBaseID + FTA_JULIAN:
playerList[FTA_JULIAN].recoveryUpdate();
g_vm->_playerList[FTA_JULIAN]->recoveryUpdate();
break;
case ActorBaseID + FTA_PHILIP:
playerList[FTA_PHILIP].recoveryUpdate();
g_vm->_playerList[FTA_PHILIP]->recoveryUpdate();
break;
case ActorBaseID + FTA_KEVIN:
playerList[FTA_KEVIN].recoveryUpdate();
g_vm->_playerList[FTA_KEVIN]->recoveryUpdate();
break;
default:
@ -1758,7 +1756,7 @@ ActorAttributes *Actor::getBaseStats(void) {
if (disposition < dispositionPlayer)
return &((ActorProto *)prototype)->baseStats;
else
return &playerList[disposition - dispositionPlayer].baseStats;
return &g_vm->_playerList[disposition - dispositionPlayer]->baseStats;
}
//-----------------------------------------------------------------------

View File

@ -56,7 +56,6 @@ extern ReadyContainerView *TrioCviews[kNumViews];
extern ReadyContainerView *indivCviewTop, *indivCviewBot;
extern SpellStuff spellBook[];
extern SpriteSet *objectSprites; // object sprites
extern PlayerActor playerList[]; // Master list of all PlayerActors
extern Alarm containerObjTextAlarm;
extern bool gameSetupComplete;

View File

@ -46,7 +46,6 @@ namespace Saga2 {
* ===================================================================== */
extern ReadyContainerView *TrioCviews[kNumViews];
extern ReadyContainerView *indivCviewTop, *indivCviewBot;
extern PlayerActor playerList[]; // Master list of all PlayerActors
extern gPanelList *trioControls, *indivControls;
extern gPanelList *playControls;
extern const uint32 imageGroupID;
@ -817,8 +816,8 @@ void CMassWeightIndicator::recalculate(void) {
setMassPie(retMass = getWeightRatio(containerObject, mass, false));
setBulkPie(retBulk = getBulkRatio(containerObject, bulk, false));
} else {
setMassPie(retMass = getWeightRatio(playerList[getCenterActorPlayerID()].getActor(), mass, false));
setBulkPie(retBulk = getBulkRatio(playerList[getCenterActorPlayerID()].getActor(), bulk, false));
setMassPie(retMass = getWeightRatio(g_vm->_playerList[getCenterActorPlayerID()]->getActor(), mass, false));
setBulkPie(retBulk = getBulkRatio(g_vm->_playerList[getCenterActorPlayerID()]->getActor(), bulk, false));
}
}
@ -984,7 +983,7 @@ void CManaIndicator::drawClipped(gPort &port,
// Do an update to the mana star info if needed,
// if not, do not draw stuff
calcDraw = update(&playerList[getCenterActorPlayerID()]);
calcDraw = update(g_vm->_playerList[getCenterActorPlayerID()]);
if (!calcDraw) {
if (!extent.overlap(clipRect)) return;
@ -1353,16 +1352,16 @@ void CHealthIndicator::updateStar(gCompImage *starCtl, int32 bro, int32 baseVita
void CHealthIndicator::update(void) {
if (indivControlsFlag) {
// get the stats for the selected brother
int16 baseVitality = playerList[translatePanID(uiIndiv)].getBaseStats().vitality;
int16 currVitality = playerList[translatePanID(uiIndiv)].getEffStats()->vitality;
int16 baseVitality = g_vm->_playerList[translatePanID(uiIndiv)]->getBaseStats().vitality;
int16 currVitality = g_vm->_playerList[translatePanID(uiIndiv)]->getEffStats()->vitality;
updateStar(indivStarBtn, uiIndiv, baseVitality, currVitality);
} else {
for (uint16 i = 0; i < numControls; i++) {
// get the stats for the selected brother
int16 baseVitality = playerList[i].getBaseStats().vitality;
int16 currVitality = playerList[i].getEffStats()->vitality;
int16 baseVitality = g_vm->_playerList[i]->getBaseStats().vitality;
int16 currVitality = g_vm->_playerList[i]->getEffStats()->vitality;
updateStar(starBtns[i], i, baseVitality, currVitality);
}
@ -1769,7 +1768,7 @@ void updateIndicators(void) {
// mana indicator update check
if (isIndivMode()) {
if (ManaIndicator->needUpdate(&playerList[getCenterActorPlayerID()])) {
if (ManaIndicator->needUpdate(g_vm->_playerList[getCenterActorPlayerID()])) {
// redraw the region that is not covered by any other window
ManaIndicator->invalidate();
}
@ -1897,7 +1896,7 @@ void setIndivBtns(uint16 brotherID) { // top = 0, mid = 1, bot = 2
// now set the indicators for mass and bulk
uint16 pieWeightRatio = MassWeightIndicator->getMassPieDiv();
uint16 pieBulkRatio = MassWeightIndicator->getBulkPieDiv();
PlayerActor *brother = &playerList[brotherID];
PlayerActor *brother = g_vm->_playerList[brotherID];
MassWeightIndicator->setMassPie(getWeightRatio(brother->getActor(), pieWeightRatio, false));
MassWeightIndicator->setBulkPie(getBulkRatio(brother->getActor(), pieBulkRatio, false));
@ -1944,7 +1943,7 @@ void setCenterBrother(uint16 whichBrother) {
g_vm->_mouseInfo->replaceObject();
// set the new center actor
setCenterActor(&playerList[whichBrother]);
setCenterActor(g_vm->_playerList[whichBrother]);
}
uint16 translatePanID(uint16 panID) {
@ -2409,8 +2408,8 @@ APPFUNC(cmdHealthStar) {
}
// get the stats for the selected brother
int16 baseVitality = playerList[transBroID].getBaseStats().vitality;
int16 currVitality = playerList[transBroID].getEffStats()->vitality;
int16 baseVitality = g_vm->_playerList[transBroID]->getBaseStats().vitality;
int16 currVitality = g_vm->_playerList[transBroID]->getEffStats()->vitality;
char buf[40];
@ -2438,7 +2437,7 @@ APPFUNC(cmdMassInd) {
if (ev.panel->id > 1) {
containerObject = (GameObject *)win->userData;
} else {
containerObject = (GameObject *)playerList[getCenterActorPlayerID()].getActor();
containerObject = (GameObject *)g_vm->_playerList[getCenterActorPlayerID()]->getActor();
}
assert(containerObject);
@ -2476,7 +2475,7 @@ APPFUNC(cmdBulkInd) {
if (ev.panel->id > 1) {
containerObject = (GameObject *)win->userData;
} else {
containerObject = (GameObject *)playerList[getCenterActorPlayerID()].getActor();
containerObject = (GameObject *)g_vm->_playerList[getCenterActorPlayerID()]->getActor();
}
assert(containerObject);
@ -2503,7 +2502,7 @@ APPFUNC(cmdManaInd) {
int numManaRegions = ManaIndicator->getNumManaRegions();
int i;
int curMana = 0, baseMana = 0;
PlayerActor *player = &playerList[getCenterActorPlayerID()];
PlayerActor *player = g_vm->_playerList[getCenterActorPlayerID()];
ActorAttributes *stats = player->getEffStats();
ActorAttributes baseStatsRef = player->getBaseStats();
Point16 pos = ev.mouse;
@ -2610,7 +2609,7 @@ void cleanupUIState(void) {
}
void gArmorIndicator::setValue(PlayerActorID brotherID) {
Actor *bro = playerList[brotherID].getActor();
Actor *bro = g_vm->_playerList[brotherID]->getActor();
bro->totalArmorAttributes(attr);
invalidate();
}
@ -2715,7 +2714,7 @@ void gEnchantmentDisplay::pointerMove(gPanelMessage &msg) {
}
void gEnchantmentDisplay::setValue(PlayerActorID pID) {
Actor *a = playerList[pID].getActor();
Actor *a = g_vm->_playerList[pID]->getActor();
uint8 newIconFlags[iconCount];
EnchantmentIterator iter(a);
ContainerIterator cIter(a);

View File

@ -135,7 +135,6 @@ bool massAndBulkCount;
extern BackWindow *mainWindow;
extern StaticPoint16 fineScroll; // current scroll pos
extern hResContext *imageRes; // image resource handle
extern PlayerActor playerList[]; // Master list of all PlayerActors
extern SpellStuff spellBook[];
extern ObjectID pickedObject;
@ -614,7 +613,7 @@ void GameObject::objCursorText(char nameBuf[], const int8 size, int16 count) {
brotherID == ActorBaseID + FTA_PHILIP ||
brotherID == ActorBaseID + FTA_KEVIN) {
// get base 0 level
level = playerList[brotherID - ActorBaseID].getSkillLevel(sProto);
level = g_vm->_playerList[brotherID - ActorBaseID]->getSkillLevel(sProto);
// normalize and output
sprintf(nameBuf, "%s-%d", objName(), ++level);
@ -4311,7 +4310,7 @@ void readyContainerSetup(void) {
indivReadyNode = CreateReadyContainerNode(0);
for (i = 0; i < kNumViews && i < kPlayerActors ; i++) {
playerList[i].readyNode = CreateReadyContainerNode(i);
g_vm->_playerList[i]->readyNode = CreateReadyContainerNode(i);
TrioCviews[i] = new ReadyContainerView(
*trioControls,
@ -4319,7 +4318,7 @@ void readyContainerSetup(void) {
trioReadyContInfo[i].yPos + 8,
iconOriginX * 2 + iconWidth * trioReadyContInfo[i].cols + iconSpacingY * (trioReadyContInfo[i].cols - 1),
iconOriginY + (iconOriginY * trioReadyContInfo[i].rows) + (trioReadyContInfo[i].rows * iconHeight) - 23),
*playerList[i].readyNode,
*g_vm->_playerList[i]->readyNode,
backImages,
numReadyContRes,
trioReadyContInfo[i].rows,
@ -4375,8 +4374,8 @@ void cleanupReadyContainers(void) {
delete TrioCviews[i];
TrioCviews[i] = nullptr;
delete playerList[i].readyNode;
playerList[i].readyNode = nullptr;
delete g_vm->_playerList[i]->readyNode;
g_vm->_playerList[i]->readyNode = nullptr;
}
delete indivReadyNode;

View File

@ -51,7 +51,6 @@ extern uint8 identityColors[256];
#pragma off (unreferenced);
#endif
extern PlayerActor playerList[]; // Master list of all PlayerActors
extern ObjectSoundFXs *objectSoundFXTable; // the global object sound effects table

View File

@ -67,14 +67,6 @@ static PlayerActorID centerActor; // Index of the current center
bool brotherBandingEnabled;
// Master list of all playerActor structures
PlayerActor playerList[kPlayerActors] = {
PlayerActor(ActorBaseID + 0), // Julian
PlayerActor(ActorBaseID + 1), // Philip
PlayerActor(ActorBaseID + 2), // Kevin
};
/* ===================================================================== *
Methods
* ===================================================================== */
@ -507,30 +499,35 @@ void PlayerActor::handleAttacked(void) {
// Return a pointer to a PlayerActor given it's ID
PlayerActor *getPlayerActorAddress(PlayerActorID id) {
assert(id >= 0 && id < ARRAYSIZE(playerList));
assert(id >= 0 && id < (int)g_vm->_playerList.size());
return &playerList[id];
return g_vm->_playerList[id];
}
//-----------------------------------------------------------------------
// Return a PlayerActor ID given it's address
PlayerActorID getPlayerActorID(PlayerActor *p) {
return p - playerList;
for (int i = 0; i < (int)g_vm->_playerList.size(); ++i) {
if (g_vm->_playerList[i] == p)
return i;
}
return -1;
}
//-----------------------------------------------------------------------
// Return a pointer the center actor's Actor structure
Actor *getCenterActor(void) {
return playerList[centerActor].getActor();
return g_vm->_playerList[centerActor]->getActor();
}
//-----------------------------------------------------------------------
// Return the center actor's object ID
ObjectID getCenterActorID(void) {
return playerList[centerActor].getActorID();
return ActorBaseID + centerActor;
}
//-----------------------------------------------------------------------
@ -548,7 +545,7 @@ void setCenterActor(PlayerActorID newCenter) {
assert(newCenter < kPlayerActors);
Actor *a = playerList[newCenter].getActor();
Actor *a = g_vm->_playerList[newCenter]->getActor();
PlayerActorIterator iter;
PlayerActor *player;
@ -564,7 +561,7 @@ void setCenterActor(PlayerActorID newCenter) {
}
centerActor = newCenter;
viewCenterObject = playerList[centerActor].getActorID();
viewCenterObject = g_vm->_playerList[centerActor]->getActorID();
indivReadyNode->changeOwner(newCenter);
g_vm->_containerList->setPlayerNum(newCenter);
@ -577,7 +574,7 @@ void setCenterActor(PlayerActorID newCenter) {
}
// Set the new centers fight stance based upon his aggression state
a->setFightStance(playerList[newCenter].isAggressive());
a->setFightStance(g_vm->_playerList[newCenter]->isAggressive());
// band actors to new center if banding button set
for (player = iter.first(); player != NULL; player = iter.next()) {
@ -600,8 +597,8 @@ void setCenterActor(Actor *newCenter) {
// Set a new center actor based upon a PlayerActor address
void setCenterActor(PlayerActor *newCenter) {
assert(newCenter >= playerList && newCenter < &playerList[kPlayerActors]);
setCenterActor(newCenter - playerList);
assert(getPlayerActorID(newCenter) >= 0);
setCenterActor(getPlayerActorID(newCenter));
}
//-----------------------------------------------------------------------
@ -610,7 +607,7 @@ void setCenterActor(PlayerActor *newCenter) {
TilePoint centerActorCoords(void) {
Actor *a;
a = playerList[centerActor].getActor();
a = g_vm->_playerList[centerActor]->getActor();
return a->getLocation();
}
@ -621,14 +618,14 @@ TilePoint centerActorCoords(void) {
void setAggression(PlayerActorID player, bool aggression) {
assert(player >= 0 && player < kPlayerActors);
Actor *a = playerList[player].getActor();
Actor *a = g_vm->_playerList[player]->getActor();
if (a->isDead()) return;
if (aggression)
playerList[player].setAggression();
g_vm->_playerList[player]->setAggression();
else
playerList[player].clearAggression();
g_vm->_playerList[player]->clearAggression();
if (player == centerActor)
a->setFightStance(aggression);
@ -643,7 +640,7 @@ void setAggression(PlayerActorID player, bool aggression) {
bool isAggressive(PlayerActorID player) {
assert(player >= 0 && player < kPlayerActors);
return playerList[player].isAggressive();
return g_vm->_playerList[player]->isAggressive();
}
//-----------------------------------------------------------------------
@ -657,7 +654,7 @@ void autoAdjustAggression(void) {
for (i = 0; i < kPlayerActors; i++) {
if (i == centerActor || isBanded(i)) {
bool enemiesPresent = false;
Actor *actor = playerList[i].getActor();
Actor *actor = g_vm->_playerList[i]->getActor();
if (actor->getStats()->vitality >= kMinAutoAggressionVitality) {
GameObject *obj;
@ -696,14 +693,14 @@ void autoAdjustAggression(void) {
void setBanded(PlayerActorID player, bool banded) {
assert(player >= 0 && player < kPlayerActors);
if (playerList[player].getActor()->isDead()) return;
if (g_vm->_playerList[player]->getActor()->isDead()) return;
if (banded)
playerList[player].setBanded();
g_vm->_playerList[player]->setBanded();
else
playerList[player].clearBanded();
g_vm->_playerList[player]->clearBanded();
playerList[player].resolveBanding();
g_vm->_playerList[player]->resolveBanding();
updateBrotherBandingButton(player, banded);
}
@ -713,7 +710,7 @@ void setBanded(PlayerActorID player, bool banded) {
bool isBanded(PlayerActorID player) {
assert(player >= 0 && player < kPlayerActors);
return playerList[player].isBanded();
return g_vm->_playerList[player]->isBanded();
}
//-----------------------------------------------------------------------
@ -794,7 +791,7 @@ void handlePlayerActorDeath(PlayerActorID id) {
allPlayerActorsDead = true;
}
PlayerActor *player = &playerList[id];
PlayerActor *player = g_vm->_playerList[id];
player->clearAggression();
player->clearBanded();
@ -872,7 +869,7 @@ void handleEndOfCombat(void) {
// Iterate through all player actors
for (i = 0; i < kPlayerActors; i++)
playerList[i].resetAttackNotification();
g_vm->_playerList[i]->resetAttackNotification();
}
/* ======================================================================= *
@ -898,10 +895,12 @@ struct PlayerActorArchive {
// Initialize the player list
void initPlayerActors(void) {
PlayerActorID i;
g_vm->_playerList.push_back(new PlayerActor(ActorBaseID + 0)); // Julian
g_vm->_playerList.push_back(new PlayerActor(ActorBaseID + 1)); // Philip
g_vm->_playerList.push_back(new PlayerActor(ActorBaseID + 2)); // Kevin
for (i = 0; i < kPlayerActors; i++) {
PlayerActor *p = &playerList[i];
for (int i = 0; i < kPlayerActors; i++) {
PlayerActor *p = g_vm->_playerList[i];
Actor *a = p->getActor();
ActorProto *proto = (ActorProto *)a->proto();
@ -943,7 +942,7 @@ void savePlayerActors(Common::OutSaveFile *outS) {
for (int i = 0; i < kPlayerActors; i++) {
debugC(3, kDebugSaveload, "Saving PlayerActor %d", i);
PlayerActor *p = &playerList[i];
PlayerActor *p = g_vm->_playerList[i];
// Store the portrait type
out->writeSint16LE(p->portraitType);
@ -984,7 +983,7 @@ void loadPlayerActors(Common::InSaveFile *in) {
for (int i = 0; i < kPlayerActors; i++) {
debugC(3, kDebugSaveload, "Loading PlayerActor %d", i);
PlayerActor *p = &playerList[i];
PlayerActor *p = g_vm->_playerList[i];
// Restore the portrait type
p->portraitType = in->readSint16LE();
@ -1043,7 +1042,7 @@ struct CenterActorArchive {
void initCenterActor(void) {
centerActor = FTA_JULIAN;
viewCenterObject = playerList[centerActor].getActorID();
viewCenterObject = g_vm->_playerList[centerActor]->getActorID();
// clear the last center actor's button state
updateBrotherRadioButtons(FTA_JULIAN);
@ -1079,11 +1078,11 @@ void loadCenterActor(Common::InSaveFile *in) {
PlayerActor *PlayerActorIterator::first(void) {
index = 0;
return &playerList[index++];
return g_vm->_playerList[index++];
}
PlayerActor *PlayerActorIterator::next(void) {
return (index < kPlayerActors) ? &playerList[index++] : NULL;
return (index < kPlayerActors) ? g_vm->_playerList[index++] : NULL;
}
//-----------------------------------------------------------------------
@ -1098,15 +1097,15 @@ PlayerActor *LivingPlayerActorIterator::next(void) {
if (index >= kPlayerActors)
return nullptr;
Actor *a = playerList[index].getActor();
Actor *a = g_vm->_playerList[index]->getActor();
while (a == nullptr || a->isDead()) {
if (++index >= kPlayerActors)
break;
a = playerList[index].getActor();
a = g_vm->_playerList[index]->getActor();
}
return (index < kPlayerActors) ? &playerList[index++] : nullptr;
return (index < kPlayerActors) ? g_vm->_playerList[index++] : nullptr;
}
} // end of namespace Saga2

View File

@ -51,7 +51,6 @@ extern BackWindow *mainWindow;
extern SpriteSet *objectSprites; // object sprites
extern APPFUNC(cmdClickSpeech);
extern PlayerActor playerList[]; // a list of the players (brothers)
extern StaticTextPallete genericTextPal;
APPFUNC(cmdHealthStar);

View File

@ -65,6 +65,7 @@ class gMousePointer;
class ActiveRegion;
class gToolBase;
class Properties;
class PlayerActor;
enum {
kDebugResources = 1 << 0,
@ -122,6 +123,7 @@ public:
WeaponStuff _weaponRack[kMaxWeapons];
weaponID _loadedWeapons;
Common::Array<char *> _nameList;
Common::Array<PlayerActor *> _playerList;
Common::List<TimerList *> _timerLists;
Common::List<Timer *> _timers;
Common::List<ActorAppearance *> _appearanceLRU;