2023-09-24 11:07:03 -04:00
|
|
|
#ifndef CONNECTION_H__
|
|
|
|
#define CONNECTION_H__
|
2023-09-24 08:45:40 -04:00
|
|
|
#include <deque>
|
2023-09-24 11:07:03 -04:00
|
|
|
#include <map>
|
2023-09-24 08:45:40 -04:00
|
|
|
#include "../SQCSim-common/player.h"
|
|
|
|
#include "../SQCSim-common/vector3.h"
|
|
|
|
#include "define.h"
|
|
|
|
|
|
|
|
struct Input {
|
2023-09-24 11:07:03 -04:00
|
|
|
Timestamp timestamp;
|
2023-09-24 08:45:40 -04:00
|
|
|
UINT8 keys; // 0bFBLRJS__
|
|
|
|
Vector3f direction;
|
|
|
|
};
|
|
|
|
|
2023-09-24 11:07:03 -04:00
|
|
|
struct Output {
|
|
|
|
Timestamp timestamp;
|
|
|
|
UINT64 id = 0;
|
|
|
|
Vector3f position, direction;
|
|
|
|
bool is_shooting, is_jumping;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sync {
|
|
|
|
Timestamp timestamp;
|
|
|
|
UINT64 sid = 0;
|
|
|
|
Vector3f position;
|
|
|
|
};
|
|
|
|
|
2023-09-24 08:45:40 -04:00
|
|
|
class Connection {
|
|
|
|
public:
|
|
|
|
Connection(
|
|
|
|
in_addr addr,
|
|
|
|
std::string name,
|
|
|
|
UINT64 hash,
|
|
|
|
UINT64 self_hash,
|
|
|
|
UINT64 team_hash);
|
|
|
|
~Connection();
|
|
|
|
|
|
|
|
Player* player = nullptr;
|
|
|
|
|
|
|
|
in_addr GetAddr() const;
|
|
|
|
UINT64 GetHash(bool self = true) const;
|
|
|
|
UINT64 GetTeamHash() const;
|
|
|
|
std::string GetName() const;
|
|
|
|
|
2023-09-24 11:07:03 -04:00
|
|
|
void AddInput(Input in);
|
|
|
|
Output* getOutput(Timestamp time);
|
|
|
|
Sync getSync(Timestamp time);
|
|
|
|
|
|
|
|
void CleanInputManifest(Timestamp time);
|
2023-09-24 08:45:40 -04:00
|
|
|
private:
|
2023-09-24 11:07:03 -04:00
|
|
|
std::map<Timestamp, Input> m_input_manifest;
|
|
|
|
std::map<Timestamp, Output> m_output_manifest;
|
2023-09-24 08:45:40 -04:00
|
|
|
in_addr m_addr;
|
2023-09-24 11:07:03 -04:00
|
|
|
UINT64 m_id,
|
|
|
|
m_sid,
|
|
|
|
m_tid;
|
2023-09-24 08:45:40 -04:00
|
|
|
std::string m_name;
|
|
|
|
|
|
|
|
};
|
|
|
|
#endif
|