1
This commit is contained in:
parent
06a6dd0806
commit
d46e2597ee
@ -63,6 +63,8 @@ class Human : public Entity
|
|||||||
int curr_scope_idx = 0;
|
int curr_scope_idx = 0;
|
||||||
std::vector<int> inventory;
|
std::vector<int> inventory;
|
||||||
|
|
||||||
|
bool need_sync_team_data = false;
|
||||||
|
bool need_sync_teammate_data = false;
|
||||||
bool need_sync_active_player = false;
|
bool need_sync_active_player = false;
|
||||||
|
|
||||||
HumanFrameData frame_data;
|
HumanFrameData frame_data;
|
||||||
@ -73,7 +75,7 @@ class Human : public Entity
|
|||||||
int pain_killer_frameno = 0;
|
int pain_killer_frameno = 0;
|
||||||
xtimer_list* pain_killer_timer = nullptr;
|
xtimer_list* pain_killer_timer = nullptr;
|
||||||
|
|
||||||
std::set<Human*> friends;
|
std::set<Human*>* team_members = nullptr;
|
||||||
|
|
||||||
Human();
|
Human();
|
||||||
virtual ~Human() override;
|
virtual ~Human() override;
|
||||||
|
@ -931,6 +931,12 @@ void Player::MakeUpdateMsg()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (need_sync_team_data) {
|
||||||
|
need_sync_team_data = false;
|
||||||
|
}
|
||||||
|
if (need_sync_teammate_data) {
|
||||||
|
need_sync_teammate_data = false;
|
||||||
|
}
|
||||||
if (send_update_msg_times == 0) {
|
if (send_update_msg_times == 0) {
|
||||||
room->FetchBuilding(this);
|
room->FetchBuilding(this);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include <a8/mutable_xobject.h>
|
#include <a8/mutable_xobject.h>
|
||||||
#include <a8/timer.h>
|
#include <a8/timer.h>
|
||||||
#include <a8/udplog.h>
|
#include <a8/udplog.h>
|
||||||
@ -17,6 +19,7 @@
|
|||||||
#include "loot.h"
|
#include "loot.h"
|
||||||
#include "collision.h"
|
#include "collision.h"
|
||||||
#include "roommgr.h"
|
#include "roommgr.h"
|
||||||
|
#include "app.h"
|
||||||
|
|
||||||
const int ROOM_MAX_PLAYER_NUM = 50;
|
const int ROOM_MAX_PLAYER_NUM = 50;
|
||||||
#if 0
|
#if 0
|
||||||
@ -39,6 +42,7 @@ Room::~Room()
|
|||||||
void Room::Init()
|
void Room::Init()
|
||||||
{
|
{
|
||||||
xtimer.Init(RoomXGetTickCount, this, 100, 100);
|
xtimer.Init(RoomXGetTickCount, this, 100, 100);
|
||||||
|
xtimer_attacher.xtimer = &xtimer;
|
||||||
|
|
||||||
ShuaAndroid();
|
ShuaAndroid();
|
||||||
CreateThings();
|
CreateThings();
|
||||||
@ -54,10 +58,22 @@ void Room::Init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if (App::Instance()->flags.find(1) != App::Instance()->flags.end()) {
|
||||||
|
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Room* room = (Room*)param.sender.GetUserData();
|
||||||
|
room->AutoMatchTeam();
|
||||||
|
},
|
||||||
|
&xtimer_attacher.timer_list_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::UnInit()
|
void Room::UnInit()
|
||||||
{
|
{
|
||||||
|
xtimer_attacher.ClearTimerList();
|
||||||
if (!stats_timer_) {
|
if (!stats_timer_) {
|
||||||
a8::Timer::Instance()->DeleteTimer(stats_timer_);
|
a8::Timer::Instance()->DeleteTimer(stats_timer_);
|
||||||
stats_timer_ = nullptr;
|
stats_timer_ = nullptr;
|
||||||
@ -875,3 +891,27 @@ void Room::OutputDebugLog()
|
|||||||
}
|
}
|
||||||
profile.max_rundelay = 0;
|
profile.max_rundelay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::AutoMatchTeam()
|
||||||
|
{
|
||||||
|
std::vector<Human*> humans;
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -85,15 +85,19 @@ private:
|
|||||||
bool GenSmallCircle(Vector2D big_circle_pos, float big_circle_rad, float small_circle_rad,
|
bool GenSmallCircle(Vector2D big_circle_pos, float big_circle_rad, float small_circle_rad,
|
||||||
Vector2D& out_pos);
|
Vector2D& out_pos);
|
||||||
void OutputDebugLog();
|
void OutputDebugLog();
|
||||||
|
void AutoMatchTeam();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
timer_list* stats_timer_ = nullptr;
|
timer_list* stats_timer_ = nullptr;
|
||||||
int elapsed_time_ = 0;
|
int elapsed_time_ = 0;
|
||||||
int alive_count_ = 0;
|
int alive_count_ = 0;
|
||||||
|
a8::XTimerAttacher xtimer_attacher;
|
||||||
|
|
||||||
|
int current_teamid = 0;
|
||||||
unsigned short current_uniid = 0;
|
unsigned short current_uniid = 0;
|
||||||
RoomState_e state_ = RS_Inactive;
|
RoomState_e state_ = RS_Inactive;
|
||||||
|
|
||||||
|
std::map<int, std::set<Human*>> team_hash_;
|
||||||
std::map<std::string, Player*> accountid_hash_;
|
std::map<std::string, Player*> accountid_hash_;
|
||||||
std::map<unsigned short, Entity*> moveable_hash_;
|
std::map<unsigned short, Entity*> moveable_hash_;
|
||||||
std::map<unsigned short, Entity*> uniid_hash_;
|
std::map<unsigned short, Entity*> uniid_hash_;
|
||||||
|
@ -615,7 +615,7 @@ message SMUpdate
|
|||||||
optional MFVector2D gas_pos_old = 30; //毒圈当前圆心坐标
|
optional MFVector2D gas_pos_old = 30; //毒圈当前圆心坐标
|
||||||
optional MFGasData gas_data = 17; //毒圈数据
|
optional MFGasData gas_data = 17; //毒圈数据
|
||||||
repeated MFTeamData team_data = 18; //活跃玩家队伍数据
|
repeated MFTeamData team_data = 18; //活跃玩家队伍数据
|
||||||
repeated MFTeammateInfo teammate_data = 19; //同队队友数据(自己的队友数据)
|
optional MFTeammateInfo teammate_data = 19; //同队队友数据(自己的队友数据)
|
||||||
repeated MFBullet bullets = 20; //子弹
|
repeated MFBullet bullets = 20; //子弹
|
||||||
repeated MFShot shots = 21; //射击
|
repeated MFShot shots = 21; //射击
|
||||||
repeated MFExplosion explosions = 22; //爆炸
|
repeated MFExplosion explosions = 22; //爆炸
|
||||||
|
Loading…
x
Reference in New Issue
Block a user