代码重构

This commit is contained in:
aozhiwei 2019-07-20 17:57:34 +08:00
parent 78d30f79e5
commit 8d1ade0c8f
22 changed files with 172 additions and 272 deletions

View File

@ -8,18 +8,18 @@
Android::Android():Human()
{
entity_type = ET_Player;
entity_subtype = EST_Android;
entity_type = kET_Player;
entity_subtype = kEST_Android;
ai = new AndroidAI;
ai->owner = this;
++App::Instance()->perf.entity_num[ET_Android];
++App::Instance()->perf.entity_num[kET_Android];
}
Android::~Android()
{
delete ai;
ai = nullptr;
--App::Instance()->perf.entity_num[ET_Android];
--App::Instance()->perf.entity_num[kET_Android];
}
void Android::Initialize()

View File

@ -57,7 +57,7 @@ static void SavePerfLog()
{
App::Instance()->perf.max_run_delay_time,
RoomMgr::Instance()->RoomNum(),
App::Instance()->perf.entity_num[ET_Player],
App::Instance()->perf.entity_num[kET_Player],
PlayerMgr::Instance()->OnlineNum()
});
if (App::Instance()->HasFlag(4)) {
@ -68,7 +68,7 @@ static void SavePerfLog()
RoomMgr::Instance()->RoomNum(),
RoomMgr::Instance()->OverRoomNum(),
PlayerMgr::Instance()->OnlineNum(),
App::Instance()->perf.entity_num[ET_Bullet],
App::Instance()->perf.entity_num[kET_Bullet],
App::Instance()->perf.grid_chg_times,
App::Instance()->perf.test_times,
GGListener::Instance()->GetSendNodeNum(),

View File

@ -10,13 +10,13 @@
Building::Building():Entity()
{
entity_type = ET_Building;
++App::Instance()->perf.entity_num[ET_Building];
entity_type = kET_Building;
++App::Instance()->perf.entity_num[kET_Building];
}
Building::~Building()
{
--App::Instance()->perf.entity_num[ET_Building];
--App::Instance()->perf.entity_num[kET_Building];
}
void Building::Initialize()
@ -52,7 +52,7 @@ void Building::RecalcSelfCollider()
void Building::FillMFObjectPart(cs::MFObjectPart* part_data)
{
part_data->set_object_type(ET_Building);
part_data->set_object_type(kET_Building);
cs::MFBuildingPart* p = part_data->mutable_union_obj_3();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
@ -60,7 +60,7 @@ void Building::FillMFObjectPart(cs::MFObjectPart* part_data)
void Building::FillMFObjectFull(cs::MFObjectFull* full_data)
{
full_data->set_object_type(ET_Building);
full_data->set_object_type(kET_Building);
cs::MFBuildingFull* p = full_data->mutable_union_obj_3();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());

View File

@ -10,13 +10,13 @@
Bullet::Bullet():Entity()
{
entity_type = ET_Bullet;
++App::Instance()->perf.entity_num[ET_Bullet];
entity_type = kET_Bullet;
++App::Instance()->perf.entity_num[kET_Bullet];
}
Bullet::~Bullet()
{
--App::Instance()->perf.entity_num[ET_Bullet];
--App::Instance()->perf.entity_num[kET_Bullet];
}
void Bullet::Initialize()
@ -84,7 +84,7 @@ void Bullet::OnHit(std::set<Entity*>& objects)
{
for (auto& target : objects) {
switch (target->entity_type) {
case ET_Player:
case kET_Player:
{
if (App::Instance()->HasFlag(8)) {
return;
@ -106,14 +106,14 @@ void Bullet::OnHit(std::set<Entity*>& objects)
hum->OnHit();
if (!hum->HasBuffEffect(BET_Invincible)) {
if (skill_id != 0) {
master->TriggerOneObjectBuff(hum, BTT_SkillHit);
master->TriggerOneObjectBuff(hum, kBTT_SkillHit);
}
hum->DecHP(finaly_dmg, master->entity_uniid, master->name, meta->i->id());
}
}
}
break;
case ET_Obstacle:
case kET_Obstacle:
{
Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->dead && obstacle->meta->i->attack_type() == 1) {
@ -159,7 +159,7 @@ void Bullet::ProcBomb()
}
for (Entity* entity : grid->entity_list) {
switch (entity->entity_type) {
case ET_Obstacle:
case kET_Obstacle:
{
if (entity->TestCollision(&collider)) {
objects.insert(entity);

View File

@ -47,120 +47,95 @@ enum ActionType_e
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_TANK = 9,
kIS_9MM = 0,
kIS_556MM = 1,
kIS_762MM = 2,
kIS_12GAUGE = 3,
kIS_RPG = 4,
kIS_FRAG = 5,
kIS_SMOKE = 6,
kIS_HEALTHKIT = 7,
kIS_PAIN_KILLER = 8,
kIS_TANK = 9,
IS_1XSCOPE = 12,
IS_2XSCOPE = 13,
IS_4XSCOPE = 14,
IS_8XSCOPE = 15,
IS_15XSCOPE = 16,
kIS_1XSCOPE = 12,
kIS_2XSCOPE = 13,
kIS_4XSCOPE = 14,
kIS_8XSCOPE = 15,
kIS_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
kIS_END
};
enum SkillCond_e
{
SC_Active = 1,
SC_Passive = 2
kSC_Active = 1,
kSC_Passive = 2
};
enum VirtualWeapon_e
{
VW_Spectate = 9000001,
VW_SelfDetonate = 9000002,
VW_Mine = 9000003,
kVW_Spectate = 9000001,
kVW_SelfDetonate = 9000002,
kVW_Mine = 9000003,
};
enum VirtualPlayer_e
{
VP_Spectate = 9000001,
VP_SelfDetonate = 9000002,
VP_Mine = 9000003,
};
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
kVP_Spectate = 9000001,
kVP_SelfDetonate = 9000002,
kVP_Mine = 9000003,
};
enum EntityType_e
{
ET_None = 0,
ET_Player = 1,
ET_Obstacle = 2,
ET_Building = 3,
//ET_LootSpawner = 4,
ET_Loot = 5,
kET_None = 0,
kET_Player = 1,
kET_Obstacle = 2,
kET_Building = 3,
//kET_LootSpawner = 4,
kET_Loot = 5,
//ET_DeadBody = 6,
//ET_Decal = 7,
//ET_Projectile = 8,
ET_Smoke = 9,
ET_Hero = 10,
kET_Smoke = 9,
kET_Hero = 10,
ET_Bullet = 20,
kET_Bullet = 20,
ET_Android = 30,
ET_MAX
kET_Android = 30,
kET_MAX
};
enum EntitySubType_e
{
EST_None = 0,
EST_Player = 1,
EST_Android = 2,
kEST_None = 0,
kEST_Player = 1,
kEST_Android = 2,
};
enum SkillTarget_e
{
ST_All = 0,
kST_All = 0,
ST_Self = 1,
ST_FriendlyIncludeSelf = 2,
ST_FriendlyExcludeSelf = 3,
kST_Self = 1,
kST_FriendlyIncludeSelf = 2,
kST_FriendlyExcludeSelf = 3,
ST_EnemySingle = 6,
ST_EnemyGroup = 7,
ST_EnemyAndObject = 8,
ST_EnemyAndSelf = 9,
ST_SingleEnemyAndSelf = 10
kST_EnemySingle = 6,
kST_EnemyGroup = 7,
kST_EnemyAndObject = 8,
kST_EnemyAndSelf = 9,
kST_SingleEnemyAndSelf = 10
};
enum BuffTriggerType_e
{
BTT_UseSkill = 1, //技能释放时触发
BTT_Kill = 2, //击杀敌方后触发
BTT_SkillHit = 3, //技能命中触发
kBTT_UseSkill = 1, //技能释放时触发
kBTT_Kill = 2, //击杀敌方后触发
kBTT_SkillHit = 3, //技能命中触发
BTT_OtherBuff = 4,//其他buff触发
BTT_UseItem = 6 //使用道具触发
kBTT_UseItem = 6 //使用道具触发
};
enum BuffTargetType_e

View File

@ -97,7 +97,7 @@ void Entity::FindLocationWithTarget(Entity* target)
for (auto& grid : new_grid_list) {
for (Entity* entity : grid->entity_list) {
switch (entity->entity_type) {
case ET_Building:
case kET_Building:
{
if (TestCollision(entity)) {
building = entity;
@ -136,12 +136,12 @@ void Entity::FindLocationWithTarget(Entity* target)
{
grid_list.clear();
switch (entity_type) {
case ET_Player:
case kET_Player:
{
room->grid_service.AddHuman((Human*)this);
}
break;
case ET_Bullet:
case kET_Bullet:
{
room->grid_service.AddBullet((Bullet*)this);
}

View File

@ -16,8 +16,8 @@ class Entity
{
public:
int entity_uniid = 0;
EntityType_e entity_type = ET_None;
EntitySubType_e entity_subtype = EST_None;
EntityType_e entity_type = kET_None;
EntitySubType_e entity_subtype = kEST_None;
long long create_frameno = 0;
Room* room = nullptr;
a8::Vec2 pos;

View File

@ -26,7 +26,7 @@ ColliderComponent* Global::last_collider = nullptr;
bool IsValidSlotId(int slot_id)
{
return slot_id >= 0 && slot_id < IS_END;
return slot_id >= 0 && slot_id < kIS_END;
}
bool IsValidBuffEffect(int buff_effect)

View File

@ -169,7 +169,7 @@ void GridService::DelBullet(Bullet* bullet)
void GridService::AddEntity(Entity* entity)
{
assert(entity->entity_type != ET_Player);
assert(entity->entity_type != kET_Player);
int x = (int)entity->pos.x + cell_width_;
int y = (int)entity->pos.y + cell_width_;
if (BroderOverFlow(x, y)) {
@ -225,12 +225,12 @@ void GridService::RemoveFromGridList(std::set<GridCell*>& grid_list, Entity* ent
{
for (auto& grid : grid_list) {
switch (entity->entity_type) {
case ET_Player:
case kET_Player:
{
grid->human_list.erase((Human*)entity);
}
break;
case ET_Bullet:
case kET_Bullet:
{
grid->bullet_list.erase((Bullet*)entity);
}

View File

@ -60,7 +60,7 @@ static void _GMStatGetRealTimeOnline(f8::JsonHttpRequest* request)
{
request->resp_xobj->SetVal("errcode", 0);
request->resp_xobj->SetVal("errmsg", "");
request->resp_xobj->SetVal("num", App::Instance()->perf.entity_num[ET_Player]);
request->resp_xobj->SetVal("num", App::Instance()->perf.entity_num[kET_Player]);
}
void HandlerMgr::Init()

View File

@ -7,7 +7,7 @@
Hero::Hero(): Entity()
{
entity_type = ET_Hero;
entity_type = kET_Hero;
}
Hero::~Hero()

View File

@ -44,15 +44,15 @@ Human::Human():Entity()
}
weapons[0] = default_weapon;
curr_weapon = &weapons[0];
inventory_[IS_1XSCOPE] = 1;
inventory_[kIS_1XSCOPE] = 1;
if (MetaMgr::Instance()->fighting_mode) {
inventory_[IS_9MM] = FIGHTING_MODE_BULLET_NUM;
inventory_[IS_556MM] = FIGHTING_MODE_BULLET_NUM;
inventory_[IS_762MM] = FIGHTING_MODE_BULLET_NUM;
inventory_[IS_12GAUGE] = FIGHTING_MODE_BULLET_NUM;
inventory_[IS_RPG] = FIGHTING_MODE_BULLET_NUM;
inventory_[IS_TANK] = FIGHTING_MODE_BULLET_NUM;
inventory_[kIS_9MM] = FIGHTING_MODE_BULLET_NUM;
inventory_[kIS_556MM] = FIGHTING_MODE_BULLET_NUM;
inventory_[kIS_762MM] = FIGHTING_MODE_BULLET_NUM;
inventory_[kIS_12GAUGE] = FIGHTING_MODE_BULLET_NUM;
inventory_[kIS_RPG] = FIGHTING_MODE_BULLET_NUM;
inventory_[kIS_TANK] = FIGHTING_MODE_BULLET_NUM;
}
}
@ -97,7 +97,7 @@ float Human::GetSpeed4()
void Human::FillMFObjectPart(cs::MFObjectPart* part_data)
{
part_data->set_object_type(ET_Player);
part_data->set_object_type(kET_Player);
cs::MFPlayerPart* p = part_data->mutable_union_obj_1();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
@ -108,7 +108,7 @@ void Human::FillMFObjectPart(cs::MFObjectPart* part_data)
void Human::FillMFObjectFull(cs::MFObjectFull* full_data)
{
full_data->set_object_type(ET_Player);
full_data->set_object_type(kET_Player);
cs::MFPlayerFull* p = full_data->mutable_union_obj_1();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
@ -254,8 +254,8 @@ bool Human::IsCollisionInMapService()
for (const ColliderComponent* collider : colliders) {
switch (collider->owner->entity_type) {
case ET_Obstacle:
case ET_Building:
case kET_Obstacle:
case kET_Building:
{
if (!collider->owner->dead && TestCollision((ColliderComponent*)collider)) {
if (last_collision_door != collider->owner) {
@ -452,7 +452,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
lethal_weapon = weapon_id;
{
Entity* entity = room->GetEntityByUniId(killer_id);
if (entity && entity->entity_type == ET_Player) {
if (entity && entity->entity_type == kET_Player) {
Human* killer = (Human*)entity;
killer->stats.dead_times++;
}
@ -573,12 +573,12 @@ void Human::DoSkill()
playing_skill = true;
last_use_skill_frameno_ = room->frame_no;
Entity* entity = room->GetEntityByUniId(skill_target_id);
if (entity && entity->entity_type == ET_Player) {
if (entity && entity->entity_type == kET_Player) {
Human* hum = (Human*)entity;
std::set<Entity*> target_list;
skill_target_pos = hum->pos;
SelectSkillTargets(hum->pos, target_list);
TriggerBuff(target_list, BTT_UseSkill);
TriggerBuff(target_list, kBTT_UseSkill);
if (!skill_meta_->phases.empty() && skill_meta_->phases[0].time_offset <= 0) {
UpdateSkill();
}
@ -597,7 +597,7 @@ void Human::FindLocation()
for (auto& grid : grid_list) {
for (Entity* entity : grid->entity_list) {
switch (entity->entity_type) {
case ET_Obstacle:
case kET_Obstacle:
{
if (!target) {
if (TestCollision(entity)) {
@ -606,9 +606,9 @@ void Human::FindLocation()
}
}
break;
case ET_Building:
case kET_Building:
{
if (!target || target->entity_type != ET_Building) {
if (!target || target->entity_type != kET_Building) {
AabbCollider aabb_box;
entity->GetAabbBox(aabb_box);
if (TestCollision(&aabb_box)) {
@ -638,9 +638,9 @@ void Human::RefreshView()
}
for (Entity* entity : cell->entity_list) {
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case kET_Building:
case kET_Obstacle:
case kET_Hero:
{
AddToNewObjects(entity);
}
@ -673,9 +673,9 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
for (Entity* entity : cell->entity_list) {
if (!room->grid_service.EntityInGridList(entity, old_grid_list)) {
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case kET_Building:
case kET_Obstacle:
case kET_Hero:
{
AddToNewObjects(entity);
RemoveOutObjects(entity);
@ -699,9 +699,9 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
for (Entity* entity : cell->entity_list) {
if (!room->grid_service.EntityInGridList(entity, grid_list)) {
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case kET_Building:
case kET_Obstacle:
case kET_Hero:
{
AddOutObjects(entity);
}
@ -874,9 +874,9 @@ void Human::SendUpdateMsg()
}
for (Entity* entity : cell->entity_list) {
switch (entity->entity_type) {
case ET_Building:
case ET_Obstacle:
case ET_Hero:
case kET_Building:
case kET_Obstacle:
case kET_Hero:
{
view_objects.insert(entity);
}
@ -1086,7 +1086,7 @@ int Human::GetSkillCd()
void Human::TriggerOneObjectBuff(Entity* target, BuffTriggerType_e trigger_type)
{
if (target->entity_type != ET_Player) {
if (target->entity_type != kET_Player) {
return;
}
Human* hum = (Human*)target;
@ -1350,8 +1350,8 @@ void Human::CheckGrass()
for (const ColliderComponent* collider : colliders) {
switch (collider->owner->entity_type) {
case ET_Obstacle:
case ET_Building:
case kET_Obstacle:
case kET_Building:
{
if (TestCollision((ColliderComponent*)collider)) {
in_grass = true;
@ -1535,7 +1535,7 @@ void Human::_UpdateAssaultMove()
}
}
}
TriggerBuff(target_list, BTT_SkillHit);
TriggerBuff(target_list, kBTT_SkillHit);
room->frame_event.AddExplosion(0, pos, 2);
room->grid_service.MoveHuman(this);
}
@ -1656,7 +1656,7 @@ void Human::Revive()
void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list)
{
switch (skill_meta_->i->skill_target()) {
case ST_All:
case kST_All:
{
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
@ -1667,12 +1667,12 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
}
}
break;
case ST_Self:
case kST_Self:
{
target_list.insert(this);
}
break;
case ST_FriendlyIncludeSelf:
case kST_FriendlyIncludeSelf:
{
target_list.insert(this);
for (auto& cell : grid_list) {
@ -1685,7 +1685,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
}
}
break;
case ST_FriendlyExcludeSelf:
case kST_FriendlyExcludeSelf:
{
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
@ -1697,10 +1697,10 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
}
}
break;
case ST_EnemySingle:
case kST_EnemySingle:
{
Entity* entity = room->GetEntityByUniId(skill_target_id);
if (entity && entity->entity_type == ET_Player) {
if (entity && entity->entity_type == kET_Player) {
Human* hum = (Human*)entity;
if (hum->team_id != team_id) {
target_list.insert(hum);
@ -1708,7 +1708,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
}
}
break;
case ST_EnemyGroup:
case kST_EnemyGroup:
{
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
@ -1720,7 +1720,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
}
}
break;
case ST_EnemyAndObject:
case kST_EnemyAndObject:
{
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
@ -1732,7 +1732,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
}
}
break;
case ST_EnemyAndSelf:
case kST_EnemyAndSelf:
{
for (auto& cell : grid_list) {
for (Human* hum : cell->human_list) {
@ -1744,10 +1744,10 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
}
}
break;
case ST_SingleEnemyAndSelf:
case kST_SingleEnemyAndSelf:
{
Entity* entity = room->GetEntityByUniId(skill_target_id);
if (entity && entity->entity_type == ET_Player) {
if (entity && entity->entity_type == kET_Player) {
Human* hum = (Human*)entity;
if (hum->team_id != team_id) {
target_list.insert(hum);

View File

@ -218,8 +218,8 @@ protected:
bool leave_ = false;
long long leave_frameno_ = 0;
std::array<int, IS_END - 1> inventory_ = {};
std::array<int, IS_END> volume_ = {};
std::array<int, kIS_END - 1> inventory_ = {};
std::array<int, kIS_END> volume_ = {};
std::set<Entity*> new_objects_;
std::set<Entity*> part_objects_;
std::set<int> del_objects_;

View File

@ -10,13 +10,13 @@
Loot::Loot():Entity()
{
entity_type = ET_Loot;
++App::Instance()->perf.entity_num[ET_Loot];
entity_type = kET_Loot;
++App::Instance()->perf.entity_num[kET_Loot];
}
Loot::~Loot()
{
--App::Instance()->perf.entity_num[ET_Loot];
--App::Instance()->perf.entity_num[kET_Loot];
}
void Loot::Initialize()
@ -31,7 +31,7 @@ void Loot::RecalcSelfCollider()
void Loot::FillMFObjectPart(cs::MFObjectPart* part_data)
{
part_data->set_object_type(ET_Loot);
part_data->set_object_type(kET_Loot);
cs::MFLootPart* p = part_data->mutable_union_obj_5();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
@ -39,7 +39,7 @@ void Loot::FillMFObjectPart(cs::MFObjectPart* part_data)
void Loot::FillMFObjectFull(cs::MFObjectFull* full_data)
{
full_data->set_object_type(ET_Loot);
full_data->set_object_type(kET_Loot);
cs::MFLootFull* p = full_data->mutable_union_obj_5();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());

View File

@ -345,53 +345,6 @@ namespace MetaData
return i->buff_effect() == BET_ChgAttr;
}
void Dress::Init()
{
for (int j = 0; j < i->max_lv(); ++j) {
std::array<float, EA_End>& attrs = a8::FastAppend(level_attrs);
for (size_t k = 0; k < EA_End; ++k) {
attrs[k] = 0;
}
}
{
std::vector<std::string> strings;
a8::Split(i->attr_type(), strings, '|');
for (auto& str : strings) {
std::vector<std::string> strings2;
a8::Split(str, strings2, ':');
if (strings2.size() != 3) {
abort();
}
int attr_type = a8::XValue(strings2[0]);
int attr_level = a8::XValue(strings2[1]);
float attr_value = a8::XValue(strings2[2]).GetDouble();
if (attr_type < EA_End) {
if (attr_level >= 0 && attr_level < i->max_lv()) {
for (int j = 1; j < i->max_lv(); ++j) {
if (j % attr_type == 0) {
level_attrs[j][attr_type] = attr_value * (j / attr_level);
}
}
}
}
}
}
}
float Dress::GetAttrValue(int level, int attr_type)
{
if (level < 1) {
return 0;
}
if (level > (int)level_attrs.size()) {
return 0;
}
if (attr_type < EA_End) {
return level_attrs[level][attr_type];
}
return 0;
}
void Driver::Init()
{
{

View File

@ -54,7 +54,7 @@ namespace MetaData
const metatable::Equip* i = nullptr;
std::vector<std::tuple<int, std::vector<BulletBornPoint>>> bullet_born_offset;
std::array<int, IS_END> volume = {};
std::array<int, kIS_END> volume = {};
void Init();
bool CanDrop();
@ -65,7 +65,7 @@ namespace MetaData
{
const metatable::Player* i = nullptr;
std::array<int, IS_END> volume = {};
std::array<int, kIS_END> volume = {};
void Init();
};
@ -155,17 +155,6 @@ namespace MetaData
std::vector<MetaData::SkillPhase> phases;
};
struct Dress
{
const metatable::Dress* i = nullptr;
void Init();
float GetAttrValue(int level, int attr_type);
private:
std::vector<std::array<float, EA_End>> level_attrs;
};
struct RankReward
{
const metatable::RankReward* i = nullptr;

View File

@ -29,8 +29,6 @@ public:
std::list<MetaData::Building> building_list;
std::list<metatable::Drop> drop_meta_list;
std::list<MetaData::Drop> drop_list;
std::list<metatable::Dress> dress_meta_list;
std::list<MetaData::Dress> dress_list;
std::list<metatable::Tank> tank_meta_list;
std::list<MetaData::Tank> tank_list;
std::list<metatable::TankSkin> tanktank_meta_list;
@ -64,7 +62,6 @@ public:
std::map<std::string, std::vector<MetaData::MapTplThing>> maptpl_hash;
std::map<std::string, std::vector<MetaData::MapTplThing>> born_point_hash;
std::map<std::string, std::tuple<int, int>> maptpl_size_hash;
std::map<int, MetaData::Dress*> dress_hash;
std::map<int, MetaData::Tank*> tank_hash;
std::map<int, MetaData::TankSkin*> tankskin_hash;
std::vector<int> tankid_list;
@ -107,7 +104,6 @@ public:
f8::ReadCsvMetaFile(res_path + "mapThing@mapThing.csv", mapthing_meta_list);
f8::ReadCsvMetaFile(res_path + "drop@drop.csv", drop_meta_list);
f8::ReadJsonMetaFile(res_path + "maps.json", building_meta_list);
f8::ReadCsvMetaFile(res_path + "dress@dress.csv", dress_meta_list);
f8::ReadCsvMetaFile(res_path + "skill@skill.csv", skill_meta_list);
f8::ReadCsvMetaFile(res_path + "buff@buff.csv", buff_meta_list);
f8::ReadCsvMetaFile(res_path + "attr@attr.csv", attr_meta_list);
@ -281,12 +277,6 @@ private:
}
}
for (auto& meta : dress_meta_list) {
MetaData::Dress& item = a8::FastAppend(dress_list);
item.i = &meta;
dress_hash[item.i->id()] = &item;
}
for (auto& meta : buff_meta_list) {
if (!IsValidBuffEffect(meta.buff_effect())) {
abort();
@ -480,12 +470,6 @@ MetaData::Attr* MetaMgr::GetAttrByName(const std::string& attr_name)
return itr != loader_->attr_name_hash.end() ? itr->second : nullptr;
}
MetaData::Dress* MetaMgr::GetDress(int dress_id)
{
auto itr = loader_->dress_hash.find(dress_id);
return itr != loader_->dress_hash.end() ? itr->second : nullptr;
}
MetaData::Driver* MetaMgr::GetDriver(int driver_id)
{
auto itr = loader_->driver_hash.find(driver_id);

View File

@ -35,7 +35,6 @@ class MetaMgr : public a8::Singleton<MetaMgr>
MetaData::Buff* GetBuff(int buff_id);
MetaData::Attr* GetAttrById(int attr_id);
MetaData::Attr* GetAttrByName(const std::string& attr_name);
MetaData::Dress* GetDress(int dress_id);
MetaData::Driver* GetDriver(int driver_id);
MetaData::Tank* GetTank(int tank_id);
MetaData::TankSkin* GetTankSkin(int tank_id);

View File

@ -11,13 +11,13 @@
Obstacle::Obstacle():Entity()
{
entity_type = ET_Obstacle;
++App::Instance()->perf.entity_num[ET_Obstacle];
entity_type = kET_Obstacle;
++App::Instance()->perf.entity_num[kET_Obstacle];
}
Obstacle::~Obstacle()
{
--App::Instance()->perf.entity_num[ET_Obstacle];
--App::Instance()->perf.entity_num[kET_Obstacle];
}
void Obstacle::Initialize()
@ -95,7 +95,7 @@ void Obstacle::RecalcSelfCollider()
void Obstacle::FillMFObjectPart(cs::MFObjectPart* part_data)
{
part_data->set_object_type(ET_Obstacle);
part_data->set_object_type(kET_Obstacle);
cs::MFObstaclePart* p = part_data->mutable_union_obj_2();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
@ -104,7 +104,7 @@ void Obstacle::FillMFObjectPart(cs::MFObjectPart* part_data)
void Obstacle::FillMFObjectFull(cs::MFObjectFull* full_data)
{
full_data->set_object_type(ET_Obstacle);
full_data->set_object_type(kET_Obstacle);
cs::MFObstacleFull* p = full_data->mutable_union_obj_2();
p->set_obj_uniid(entity_uniid);
TypeConvert::ToPb(pos, p->mutable_pos());
@ -181,8 +181,8 @@ void Obstacle::Explosion()
}
for (Entity* entity : grid->entity_list) {
switch (entity->entity_type) {
case ET_Obstacle:
case ET_Building:
case kET_Obstacle:
case kET_Building:
{
if (entity != this && entity->TestCollision(&collider)) {
objects.insert(entity);
@ -200,7 +200,7 @@ void Obstacle::Explosion()
room->frame_event.AddExplosion(meta->i->thing_id(), bomb_pos, 0);
for (auto& target : objects) {
switch (target->entity_type) {
case ET_Player:
case kET_Player:
{
Human* hum = (Human*)target;
if (!hum->dead && hum != master) {
@ -212,12 +212,12 @@ void Obstacle::Explosion()
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
hum->OnHit();
if (!hum->HasBuffEffect(BET_Invincible)) {
hum->DecHP(finaly_dmg, VP_Mine, "地雷", VW_Mine);
hum->DecHP(finaly_dmg, kVP_Mine, "地雷", kVW_Mine);
}
}
}
break;
case ET_Obstacle:
case kET_Obstacle:
{
Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->dead && obstacle->meta->i->attack_type() == 1) {

View File

@ -17,14 +17,14 @@
Player::Player():Human()
{
entity_type = ET_Player;
entity_subtype = EST_Player;
++App::Instance()->perf.entity_num[ET_Player];
entity_type = kET_Player;
entity_subtype = kEST_Player;
++App::Instance()->perf.entity_num[kET_Player];
}
Player::~Player()
{
--App::Instance()->perf.entity_num[ET_Player];
--App::Instance()->perf.entity_num[kET_Player];
}
void Player::Initialize()
@ -188,13 +188,13 @@ void Player::UpdateCancelAction()
void Player::UpdateUseItemIdx()
{
if (use_item_idx >= 0 && use_item_idx < IS_END) {
if (use_item_idx >= 0 && use_item_idx < kIS_END) {
switch (use_item_idx) {
case IS_HEALTHKIT:
case kIS_HEALTHKIT:
{
}
break;
case IS_PAIN_KILLER:
case kIS_PAIN_KILLER:
{
}
break;
@ -214,7 +214,7 @@ void Player::UpdateSpectate()
spectate = false;
return;
}
BeKill(entity_uniid, name, VW_Spectate);
BeKill(entity_uniid, name, kVW_Spectate);
spectate = false;
}
@ -236,17 +236,17 @@ void Player::ProcInteraction()
Entity* entity = room->GetEntityByUniId(obj_id);
if (entity) {
switch (entity->entity_type) {
case ET_Obstacle:
case kET_Obstacle:
{
ObstacleInteraction((Obstacle*)entity);
}
break;
case ET_Loot:
case kET_Loot:
{
LootInteraction((Loot*)entity);
}
break;
case ET_Player:
case kET_Player:
{
HumanInteraction((Human*)entity);
}
@ -509,8 +509,8 @@ void Player::UpdateDropWeapon()
void Player::UpdateUseScope()
{
if (IS_1XSCOPE + use_scope_idx >= IS_1XSCOPE && IS_1XSCOPE + use_scope_idx <= IS_15XSCOPE) {
if (GetInventory(IS_1XSCOPE + use_scope_idx) > 0) {
if (kIS_1XSCOPE + use_scope_idx >= kIS_1XSCOPE && kIS_1XSCOPE + use_scope_idx <= kIS_15XSCOPE) {
if (GetInventory(kIS_1XSCOPE + use_scope_idx) > 0) {
curr_scope_idx = use_scope_idx;
need_sync_active_player = true;
}
@ -561,7 +561,7 @@ void Player::_CMLeave(f8::MsgHdr& hdr, const cs::CMLeave& msg)
if (!leave_) {
if (room->BattleStarted()) {
//如果战斗已经开始算自杀
BeKill(entity_uniid, name, VW_Spectate);
BeKill(entity_uniid, name, kVW_Spectate);
}
leave_ = true;
leave_frameno_ = room->frame_no;

View File

@ -100,7 +100,7 @@ void Room::Update(int delta_time)
UpdateGas();
}
for (auto& pair : moveable_hash_) {
if (pair.second->entity_type == ET_Player &&
if (pair.second->entity_type == kET_Player &&
pair.second->updated_times <= 0) {
if (frame_no % 2 == 0) {
pair.second->Update(50);
@ -136,13 +136,13 @@ Player* Room::GetPlayerByAccountId(const std::string& accountid)
Player* Room::GetPlayerByUniId(int uniid)
{
Entity* entity = GetEntityByUniId(uniid);
return entity->entity_type == ET_Player && entity->entity_subtype == EST_Player ? (Player*)entity : nullptr;
return entity->entity_type == kET_Player && entity->entity_subtype == kEST_Player ? (Player*)entity : nullptr;
}
Human* Room::GetHumanByUniId(int uniid)
{
Entity* entity = GetEntityByUniId(uniid);
return entity && entity->entity_type == ET_Player ? (Human*)entity : nullptr;
return entity && entity->entity_type == kET_Player ? (Human*)entity : nullptr;
}
Entity* Room::GetEntityByUniId(int uniid)
@ -306,9 +306,9 @@ Human* Room::FindEnemy(Human* hum)
{
std::vector<Human*> enemys;
enemys.reserve(50);
EntitySubType_e sub_type = EST_Player;
EntitySubType_e sub_type = kEST_Player;
if ((rand() % 10) < 2) {
sub_type = EST_Android;
sub_type = kEST_Android;
}
for (auto& cell : hum->grid_list) {
for (Human* target : cell->human_list) {
@ -574,26 +574,26 @@ void Room::RemoveObjectLater(Entity* entity)
{
Entity* entity = (Entity*)param.sender.GetUserData();
switch (entity->entity_type) {
case ET_Bullet:
case kET_Bullet:
{
entity->room->moveable_hash_.erase(entity->entity_uniid);
entity->room->grid_service.DelBullet((Bullet*)entity);
}
break;
case ET_Loot:
case ET_Hero:
case kET_Loot:
case kET_Hero:
{
entity->BroadcastDeleteState();
entity->room->grid_service.DelEntity(entity);
}
break;
case ET_Player:
case kET_Player:
{
entity->room->moveable_hash_.erase(entity->entity_uniid);
entity->room->human_hash_.erase(entity->entity_uniid);
}
break;
case ET_Obstacle:
case kET_Obstacle:
{
entity->BroadcastDeleteState();
entity->room->grid_service.DelEntity(entity);
@ -619,7 +619,7 @@ void Room::RemoveObjectLater(Entity* entity)
void Room::FetchBuilding(Human* hum)
{
for (auto& pair : uniid_hash_) {
if (pair.second->entity_type == ET_Building) {
if (pair.second->entity_type == kET_Building) {
hum->AddToNewObjects(pair.second);
}
}
@ -941,7 +941,7 @@ void Room::AddObjectLater(Entity* entity)
auto add_func = [] (const a8::XParams& param)
{
Entity* entity = (Entity*)param.sender.GetUserData();
if (entity->entity_type == ET_Bullet) {
if (entity->entity_type == kET_Bullet) {
entity->room->moveable_hash_[entity->entity_uniid] = entity;
}
entity->room->uniid_hash_[entity->entity_uniid] = entity;
@ -959,7 +959,7 @@ void Room::RandRemoveAndroid()
{
Human* hum = nullptr;
for (auto& pair : human_hash_) {
if (pair.second->entity_subtype == EST_Android) {
if (pair.second->entity_subtype == kEST_Android) {
hum = pair.second;
break;
}
@ -1056,7 +1056,7 @@ void Room::BattleReport()
p->set_dead_times(hum->stats.dead_times);
}
for (Human* hum : human_list) {
if (hum->entity_subtype == EST_Player) {
if (hum->entity_subtype == kEST_Player) {
hum->SendNotifyMsg(msg);
}
}

View File

@ -9,7 +9,7 @@
Smoke::Smoke():Entity()
{
entity_type = ET_Smoke;
entity_type = kET_Smoke;
}
Smoke::~Smoke()