grid ok
This commit is contained in:
parent
a047b17d29
commit
efc81d40e1
@ -30,6 +30,7 @@ void Android::Update(int delta_time)
|
|||||||
{
|
{
|
||||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||||
pos = room->plane.curr_pos;
|
pos = room->plane.curr_pos;
|
||||||
|
room->grid_service.MoveHuman(this);
|
||||||
}
|
}
|
||||||
ai->Update(delta_time);
|
ai->Update(delta_time);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,10 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
|||||||
}
|
}
|
||||||
for (auto& itr : hum->del_objects) {
|
for (auto& itr : hum->del_objects) {
|
||||||
msg->add_del_objids(itr);
|
msg->add_del_objids(itr);
|
||||||
|
Entity* entity = hum->room->GetEntityByUniId(itr);
|
||||||
|
if (entity) {
|
||||||
|
hum->part_objects.erase(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (hum->send_msg_times == 0 || hum->need_sync_active_player) {
|
if (hum->send_msg_times == 0 || hum->need_sync_active_player) {
|
||||||
msg->set_active_player_id(hum->entity_uniid);
|
msg->set_active_player_id(hum->entity_uniid);
|
||||||
@ -96,6 +100,8 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
|||||||
}
|
}
|
||||||
msg->set_alive_count(room->AliveCount());
|
msg->set_alive_count(room->AliveCount());
|
||||||
}
|
}
|
||||||
|
hum->new_objects.clear();
|
||||||
|
hum->del_objects.clear();
|
||||||
++hum->send_msg_times;
|
++hum->send_msg_times;
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,22 @@ void GridService::ComputeDiff(int old_grid_id, int new_grid_id,
|
|||||||
std::set<GridCell*>& dec_grid_list)
|
std::set<GridCell*>& dec_grid_list)
|
||||||
{
|
{
|
||||||
int diff_grid = new_grid_id - old_grid_id;
|
int diff_grid = new_grid_id - old_grid_id;
|
||||||
|
#if 1
|
||||||
|
{
|
||||||
|
std::set<GridCell*> new_grid_list;
|
||||||
|
Get123456789(new_grid_id, new_grid_list);
|
||||||
|
for (auto& cell : new_grid_list) {
|
||||||
|
if (grid_list.find(cell) == grid_list.end()) {
|
||||||
|
inc_grid_list.insert(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& cell : grid_list) {
|
||||||
|
if (new_grid_list.find(cell) == new_grid_list.end()) {
|
||||||
|
dec_grid_list.insert(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (diff_grid == 1) {
|
if (diff_grid == 1) {
|
||||||
Get369(new_grid_id, inc_grid_list);
|
Get369(new_grid_id, inc_grid_list);
|
||||||
Get147(old_grid_id, dec_grid_list);
|
Get147(old_grid_id, dec_grid_list);
|
||||||
@ -252,6 +268,7 @@ void GridService::ComputeDiff(int old_grid_id, int new_grid_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
grid_list.clear();
|
grid_list.clear();
|
||||||
Get123456789(new_grid_id, grid_list);
|
Get123456789(new_grid_id, grid_list);
|
||||||
|
@ -37,6 +37,7 @@ void Player::Update(int delta_time)
|
|||||||
}
|
}
|
||||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||||
pos = room->plane.curr_pos;
|
pos = room->plane.curr_pos;
|
||||||
|
room->grid_service.MoveHuman(this);
|
||||||
}
|
}
|
||||||
if (moving) {
|
if (moving) {
|
||||||
UpdateMove();
|
UpdateMove();
|
||||||
|
@ -915,19 +915,12 @@ void Room::ShuaPlane()
|
|||||||
plane.dir.Normalize();
|
plane.dir.Normalize();
|
||||||
plane.curr_pos = plane.start_point;
|
plane.curr_pos = plane.start_point;
|
||||||
|
|
||||||
std::vector<Human*> humans;
|
|
||||||
for (auto& pair : human_hash_) {
|
for (auto& pair : human_hash_) {
|
||||||
a8::SetBitFlag(pair.second->status, HS_Fly);
|
a8::SetBitFlag(pair.second->status, HS_Fly);
|
||||||
pair.second->pos = plane.curr_pos;
|
pair.second->pos = plane.curr_pos;
|
||||||
pair.second->attack_dir = plane.dir;
|
pair.second->attack_dir = plane.dir;
|
||||||
pair.second->move_dir = plane.dir;
|
pair.second->move_dir = plane.dir;
|
||||||
humans.push_back(pair.second);
|
grid_service.MoveHuman(pair.second);
|
||||||
}
|
|
||||||
for (auto& hum : humans) {
|
|
||||||
for (auto& pair : human_hash_) {
|
|
||||||
hum->AddToNewObjects(pair.second);
|
|
||||||
hum->AddToPartObjects(pair.second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user