Merge pull request #11 from CegepSTH/linux

Serveur Linux
This commit is contained in:
MarcEricMartel 2023-10-16 17:38:59 -04:00 committed by GitHub
commit 81240c6f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 127 additions and 12 deletions

5
.gitignore vendored
View File

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

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

@ -130,7 +130,7 @@ void World::GetScope(unsigned int& x, unsigned int& y) {
y = m_center[1];
}
void World::Update(Bullet* bullets[MAX_BULLETS], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
UpdateWorld(player_pos, blockinfo);
//TransposeWorld(player_pos, bullets);
}
@ -407,4 +407,4 @@ void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]
}*/
}
int World::GettbDeleted() const { return m_tbDeleted.size(); }
int World::GettbDeleted() const { return m_tbDeleted.size(); }

View File

@ -30,7 +30,7 @@ public:
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
void Update(Bullet* bullets[MAX_BULLETS], Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
void Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
void GetScope(unsigned int& x, unsigned int& y);

View File

@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.18.4)
project(SQCSim-Server VERSION 0.1)
add_compile_options("-Wno-narrowing")
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

@ -14,4 +14,4 @@
typedef unsigned char LogDest;
enum LOG_DEST { CONSOLE, LOGFILE, LOG_LAST };
#endif
#endif

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

@ -1,8 +1,14 @@
#ifndef AUDIO_H__
#define AUDIO_H__
#ifdef _WIN32
#include <irrKlang.h>
#include <ik_ISoundSource.h>
#else
#include "./external/irrKlang-64bit-1.6.0/include/irrKlang.h"
#include "./external/irrKlang-64bit-1.6.0/include/ik_ISoundSource.h"
#endif
#include "../SQCSim-common/vector3.h"
#include "define.h"
@ -29,4 +35,4 @@ public:
void PauseEngine();
};
#endif // AUDIO_H__
#endif // AUDIO_H__

View File

@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.18.4)
project(SQCSim-Client VERSION 0.8)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_STANDARD_REQUIRED True)
set(CMAKE_BUILD_DIRECTORY "./build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../")
set(SQCSIM_COMMON_DIR "../../SQCSim-common/")
set(SQCSIM_EXTERN_DIR "../external/")
find_package(SFML COMPONENTS system window graphics REQUIRED)
find_package(DevIL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_library(IRRKLANG_LIBRARY
NAMES libIrrKlang.so
PATHS "${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/lib/linux-gcc-64/")
include_directories(
${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/include/
${SFML_INCLUDE_DIRS}
${IL_INCLUDE_DIR}
)
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-client
"../audio.cpp"
"../connector.cpp"
"../engine.cpp"
"../mesh.cpp"
"../openglcontext.cpp"
"../shader.cpp"
"../skybox.cpp"
"../texture.cpp"
"../textureatlas.cpp"
"../tool.cpp"
"../vertexbuffer.cpp"
"../worldrenderer.cpp"
"../main.cpp"
)
target_link_libraries(SQCSim-client PUBLIC SQCSim-common
${IRRKLANG_LIBRARY}
sfml-system
sfml-window
sfml-graphics
GL
GLU
GLEW
${IL_LIBRARIES}
${ILU_LIBRARIES}
)

View File

@ -6,14 +6,18 @@
#include <iostream>
#include <chrono>
#include <iomanip>
#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "../SQCSim-common/define.h"
#ifdef _WIN32
#include <GL/glew.h>
#include <gl/GL.h>
#include <gl/GLU.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <climits>
#endif
#define NETWORK_TEST false

View File

View File

@ -0,0 +1 @@

View File

@ -7,7 +7,7 @@ void main()
texel = texture2D(tex,gl_TexCoord[0].st);
texel *= light;
texel.a = 255;
texel.a = 255.;
gl_FragColor = texel;
}