2023-09-24 11:07:03 -04:00
|
|
|
#ifndef CONNECTION_H__
|
|
|
|
#define CONNECTION_H__
|
2023-09-30 14:54:39 -04:00
|
|
|
|
2023-09-24 08:45:40 -04:00
|
|
|
#include <deque>
|
2023-11-06 13:56:12 -05:00
|
|
|
#include <unordered_map>
|
2023-09-24 08:45:40 -04:00
|
|
|
#include "../SQCSim-common/player.h"
|
|
|
|
#include "../SQCSim-common/vector3.h"
|
2023-09-25 16:30:03 -04:00
|
|
|
#include "../SQCSim-common/netprotocol.h"
|
2023-11-06 16:43:52 -05:00
|
|
|
#include "../SQCSim-common/world.h"
|
2023-09-24 08:45:40 -04:00
|
|
|
#include "define.h"
|
|
|
|
|
2023-10-25 12:16:14 -04:00
|
|
|
using namespace netprot;
|
|
|
|
|
2023-09-24 08:45:40 -04:00
|
|
|
class Connection {
|
|
|
|
public:
|
|
|
|
Connection(
|
2023-09-27 17:34:25 -04:00
|
|
|
SOCKET sock,
|
|
|
|
sockaddr_in sockaddr,
|
2023-12-09 12:02:04 -05:00
|
|
|
LoginInfo *log,
|
|
|
|
PlayerInfo *play);
|
2023-09-24 08:45:40 -04:00
|
|
|
~Connection();
|
|
|
|
|
2023-12-05 06:25:48 -05:00
|
|
|
Player* player = nullptr;
|
2023-09-24 08:45:40 -04:00
|
|
|
|
2023-09-25 08:23:52 -04:00
|
|
|
uint64_t GetHash(bool self = true) const;
|
|
|
|
uint64_t GetTeamHash() const;
|
2023-09-24 08:45:40 -04:00
|
|
|
std::string GetName() const;
|
|
|
|
|
2023-10-25 12:16:14 -04:00
|
|
|
void AddInput(Input in);
|
|
|
|
Output* getOutput(Timestamp time);
|
|
|
|
Sync getSync(Timestamp time);
|
|
|
|
SOCKET getSock() const;
|
|
|
|
PlayerInfo* getInfo() const;
|
2023-10-26 17:57:42 -04:00
|
|
|
sockaddr_in* getAddr() const;
|
2023-09-24 11:07:03 -04:00
|
|
|
|
2023-11-06 17:59:57 -05:00
|
|
|
void getPacks(SOCKET sock);
|
2023-12-05 13:44:54 -05:00
|
|
|
void sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns, const uint32_t timer);
|
2023-11-06 16:43:52 -05:00
|
|
|
|
2023-12-05 06:25:48 -05:00
|
|
|
Timestamp Run(World* world);
|
2023-11-06 16:43:52 -05:00
|
|
|
|
2023-09-24 11:07:03 -04:00
|
|
|
void CleanInputManifest(Timestamp time);
|
2023-11-24 15:32:53 -05:00
|
|
|
|
|
|
|
bool m_nsync = true;
|
2023-12-02 10:04:18 -05:00
|
|
|
|
2023-12-06 11:16:39 -05:00
|
|
|
std::vector<Bullet*> Bullets;
|
|
|
|
std::vector<ChunkMod*> ChunkDiffs;
|
2023-12-02 10:04:18 -05:00
|
|
|
|
2023-12-05 06:25:48 -05:00
|
|
|
Timestamp GetTStamp() const;
|
|
|
|
|
2023-09-24 08:45:40 -04:00
|
|
|
private:
|
2023-11-06 13:56:12 -05:00
|
|
|
std::unordered_map<Timestamp, Input> m_input_manifest;
|
2023-12-05 13:44:54 -05:00
|
|
|
std::vector<Input> m_input_vector;
|
2023-11-06 13:56:12 -05:00
|
|
|
std::unordered_map<Timestamp, Output> m_output_manifest;
|
2023-12-05 13:44:54 -05:00
|
|
|
std::deque<Output> m_output_vector;
|
2023-11-06 13:56:12 -05:00
|
|
|
std::unordered_map<Timestamp, Chat> m_chatlog;
|
2023-09-27 17:34:25 -04:00
|
|
|
|
2023-12-02 11:05:00 -05:00
|
|
|
float m_shoot_acc = 0;
|
2023-12-05 06:25:48 -05:00
|
|
|
Timestamp m_tstamp = 0;
|
2023-12-02 10:04:18 -05:00
|
|
|
|
2023-10-23 16:21:15 -04:00
|
|
|
SOCKET m_sock;
|
2023-09-27 17:34:25 -04:00
|
|
|
sockaddr_in m_addr;
|
2023-10-25 12:16:14 -04:00
|
|
|
LoginInfo m_loginfo;
|
|
|
|
PlayerInfo m_playinfo;
|
2023-09-24 08:45:40 -04:00
|
|
|
|
2023-11-06 17:59:57 -05:00
|
|
|
Timestamp m_startsync;
|
|
|
|
|
|
|
|
uint64_t m_last_in = 0,
|
|
|
|
m_last_out = 0;
|
|
|
|
Buffer m_buf,
|
|
|
|
m_bufout;
|
2023-09-24 08:45:40 -04:00
|
|
|
};
|
2023-10-26 17:57:42 -04:00
|
|
|
#endif
|