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