Fix Teams not functioning as swapped character

This commit is contained in:
Kae 2023-07-26 19:02:33 +10:00
parent ddab1db73f
commit f2afd91d0f
4 changed files with 11 additions and 11 deletions

View File

@ -132,7 +132,7 @@ void TeamBar::updatePlayerResources() {
m_energyBar->setColor(m_energyBarColor.mix(m_energyBarRegenMixColor, player->energyRegenBlockPercent()));
}
m_nameLabel->setText(m_client->mainPlayer()->name());
m_nameLabel->setText(player->name());
}
void TeamBar::inviteButton() {

View File

@ -79,7 +79,7 @@ TeleportDialog::TeleportDialog(UniverseClientPtr client,
if (config.getBool("includePartyMembers", false)) {
auto teamClient = m_client->teamClient();
for (auto member : teamClient->members()) {
if (member.uuid == m_client->mainPlayer()->uuid() || member.warpMode == WarpMode::None)
if (member.uuid == m_client->clientContext()->playerUuid() || member.warpMode == WarpMode::None)
continue;
auto entry = destList->addItem();

View File

@ -28,7 +28,7 @@ TeamClient::TeamClient(PlayerPtr mainPlayer, ClientContextPtr clientContext) {
bool TeamClient::isTeamLeader() {
if (!m_teamUuid)
return false;
return m_teamLeader == m_mainPlayer->uuid();
return m_teamLeader == m_clientContext->playerUuid();
}
bool TeamClient::isTeamLeader(Uuid const& playerUuid) {
@ -47,7 +47,7 @@ void TeamClient::invitePlayer(String const& playerName) {
JsonObject request;
request["inviteeName"] = playerName;
request["inviterUuid"] = m_mainPlayer->uuid().hex();
request["inviterUuid"] = m_clientContext->playerUuid().hex();
request["inviterName"] = m_mainPlayer->name();
invokeRemote("team.invite", request, [](Json) {});
}
@ -55,7 +55,7 @@ void TeamClient::invitePlayer(String const& playerName) {
void TeamClient::acceptInvitation(Uuid const& inviterUuid) {
JsonObject request;
request["inviterUuid"] = inviterUuid.hex();
request["inviteeUuid"] = m_mainPlayer->uuid().hex();
request["inviteeUuid"] = m_clientContext->playerUuid().hex();
invokeRemote("team.acceptInvitation", request, [this](Json) { forceUpdate(); });
}
@ -77,7 +77,7 @@ void TeamClient::makeLeader(Uuid const& playerUuid) {
void TeamClient::removeFromTeam(Uuid const& playerUuid) {
if (!m_teamUuid)
return;
if (!isTeamLeader() && playerUuid != m_mainPlayer->uuid())
if (!isTeamLeader() && playerUuid != m_clientContext->playerUuid())
return;
JsonObject request;
request["teamUuid"] = m_teamUuid->hex();
@ -101,7 +101,7 @@ void TeamClient::update() {
if (Time::monotonicTime() - m_pollInvitationsTimer > Root::singleton().assets()->json("/interface.config:invitationPollInterval").toFloat()) {
m_pollInvitationsTimer = Time::monotonicTime();
JsonObject request;
request["playerUuid"] = m_mainPlayer->uuid().hex();
request["playerUuid"] = m_clientContext->playerUuid().hex();
invokeRemote("team.pollInvitation", request, [this](Json response) {
if (response.isNull())
return;
@ -131,7 +131,7 @@ void TeamClient::pullFullUpdate() {
return;
m_fullUpdateRunning = true;
JsonObject request;
request["playerUuid"] = m_mainPlayer->uuid().hex();
request["playerUuid"] = m_clientContext->playerUuid().hex();
invokeRemote("team.fetchTeamStatus", request, [this](Json response) {
m_fullUpdateRunning = false;
@ -212,7 +212,7 @@ void TeamClient::handleRpcResponses() {
}
void TeamClient::writePlayerData(JsonObject& request, PlayerPtr player, bool fullWrite) const {
request["playerUuid"] = player->uuid().hex();
request["playerUuid"] = m_clientContext->playerUuid().hex();
request["entity"] = player->entityId();
request["health"] = player->health() / player->maxHealth();
request["energy"] = player->energy() / player->maxEnergy();

View File

@ -394,7 +394,7 @@ CelestialCoordinate UniverseClient::shipCoordinate() const {
}
bool UniverseClient::playerOnOwnShip() const {
return playerWorld().is<ClientShipWorldId>() && playerWorld().get<ClientShipWorldId>() == mainPlayer()->uuid();
return playerWorld().is<ClientShipWorldId>() && playerWorld().get<ClientShipWorldId>() == m_clientContext->playerUuid();
}
bool UniverseClient::playerIsOriginal() const {
@ -412,7 +412,7 @@ bool UniverseClient::isAdmin() const {
Uuid UniverseClient::teamUuid() const {
if (auto team = m_teamClient->currentTeam())
return *team;
return m_mainPlayer->uuid();
return m_clientContext->playerUuid();
}
WorldTemplateConstPtr UniverseClient::currentTemplate() const {