but I just had to laugh

This commit is contained in:
MarcEricMartel 2023-10-28 12:13:45 -04:00
parent a69e716105
commit 10fcfed05a
4 changed files with 8 additions and 11 deletions

View File

@ -46,6 +46,7 @@ typedef uint64_t Timestamp;
#include <cstdio> #include <cstdio>
#include <ctime> #include <ctime>
#define strcpy strcpy_s
#define addrlen_t int #define addrlen_t int
#define popen _popen #define popen _popen
#define pclose _pclose #define pclose _pclose

View File

@ -82,7 +82,7 @@ namespace netprot {
char name[32]; char name[32];
uint64_t id = 0; uint64_t id = 0;
TeamInfo() {} TeamInfo() {}
TeamInfo(TeamInfo* tem) : id(tem->id) { strcpy_s(tem->name, name); } TeamInfo(TeamInfo* tem) : id(tem->id) { strcpy(tem->name, name); }
}; };
struct LoginInfo { // cli <-> srv TCP once struct LoginInfo { // cli <-> srv TCP once
@ -90,7 +90,7 @@ namespace netprot {
uint64_t sid = 0, uint64_t sid = 0,
tid = 0; tid = 0;
LoginInfo() {} LoginInfo() {}
LoginInfo(LoginInfo* ply): sid(ply->sid), tid(ply->tid) { strcpy_s(ply->name, name); } LoginInfo(LoginInfo* ply): sid(ply->sid), tid(ply->tid) { strcpy(ply->name, name); }
}; };
struct PlayerInfo { // cli <-> srv TCP once struct PlayerInfo { // cli <-> srv TCP once
@ -98,7 +98,7 @@ namespace netprot {
uint64_t id = 0, uint64_t id = 0,
tid = 0; tid = 0;
PlayerInfo() {} PlayerInfo() {}
PlayerInfo(PlayerInfo* log) : id(log->id), tid(log->tid) { strcpy_s(log->name, name); } PlayerInfo(PlayerInfo* log) : id(log->id), tid(log->tid) { strcpy(log->name, name); }
}; };
struct GameInfo { // cli <-> srv TCP event (before game start)/ once struct GameInfo { // cli <-> srv TCP event (before game start)/ once
@ -115,14 +115,14 @@ namespace netprot {
dest_team_id = 0; dest_team_id = 0;
char mess[140]; // Good 'nough for twitr, good 'nough for me. char mess[140]; // Good 'nough for twitr, good 'nough for me.
Chat() {} 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); } Chat(Chat* cha) : src_id(cha->src_id), dest_id(cha->dest_id), dest_team_id(cha->dest_team_id) { strcpy(cha->mess, mess); }
}; };
struct ErrorLog { // srv -> cli TCP event struct ErrorLog { // srv -> cli TCP event
char mess[140]; char mess[140];
bool is_fatal; bool is_fatal;
ErrorLog() {}; ErrorLog() {};
ErrorLog(ErrorLog* err) : is_fatal(err->is_fatal) { strcpy_s(err->mess, mess); } ErrorLog(ErrorLog* err) : is_fatal(err->is_fatal) { strcpy(err->mess, mess); }
}; };
void Serialize(Input* in, char* buf[], uint32_t* buflen); // cli void Serialize(Input* in, char* buf[], uint32_t* buflen); // cli

View File

@ -11,8 +11,4 @@
#define ID_LIST_SIZE 127 #define ID_LIST_SIZE 127
#define SRV_MANUAL_SETUP true #define SRV_MANUAL_SETUP true
#ifdef _WIN32
#define strcpy strcpy_s
#endif
#endif #endif

View File

@ -57,14 +57,14 @@ int Connector::Connect(const char* srv_addr, std::string name) {
return 2; return 2;
} }
if (ioctlsocket(m_sock_tcp, FIONBIO, NULL) < 0) { if (ioctlsocket(m_sock_tcp, FIONBIO, nullptr) < 0) {
std::cout << "Impossible de mettre le socket en mode non-bloquant." << std::endl; std::cout << "Impossible de mettre le socket en mode non-bloquant." << std::endl;
return 3; return 3;
} }
netprot::Buffer bf; netprot::Buffer bf;
netprot::LoginInfo log; netprot::LoginInfo log;
strcpy_s(log.name, name.c_str()); strcpy(log.name, name.c_str());
netprot::sendPack(m_sock_tcp, &log, &bf); netprot::sendPack(m_sock_tcp, &log, &bf);