[Scummvm-git-logs] scummvm master -> 0e0c4566122e8512d6bca651d4bbc64e2bf554fe
sev-
sev at scummvm.org
Tue Jul 6 14:02:17 UTC 2021
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
abaf4c3ddd SAGA2: Fix initialization of SpellTarget. CID 1457848, CID 1457849
d4c8cfb80d SAGA2: Properly set actor assignment on loading. CID 1457852, CID 1457891
aa12af7e1a SAGA2: Fix Band initialization. CID 1457853, CID 1457980
7c909cd569 SAGA2: Properly initialize TileIterator. CID 1457854
84fbbc156c SAGA2: Move mixer assignment to constructor. CID 1457855
0e0c456612 SAGA2: Replace rand() with _random
Commit: abaf4c3ddd351de237d863c0aeb020aa7ab75db7
https://github.com/scummvm/scummvm/commit/abaf4c3ddd351de237d863c0aeb020aa7ab75db7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T14:40:29+02:00
Commit Message:
SAGA2: Fix initialization of SpellTarget. CID 1457848, CID 1457849
Changed paths:
engines/saga2/speldefs.h
diff --git a/engines/saga2/speldefs.h b/engines/saga2/speldefs.h
index 9e27a4c5a3..98e557f2f3 100644
--- a/engines/saga2/speldefs.h
+++ b/engines/saga2/speldefs.h
@@ -161,11 +161,12 @@ public:
SpellTarget() {
type = spellTargetNone;
- obj = NULL;
+ obj = nullptr;
loc.u = 0;
loc.v = 0;
loc.z = 0;
- next = NULL;
+ next = nullptr;
+ tag = nullptr;
}
// This constructor is for non-tracking targets
@@ -173,25 +174,29 @@ public:
type = spellTargetObjectPoint;
loc = object.getWorldLocation();
loc.z += object.proto()->height / 2;
- next = NULL;
+ next = nullptr;
obj = &object;
+ tag = nullptr;
}
// This constructor is for tracking targets
SpellTarget(GameObject *object) {
type = spellTargetObject;
obj = object;
- next = NULL;
+ next = nullptr;
+ tag = nullptr;
}
SpellTarget(TilePoint &tp) {
type = spellTargetPoint;
loc = tp;
- next = NULL;
+ next = nullptr;
+ tag = nullptr;
}
SpellTarget(ActiveItem *ai) {
type = spellTargetTAG;
tag = ai;
- next = NULL;
+ next = nullptr;
+ tag = nullptr;
}
SpellTarget(StorageSpellTarget &sst);
@@ -212,8 +217,9 @@ public:
}
~SpellTarget() {
- if (next) delete next;
- next = NULL;
+ if (next)
+ delete next;
+ next = nullptr;
};
TilePoint getPoint(void) {
Commit: d4c8cfb80d39e603425386ec228eab08e87b3451
https://github.com/scummvm/scummvm/commit/d4c8cfb80d39e603425386ec228eab08e87b3451
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T15:01:04+02:00
Commit Message:
SAGA2: Properly set actor assignment on loading. CID 1457852, CID 1457891
Changed paths:
engines/saga2/actor.cpp
engines/saga2/actor.h
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 177d553829..33487f030b 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1254,8 +1254,9 @@ Actor::Actor(void **buf) : GameObject(buf) {
bufferPtr = &a[1];
if (flags & hasAssignment) {
- delete _assignment;
bufferPtr = constructAssignment(this, bufferPtr);
+ } else {
+ _assignment = nullptr;
}
appearance = NULL;
diff --git a/engines/saga2/actor.h b/engines/saga2/actor.h
index da0711a36f..f648d10907 100644
--- a/engines/saga2/actor.h
+++ b/engines/saga2/actor.h
@@ -768,7 +768,7 @@ public:
ActorAssignment *getAssignment(void) {
return flags & hasAssignment
? _assignment
- : NULL;
+ : nullptr;
}
// determine wether this actor has a specified property
Commit: aa12af7e1aff260473988574d71210e72d60fce8
https://github.com/scummvm/scummvm/commit/aa12af7e1aff260473988574d71210e72d60fce8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T15:01:22+02:00
Commit Message:
SAGA2: Fix Band initialization. CID 1457853, CID 1457980
Changed paths:
engines/saga2/band.cpp
diff --git a/engines/saga2/band.cpp b/engines/saga2/band.cpp
index 7fd0def6ec..3421754784 100644
--- a/engines/saga2/band.cpp
+++ b/engines/saga2/band.cpp
@@ -333,14 +333,19 @@ void cleanupBands(void) {
Band::Band() : leader(nullptr), memberCount(0) {
g_vm->_bandList->addBand(this);
+
+ for (int i = 0; i < maxBandMembers; i++)
+ members[i] = nullptr;
}
Band::Band(Actor *l) : leader(l), memberCount(0) {
g_vm->_bandList->addBand(this);
+
+ for (int i = 0; i < maxBandMembers; i++)
+ members[i] = nullptr;
}
Band::Band(void **buf) {
void *bufferPtr = *buf;
- int16 i;
// Restore the leader pointer
assert(isActor(*((ObjectID *)bufferPtr)));
@@ -352,8 +357,11 @@ Band::Band(void **buf) {
memberCount = *((int16 *)bufferPtr);
bufferPtr = (int16 *)bufferPtr + 1;
+ for (int i = 0; i < maxBandMembers; i++)
+ members[i] = nullptr;
+
// Restore the member pointers
- for (i = 0; i < memberCount; i++) {
+ for (int i = 0; i < memberCount; i++) {
assert(isActor(*((ObjectID *)bufferPtr)));
members[i] = (Actor *)GameObject::objectAddress(
*((ObjectID *)bufferPtr));
Commit: 7c909cd569a5e226174ea4bb49fab73e8e839732
https://github.com/scummvm/scummvm/commit/7c909cd569a5e226174ea4bb49fab73e8e839732
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T15:01:22+02:00
Commit Message:
SAGA2: Properly initialize TileIterator. CID 1457854
Changed paths:
engines/saga2/tile.h
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 090b42f020..b92dd87bc1 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -956,6 +956,9 @@ public:
TileIterator(int16 mapNum, const TileRegion ®) :
metaIter(mapNum, reg),
region(reg) {
+ mt = nullptr;
+ platIndex = 0;
+ platform = nullptr;
}
TileInfo *first(TilePoint *loc, StandingTileInfo *stiResult = NULL);
Commit: 84fbbc156cf81674ce19229c2f1c41a152bc2aa3
https://github.com/scummvm/scummvm/commit/84fbbc156cf81674ce19229c2f1c41a152bc2aa3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T15:01:22+02:00
Commit Message:
SAGA2: Move mixer assignment to constructor. CID 1457855
Changed paths:
engines/saga2/audio.cpp
diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index fa1ae5bcee..2f7a6645be 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -545,6 +545,7 @@ void cleanupAudio() {
audioInterface::audioInterface() {
_music = nullptr;
+ _mixer = g_system->getMixer();
}
audioInterface::~audioInterface() {
@@ -552,7 +553,6 @@ audioInterface::~audioInterface() {
}
void audioInterface::initAudioInterface(hResContext *musicContext) {
- _mixer = g_system->getMixer();
_music = new Music(musicContext, _mixer);
}
Commit: 0e0c4566122e8512d6bca651d4bbc64e2bf554fe
https://github.com/scummvm/scummvm/commit/0e0c4566122e8512d6bca651d4bbc64e2bf554fe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:02:00+02:00
Commit Message:
SAGA2: Replace rand() with _random
Changed paths:
engines/saga2/actor.cpp
diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 33487f030b..368ffc7dd1 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -396,7 +396,7 @@ bool ActorProto::acceptDamageAction(
if (dice)
for (int d = 0; d < ABS(dice); d++)
- damage += ((rand() % sides) + pdm + 1) * (dice > 0 ? 1 : -1);
+ damage += (g_vm->_rnd->getRandomNumber(sides - 1) + pdm + 1) * (dice > 0 ? 1 : -1);
}
if (damage > 0 && resistant)
@@ -436,7 +436,7 @@ bool ActorProto::acceptDamageAction(
Location al = Location(a->getLocation(), a->IDParent());
if (gruntStyle > 0
&& ((flags & ResourceObjectPrototype::objPropNoSurface)
- || (damage > 2 && (rand() % vitality) < (damage * 2))))
+ || (damage > 2 && g_vm->_rnd->getRandomNumber(vitality - 1) < (damage * 2))))
makeGruntSound(gruntStyle, al);
if (enactorPtr != NULL) {
@@ -570,7 +570,7 @@ bool ActorProto::acceptStrikeAction(
hitChance = MAX<uint8>(hitChance, 5);
// Randomly determine hit success
- if (rand() % toHitBase < hitChance) {
+ if (g_vm->_rnd->getRandomNumber(toHitBase - 1) < hitChance) {
// Hit has succeeded
GameObject *blockingObj = a->blockingObject(enactorPtr);
@@ -583,7 +583,7 @@ bool ActorProto::acceptStrikeAction(
- (int)blockingObj->proto()->getSkillValue(dObj))
* skillScalingFactor;
- if (rand() % toHitBase >= hitChance) {
+ if (g_vm->_rnd->getRandomNumber(toHitBase - 1) >= hitChance) {
// The shield was hit
blockingObj->acceptStrike(
enactor,
@@ -606,8 +606,8 @@ bool ActorProto::acceptStrikeAction(
if (!a->isDead()) {
int16 pmass = a->proto()->mass;
- if (pmass <= 100 || (rand() % 156) >= pmass - 100) {
- if ((rand() & 0x7) == 0)
+ if (pmass <= 100 || g_vm->_rnd->getRandomNumber(154) >= pmass - 100) {
+ if (g_vm->_rnd->getRandomNumber(7) == 0)
MotionTask::fallDown(*a, *enactorPtr);
else
MotionTask::acceptHit(*a, *enactorPtr);
@@ -787,7 +787,7 @@ void ActorProto::doBackgroundUpdate(GameObject *obj) {
} else {
// If the actor has failed morale there is a random
// chance of him regaining his courage
- if ((a->flags & Actor::afraid) && rand() % 128 == 0)
+ if ((a->flags & Actor::afraid) && g_vm->_rnd->getRandomNumber(127) == 0)
a->flags &= ~Actor::afraid;
}
}
@@ -839,7 +839,7 @@ void ActorProto::applySkillGrowth(ObjectID enactor, uint8 points) {
player->skillAdvance(skillIDBludgeon, points);
- if (rand() & 1)
+ if (g_vm->_rnd->getRandomNumber(1))
player->skillAdvance(skillIDBrawn, points);
}
}
@@ -2109,7 +2109,7 @@ bool Actor::nextAnimationFrame(void) {
if (animationFlags & animateRandom) {
// Select a random frame from the series.
- currentPose = rand() % numPoses;
+ currentPose = g_vm->_rnd->getRandomNumber(numPoses - 1);
} else if (animationFlags & animateReverse) {
// Note that the logic for forward repeats is slightly
// different for reverse repeats. Specifically, the
@@ -2306,7 +2306,7 @@ void Actor::updateAppearance(int32) {
}
} else //Assume -1
if (nextAnimationFrame())//If Last Frame In Wait Animation
- cycleCount = rand() % 20;
+ cycleCount = g_vm->_rnd->getRandomNumber(19);
}
}
} else {
@@ -2709,7 +2709,7 @@ void Actor::handleDamageTaken(uint8 damage) {
&& !hasEffect(actorRepelUndead)) {
if (flags & afraid) {
// Let's give monsters a small chance of regaining their courage
- if ((uint16)rand() <= 0x3fff)
+ if ((uint16)g_vm->_rnd->getRandomNumber(65534) <= 0x3fff)
flags &= ~afraid;
} else {
int16 i,
@@ -2745,7 +2745,7 @@ void Actor::handleDamageTaken(uint8 damage) {
moraleBase -= bonus * moraleBase >> 16;
// Test this actor's morale
- if ((uint16)rand() <= moraleBase)
+ if ((uint16)g_vm->_rnd->getRandomNumber(65534) <= moraleBase)
flags |= afraid;
}
}
@@ -2864,7 +2864,7 @@ void Actor::evaluateMeleeAttack(Actor *attacker) {
if (canBlockWithSecondary) {
// If we can block with either primary or secondary
// there is a 25% chance of using the secondary
- defenseObj = ((rand() & 0x3) != 0) ? primary : secondary;
+ defenseObj = (g_vm->_rnd->getRandomNumber(3) != 0) ? primary : secondary;
} else {
// The primary defensive object will be used
defenseObj = primary;
@@ -3015,7 +3015,7 @@ void Actor::removeFollower(Actor *bandMember) {
moraleBase -= moraleBase * moraleBonus >> 16;
- if ((uint16)rand() <= moraleBase)
+ if ((uint16)g_vm->_rnd->getRandomNumber(65534) <= moraleBase)
follower->flags |= afraid;
}
}
@@ -3143,7 +3143,7 @@ void Actor::useKnowledge(scriptCallFrame &scf) {
if (pri > 0) {
// Add a bit of jitter to response
- pri += rand() & 3;
+ pri += g_vm->_rnd->getRandomNumber(3);
if (pri > bestResponsePri) {
bestResponsePri = pri;
@@ -3317,11 +3317,7 @@ bool areActorsInitialized(void) {
}
int16 GetRandomBetween(int start, int end) {
- // Here's a more efficient way to express this.
-
- if (start == end) return start;
- else return (rand() % ABS(end - start)) + start;
-
+ g_vm->_rnd->getRandomNumberRng(start, end);
}
void updateActorStates(void) {
More information about the Scummvm-git-logs
mailing list