MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / updateRunning

Method updateRunning

source/client/StarClientApplication.cpp:943–1216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

941}
942
943void ClientApplication::updateRunning(float dt) {
944 try {
945 auto& app = appController();
946 auto worldClient = m_universeClient->worldClient();
947 auto p2pNetworkingService = app->p2pNetworkingService();
948 bool clientIPJoinable = m_root->configuration()->get("clientIPJoinable").toBool();
949 bool clientP2PJoinable = m_root->configuration()->get("clientP2PJoinable").toBool();
950 Maybe<pair<uint16_t, uint16_t>> party = make_pair(m_universeClient->players(), m_universeClient->maxPlayers());
951
952 if (m_state == MainAppState::MultiPlayer) {
953 if (p2pNetworkingService) {
954 p2pNetworkingService->setAcceptingP2PConnections(false);
955 if (clientP2PJoinable && m_currentRemoteJoin)
956 p2pNetworkingService->setJoinRemote(*m_currentRemoteJoin);
957 else
958 p2pNetworkingService->setJoinUnavailable();
959 }
960 } else {
961 m_universeServer->setListeningTcp(clientIPJoinable);
962 if (p2pNetworkingService) {
963 p2pNetworkingService->setAcceptingP2PConnections(clientP2PJoinable);
964 if (clientP2PJoinable) {
965 p2pNetworkingService->setJoinLocal(m_universeServer->maxClients());
966 } else {
967 p2pNetworkingService->setJoinUnavailable();
968 party = {};
969 }
970 }
971 }
972
973 if (p2pNetworkingService) {
974 auto getActivityDetail = [&](String const& tag) -> String {
975 if (tag == "playerName")
976 return Text::stripEscapeCodes(m_player->name());
977 if (tag == "playerHealth")
978 return toString(m_player->health());
979 if (tag == "playerMaxHealth")
980 return toString(m_player->maxHealth());
981 if (tag == "playerEnergy")
982 return toString(m_player->energy());
983 if (tag == "playerMaxEnergy")
984 return toString(m_player->maxEnergy());
985 if (tag == "playerBreath")
986 return toString(m_player->breath());
987 if (tag == "playerMaxBreath")
988 return toString(m_player->maxBreath());
989 if (tag == "playerXPos")
990 return toString(round(m_player->position().x()));
991 if (tag == "playerYPos")
992 return toString(round(m_player->position().y()));
993 if (tag == "worldName") {
994 if (m_universeClient->clientContext()->playerWorldId().is<ClientShipWorldId>())
995 return "Player Ship";
996 else if (WorldTemplate const* worldTemplate = worldClient ? worldClient->currentTemplate().get() : nullptr) {
997 auto worldName = worldTemplate->worldName();
998 if (worldName.empty())
999 return "In World";
1000 else

Callers

nothing calls this directly

Calls 15

stripEscapeCodesFunction · 0.85
toStringFunction · 0.85
roundFunction · 0.85
lerpFunction · 0.85
clampFunction · 0.85
strfFunction · 0.85
connectionForEntityFunction · 0.85
UniverseConnectionClass · 0.85
worldClientMethod · 0.80
toBoolMethod · 0.80
configurationMethod · 0.80
maxPlayersMethod · 0.80

Tested by

no test coverage detected