Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions source/game/field/obj/ObjectBasabasa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ void ObjectBasabasaDummy::calcState0() {
ObjectBasabasa::ObjectBasabasa(const System::MapdataGeoObj &params)
: ObjectCollidable(params), m_initialTimer(params.setting(1)),
m_batsPerGroup(params.setting(2)), m_startFrame(params.setting(6)),
m_batSpacing(static_cast<u32>(static_cast<f32>(params.setting(5)) /
m_batSpacing(static_cast<s32>(static_cast<f32>(params.setting(5)) /
static_cast<f32>(params.setting(0)) / static_cast<f32>(m_batsPerGroup))) {
f32 railLen = RailManager::Instance()->rail(params.pathId())->getPathLength();
u32 groupCount = static_cast<u32>(railLen / static_cast<f32>(params.setting(0)) /
static_cast<f32>(m_initialTimer)) +
1;
u32 batCount = groupCount * m_batsPerGroup;
u32 batCount = groupCount * static_cast<u32>(m_batsPerGroup);

m_bats = std::span<ObjectBasabasaDummy *>(new ObjectBasabasaDummy *[batCount], batCount);

Expand All @@ -90,8 +90,8 @@ ObjectBasabasa::ObjectBasabasa(const System::MapdataGeoObj &params)
bat->load();
}

s_initialX = params.setting(3);
s_initialY = params.setting(4);
s_initialX = static_cast<f32>(params.setting(3));
s_initialY = static_cast<f32>(params.setting(4));
}

/// @addr{0x806B72F4}
Expand All @@ -114,7 +114,7 @@ void ObjectBasabasa::init() {

/// @addr{0x806B74C4}
void ObjectBasabasa::calc() {
if (System::RaceManager::Instance()->timer() <= m_startFrame) {
if (System::RaceManager::Instance()->timer() <= static_cast<u32>(m_startFrame)) {
return;
}

Expand Down
12 changes: 6 additions & 6 deletions source/game/field/obj/ObjectBasabasa.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ public:

private:
std::span<ObjectBasabasaDummy *> m_bats; ///< The array of individual bats
const u32 m_initialTimer; ///< The m_cycleTimer starts and resets to this value
const u32 m_batsPerGroup; ///< Number of bats that will spawn before resetting the m_cycleTimer
const u32 m_startFrame; ///< Initial delay before the spawner will start calculating
const u32 m_batSpacing; ///< How many frames in between bat spawns
u32 m_cycleTimer; ///< Used to determine when to spawn next bat
u32 m_batsActive; ///< The number of bats currently spawned
const s32 m_initialTimer; ///< The m_cycleTimer starts and resets to this value
const s32 m_batsPerGroup; ///< Number of bats that will spawn before resetting the m_cycleTimer
const s32 m_startFrame; ///< Initial delay before the spawner will start calculating
const s32 m_batSpacing; ///< How many frames in between bat spawns
s32 m_cycleTimer; ///< Used to determine when to spawn next bat
s32 m_batsActive; ///< The number of bats currently spawned
};

} // namespace Field
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectBelt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool ObjectBelt::calcCollision(const EGG::Vector3f &v0, const EGG::Vector3f & /*
if (entry->dist > info->movingFloorDist) {
info->movingFloorDist = entry->dist;
info->roadVelocity = calcRoadVelocity(entry->variant(), v0,
System::RaceManager::Instance()->timer() - timeOffset);
static_cast<s32>(System::RaceManager::Instance()->timer() - timeOffset));
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectBelt.hh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public:
}

[[nodiscard]] virtual EGG::Vector3f calcRoadVelocity(u32 variant, const EGG::Vector3f &pos,
u32 timeOffset) const = 0;
s32 timeOffset) const = 0;

[[nodiscard]] virtual bool isMoving(u32 variant, const EGG::Vector3f &pos) const = 0;

Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectBeltCrossing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ObjectBeltCrossing::~ObjectBeltCrossing() = default;

/// @addr{0x807FC7D8}
EGG::Vector3f ObjectBeltCrossing::calcRoadVelocity(u32 variant, const EGG::Vector3f & /*pos*/,
u32 /*timeOffset*/) const {
s32 /*timeOffset*/) const {
switch (variant) {
case 0:
return -EGG::Vector3f::ex * m_roadVel;
Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectBeltCrossing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public:
~ObjectBeltCrossing() override;

[[nodiscard]] EGG::Vector3f calcRoadVelocity(u32 variant, const EGG::Vector3f &pos,
u32 timeOffset) const override;
s32 timeOffset) const override;

[[nodiscard]] bool isMoving(u32 variant, const EGG::Vector3f &pos) const override;
};
Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectBeltCurveA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ObjectBeltCurveA::~ObjectBeltCurveA() = default;

/// @addr{0x807FC9D4}
EGG::Vector3f ObjectBeltCurveA::calcRoadVelocity(u32 variant, const EGG::Vector3f &pos,
u32 timeOffset) const {
s32 timeOffset) const {
EGG::Vector3f posDelta = pos - m_pos;
posDelta.y = 0.0f;

Expand Down
6 changes: 3 additions & 3 deletions source/game/field/obj/ObjectBeltCurveA.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public:
~ObjectBeltCurveA() override;

[[nodiscard]] EGG::Vector3f calcRoadVelocity(u32 variant, const EGG::Vector3f &pos,
u32 timeOffset) const override;
s32 timeOffset) const override;

/// @addr{0x807FCCA4}
[[nodiscard]] bool isMoving(u32 variant, const EGG::Vector3f & /*pos*/) const override {
Expand All @@ -23,8 +23,8 @@ private:
[[nodiscard]] f32 calcDirSwitchVelocity(u32 t) const;

bool m_startForward;
u16 m_dirChange1Frame;
u16 m_dirChange2Frame;
s32 m_dirChange1Frame;
s32 m_dirChange2Frame;
EGG::Matrix34f m_initMat;
};

Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectBeltEasy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ObjectBeltEasy::~ObjectBeltEasy() = default;

/// @addr{0x807FC62C}
EGG::Vector3f ObjectBeltEasy::calcRoadVelocity(u32 variant, const EGG::Vector3f & /*pos*/,
u32 /*timeOffset*/) const {
s32 /*timeOffset*/) const {
switch (variant) {
case 2:
return EGG::Vector3f::ex * m_roadVel;
Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectBeltEasy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public:

private:
[[nodiscard]] EGG::Vector3f calcRoadVelocity(u32 variant, const EGG::Vector3f &pos,
u32 timeOffset) const override;
s32 timeOffset) const override;

/// @addr{0x807FC6C8}
[[nodiscard]] bool isMoving(u32 variant, const EGG::Vector3f & /*pos*/) const override {
Expand Down
4 changes: 3 additions & 1 deletion source/game/field/obj/ObjectBird.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ObjectBird::ObjectBird(const System::MapdataGeoObj &params) : ObjectCollidable(p
m_leader = new ObjectBirdLeader(params, this);
m_leader->load();

u32 count = params.setting(1);
u32 count = static_cast<u32>(params.setting(1));
if (count == 0) {
count = 5;
}
Expand Down Expand Up @@ -73,6 +73,7 @@ void ObjectBirdLeader::init() {
m_railInterpolator->calc();
m_pos = m_railInterpolator->curPos();
m_flags.setBit(eFlags::Position);
ASSERT(m_mapObj);
m_railInterpolator->setCurrVel(static_cast<f32>(m_mapObj->setting(0)));
}

Expand Down Expand Up @@ -117,6 +118,7 @@ void ObjectBirdFollower::init() {
f32 rate = rand.getF32(static_cast<f32>(frameCount));
anmMgr->playAnim(rate, 1.0f, 0);

ASSERT(m_mapObj);
m_baseSpeed = static_cast<f32>(m_mapObj->setting(0));
m_velocity = EGG::Vector3f::ez * m_baseSpeed;

Expand Down
15 changes: 5 additions & 10 deletions source/game/field/obj/ObjectBulldozer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ namespace Field {

/// @addr{0x807FD938}
ObjectBulldozer::ObjectBulldozer(const System::MapdataGeoObj &params)
: ObjectKCL(params), m_initialPos(m_pos), m_initialRot(m_rot) {
m_timeOffset = params.setting(3) * 2;
m_periodDenom = std::max<u16>(2, params.setting(2));
m_restFrames = params.setting(4);
m_amplitude = params.setting(1);
m_left = (strcmp(getName(), "bulldozer_left") == 0);
m_fullPeriod = m_periodDenom + m_restFrames * 2;
m_halfPeriod = m_fullPeriod / 2;
m_period = F_TAU / static_cast<f32>(m_periodDenom);
}
: ObjectKCL(params), m_initialPos(m_pos), m_initialRot(m_rot),
m_timeOffset(params.setting(3) * 2), m_periodDenom(std::max<s16>(2, params.setting(2))),
m_restFrames(params.setting(4)), m_fullPeriod(m_periodDenom + m_restFrames * 2),
m_amplitude(params.setting(1)), m_left(strcmp(getName(), "bulldozer_left") == 0),
m_period(F_TAU / static_cast<f32>(m_periodDenom)), m_halfPeriod(m_fullPeriod / 2) {}

/// @addr{0x807FE5F0}
ObjectBulldozer::~ObjectBulldozer() = default;
Expand Down
16 changes: 8 additions & 8 deletions source/game/field/obj/ObjectBulldozer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public:

const EGG::Vector3f m_initialPos;
const EGG::Vector3f m_initialRot;
u16 m_timeOffset;
u16 m_periodDenom;
u16 m_restFrames; ///< How long bulldozers stop moving for
u16 m_fullPeriod; ///< m_periodDenom + 2 * m_restFrames
u16 m_amplitude;
bool m_left; ///< Flips the sin wave direction.
f32 m_period;
u16 m_halfPeriod;
const s16 m_timeOffset;
const s16 m_periodDenom;
const s16 m_restFrames; ///< How long bulldozers stop moving for
const s16 m_fullPeriod; ///< m_periodDenom + 2 * m_restFrames
const s16 m_amplitude;
const bool m_left; ///< Flips the sin wave direction.
const f32 m_period;
const s16 m_halfPeriod;
EGG::Matrix34f m_rtMat; ///< Exists solely so getUpdatedMatrix can return a reference.
};

Expand Down
5 changes: 2 additions & 3 deletions source/game/field/obj/ObjectCarA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Field {
ObjectCarA::ObjectCarA(const System::MapdataGeoObj &params)
: ObjectCollidable(params), StateManager(this, STATE_ENTRIES),
m_finalVel(static_cast<f32>(params.setting(0))),
m_accel(static_cast<f32>(params.setting(1)) / 10.0f),
m_stopTime(static_cast<u32>(params.setting(2))) {}
m_accel(static_cast<f32>(params.setting(1)) / 10.0f), m_stopTime(params.setting(2)) {}

/// @addr{0x806B78CC}
ObjectCarA::~ObjectCarA() = default;
Expand Down Expand Up @@ -96,7 +95,7 @@ void ObjectCarA::enterCruising() {

/// @addr{0x806B8588}
void ObjectCarA::calcStop() {
if (m_currentFrame > m_stopTime) {
if (m_currentFrame > static_cast<u32>(m_stopTime)) {
m_motionState = MotionState::Accelerating;
m_currentStateId = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectCarA.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private:

const f32 m_finalVel;
const f32 m_accel;
const u32 m_stopTime;
const s32 m_stopTime;
f32 m_cruiseTime; ///< How long to spend at cruising speed before decelerating.
EGG::Vector3f m_currTangent; ///< It's @ref EGG::Vector3f::ey unless it flies up in the air.
EGG::Vector3f m_currUp; ///< It's @ref EGG::Vector3f::ey unless it flies up in the air.
Expand Down
14 changes: 6 additions & 8 deletions source/game/field/obj/ObjectCarTGE.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ namespace Field {
/// @addr{0x806D5EE4}
ObjectCarTGE::ObjectCarTGE(const System::MapdataGeoObj &params)
: ObjectCollidable(params), StateManager(this, STATE_ENTRIES), m_auxCollision(nullptr),
m_carName{}, m_mdlName{}, m_carType(CarType::Normal), m_dummyId(ObjectId::None),
m_highwayVel(static_cast<f32>(params.setting(2))),
m_localVel(static_cast<f32>(params.setting(1))), m_carName{}, m_mdlName{},
m_carType(CarType::Normal), m_dummyId(ObjectId::None),
m_scaledTangentDir(EGG::Vector3f::zero), m_currSpeed(0.0f), m_up(EGG::Vector3f::zero),
m_tangent(EGG::Vector3f::zero) {
u32 carVariant = static_cast<u32>(params.setting(3));
m_highwayVel = static_cast<f32>(params.setting(2));
m_localVel = static_cast<f32>(params.setting(1));

s16 pathId = params.pathId();

// The base game returns before the StateManager sets its state entries.
// Since we handle this in the template specialization's constructor in Kinoko,
// we need to reset the StateManager parameters back to their default values before returning.
s16 pathId = params.pathId();
if (pathId == -1) {
m_nextStateId = -1;
m_currentStateId = 0;
Expand All @@ -50,6 +47,7 @@ ObjectCarTGE::ObjectCarTGE(const System::MapdataGeoObj &params)
}

const auto *resourceName = getResources();
s32 carVariant = params.setting(3);

switch (carVariant) {
case 0: {
Expand Down Expand Up @@ -111,7 +109,7 @@ void ObjectCarTGE::init() {
return;
}

u16 idx = m_mapObj->setting(0);
u16 idx = static_cast<u16>(m_mapObj->setting(0));
m_railInterpolator->init(0.0f, idx);

auto *rail = RailManager::Instance()->rail(m_mapObj->pathId());
Expand Down
4 changes: 2 additions & 2 deletions source/game/field/obj/ObjectCarTGE.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ private:

const ObjectHighwayManager *m_highwayMgr;
ObjectCollisionBase *m_auxCollision;
f32 m_highwayVel; ///< Speed while on the highway
f32 m_localVel; ///< Speed while off the highway
const f32 m_highwayVel; ///< Speed while on the highway
const f32 m_localVel; ///< Speed while off the highway
char m_carName[32];
char m_mdlName[32];
CarType m_carType; ///< Car, truck, or bomb car
Expand Down
10 changes: 4 additions & 6 deletions source/game/field/obj/ObjectChoropu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ namespace Field {

/// @addr{0x806B96A0}
ObjectChoropu::ObjectChoropu(const System::MapdataGeoObj &params)
: ObjectCollidable(params), StateManager(this, STATE_ENTRIES) {
: ObjectCollidable(params), StateManager(this, STATE_ENTRIES),
m_startFrameOffset(params.setting(1)), m_idleDuration(params.setting(0)),
m_isStationary(strcmp(getName(), "choropu") != 0) {
constexpr f32 MAX_SPEED = 20.0f;

m_startFrameOffset = static_cast<s16>(params.setting(1));
m_idleDuration = params.setting(0);
m_isStationary = strcmp(getName(), "choropu") != 0;

s16 railIdx = params.pathId();
if (railIdx != -1) {
auto *rail = RailManager::Instance()->rail(railIdx);
Expand Down Expand Up @@ -172,7 +170,7 @@ void ObjectChoropu::calcStateStub() {}
/// @addr{0x806BA7FC}
void ObjectChoropu::calcDigging() {
if (m_isStationary) {
if (m_currentFrame > m_idleDuration) {
if (m_currentFrame > static_cast<u32>(m_idleDuration)) {
m_nextStateId = 1;
}

Expand Down
6 changes: 3 additions & 3 deletions source/game/field/obj/ObjectChoropu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ private:

std::span<ObjectChoropuGround *> m_groundObjs;
ObjectChoropuHoll *m_objHoll;
s16 m_startFrameOffset;
u16 m_idleDuration;
const s16 m_startFrameOffset;
const s16 m_idleDuration;
f32 m_groundHeight;
bool m_isStationary; ///< rPG moles don't move while MMM moles do
const bool m_isStationary; ///< rPG moles don't move while MMM moles do
EGG::Matrix34f m_transMat;
EGG::Matrix34f m_railMat;
f32 m_groundLength;
Expand Down
13 changes: 6 additions & 7 deletions source/game/field/obj/ObjectCow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
namespace Field {

/// @addr{0x806BBEC0}
ObjectCow::ObjectCow(const System::MapdataGeoObj &params) : ObjectCollidable(params) {
m_startFrame = params.setting(2);
}
ObjectCow::ObjectCow(const System::MapdataGeoObj &params)
: ObjectCollidable(params), m_startFrame(params.setting(2)) {}

/// @addr{0x806BBF24}
ObjectCow::~ObjectCow() = default;
Expand Down Expand Up @@ -114,6 +113,7 @@ void ObjectCowLeader::init() {

setTarget(m_pos + m_railInterpolator->curTangentDir() * 10.0f);

ASSERT(m_mapObj);
m_railInterpolator->setCurrVel(static_cast<f32>(m_mapObj->setting(1)));

m_railSpeed = 0.0f;
Expand All @@ -128,7 +128,7 @@ void ObjectCowLeader::init() {
void ObjectCowLeader::calc() {
u32 t = System::RaceManager::Instance()->timer();

if (t >= m_startFrame) {
if (t >= static_cast<u32>(m_startFrame)) {
StateManager::calc();
}

Expand Down Expand Up @@ -283,7 +283,7 @@ void ObjectCowFollower::init() {
void ObjectCowFollower::calc() {
u32 t = System::RaceManager::Instance()->timer();

if (t < m_startFrame) {
if (t < static_cast<u32>(m_startFrame)) {
if (m_currentFrame > m_waitFrames) {
m_nextStateId = 1;
}
Expand Down Expand Up @@ -432,11 +432,10 @@ void ObjectCowFollower::calcFollowLeader() {
ObjectCowHerd::ObjectCowHerd(const System::MapdataGeoObj &params) : ObjectCollidable(params) {
constexpr f32 FOLLOWER_SPACING = 600.0f;

u8 followerCount = params.setting(0);

m_leader = new ObjectCowLeader(params);
m_leader->load();

u8 followerCount = static_cast<u8>(params.setting(0));
m_followers =
std::span<ObjectCowFollower *>(new ObjectCowFollower *[followerCount], followerCount);

Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectCow.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected:
return v0 + (v1 - v0) * t;
}

u32 m_startFrame; ///< The frame the cow will start moving
const s32 m_startFrame; ///< The frame the cow will start moving
EGG::Vector3f m_tangent;
EGG::Vector3f m_prevTangent;
EGG::Vector3f m_up;
Expand Down
2 changes: 1 addition & 1 deletion source/game/field/obj/ObjectCrab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Field {

/// @addr{0x8088344C}
ObjectCrab::ObjectCrab(const System::MapdataGeoObj &params)
: ObjectCollidable(params), m_vel(static_cast<f32>(static_cast<s16>(params.setting(0)))),
: ObjectCollidable(params), m_vel(static_cast<f32>(params.setting(0))),
m_backwards(!!params.setting(1)), m_introCalc(false) {}

/// @addr{0x808837B8}
Expand Down
Loading