Merge branch 'SQC-15_online' of https://github.com/CegepSTH/SQCSim2023 into SQC-15_online

This commit is contained in:
Claudel-D-Roy 2023-12-13 16:32:49 -05:00
commit bb247d0afe
3 changed files with 18 additions and 3 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

@ -59,7 +59,9 @@ void Connection::getPacks(SOCKET sock) {
switch (netprot::getType(pck, 1)) {
using enum netprot::PACKET_TYPE;
case INPUT:
if (Deserialize(&in, pck, &bsize)) {
if (player->AmIDead())
break;
else if (Deserialize(&in, pck, &bsize)) {
m_input_manifest[in.timestamp] = in;
m_input_vector.push_back(in);
}
@ -77,6 +79,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);