This commit is contained in:
aozhiwei 2019-11-20 17:49:45 +08:00
parent 5f8a76d6ab
commit e0ff02c234
13 changed files with 7 additions and 257 deletions

View File

@ -66,14 +66,13 @@ static void SavePerfLog()
f8::HttpClientPool::Instance()->GetPendingNum() f8::HttpClientPool::Instance()->GetPendingNum()
}); });
if (App::Instance()->HasFlag(4)) { if (App::Instance()->HasFlag(4)) {
a8::XPrintf("mainloop_time:%d netmsg_time:%d room:%d over_room:%d online:%d bullet:%d grid_chg_times:%d test_times:%d send_node_num:%d sent_node_num:%d sent_bytes_num:%d max_user_request_delay:%d\n", a8::XPrintf("mainloop_time:%d netmsg_time:%d room:%d over_room:%d online:%d grid_chg_times:%d test_times:%d send_node_num:%d sent_node_num:%d sent_bytes_num:%d max_user_request_delay:%d\n",
{ {
App::Instance()->perf.max_run_delay_time, App::Instance()->perf.max_run_delay_time,
App::Instance()->perf.max_dispatchmsg_time, App::Instance()->perf.max_dispatchmsg_time,
RoomMgr::Instance()->RoomNum(), RoomMgr::Instance()->RoomNum(),
RoomMgr::Instance()->OverRoomNum(), RoomMgr::Instance()->OverRoomNum(),
PlayerMgr::Instance()->OnlineNum(), PlayerMgr::Instance()->OnlineNum(),
App::Instance()->perf.entity_num[ET_Bullet],
App::Instance()->perf.grid_chg_times, App::Instance()->perf.grid_chg_times,
App::Instance()->perf.test_times, App::Instance()->perf.test_times,
GGListener::Instance()->GetSendNodeNum(), GGListener::Instance()->GetSendNodeNum(),

View File

@ -34,10 +34,7 @@ enum PlayerState_e
enum VirtualItemId_e enum VirtualItemId_e
{ {
VID_Item_Gold = 50001,
VID_Item_Exp = 50002,
VID_Soul_Stone = 50018,
VID_Pickaxe = 50019
}; };
enum SyncData_e enum SyncData_e
@ -45,95 +42,18 @@ enum SyncData_e
SYNC_Data_Exp = 0, SYNC_Data_Exp = 0,
}; };
enum DoorState_e
{
DoorStateClose = 0,
DoorStateOpen = 1
};
enum GasMode_e enum GasMode_e
{ {
GasInactive = 0, GasInactive = 0,
GasWaiting = 1,
GasMoving = 2,
GasJump = 3
};
enum ActionType_e
{
AT_None = 0,
AT_Reload = 1,
AT_UseItem = 2,
AT_Relive = 3,
AT_Rescue = 4
};
enum InventorySlot_e
{
IS_9MM = 0,
IS_556MM = 1,
IS_762MM = 2,
IS_12GAUGE = 3,
IS_RPG = 4,
IS_FRAG = 5,
IS_SMOKE = 6,
IS_HEALTHKIT = 7, //医疗包
IS_PAIN_KILLER = 8, //止痛药
IS_1XSCOPE = 12,
IS_2XSCOPE = 13,
IS_4XSCOPE = 14,
IS_8XSCOPE = 15,
IS_15XSCOPE = 16,
IS_END
};
enum SkillType_e
{
ST_Hide = 1,
ST_SummonHero = 2,
ST_Accelerate = 3,
ST_DamageAdd = 4,
ST_DefAdd = 5,
ST_RecoverHP = 6,
ST_ReflectDamage = 7,
ST_SelfDetonate = 8
};
enum SkillCond_e
{
SC_Active = 1,
SC_Passive = 2
};
enum VirtualWeapon_e
{
VW_SafeArea = 9000000,
VW_Spectate = 9000001,
VW_SelfDetonate = 9000002,
VW_Mine = 9000003,
VW_Tank = 9000004,
}; };
enum VirtualPlayer_e enum VirtualPlayer_e
{ {
VP_SafeArea = 9000000,
VP_Spectate = 9000001, VP_Spectate = 9000001,
VP_SelfDetonate = 9000002,
VP_Mine = 9000003,
}; };
enum EquipAttr_e enum EquipAttr_e
{ {
EA_View = 1, //客户端用
EA_ShotRange = 2,
EA_Volume = 3,
EA_AutoAngle = 4, //客户端用
EA_BulletAngle = 5,
EA_Atk = 6,
EA_Def = 7,
EA_Speed = 8,
EA_End EA_End
}; };
@ -142,17 +62,7 @@ enum EntityType_e
ET_None = 0, ET_None = 0,
ET_Player = 1, ET_Player = 1,
ET_Obstacle = 2, ET_Obstacle = 2,
ET_Building = 3,
//ET_LootSpawner = 4,
ET_Loot = 5, ET_Loot = 5,
//ET_DeadBody = 6,
//ET_Decal = 7,
//ET_Projectile = 8,
ET_Smoke = 9,
ET_Hero = 10,
ET_Bullet = 20,
ET_Android = 30, ET_Android = 30,
ET_MAX ET_MAX
}; };
@ -166,11 +76,6 @@ enum EntitySubType_e
enum PropertyType_e enum PropertyType_e
{ {
kPropHp = 1,
kPropMaxHp = 2,
kPropTankBulletNum = 6,
kPropTankOil = 7,
kPropBulletNum = 8
}; };
enum MapObjectType_e enum MapObjectType_e
@ -186,23 +91,12 @@ const float TEN_W = 10000 * 10;
const int SYS_RESET_TIME = 2*60; //每日两点重置 const int SYS_RESET_TIME = 2*60; //每日两点重置
const int DEF_WEAPON_ID = 12103;
const int SERVER_FRAME_RATE = 20; const int SERVER_FRAME_RATE = 20;
const int SYNC_FRAME_RATE = 10; const int SYNC_FRAME_RATE = 10;
const float FRAME_RATE_MS = 1000.0f / SERVER_FRAME_RATE; const float FRAME_RATE_MS = 1000.0f / SERVER_FRAME_RATE;
const int MAX_WEAPON_NUM = 5;
const int MAX_SKIN_LV = 9; const int MAX_SKIN_LV = 9;
const int GUN_SLOT1 = 1;
const int GUN_SLOT2 = 2;
const int FRAG_SLOT = 3;
const int SMOKE_SLOT = 4;
const int DOOR_THING_ID = 61701;
const int FIGHTING_MODE_BULLET_NUM = 10000 * 10000; const int FIGHTING_MODE_BULLET_NUM = 10000 * 10000;
const int MAX_NODE_ID = 8; const int MAX_NODE_ID = 8;

View File

@ -27,10 +27,6 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
for (auto& itr : hum->out_objects) { for (auto& itr : hum->out_objects) {
msg->add_out_objids(itr); msg->add_out_objids(itr);
} }
if (room->gas_data.gas_mode == GasMoving) {
msg->set_gas_progress(room->gas_data.gas_progress);
TypeConvert::ToPb(room->gas_data.pos_old, msg->mutable_gas_pos_old());
}
msg->set_alive_count(room->AliveCount()); msg->set_alive_count(room->AliveCount());
} }
return msg; return msg;

