优化SecondRandPoint
This commit is contained in:
parent
1b9aa8c34a
commit
c8e8c92889
@ -1547,64 +1547,24 @@ void Room::DecBornPointHumanNum(BornPoint* point, Human* hum)
|
|||||||
|
|
||||||
void Room::SecondRandPoint()
|
void Room::SecondRandPoint()
|
||||||
{
|
{
|
||||||
for (auto& pair : accountid_hash_) {
|
|
||||||
Human* hum = pair.second;
|
|
||||||
hum->born_point = AllocBornPoint(hum);
|
|
||||||
}
|
|
||||||
for (auto& pair : team_hash_) {
|
|
||||||
Human* target = nullptr;
|
|
||||||
for (Human* hum : pair.second) {
|
|
||||||
if (!target) {
|
|
||||||
target = hum;
|
|
||||||
} else {
|
|
||||||
if (target->born_point) {
|
|
||||||
if (hum->born_point) {
|
|
||||||
DecBornPointHumanNum(hum->born_point, hum);
|
|
||||||
}
|
|
||||||
hum->born_point = target->born_point;
|
|
||||||
if (hum->born_point) {
|
|
||||||
IncBornPointHumanNum(hum->born_point, hum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} //end if
|
|
||||||
if (!hum->born_point) {
|
|
||||||
hum->SetX(DEFAULT_BORN_POINT_X + rand() % 100);
|
|
||||||
hum->SetY(DEFAULT_BORN_POINT_Y + rand() % 200);
|
|
||||||
} else {
|
|
||||||
hum->SetPos(hum->born_point->RandPoint());
|
|
||||||
}
|
|
||||||
if (!a8::HasBitFlag(hum->status, HS_Disable)) {
|
|
||||||
hum->FindLocation();
|
|
||||||
hum->RefreshView();
|
|
||||||
grid_service->MoveHuman(hum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (room_type_ == RT_NewBrid) {
|
|
||||||
for (auto& pair : accountid_hash_) {
|
|
||||||
Human* hum = pair.second;
|
|
||||||
BornPoint* newbie_point = GetBornPoint(newbie_born_point_uniid_);
|
|
||||||
if (newbie_point && hum->born_point != newbie_point) {
|
|
||||||
if (hum->born_point) {
|
|
||||||
DecBornPointHumanNum(hum->born_point, hum);
|
|
||||||
}
|
|
||||||
hum->born_point = newbie_point;
|
|
||||||
if (hum->born_point) {
|
|
||||||
IncBornPointHumanNum(hum->born_point, hum);
|
|
||||||
hum->SetPos(hum->born_point->RandPoint());
|
|
||||||
}
|
|
||||||
hum->FindLocation();
|
|
||||||
hum->RefreshView();
|
|
||||||
grid_service->MoveHuman(hum);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
CheckPartObjects();
|
CheckPartObjects();
|
||||||
#endif
|
#endif
|
||||||
for (auto& pair : accountid_hash_) {
|
for (auto& pair : accountid_hash_) {
|
||||||
if (room_type_ == RT_MidBrid) {
|
Human* hum = pair.second;
|
||||||
|
hum->born_point = AllocBornPoint(hum);
|
||||||
|
}
|
||||||
|
CombineTeamBornPoint();
|
||||||
|
if (room_type_ == RT_NewBrid) {
|
||||||
|
BornPoint* newbie_point = GetBornPoint(newbie_born_point_uniid_);
|
||||||
|
if (newbie_point && first_newbie_) {
|
||||||
|
ForceSetBornPoint(first_newbie_, newbie_point);
|
||||||
|
} else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (room_type_ == RT_MidBrid) {
|
||||||
|
for (auto& pair : accountid_hash_) {
|
||||||
pair.second->on_grid_chg = std::bind(&Room::OnHumanGridChg,
|
pair.second->on_grid_chg = std::bind(&Room::OnHumanGridChg,
|
||||||
this,
|
this,
|
||||||
std::placeholders::_1);
|
std::placeholders::_1);
|
||||||
@ -2444,3 +2404,53 @@ void Room::RemoveFromLaterAddHash(RoomEntity* entity)
|
|||||||
{
|
{
|
||||||
later_add_hash_.erase(entity->entity_uniid);
|
later_add_hash_.erase(entity->entity_uniid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::CombineTeamBornPoint()
|
||||||
|
{
|
||||||
|
for (auto& pair : team_hash_) {
|
||||||
|
Human* target = nullptr;
|
||||||
|
for (Human* hum : pair.second) {
|
||||||
|
if (!target) {
|
||||||
|
target = hum;
|
||||||
|
} else {
|
||||||
|
if (target->born_point) {
|
||||||
|
if (hum->born_point) {
|
||||||
|
DecBornPointHumanNum(hum->born_point, hum);
|
||||||
|
}
|
||||||
|
hum->born_point = target->born_point;
|
||||||
|
if (hum->born_point) {
|
||||||
|
IncBornPointHumanNum(hum->born_point, hum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} //end if
|
||||||
|
if (!hum->born_point) {
|
||||||
|
hum->SetX(DEFAULT_BORN_POINT_X + rand() % 100);
|
||||||
|
hum->SetY(DEFAULT_BORN_POINT_Y + rand() % 200);
|
||||||
|
} else {
|
||||||
|
hum->SetPos(hum->born_point->RandPoint());
|
||||||
|
}
|
||||||
|
if (!a8::HasBitFlag(hum->status, HS_Disable)) {
|
||||||
|
hum->FindLocation();
|
||||||
|
hum->RefreshView();
|
||||||
|
grid_service->MoveHuman(hum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::ForceSetBornPoint(Human* hum, BornPoint* born_point)
|
||||||
|
{
|
||||||
|
if (born_point && hum->born_point != born_point) {
|
||||||
|
if (hum->born_point) {
|
||||||
|
DecBornPointHumanNum(hum->born_point, hum);
|
||||||
|
}
|
||||||
|
hum->born_point = born_point;
|
||||||
|
if (hum->born_point) {
|
||||||
|
IncBornPointHumanNum(hum->born_point, hum);
|
||||||
|
hum->SetPos(hum->born_point->RandPoint());
|
||||||
|
}
|
||||||
|
hum->FindLocation();
|
||||||
|
hum->RefreshView();
|
||||||
|
grid_service->MoveHuman(hum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -176,6 +176,8 @@ private:
|
|||||||
void RemoveFromLaterAddHash(RoomEntity* entity);
|
void RemoveFromLaterAddHash(RoomEntity* entity);
|
||||||
|
|
||||||
void AddPlayerPostProc(Player* hum);
|
void AddPlayerPostProc(Player* hum);
|
||||||
|
void CombineTeamBornPoint();
|
||||||
|
void ForceSetBornPoint(Human* hum, BornPoint* born_point);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void InitDebugInfo();
|
void InitDebugInfo();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user