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 44de468 commit 2169bcd
Show file tree
Hide file tree
Showing 42 changed files with 389 additions and 383 deletions.
2 changes: 1 addition & 1 deletion 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 dd0cc60de5f07f4180821db9b3f89fbc15cdf03f
GIT_TAG ae249dae3e3de4b1790098a1067c24750921c8ec
)

set_target_properties(sfml-system PROPERTIES UNITY_BUILD ON)
Expand Down
4 changes: 2 additions & 2 deletions include/SSVOpenHexagon/Core/HGStatus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <array>
#include <cstddef>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <string>

namespace hg {
Expand Down Expand Up @@ -78,7 +78,7 @@ struct HexagonGameStatus
bool showPlayerTrail{true};

// Shaders
std::array<std::optional<std::size_t>,
std::array<sf::base::Optional<std::size_t>,
static_cast<std::size_t>(RenderStage::Count)>
fragmentShaderIds;

Expand Down
16 changes: 8 additions & 8 deletions include/SSVOpenHexagon/Core/HexagonClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <SFML/Network/Packet.hpp>

#include <deque>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <sstream>
#include <unordered_set>
#include <variant>
Expand Down Expand Up @@ -84,7 +84,7 @@ class HexagonClient
private:
Steam::steam_manager& _steamManager;

std::optional<std::uint64_t> _ticketSteamID;
sf::base::Optional<std::uint64_t> _ticketSteamID;

const sf::IpAddress _serverIp;
const unsigned short _serverPort;
Expand All @@ -100,13 +100,13 @@ class HexagonClient
bool _verbose;

const SodiumPSKeys _clientPSKeys;
std::optional<SodiumPublicKeyArray> _serverPublicKey;
std::optional<SodiumRTKeys> _clientRTKeys;
sf::base::Optional<SodiumPublicKeyArray> _serverPublicKey;
sf::base::Optional<SodiumRTKeys> _clientRTKeys;

State _state;

std::optional<std::uint64_t> _loginToken;
std::optional<std::string> _loginName;
sf::base::Optional<std::uint64_t> _loginToken;
sf::base::Optional<std::string> _loginName;

std::deque<Event> _events;

Expand Down Expand Up @@ -192,10 +192,10 @@ class HexagonClient
[[nodiscard]] State getState() const noexcept;
[[nodiscard]] bool hasRTKeys() const noexcept;

[[nodiscard]] const std::optional<std::string>&
[[nodiscard]] const sf::base::Optional<std::string>&
getLoginName() const noexcept;

[[nodiscard]] std::optional<Event> pollEvent();
[[nodiscard]] sf::base::Optional<Event> pollEvent();

[[nodiscard]] bool isLevelSupportedByServer(
const std::string& levelValidator) const noexcept;
Expand Down
22 changes: 11 additions & 11 deletions include/SSVOpenHexagon/Core/HexagonGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <sstream>
#include <unordered_set>
#include <functional>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <vector>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -114,7 +114,7 @@ class HexagonGame
std::int8_t steamAttempt{1};

HGAssets& assets;
std::optional<TextUI> textUI;
sf::base::Optional<TextUI> textUI;

Audio* audio;

Expand Down Expand Up @@ -151,16 +151,16 @@ class HexagonGame
float timeUntilRichPresenceUpdate = 0.f;

private:
std::optional<ssvs::Camera> backgroundCamera;
std::optional<ssvs::Camera> overlayCamera;
sf::base::Optional<ssvs::Camera> backgroundCamera;
sf::base::Optional<ssvs::Camera> overlayCamera;

struct PreShakeCenters
{
sf::Vector2f background;
sf::Vector2f overlay;
};

std::optional<PreShakeCenters> preShakeCenters;
sf::base::Optional<PreShakeCenters> preShakeCenters;

const sf::Vector2f centerPos{0.f, 0.f};

Expand Down Expand Up @@ -219,7 +219,7 @@ class HexagonGame
float angle;
};

std::optional<SwapParticleSpawnInfo> swapParticlesSpawnInfo;
sf::base::Optional<SwapParticleSpawnInfo> swapParticlesSpawnInfo;
float nextPBParticleSpawn{0.f};
float pbTextGrowth{0.f};

Expand Down Expand Up @@ -261,7 +261,7 @@ class HexagonGame
explicit ActiveReplay(const replay_file& mReplayFile);
};

std::optional<ActiveReplay> activeReplay;
sf::base::Optional<ActiveReplay> activeReplay;

random_number_generator::seed_type lastSeed{};
replay_data lastReplayData{};
Expand Down Expand Up @@ -347,11 +347,11 @@ class HexagonGame
void initFlashEffect(int r, int g, int b);

// Fast-forward
std::optional<double> fastForwardTarget;
sf::base::Optional<double> fastForwardTarget;
void fastForwardTo(const double target);

// Advance by ticks
std::optional<int> advanceTickCount;
sf::base::Optional<int> advanceTickCount;
void advanceByTicks(const int nTicks);

// Update methods
Expand Down Expand Up @@ -501,10 +501,10 @@ class HexagonGame
float customScore;
};

[[nodiscard]] std::optional<GameExecutionResult> executeGameUntilDeath(
[[nodiscard]] sf::base::Optional<GameExecutionResult> executeGameUntilDeath(
const int maxProcessingSeconds, const float timescale);

[[nodiscard]] std::optional<GameExecutionResult>
[[nodiscard]] sf::base::Optional<GameExecutionResult>
runReplayUntilDeathAndGetScore(const replay_file& mReplayFile,
const int maxProcessingSeconds, const float timescale);

Expand Down
12 changes: 6 additions & 6 deletions include/SSVOpenHexagon/Core/HexagonServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <SFML/Network/UdpSocket.hpp>

#include <list>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <sstream>
#include <string>
#include <unordered_set>
Expand Down Expand Up @@ -69,8 +69,8 @@ class HexagonServer
Utils::SCTimePoint _lastActivity;
int _consecutiveFailures;
bool _mustDisconnect;
std::optional<SodiumPublicKeyArray> _clientPublicKey;
std::optional<SodiumRTKeys> _rtKeys;
sf::base::Optional<SodiumPublicKeyArray> _clientPublicKey;
sf::base::Optional<SodiumRTKeys> _rtKeys;

struct LoginData
{
Expand All @@ -81,7 +81,7 @@ class HexagonServer
std::uint64_t _loginToken;
};

std::optional<LoginData> _loginData;
sf::base::Optional<LoginData> _loginData;

State _state;

Expand All @@ -91,7 +91,7 @@ class HexagonServer
std::string _levelValidator;
};

std::optional<GameStatus> _gameStatus;
sf::base::Optional<GameStatus> _gameStatus;

explicit ConnectedClient(const Utils::SCTimePoint lastActivity);
~ConnectedClient();
Expand Down Expand Up @@ -139,7 +139,7 @@ class HexagonServer
[[nodiscard]] bool sendTopScoresAndOwnScore(ConnectedClient& c,
const std::string& levelValidator,
const std::vector<Database::ProcessedScore>& scores,
const std::optional<Database::ProcessedScore>& ownScore);
const sf::base::Optional<Database::ProcessedScore>& ownScore);
[[nodiscard]] bool sendServerStatus(ConnectedClient& c,
const ProtocolVersion& protocolVersion, const GameVersion& gameVersion,
const std::vector<std::string>& supportedLevelValidators);
Expand Down
4 changes: 2 additions & 2 deletions include/SSVOpenHexagon/Core/LeaderboardCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <string>
#include <vector>
#include <unordered_map>
#include <optional>
#include <SFML/Base/Optional.hpp>

namespace hg {

Expand All @@ -21,7 +21,7 @@ class LeaderboardCache
struct CachedScores
{
std::vector<Database::ProcessedScore> _scores;
std::optional<Database::ProcessedScore> _ownScore;
sf::base::Optional<Database::ProcessedScore> _ownScore;
HRTimePoint _cacheTime;
};

Expand Down
8 changes: 4 additions & 4 deletions include/SSVOpenHexagon/Core/MenuGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <array>
#include <cctype>
#include <functional>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <string_view>
#include <string>
#include <utility>
Expand Down Expand Up @@ -272,9 +272,9 @@ class MenuGame
bool mousePressed{false};
bool mustFavorite{false};
bool mustPlay{false};
std::optional<int> mustChangeIndexTo;
std::optional<int> mustChangePackIndexTo;
std::optional<int> mustUseMenuItem;
sf::base::Optional<int> mustChangeIndexTo;
sf::base::Optional<int> mustChangePackIndexTo;
sf::base::Optional<int> mustUseMenuItem;
bool mouseCursorVisible{true};
sf::Vector2i lastMouseMovedPosition{};

Expand Down
6 changes: 3 additions & 3 deletions include/SSVOpenHexagon/Core/Replay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <cstdint>
#include <cstring>
#include <filesystem>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <string>
#include <vector>

Expand Down Expand Up @@ -161,10 +161,10 @@ struct compressed_replay_file
[[nodiscard]] bool deserialize_from_packet(sf::Packet& p);
};

[[nodiscard]] std::optional<compressed_replay_file> compress_replay_file(
[[nodiscard]] sf::base::Optional<compressed_replay_file> compress_replay_file(
const replay_file& rf);

[[nodiscard]] std::optional<replay_file> decompress_replay_file(
[[nodiscard]] sf::base::Optional<replay_file> decompress_replay_file(
const compressed_replay_file& crf);

} // namespace hg
4 changes: 2 additions & 2 deletions include/SSVOpenHexagon/Core/Steam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <cstdint>
#include <functional>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <string_view>
#include <string>

Expand Down Expand Up @@ -62,7 +62,7 @@ class steam_manager

[[nodiscard]] bool got_encrypted_app_ticket() const noexcept;

[[nodiscard]] std::optional<std::uint64_t>
[[nodiscard]] sf::base::Optional<std::uint64_t>
get_ticket_steam_id() const noexcept;
};

