Skip to content

Commit

Permalink
adapt to newest sfml
Browse files Browse the repository at this point in the history
  • Loading branch information
vittorioromeo committed Aug 6, 2024
1 parent 88ade05 commit 44de468
Show file tree
Hide file tree
Showing 19 changed files with 202 additions and 82 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ set(SFML_ENABLE_PCH true)
CPMAddPackage(
NAME SFML
GITHUB_REPOSITORY vittorioromeo/SFML
GIT_TAG 0608821ff4e8de462d5aa44343df42d989f8102a
GIT_TAG dd0cc60de5f07f4180821db9b3f89fbc15cdf03f
)

set_target_properties(sfml-system PROPERTIES UNITY_BUILD ON)
Expand Down Expand Up @@ -201,7 +201,7 @@ if(NOT SSVOH_ANDROID)
CPMAddPackage(
NAME imgui-sfml
GITHUB_REPOSITORY vittorioromeo/imgui-sfml
GIT_TAG 32b2c1588b78b2946f8c7c61420fbd8a45ae4e9c
GIT_TAG d65ebaba593dbda0353aab99ace9b895788f727d
)

set_target_properties(ImGui-SFML PROPERTIES UNITY_BUILD ON)
Expand Down
2 changes: 1 addition & 1 deletion build/r_gdb.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
(cp ./SSVOpenHexagon-Console.exe ../_RELEASE ; cd ../_RELEASE && gdb -- ./SSVOpenHexagon-Console.exe "$@")
(cp ./SSVOpenHexagon.exe ../_RELEASE ; cd ../_RELEASE && gdb -- ./SSVOpenHexagon.exe "$@")
4 changes: 3 additions & 1 deletion include/SSVOpenHexagon/Components/CWall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "SSVOpenHexagon/Utils/FastVertexVector.hpp"

#include <SFML/System/Vector2.hpp>
#include <SFML/Base/Math/Cos.hpp>
#include <SFML/Base/Math/Sin.hpp>

#include <array>
#include <cstdint>
Expand Down Expand Up @@ -63,7 +65,7 @@ class CWall
const float rad = getCurveRadians(ft);

moveVertexAlongCurveImpl(
vertex, centerPos, std::sin(rad), std::cos(rad));
vertex, centerPos, sf::base::sin(rad), sf::base::cos(rad));
}

void draw(sf::Color color, Utils::FastVertexVectorTris& wallQuads);
Expand Down
2 changes: 1 addition & 1 deletion include/SSVOpenHexagon/Core/HexagonGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Texture.hpp>

#include <SFML/Window/GraphicsContext.hpp>
#include <SFML/Graphics/GraphicsContext.hpp>

#include <SFML/System/Vector2.hpp>
#include <SFML/System/Clock.hpp>
Expand Down
18 changes: 3 additions & 15 deletions include/SSVOpenHexagon/Core/HexagonServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,8 @@ class HexagonServer

std::optional<GameStatus> _gameStatus;

explicit ConnectedClient(const Utils::SCTimePoint lastActivity)
: _socket{},
_lastActivity{lastActivity},
_consecutiveFailures{0},
_mustDisconnect{false},
_clientPublicKey{},
_loginData{},
_state{State::Disconnected}
{}

~ConnectedClient()
{
_socket.disconnect();
}
explicit ConnectedClient(const Utils::SCTimePoint lastActivity);
~ConnectedClient();
};

std::list<ConnectedClient> _connectedClients;
Expand Down Expand Up @@ -156,7 +144,7 @@ class HexagonServer
const ProtocolVersion& protocolVersion, const GameVersion& gameVersion,
const std::vector<std::string>& supportedLevelValidators);

void kickAndRemoveClient(ConnectedClient& c);
[[nodiscard]] bool kickAndRemoveClient(ConnectedClient& c);

void run();
void runIteration();
Expand Down
2 changes: 1 addition & 1 deletion include/SSVOpenHexagon/Core/MenuGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Texture.hpp>

#include <SFML/Window/GraphicsContext.hpp>
#include <SFML/Graphics/GraphicsContext.hpp>

#include <SFML/System/Vector2.hpp>

Expand Down
43 changes: 38 additions & 5 deletions include/SSVOpenHexagon/Global/PCH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,44 @@
// SFML
// ----------------------------------------------------------------------------

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio/Music.hpp>
#include <SFML/Audio/PlaybackDevice.hpp>
#include <SFML/Audio/SoundBuffer.hpp>

#include <SFML/Base/Optional.hpp>

#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Glsl.hpp>
#include <SFML/Graphics/GraphicsContext.hpp>
#include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/Graphics/Shader.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Texture.hpp>

#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Packet.hpp>
#include <SFML/Network/Packet.hpp>
#include <SFML/Network/TcpListener.hpp>
#include <SFML/Network/TcpListener.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/Network/UdpSocket.hpp>
#include <SFML/Network/UdpSocket.hpp>

#include <SFML/System/Angle.hpp>
#include <SFML/System/Vector2.hpp>

#include <SFML/Window/Joystick.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/VideoMode.hpp>
#include <SFML/Window/VideoModeUtils.hpp>

//
//
Expand Down
2 changes: 1 addition & 1 deletion src/OHServerControl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, char* argv[])

std::string stringBuf;
sf::Packet packet;
sf::UdpSocket controlSocket;
sf::UdpSocket controlSocket(true /* isBlocking */);

const auto sendToServer = [&]
{
Expand Down
9 changes: 5 additions & 4 deletions src/SSVOpenHexagon/Core/HGUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,8 @@ void HexagonGame::updateTrailParticles(float mFT)

p.sprite.setScale(p.sprite.getScale() * 0.98f);

p.sprite.setPosition(
sf::Vector2f::fromAngle(status.radius + 2.4f, sf::radians(p.angle)));
p.sprite.setPosition(sf::Vector2f::fromAngle(
status.radius + 2.4f, sf::radians(p.angle)));
}

if (player.hasChangedAngle())
Expand Down Expand Up @@ -1064,8 +1064,9 @@ void HexagonGame::updateSwapParticles(float mFT)
c.a = alpha;
p.sprite.setColor(c);

p.velocity = sf::Vector2f::fromAngle(ssvu::getRndR(0.1f, 10.f) * speedMult,
sf::radians(si.angle + ssvu::getRndR(-expand, expand)));
p.velocity =
sf::Vector2f::fromAngle(ssvu::getRndR(0.1f, 10.f) * speedMult,
sf::radians(si.angle + ssvu::getRndR(-expand, expand)));

return p;
};
Expand Down
8 changes: 6 additions & 2 deletions src/SSVOpenHexagon/Core/HexagonClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ HexagonClient::HexagonClient(Steam::steam_manager& steamManager,
_ticketSteamID{},
_serverIp{serverIp},
_serverPort{serverPort},
_socket{},
_socket{true /* isBlocking */},
_socketConnected{false},
_packetBuffer{},
_errorOss{},
Expand Down Expand Up @@ -497,7 +497,11 @@ void HexagonClient::disconnect()
(void)sendDisconnect();
}

_socket.disconnect();
if (!_socket.disconnect())
{
SSVOH_CLOG << "Failure disconnecting client socket\n";
}

_socketConnected = false;

SSVOH_CLOG << "Client disconnected\n";
Expand Down
Loading

0 comments on commit 44de468

Please sign in to comment.