keep in sync when dead

This commit is contained in:
MarcEricMartel 2023-12-13 16:29:13 -05:00
parent 7b350fa403
commit 325c6b60f9
3 changed files with 15 additions and 2 deletions

View File

@ -18,7 +18,7 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere
for (auto& [key, player] : mapPlayer) {
bool hit = false;
if ((m_currentpos - player->GetPosition()).Length() < .6f) {
if ((m_currentpos - player->GetPosition()).Length() < 1.f) {
hit = true;
}
if ((m_currentpos - player->GetPOV()).Length() < .2f) {

View File

@ -77,6 +77,19 @@ void Connection::getPacks(SOCKET sock) {
void Connection::sendPacks(SOCKET sock, std::unordered_map<uint64_t, Connection*> conns, const uint32_t timer) {
static int outs = 0;
static Timestamp last = 0;
static uint32_t lasttimer = timer;
if (m_output_vector.empty() && player->AmIDead()) {
if (timer != lasttimer) {
lasttimer = timer;
Sync sync;
sync.timestamp = sync.sid = m_loginfo.sid;
sync.hp = 0;
sync.ammo = -1;
sync.timer = timer;
sendPackTo<Sync>(sock, &sync, &m_bufout, &m_addr);
}
}
while (!m_output_vector.empty()) {
Output out = m_output_vector.front();

View File

@ -374,7 +374,7 @@ void Server::Run() {
for (auto bull = bullets.begin(); bull != bullets.end(); ++bull) {
ChunkMod* cmod = nullptr;
Bullet* bullet = *bull;
if (bullet->Update(m_world, (1. / 60.), 10, m_players, &cmod)) {
if (bullet->Update(m_world, (1. / 60.), 100, m_players, &cmod)) {
if (cmod)
chunkdiffs.emplace_back(cmod);
bullit.push_back(bull);