About a lucky man who made the grade
This commit is contained in:
@@ -74,29 +74,39 @@ namespace netprot {
|
||||
uint16_t ammo = 0;
|
||||
uint8_t hp = 0;
|
||||
Vector3f position;
|
||||
Sync() {}
|
||||
Sync(Sync* sync) : timestamp(sync->timestamp), sid(sync->sid), timer(sync->timer), ammo(sync->ammo), hp(sync->hp), position(sync->position) {}
|
||||
};
|
||||
|
||||
struct TeamInfo { // cli <-> srv TCP once
|
||||
char name[32];
|
||||
uint64_t id = 0;
|
||||
TeamInfo() {}
|
||||
TeamInfo(TeamInfo* tem) : id(tem->id) { strcpy_s(tem->name, name); }
|
||||
};
|
||||
|
||||
struct LoginInfo { // cli <-> srv TCP once
|
||||
char name[32];
|
||||
uint64_t sid = 0,
|
||||
tid = 0;
|
||||
LoginInfo() {}
|
||||
LoginInfo(LoginInfo* ply): sid(ply->sid), tid(ply->tid) { strcpy_s(ply->name, name); }
|
||||
};
|
||||
|
||||
struct PlayerInfo { // cli <-> srv TCP once
|
||||
char name[32];
|
||||
uint64_t id = 0,
|
||||
tid = 0;
|
||||
PlayerInfo() {}
|
||||
PlayerInfo(PlayerInfo* log) : id(log->id), tid(log->tid) { strcpy_s(log->name, name); }
|
||||
};
|
||||
|
||||
struct GameInfo { // cli <-> srv TCP event (before game start)/ once
|
||||
uint64_t seed;
|
||||
uint32_t countdown;
|
||||
uint8_t gameType; // TOOD: enum.
|
||||
uint8_t gameType; // TODD: enum.
|
||||
GameInfo() {}
|
||||
GameInfo(GameInfo* gam) : seed(gam->seed), countdown(gam->countdown), gameType(gam->gameType) {}
|
||||
};
|
||||
|
||||
struct Chat { // cli <-> srv TCP event
|
||||
@@ -104,11 +114,15 @@ namespace netprot {
|
||||
dest_id = 0,
|
||||
dest_team_id = 0;
|
||||
char mess[140]; // Good 'nough for twitr, good 'nough for me.
|
||||
Chat() {}
|
||||
Chat(Chat* cha) : src_id(cha->src_id), dest_id(cha->dest_id), dest_team_id(cha->dest_team_id) { strcpy_s(cha->mess, mess); }
|
||||
};
|
||||
|
||||
struct ErrorLog { // srv -> cli TCP event
|
||||
char mess[140];
|
||||
bool is_fatal;
|
||||
ErrorLog() {};
|
||||
ErrorLog(ErrorLog* err) : is_fatal(err->is_fatal) { strcpy_s(err->mess, mess); }
|
||||
};
|
||||
|
||||
void Serialize(Input* in, char* buf[], uint32_t* buflen); // cli
|
||||
@@ -138,7 +152,7 @@ namespace netprot {
|
||||
|
||||
bool emptyPack(Packet pck);
|
||||
|
||||
Packet makePack(void* ptr, PACKET_TYPE type); // Pour pouvoir faire une liste de stock à supprimer sans avoir à en faire une pour chaque type.
|
||||
Packet makePack(void* ptr, PACKET_TYPE type); // Pour pouvoir faire une liste de stock a supprimer sans avoir a en faire une pour chaque type.
|
||||
|
||||
template <class T> void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen);
|
||||
template <class T> void sendPackTo(SOCKET sock, T* pack, char** buf, uint32_t* buflen, sockaddr_in* sockad);
|
||||
@@ -151,8 +165,8 @@ namespace netprot {
|
||||
template <class T>
|
||||
void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen) {
|
||||
netprot::Serialize(pack, buf, buflen);
|
||||
memset(buf->ptr[buf->len], , '\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buf->len += sizeof(uint64_t) + sizeof(uint8_t)
|
||||
memset(&buf[*buflen], '\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buflen += sizeof(uint64_t) + sizeof(uint8_t);
|
||||
send(sock, *buf, *buflen, 0);
|
||||
*buflen = BUFFER_LENGTH;
|
||||
}
|
||||
@@ -161,8 +175,8 @@ namespace netprot {
|
||||
void sendPackTo(SOCKET sock, T* pack, char** buf, uint32_t* buflen, sockaddr_in* sockad) {
|
||||
sockaddr_in addr = *sockad;
|
||||
netprot::Serialize(pack, buf, buflen);
|
||||
memset(buf->ptr[buf->len], , '\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buf->len += sizeof(uint64_t) + sizeof(uint8_t)
|
||||
memset(&buf[*buflen], '\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buflen += sizeof(uint64_t) + sizeof(uint8_t);
|
||||
sendto(sock, *buf, *buflen, 0, (sockaddr*)&addr, sizeof(addr));
|
||||
*buflen = BUFFER_LENGTH;
|
||||
}
|
||||
@@ -170,8 +184,8 @@ namespace netprot {
|
||||
template <class T>
|
||||
void sendPack(SOCKET sock, T* pack, Buffer* buf) {
|
||||
netprot::Serialize(pack, &buf->ptr, &buf->len);
|
||||
memset(buf->ptr[buf->len], , '\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buf->len += sizeof(uint64_t) + sizeof(uint8_t)
|
||||
memset(&buf->ptr[buf->len], '\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buf->len += sizeof(uint64_t) + sizeof(uint8_t);
|
||||
send(sock, buf->ptr, buf->len, 0);
|
||||
buf->rstLen();
|
||||
}
|
||||
@@ -180,8 +194,8 @@ namespace netprot {
|
||||
void sendPackTo(SOCKET sock, T* pack, Buffer* buf, sockaddr_in* sockad) {
|
||||
sockaddr_in addr = *sockad;
|
||||
netprot::Serialize(pack, &buf->ptr, &buf->len);
|
||||
memset(buf->ptr[buf->len], ,'\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buf->len += sizeof(uint64_t) + sizeof(uint8_t)
|
||||
memset(&buf->ptr[buf->len], '\0', sizeof(uint64_t) + sizeof(uint8_t));
|
||||
buf->len += sizeof(uint64_t) + sizeof(uint8_t);
|
||||
sendto(sock, buf->ptr, buf->len, 0, (sockaddr*)&addr, sizeof(addr));
|
||||
buf->rstLen();
|
||||
}
|
||||
|
Reference in New Issue
Block a user