mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
minor fixes; added round clock
This commit is contained in:
parent
02f2fb9764
commit
5544de3213
9 changed files with 28 additions and 8 deletions
|
|
@ -414,9 +414,10 @@ Event_PlayerPropertiesChanged::Event_PlayerPropertiesChanged(int _playerId, Serv
|
|||
insertItem(_properties);
|
||||
}
|
||||
|
||||
Event_Ping::Event_Ping(const QList<ServerInfo_PlayerPing *> &_pingList)
|
||||
Event_Ping::Event_Ping(int _secondsElapsed, const QList<ServerInfo_PlayerPing *> &_pingList)
|
||||
: GameEvent("ping", -1)
|
||||
{
|
||||
insertItem(new SerializableItem_Int("seconds_elapsed", _secondsElapsed));
|
||||
for (int i = 0; i < _pingList.size(); ++i)
|
||||
itemList.append(_pingList[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -399,9 +399,10 @@ public:
|
|||
class Event_Ping : public GameEvent {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Event_Ping(const QList<ServerInfo_PlayerPing *> &_pingList = QList<ServerInfo_PlayerPing *>());
|
||||
Event_Ping(int _secondsElapsed = -1, const QList<ServerInfo_PlayerPing *> &_pingList = QList<ServerInfo_PlayerPing *>());
|
||||
static SerializableItem *newItem() { return new Event_Ping; }
|
||||
int getItemId() const { return ItemId_Event_Ping; }
|
||||
int getSecondsElapsed() const { return static_cast<SerializableItem_Int *>(itemMap.value("seconds_elapsed"))->getData(); }
|
||||
QList<ServerInfo_PlayerPing *> getPingList() const { return typecastItemList<ServerInfo_PlayerPing *>(); }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,9 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName) co
|
|||
|
||||
bool Server_CardZone::isColumnStacked(int x, int y) const
|
||||
{
|
||||
if (!has_coords)
|
||||
return false;
|
||||
|
||||
QMap<int, Server_Card *> coordMap;
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
if (cards[i]->getY() == y)
|
||||
|
|
@ -129,6 +132,9 @@ bool Server_CardZone::isColumnStacked(int x, int y) const
|
|||
|
||||
bool Server_CardZone::isColumnEmpty(int x, int y) const
|
||||
{
|
||||
if (!has_coords)
|
||||
return true;
|
||||
|
||||
QMap<int, Server_Card *> coordMap;
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
if (cards[i]->getY() == y)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
Server_Game::Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, bool _spectatorsAllowed, bool _spectatorsNeedPassword, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, Server_Room *parent)
|
||||
: QObject(parent), creatorInfo(new ServerInfo_User(_creator->getUserInfo())), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers), activePlayer(-1), activePhase(-1), spectatorsAllowed(_spectatorsAllowed), spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0)
|
||||
: QObject(parent), creatorInfo(new ServerInfo_User(_creator->getUserInfo())), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers), activePlayer(-1), activePhase(-1), spectatorsAllowed(_spectatorsAllowed), spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0), secondsElapsed(0)
|
||||
{
|
||||
addPlayer(_creator, false, false);
|
||||
|
||||
|
|
@ -56,6 +56,8 @@ Server_Game::~Server_Game()
|
|||
|
||||
void Server_Game::pingClockTimeout()
|
||||
{
|
||||
++secondsElapsed;
|
||||
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QList<ServerInfo_PlayerPing *> pingList;
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
|
|
@ -70,7 +72,7 @@ void Server_Game::pingClockTimeout()
|
|||
pingTime = -1;
|
||||
pingList.append(new ServerInfo_PlayerPing(player->getPlayerId(), pingTime));
|
||||
}
|
||||
sendGameEvent(new Event_Ping(pingList));
|
||||
sendGameEvent(new Event_Ping(secondsElapsed, pingList));
|
||||
|
||||
const int maxTime = static_cast<Server_Room *>(parent())->getServer()->getMaxGameInactivityTime();
|
||||
if (allPlayersInactive) {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ private:
|
|||
bool spectatorsCanTalk;
|
||||
bool spectatorsSeeEverything;
|
||||
int inactivityCounter;
|
||||
int secondsElapsed;
|
||||
QTimer *pingClock;
|
||||
signals:
|
||||
void gameClosing();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue