Rollover Beethoven
This commit is contained in:
parent
6178604d95
commit
7077b617be
@ -405,7 +405,14 @@ void netprot::Serialize(Chat* chat, char* buf[], uint32_t* buflen) {
|
||||
|
||||
size_t messize = std::strlen(chat->mess) + 1;
|
||||
|
||||
memcpy(*buf + 1 + sizeof(uint64_t) * 3, &chat->mess, messize);
|
||||
std::cout << chat->mess << ": ";
|
||||
|
||||
strcpy(*buf + 1 + sizeof(uint64_t) * 3, messize, chat->mess);
|
||||
|
||||
//memcpy(*buf + 1 + sizeof(uint64_t) * 3, &chat->mess, messize);
|
||||
|
||||
for (int x = 0; x < sizeof(Chat); ++x)
|
||||
std::cout << *(*buf + x);
|
||||
|
||||
*buflen = messize + sizeof(uint64_t) * 3 + 2;
|
||||
}
|
||||
@ -928,6 +935,9 @@ bool netprot::Deserialize(Chat* chat, char* buf, uint32_t *buflen) {
|
||||
if (messsize > 140)
|
||||
return false;
|
||||
|
||||
for (int x = 0; x < 140; ++x)
|
||||
std::cout << buf[sizeof(uint64_t) * 3 + x];
|
||||
|
||||
memcpy(&chat->mess, &buf[1 + sizeof(uint64_t) * 3], messsize);
|
||||
|
||||
*buflen = messsize + sizeof(uint64_t) * 3 + 2;
|
||||
|
@ -129,7 +129,7 @@ namespace netprot {
|
||||
Chat() {}
|
||||
Chat(Chat* cha) : src_id(cha->src_id), dest_id(cha->dest_id), dest_team_id(cha->dest_team_id) {
|
||||
strcpy(mess, 140, cha->mess); }
|
||||
~Chat() { delete[] mess; }
|
||||
~Chat() {/* delete[] mess; */}
|
||||
};
|
||||
|
||||
struct ChunkMod {
|
||||
|
@ -83,17 +83,18 @@ int Server::Ready() {
|
||||
m_game.countdown = 0;
|
||||
}
|
||||
} while (m_game.countdown < 1);
|
||||
do {
|
||||
m_game.seed = 9370707;
|
||||
/*do {
|
||||
Log("Entrez le seed de la partie: ", false, false);
|
||||
std::cin.getline(m_buf.ptr, BUFFER_LENGTH);
|
||||
try {
|
||||
m_game.seed = 9370707;//std::stoi(m_buf.ptr);
|
||||
std::stoi(m_buf.ptr);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
Log(e.what(), true, false);
|
||||
m_game.seed = 0;
|
||||
}
|
||||
} while (m_game.seed < 1);
|
||||
} while (m_game.seed < 1);*/
|
||||
do {
|
||||
Log("Entrez le nombre de joueurs: ", false, false);
|
||||
std::cin.getline(m_buf.ptr, BUFFER_LENGTH);
|
||||
@ -312,10 +313,12 @@ void Server::Run() {
|
||||
endgame = true;
|
||||
}
|
||||
|
||||
for (auto& bull : netbull)
|
||||
for (auto& bull : netbull) {
|
||||
for (auto& [key, conn] : m_conns)
|
||||
if (bull->id != conn->GetHash(false)) // Pour pas repitcher au joueur sa propre balle.
|
||||
sendPackTo<BulletAdd>(m_sock_udp, bull, &m_buf, conn->getAddr());
|
||||
delete bull;
|
||||
}
|
||||
|
||||
|
||||
for (auto& bull : bullets) {
|
||||
@ -327,6 +330,10 @@ void Server::Run() {
|
||||
}
|
||||
}
|
||||
|
||||
//for (auto& bull : outbox_bullets)
|
||||
// delete bull;
|
||||
//outbox_bullets.clear();
|
||||
|
||||
for (auto& chat : chatlog) {
|
||||
Log(chat->mess, false, false);
|
||||
for (auto& [key, conn] : m_conns)
|
||||
@ -340,7 +347,6 @@ void Server::Run() {
|
||||
delete chmo;
|
||||
}
|
||||
|
||||
outbox_bullets.clear();
|
||||
netbull.clear();
|
||||
chunkdiffs.clear();
|
||||
chatlog.clear();
|
||||
|
@ -90,7 +90,7 @@ void Engine::Init() {
|
||||
RemotePlayer* rt = (RemotePlayer*)m_players[key];
|
||||
rt->SetPosition(Vector3f(555, 555, 555));
|
||||
}
|
||||
|
||||
m_player.m_username = playname;
|
||||
seed = 9370707;//m_conn.getSeed();
|
||||
m_networkgame = true;
|
||||
}
|
||||
@ -659,17 +659,17 @@ void Engine::PrintText(float x, float y, const std::string& t, float charSizeMul
|
||||
int Engine::GetFps(float elapsedTime) const { return 1 / elapsedTime; }
|
||||
|
||||
int Engine::GetCountdown(float elapsedTime) {
|
||||
if (m_resetcountdown) {
|
||||
m_nbReductionChunk = 4;
|
||||
m_timerReductionChunk = 30;
|
||||
m_countdown = m_time + COUNTDOWN;
|
||||
m_resetcountdown = false;
|
||||
}
|
||||
if (m_countdown < m_time) {}
|
||||
//Stop();
|
||||
if (!m_stopcountdown)
|
||||
m_time += elapsedTime;
|
||||
return m_countdown - (int)m_time;
|
||||
//if (m_resetcountdown) {
|
||||
// m_nbReductionChunk = 4;
|
||||
// m_timerReductionChunk = 30;
|
||||
// m_countdown = m_time + COUNTDOWN;
|
||||
// m_resetcountdown = false;
|
||||
// }
|
||||
// if (m_countdown < m_time) {}
|
||||
// Stop();
|
||||
//if (!m_stopcountdown)
|
||||
// m_time += elapsedTime;
|
||||
return m_countdown;// -(int)m_time;
|
||||
}
|
||||
|
||||
int Engine::GetOptionsChoice() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user