修复活跃玩家问题

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;
long long poisoning_time = 0;
long long dead_frameno = 0;
long long join_frameno = 0;
Weapon default_weapon;
std::vector<Weapon> weapons;

View File

@ -48,8 +48,16 @@ void Room::Update(int delta_time)
UpdateGas();
}
for (auto& pair : moveable_hash_) {
pair.second->Update(50);
pair.second->updated_times++;
if (pair.second->entity_type == ET_Player &&
pair.second->updated_times <= 0) {
if (frame_no % 2 == 0) {
pair.second->Update(50);
pair.second->updated_times++;
}
} else {
pair.second->Update(50);
pair.second->updated_times++;
}
}
if (frame_no % 2 == 0) {
ClearDeletedObjects();
@ -139,6 +147,7 @@ void Room::AddPlayer(Player* hum)
}
hum->entity_uniid = AllocUniid();
hum->room = this;
hum->join_frameno = frame_no;
hum->Initialize();
uniid_hash_[hum->entity_uniid] = hum;
moveable_hash_[hum->entity_uniid] = hum;
@ -713,7 +722,7 @@ bool Room::GenSmallCircle(Vector2D big_circle_pos, float big_circle_rad, float s
return true;
}
void Room::OutputDebugLog()
{
void Room::OutputDebugLog()
{
}
}