Turn Card, Deck_List, Protocol, RNG, Network (Client, Server), Settings and Utility into libraries and remove cockatrice_common. (#6212)

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
BruebachL 2025-10-09 07:36:12 +02:00 committed by GitHub
parent be1403c920
commit 1ef07309d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
605 changed files with 3812 additions and 3408 deletions

View file

@ -0,0 +1,23 @@
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(HEADERS local_client.h)
set(SOURCES local_client.cpp)
if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif()
add_library(libcockatrice_network_client_local STATIC ${MOC_SOURCES} ${SOURCES})
add_dependencies(libcockatrice_network_client_local libcockatrice_network_client_abstract)
target_include_directories(libcockatrice_network_client_local PUBLIC .)
target_link_libraries(
libcockatrice_network_client_local PUBLIC ${COCKATRICE_QT_MODULES} libcockatrice_network_client_abstract
)

View file

@ -0,0 +1,44 @@
#include "local_client.h"
#include "../../server/local/local_server_interface.h"
#include <libcockatrice/protocol/debug_pb_message.h>
#include <libcockatrice/protocol/pb/session_commands.pb.h>
LocalClient::LocalClient(LocalServerInterface *_lsi,
const QString &_playerName,
const QString &_clientId,
QObject *parent)
: AbstractClient(parent), lsi(_lsi)
{
connect(lsi, &LocalServerInterface::itemToClient, this, &LocalClient::itemFromServer);
userName = _playerName;
Command_Login loginCmd;
loginCmd.set_user_name(_playerName.toStdString());
loginCmd.set_clientid(_clientId.toStdString());
sendCommand(prepareSessionCommand(loginCmd));
Command_JoinRoom joinCmd;
joinCmd.set_room_id(0);
sendCommand(prepareSessionCommand(joinCmd));
}
LocalClient::~LocalClient()
{
}
void LocalClient::sendCommandContainer(const CommandContainer &cont)
{
qCDebug(LocalClientLog).noquote() << userName << "OUT" << getSafeDebugString(cont);
lsi->itemFromClient(cont);
}
void LocalClient::itemFromServer(const ServerMessage &item)
{
qCDebug(LocalClientLog).noquote() << userName << "IN" << getSafeDebugString(item);
processProtocolItem(item);
}

View file

@ -0,0 +1,36 @@
/**
* @file local_client.h
* @ingroup Client
* @brief TODO: Document this.
*/
#ifndef LOCALCLIENT_H
#define LOCALCLIENT_H
#include "../abstract/abstract_client.h"
#include <QLoggingCategory>
inline Q_LOGGING_CATEGORY(LocalClientLog, "local_client");
class LocalServerInterface;
class LocalClient : public AbstractClient
{
Q_OBJECT
private:
LocalServerInterface *lsi;
public:
LocalClient(LocalServerInterface *_lsi,
const QString &_playerName,
const QString &_clientId,
QObject *parent = nullptr);
~LocalClient() override;
void sendCommandContainer(const CommandContainer &cont) override;
private slots:
void itemFromServer(const ServerMessage &item);
};
#endif