Début protocole
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
Connection::Connection(in_addr addr,
|
||||
std::string name,
|
||||
UINT64 id,
|
||||
UINT64 self_id,
|
||||
UINT64 team_id):
|
||||
uint64_t id,
|
||||
uint64_t self_id,
|
||||
uint64_t team_id):
|
||||
m_addr(addr),
|
||||
m_id(id),
|
||||
m_sid(self_id),
|
||||
@@ -19,9 +19,9 @@ Connection::~Connection() {
|
||||
|
||||
in_addr Connection::GetAddr() const { return m_addr; }
|
||||
|
||||
UINT64 Connection::GetHash(bool self) const { return self? m_sid: m_id; }
|
||||
uint64_t Connection::GetHash(bool self) const { return self? m_sid: m_id; }
|
||||
|
||||
UINT64 Connection::GetTeamHash() const { return m_tid; }
|
||||
uint64_t Connection::GetTeamHash() const { return m_tid; }
|
||||
|
||||
std::string Connection::GetName() const { return m_name; }
|
||||
|
||||
|
@@ -4,42 +4,24 @@
|
||||
#include <map>
|
||||
#include "../SQCSim-common/player.h"
|
||||
#include "../SQCSim-common/vector3.h"
|
||||
#include "../SQCSim-common/serialization.h"
|
||||
#include "define.h"
|
||||
|
||||
struct Input {
|
||||
Timestamp timestamp;
|
||||
UINT8 keys; // 0bFBLRJS__
|
||||
Vector3f direction;
|
||||
};
|
||||
|
||||
struct Output {
|
||||
Timestamp timestamp;
|
||||
UINT64 id = 0;
|
||||
Vector3f position, direction;
|
||||
bool is_shooting, is_jumping;
|
||||
};
|
||||
|
||||
struct Sync {
|
||||
Timestamp timestamp;
|
||||
UINT64 sid = 0;
|
||||
Vector3f position;
|
||||
};
|
||||
|
||||
class Connection {
|
||||
public:
|
||||
Connection(
|
||||
in_addr addr,
|
||||
std::string name,
|
||||
UINT64 hash,
|
||||
UINT64 self_hash,
|
||||
UINT64 team_hash);
|
||||
uint64_t hash,
|
||||
uint64_t self_hash,
|
||||
uint64_t team_hash);
|
||||
~Connection();
|
||||
|
||||
Player* player = nullptr;
|
||||
|
||||
in_addr GetAddr() const;
|
||||
UINT64 GetHash(bool self = true) const;
|
||||
UINT64 GetTeamHash() const;
|
||||
uint64_t GetHash(bool self = true) const;
|
||||
uint64_t GetTeamHash() const;
|
||||
std::string GetName() const;
|
||||
|
||||
void AddInput(Input in);
|
||||
@@ -51,7 +33,7 @@ private:
|
||||
std::map<Timestamp, Input> m_input_manifest;
|
||||
std::map<Timestamp, Output> m_output_manifest;
|
||||
in_addr m_addr;
|
||||
UINT64 m_id,
|
||||
uint64_t m_id,
|
||||
m_sid,
|
||||
m_tid;
|
||||
std::string m_name;
|
||||
|
@@ -6,38 +6,9 @@
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
#define MAX_CONNECTIONS 16
|
||||
typedef unsigned char LogDest;
|
||||
enum LOG_DEST { CONSOLE, LOGFILE, LOG_LAST };
|
||||
typedef std::chrono::system_clock::time_point Timestamp;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#pragma comment(lib,"wsock32.lib") // Pour pouvoir faire fonctionner le linker sans le vcxproject
|
||||
|
||||
#include <Windows.h>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
|
||||
#else // Pas _WIN32
|
||||
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#define SOCKET int
|
||||
#define INVALID_SOCKET -1
|
||||
#define closesocket close
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user