add GetBornPoint() SetBornPoint()
This commit is contained in:
parent
6c0a8624c2
commit
b551a21bc9
@ -2758,7 +2758,7 @@ void Creature::OnLand()
|
||||
if (!ok) {
|
||||
#if 1
|
||||
if (IsHuman()) {
|
||||
point = AsHuman()->born_point->GetSrcPoint(room).ToGlmVec3();
|
||||
point = AsHuman()->GetBornPoint()->GetSrcPoint(room).ToGlmVec3();
|
||||
}
|
||||
#else
|
||||
abort();
|
||||
|
@ -3441,7 +3441,7 @@ void Human::InternalBeKill(int killer_id, const std::string& killer_name, int we
|
||||
if (!room->IsGameOver()) {
|
||||
if (dead) {
|
||||
App::Instance()->verify_set_pos = 1;
|
||||
SetPos(born_point->RandPoint(room));
|
||||
SetPos(GetBornPoint()->RandPoint(room));
|
||||
room->grid_service->MoveCreature(this);
|
||||
App::Instance()->verify_set_pos = 0;
|
||||
GetMovement()->ClearPath();
|
||||
@ -3921,3 +3921,8 @@ void Human::SendPersonalBattleReport()
|
||||
*params.get()
|
||||
);
|
||||
}
|
||||
|
||||
void Human::SetBornPoint(std::shared_ptr<BornPoint> born_point)
|
||||
{
|
||||
born_point_ = born_point;
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ class Human : public Creature
|
||||
a8::XTimerWp downed_timer;
|
||||
|
||||
std::set<Human*> kill_humans;
|
||||
std::shared_ptr<BornPoint> born_point = nullptr;
|
||||
|
||||
a8::XTimerWp shot_hold_timer;
|
||||
int series_shot_frames = 0;
|
||||
@ -273,6 +272,8 @@ class Human : public Creature
|
||||
void PushJoinRoomMsg();
|
||||
void ReJoin(long ip_saddr, int socket_handle, std::shared_ptr<cs::CMJoin> msg,
|
||||
std::shared_ptr<MobaBattle> p);
|
||||
const std::shared_ptr<BornPoint> GetBornPoint() { return born_point_; }
|
||||
void SetBornPoint(std::shared_ptr<BornPoint> born_point);
|
||||
|
||||
protected:
|
||||
void ProcLootWeapon(AddItemDTO& dto);
|
||||
@ -352,6 +353,7 @@ protected:
|
||||
bool statsed_ = false;
|
||||
|
||||
private:
|
||||
std::shared_ptr<BornPoint> born_point_;
|
||||
FrameData framedata_;
|
||||
std::set<Human*> observers_;
|
||||
std::map<int, int> items_;
|
||||
|
@ -311,7 +311,7 @@ Human* Incubator::ActiveAndroid(Human* hum)
|
||||
App::Instance()->verify_set_pos = 0;
|
||||
} else {
|
||||
App::Instance()->verify_set_pos = 1;
|
||||
target->GetMutablePos().FromGlmVec3(target->born_point->GetSrcPoint(room).ToGlmVec3());
|
||||
target->GetMutablePos().FromGlmVec3(target->GetBornPoint()->GetSrcPoint(room).ToGlmVec3());
|
||||
App::Instance()->verify_set_pos = 0;
|
||||
}
|
||||
room->EnableHuman(target);
|
||||
|
@ -2464,7 +2464,7 @@ int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr<c
|
||||
[this, side] (Human* hum) -> bool
|
||||
{
|
||||
hum->side = side;
|
||||
hum->born_point->wo_meta = std::get<0>(GetMapMeta()->moba_born_points.at(side - 1));
|
||||
hum->GetBornPoint()->wo_meta = std::get<0>(GetMapMeta()->moba_born_points.at(side - 1));
|
||||
hum->InitMobaRoad();
|
||||
#ifdef MYDEBUG
|
||||
a8::XPrintf("moba init uniid:%d team_id:%d side:%d wo_meta:%d\n",
|
||||
@ -2472,7 +2472,7 @@ int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr<c
|
||||
hum->GetUniId(),
|
||||
hum->GetTeam()->GetTeamId(),
|
||||
hum->side,
|
||||
hum->born_point->wo_meta.get()
|
||||
hum->GetBornPoint()->wo_meta.get()
|
||||
});
|
||||
#endif
|
||||
return true;
|
||||
|
@ -304,15 +304,15 @@ void Room::AddPlayer(Player* hum, std::shared_ptr<BornPoint> init_born_point, bo
|
||||
RandRemoveAndroid();
|
||||
}
|
||||
if (init_born_point) {
|
||||
hum->born_point = init_born_point;
|
||||
hum->SetBornPoint(init_born_point);
|
||||
} else {
|
||||
hum->born_point = AllocBornPoint(hum);
|
||||
hum->SetBornPoint(AllocBornPoint(hum));
|
||||
}
|
||||
App::Instance()->verify_set_pos = 1;
|
||||
if (!hum->born_point) {
|
||||
if (!hum->GetBornPoint()) {
|
||||
abort();
|
||||
} else {
|
||||
hum->SetPos(hum->born_point->RandPoint(this));
|
||||
hum->SetPos(hum->GetBornPoint()->RandPoint(this));
|
||||
}
|
||||
App::Instance()->verify_set_pos = 0;
|
||||
glm::vec3 attack_dir = hum->GetPos().ToGlmVec3();
|
||||
@ -463,7 +463,7 @@ void Room::ShuaAndroid()
|
||||
|
||||
void Room::ShowAndroid(Human* target, int num)
|
||||
{
|
||||
if (!target->born_point) {
|
||||
if (!target->GetBornPoint()) {
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
@ -471,12 +471,12 @@ void Room::ShowAndroid(Human* target, int num)
|
||||
Human* hum = pair.second;
|
||||
if (hum->IsAndroid() &&
|
||||
a8::HasBitFlag(hum->status, CS_Disable)) {
|
||||
if (hum->born_point) {
|
||||
DecBornPointHumanNum(hum->born_point, hum);
|
||||
if (hum->GetBornPoint()) {
|
||||
DecBornPointHumanNum(hum->GetBornPoint(), hum);
|
||||
}
|
||||
hum->born_point = target->born_point;
|
||||
IncBornPointHumanNum(hum->born_point, hum);
|
||||
hum->SetPos(hum->born_point->RandPoint(this));
|
||||
hum->SetBornPoint(target->GetBornPoint());
|
||||
IncBornPointHumanNum(hum->GetBornPoint(), hum);
|
||||
hum->SetPos(hum->GetBornPoint()->RandPoint(this));
|
||||
EnableHuman(hum);
|
||||
++i;
|
||||
if (i >= num) {
|
||||
@ -505,12 +505,12 @@ void Room::CreateAndroid(int robot_num, std::shared_ptr<Team> team)
|
||||
hum->meta = mt::Hero::GetById(robot_meta->hero_id());
|
||||
#endif
|
||||
hum->robot_meta = robot_meta;
|
||||
hum->born_point = AllocBornPoint(hum);
|
||||
hum->SetBornPoint(AllocBornPoint(hum));
|
||||
App::Instance()->verify_set_pos = 1;
|
||||
if (!hum->born_point) {
|
||||
if (!hum->GetBornPoint()) {
|
||||
abort();
|
||||
} else {
|
||||
hum->SetPos(hum->born_point->RandPoint(this));
|
||||
hum->SetPos(hum->GetBornPoint()->RandPoint(this));
|
||||
}
|
||||
App::Instance()->verify_set_pos = 0;
|
||||
glm::vec3 attack_dir = hum->GetPos().ToGlmVec3();
|
||||
@ -1582,10 +1582,10 @@ void Room::UpdateGasInactiveMoba()
|
||||
App::Instance()->verify_set_pos = 1;
|
||||
for (auto& pair : human_hash_) {
|
||||
Human* hum = pair.second;
|
||||
if (!hum->born_point) {
|
||||
if (!hum->GetBornPoint()) {
|
||||
abort();
|
||||
} else {
|
||||
hum->SetPos(hum->born_point->RandPoint(this));
|
||||
hum->SetPos(hum->GetBornPoint()->RandPoint(this));
|
||||
}
|
||||
a8::XPrintf("set_pos side:%d %d pos:%f %f %f\n", {
|
||||
hum->side,
|
||||
@ -2124,8 +2124,8 @@ void Room::RandRemoveAndroid()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hum->born_point) {
|
||||
DecBornPointHumanNum(hum->born_point, hum);
|
||||
if (hum->GetBornPoint()) {
|
||||
DecBornPointHumanNum(hum->GetBornPoint(), hum);
|
||||
}
|
||||
grid_service->DeatchHuman(hum);
|
||||
RemoveFromMoveableHash(hum);
|
||||
@ -2224,13 +2224,13 @@ bool Room::HaveMyTeam(const std::string& team_uuid)
|
||||
std::shared_ptr<BornPoint> Room::AllocBornPoint(Human* hum)
|
||||
{
|
||||
std::shared_ptr<BornPoint> born_point = nullptr;
|
||||
if (hum->born_point) {
|
||||
if (hum->GetBornPoint()) {
|
||||
std::vector<std::shared_ptr<BornPoint>> point_list;
|
||||
std::vector<std::shared_ptr<BornPoint>> free_point_list;
|
||||
std::shared_ptr<BornPoint> pre_point = nullptr;
|
||||
std::shared_ptr<BornPoint> reserve_point = nullptr;
|
||||
for (auto& pair : born_point_hash_) {
|
||||
if (pair.second != hum->born_point) {
|
||||
if (pair.second != hum->GetBornPoint()) {
|
||||
if (pair.second->player_num + pair.second->android_num <
|
||||
pair.second->GetNum()) {
|
||||
point_list.push_back(pair.second);
|
||||
@ -2353,7 +2353,7 @@ void Room::SecondRandPoint()
|
||||
#endif
|
||||
for (auto& pair : accountid_hash_) {
|
||||
Human* hum = pair.second;
|
||||
hum->born_point = AllocBornPoint(hum);
|
||||
hum->SetBornPoint(AllocBornPoint(hum));
|
||||
}
|
||||
CombineTeamBornPoint();
|
||||
#ifdef MYDEBUG
|
||||
@ -2651,14 +2651,14 @@ void Room::CombineTeamBornPoint()
|
||||
|
||||
void Room::ForceSetBornPoint(Human* hum, std::shared_ptr<BornPoint> born_point)
|
||||
{
|
||||
if (born_point && hum->born_point != born_point) {
|
||||
if (hum->born_point) {
|
||||
DecBornPointHumanNum(hum->born_point, hum);
|
||||
if (born_point && hum->GetBornPoint() != born_point) {
|
||||
if (hum->GetBornPoint()) {
|
||||
DecBornPointHumanNum(hum->GetBornPoint(), hum);
|
||||
}
|
||||
hum->born_point = born_point;
|
||||
if (hum->born_point) {
|
||||
IncBornPointHumanNum(hum->born_point, hum);
|
||||
hum->SetPos(hum->born_point->RandPoint(this));
|
||||
hum->SetBornPoint(born_point);
|
||||
if (hum->GetBornPoint()) {
|
||||
IncBornPointHumanNum(hum->GetBornPoint(), hum);
|
||||
hum->SetPos(hum->GetBornPoint()->RandPoint(this));
|
||||
}
|
||||
hum->FindLocation();
|
||||
hum->RefreshView();
|
||||
@ -2671,18 +2671,18 @@ std::shared_ptr<BornPoint> Room::ForceTakeBornPoint(Human* hum, std::shared_ptr<
|
||||
if (!reserve_born_point) {
|
||||
A8_ABORT();
|
||||
}
|
||||
if (hum->born_point == reserve_born_point) {
|
||||
if (hum->GetBornPoint() == reserve_born_point) {
|
||||
A8_ABORT();
|
||||
}
|
||||
if (!hum->born_point) {
|
||||
if (!hum->GetBornPoint()) {
|
||||
A8_ABORT();
|
||||
}
|
||||
std::shared_ptr<BornPoint> pre_point = hum->born_point;
|
||||
std::shared_ptr<BornPoint> pre_point = hum->GetBornPoint();
|
||||
if (pre_point) {
|
||||
DecBornPointHumanNum(pre_point, hum);
|
||||
}
|
||||
for (auto& pair : human_hash_) {
|
||||
if (pair.second->born_point == reserve_born_point) {
|
||||
if (pair.second->GetBornPoint() == reserve_born_point) {
|
||||
ForceSetBornPoint(pair.second, pre_point);
|
||||
}
|
||||
}
|
||||
@ -3010,12 +3010,12 @@ void Room::AddTeam(class MatchTeam* team)
|
||||
if (!init_born_point) {
|
||||
init_born_point = AllocBornPoint(hum);
|
||||
}
|
||||
hum->born_point = init_born_point;
|
||||
hum->SetBornPoint(init_born_point);
|
||||
App::Instance()->verify_set_pos = 1;
|
||||
if (!hum->born_point) {
|
||||
if (!hum->GetBornPoint()) {
|
||||
abort();
|
||||
} else {
|
||||
hum->SetPos(hum->born_point->RandPoint(this));
|
||||
hum->SetPos(hum->GetBornPoint()->RandPoint(this));
|
||||
}
|
||||
App::Instance()->verify_set_pos = 0;
|
||||
glm::vec3 attack_dir = hum->GetPos().ToGlmVec3();
|
||||
|
@ -114,20 +114,20 @@ void Team::CombineBornPoint()
|
||||
if (!target) {
|
||||
target = member;
|
||||
} else {
|
||||
if (target->born_point) {
|
||||
if (member->born_point) {
|
||||
room->DecBornPointHumanNum(member->born_point, member);
|
||||
if (target->GetBornPoint()) {
|
||||
if (member->GetBornPoint()) {
|
||||
room->DecBornPointHumanNum(member->GetBornPoint(), member);
|
||||
}
|
||||
member->born_point = target->born_point;
|
||||
if (member->born_point) {
|
||||
room->IncBornPointHumanNum(member->born_point, member);
|
||||
member->SetBornPoint(target->GetBornPoint());
|
||||
if (member->GetBornPoint()) {
|
||||
room->IncBornPointHumanNum(member->GetBornPoint(), member);
|
||||
}
|
||||
}
|
||||
} //end if
|
||||
if (!member->born_point) {
|
||||
if (!member->GetBornPoint()) {
|
||||
abort();
|
||||
} else {
|
||||
member->SetPos(member->born_point->RandPoint(member->room));
|
||||
member->SetPos(member->GetBornPoint()->RandPoint(member->room));
|
||||
}
|
||||
if (!a8::HasBitFlag(member->status, CS_Disable)) {
|
||||
member->FindLocation();
|
||||
|
Loading…
x
Reference in New Issue
Block a user