1
This commit is contained in:
parent
a6aea78d20
commit
e6d8aa0903
@ -5,10 +5,16 @@ namespace MetaData
|
||||
struct MapTplThing;
|
||||
}
|
||||
|
||||
namespace mt
|
||||
{
|
||||
struct WorldObject;
|
||||
}
|
||||
|
||||
struct BornPoint
|
||||
{
|
||||
int player_num = 0;
|
||||
int android_num = 0;
|
||||
std::shared_ptr<mt::WorldObject> cfg;
|
||||
|
||||
int GetNum() { return 10;};
|
||||
Position RandPoint() const;
|
||||
|
@ -182,6 +182,7 @@ class RoomObstacle;
|
||||
class Loot;
|
||||
class Car;
|
||||
class Buff;
|
||||
struct BornPoint;
|
||||
class Human : public Creature
|
||||
{
|
||||
public:
|
||||
@ -253,7 +254,7 @@ class Human : public Creature
|
||||
a8::XTimerWp downed_timer;
|
||||
|
||||
std::set<Human*> kill_humans;
|
||||
struct BornPoint* born_point = nullptr;
|
||||
std::shared_ptr<BornPoint> born_point = nullptr;
|
||||
|
||||
bool shot_start = false;
|
||||
bool shot_hold = false;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "frameeventdata.h"
|
||||
#include "pbutils.h"
|
||||
#include "movement.h"
|
||||
#include "bornpoint.h"
|
||||
|
||||
#include "mt/Param.h"
|
||||
#include "mt/Hero.h"
|
||||
@ -257,7 +258,7 @@ Player* Room::NewPlayer()
|
||||
return hum;
|
||||
}
|
||||
|
||||
void Room::AddPlayer(Player* hum, BornPoint* init_born_point, bool no_matchteam)
|
||||
void Room::AddPlayer(Player* hum, std::shared_ptr<BornPoint> init_born_point, bool no_matchteam)
|
||||
{
|
||||
if (GetGasData().GetGasMode() != GasInactive) {
|
||||
A8_ABORT();
|
||||
@ -2009,26 +2010,26 @@ void Room::BattleReport()
|
||||
}
|
||||
#endif
|
||||
|
||||
BornPoint* Room::AllocBornPoint(Human* hum)
|
||||
std::shared_ptr<BornPoint> Room::AllocBornPoint(Human* hum)
|
||||
{
|
||||
BornPoint* born_point = nullptr;
|
||||
std::shared_ptr<BornPoint> born_point = nullptr;
|
||||
if (hum->born_point) {
|
||||
std::vector<BornPoint*> point_list;
|
||||
std::vector<BornPoint*> free_point_list;
|
||||
BornPoint* pre_point = nullptr;
|
||||
BornPoint* reserve_point = nullptr;
|
||||
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.player_num + pair.second.android_num <
|
||||
pair.second.GetNum()) {
|
||||
point_list.push_back(&pair.second);
|
||||
free_point_list.push_back(&pair.second);;
|
||||
if (pair.second != hum->born_point) {
|
||||
if (pair.second->player_num + pair.second->android_num <
|
||||
pair.second->GetNum()) {
|
||||
point_list.push_back(pair.second);
|
||||
free_point_list.push_back(pair.second);;
|
||||
}
|
||||
if (!reserve_point || rand() % 100 < 10) {
|
||||
reserve_point = &pair.second;
|
||||
reserve_point = pair.second;
|
||||
}
|
||||
} else {
|
||||
pre_point = &pair.second;
|
||||
pre_point = pair.second;
|
||||
}
|
||||
}
|
||||
if (!free_point_list.empty()) {
|
||||
@ -2047,11 +2048,11 @@ BornPoint* Room::AllocBornPoint(Human* hum)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::vector<BornPoint*> free_point_list;
|
||||
std::vector<std::shared_ptr<BornPoint>> free_point_list;
|
||||
for (auto& pair : born_point_hash_) {
|
||||
if (pair.second.player_num + pair.second.android_num <
|
||||
pair.second.GetNum()) {
|
||||
free_point_list.push_back(&pair.second);
|
||||
if (pair.second->player_num + pair.second->android_num <
|
||||
pair.second->GetNum()) {
|
||||
free_point_list.push_back(pair.second);
|
||||
}
|
||||
}
|
||||
if (!free_point_list.empty()) {
|
||||
@ -2069,22 +2070,22 @@ BornPoint* Room::AllocBornPoint(Human* hum)
|
||||
return born_point;
|
||||
}
|
||||
|
||||
BornPoint* Room::GetBornPoint(int point_uniid)
|
||||
std::shared_ptr<BornPoint> Room::GetBornPoint(int point_uniid)
|
||||
{
|
||||
auto itr = born_point_hash_.find(point_uniid);
|
||||
return itr != born_point_hash_.end() ? &itr->second : nullptr;
|
||||
return itr != born_point_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
void Room::CreateSpawnPoints()
|
||||
{
|
||||
for (size_t i = 0; i < 10; ++i) {
|
||||
int uniid = AllocUniid();
|
||||
BornPoint born_point;
|
||||
std::shared_ptr<BornPoint> born_point = std::make_shared<BornPoint>();
|
||||
born_point_hash_[uniid] = born_point;
|
||||
}
|
||||
}
|
||||
|
||||
void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
||||
void Room::IncBornPointHumanNum(std::shared_ptr<BornPoint> point, Human* hum)
|
||||
{
|
||||
switch (hum->GetEntitySubType()) {
|
||||
case EST_Player:
|
||||
@ -2104,7 +2105,7 @@ void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
||||
}
|
||||
}
|
||||
|
||||
void Room::DecBornPointHumanNum(BornPoint* point, Human* hum)
|
||||
void Room::DecBornPointHumanNum(std::shared_ptr<BornPoint> point, Human* hum)
|
||||
{
|
||||
switch (hum->GetEntitySubType()) {
|
||||
case EST_Player:
|
||||
@ -2136,7 +2137,7 @@ void Room::SecondRandPoint()
|
||||
}
|
||||
CombineTeamBornPoint();
|
||||
if (room_type_ == RT_MidBrid) {
|
||||
BornPoint* newbie_point = GetBornPoint(level1room_born_point_uniid_);
|
||||
std::shared_ptr<BornPoint> newbie_point = GetBornPoint(level1room_born_point_uniid_);
|
||||
for (auto& pair : accountid_hash_) {
|
||||
pair.second->on_grid_chg = std::bind(&Room::OnHumanGridChg,
|
||||
this,
|
||||
@ -2879,7 +2880,7 @@ void Room::CombineTeamBornPoint()
|
||||
}
|
||||
}
|
||||
|
||||
void Room::ForceSetBornPoint(Human* hum, BornPoint* born_point)
|
||||
void Room::ForceSetBornPoint(Human* hum, std::shared_ptr<BornPoint> born_point)
|
||||
{
|
||||
if (born_point && hum->born_point != born_point) {
|
||||
if (hum->born_point) {
|
||||
@ -2896,7 +2897,7 @@ void Room::ForceSetBornPoint(Human* hum, BornPoint* born_point)
|
||||
}
|
||||
}
|
||||
|
||||
BornPoint* Room::ForceTakeBornPoint(Human* hum, BornPoint* reserve_born_point)
|
||||
std::shared_ptr<BornPoint> Room::ForceTakeBornPoint(Human* hum, std::shared_ptr<BornPoint> reserve_born_point)
|
||||
{
|
||||
if (!reserve_born_point) {
|
||||
A8_ABORT();
|
||||
@ -2907,7 +2908,7 @@ BornPoint* Room::ForceTakeBornPoint(Human* hum, BornPoint* reserve_born_point)
|
||||
if (!hum->born_point) {
|
||||
A8_ABORT();
|
||||
}
|
||||
BornPoint* pre_point = hum->born_point;
|
||||
std::shared_ptr<BornPoint> pre_point = hum->born_point;
|
||||
if (pre_point) {
|
||||
DecBornPointHumanNum(pre_point, hum);
|
||||
}
|
||||
@ -3526,7 +3527,7 @@ void Room::AddTeam(class MatchTeam* team)
|
||||
new_team->SetAutoFill(true);
|
||||
#endif
|
||||
}
|
||||
BornPoint* init_born_point = nullptr;
|
||||
std::shared_ptr<BornPoint> init_born_point = nullptr;
|
||||
for (auto& member : team->GetCurrMembers()) {
|
||||
cs::CMJoin& msg = *member->msg;
|
||||
if (member->is_robot) {
|
||||
@ -3757,6 +3758,13 @@ void Room::CreateWorldObjects()
|
||||
);
|
||||
}
|
||||
break;
|
||||
case WorldObjectType_e::kBornPointType:
|
||||
{
|
||||
int uniid = AllocUniid();
|
||||
std::shared_ptr<BornPoint> born_point = std::make_shared<BornPoint>();
|
||||
born_point_hash_[uniid] = born_point;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "mapservice.h"
|
||||
#include "gasdata.h"
|
||||
#include "pvedata.h"
|
||||
#include "bornpoint.h"
|
||||
|
||||
namespace cs
|
||||
{
|
||||
@ -29,6 +28,7 @@ class Car;
|
||||
class Hero;
|
||||
class Incubator;
|
||||
class Team;
|
||||
struct BornPoint;
|
||||
class MapInstance;
|
||||
struct RoomInitInfo;
|
||||
struct FrameEventData;
|
||||
@ -111,7 +111,7 @@ public:
|
||||
void OnEnterNewWave(int wave);
|
||||
|
||||
Player* NewPlayer();
|
||||
void AddPlayer(Player* hum, BornPoint* init_born_point = nullptr, bool no_matchteam = false);
|
||||
void AddPlayer(Player* hum, std::shared_ptr<BornPoint> init_born_point = nullptr, bool no_matchteam = false);
|
||||
Human* FindEnemy(Human* hum, float range);
|
||||
|
||||
void AddTeam(class MatchTeam* team);
|
||||
@ -239,12 +239,12 @@ private:
|
||||
void AddObjectLater(RoomEntity* entity);
|
||||
void OnGameOver();
|
||||
void RandRemoveAndroid();
|
||||
BornPoint* AllocBornPoint(Human* hum);
|
||||
BornPoint* GetBornPoint(int point_uniid);
|
||||
std::shared_ptr<BornPoint> AllocBornPoint(Human* hum);
|
||||
std::shared_ptr<BornPoint> GetBornPoint(int point_uniid);
|
||||
void CreateSpawnPoints();
|
||||
void CreateWorldObjects();
|
||||
void IncBornPointHumanNum(BornPoint* point, Human* hum);
|
||||
void DecBornPointHumanNum(BornPoint* point, Human* hum);
|
||||
void IncBornPointHumanNum(std::shared_ptr<BornPoint> point, Human* hum);
|
||||
void DecBornPointHumanNum(std::shared_ptr<BornPoint> point, Human* hum);
|
||||
void SecondRandPoint();
|
||||
void NotifyGameStart();
|
||||
void EnableHuman(Human* hum);
|
||||
@ -277,8 +277,8 @@ private:
|
||||
|
||||
void AddPlayerPostProc(Player* hum);
|
||||
void CombineTeamBornPoint();
|
||||
void ForceSetBornPoint(Human* hum, BornPoint* born_point);
|
||||
BornPoint* ForceTakeBornPoint(Human* hum, BornPoint* reserve_born_point);
|
||||
void ForceSetBornPoint(Human* hum, std::shared_ptr<BornPoint> born_point);
|
||||
std::shared_ptr<BornPoint> ForceTakeBornPoint(Human* hum, std::shared_ptr<BornPoint> reserve_born_point);
|
||||
void NewBieRoomStart();
|
||||
bool CanAddToScene(Human* hum);
|
||||
void SyncFrameData();
|
||||
@ -347,7 +347,7 @@ private:
|
||||
std::map<int, Human*> alive_human_hash_;
|
||||
std::map<int, Human*> alive_player_hash_;
|
||||
std::map<int, Human*> last_human_hash_;
|
||||
std::map<int, BornPoint> born_point_hash_;
|
||||
std::map<int, std::shared_ptr<BornPoint>> born_point_hash_;
|
||||
std::map<int, ITask*> task_hash_;
|
||||
|
||||
std::map<int, CarObject> car_hash_;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "human.h"
|
||||
#include "room.h"
|
||||
#include "app.h"
|
||||
#include "bornpoint.h"
|
||||
#include "battledatacontext.h"
|
||||
|
||||
void Team::TraverseMembers(std::function<bool (Human*)> func)
|
||||
|
Loading…
x
Reference in New Issue
Block a user