mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -07:00
Support Qt6, Min Qt5.8, Fix Win32, Fix Servatrice
Add lock around deleting arrows for commanding cards Add support for Qt6 w/ Backwards Qt5 Handle Qt5/6 cross compilation better Last cleanups caps matter Fix serv Prevent crash on 6.3.0 Linux & bump to 5.8 min Prevent out of bounds indexing Delete shutdown timer if it exists Fixup ticket comments, remove unneeded guards Try to add support for missing OSes Update .ci/release_template.md Update PR based on comments Update XML name after done and remove Hirsute Address local game crash Address comments from PR (again) Tests don't work on mac, will see if a problem on other OSes make soundengine more consistent across qt versions disable tests on distros that are covered by others Fix Oracle Crash due to bad memory access Update Oracle to use new Qt6 way of adding translations Add support for Qt5/Qt6 compiling of Cockatrice Remove unneeded calls to QtMath/cmath/math.h Update how we handle bitwise comparisons for enums with Tray Icon Change header guards to not duplicate function Leave comment & Fix Path for GHA Qt Update common/server.h Update cockatrice/src/window_main.cpp Rollback change on cmake module path for NSIS check docker image requirements add size limit to ccache put variables in quotes properly set build type on mac avoid names used in cmake fix up cmake module path cmake 3.10 does not recognize prepend Support Tests in FindQtRuntime set ccache size on non debug builds as well immediately return when removing non existing client handle incTxBytes with a signal instead don't set common link libraries in cockatrice/CMakeLists.txt add comments set macos qt version to 6 Try upgrading XCode versions to latest they can be supported on Ensure Qt gets linked add tmate so i can see what's going on Qt6 points two directories further down than Qt5 with regard to the top lib path, so we need to account for this Establish Plugins directory for Qt6 Establish TLS plugins for Qt6 services Minor change for release channel network manager Let windows build in parallel cores Wrong symbols Qt6 patch up for signal add missing qt6 package on deb builds boolean expressions are hard negative indexes should go to the end Intentionally fail cache move size checks to individual zone types Hardcode libs needed for building on Windows, as the regex was annoying Update wording use the --parallel option in all builds clean up the .ci scripts some more tweak fedora build add os parameter to compile.sh I don't really like this but it seems the easiest way I'd prefer if these types of quirks would live in the main configuration file, the yml fixup yml readd appended cache key to vcpkg step fix windows 32 quirk the json hash is already added to the key as well remove os parameter and clean up ci files set name_build.sh to output relative paths set backwards compatible version of xcode and qt on mac set QTDIR for mac builds on qt5 has no effect for qt6 export BUILD_DIR to name_build.sh merge mac build steps merge homebrew steps, set package suffix link qt5 remove brew link set qtdir to qt5 only compile.sh vars need to be empty not 0 fix sets manager search bar on qt 5.12/15 fix oracle subprocess errors being ignored on qt 5 clean up translation loading move en@source translation file so it will not get included in packages NOTE: this needs to be done at transifex as well! Use generator platform over osname Short circuit if not Win defined
This commit is contained in:
parent
accd5e4df7
commit
b02adccf87
114 changed files with 1925 additions and 1603 deletions
|
|
@ -36,8 +36,8 @@ set(ORACLE_LIBS)
|
|||
INCLUDE_DIRECTORIES(pb)
|
||||
INCLUDE_DIRECTORIES(sfmt)
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
|
||||
include_directories(${Qt5Core_INCLUDE_DIRS})
|
||||
include_directories(${${COCKATRICE_QT_VERSION_NAME}Core_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_library(cockatrice_common ${common_SOURCES} ${common_MOC_SRCS})
|
||||
target_link_libraries(cockatrice_common cockatrice_protocol)
|
||||
target_link_libraries(cockatrice_common PUBLIC cockatrice_protocol)
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ bool AbstractDecklistCardNode::readElement(QXmlStreamReader *xml)
|
|||
{
|
||||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
if (xml->isEndElement() && xml->name() == "card")
|
||||
if (xml->isEndElement() && xml->name().toString() == "card")
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -435,7 +435,7 @@ bool DeckList::loadFromXml(QXmlStreamReader *xml)
|
|||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
if (xml->isStartElement()) {
|
||||
if (xml->name() != "cockatrice_deck")
|
||||
if (xml->name().toString() != "cockatrice_deck")
|
||||
return false;
|
||||
while (!xml->atEnd()) {
|
||||
xml->readNext();
|
||||
|
|
@ -602,7 +602,7 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
|
|||
int amount = 1;
|
||||
match = reMultiplier.match(cardName);
|
||||
if (match.hasMatch()) {
|
||||
amount = match.capturedRef(1).toInt();
|
||||
amount = match.captured(1).toInt();
|
||||
cardName = match.captured(2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <cmath>
|
||||
#include <QtMath>
|
||||
#include <functional>
|
||||
|
||||
peg::parser math(R"(
|
||||
|
|
@ -32,19 +32,17 @@ Expression::Expression(double initial) : value(initial)
|
|||
{
|
||||
if (default_functions == nullptr) {
|
||||
default_functions = new QMap<QString, std::function<double(double)>>();
|
||||
default_functions->insert("sin", [](double a) { return sin(a); });
|
||||
default_functions->insert("cos", [](double a) { return cos(a); });
|
||||
default_functions->insert("tan", [](double a) { return tan(a); });
|
||||
default_functions->insert("sqrt", [](double a) { return sqrt(a); });
|
||||
default_functions->insert("log", [](double a) { return log(a); });
|
||||
default_functions->insert("log10", [](double a) { return log(a); });
|
||||
default_functions->insert("trunc", [](double a) { return trunc(a); });
|
||||
default_functions->insert("abs", [](double a) { return fabs(a); });
|
||||
|
||||
default_functions->insert("floor", [](double a) { return floor(a); });
|
||||
default_functions->insert("ceil", [](double a) { return ceil(a); });
|
||||
default_functions->insert("round", [](double a) { return round(a); });
|
||||
default_functions->insert("trunc", [](double a) { return trunc(a); });
|
||||
default_functions->insert("abs", [](double a) { return qFabs(a); });
|
||||
default_functions->insert("ceil", [](double a) { return qCeil(a); });
|
||||
default_functions->insert("cos", [](double a) { return qCos(a); });
|
||||
default_functions->insert("floor", [](double a) { return qFloor(a); });
|
||||
default_functions->insert("log", [](double a) { return qLn(a); });
|
||||
default_functions->insert("log10", [](double a) { return qLn(a); });
|
||||
default_functions->insert("round", [](double a) { return qRound(a); });
|
||||
default_functions->insert("sin", [](double a) { return qSin(a); });
|
||||
default_functions->insert("sqrt", [](double a) { return qSqrt(a); });
|
||||
default_functions->insert("tan", [](double a) { return qTan(a); });
|
||||
default_functions->insert("trunc", [](double a) { return std::trunc(a); });
|
||||
}
|
||||
fns = QMap<QString, std::function<double(double)>>(*default_functions);
|
||||
}
|
||||
|
|
@ -80,7 +78,7 @@ double Expression::eval(const peg::Ast &ast)
|
|||
result /= arg;
|
||||
break;
|
||||
case '^':
|
||||
result = pow(result, arg);
|
||||
result = qPow(result, arg);
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
RNG_SFMT::RNG_SFMT(QObject *parent) : RNG_Abstract(parent)
|
||||
{
|
||||
// initialize the random number generator with a 32bit integer seed (timestamp)
|
||||
sfmt_init_gen_rand(&sfmt, QDateTime::currentDateTime().toTime_t());
|
||||
sfmt_init_gen_rand(&sfmt, QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session,
|
|||
Event_ConnectionClosed event;
|
||||
event.set_reason(Event_ConnectionClosed::LOGGEDINELSEWERE);
|
||||
event.set_reason_str("You have been logged out due to logging in at another location.");
|
||||
event.set_end_time(QDateTime::currentDateTime().toTime_t());
|
||||
event.set_end_time(QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
|
||||
SessionEvent *se = users.value(name)->prepareSessionEvent(event);
|
||||
users.value(name)->sendProtocolItem(*se);
|
||||
|
|
@ -230,6 +230,11 @@ void Server::addClient(Server_ProtocolHandler *client)
|
|||
|
||||
void Server::removeClient(Server_ProtocolHandler *client)
|
||||
{
|
||||
int clientIndex = clients.indexOf(client);
|
||||
if (clientIndex == -1) {
|
||||
qWarning() << "tried to remove non existing client";
|
||||
return;
|
||||
}
|
||||
|
||||
if (client->getConnectionType() == "tcp")
|
||||
tcpUserCount--;
|
||||
|
|
@ -238,7 +243,7 @@ void Server::removeClient(Server_ProtocolHandler *client)
|
|||
webSocketUserCount--;
|
||||
|
||||
QWriteLocker locker(&clientsLock);
|
||||
clients.removeAt(clients.indexOf(client));
|
||||
clients.removeAt(clientIndex);
|
||||
ServerInfo_User *data = client->getUserInfo();
|
||||
if (data) {
|
||||
Event_UserLeft event;
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ private slots:
|
|||
|
||||
public:
|
||||
mutable QReadWriteLock clientsLock, roomsLock; // locking order: roomsLock before clientsLock
|
||||
Server(QObject *parent = nullptr);
|
||||
~Server() = default;
|
||||
explicit Server(QObject *parent = nullptr);
|
||||
virtual ~Server() = default;
|
||||
AuthenticationResult loginUser(Server_ProtocolHandler *session,
|
||||
QString &name,
|
||||
const QString &password,
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@
|
|||
#define SERVER_CARD_H
|
||||
|
||||
#include "pb/card_attributes.pb.h"
|
||||
#include "pb/serverinfo_card.pb.h"
|
||||
#include "server_arrowtarget.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
class Server_CardZone;
|
||||
class ServerInfo_Card;
|
||||
|
||||
class Server_Card : public Server_ArrowTarget
|
||||
{
|
||||
|
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
public:
|
||||
Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone = 0);
|
||||
~Server_Card();
|
||||
~Server_Card() override;
|
||||
|
||||
Server_CardZone *getZone() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -292,10 +292,10 @@ void Server_CardZone::insertCard(Server_Card *card, int x, int y)
|
|||
insertCardIntoCoordMap(card, x, y);
|
||||
} else {
|
||||
card->setCoords(0, 0);
|
||||
if (x == -1) {
|
||||
cards.append(card);
|
||||
} else {
|
||||
if (0 <= x && x < cards.length()) {
|
||||
cards.insert(x, card);
|
||||
} else {
|
||||
cards.append(card);
|
||||
}
|
||||
}
|
||||
card->setZone(this);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,12 @@ public:
|
|||
LogMessage_TargetType /* targetType */,
|
||||
const int /* targetId */,
|
||||
const QString & /* targetName */){};
|
||||
bool checkUserIsBanned(Server_ProtocolHandler *session, QString &banReason, int &banSecondsRemaining);
|
||||
virtual bool checkUserIsBanned(Server_ProtocolHandler * /* session */,
|
||||
QString & /* banReason */,
|
||||
int & /* banSecondsRemaining */)
|
||||
{
|
||||
return false;
|
||||
};
|
||||
virtual int checkNumberOfUserAccounts(const QString & /* email */)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ Server_Game::Server_Game(const ServerInfo_User &_creatorInfo,
|
|||
spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk),
|
||||
spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0), startTimeOfThisGame(0),
|
||||
secondsElapsed(0), firstGameStarted(false), turnOrderReversed(false), startTime(QDateTime::currentDateTime()),
|
||||
pingClock(nullptr),
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
gameMutex()
|
||||
#else
|
||||
|
|
@ -97,7 +98,7 @@ Server_Game::~Server_Game()
|
|||
|
||||
gameClosed = true;
|
||||
sendGameEventContainer(prepareGameEvent(Event_GameClosed(), -1));
|
||||
for (Server_Player *player : players.values()) {
|
||||
for (auto *player : players.values()) {
|
||||
player->prepareDestroy();
|
||||
}
|
||||
players.clear();
|
||||
|
|
@ -112,10 +113,22 @@ Server_Game::~Server_Game()
|
|||
replayList.append(currentReplay);
|
||||
storeGameInformation();
|
||||
|
||||
for (int i = 0; i < replayList.size(); ++i)
|
||||
delete replayList[i];
|
||||
for (auto *replay : replayList) {
|
||||
delete replay;
|
||||
}
|
||||
replayList.clear();
|
||||
|
||||
room = nullptr;
|
||||
currentReplay = nullptr;
|
||||
creatorInfo = nullptr;
|
||||
|
||||
if (pingClock) {
|
||||
delete pingClock;
|
||||
pingClock = nullptr;
|
||||
}
|
||||
|
||||
qDebug() << "Server_Game destructor: gameId=" << gameId;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void Server_Game::storeGameInformation()
|
||||
|
|
@ -126,7 +139,7 @@ void Server_Game::storeGameInformation()
|
|||
ServerInfo_ReplayMatch *replayMatchInfo = replayEvent.mutable_match_info();
|
||||
replayMatchInfo->set_game_id(gameInfo.game_id());
|
||||
replayMatchInfo->set_room_name(room->getName().toStdString());
|
||||
replayMatchInfo->set_time_started(QDateTime::currentDateTime().addSecs(-secondsElapsed).toTime_t());
|
||||
replayMatchInfo->set_time_started(QDateTime::currentDateTime().addSecs(-secondsElapsed).toSecsSinceEpoch());
|
||||
replayMatchInfo->set_length(secondsElapsed);
|
||||
replayMatchInfo->set_game_name(gameInfo.description());
|
||||
|
||||
|
|
@ -769,6 +782,6 @@ void Server_Game::getInfo(ServerInfo_Game &result) const
|
|||
result.set_spectators_can_chat(spectatorsCanTalk);
|
||||
result.set_spectators_omniscient(spectatorsSeeEverything);
|
||||
result.set_spectators_count(getSpectatorCount());
|
||||
result.set_start_time(startTime.toTime_t());
|
||||
result.set_start_time(startTime.toSecsSinceEpoch());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ Server_Player::~Server_Player() = default;
|
|||
void Server_Player::prepareDestroy()
|
||||
{
|
||||
delete deck;
|
||||
deck = nullptr;
|
||||
|
||||
playerMutex.lock();
|
||||
if (userInterface) {
|
||||
|
|
@ -1234,7 +1235,6 @@ Server_Player::cmdAttachCard(const Command_AttachCard &cmd, ResponseContainer &
|
|||
return Response::RespContextError;
|
||||
}
|
||||
|
||||
// Get all arrows pointing to or originating from the card being attached and delete them.
|
||||
QMapIterator<int, Server_Player *> playerIterator(game->getPlayers());
|
||||
while (playerIterator.hasNext()) {
|
||||
Server_Player *p = playerIterator.next().value();
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QtMath>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <math.h>
|
||||
|
||||
Server_ProtocolHandler::Server_ProtocolHandler(Server *_server,
|
||||
Server_DatabaseInterface *_databaseInterface,
|
||||
|
|
@ -44,6 +44,7 @@ Server_ProtocolHandler::~Server_ProtocolHandler()
|
|||
}
|
||||
|
||||
// This function must only be called from the thread this object lives in.
|
||||
// Except when the server is shutting down.
|
||||
// The thread must not hold any server locks when calling this (e.g. clientsLock, roomsLock).
|
||||
void Server_ProtocolHandler::prepareDestroy()
|
||||
{
|
||||
|
|
@ -412,7 +413,7 @@ void Server_ProtocolHandler::pingClockTimeout()
|
|||
}
|
||||
}
|
||||
|
||||
if (((timeRunning - lastActionReceived) >= ceil(server->getIdleClientTimeout() * .9)) &&
|
||||
if (((timeRunning - lastActionReceived) >= qCeil(server->getIdleClientTimeout() * .9)) &&
|
||||
(!idleClientWarningSent) && (server->getIdleClientTimeout() > 0)) {
|
||||
Event_NotifyUser event;
|
||||
event.set_type(Event_NotifyUser::IDLEWARNING);
|
||||
|
|
@ -489,7 +490,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
Response_Login *re = new Response_Login;
|
||||
re->set_denied_reason_str(reasonStr.toStdString());
|
||||
if (banSecondsLeft != 0)
|
||||
re->set_denied_end_time(QDateTime::currentDateTime().addSecs(banSecondsLeft).toTime_t());
|
||||
re->set_denied_end_time(QDateTime::currentDateTime().addSecs(banSecondsLeft).toSecsSinceEpoch());
|
||||
rc.setResponseExtension(re);
|
||||
return Response::RespUserIsBanned;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ protected:
|
|||
private:
|
||||
QList<int> messageSizeOverTime, messageCountOverTime, commandCountOverTime;
|
||||
int timeRunning, lastDataReceived, lastActionReceived;
|
||||
QTimer *pingClock;
|
||||
|
||||
virtual void transmitProtocolItem(const ServerMessage &item) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ ServerInfo_User_Container::ServerInfo_User_Container(const ServerInfo_User_Conta
|
|||
if (other.userInfo)
|
||||
userInfo = new ServerInfo_User(*other.userInfo);
|
||||
else
|
||||
userInfo = 0;
|
||||
userInfo = nullptr;
|
||||
}
|
||||
|
||||
ServerInfo_User_Container::~ServerInfo_User_Container()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ protected:
|
|||
ServerInfo_User *userInfo;
|
||||
|
||||
public:
|
||||
ServerInfo_User_Container(ServerInfo_User *_userInfo = 0);
|
||||
ServerInfo_User_Container(ServerInfo_User *_userInfo = nullptr);
|
||||
ServerInfo_User_Container(const ServerInfo_User &_userInfo);
|
||||
ServerInfo_User_Container(const ServerInfo_User_Container &other);
|
||||
ServerInfo_User_Container &operator=(const ServerInfo_User_Container &other) = default;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#define STRINGSIZES_H
|
||||
|
||||
#include <QString>
|
||||
#include <QtMath>
|
||||
|
||||
// max size for short strings, like names and things that are generally a single phrase
|
||||
constexpr int MAX_NAME_LENGTH = 0xff;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue