From 807d90a745030c9b34162786b88173c7ee101d43 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 16 Mar 2021 16:53:40 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 18 +++++++++++------- server/gameserver/room.cc | 12 ++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index f772ac9..713fe5b 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -4372,14 +4372,18 @@ void Human::DoGetOnWithLoot(Loot* entity) if (GetCar()) { GetCar()->GetDown(this); } - car_ = room->CreateCar( - this, - entity->GetEntityUniId(), - item_meta, - GetPos() - ); - car_->GetOn(this); + Car* car = room->CreateCar( + this, + entity->GetEntityUniId(), + item_meta, + GetPos() + ); + car->GetOn(this); + room->TakeOnCarObject(entity->GetEntityUniId()); room->NotifyUiUpdate(); + #ifdef DEBUG + a8::XPrintf("DoGetOnWithLoot uniid:%d car_uniid:%d\n", {car->GetEntityUniId(), car->car_uniid}); + #endif } void Human::DoGetOnWithCar(Car* car) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index d1a4a25..7844496 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -127,14 +127,14 @@ void Room::Update(int delta_time) elapsed_time_ += delta_time; while (elapsed_time_ >= 50) { - #ifdef DEBUG + #ifdef DEBUG1 long long begin_tick = a8::XGetTickCount(); long long end_tick = a8::XGetTickCount(); #endif if (GetFrameNo() % 2 == 0) { UpdateGas(); } - #ifdef DEBUG + #ifdef DEBUG1 end_tick = a8::XGetTickCount(); if (a8::XGetTickCount() - begin_tick > 1000) { abort(); @@ -144,7 +144,7 @@ void Room::Update(int delta_time) for (auto& pair : moveable_hash_) { pair.second->Update(50); } - #ifdef DEBUG + #ifdef DEBUG1 end_tick = a8::XGetTickCount(); if (a8::XGetTickCount() - begin_tick > 1000) { abort(); @@ -154,7 +154,7 @@ void Room::Update(int delta_time) if (GetFrameNo() % 2 == 0) { SyncFrameData(); } - #ifdef DEBUG + #ifdef DEBUG1 end_tick = a8::XGetTickCount(); if (a8::XGetTickCount() - begin_tick > 1000) { abort(); @@ -552,7 +552,7 @@ Car* Room::CreateCar(Human* driver, MetaData::Equip* item_meta, const a8::Vec2& pos) { - Car* car = EntityFactory::Instance()->MakeCar(car_uniid); + Car* car = EntityFactory::Instance()->MakeCar(AllocUniid()); car->car_uniid = car_uniid; car->meta = item_meta; car->room = this; @@ -564,8 +564,8 @@ Car* Room::CreateCar(Human* driver, car->Initialize(); AddToEntityHash(car); grid_service->AddCar(car); - car->BroadcastFullState(this); car->RefreshView(); + car->BroadcastFullState(this); return car; }