修复活跃玩家问题

This commit is contained in:
aozhiwei 2019-04-11 14:00:51 +08:00
parent 8f1d7dc710
commit be6c6e5272
2 changed files with 15 additions and 5 deletions

View File

@ -47,6 +47,7 @@ class Human : public Entity
bool poisoning = false; bool poisoning = false;
long long poisoning_time = 0; long long poisoning_time = 0;
long long dead_frameno = 0; long long dead_frameno = 0;
long long join_frameno = 0;
Weapon default_weapon; Weapon default_weapon;
std::vector<Weapon> weapons; std::vector<Weapon> weapons;

View File

@ -48,9 +48,17 @@ void Room::Update(int delta_time)
UpdateGas(); UpdateGas();
} }
for (auto& pair : moveable_hash_) { for (auto& pair : moveable_hash_) {
if (pair.second->entity_type == ET_Player &&
pair.second->updated_times <= 0) {
if (frame_no % 2 == 0) {
pair.second->Update(50); pair.second->Update(50);
pair.second->updated_times++; pair.second->updated_times++;
} }
} else {
pair.second->Update(50);
pair.second->updated_times++;
}
}
if (frame_no % 2 == 0) { if (frame_no % 2 == 0) {
ClearDeletedObjects(); ClearDeletedObjects();
ProcAddedObjects(); ProcAddedObjects();
@ -139,6 +147,7 @@ void Room::AddPlayer(Player* hum)
} }
hum->entity_uniid = AllocUniid(); hum->entity_uniid = AllocUniid();
hum->room = this; hum->room = this;
hum->join_frameno = frame_no;
hum->Initialize(); hum->Initialize();
uniid_hash_[hum->entity_uniid] = hum; uniid_hash_[hum->entity_uniid] = hum;
moveable_hash_[hum->entity_uniid] = hum; moveable_hash_[hum->entity_uniid] = hum;