View File

@ -5,10 +5,7 @@ int g_hint_flags = 0;
bool Global::IsVirtualItem(int itemid) bool Global::IsVirtualItem(int itemid)
{ {
return (itemid == VID_Item_Exp || return false;
itemid == VID_Item_Gold ||
itemid == VID_Soul_Stone ||
itemid == VID_Pickaxe);
} }
time_t Global::BetweenDays(time_t time1, time_t time2) time_t Global::BetweenDays(time_t time1, time_t time2)
@ -32,7 +29,3 @@ int Global::g_time_zone = 8;
bool Global::g_shutdown = false; bool Global::g_shutdown = false;
ColliderComponent* Global::last_collider = nullptr; ColliderComponent* Global::last_collider = nullptr;
bool IsValidSlotId(int slot_id)
{
return slot_id >= 0 && slot_id < IS_END;
}

View File

@ -21,4 +21,3 @@ class Global : public a8::Singleton<Global>
static ColliderComponent* last_collider; static ColliderComponent* last_collider;
}; };
bool IsValidSlotId(int slot_id);

View File

@ -183,11 +183,6 @@ void GridService::RemoveFromGridList(std::set<GridCell*>& grid_list, Entity* ent
grid->human_list.erase((Human*)entity); grid->human_list.erase((Human*)entity);
} }
break; break;
case ET_Bullet:
{
grid->bullet_list.erase((Bullet*)entity);
}
break;
default: default:
{ {
grid->entity_list.erase(entity); grid->entity_list.erase(entity);

View File

@ -432,17 +432,6 @@ void Human::FindLocation()
} }
} }
break; break;
case ET_Building:
{
if (!target || target->entity_type != ET_Building) {
AabbCollider aabb_box;
entity->GetAabbBox(aabb_box);
if (TestCollision(&aabb_box)) {
target = entity;
}
}
}
break;
default: default:
break; break;
} }
@ -464,9 +453,7 @@ void Human::RefreshView()
} }
for (Entity* entity : cell->entity_list) { for (Entity* entity : cell->entity_list) {
switch (entity->entity_type) { switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle: case ET_Obstacle:
case ET_Hero:
case ET_Loot: case ET_Loot:
{ {
AddToNewObjects(entity); AddToNewObjects(entity);
@ -500,9 +487,7 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
for (Entity* entity : cell->entity_list) { for (Entity* entity : cell->entity_list) {
if (!room->grid_service.EntityInGridList(entity, old_grid_list)) { if (!room->grid_service.EntityInGridList(entity, old_grid_list)) {
switch (entity->entity_type) { switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle: case ET_Obstacle:
case ET_Hero:
case ET_Loot: case ET_Loot:
{ {
AddToNewObjects(entity); AddToNewObjects(entity);
@ -527,9 +512,7 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
for (Entity* entity : cell->entity_list) { for (Entity* entity : cell->entity_list) {
if (!room->grid_service.EntityInGridList(entity, grid_list)) { if (!room->grid_service.EntityInGridList(entity, grid_list)) {
switch (entity->entity_type) { switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle: case ET_Obstacle:
case ET_Hero:
case ET_Loot: case ET_Loot:
{ {
AddOutObjects(entity); AddOutObjects(entity);
@ -557,25 +540,6 @@ void Human::FillMFGasData(cs::MFGasData* gas_data)
long long duration = MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE - long long duration = MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE -
(room->frame_no - room->gas_data.gas_start_frameno); (room->frame_no - room->gas_data.gas_start_frameno);
gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000); gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000);
} else if (room->gas_data.gas_mode == GasJump) {
gas_data->set_duration(0);
} else if (room->gas_data.gas_mode == GasMoving) {
if (room->gas_data.new_area_meta->i->shrink_speed() > 0.01f) {
long long duration = (room->gas_data.old_area_meta->i->rad() - room->gas_data.new_area_meta->i->rad()) /
room->gas_data.new_area_meta->i->shrink_speed();
++duration;
gas_data->set_duration(++duration);
} else {
gas_data->set_duration(0);
}
} else {
if (room->gas_data.old_area_meta->i->wait_time() <= 0) {
gas_data->set_duration(0);
} else {
long long duration = room->gas_data.old_area_meta->i->wait_time() * 20 -
(room->frame_no - room->gas_data.gas_start_frameno);
gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000);
}
} }
} }
@ -593,9 +557,6 @@ void Human::RecalcBuff()
{ {
buff = HumanAbility(); buff = HumanAbility();
if (skin_meta) { if (skin_meta) {
buff.damage_add += skin_meta->GetAttrValue(skin.skin_lv, EA_Atk);
buff.def_add += skin_meta->GetAttrValue(skin.skin_lv, EA_Def);
buff.speed += skin_meta->GetAttrValue(skin.skin_lv, EA_Speed);
} }
} }
@ -612,9 +573,6 @@ void Human::RemoveObserver(Human* observer)
void Human::SendUpdateMsg() void Human::SendUpdateMsg()
{ {
if (!follow_target_) { if (!follow_target_) {
if (send_msg_times == 0) {
room->FetchBuilding(this);
}
cs::MFActivePlayerData* active_player_data_pb = nullptr; cs::MFActivePlayerData* active_player_data_pb = nullptr;
if (send_msg_times == 0 || need_sync_active_player) { if (send_msg_times == 0 || need_sync_active_player) {
active_player_data_pb = new cs::MFActivePlayerData(); active_player_data_pb = new cs::MFActivePlayerData();
@ -625,7 +583,6 @@ void Human::SendUpdateMsg()
cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this); cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this);
if (send_msg_times == 0 || last_sync_gas_frameno < room->gas_data.gas_start_frameno) { if (send_msg_times == 0 || last_sync_gas_frameno < room->gas_data.gas_start_frameno) {
last_sync_gas_frameno = room->gas_data.gas_start_frameno; last_sync_gas_frameno = room->gas_data.gas_start_frameno;
FillMFGasData(msg->mutable_gas_data());
} }
bool refreshed_view = false; bool refreshed_view = false;
std::set<Entity*> view_objects; std::set<Entity*> view_objects;
@ -648,9 +605,7 @@ void Human::SendUpdateMsg()
} }
for (Entity* entity : cell->entity_list) { for (Entity* entity : cell->entity_list) {
switch (entity->entity_type) { switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle: case ET_Obstacle:
case ET_Hero:
case ET_Loot: case ET_Loot:
{ {
view_objects.insert(entity); view_objects.insert(entity);
@ -1006,6 +961,7 @@ void Human::FindLocationWithTarget(Entity* target)
room->grid_service.GetAllCellsByXy(pos.x, pos.y, new_grid_list); room->grid_service.GetAllCellsByXy(pos.x, pos.y, new_grid_list);
for (auto& grid : new_grid_list) { for (auto& grid : new_grid_list) {
for (Entity* entity : grid->entity_list) { for (Entity* entity : grid->entity_list) {
#if 0
switch (entity->entity_type) { switch (entity->entity_type) {
case ET_Building: case ET_Building:
{ {
@ -1017,6 +973,7 @@ void Human::FindLocationWithTarget(Entity* target)
default: default:
break; break;
} }
#endif
if (building) { if (building) {
break; break;
} }

View File

@ -61,22 +61,6 @@ namespace MetaData
); );
} }
} }
{
std::vector<std::string> strings;
a8::Split(i->volume(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
assert(strings2.size() == 2);
if (strings2.size() >= 2) {
size_t slot = a8::XValue(strings2[0]);
size_t num = a8::XValue(strings2[1]);
if (slot >= 0 && slot < volume.size()){
volume[slot] = num;
}
}
}
}
} }
void EquipUpgrade::Init() void EquipUpgrade::Init()
@ -128,22 +112,6 @@ namespace MetaData
void Player::Init() void Player::Init()
{ {
{
std::vector<std::string> strings;
a8::Split(i->volume(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
assert(strings2.size() == 2);
if (strings2.size() >= 2) {
size_t slot = a8::XValue(strings2[0]);
size_t num = a8::XValue(strings2[1]);
if (slot >= 0 && slot < volume.size()){
volume[slot] = num;
}
}
}
}
} }
void Robot::Init() void Robot::Init()

View File

@ -47,8 +47,6 @@ namespace MetaData
const metatable::Equip* i = nullptr; const metatable::Equip* i = nullptr;
std::vector<std::tuple<float, float, float>> bullet_born_offset; std::vector<std::tuple<float, float, float>> bullet_born_offset;
std::array<int, IS_END> volume = {};
void Init(); void Init();
}; };
@ -67,8 +65,6 @@ namespace MetaData
{ {
const metatable::Player* i = nullptr; const metatable::Player* i = nullptr;
std::array<int, IS_END> volume = {};
void Init(); void Init();
}; };

View File

@ -447,11 +447,6 @@ void Room::RemoveObjectLater(Entity* entity)
Entity* entity = (Entity*)param.sender.GetUserData(); Entity* entity = (Entity*)param.sender.GetUserData();
switch (entity->entity_type) { switch (entity->entity_type) {
case ET_Loot: case ET_Loot:
case ET_Hero:
{
entity->BroadcastDeleteState();
entity->room->grid_service.DelEntity(entity);
}
break; break;
case ET_Player: case ET_Player:
{ {
@ -475,15 +470,6 @@ void Room::RemoveObjectLater(Entity* entity)
&entity->xtimer_attacher.timer_list_); &entity->xtimer_attacher.timer_list_);
} }
void Room::FetchBuilding(Human* hum)
{
for (auto& pair : uniid_hash_) {
if (pair.second->entity_type == ET_Building) {
hum->AddToNewObjects(pair.second);
}
}
}
void Room::OnHumanDie(Human* hum) void Room::OnHumanDie(Human* hum)
{ {
--alive_count_; --alive_count_;
@ -604,17 +590,6 @@ Entity* Room::FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aa
} }
} }
break; break;
case ET_Building:
{
if (!target || target->entity_type != ET_Building) {
AabbCollider building_aabb_box;
entity->GetAabbBox(building_aabb_box);
if (building_aabb_box.IntersectEx(aabb_pos, &aabb_box)) {
target = entity;
}
}
}
break;
default: default:
break; break;
} }
@ -738,7 +713,9 @@ void Room::UpdateGasInactive()
{ {
if (frame_no - gas_data.gas_start_frameno >= if (frame_no - gas_data.gas_start_frameno >=
MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) { MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) {
#if 0
gas_data.gas_mode = GasJump; gas_data.gas_mode = GasJump;
#endif
gas_data.gas_start_frameno = frame_no; gas_data.gas_start_frameno = frame_no;
if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) { if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) {
CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size()); CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size());
@ -863,9 +840,6 @@ void Room::AddObjectLater(Entity* entity)
auto add_func = [] (const a8::XParams& param) auto add_func = [] (const a8::XParams& param)
{ {
Entity* entity = (Entity*)param.sender.GetUserData(); Entity* entity = (Entity*)param.sender.GetUserData();
if (entity->entity_type == ET_Bullet) {
entity->room->moveable_hash_[entity->entity_uniid] = entity;
}
entity->room->uniid_hash_[entity->entity_uniid] = entity; entity->room->uniid_hash_[entity->entity_uniid] = entity;
entity->room->later_add_hash_.erase(entity->entity_uniid); entity->room->later_add_hash_.erase(entity->entity_uniid);
}; };

View File

@ -57,7 +57,6 @@ public:
void RemoveObjectLater(Entity* entity); void RemoveObjectLater(Entity* entity);
void FetchBuilding(Human* hum);
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg); void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
void TouchPlayerList(a8::XParams param, void TouchPlayerList(a8::XParams param,

View File

@ -31,16 +31,7 @@ namespace cs
struct GasData struct GasData
{ {
GasMode_e gas_mode = GasInactive; GasMode_e gas_mode = GasInactive;
a8::Vec2 pos_old;
a8::Vec2 pos_old_bk;
a8::Vec2 pre_pos_old;
a8::Vec2 pos_new;
float rad_old = 0.0f;
float rad_new = 0.0f;
float gas_progress = 0.0f;
long long gas_start_frameno = 0; long long gas_start_frameno = 0;
MetaData::SafeArea* old_area_meta = nullptr;
MetaData::SafeArea* new_area_meta = nullptr;
bool is_last_gas = false; bool is_last_gas = false;
}; };
@ -80,14 +71,6 @@ struct PlayerStats
int rank = 0; int rank = 0;
}; };
struct Plane
{
a8::Vec2 start_point;
a8::Vec2 end_point;
a8::Vec2 dir;
a8::Vec2 curr_pos;
};
struct HumanAbility struct HumanAbility
{ {
float speed = 0.0f; float speed = 0.0f;

View File

@ -429,9 +429,6 @@ message SMUpdate
optional int32 active_player_id = 5; //id(id) optional int32 active_player_id = 5; //id(id)
optional MFActivePlayerData active_player_data = 6; //() optional MFActivePlayerData active_player_data = 6; //()
optional int32 alive_count = 15; // optional int32 alive_count = 15; //
optional int32 gas_progress = 16; //,(gas_data.mode == moving时才会发进度)
optional MFVector2D gas_pos_old = 30; //
optional MFGasData gas_data = 17; //
repeated MFTeamData team_data = 18; // repeated MFTeamData team_data = 18; //
repeated MFEmote emotes = 23; // repeated MFEmote emotes = 23; //
} }