Expand Down
6 changes: 3 additions & 3 deletions include/SSVOpenHexagon/Global/Assets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "SSVOpenHexagon/Utils/UniquePtr.hpp"

#include <cstddef>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <string>
#include <unordered_map>
#include <unordered_set>
Expand Down Expand Up @@ -94,9 +94,9 @@ class HGAssets
[[nodiscard]] sf::Shader* getShader(
const std::string& mPackId, const std::string& mId);

[[nodiscard]] std::optional<std::size_t> getShaderId(
[[nodiscard]] sf::base::Optional<std::size_t> getShaderId(
const std::string& mPackId, const std::string& mId);
[[nodiscard]] std::optional<std::size_t> getShaderIdByPath(
[[nodiscard]] sf::base::Optional<std::size_t> getShaderIdByPath(
const std::string& mShaderPath);
[[nodiscard]] sf::Shader* getShaderByShaderId(const std::size_t mShaderId);
[[nodiscard]] bool isValidShaderId(const std::size_t mShaderId) const;
Expand Down
7 changes: 3 additions & 4 deletions include/SSVOpenHexagon/Global/PCH.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include <list>
#include <map>
#include <memory>
#include <optional>
#include <random>
#include <sstream>
#include <stdexcept>
Expand Down Expand Up @@ -229,9 +228,9 @@

extern template class std::vector<std::string>;

extern template class std::optional<int>;
extern template class std::optional<std::size_t>;
extern template class std::optional<std::string>;
extern template class sf::base::Optional<int>;
extern template class sf::base::Optional<std::size_t>;
extern template class sf::base::Optional<std::string>;

extern template class std::unordered_map<std::string, float>;
extern template class std::unordered_map<float, std::string>;
Expand Down
10 changes: 5 additions & 5 deletions include/SSVOpenHexagon/Online/Database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <string>
#include <cstdint>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <vector>

// TODO (P2): remove reliance on steam ID for future platforms
Expand All @@ -25,7 +25,7 @@ void dumpUsers();

[[nodiscard]] bool anyUserWithName(const std::string& name);

[[nodiscard]] std::optional<User> getUserWithSteamIdAndName(
[[nodiscard]] sf::base::Optional<User> getUserWithSteamIdAndName(
const std::uint64_t steamId, const std::string& name);

void removeAllLoginTokensForUser(const std::uint32_t userId);
Expand All @@ -35,7 +35,7 @@ void addLoginToken(const LoginToken& loginToken);
[[nodiscard]] std::vector<User> getAllUsersWithSteamId(
const std::uint64_t steamId);

[[nodiscard]] std::optional<User> getUserWithSteamId(
[[nodiscard]] sf::base::Optional<User> getUserWithSteamId(
const std::uint64_t steamId);

[[nodiscard]] std::vector<LoginToken> getAllStaleLoginTokens();
Expand All @@ -49,9 +49,9 @@ void removeAllStaleLoginTokens();
void addScore(const std::string& levelValidator, const std::uint64_t timestamp,
const std::uint64_t userSteamId, const double value);

[[nodiscard]] std::optional<ProcessedScore> getScore(
[[nodiscard]] sf::base::Optional<ProcessedScore> getScore(
const std::string& levelValidator, const std::uint64_t userSteamId);

[[nodiscard]] std::optional<std::string> execute(const std::string& query);
[[nodiscard]] sf::base::Optional<std::string> execute(const std::string& query);

} // namespace hg::Database
4 changes: 2 additions & 2 deletions include/SSVOpenHexagon/Online/Shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <sodium.h>

#include <sstream>
#include <optional>
#include <SFML/Base/Optional.hpp>
#include <variant>
#include <string>
#include <vector>
Expand Down Expand Up @@ -113,7 +113,7 @@ struct STCPDeleteAccountSuccess { };
struct STCPDeleteAccountFailure { std::string error; };
struct STCPTopScores { std::string levelValidator; std::vector<Database::ProcessedScore> scores; };
struct STCPOwnScore { std::string levelValidator; Database::ProcessedScore score; };
struct STCPTopScoresAndOwnScore { std::string levelValidator; std::vector<Database::ProcessedScore> scores; std::optional<Database::ProcessedScore> ownScore; };
struct STCPTopScoresAndOwnScore { std::string levelValidator; std::vector<Database::ProcessedScore> scores; sf::base::Optional<Database::ProcessedScore> ownScore; };
struct STCPServerStatus { ProtocolVersion protocolVersion; GameVersion gameVersion; std::vector<std::string> supportedLevelValidators; };
// clang-format on

Expand Down
Loading

0 comments on commit 2169bcd

Please sign in to comment.