IT'S LEAKING!

This commit is contained in:
MarcEricMartel 2023-12-07 13:34:58 -05:00
parent 4d44d57a5a
commit 33bcdea06f

View File

@ -224,9 +224,9 @@ void Server::Run() {
std::vector<Bullet*> bullets, outbox_bullets;
std::vector<BulletAdd*> netbull;
Chat* startchat;
Chat* startchat = new Chat();
startchat->src_id = 0;
char startmess[] = "How would YOU like to die today, motherfuckers?";
char startmess[] = "How would -YOU- like to die today, motherfuckers?";
strcpy(startchat->mess, 140, startmess);
@ -244,7 +244,7 @@ void Server::Run() {
sync_acc -= 1000;
--timer;
std::string str = "Timer: ";
Log(str.append(std::to_string(timer).append(" SyncAcc: ").append(std::to_string(sync_acc))), false, false);
Log(str.append(std::to_string(timer)), false, false);
}
last = tstamp;
@ -296,7 +296,7 @@ void Server::Run() {
}
else {
for (auto& chmo : conn->ChunkDiffs)
chunkdiffs.emplace_back(chmo);
chunkdiffs.emplace_back(std::move(chmo));
conn->ChunkDiffs.clear();
for (auto& bull : conn->Bullets) {
@ -308,7 +308,7 @@ void Server::Run() {
nbul->id = key;
nbul->tstamp = tstamp;
netbull.emplace_back(nbul);
netbull.emplace_back(std::move(nbul));
}
conn->Bullets.clear();
}
@ -333,10 +333,11 @@ void Server::Run() {
ChunkMod* cmod = nullptr;
if (bull->Update(m_world, (1. / 60.), 20, m_players, &cmod)) {
if (cmod)
chunkdiffs.emplace_back(cmod);
chunkdiffs.emplace_back(std::move(cmod));
outbox_bullets.emplace_back(std::move(bull));
}
}
netbull.clear();
for (auto& chat : chatlog) {
Log(chat->mess, false, false);
@ -344,16 +345,18 @@ void Server::Run() {
sendPackTo<Chat>(m_sock_udp, chat, &m_buf, conn->getAddr());
delete chat;
}
chatlog.clear();
for (auto& chmo : chunkdiffs) {
for (auto& [key, conn] : m_conns)
sendPackTo<ChunkMod>(m_sock_udp, chmo, &m_buf, conn->getAddr());
delete chmo;
}
netbull.clear();
chunkdiffs.clear();
chatlog.clear();
for (auto& bull : outbox_bullets)
delete bull;
outbox_bullets.clear();
}
Chat end;