Skip to content

Commit

Permalink
macos compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
dank meme authored and dank meme committed Dec 7, 2023
1 parent 337c91b commit 3b378cf
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 28 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion src/managers/game_server_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions src/ui/error_check_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CCTransitionScene*>(currentScene) || typeinfo_cast<LoadingLayer*>(currentLayer)) {
return;
}
#endif

auto warnings = ErrorQueues::get().getWarnings();

Expand Down
13 changes: 11 additions & 2 deletions src/ui/hooks/play_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -104,7 +106,9 @@ class $modify(GlobedPlayLayer, PlayLayer) {
log::debug("Recv level data, {} players", packet->players.size());
});


nm.addListener<VoiceBroadcastPacket>([this](VoiceBroadcastPacket* packet) {
#if GLOBED_VOICE_SUPPORT
if (this->m_fields->deafened) return;

// TODO client side blocking and stuff..
Expand All @@ -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>([](PlayerMetadataPacket*) {
Expand All @@ -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<keybinds::InvokeBindFilter>([this](keybinds::InvokeBindEvent* event) {
Expand Down Expand Up @@ -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 */
Expand All @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/ui/menu/main/signup_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,22 @@ 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;
storedLevelId = levelId;
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) {
Expand Down Expand Up @@ -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();
Expand Down
19 changes: 0 additions & 19 deletions src/ui/menu/player_list/player_list_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -49,11 +40,6 @@ bool PlayerListPopup::setup() {
}

void PlayerListPopup::onLoaded() {
if (timeoutSequence) {
this->stopAction(timeoutSequence);
timeoutSequence = nullptr;
}

this->removeLoadingCircle();

auto cells = CCArray::create();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/menu/server_switcher/server_test_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/util/debugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ namespace util::debugging {
}

[[noreturn]] void suicide() {
GLOBED_REQUIRE_LOG("suicide called at <unknown location>, terminating.");
GLOBED_REQUIRE_LOG("If you see this, something very, very bad happened.");
geode::log::error("suicide called at <unknown location>, terminating.");
geode::log::error("If you see this, something very, very bad happened.");
GLOBED_SUICIDE
}
#endif
Expand Down

0 comments on commit 3b378cf

Please sign in to comment.