Skip to content

Commit

Permalink
tweak accuracy error calc for buried balls
Browse files Browse the repository at this point in the history
fix array bounds error for clubset limiter
  • Loading branch information
fallahn committed Sep 15, 2023
1 parent fc6a17d commit 6d139dc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
4 changes: 2 additions & 2 deletions samples/golf/buildnumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BUILD_NUMBER_H_
#define BUILD_NUMBER_H_

#define BUILDNUMBER 1769
#define BUILDNUMBER_STR "1769"
#define BUILDNUMBER 1773
#define BUILDNUMBER_STR "1773"

#endif /* BUILD_NUMBER_H_ */
4 changes: 2 additions & 2 deletions samples/golf/src/GolfGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,9 @@ bool GolfGame::initialise()
#ifdef CRO_DEBUG_
//m_stateStack.pushState(StateID::DrivingRange); //can't go straight to this because menu needs to parse avatar data
//m_stateStack.pushState(StateID::Bush);
m_stateStack.pushState(StateID::Clubhouse);
//m_stateStack.pushState(StateID::Clubhouse);
//m_stateStack.pushState(StateID::SplashScreen);
//m_stateStack.pushState(StateID::Menu);
m_stateStack.pushState(StateID::Menu);
//m_stateStack.pushState(StateID::Workshop);
#else
m_stateStack.pushState(StateID::SplashScreen);
Expand Down
9 changes: 9 additions & 0 deletions samples/golf/src/golf/GolfState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,11 @@ void GolfState::handleMessage(const cro::Message& msg)
msg3->type = (power > PowerShot && club < ClubID::NineIron) ? GolfEvent::PowerShot : GolfEvent::NiceShot;
msg3->position = m_currentPlayer.position;

if (msg3->type == GolfEvent::PowerShot)
{
m_activeAvatar->ballModel.getComponent<cro::ParticleEmitter>().start();
}

//award more XP for aiming straight
float dirAmount = /*cro::Util::Easing::easeOutExpo*/((m_inputParser.getMaxRotation() - std::abs(m_inputParser.getRotation())) / m_inputParser.getMaxRotation());

Expand All @@ -998,6 +1003,8 @@ void GolfState::handleMessage(const cro::Message& msg)
auto* msg3 = cro::App::getInstance().getMessageBus().post<GolfEvent>(MessageID::GolfMessage);
msg3->type = GolfEvent::PowerShot;
msg3->position = m_currentPlayer.position;

m_activeAvatar->ballModel.getComponent<cro::ParticleEmitter>().start();
}

//hide the ball briefly to hack around the motion lag
Expand Down Expand Up @@ -4785,6 +4792,8 @@ void GolfState::spawnBall(const ActorInfo& info)
entity.addComponent<ClientCollider>();
entity.addComponent<cro::Model>(m_resources.meshes.getMesh(m_ballResources.ballMeshID), material);
entity.getComponent<cro::Model>().setRenderFlags(~RenderFlags::MiniMap);

entity.addComponent<cro::ParticleEmitter>().settings.loadFromFile("assets/golf/particles/rockit.cps", m_resources.textures);

entity.addComponent<cro::Callback>().function =
[](cro::Entity e, float dt)
Expand Down
4 changes: 2 additions & 2 deletions samples/golf/src/golf/GolfStateUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3426,9 +3426,9 @@ void GolfState::showMessageBoard(MessageBoardID messageType, bool special)
{
textEnt3.getComponent<cro::Text>().setString("Nice Putt!");
textEnt3.getComponent<cro::Text>().setFillColour(TextGoldColour);
textEnt3.getComponent<cro::Transform>().move({ 0.f, -10.f });
textEnt3.getComponent<cro::Transform>().move({ 0.f, -11.f });

textEnt.getComponent<cro::Transform>().move({ 0.f, 2.f, 0.f });
textEnt.getComponent<cro::Transform>().move({ 0.f, 3.f, 0.f });
}

//overwrite special text if this is a forfeit
Expand Down
2 changes: 1 addition & 1 deletion samples/golf/src/golf/InputParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ float InputParser::getHook() const
&& m_lie == 0)
{
//TODO include the current player/CPU skill level here?
hook = std::min(1.f, hook * 1.02f);
hook = std::min(1.f, hook * (1.f + (hook * 0.04f)));
}

return hook * 2.f - 1.f;
Expand Down
14 changes: 13 additions & 1 deletion samples/golf/src/golf/server/ServerLobbyState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,19 @@ void LobbyState::netEvent(const net::NetEvent& evt)
case PacketID::ClubLevel:
{
auto data = evt.packet.as<std::uint16_t>();
m_sharedData.clubLevels[(data & 0xff00) >> 8] = (data & 0xff);
auto idx = ((data & 0xff00) >> 8);

//TODO sending our own here returns 255 as
//it happens before gaining a client ID...
//is this true for other connections?
if (idx < ConstVal::MaxClients)
{
m_sharedData.clubLevels[idx] = (data & 0xff);
}
else
{
LogW << "Got Club Level placket from client ID " << (int)idx << std::endl;
}
}
break;
case PacketID::RequestGameStart:
Expand Down

0 comments on commit 6d139dc

Please sign in to comment.