Update number of votes on client.
This commit is contained in:
+16
-1
@@ -896,7 +896,7 @@ Deny Reason:
|
|||||||
0xFFFF: Other reason.
|
0xFFFF: Other reason.
|
||||||
|
|
||||||
|
|
||||||
Server Notification: End Kick Player Petition
|
Server Notification: Kick Player Petition Update
|
||||||
|
|
||||||
0 1 2 3
|
0 1 2 3
|
||||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
@@ -907,6 +907,21 @@ Server Notification: End Kick Player Petition
|
|||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| # Votes against Kicking | # Votes in favour of Kicking |
|
| # Votes against Kicking | # Votes in favour of Kicking |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| # Votes Needed to kick | Reserved |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
|
Server Notification: End Kick Player Petition
|
||||||
|
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Message Type = 120 | Message Length = 16 |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| Petition ID |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| # Votes against Kicking | # Votes in favour of Kicking |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
| Vote Result | End Reason |
|
| Vote Result | End Reason |
|
||||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
Vote Result:
|
Vote Result:
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ protected:
|
|||||||
void ClearGameInfoMap();
|
void ClearGameInfoMap();
|
||||||
|
|
||||||
void StartPetition(unsigned petitionId, unsigned proposingPlayerId, unsigned kickPlayerId, int timeoutSec, int numVotesToKick);
|
void StartPetition(unsigned petitionId, unsigned proposingPlayerId, unsigned kickPlayerId, int timeoutSec, int numVotesToKick);
|
||||||
|
void UpdatePetition(unsigned petitionId, int numVotesAgainstKicking, int numVotesInFavourOfKicking, int numVotesToKick);
|
||||||
void EndPetition(unsigned petitionId);
|
void EndPetition(unsigned petitionId);
|
||||||
|
|
||||||
void UpdateStatData(const ServerStats &stats);
|
void UpdateStatData(const ServerStats &stats);
|
||||||
|
|||||||
@@ -776,6 +776,13 @@ AbstractClientStateReceiving::Process(ClientThread &client)
|
|||||||
client.StartPetition(startPetitionData.petitionId, startPetitionData.proposingPlayerId,
|
client.StartPetition(startPetitionData.petitionId, startPetitionData.proposingPlayerId,
|
||||||
startPetitionData.kickPlayerId, startPetitionData.kickTimeoutSec, startPetitionData.numVotesNeededToKick);
|
startPetitionData.kickPlayerId, startPetitionData.kickTimeoutSec, startPetitionData.numVotesNeededToKick);
|
||||||
}
|
}
|
||||||
|
else if (tmpPacket->ToNetPacketKickPlayerPetitionUpdate())
|
||||||
|
{
|
||||||
|
NetPacketKickPlayerPetitionUpdate::Data updatePetitionData;
|
||||||
|
tmpPacket->ToNetPacketKickPlayerPetitionUpdate()->GetData(updatePetitionData);
|
||||||
|
client.UpdatePetition(updatePetitionData.petitionId, updatePetitionData.numVotesAgainstKicking,
|
||||||
|
updatePetitionData.numVotesInFavourOfKicking, updatePetitionData.numVotesNeededToKick);
|
||||||
|
}
|
||||||
else if (tmpPacket->ToNetPacketEndKickPlayerPetition())
|
else if (tmpPacket->ToNetPacketEndKickPlayerPetition())
|
||||||
{
|
{
|
||||||
NetPacketEndKickPlayerPetition::Data endPetitionData;
|
NetPacketEndKickPlayerPetition::Data endPetitionData;
|
||||||
|
|||||||
@@ -1037,6 +1037,20 @@ ClientThread::StartPetition(unsigned petitionId, unsigned proposingPlayerId, uns
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientThread::UpdatePetition(unsigned petitionId, int /*numVotesAgainstKicking*/, int numVotesInFavourOfKicking, int numVotesToKick)
|
||||||
|
{
|
||||||
|
bool isCurPetition;
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_curPetitionIdMutex);
|
||||||
|
isCurPetition = m_curPetitionId == petitionId;
|
||||||
|
}
|
||||||
|
if (isCurPetition)
|
||||||
|
{
|
||||||
|
GetGui().refreshVotesMonitor(numVotesInFavourOfKicking, numVotesToKick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientThread::EndPetition(unsigned petitionId)
|
ClientThread::EndPetition(unsigned petitionId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ using namespace std;
|
|||||||
#define NET_TYPE_VOTE_KICK_PLAYER 0x0074
|
#define NET_TYPE_VOTE_KICK_PLAYER 0x0074
|
||||||
#define NET_TYPE_VOTE_KICK_PLAYER_ACK 0x0075
|
#define NET_TYPE_VOTE_KICK_PLAYER_ACK 0x0075
|
||||||
#define NET_TYPE_VOTE_KICK_PLAYER_DENIED 0x0076
|
#define NET_TYPE_VOTE_KICK_PLAYER_DENIED 0x0076
|
||||||
#define NET_TYPE_END_KICK_PLAYER_PETITION 0x0077
|
#define NET_TYPE_KICK_PLAYER_PETITION_UPDATE 0x0077
|
||||||
|
#define NET_TYPE_END_KICK_PLAYER_PETITION 0x0078
|
||||||
|
|
||||||
#define NET_TYPE_STATISTICS_CHANGED 0x0080
|
#define NET_TYPE_STATISTICS_CHANGED 0x0080
|
||||||
|
|
||||||
@@ -588,6 +589,16 @@ struct GCC_PACKED NetPacketVoteKickPlayerDeniedData
|
|||||||
u_int16_t reserved;
|
u_int16_t reserved;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GCC_PACKED NetPacketKickPlayerPetitionUpdateData
|
||||||
|
{
|
||||||
|
NetPacketHeader head;
|
||||||
|
u_int32_t petitionId;
|
||||||
|
u_int16_t numVotesAgainstKicking;
|
||||||
|
u_int16_t numVotesInFavourOfKicking;
|
||||||
|
u_int16_t numVotesNeededToKick;
|
||||||
|
u_int16_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
struct GCC_PACKED NetPacketEndKickPlayerPetitionData
|
struct GCC_PACKED NetPacketEndKickPlayerPetitionData
|
||||||
{
|
{
|
||||||
NetPacketHeader head;
|
NetPacketHeader head;
|
||||||
@@ -915,6 +926,9 @@ NetPacket::Create(char *data, unsigned &dataSize)
|
|||||||
case NET_TYPE_VOTE_KICK_PLAYER_DENIED:
|
case NET_TYPE_VOTE_KICK_PLAYER_DENIED:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketVoteKickPlayerDenied);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketVoteKickPlayerDenied);
|
||||||
break;
|
break;
|
||||||
|
case NET_TYPE_KICK_PLAYER_PETITION_UPDATE:
|
||||||
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketKickPlayerPetitionUpdate);
|
||||||
|
break;
|
||||||
case NET_TYPE_END_KICK_PLAYER_PETITION:
|
case NET_TYPE_END_KICK_PLAYER_PETITION:
|
||||||
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketEndKickPlayerPetition);
|
tmpPacket = boost::shared_ptr<NetPacket>(new NetPacketEndKickPlayerPetition);
|
||||||
break;
|
break;
|
||||||
@@ -1305,6 +1319,12 @@ NetPacket::ToNetPacketVoteKickPlayerDenied() const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NetPacketKickPlayerPetitionUpdate *
|
||||||
|
NetPacket::ToNetPacketKickPlayerPetitionUpdate() const
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const NetPacketEndKickPlayerPetition *
|
const NetPacketEndKickPlayerPetition *
|
||||||
NetPacket::ToNetPacketEndKickPlayerPetition() const
|
NetPacket::ToNetPacketEndKickPlayerPetition() const
|
||||||
{
|
{
|
||||||
@@ -4828,6 +4848,75 @@ NetPacketVoteKickPlayerDenied::InternalCheck(const NetPacketHeader*) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NetPacketKickPlayerPetitionUpdate::NetPacketKickPlayerPetitionUpdate()
|
||||||
|
: NetPacket(NET_TYPE_KICK_PLAYER_PETITION_UPDATE, sizeof(NetPacketKickPlayerPetitionUpdateData), sizeof(NetPacketKickPlayerPetitionUpdateData))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetPacketKickPlayerPetitionUpdate::~NetPacketKickPlayerPetitionUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<NetPacket>
|
||||||
|
NetPacketKickPlayerPetitionUpdate::Clone() const
|
||||||
|
{
|
||||||
|
boost::shared_ptr<NetPacket> newPacket(new NetPacketKickPlayerPetitionUpdate);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newPacket->SetRawData(GetRawData());
|
||||||
|
} catch (const NetException &)
|
||||||
|
{
|
||||||
|
// Need to return the new packet anyway.
|
||||||
|
}
|
||||||
|
return newPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketKickPlayerPetitionUpdate::SetData(const NetPacketKickPlayerPetitionUpdate::Data &inData)
|
||||||
|
{
|
||||||
|
NetPacketKickPlayerPetitionUpdateData *tmpData = (NetPacketKickPlayerPetitionUpdateData *)GetRawData();
|
||||||
|
|
||||||
|
tmpData->petitionId = htonl(inData.petitionId);
|
||||||
|
tmpData->numVotesAgainstKicking = htons(inData.numVotesAgainstKicking);
|
||||||
|
tmpData->numVotesInFavourOfKicking = htons(inData.numVotesInFavourOfKicking);
|
||||||
|
tmpData->numVotesNeededToKick = htons(inData.numVotesNeededToKick);
|
||||||
|
|
||||||
|
// Check the packet - just in case.
|
||||||
|
Check(GetRawData());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketKickPlayerPetitionUpdate::GetData(NetPacketKickPlayerPetitionUpdate::Data &outData) const
|
||||||
|
{
|
||||||
|
NetPacketKickPlayerPetitionUpdateData *tmpData = (NetPacketKickPlayerPetitionUpdateData *)GetRawData();
|
||||||
|
|
||||||
|
outData.petitionId = ntohl(tmpData->petitionId);
|
||||||
|
outData.numVotesAgainstKicking = ntohs(tmpData->numVotesAgainstKicking);
|
||||||
|
outData.numVotesInFavourOfKicking = ntohs(tmpData->numVotesInFavourOfKicking);
|
||||||
|
outData.numVotesNeededToKick = ntohs(tmpData->numVotesNeededToKick);
|
||||||
|
}
|
||||||
|
|
||||||
|
const NetPacketKickPlayerPetitionUpdate *
|
||||||
|
NetPacketKickPlayerPetitionUpdate::ToNetPacketKickPlayerPetitionUpdate() const
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetPacketKickPlayerPetitionUpdate::InternalCheck(const NetPacketHeader *data) const
|
||||||
|
{
|
||||||
|
NetPacketKickPlayerPetitionUpdateData *tmpData = (NetPacketKickPlayerPetitionUpdateData *)data;
|
||||||
|
|
||||||
|
if (ntohs(tmpData->numVotesAgainstKicking) > MAX_NUMBER_OF_PLAYERS)
|
||||||
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
|
if (ntohs(tmpData->numVotesInFavourOfKicking) > MAX_NUMBER_OF_PLAYERS)
|
||||||
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
|
if (ntohs(tmpData->numVotesNeededToKick) > MAX_NUMBER_OF_PLAYERS)
|
||||||
|
throw NetException(__FILE__, __LINE__, ERR_SOCK_INVALID_PACKET, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NetPacketEndKickPlayerPetition::NetPacketEndKickPlayerPetition()
|
NetPacketEndKickPlayerPetition::NetPacketEndKickPlayerPetition()
|
||||||
: NetPacket(NET_TYPE_END_KICK_PLAYER_PETITION, sizeof(NetPacketEndKickPlayerPetitionData), sizeof(NetPacketEndKickPlayerPetitionData))
|
: NetPacket(NET_TYPE_END_KICK_PLAYER_PETITION, sizeof(NetPacketEndKickPlayerPetitionData), sizeof(NetPacketEndKickPlayerPetitionData))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -385,6 +385,16 @@ ServerGameThread::InternalVoteKick(SessionWrapper byWhom, unsigned petitionId, K
|
|||||||
m_voteKickData->numVotesInFavourOfKicking++;
|
m_voteKickData->numVotesInFavourOfKicking++;
|
||||||
else
|
else
|
||||||
m_voteKickData->numVotesAgainstKicking++;
|
m_voteKickData->numVotesAgainstKicking++;
|
||||||
|
// Send update notification.
|
||||||
|
boost::shared_ptr<NetPacket> updatePetition(new NetPacketKickPlayerPetitionUpdate);
|
||||||
|
NetPacketKickPlayerPetitionUpdate::Data updatePetitionData;
|
||||||
|
updatePetitionData.petitionId = m_voteKickData->petitionId;
|
||||||
|
updatePetitionData.numVotesAgainstKicking = m_voteKickData->numVotesAgainstKicking;
|
||||||
|
updatePetitionData.numVotesInFavourOfKicking = m_voteKickData->numVotesInFavourOfKicking;
|
||||||
|
updatePetitionData.numVotesNeededToKick = m_voteKickData->numVotesToKick;
|
||||||
|
|
||||||
|
static_cast<NetPacketKickPlayerPetitionUpdate *>(updatePetition.get())->SetData(updatePetitionData);
|
||||||
|
SendToAllPlayers(updatePetition, SessionData::Game);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
InternalDenyVoteKick(byWhom, petitionId, VOTE_DENIED_ALREADY_VOTED);
|
InternalDenyVoteKick(byWhom, petitionId, VOTE_DENIED_ALREADY_VOTED);
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class NetPacketStartKickPlayerPetition;
|
|||||||
class NetPacketVoteKickPlayer;
|
class NetPacketVoteKickPlayer;
|
||||||
class NetPacketVoteKickPlayerAck;
|
class NetPacketVoteKickPlayerAck;
|
||||||
class NetPacketVoteKickPlayerDenied;
|
class NetPacketVoteKickPlayerDenied;
|
||||||
|
class NetPacketKickPlayerPetitionUpdate;
|
||||||
class NetPacketEndKickPlayerPetition;
|
class NetPacketEndKickPlayerPetition;
|
||||||
class NetPacketStatisticsChanged;
|
class NetPacketStatisticsChanged;
|
||||||
class NetPacketRemovedFromGame;
|
class NetPacketRemovedFromGame;
|
||||||
@@ -166,6 +167,7 @@ public:
|
|||||||
virtual const NetPacketVoteKickPlayer *ToNetPacketVoteKickPlayer() const;
|
virtual const NetPacketVoteKickPlayer *ToNetPacketVoteKickPlayer() const;
|
||||||
virtual const NetPacketVoteKickPlayerAck *ToNetPacketVoteKickPlayerAck() const;
|
virtual const NetPacketVoteKickPlayerAck *ToNetPacketVoteKickPlayerAck() const;
|
||||||
virtual const NetPacketVoteKickPlayerDenied *ToNetPacketVoteKickPlayerDenied() const;
|
virtual const NetPacketVoteKickPlayerDenied *ToNetPacketVoteKickPlayerDenied() const;
|
||||||
|
virtual const NetPacketKickPlayerPetitionUpdate *ToNetPacketKickPlayerPetitionUpdate() const;
|
||||||
virtual const NetPacketEndKickPlayerPetition *ToNetPacketEndKickPlayerPetition() const;
|
virtual const NetPacketEndKickPlayerPetition *ToNetPacketEndKickPlayerPetition() const;
|
||||||
virtual const NetPacketStatisticsChanged *ToNetPacketStatisticsChanged() const;
|
virtual const NetPacketStatisticsChanged *ToNetPacketStatisticsChanged() const;
|
||||||
virtual const NetPacketRemovedFromGame *ToNetPacketRemovedFromGame() const;
|
virtual const NetPacketRemovedFromGame *ToNetPacketRemovedFromGame() const;
|
||||||
@@ -1332,6 +1334,32 @@ protected:
|
|||||||
virtual void InternalCheck(const NetPacketHeader* data) const;
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NetPacketKickPlayerPetitionUpdate : public NetPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Data
|
||||||
|
{
|
||||||
|
u_int32_t petitionId;
|
||||||
|
u_int16_t numVotesAgainstKicking;
|
||||||
|
u_int16_t numVotesInFavourOfKicking;
|
||||||
|
u_int16_t numVotesNeededToKick;
|
||||||
|
};
|
||||||
|
|
||||||
|
NetPacketKickPlayerPetitionUpdate();
|
||||||
|
virtual ~NetPacketKickPlayerPetitionUpdate();
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<NetPacket> Clone() const;
|
||||||
|
|
||||||
|
void SetData(const Data &inData);
|
||||||
|
void GetData(Data &outData) const;
|
||||||
|
|
||||||
|
virtual const NetPacketKickPlayerPetitionUpdate *ToNetPacketKickPlayerPetitionUpdate() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void InternalCheck(const NetPacketHeader* data) const;
|
||||||
|
};
|
||||||
|
|
||||||
class NetPacketEndKickPlayerPetition : public NetPacket
|
class NetPacketEndKickPlayerPetition : public NetPacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user