Redressage des classes; seed est reçue du serveur

This commit is contained in:
MarcEricMartel
2023-09-27 17:34:25 -04:00
parent 7eabee38ad
commit df52d4a084
8 changed files with 198 additions and 77 deletions

View File

@@ -76,6 +76,7 @@ int Server::Ready() {
char* buf = new char[150];
uint32_t buflen = 150;
bool readystart = false;
srand(time(NULL));
Log("<EFBFBD> l'<27>coute sur le port: " + std::to_string(SRV_PORT), false, false);
@@ -87,23 +88,35 @@ int Server::Ready() {
if (sock < 0)
Log("Erreur de connexion", true, false);
else if (sock > 0) {
std::string str = "Nouvelle connection provenant de: ";
char* strbuf = new char[150];
uint32_t strbuflen = 150;
std::cout << inet_ntop(AF_INET, &sockad.sin_addr, strbuf, strbuflen) << ':' << std::to_string(sockad.sin_port) << std::endl;;
str.append(inet_ntop(AF_INET, &sockad.sin_addr, strbuf, strbuflen)).append(": ").append(std::to_string(sockad.sin_port));
if (recv(sock, buf, buflen, 0) > 0) {
netprot::LoginInfo log;
if (netprot::Deserialize(&log, buf, buflen)) {
std::string str;
log.sid = 8675309; // EIGHT SIX SEVENFIVE THREE AUGHT NIIIIIIIIIiiIIIIiINE!
log.sid = ((uint64_t)rand() << 25) % 8675309; // EIGHT SIX SEVENFIVE THREE AUGHT NIIIIIIIIIiiIIIIiINE!
log.tid = 123456789;
str.append(" Nom: ").append(log.name);
Log(str, false, false);
str = "";
str.append(log.name).append(": ").append(std::to_string(log.sid));
str.append(log.name).append(" SID: [").append(std::to_string(log.sid).append("]"));
Log(str, false, false);
netprot::Serialize(&log, &buf, &buflen);
send(sock, buf, buflen, 0);
std::cin.getline(nullptr, 1);
buflen = 150;
Sleep(300);
netprot::GameInfo ginfo;
ginfo.countdown = 360;
ginfo.gameType = 1;
ginfo.seed = 9370707;
netprot::Serialize(&ginfo, &buf, &buflen);
send(sock, buf, buflen, 0);
Sleep(10000);
readystart = true;
}
}