From 3b378cf7c50ba725c46127b8533f87207ddf7c50 Mon Sep 17 00:00:00 2001 From: dank meme Date: Thu, 7 Dec 2023 12:28:43 -0800 Subject: [PATCH] macos compiles --- CMakeLists.txt | 9 ++++++--- src/managers/game_server_manager.cpp | 6 +++++- src/ui/error_check_node.cpp | 8 ++++++++ src/ui/hooks/play_layer.hpp | 13 +++++++++++-- src/ui/menu/main/signup_popup.cpp | 7 +++++++ src/ui/menu/player_list/player_list_popup.cpp | 19 ------------------- .../server_switcher/server_test_popup.cpp | 2 +- src/util/debugging.cpp | 4 ++-- 8 files changed, 40 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e078cd1b..adf40fbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,12 +50,15 @@ target_include_directories(${PROJECT_NAME} PRIVATE src/) # libcurl ssl support if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - # on windows we just use schannel, no extra setup + # on windows we just use schannel (built into windows) set(CURL_USE_SCHANNEL ON) set(CURL_USE_OPENSSL OFF) +elseif(APPLE) + # on mac we use sectransp (built into mac) + set(CURL_USE_SECTRANP ON) + set(CURL_USE_OPENSSL OFF) elseif(ANDROID) - # on android we use geode provided openssl library and our own headers - set(CURL_USE_SCHANNEL OFF) + # on android we use geode provided openssl library and our own headers (see android-build.md) set(CURL_USE_OPENSSL ON) set(OPENSSL_ROOT_DIR "${CMAKE_SOURCE_DIR}/libs/openssl") set(OPENSSL_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/libs/openssl/include") diff --git a/src/managers/game_server_manager.cpp b/src/managers/game_server_manager.cpp index 1cc5a97c..851a8e7f 100644 --- a/src/managers/game_server_manager.cpp +++ b/src/managers/game_server_manager.cpp @@ -21,8 +21,12 @@ void GameServerManager::addServer(const std::string& serverId, const std::string .playerCount = 0, }; + GameServerManager::GameServerData gsdata = { + .server = server + }; + auto data = _data.lock(); - data->servers.insert(std::make_pair(serverId, server)); + data->servers[serverId] = gsdata; } void GameServerManager::clear() { diff --git a/src/ui/error_check_node.cpp b/src/ui/error_check_node.cpp index 46a3aa9c..91bb186c 100644 --- a/src/ui/error_check_node.cpp +++ b/src/ui/error_check_node.cpp @@ -19,9 +19,17 @@ void ErrorCheckNode::updateErrors(float) { auto* currentLayer = currentScene->getChildren()->objectAtIndex(0); // do nothing during transitions or loading + // TODO mac issues.. + /* + ld: undefined symbols + typeinfo for cocos2d::CCTransitionScene, referenced from: + */ + +#ifndef GLOBED_MAC if (typeinfo_cast(currentScene) || typeinfo_cast(currentLayer)) { return; } +#endif auto warnings = ErrorQueues::get().getWarnings(); diff --git a/src/ui/hooks/play_layer.hpp b/src/ui/hooks/play_layer.hpp index 4b2911e7..15a767a9 100644 --- a/src/ui/hooks/play_layer.hpp +++ b/src/ui/hooks/play_layer.hpp @@ -72,8 +72,10 @@ class $modify(GlobedPlayLayer, PlayLayer) { if (!m_fields->globedReady) return; +#if GLOBED_HAS_VOICE GlobedAudioManager::get().haltRecording(); VoicePlaybackManager::get().stopAllStreams(); +#endif // GLOBED_VOICE_SUPPORT auto& nm = NetworkManager::get(); @@ -104,7 +106,9 @@ class $modify(GlobedPlayLayer, PlayLayer) { log::debug("Recv level data, {} players", packet->players.size()); }); + nm.addListener([this](VoiceBroadcastPacket* packet) { +#if GLOBED_VOICE_SUPPORT if (this->m_fields->deafened) return; // TODO client side blocking and stuff.. @@ -115,6 +119,7 @@ class $modify(GlobedPlayLayer, PlayLayer) { } catch (const std::exception& e) { ErrorQueues::get().debugWarn(std::string("Failed to play a voice frame: ") + e.what()); } +#endif // GLOBED_VOICE_SUPPORT }); nm.addListener([](PlayerMetadataPacket*) { @@ -123,7 +128,7 @@ class $modify(GlobedPlayLayer, PlayLayer) { } void setupCustomKeybinds() { -#if GLOBED_HAS_KEYBINDS +#if GLOBED_HAS_KEYBINDS && GLOBED_VOICE_SUPPORT // TODO let the user pick recording device somehow // TODO this breaks for impostor playlayers, if they won't be fixed in 2.2 then do a good old workaround this->addEventListener([this](keybinds::InvokeBindEvent* event) { @@ -169,7 +174,7 @@ class $modify(GlobedPlayLayer, PlayLayer) { return ListenerResult::Propagate; }, "voice-deafen"_spr); -#endif // GLOBED_HAS_KEYBINDS +#endif // GLOBED_HAS_KEYBINDS && GLOBED_VOICE_SUPPORT } /* periodical selectors */ @@ -196,15 +201,19 @@ class $modify(GlobedPlayLayer, PlayLayer) { } void handlePlayerJoin(int playerId) { +#if GLOBED_VOICE_SUPPORT try { VoicePlaybackManager::get().prepareStream(playerId); } catch (const std::exception& e) { ErrorQueues::get().error(std::string("Failed to prepare audio stream: ") + e.what()); } +#endif // GLOBED_VOICE_SUPPORT } void handlePlayerLeave(int playerId) { +#if GLOBED_VOICE_SUPPORT VoicePlaybackManager::get().removeStream(playerId); +#endif // GLOBED_VOICE_SUPPORT } // With speedhack enabled, all scheduled selectors will run more often than they are supposed to. diff --git a/src/ui/menu/main/signup_popup.cpp b/src/ui/menu/main/signup_popup.cpp index 57aad2aa..97cbab0a 100644 --- a/src/ui/menu/main/signup_popup.cpp +++ b/src/ui/menu/main/signup_popup.cpp @@ -68,10 +68,14 @@ void GlobedSignupPopup::onChallengeCreated(int levelId, const std::string& chtok auto hash = util::crypto::simpleHash(chtoken); auto authcode = util::crypto::simpleTOTP(hash); + // TODO mac no worky yet, will have to find the symbols later +#ifndef GLOBED_MAC if (levelId == -1) { +#endif // GLOBED_MAC // skip posting the comment, server has it disabled this->onChallengeCompleted(authcode); +#ifndef GLOBED_MAC } else { statusMessage->setString("Uploading results.."); storedAuthcode = authcode; @@ -79,6 +83,7 @@ void GlobedSignupPopup::onChallengeCreated(int levelId, const std::string& chtok GameLevelManager::get()->m_commentUploadDelegate = this; GameLevelManager::get()->uploadLevelComment(levelId, authcode + " ## globed verification test, if you see this you can manually delete the comment.", 0); } +#endif // GLOBED_MAC } void GlobedSignupPopup::commentUploadFinished(int) { @@ -139,10 +144,12 @@ void GlobedSignupPopup::onChallengeCompleted(const std::string& authcode) { am.storeAuthKey(util::crypto::simpleHash(authkey)); this->onSuccess(); +#ifndef GLOBED_MAC // delete the comment to cleanup if (commentId != "none") { GameLevelManager::get()->deleteComment(std::stoi(commentId), CommentType::Level, storedLevelId); } +#endif // GLOBED_MAC } }) .send(); diff --git a/src/ui/menu/player_list/player_list_popup.cpp b/src/ui/menu/player_list/player_list_popup.cpp index 28490d79..bc58de0f 100644 --- a/src/ui/menu/player_list/player_list_popup.cpp +++ b/src/ui/menu/player_list/player_list_popup.cpp @@ -24,15 +24,6 @@ bool PlayerListPopup::setup() { nm.send(RequestPlayerListPacket::create()); - // show an error popup if no response after 2 seconds - timeoutSequence = CCSequence::create( - CCDelayTime::create(2.0f), - CCCallFunc::create(this, callfunc_selector(PlayerListPopup::onLoadTimeout)), - nullptr - ); - - this->runAction(timeoutSequence); - auto listview = ListView::create(CCArray::create(), PlayerListCell::CELL_HEIGHT, LIST_WIDTH, LIST_HEIGHT); listLayer = GJCommentListLayer::create(listview, "", {192, 114, 62, 255}, LIST_WIDTH, LIST_HEIGHT, false); @@ -49,11 +40,6 @@ bool PlayerListPopup::setup() { } void PlayerListPopup::onLoaded() { - if (timeoutSequence) { - this->stopAction(timeoutSequence); - timeoutSequence = nullptr; - } - this->removeLoadingCircle(); auto cells = CCArray::create(); @@ -69,11 +55,6 @@ void PlayerListPopup::onLoaded() { .collect(); } -void PlayerListPopup::onLoadTimeout() { - ErrorQueues::get().error("Failed to fetch the player list! This is most likely a server-side bug or a problem with your connection!"); - this->removeLoadingCircle(); -} - void PlayerListPopup::removeLoadingCircle() { if (loadingCircle) { loadingCircle->fadeAndRemove(); diff --git a/src/ui/menu/server_switcher/server_test_popup.cpp b/src/ui/menu/server_switcher/server_test_popup.cpp index 618e5c9b..eb213a48 100644 --- a/src/ui/menu/server_switcher/server_test_popup.cpp +++ b/src/ui/menu/server_switcher/server_test_popup.cpp @@ -46,7 +46,7 @@ bool ServerTestPopup::setup(const std::string& url, AddServerPopup* parent) { } else { auto response = resp.response; int protocol = 0; -#ifdef GLOBED_ANDROID +#ifdef GLOBED_UNIX // this is such a meme im crying std::istringstream iss(response); iss >> protocol; diff --git a/src/util/debugging.cpp b/src/util/debugging.cpp index 2a6fd044..8e1a6d08 100644 --- a/src/util/debugging.cpp +++ b/src/util/debugging.cpp @@ -108,8 +108,8 @@ namespace util::debugging { } [[noreturn]] void suicide() { - GLOBED_REQUIRE_LOG("suicide called at , terminating."); - GLOBED_REQUIRE_LOG("If you see this, something very, very bad happened."); + geode::log::error("suicide called at , terminating."); + geode::log::error("If you see this, something very, very bad happened."); GLOBED_SUICIDE } #endif