Ajout CMakeLists.txt pour compiler le serveur en Linux

This commit is contained in:
Marc-Éric Martel 2023-10-01 11:52:07 -04:00
parent bfda5e8948
commit 8be8852596
8 changed files with 39 additions and 6 deletions

2
.gitignore vendored
View File

@ -373,3 +373,5 @@ FodyWeavers.xsd
/x64/Release/SQCSim2023.exe
/x64/Debug/SQCSim2023.exe
/x64/Debug/SQCSim2021.pdb
/SQCSim-srv/cmake/*
!/SQCSim-srv/cmake/CMakeLists.txt

View File

@ -53,6 +53,7 @@ typedef uint64_t Timestamp;
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <cstring>
#define SOCKET int
#define INVALID_SOCKET -1

View File

@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.18.4)
project(SQCSim-Server VERSION 0.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_STANDARD_REQUIRED True)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../out")
set(SQCSIM_COMMON_DIR "../../SQCSim-common/")
add_library(SQCSim-common
"${SQCSIM_COMMON_DIR}blockinfo.cpp"
"${SQCSIM_COMMON_DIR}bullet.cpp"
"${SQCSIM_COMMON_DIR}chunk.cpp"
"${SQCSIM_COMMON_DIR}netprotocol.cpp"
"${SQCSIM_COMMON_DIR}opensimplex.cpp"
"${SQCSIM_COMMON_DIR}player.cpp"
"${SQCSIM_COMMON_DIR}transformation.cpp"
"${SQCSIM_COMMON_DIR}world.cpp"
)
add_executable(SQCSim-server
"../connection.cpp"
"../server.cpp"
"../main.cpp"
)
target_link_libraries(SQCSim-server PUBLIC SQCSim-common)

View File

@ -85,7 +85,7 @@ int Server::Ready() {
while (!readystart) {
sockaddr_in sockad;
int addrlen = sizeof(sockad);
unsigned int addrlen = sizeof(sockad);
SOCKET sock = accept(m_sock_tcp, (sockaddr*)&sockad, &addrlen);
if (sock < 0)
@ -140,7 +140,7 @@ void Server::Run() {
Log("Partie en cours...", false, false);
}
inline std::string Server::Timestamp() {
inline std::string Server::LogTimestamp() {
time_t rawtime;
struct tm timeinfo;
char buffer[80];
@ -162,11 +162,11 @@ inline std::string Server::Timestamp() {
void Server::Log(std::string str, bool is_error = false, bool is_fatal = false) {
switch (m_log) {
case LOG_DEST::LOGFILE:
m_logfile << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
m_logfile << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
break;
case LOG_DEST::CONSOLE:
default:
std::cout << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
std::cout << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
break;
}

View File

@ -35,7 +35,7 @@ private:
World* m_world = nullptr;
std::string Timestamp();
std::string LogTimestamp();
void Log(std::string str, bool is_error, bool is_fatal);
void buildIdList(size_t size);

View File

View File

@ -0,0 +1 @@