Show country flag in soccer if client supports
This commit is contained in:
parent
970061358b
commit
275dbe3631
@ -586,5 +586,6 @@
|
||||
-->
|
||||
<network-capabilities>
|
||||
<capabilities name="report_player"/>
|
||||
<capabilities name="country_flag"/>
|
||||
</network-capabilities>
|
||||
</config>
|
||||
|
@ -537,9 +537,9 @@ const std::string& CaptureTheFlag::getIdent() const
|
||||
} // getIdent
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CaptureTheFlag::saveCompleteState(BareNetworkString* bns)
|
||||
void CaptureTheFlag::saveCompleteState(BareNetworkString* bns, STKPeer* peer)
|
||||
{
|
||||
FreeForAll::saveCompleteState(bns);
|
||||
FreeForAll::saveCompleteState(bns, peer);
|
||||
bns->addUInt32(m_red_scores).addUInt32(m_blue_scores);
|
||||
} // saveCompleteState
|
||||
|
||||
|
@ -157,7 +157,8 @@ public:
|
||||
return progress;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void saveCompleteState(BareNetworkString* bns) OVERRIDE;
|
||||
virtual void saveCompleteState(BareNetworkString* bns,
|
||||
STKPeer* peer) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void restoreCompleteState(const BareNetworkString& b) OVERRIDE;
|
||||
}; // CaptureTheFlag
|
||||
|
@ -252,7 +252,7 @@ bool FreeForAll::getKartFFAResult(int kart_id) const
|
||||
} // getKartFFAResult
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void FreeForAll::saveCompleteState(BareNetworkString* bns)
|
||||
void FreeForAll::saveCompleteState(BareNetworkString* bns, STKPeer* peer)
|
||||
{
|
||||
for (unsigned i = 0; i < m_scores.size(); i++)
|
||||
bns->addUInt32(m_scores[i]);
|
||||
|
@ -80,7 +80,8 @@ public:
|
||||
m_scores.at(kart_id) = 0;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void saveCompleteState(BareNetworkString* bns) OVERRIDE;
|
||||
virtual void saveCompleteState(BareNetworkString* bns,
|
||||
STKPeer* peer) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void restoreCompleteState(const BareNetworkString& b) OVERRIDE;
|
||||
}; // FreeForAll
|
||||
|
@ -1116,7 +1116,7 @@ void LinearWorld::KartInfo::restoreCompleteState(const BareNetworkString& b)
|
||||
} // restoreCompleteState
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void LinearWorld::saveCompleteState(BareNetworkString* bns)
|
||||
void LinearWorld::saveCompleteState(BareNetworkString* bns, STKPeer* peer)
|
||||
{
|
||||
bns->addUInt32(m_fastest_lap_ticks);
|
||||
bns->addFloat(m_distance_increase);
|
||||
|
@ -226,7 +226,8 @@ public:
|
||||
virtual std::pair<uint32_t, uint32_t> getGameStartedProgress() const
|
||||
OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void saveCompleteState(BareNetworkString* bns) OVERRIDE;
|
||||
virtual void saveCompleteState(BareNetworkString* bns,
|
||||
STKPeer* peer) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void restoreCompleteState(const BareNetworkString& b) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "network/network_string.hpp"
|
||||
#include "network/protocols/game_events_protocol.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "tracks/graph.hpp"
|
||||
@ -40,6 +41,7 @@
|
||||
#include "tracks/track_object_manager.hpp"
|
||||
#include "tracks/track_sector.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <numeric>
|
||||
@ -275,7 +277,8 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
||||
sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal);
|
||||
sd.m_kart = getKart(m_ball_hitter)->getIdent();
|
||||
sd.m_player = getKart(m_ball_hitter)->getController()->getName();
|
||||
|
||||
sd.m_country_flag = StringUtils::getCountryFlag(
|
||||
race_manager->getKartInfo(m_ball_hitter).getCountryCode());
|
||||
if (sd.m_correct_goal)
|
||||
{
|
||||
m_karts[m_ball_hitter]->getKartModel()
|
||||
@ -319,9 +322,32 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
||||
.addUInt8((uint8_t)sd.m_id).addUInt8(sd.m_correct_goal)
|
||||
.addUInt8(first_goal).addFloat(sd.m_time)
|
||||
.addTime(m_ticks_back_to_own_goal)
|
||||
.encodeString(sd.m_kart)
|
||||
.encodeString(sd.m_player);
|
||||
STKHost::get()->sendPacketToAllPeers(&p, true);
|
||||
.encodeString(sd.m_kart);
|
||||
core::stringw player_name = sd.m_player;
|
||||
NetworkString p_with_flag = p;
|
||||
p.encodeString(player_name);
|
||||
if (!sd.m_country_flag.empty())
|
||||
{
|
||||
player_name += L" ";
|
||||
player_name += sd.m_country_flag;
|
||||
}
|
||||
p_with_flag.encodeString(player_name);
|
||||
auto peers = STKHost::get()->getPeers();
|
||||
for (auto& peer : peers)
|
||||
{
|
||||
if (peer->isValidated() && !peer->isWaitingForGame())
|
||||
{
|
||||
if (peer->getClientCapabilities().find("country_flag") !=
|
||||
peer->getClientCapabilities().end())
|
||||
{
|
||||
peer->sendPacket(&p_with_flag, true/*reliable*/);
|
||||
}
|
||||
else
|
||||
{
|
||||
peer->sendPacket(&p, true/*reliable*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < m_karts.size(); i++)
|
||||
@ -740,7 +766,7 @@ void SoccerWorld::enterRaceOverState()
|
||||
} // enterRaceOverState
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void SoccerWorld::saveCompleteState(BareNetworkString* bns)
|
||||
void SoccerWorld::saveCompleteState(BareNetworkString* bns, STKPeer* peer)
|
||||
{
|
||||
const unsigned red_scorers = (unsigned)m_red_scorers.size();
|
||||
bns->addUInt32(red_scorers);
|
||||
@ -749,8 +775,15 @@ void SoccerWorld::saveCompleteState(BareNetworkString* bns)
|
||||
bns->addUInt8((uint8_t)m_red_scorers[i].m_id)
|
||||
.addUInt8(m_red_scorers[i].m_correct_goal)
|
||||
.addFloat(m_red_scorers[i].m_time)
|
||||
.encodeString(m_red_scorers[i].m_kart)
|
||||
.encodeString(m_red_scorers[i].m_player);
|
||||
.encodeString(m_red_scorers[i].m_kart);
|
||||
core::stringw player_name = m_red_scorers[i].m_player;
|
||||
if (peer->getClientCapabilities().find("country_flag") !=
|
||||
peer->getClientCapabilities().end())
|
||||
{
|
||||
player_name += L" ";
|
||||
player_name += m_red_scorers[i].m_country_flag;
|
||||
}
|
||||
bns->encodeString(player_name);
|
||||
}
|
||||
|
||||
const unsigned blue_scorers = (unsigned)m_blue_scorers.size();
|
||||
@ -760,8 +793,15 @@ void SoccerWorld::saveCompleteState(BareNetworkString* bns)
|
||||
bns->addUInt8((uint8_t)m_blue_scorers[i].m_id)
|
||||
.addUInt8(m_blue_scorers[i].m_correct_goal)
|
||||
.addFloat(m_blue_scorers[i].m_time)
|
||||
.encodeString(m_blue_scorers[i].m_kart)
|
||||
.encodeString(m_blue_scorers[i].m_player);
|
||||
.encodeString(m_blue_scorers[i].m_kart);
|
||||
core::stringw player_name = m_blue_scorers[i].m_player;
|
||||
if (peer->getClientCapabilities().find("country_flag") !=
|
||||
peer->getClientCapabilities().end())
|
||||
{
|
||||
player_name += L" ";
|
||||
player_name += m_blue_scorers[i].m_country_flag;
|
||||
}
|
||||
bns->encodeString(player_name);
|
||||
}
|
||||
bns->addTime(m_reset_ball_ticks).addTime(m_ticks_back_to_own_goal);
|
||||
} // saveCompleteState
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
std::string m_kart;
|
||||
/** Player name which scores. */
|
||||
core::stringw m_player;
|
||||
/** Country flag of player (used in server only). */
|
||||
core::stringw m_country_flag;
|
||||
}; // ScorerData
|
||||
|
||||
private:
|
||||
@ -414,7 +416,8 @@ public:
|
||||
return progress;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void saveCompleteState(BareNetworkString* bns) OVERRIDE;
|
||||
virtual void saveCompleteState(BareNetworkString* bns,
|
||||
STKPeer* peer) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void restoreCompleteState(const BareNetworkString& b) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -46,6 +46,7 @@ class btRigidBody;
|
||||
class Controller;
|
||||
class ItemState;
|
||||
class PhysicalObject;
|
||||
class STKPeer;
|
||||
|
||||
namespace Scripting
|
||||
{
|
||||
@ -339,7 +340,7 @@ public:
|
||||
m_eliminated_karts--;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void saveCompleteState(BareNetworkString* bns) {}
|
||||
virtual void saveCompleteState(BareNetworkString* bns, STKPeer* peer) {}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void restoreCompleteState(const BareNetworkString& buffer) {}
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -1575,7 +1575,7 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
|
||||
nim->saveCompleteState(ns);
|
||||
nim->addLiveJoinPeer(peer);
|
||||
|
||||
w->saveCompleteState(ns);
|
||||
w->saveCompleteState(ns, peer.get());
|
||||
if (race_manager->supportsLiveJoining())
|
||||
{
|
||||
// Only needed in non-racing mode as no need players can added after
|
||||
|
Loading…
Reference in New Issue
Block a user