1
This commit is contained in:
parent
c054a7008b
commit
540db91267
@ -90,17 +90,6 @@ void Room::Init(const cs::CMJoin& msg)
|
|||||||
map_service.Init(map_width / kMAP_GRID_WIDTH + 1, map_height / kMAP_GRID_WIDTH + 1, kMAP_GRID_WIDTH);
|
map_service.Init(map_width / kMAP_GRID_WIDTH + 1, map_height / kMAP_GRID_WIDTH + 1, kMAP_GRID_WIDTH);
|
||||||
|
|
||||||
CreateThings();
|
CreateThings();
|
||||||
if (App::Instance()->HasFlag(1)) {
|
|
||||||
xtimer.AddDeadLineTimerAndAttach(kSERVER_FRAME_RATE * 3,
|
|
||||||
a8::XParams()
|
|
||||||
.SetSender(this),
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
Room* room = (Room*)param.sender.GetUserData();
|
|
||||||
room->AutoMatchTeam();
|
|
||||||
},
|
|
||||||
&xtimer_attacher.timer_list_);
|
|
||||||
}
|
|
||||||
born_points_ = MetaMgr::Instance()->GetMapBornPoints(map_tpl_name);
|
born_points_ = MetaMgr::Instance()->GetMapBornPoints(map_tpl_name);
|
||||||
if (!born_points_ || born_points_->size() != kROOM_MAX_PLAYER_NUM) {
|
if (!born_points_ || born_points_->size() != kROOM_MAX_PLAYER_NUM) {
|
||||||
abort();
|
abort();
|
||||||
@ -215,16 +204,7 @@ void Room::AddPlayer(Player* hum)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
while (human_hash_.size() + 1 > kROOM_MAX_PLAYER_NUM) {
|
|
||||||
RandRemoveAndroid();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if 1
|
|
||||||
hum->entity_uniid = entity_uniid;
|
hum->entity_uniid = entity_uniid;
|
||||||
#else
|
|
||||||
hum->entity_uniid = AllocUniid();
|
|
||||||
#endif
|
|
||||||
hum->born_point = AllocBornPoint();
|
hum->born_point = AllocBornPoint();
|
||||||
{
|
{
|
||||||
const MetaData::MapTplThing& thing_tpl = (*born_points_)[hum->born_point];
|
const MetaData::MapTplThing& thing_tpl = (*born_points_)[hum->born_point];
|
||||||
@ -450,7 +430,6 @@ bool Room::IsGameOver()
|
|||||||
|
|
||||||
void Room::FillSMUiUpdate(cs::SMUiUpdate& msg)
|
void Room::FillSMUiUpdate(cs::SMUiUpdate& msg)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
for (auto& pair : members_hash_) {
|
for (auto& pair : members_hash_) {
|
||||||
cs::MFPlayerBattlingStats* p = msg.add_player_stats();
|
cs::MFPlayerBattlingStats* p = msg.add_player_stats();
|
||||||
p->set_player_id(pair.second.entity_uniid);
|
p->set_player_id(pair.second.entity_uniid);
|
||||||
@ -465,15 +444,6 @@ void Room::FillSMUiUpdate(cs::SMUiUpdate& msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
for (auto& pair : human_hash_) {
|
|
||||||
cs::MFPlayerBattlingStats* p = msg.add_player_stats();
|
|
||||||
p->set_player_id(pair.second->entity_uniid);
|
|
||||||
p->set_name(pair.second->name);
|
|
||||||
p->set_kills(pair.second->stats.kills);
|
|
||||||
p->set_last_kill_timeseq(pair.second->stats.last_kill_timeseq);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Hero* Room::CreateHero(Human* hum)
|
Hero* Room::CreateHero(Human* hum)
|
||||||
@ -742,13 +712,6 @@ bool Room::CanJoin(const cs::CMJoin& msg)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return msg.team_uuid() == room_unionid;
|
return msg.team_uuid() == room_unionid;
|
||||||
#if 0
|
|
||||||
if (App::Instance()->HasFlag(5)) {
|
|
||||||
return accountid_hash_.size() < 1;
|
|
||||||
} else {
|
|
||||||
return accountid_hash_.size() < kROOM_MAX_PLAYER_NUM;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::OnPlayerOffline(Player* hum)
|
void Room::OnPlayerOffline(Player* hum)
|
||||||
@ -835,14 +798,7 @@ void Room::UpdateGas()
|
|||||||
MetaMgr::Instance()->gas_inactive_time * kSERVER_FRAME_RATE) {
|
MetaMgr::Instance()->gas_inactive_time * kSERVER_FRAME_RATE) {
|
||||||
gas_data.gas_mode = kGasStarted;
|
gas_data.gas_mode = kGasStarted;
|
||||||
gas_data.gas_start_frameno = frameno;
|
gas_data.gas_start_frameno = frameno;
|
||||||
#if 1
|
|
||||||
SpllyAndroid();
|
SpllyAndroid();
|
||||||
#else
|
|
||||||
if (human_hash_.size() < kROOM_MAX_PLAYER_NUM) {
|
|
||||||
CreateAndroid(kROOM_MAX_PLAYER_NUM - human_hash_.size());
|
|
||||||
NotifyUiUpdate();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
NotifyWxVoip();
|
NotifyWxVoip();
|
||||||
RoomMgr::Instance()->ActiveRoom(room_uuid);
|
RoomMgr::Instance()->ActiveRoom(room_uuid);
|
||||||
battle_start_frameno_ = frameno;
|
battle_start_frameno_ = frameno;
|
||||||
@ -886,34 +842,6 @@ bool Room::GenSmallCircle(a8::Vec2 big_circle_pos, float big_circle_rad, float s
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::AutoMatchTeam()
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
std::vector<Human*> humans;
|
|
||||||
for (auto& pair : human_hash_) {
|
|
||||||
if (pair.second->team_uuid.empty()) {
|
|
||||||
humans.push_back(pair.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::random_shuffle(humans.begin(), humans.end());
|
|
||||||
std::set<Human*>* team_members = nullptr;
|
|
||||||
for (size_t i = 0; i < humans.size(); ++i) {
|
|
||||||
if (i % 4 == 0) {
|
|
||||||
++current_teamid;
|
|
||||||
team_hash_[current_teamid] = std::set<Human*>();
|
|
||||||
auto itr = team_hash_.find(current_teamid);
|
|
||||||
team_members = &itr->second;
|
|
||||||
}
|
|
||||||
humans[i]->team_id = current_teamid;
|
|
||||||
humans[i]->team_members = team_members;
|
|
||||||
humans[i]->need_sync_team_data = true;
|
|
||||||
humans[i]->need_sync_teammate_data = true;
|
|
||||||
humans[i]->need_sync_active_player = true;
|
|
||||||
team_members->insert(humans[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::MatchTeam(Human* hum)
|
void Room::MatchTeam(Human* hum)
|
||||||
{
|
{
|
||||||
for (auto& pair : human_hash_) {
|
for (auto& pair : human_hash_) {
|
||||||
@ -1052,12 +980,6 @@ void Room::BattleReport()
|
|||||||
std::vector<Human*> human_list;
|
std::vector<Human*> human_list;
|
||||||
human_list.reserve(human_hash_.size());
|
human_list.reserve(human_hash_.size());
|
||||||
for (auto& pair : human_hash_) {
|
for (auto& pair : human_hash_) {
|
||||||
#if 0
|
|
||||||
pair.second->stats.kills = rand() % 20;
|
|
||||||
pair.second->stats.dead_times = rand() % 2010;
|
|
||||||
pair.second->stats.damage_amount_out = rand() % 20100;
|
|
||||||
pair.second->stats.last_kill_timeseq = rand() % 20100;
|
|
||||||
#endif
|
|
||||||
human_list.push_back(pair.second);
|
human_list.push_back(pair.second);
|
||||||
}
|
}
|
||||||
std::sort(human_list.begin(), human_list.end(),
|
std::sort(human_list.begin(), human_list.end(),
|
||||||
@ -1099,16 +1021,6 @@ void Room::BattleReport()
|
|||||||
int rank = 1;
|
int rank = 1;
|
||||||
for (Human* hum : human_list) {
|
for (Human* hum : human_list) {
|
||||||
hum->stats.rank = rank++;
|
hum->stats.rank = rank++;
|
||||||
#if 0
|
|
||||||
a8::XPrintf("rank:%d kills:%d dead_times:%d damage_amount_out:%d last_kill_timeseq:%d\n",
|
|
||||||
{
|
|
||||||
hum->stats.rank,
|
|
||||||
hum->stats.kills,
|
|
||||||
hum->stats.dead_times,
|
|
||||||
hum->stats.damage_amount_out,
|
|
||||||
hum->stats.last_kill_timeseq,
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
hum->SendGameOver();
|
hum->SendGameOver();
|
||||||
}
|
}
|
||||||
game_over = true;
|
game_over = true;
|
||||||
@ -1254,11 +1166,7 @@ void Room::SpllyAndroid()
|
|||||||
#if 0
|
#if 0
|
||||||
hum->robot_meta = robot_meta;
|
hum->robot_meta = robot_meta;
|
||||||
#endif
|
#endif
|
||||||
#if 1
|
|
||||||
hum->entity_uniid = pair.second.entity_uniid;
|
hum->entity_uniid = pair.second.entity_uniid;
|
||||||
#else
|
|
||||||
hum->entity_uniid = AllocUniid();
|
|
||||||
#endif
|
|
||||||
hum->born_point = AllocBornPoint();
|
hum->born_point = AllocBornPoint();
|
||||||
{
|
{
|
||||||
const MetaData::MapTplThing& thing_tpl = (*born_points_)[hum->born_point];
|
const MetaData::MapTplThing& thing_tpl = (*born_points_)[hum->born_point];
|
||||||
|
@ -119,7 +119,6 @@ private:
|
|||||||
void UpdateGas();
|
void UpdateGas();
|
||||||
bool GenSmallCircle(a8::Vec2 big_circle_pos, float big_circle_rad, float small_circle_rad,
|
bool GenSmallCircle(a8::Vec2 big_circle_pos, float big_circle_rad, float small_circle_rad,
|
||||||
a8::Vec2& out_pos);
|
a8::Vec2& out_pos);
|
||||||
void AutoMatchTeam();
|
|
||||||
void MatchTeam(Human* hum);
|
void MatchTeam(Human* hum);
|
||||||
int NewTeam();
|
int NewTeam();
|
||||||
void CreateThings();
|
void CreateThings();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user