SAGA2: Rename class variables in spelshow.h

This commit is contained in:
Eugene Sandulenko 2022-09-27 14:41:58 +02:00
parent c68a1a910c
commit 6ccffbfbf8
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
8 changed files with 348 additions and 346 deletions

View File

@ -980,8 +980,7 @@ void Effectron::drawEffect() {
sc->sp = spellSprites->sprite(spriteID()); //tempSpellSpriteIDs[rand()%39] );
sc->offset.x = scList->offset.y = 0;
(*g_vm->_sdpList)[_parent->spell]->
getColorTranslation(eColors, this);
(*g_vm->_sdpList)[_parent->_spell]->getColorTranslation(eColors, this);
sc->colorTable = eColors;
sc->flipped = false;

View File

@ -582,10 +582,10 @@ void SpellStuff::show(GameObject *caster, SpellTarget &trg) {
SpellInstance::SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, SpellID spellNo) {
assert(newCaster);
assert(newTarget);
caster = newCaster;
target = new SpellTarget(*newTarget);
world = newCaster->world();
spell = spellNo;
_caster = newCaster;
_target = new SpellTarget(*newTarget);
_world = newCaster->world();
_spell = spellNo;
init();
}
@ -594,10 +594,10 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, Spe
SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject &newTarget, SpellID spellNo) {
assert(newCaster);
target = new SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
spell = spellNo;
_target = new SpellTarget(newTarget);
_caster = newCaster;
_world = newCaster->world();
_spell = spellNo;
init();
}
@ -607,10 +607,10 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject &newTarget, Spel
SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject *newTarget, SpellID spellNo) {
assert(newCaster);
assert(newTarget);
target = new SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
spell = spellNo;
_target = new SpellTarget(newTarget);
_caster = newCaster;
_world = newCaster->world();
_spell = spellNo;
init();
}
@ -619,10 +619,10 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, GameObject *newTarget, Spel
SpellInstance::SpellInstance(SpellCaster *newCaster, TilePoint &newTarget, SpellID spellNo) {
assert(newCaster);
target = new SpellTarget(newTarget);
caster = newCaster;
world = newCaster->world();
spell = spellNo;
_target = new SpellTarget(newTarget);
_caster = newCaster;
_world = newCaster->world();
_spell = spellNo;
init();
}
@ -631,38 +631,41 @@ SpellInstance::SpellInstance(SpellCaster *newCaster, TilePoint &newTarget, Spell
SpellInstance::~SpellInstance() {
if (age < implementAge && g_vm->_gameRunning)
spellBook[spell].implement(caster, target);
for (int32 i = 0; i < eList._count; i++) {
if (eList._displayList[i]._efx)
delete eList._displayList[i]._efx;
eList._displayList[i]._efx = nullptr;
if (_age < _implementAge && g_vm->_gameRunning)
spellBook[_spell].implement(_caster, _target);
for (int32 i = 0; i < _eList._count; i++) {
if (_eList._displayList[i]._efx)
delete _eList._displayList[i]._efx;
_eList._displayList[i]._efx = nullptr;
}
if (target)
delete target;
target = nullptr;
if (_target)
delete _target;
_target = nullptr;
}
// ------------------------------------------------------------------
// common initialization code
void SpellInstance::init() {
dProto = (*g_vm->_sdpList)[spell];
ProtoObj *proto = caster->proto();
TilePoint sPoint = caster->getWorldLocation();
_dProto = (*g_vm->_sdpList)[_spell];
ProtoObj *proto = _caster->proto();
TilePoint sPoint = _caster->getWorldLocation();
sPoint.z += proto->height / 2;
age = 0;
implementAge = 0;
effSeq = 0;
assert(dProto);
if (!dProto) return;
effect = (*g_vm->_edpList)[dProto->effect];
implementAge = dProto->implementAge;
maxAge = dProto->maxAge;
_age = 0;
_implementAge = 0;
_effSeq = 0;
assert(_dProto);
if (!_dProto)
return;
_effect = (*g_vm->_edpList)[_dProto->_effect];
_implementAge = _dProto->_implementAge;
_maxAge = _dProto->_maxAge;
initEffect(sPoint);
if (implementAge == 0)
spellBook[spell].implement(caster, target);
if (_implementAge == 0)
spellBook[_spell].implement(_caster, _target);
}
@ -670,11 +673,11 @@ void SpellInstance::init() {
// common cleanup
void SpellInstance::termEffect() {
if (eList._count)
for (int32 i = 0; i < eList._count; i++) {
if (eList._displayList[i]._efx) {
delete eList._displayList[i]._efx;
eList._displayList[i]._efx = nullptr;
if (_eList._count)
for (int32 i = 0; i < _eList._count; i++) {
if (_eList._displayList[i]._efx) {
delete _eList._displayList[i]._efx;
_eList._displayList[i]._efx = nullptr;
}
}
}
@ -683,11 +686,11 @@ void SpellInstance::termEffect() {
// visual init
void SpellInstance::initEffect(TilePoint startpoint) {
eList._count = effect->nodeCount; //sdp->effCount;
if (eList._count)
for (int32 i = 0; i < eList._count; i++) {
_eList._count = _effect->_nodeCount; //sdp->effCount;
if (_eList._count)
for (int32 i = 0; i < _eList._count; i++) {
Effectron *e = new Effectron(0, i);
eList._displayList[i]._efx = e;
_eList._displayList[i]._efx = e;
e->_parent = this;
e->_start = startpoint;
e->_current = startpoint;
@ -701,16 +704,16 @@ void SpellInstance::initEffect(TilePoint startpoint) {
// visual update
bool SpellInstance::buildList() {
if (eList.dissipated()) {
if (_eList.dissipated()) {
termEffect();
if (effect->next == nullptr)
if (_effect->_next == nullptr)
return false;
effect = effect->next;
effSeq++;
_effect = _effect->_next;
_effSeq++;
//
initEffect(target->getPoint());
initEffect(_target->getPoint());
}
eList.buildEffects(false);
_eList.buildEffects(false);
return true;
}
@ -719,13 +722,13 @@ bool SpellInstance::buildList() {
bool SpellInstance::updateStates(int32 deltaTime) {
spellBook[spell].show(caster, *target);
age++;
if (age == implementAge || implementAge == continuouslyImplemented)
spellBook[spell].implement(caster, target);
if (maxAge > 0 && age > maxAge)
spellBook[_spell].show(_caster, *_target);
_age++;
if (_age == _implementAge || _implementAge == continuouslyImplemented)
spellBook[_spell].implement(_caster, _target);
if (_maxAge > 0 && _age > _maxAge)
termEffect();
eList.updateEStates(deltaTime);
_eList.updateEStates(deltaTime);
return true;
}
@ -810,7 +813,7 @@ void Effectron::updateEffect(int32 deltaTime) {
if (_age > 1) {
_age = 0;
_pos++;
_finish = _parent->target->getPoint();
_finish = _parent->_target->getPoint();
_stepNo++;
_flags = staCall();
@ -832,7 +835,7 @@ void Effectron::updateEffect(int32 deltaTime) {
//-----------------------------------------------------------------------
void Effectron::bump() {
switch (_parent->dProto->elasticity) {
switch (_parent->_dProto->_elasticity) {
case ecFlagBounce:
_velocity = -_velocity;
break;

View File

@ -57,15 +57,15 @@ EffectDisplayPrototype::EffectDisplayPrototype(
SpellHeightFunction *newHeight,
SpellBreadthFunction *newBreadth,
SpellInitFunction *newInit) {
nodeCount = nodes;
location = newLocation;
spriteno = newSpriteno;
status = newStatus;
height = newHeight;
breadth = newBreadth;
init = newInit;
next = nullptr;
ID = spellNone;
_nodeCount = nodes;
_location = newLocation;
_spriteno = newSpriteno;
_status = newStatus;
_height = newHeight;
_breadth = newBreadth;
_init = newInit;
_next = nullptr;
_ID = spellNone;
}
/* ===================================================================== *
@ -73,49 +73,49 @@ EffectDisplayPrototype::EffectDisplayPrototype(
* ===================================================================== */
EffectDisplayPrototypeList::EffectDisplayPrototypeList(int32 c) {
count = 0;
maxCount = 0;
effects = new pEffectDisplayPrototype[c]();
_count = 0;
_maxCount = 0;
_effects = new pEffectDisplayPrototype[c]();
for (int i = 0; i < c; i++)
effects[i] = nullptr;
assert(effects);
if (effects) maxCount = c;
_effects[i] = nullptr;
assert(_effects);
if (_effects) _maxCount = c;
}
EffectDisplayPrototypeList::~EffectDisplayPrototypeList() {
if (maxCount && effects)
delete[] effects;
maxCount = 0;
effects = nullptr;
if (_maxCount && _effects)
delete[] _effects;
_maxCount = 0;
_effects = nullptr;
}
int32 EffectDisplayPrototypeList::add(EffectDisplayPrototype *edp) {
assert(count < maxCount);
edp->setID(count);
effects[count++] = edp;
return count - 1;
assert(_count < _maxCount);
edp->setID(_count);
_effects[_count++] = edp;
return _count - 1;
}
void EffectDisplayPrototypeList::cleanup() {
if (maxCount && effects)
for (int i = 0; i < maxCount; i++)
if (effects[i]) {
delete effects[i];
effects[i] = nullptr;
if (_maxCount && _effects)
for (int i = 0; i < _maxCount; i++)
if (_effects[i]) {
delete _effects[i];
_effects[i] = nullptr;
}
maxCount = 0;
_maxCount = 0;
}
void EffectDisplayPrototypeList::append(EffectDisplayPrototype *nedp, int32 acount) {
assert(acount < maxCount);
EffectDisplayPrototype *edp = effects[acount];
while (edp->next) edp = edp->next;
edp->next = nedp;
assert(acount < _maxCount);
EffectDisplayPrototype *edp = _effects[acount];
while (edp->_next) edp = edp->_next;
edp->_next = nedp;
}
EffectDisplayPrototype *EffectDisplayPrototypeList::operator[](EffectID e) {
assert(e < maxCount);
return effects[e];
assert(e < _maxCount);
return _effects[e];
}
/* ===================================================================== *
@ -126,33 +126,33 @@ SpellDisplayPrototype::SpellDisplayPrototype(
EffectID e, int32 e1, int32 e2, int32 e3, int32 e4,
effectDirectionInit sc, effectCollisionCont cc, SpellAge sa,
uint32 spID, uint8 sco, uint8) {
effect = e; // Effect ID
effParm1 = e1; // effect setting 1
effParm2 = e2; // effect setting 1
effParm3 = e3; // effect setting 1
effParm4 = e4; // effect setting 1
_effect = e; // Effect ID
_effParm1 = e1; // effect setting 1
_effParm2 = e2; // effect setting 1
_effParm3 = e3; // effect setting 1
_effParm4 = e4; // effect setting 1
scatter = sc; // direction init mode
elasticity = cc; // collision flags
_scatter = sc; // direction init mode
_elasticity = cc; // collision flags
maxAge = sa; // auto self-destruct age
primarySpriteID = spID; // RES_ID( x, y, z, 0 ) to get sprites
primarySpriteNo = sco; // sprites available
secondarySpriteID = spID; // RES_ID( x, y, z, 0 ) to get sprites
secondarySpriteNo = sco; // sprites available
//effCount=eco; // effectrons to allocate
_maxAge = sa; // auto self-destruct age
_primarySpriteID = spID; // RES_ID( x, y, z, 0 ) to get sprites
_primarySpriteNo = sco; // sprites available
_secondarySpriteID = spID; // RES_ID( x, y, z, 0 ) to get sprites
_secondarySpriteNo = sco; // sprites available
//_effCount=eco; // effectrons to allocate
ID = spellNone;
implementAge = 0;
_ID = spellNone;
_implementAge = 0;
}
SpellDisplayPrototype *SpellDisplayPrototypeList::operator[](SpellID s) {
assert(s >= 0 && s < count);
return spells[s];
assert(s >= 0 && s < _count);
return _spells[s];
}
void SpellDisplayPrototype::getColorTranslation(ColorTable map, Effectron *e) {
int32 i = colorMap[whichColorMap(effect, e)];
int32 i = _colorMap[whichColorMap(_effect, e)];
i = MAX<int32>(0, MIN(loadedColorMaps, i));
buildColorTable(map, spellSchemes->_schemes[i]->bank, 11);
}
@ -167,39 +167,39 @@ void SpellDisplayPrototypeList::init() {
}
void SpellDisplayPrototypeList::cleanup() {
if (spells) {
for (int i = 0; i < maxCount; i++)
if (spells[i]) {
delete spells[i];
spells[i] = nullptr;
if (_spells) {
for (int i = 0; i < _maxCount; i++)
if (_spells[i]) {
delete _spells[i];
_spells[i] = nullptr;
}
delete[] spells;
spells = nullptr;
maxCount = 0;
delete[] _spells;
_spells = nullptr;
_maxCount = 0;
}
}
SpellDisplayPrototypeList::SpellDisplayPrototypeList(uint16 s) {
count = 0;
maxCount = 0;
spells = new pSpellDisplayPrototype[s]();
_count = 0;
_maxCount = 0;
_spells = new pSpellDisplayPrototype[s]();
for (int i = 0; i < s; i++)
spells[i] = nullptr;
assert(spells);
if (spells) maxCount = s;
_spells[i] = nullptr;
assert(_spells);
if (_spells) _maxCount = s;
}
SpellDisplayPrototypeList::~SpellDisplayPrototypeList() {
if (maxCount && spells)
delete[] spells;
spells = nullptr;
if (_maxCount && _spells)
delete[] _spells;
_spells = nullptr;
}
int32 SpellDisplayPrototypeList::add(SpellDisplayPrototype *sdp) {
assert(count < maxCount);
sdp->setID((SpellID) count);
spells[count++] = sdp;
return count;
assert(_count < _maxCount);
sdp->setID((SpellID) _count);
_spells[_count++] = sdp;
return _count;
}
/* ===================================================================== *
@ -207,12 +207,12 @@ int32 SpellDisplayPrototypeList::add(SpellDisplayPrototype *sdp) {
* ===================================================================== */
SpellDisplayList::SpellDisplayList(uint16 s) {
count = 0;
maxCount = 0;
spells = new pSpellInstance[s]();
_count = 0;
_maxCount = 0;
_spells = new pSpellInstance[s]();
for (int i = 0; i < s; i++)
spells[i] = nullptr;
if (spells) maxCount = s;
_spells[i] = nullptr;
if (_spells) _maxCount = s;
init();
}
@ -221,45 +221,45 @@ SpellDisplayList::~SpellDisplayList() {
}
void SpellDisplayList::init() {
count = 0;
_count = 0;
}
void SpellDisplayList::cleanup() {
if (maxCount && spells)
delete[] spells;
spells = nullptr;
if (_maxCount && _spells)
delete[] _spells;
_spells = nullptr;
}
void SpellDisplayList::add(SpellInstance *newSpell) {
assert(newSpell);
if (count < maxCount)
spells[count++] = newSpell;
if (_count < _maxCount)
_spells[_count++] = newSpell;
}
void SpellDisplayList::buildList() {
if (count)
for (int16 i = 0; i < count; i++) // check all active spells
if (!spells[i]->buildList()) { // update
if (_count)
for (int16 i = 0; i < _count; i++) // check all active _spells
if (!_spells[i]->buildList()) { // update
tidyKill(i--); // that spell is done
}
}
void SpellDisplayList::updateStates(int32 deltaTime) {
if (count)
for (int16 i = 0; i < count; i++)
spells[i]->updateStates(deltaTime);
if (_count)
for (int16 i = 0; i < _count; i++)
_spells[i]->updateStates(deltaTime);
}
void SpellDisplayList::tidyKill(uint16 spellNo) {
assert(count);
if (spells[spellNo]) {
delete spells[spellNo];
spells[spellNo] = nullptr;
assert(_count);
if (_spells[spellNo]) {
delete _spells[spellNo];
_spells[spellNo] = nullptr;
}
if (spellNo < count--) {
for (uint16 i = spellNo; i <= count; i++)
spells[i] = spells[i + 1];
spells[count + 1] = nullptr;
if (spellNo < _count--) {
for (uint16 i = spellNo; i <= _count; i++)
_spells[i] = _spells[i + 1];
_spells[_count + 1] = nullptr;
}
}

View File

@ -64,11 +64,11 @@ SPELLINITFUNCTION(invisibleSpellInit) {
// aura that tracks target
SPELLINITFUNCTION(auraSpellInit) {
if (effectron->_parent->maxAge)
effectron->_totalSteps = effectron->_parent->maxAge;
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 20;
effectron->_current = effectron->_parent->target->getPoint();
effectron->_current = effectron->_parent->_target->getPoint();
effectron->_velocity = TilePoint(0, 0, 0);
effectron->_acceleration = TilePoint(0, 0, 0);
}
@ -77,11 +77,11 @@ SPELLINITFUNCTION(auraSpellInit) {
// aura that tracks target (in front)
SPELLINITFUNCTION(glowSpellInit) {
if (effectron->_parent->maxAge)
effectron->_totalSteps = effectron->_parent->maxAge;
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 20;
effectron->_current = effectron->_parent->target->getPoint() - TilePoint(1, 1, 0);
effectron->_current = effectron->_parent->_target->getPoint() - TilePoint(1, 1, 0);
effectron->_finish = effectron->_current;
effectron->_velocity = TilePoint(0, 0, 0);
effectron->_acceleration = TilePoint(0, 0, 0);
@ -91,13 +91,13 @@ SPELLINITFUNCTION(glowSpellInit) {
// sprites that surround target
SPELLINITFUNCTION(wallSpellInit) {
if (effectron->_parent->maxAge)
effectron->_totalSteps = effectron->_parent->maxAge;
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 20;
effectron->_current = effectron->_parent->target->getPoint();
effectron->_current = effectron->_parent->_target->getPoint();
effectron->_velocity = WallVectors[effectron->_partno] * wallSpellRadius / 3;
effectron->_current = effectron->_parent->target->getPoint() + effectron->_velocity;
effectron->_current = effectron->_parent->_target->getPoint() + effectron->_velocity;
effectron->_acceleration = TilePoint(0, 0, 0);
}
@ -106,7 +106,7 @@ SPELLINITFUNCTION(wallSpellInit) {
SPELLINITFUNCTION(projectileSpellInit) {
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->target->getPoint();
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tp = (effectron->_finish - effectron->_start);
effectron->_totalSteps = 1 + (tp.magnitude() / (2 * SpellJumpiness));
effectron->_velocity = tp / effectron->_totalSteps;
@ -119,10 +119,10 @@ SPELLINITFUNCTION(projectileSpellInit) {
SPELLINITFUNCTION(exchangeSpellInit) {
if (effectron->_partno % 2) {
effectron->_finish = effectron->_current;
effectron->_start = effectron->_parent->target->getPoint();
effectron->_start = effectron->_parent->_target->getPoint();
} else {
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->target->getPoint();
effectron->_finish = effectron->_parent->_target->getPoint();
}
TilePoint tp = (effectron->_finish - effectron->_start);
effectron->_totalSteps = 1 + (tp.magnitude() / (SpellJumpiness));
@ -137,13 +137,13 @@ SPELLINITFUNCTION(exchangeSpellInit) {
SPELLINITFUNCTION(boltSpellInit) {
effectron->_stepNo = 0;
if (effectron->_parent->maxAge)
effectron->_totalSteps = effectron->_parent->maxAge;
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 1 + (boltSpellLength / (SpellJumpiness * 3));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->target->getPoint();
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, boltSpellLength);
@ -165,13 +165,13 @@ SPELLINITFUNCTION(boltSpellInit) {
SPELLINITFUNCTION(beamSpellInit) {
effectron->_stepNo = 0;
if (effectron->_parent->maxAge)
effectron->_totalSteps = effectron->_parent->maxAge;
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 1 + (beamSpellLength / (SpellJumpiness));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->target->getPoint();
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, beamSpellLength);
@ -195,7 +195,7 @@ SPELLINITFUNCTION(coneSpellInit) {
effectron->_totalSteps = 1 + (coneSpellLength / (SpellJumpiness * 3));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->target->getPoint();
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, coneSpellLength);
@ -216,7 +216,7 @@ SPELLINITFUNCTION(waveSpellInit) {
effectron->_totalSteps = 1 + (coneSpellLength / (SpellJumpiness * 2));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->target->getPoint();
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, waveSpellLength);

View File

@ -44,25 +44,25 @@ namespace Saga2 {
// ctor
SpellDisplayPrototype::SpellDisplayPrototype(ResourceSpellItem *rsi) {
effect = rsi->effect; // Effect ID
effParm1 = 0; // effect setting 1
effParm2 = 0; // effect setting 1
effParm3 = 0; // effect setting 1
effParm4 = 0; // effect setting 1
scatter = diFlagZero; // direction init mode
elasticity = (effectCollisionCont) rsi->effectronElasticity; // collision flags
maxAge = rsi->maxAge; // auto self-destruct age
implementAge = rsi->implAge; // auto self-destruct age
primarySpriteID = rsi->baseSprite; // RES_ID(x, y, z, 0) to get sprites
primarySpriteNo = rsi->spriteCount; // sprites available
secondarySpriteID = rsi->baseSprite2; // RES_ID(x, y, z, 0) to get sprites
secondarySpriteNo = rsi->spriteCount2; // sprites available
//effCount=0; // effectrons to allocate
colorMap[0] = rsi->cm0;
colorMap[1] = rsi->cm1;
colorMap[2] = 0;
colorMap[3] = 0;
ID = spellNone;
_effect = rsi->effect; // Effect ID
_effParm1 = 0; // effect setting 1
_effParm2 = 0; // effect setting 1
_effParm3 = 0; // effect setting 1
_effParm4 = 0; // effect setting 1
_scatter = diFlagZero; // direction init mode
_elasticity = (effectCollisionCont) rsi->effectronElasticity; // collision flags
_maxAge = rsi->maxAge; // auto self-destruct age
_implementAge = rsi->implAge; // auto self-destruct age
_primarySpriteID = rsi->baseSprite; // RES_ID(x, y, z, 0) to get sprites
_primarySpriteNo = rsi->spriteCount; // sprites available
_secondarySpriteID = rsi->baseSprite2; // RES_ID(x, y, z, 0) to get sprites
_secondarySpriteNo = rsi->spriteCount2; // sprites available
//_effCount=0; // effectrons to allocate
_colorMap[0] = rsi->cm0;
_colorMap[1] = rsi->cm1;
_colorMap[2] = 0;
_colorMap[3] = 0;
_ID = spellNone;
}
/* ===================================================================== *
@ -224,7 +224,7 @@ void cleanupSpellState() {
}
// ------------------------------------------------------------------
// cleanup active spells
// cleanup active _spells
StorageSpellTarget::StorageSpellTarget(SpellTarget &st) {
GameObject *go = nullptr;
@ -255,17 +255,17 @@ StorageSpellTarget::StorageSpellTarget(SpellTarget &st) {
}
StorageSpellInstance::StorageSpellInstance(SpellInstance &si) {
implementAge = si.implementAge; // age at which to implement the spell effects
effect = si.effect->thisID(); // effect prototype of the current effect
dProto = si.dProto->thisID(); // effect prototype of the current effect
caster = si.caster->thisID();
target = StorageSpellTarget(*si.target);
world = si.world->thisID();
age = si.age;
spell = si.spell;
maxAge = si.maxAge;
effSeq = si.effSeq; // which effect in a sequence is being played
eListSize = si.eList._count;
implementAge = si._implementAge; // age at which to implement the spell effects
effect = si._effect->thisID(); // effect prototype of the current effect
dProto = si._dProto->thisID(); // effect prototype of the current effect
caster = si._caster->thisID();
target = StorageSpellTarget(*si._target);
world = si._world->thisID();
age = si._age;
spell = si._spell;
maxAge = si._maxAge;
effSeq = si._effSeq; // which effect in a sequence is being played
eListSize = si._eList._count;
}
StorageSpellTarget::StorageSpellTarget() {
@ -339,29 +339,29 @@ SpellTarget::SpellTarget(StorageSpellTarget &sst) {
}
SpellInstance::SpellInstance(StorageSpellInstance &ssi) {
implementAge = ssi.implementAge; // age at which to implement the spell effects
dProto = (*g_vm->_sdpList)[ssi.dProto];
caster = GameObject::objectAddress(ssi.caster);
target = new SpellTarget(ssi.target);
_implementAge = ssi.implementAge; // age at which to implement the spell effects
_dProto = (*g_vm->_sdpList)[ssi.dProto];
_caster = GameObject::objectAddress(ssi.caster);
_target = new SpellTarget(ssi.target);
GameObject *go = GameObject::objectAddress(ssi.world);
assert(isWorld(go));
world = (GameWorld *) go;
age = ssi.age;
spell = ssi.spell;
maxAge = ssi.maxAge;
effSeq = 0;
effect = (*g_vm->_edpList)[ssi.effect];
while (effSeq < ssi.effSeq) // which effect in a sequence is being played
effect = effect->next;
_world = (GameWorld *) go;
_age = ssi.age;
_spell = ssi.spell;
_maxAge = ssi.maxAge;
_effSeq = 0;
_effect = (*g_vm->_edpList)[ssi.effect];
while (_effSeq < ssi.effSeq) // which effect in a sequence is being played
_effect = _effect->_next;
}
size_t SpellDisplayList::saveSize() {
size_t total = 0;
total += sizeof(count);
if (count) {
for (int i = 0; i < count; i++)
total += spells[i]->saveSize();
total += sizeof(_count);
if (_count) {
for (int i = 0; i < _count; i++)
total += _spells[i]->saveSize();
}
return total;
}
@ -369,16 +369,16 @@ size_t SpellDisplayList::saveSize() {
void SpellDisplayList::write(Common::OutSaveFile *outS) {
outS->write("SPEL", 4);
CHUNK_BEGIN;
out->writeUint16LE(count);
out->writeUint16LE(_count);
debugC(3, kDebugSaveload, "... count = %d", count);
debugC(3, kDebugSaveload, "... count = %d", _count);
if (count) {
for (int i = 0; i < count; i++) {
if (_count) {
for (int i = 0; i < _count; i++) {
debugC(3, kDebugSaveload, "Saving Spell Instance %d", i);
StorageSpellInstance ssi = StorageSpellInstance(*spells[i]);
StorageSpellInstance ssi = StorageSpellInstance(*_spells[i]);
ssi.write(out);
spells[i]->writeEffect(out);
_spells[i]->writeEffect(out);
}
}
CHUNK_END;
@ -391,7 +391,7 @@ void SpellDisplayList::read(Common::InSaveFile *in) {
debugC(3, kDebugSaveload, "... count = %d", tCount);
assert(tCount < maxCount);
assert(tCount < _maxCount);
if (tCount) {
for (int i = 0; i < tCount; i++) {
debugC(3, kDebugSaveload, "Loading Spell Instance %d", i);
@ -403,47 +403,47 @@ void SpellDisplayList::read(Common::InSaveFile *in) {
si->readEffect(in, ssi.eListSize);
}
}
assert(tCount == count);
assert(tCount == _count);
}
void SpellDisplayList::wipe() {
for (int i = 0; i < maxCount; i++)
if (spells[i]) {
delete spells[i];
spells[i] = nullptr;
count--;
for (int i = 0; i < _maxCount; i++)
if (_spells[i]) {
delete _spells[i];
_spells[i] = nullptr;
_count--;
}
assert(count == 0);
assert(_count == 0);
}
size_t SpellInstance::saveSize() {
size_t total = 0;
total += sizeof(StorageSpellInstance);
if (eList._count)
for (int32 i = 0; i < eList._count; i++) {
if (_eList._count)
for (int32 i = 0; i < _eList._count; i++) {
total += sizeof(StorageEffectron);
}
return total;
}
void SpellInstance::writeEffect(Common::MemoryWriteStreamDynamic *out) {
if (eList._count > 0 && !(maxAge > 0 && (age + 1) > maxAge))
for (int32 i = 0; i < eList._count; i++) {
StorageEffectron se = StorageEffectron(*eList._displayList[i]._efx);
if (_eList._count > 0 && !(_maxAge > 0 && (_age + 1) > _maxAge))
for (int32 i = 0; i < _eList._count; i++) {
StorageEffectron se = StorageEffectron(*_eList._displayList[i]._efx);
se.write(out);
}
}
void SpellInstance::readEffect(Common::InSaveFile *in, uint16 eListSize) {
assert(eListSize == effect->nodeCount);
eList._count = effect->nodeCount; //sdp->effCount;
if (eList._count)
for (int32 i = 0; i < eList._count; i++) {
assert(eListSize == _effect->_nodeCount);
_eList._count = _effect->_nodeCount; //sdp->effCount;
if (_eList._count)
for (int32 i = 0; i < _eList._count; i++) {
StorageEffectron se;
se.read(in);
Effectron *e = new Effectron(se, this);
eList._displayList[i]._efx = e;
_eList._displayList[i]._efx = e;
}
}

View File

@ -65,7 +65,7 @@ SPELLLOCATIONFUNCTION(glowSpellPos) {
// sprites that surround target
SPELLLOCATIONFUNCTION(wallSpellPos) {
return effectron->_parent->target->getPoint() + effectron->_velocity;
return effectron->_parent->_target->getPoint() + effectron->_velocity;
}
// ------------------------------------------------------------------

View File

@ -39,25 +39,25 @@ namespace Saga2 {
* ===================================================================== */
// random sprite from primary range
#define PRIMARY (effectron->_parent->dProto->primarySpriteNo?\
(effectron->_parent->dProto->primarySpriteID + g_vm->_rnd->getRandomNumber(effectron->_parent->dProto->primarySpriteNo - 1)):\
effectron->_parent->dProto->primarySpriteID)
#define PRIMARY (effectron->_parent->_dProto->_primarySpriteNo?\
(effectron->_parent->_dProto->_primarySpriteID + g_vm->_rnd->getRandomNumber(effectron->_parent->_dProto->_primarySpriteNo - 1)):\
effectron->_parent->_dProto->_primarySpriteID)
// random sprite from secondary range
#define SECONDARY (effectron->_parent->dProto->secondarySpriteNo?\
(effectron->_parent->dProto->secondarySpriteID + g_vm->_rnd->getRandomNumber(effectron->_parent->dProto->secondarySpriteNo - 1)):\
effectron->_parent->dProto->secondarySpriteID)
#define SECONDARY (effectron->_parent->_dProto->_secondarySpriteNo?\
(effectron->_parent->_dProto->_secondarySpriteID + g_vm->_rnd->getRandomNumber(effectron->_parent->_dProto->_secondarySpriteNo - 1)):\
effectron->_parent->_dProto->_secondarySpriteID)
// ordered sprite from primary range
#define SEQUENTIAL (effectron->_parent->dProto->primarySpriteNo?\
(effectron->_parent->dProto->primarySpriteID + effectron->_stepNo%effectron->_parent->dProto->primarySpriteNo):\
effectron->_parent->dProto->primarySpriteID)
#define SEQUENTIAL (effectron->_parent->_dProto->_primarySpriteNo?\
(effectron->_parent->_dProto->_primarySpriteID + effectron->_stepNo%effectron->_parent->_dProto->_primarySpriteNo):\
effectron->_parent->_dProto->_primarySpriteID)
// ordered sprite from secondary range
#define SECUENTIAL (effectron->_parent->dProto->secondarySpriteNo?\
(effectron->_parent->dProto->secondarySpriteID + effectron->_stepNo%effectron->_parent->dProto->secondarySpriteNo):\
effectron->_parent->dProto->secondarySpriteID)
#define SECUENTIAL (effectron->_parent->_dProto->_secondarySpriteNo?\
(effectron->_parent->_dProto->_secondarySpriteID + effectron->_stepNo%effectron->_parent->_dProto->_secondarySpriteNo):\
effectron->_parent->_dProto->_secondarySpriteID)
// ordered sprite from primary range for exchange
#define SEMIQUENTIAL (effectron->_parent->dProto->primarySpriteNo?\
(effectron->_parent->dProto->primarySpriteID + (effectron->_partno/2)%effectron->_parent->dProto->primarySpriteNo):\
effectron->_parent->dProto->primarySpriteID)
#define SEMIQUENTIAL (effectron->_parent->_dProto->_primarySpriteNo?\
(effectron->_parent->_dProto->_primarySpriteID + (effectron->_partno/2)%effectron->_parent->_dProto->_primarySpriteNo):\
effectron->_parent->_dProto->_primarySpriteID)
/* ===================================================================== *
Color mapping selection
@ -80,7 +80,7 @@ int16 whichColorMap(EffectID eid, const Effectron *const effectron) {
case eAreaSquare:
case eAreaBall:
case eAreaStorm:
rval = (effectron->_parent->effSeq == 0) ? 0 : 1;
rval = (effectron->_parent->_effSeq == 0) ? 0 : 1;
break;
case eAreaBolt:
rval = ((effectron->_partno % 3) == 1) ? 0 : 1;
@ -106,7 +106,7 @@ SPELLSPRITATIONFUNCTION(invisibleSprites) {
}
SPELLSPRITATIONFUNCTION(auraSprites) {
if (effectron->_parent->effSeq)
if (effectron->_parent->_effSeq)
return SECUENTIAL;
return SEQUENTIAL;
}
@ -140,13 +140,13 @@ SPELLSPRITATIONFUNCTION(coneSprites) {
}
SPELLSPRITATIONFUNCTION(ballSprites) {
if (effectron->_parent->effSeq)
if (effectron->_parent->_effSeq)
return SECONDARY;
return PRIMARY;
}
SPELLSPRITATIONFUNCTION(squareSprites) {
if (effectron->_parent->effSeq)
if (effectron->_parent->_effSeq)
return SECONDARY;
return PRIMARY;
}
@ -158,7 +158,7 @@ SPELLSPRITATIONFUNCTION(waveSprites) {
}
SPELLSPRITATIONFUNCTION(stormSprites) {
if (effectron->_parent->effSeq)
if (effectron->_parent->_effSeq)
return SECONDARY;
return PRIMARY;
}

View File

@ -128,27 +128,27 @@ class EffectDisplayPrototype {
static SPELLINITFUNCTION(nullInit) {
}
EffectID ID;
EffectID _ID;
public:
int16 nodeCount;
EffectDisplayPrototype *next;
int16 _nodeCount;
EffectDisplayPrototype *_next;
SpellLocationFunction *location;
SpellSpritationFunction *spriteno;
SpellStatusFunction *status;
SpellHeightFunction *height;
SpellBreadthFunction *breadth;
SpellInitFunction *init;
SpellLocationFunction *_location;
SpellSpritationFunction *_spriteno;
SpellStatusFunction *_status;
SpellHeightFunction *_height;
SpellBreadthFunction *_breadth;
SpellInitFunction *_init;
EffectDisplayPrototype() {
nodeCount = 0;
next = NULL;
location = &nullLocation;
spriteno = &nullSpritation;
status = &nullStatus;
height = &nullHeight;
breadth = &nullBreadth;
init = &nullInit;
_nodeCount = 0;
_next = NULL;
_location = &nullLocation;
_spriteno = &nullSpritation;
_status = &nullStatus;
_height = &nullHeight;
_breadth = &nullBreadth;
_init = &nullInit;
}
EffectDisplayPrototype(
@ -160,14 +160,14 @@ public:
SpellBreadthFunction *newBreadth,
SpellInitFunction *newInit);
~EffectDisplayPrototype() {
if (next) delete next;
next = NULL;
if (_next) delete _next;
_next = NULL;
}
void setID(EffectID i) {
ID = i;
_ID = i;
}
EffectID thisID() {
return ID;
return _ID;
}
};
@ -181,9 +181,9 @@ typedef EffectDisplayPrototype *pEffectDisplayPrototype;
class EffectDisplayPrototypeList {
pEffectDisplayPrototype *effects;
uint16 count;
uint16 maxCount;
pEffectDisplayPrototype *_effects;
uint16 _count;
uint16 _maxCount;
public:
EffectDisplayPrototypeList(int32 c);
@ -227,26 +227,26 @@ enum effectDirectionInit {
// Combines a SpellEffectPrototype with the appropriate sprites
class SpellDisplayPrototype {
SpellID ID;
SpellID _ID;
public:
EffectID effect; // Effect ID
int32 effParm1; // effect setting 1
int32 effParm2; // effect setting 1
int32 effParm3; // effect setting 1
int32 effParm4; // effect setting 1
EffectID _effect; // Effect ID
int32 _effParm1; // effect setting 1
int32 _effParm2; // effect setting 1
int32 _effParm3; // effect setting 1
int32 _effParm4; // effect setting 1
effectDirectionInit scatter; // direction init mode
effectCollisionCont elasticity; // collision flags
effectDirectionInit _scatter; // direction init mode
effectCollisionCont _elasticity; // collision flags
SpellAge maxAge; // auto self-destruct age
SpellAge implementAge; // auto self-destruct age
uint32 primarySpriteID; // RES_ID(x, y, z, 0) to get sprites
uint8 primarySpriteNo; // sprites available
uint32 secondarySpriteID; // RES_ID(x, y, z, 0) to get sprites
uint8 secondarySpriteNo; // sprites available
//uint8 effCount; // effectrons to allocate
SpellAge _maxAge; // auto self-destruct age
SpellAge _implementAge; // auto self-destruct age
uint32 _primarySpriteID; // RES_ID(x, y, z, 0) to get sprites
uint8 _primarySpriteNo; // sprites available
uint32 _secondarySpriteID; // RES_ID(x, y, z, 0) to get sprites
uint8 _secondarySpriteNo; // sprites available
//uint8 _effCount; // effectrons to allocate
uint8 colorMap[4]; // indirect color map
uint8 _colorMap[4]; // indirect color map
// full init
SpellDisplayPrototype(
EffectID, int32, int32, int32, int32, effectDirectionInit,
@ -256,10 +256,10 @@ public:
void getColorTranslation(ColorTable mainColors, Effectron *); // colors for effectrons
void setID(SpellID i) {
ID = i;
_ID = i;
}
SpellID thisID() {
return ID;
return _ID;
}
};
@ -270,9 +270,9 @@ public:
typedef SpellDisplayPrototype *pSpellDisplayPrototype;
class SpellDisplayPrototypeList {
pSpellDisplayPrototype *spells;
uint16 count;
uint16 maxCount;
pSpellDisplayPrototype *_spells;
uint16 _count;
uint16 _maxCount;
public:
SpellDisplayPrototypeList(uint16 s);
@ -292,18 +292,18 @@ public:
class SpellInstance {
friend struct StorageSpellInstance;
SpellAge implementAge; // age at which to implement the spell effects
SpellAge _implementAge; // age at which to implement the spell effects
public:
EffectDisplayPrototype *effect; // effect prototype of the current effect
SpellDisplayPrototype *dProto; // effect prototype of the current effect
SpellCaster *caster;
SpellTarget *target;
GameWorld *world;
SpellAge age;
EffectronList eList;
SpellID spell;
SpellAge maxAge;
int16 effSeq; // which effect in a sequence is being played
EffectDisplayPrototype *_effect; // effect prototype of the current effect
SpellDisplayPrototype *_dProto; // effect prototype of the current effect
SpellCaster *_caster;
SpellTarget *_target;
GameWorld *_world;
SpellAge _age;
EffectronList _eList;
SpellID _spell;
SpellAge _maxAge;
int16 _effSeq; // which effect in a sequence is being played
SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, SpellID);
SpellInstance(SpellCaster *newCaster, GameObject &newTarget, SpellID);
@ -331,10 +331,10 @@ public:
typedef SpellInstance *pSpellInstance;
class SpellDisplayList {
uint16 count;
uint16 maxCount;
uint16 _count;
uint16 _maxCount;
public :
pSpellInstance *spells;
pSpellInstance *_spells;
void init();
void cleanup();
@ -363,42 +363,42 @@ public :
// Some functions that require the above definitions to work
inline GameWorld *Effectron::world() const {
return _parent->world;
return _parent->_world;
}
inline int16 Effectron::getMapNum() const {
return _parent->world->_mapNum;
return _parent->_world->_mapNum;
}
inline EffectID Effectron::spellID() {
return _parent->spell;
return _parent->_spell;
}
inline SpellDisplayPrototype *Effectron::spell() {
return (*g_vm->_sdpList)[(SpellID) spellID()];
return (*g_vm->_sdpList)[(SpellID)spellID()];
}
inline EffectID Effectron::effectID() {
return spell()->effect;
return spell()->_effect;
}
inline EffectDisplayPrototype *Effectron::effect() {
return _parent->effect;
return _parent->_effect;
}
inline EffectronFlags Effectron::staCall() {
return _parent->effect->status(this);
return _parent->_effect->_status(this);
}
inline TilePoint Effectron::posCall() {
return _parent->effect->location(this);
return _parent->_effect->_location(this);
}
inline SpellSpritationSeed Effectron::sprCall() {
return _parent->effect->spriteno(this);
return _parent->_effect->_spriteno(this);
}
inline spellHeight Effectron::hgtCall() {
return _parent->effect->height(this);
return _parent->_effect->_height(this);
}
inline spellBreadth Effectron::brdCall() {
return _parent->effect->breadth(this);
return _parent->_effect->_breadth(this);
}
inline void Effectron::initCall(int16 eno) {
_partno = eno;
_parent->effect->init(this);
_parent->_effect->_init(this);
}
/* ===================================================================== *