From d312970da81aeea19a2522c92103ad32da72ead5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 22 Jul 2019 09:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/android.ai.cc | 10 +-- server/gameserver/android.cc | 14 ++-- server/gameserver/app.cc | 18 ++--- server/gameserver/buff.cc | 8 +-- server/gameserver/building.cc | 2 +- server/gameserver/bullet.cc | 22 +++--- server/gameserver/constant.h | 114 ++++++++++++++--------------- server/gameserver/framemaker.cc | 2 +- server/gameserver/gamelog.cc | 4 +- server/gameserver/global.cc | 6 +- server/gameserver/human.cc | 124 ++++++++++++++++---------------- server/gameserver/human.h | 6 +- server/gameserver/mapservice.cc | 4 +- server/gameserver/metadata.cc | 12 ++-- server/gameserver/metadata.h | 2 +- server/gameserver/metamgr.cc | 4 +- server/gameserver/obstacle.cc | 2 +- server/gameserver/player.cc | 56 +++++++-------- server/gameserver/playermgr.cc | 16 ++--- server/gameserver/room.cc | 32 ++++----- 20 files changed, 229 insertions(+), 229 deletions(-) diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index f3830fd..94bad45 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -93,7 +93,7 @@ void AndroidAI::ChangeToState(AndroidState_e to_state) void AndroidAI::DoMove() { Human* hum = (Human*)owner; - if (hum->HasBuffEffect(BET_Vertigo) || hum->HasBuffEffect(BET_Dcgr)) { + if (hum->HasBuffEffect(kBET_Vertigo) || hum->HasBuffEffect(kBET_Dcgr)) { return; } if (owner->updated_times % 2 == 0) { @@ -121,15 +121,15 @@ void AndroidAI::DoAttack() if (hum->room->gas_data.gas_mode == kGasInactive) { return; } - if (hum->HasBuffEffect(BET_Vertigo) || hum->HasBuffEffect(BET_Dcgr)) { + if (hum->HasBuffEffect(kBET_Vertigo) || hum->HasBuffEffect(kBET_Dcgr)) { return; } if (owner->updated_times % 10 == 0) { Human* enemy = owner->room->FindEnemy((Human*)owner); if (enemy && - !enemy->HasBuffEffect(BET_Invincible) && - !enemy->HasBuffEffect(BET_Hide) && - !enemy->HasBuffEffect(BET_InGrass) + !enemy->HasBuffEffect(kBET_Invincible) && + !enemy->HasBuffEffect(kBET_Hide) && + !enemy->HasBuffEffect(kBET_InGrass) ) { Human* sender = (Human*)owner; if (sender->CanUseSkill()) { diff --git a/server/gameserver/android.cc b/server/gameserver/android.cc index 8f5531b..5b37b36 100644 --- a/server/gameserver/android.cc +++ b/server/gameserver/android.cc @@ -53,13 +53,13 @@ void Android::GiveEquip() if (tank_meta_) { MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(tank_meta_->i->bullet_id()); if (weapon_meta) { - weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1; - weapons[GUN_SLOT1].weapon_id = weapon_meta->i->id(); - weapons[GUN_SLOT1].weapon_lv = robot_meta->i->weapon_lv(); - weapons[GUN_SLOT1].ammo = 0; - weapons[GUN_SLOT1].meta = weapon_meta; - weapons[GUN_SLOT1].Recalc(); - curr_weapon = &weapons[GUN_SLOT1]; + weapons[kGUN_SLOT1].weapon_idx = kGUN_SLOT1; + weapons[kGUN_SLOT1].weapon_id = weapon_meta->i->id(); + weapons[kGUN_SLOT1].weapon_lv = robot_meta->i->weapon_lv(); + weapons[kGUN_SLOT1].ammo = 0; + weapons[kGUN_SLOT1].meta = weapon_meta; + weapons[kGUN_SLOT1].Recalc(); + curr_weapon = &weapons[kGUN_SLOT1]; DirectReload(); } } diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index 9b3a239..620b8ad 100755 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -110,12 +110,12 @@ bool App::Init(int argc, char* argv[]) if (!ParseOpt()) { if (node_id <= 0) { a8::XPrintf("gameserver启动失败,缺少-n参数\n", {}); - } else if (node_id > MAX_NODE_ID) { - a8::XPrintf("gameserver启动失败,-n参数不能大于%d\n", {MAX_NODE_ID}); + } else if (node_id > kMAX_NODE_ID) { + a8::XPrintf("gameserver启动失败,-n参数不能大于%d\n", {kMAX_NODE_ID}); } else if (instance_id <= 0) { a8::XPrintf("gameserver启动失败,缺少-i参数\n", {}); - } else if (instance_id > MAX_INSTANCE_ID) { - a8::XPrintf("gameserver启动失败,-i参数不能大于%d\n", {MAX_INSTANCE_ID}); + } else if (instance_id > kMAX_INSTANCE_ID) { + a8::XPrintf("gameserver启动失败,-i参数不能大于%d\n", {kMAX_INSTANCE_ID}); } return false; } @@ -137,11 +137,11 @@ bool App::Init(int argc, char* argv[]) HandlerMgr::Instance()->Init(); a8::Timer::Instance()->Init(); f8::MsgQueue::Instance()->Init(); - f8::TGLog::Instance()->Init(a8::Format(PROJ_NAME_FMT, {GAME_ID}), false); + f8::TGLog::Instance()->Init(a8::Format(kPROJ_NAME_FMT, {GAME_ID}), false); f8::HttpClientPool::Instance()->Init(10); JsonDataMgr::Instance()->Init(); MetaMgr::Instance()->Init(); - uuid.SetMachineId((node_id - 1) * MAX_NODE_ID + instance_id); + uuid.SetMachineId((node_id - 1) * kMAX_NODE_ID + instance_id); RoomMgr::Instance()->Init(); PlayerMgr::Instance()->Init(); GGListener::Instance()->Init(); @@ -470,10 +470,10 @@ void App::InitLog() std::string filename_fmt = PROJ_LOG_FILENAME_FMT; a8::ReplaceString(filename_fmt, "$pid", a8::XValue(getpid())); - std::string proj_root_dir = a8::Format(PROJ_ROOT_FMT, {a8::Format(PROJ_NAME_FMT,{GAME_ID})}); - std::string proj_log_root_dir = a8::Format(PROJ_LOG_ROOT_FMT, {a8::Format(PROJ_NAME_FMT, {GAME_ID})}); + std::string proj_root_dir = a8::Format(kPROJ_ROOT_FMT, {a8::Format(kPROJ_NAME_FMT,{GAME_ID})}); + std::string proj_log_root_dir = a8::Format(PROJ_LOG_ROOT_FMT, {a8::Format(kPROJ_NAME_FMT, {GAME_ID})}); std::string log_file_name = a8::Format(PROJ_LOG_ROOT_FMT, - {a8::Format(PROJ_NAME_FMT, {GAME_ID})}) + "/" + filename_fmt; + {a8::Format(kPROJ_NAME_FMT, {GAME_ID})}) + "/" + filename_fmt; a8::MkDir(proj_root_dir); a8::MkDir(proj_log_root_dir); diff --git a/server/gameserver/buff.cc b/server/gameserver/buff.cc index 91358f5..17f3dc6 100644 --- a/server/gameserver/buff.cc +++ b/server/gameserver/buff.cc @@ -8,7 +8,7 @@ int Buff::GetLeftTime() { - int passed_ms = (owner->room->frame_no - add_frameno) * FRAME_RATE_MS; + int passed_ms = (owner->room->frame_no - add_frameno) * kFRAME_RATE_MS; return std::max(GetLastingTime() - passed_ms, 0); } @@ -28,7 +28,7 @@ void Buff::ProcLastBurn(const a8::XParams& param) { Human* hum = (Human*)param.sender.GetUserData(); Buff* buff = (Buff*)param.param1.GetUserData(); - if (!hum->dead && !hum->HasBuffEffect(BET_Invincible)) { + if (!hum->dead && !hum->HasBuffEffect(kBET_Invincible)) { float power = buff->meta->param1; float def = hum->ability.def; float finally_dmg = power * (1 - def/MetaMgr::Instance()->K); @@ -50,7 +50,7 @@ void Buff::ProcReleaseDcgr(const a8::XParams& param) collider.rad = buff->meta->param2; for (auto& cell : sender->grid_list) { for (Human* hum : cell->human_list) { - if (hum != sender && !hum->HasBuffEffect(BET_Invincible)) { + if (hum != sender && !hum->HasBuffEffect(kBET_Invincible)) { if (hum->TestCollision(&collider)) { hum->AddBuff(add_buff); } @@ -71,7 +71,7 @@ void Buff::ProcReleaseFireBomb(const a8::XParams& param) collider.rad = buff->meta->param3; for (auto& cell : sender->grid_list) { for (Human* hum : cell->human_list) { - if (hum != sender && !hum->dead && !hum->HasBuffEffect(BET_Invincible)) { + if (hum != sender && !hum->dead && !hum->HasBuffEffect(kBET_Invincible)) { if (hum->TestCollision(&collider)) { float power = buff->meta->param4 + sender->ability.atk; float def = hum->ability.def; diff --git a/server/gameserver/building.cc b/server/gameserver/building.cc index b00761e..d4cdc45 100644 --- a/server/gameserver/building.cc +++ b/server/gameserver/building.cc @@ -40,7 +40,7 @@ void Building::RecalcSelfCollider() for (auto& obj : meta->i->grassobj()) { AabbCollider* collider = new AabbCollider(); collider->owner = this; - collider->tag = ColliderTag_Grass; + collider->tag = kColliderTag_Grass; collider->_min = a8::Vec2(obj.x() - obj.width()/2.0 - meta->i->tilewidth()/2.0, obj.y() - obj.height()/2.0 - meta->i->tileheight()/2.0); collider->_max = a8::Vec2(obj.x() + obj.width()/2.0 - meta->i->tilewidth()/2.0, diff --git a/server/gameserver/bullet.cc b/server/gameserver/bullet.cc index 9c8fe97..08973a9 100644 --- a/server/gameserver/bullet.cc +++ b/server/gameserver/bullet.cc @@ -29,7 +29,7 @@ void Bullet::Update(int delta_time) if (dead) { return; } - pos = pos + dir * meta->i->bullet_speed() / (float)SERVER_FRAME_RATE; + pos = pos + dir * meta->i->bullet_speed() / (float)kSERVER_FRAME_RATE; float distance = (pos - born_pos).Norm(); if (room->OverBorder(pos, meta->i->bullet_rad())) { if (IsBomb()) { @@ -90,7 +90,7 @@ void Bullet::OnHit(std::set& objects) return; } Human* hum = (Human*)target; - if (hum->HasBuffEffect(BET_Invincible)) { + if (hum->HasBuffEffect(kBET_Invincible)) { continue; } #if 1 @@ -104,7 +104,7 @@ void Bullet::OnHit(std::set& objects) float finaly_dmg = power * (1 - def/MetaMgr::Instance()->K); master->stats.damage_amount_out += finaly_dmg; hum->OnHit(); - if (!hum->HasBuffEffect(BET_Invincible)) { + if (!hum->HasBuffEffect(kBET_Invincible)) { if (skill_id != 0) { master->TriggerOneObjectBuff(hum, kBTT_SkillHit); } @@ -197,7 +197,7 @@ void Bullet::PostAttack() for (Human* hum: grid->human_list) { if (hum->pos.Distance(obstacle->pos) < obstacle->meta->i->damage_dia()) { hum->OnHit(); - if (!hum->HasBuffEffect(BET_Invincible)) { + if (!hum->HasBuffEffect(kBET_Invincible)) { float power = obstacle->meta->i->damage() + sender->ability.atk; float def = hum->ability.def; float finally_dmg = power * (1 - def/MetaMgr::Instance()->K); @@ -208,17 +208,17 @@ void Bullet::PostAttack() } }; - if (meta->i->equip_subtype() == BulletType_FireBomb) { + if (meta->i->equip_subtype() == kBulletType_FireBomb) { //燃烧弹火墙 - Obstacle* obstacle = room->CreateObstacle(FIRE_WALL_EQUIP_ID, pos.x, pos.y); + Obstacle* obstacle = room->CreateObstacle(kFIRE_WALL_EQUIP_ID, pos.x, pos.y); if (obstacle) { - room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(kSERVER_FRAME_RATE, a8::XParams() .SetSender(obstacle) .SetParam1(master), fire_func, &obstacle->xtimer_attacher.timer_list_); - room->xtimer.AddDeadLineTimerAndAttach(meta->i->time() * SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(meta->i->time() * kSERVER_FRAME_RATE, a8::XParams() .SetSender(obstacle), [] (const a8::XParams& param) @@ -240,10 +240,10 @@ void Bullet::ProcMissible(const a8::XParams& param) a8::Vec2 src_pos(a8::Low32(param.param3.GetInt64()), a8::High32(param.param3.GetInt64())); Human* target = sender->room->GetHumanByUniId(param.param2); if (target && !target->dead) { - if (bullet_meta->i->equip_subtype() == BulletType_Trace) { + if (bullet_meta->i->equip_subtype() == kBulletType_Trace) { if (src_pos.Distance(target->pos) < bullet_meta->i->range()) { target->OnHit(); - if (!target->HasBuffEffect(BET_Invincible)) { + if (!target->HasBuffEffect(kBET_Invincible)) { float power = bullet_meta->i->atk() + sender->ability.atk; float def = target->ability.def; float finally_dmg = power * (1 - def/MetaMgr::Instance()->K); @@ -256,7 +256,7 @@ void Bullet::ProcMissible(const a8::XParams& param) } } else { target->OnHit(); - if (!target->HasBuffEffect(BET_Invincible)) { + if (!target->HasBuffEffect(kBET_Invincible)) { float power = bullet_meta->i->atk() + sender->ability.atk; float def = target->ability.def; float finally_dmg = power * (1 - def/MetaMgr::Instance()->K); diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 65e943c..bb4bc78 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -134,7 +134,7 @@ enum BuffTriggerType_e kBTT_UseSkill = 1, //技能释放时触发 kBTT_Kill = 2, //击杀敌方后触发 kBTT_SkillHit = 3, //技能命中触发 - BTT_OtherBuff = 4,//其他buff触发 + kBTT_OtherBuff = 4,//其他buff触发 kBTT_UseItem = 6 //使用道具触发 }; @@ -147,99 +147,99 @@ enum BuffTargetType_e enum BuffEffectType_e { - BET_Begin = 0, - BET_ChgAttr = 1, //改变属性 - BET_Vertigo = 2, //眩晕 - BET_InGrass = 3, //在草丛 - BET_LastBurn = 4, //持续灼烧 - BET_Invincible = 5, //无敌 - BET_Hide = 6, //隐身 - BET_Dcgr = 7, //电磁干扰 - BET_ReleaseDcgr = 8, //释放电磁干扰 - BET_ReleaseFireBomb = 9, //喷火 - BET_Assault = 10, //向心突击 - BET_End + kBET_Begin = 0, + kBET_ChgAttr = 1, //改变属性 + kBET_Vertigo = 2, //眩晕 + kBET_InGrass = 3, //在草丛 + kBET_LastBurn = 4, //持续灼烧 + kBET_Invincible = 5, //无敌 + kBET_Hide = 6, //隐身 + kBET_Dcgr = 7, //电磁干扰 + kBET_ReleaseDcgr = 8, //释放电磁干扰 + kBET_ReleaseFireBomb = 9, //喷火 + kBET_Assault = 10, //向心突击 + kBET_End }; enum SkillFunc_e { - Skill_FuncNone = 0, - Skill_Jump = 2, - Skill_Shot = 3, - Skill_SummonObject = 4, - Skill_FuncEnd + kSkill_FuncNone = 0, + kSkill_Jump = 2, + kSkill_Shot = 3, + kSkill_SummonObject = 4, + kSkill_FuncEnd }; enum HumanAttrType_e { - HAT_Begin = 0, - HAT_Hp = 1, - HAT_HPRecover = 2, - HAT_Atk = 3, - HAT_Def = 4, - HAT_Speed = 5, - HAT_ShotRange = 6, + kHAT_Begin = 0, + kHAT_Hp = 1, + kHAT_HPRecover = 2, + kHAT_Atk = 3, + kHAT_Def = 4, + kHAT_Speed = 5, + kHAT_ShotRange = 6, HAT_ShotSpeed = 7, HkAT_ReloadSpeed = 8, - HAT_End + kHAT_End }; enum EquipType_e { - EquipType_Bullet = 1, + kEquipType_Bullet = 1, }; enum BulletType_e { - BulletType_Normal = 1, //普通子弹 - BulletType_Missile = 2, //导弹 - BulletType_FireBomb = 3, //燃烧弹 - BulletType_Trace = 4, //追踪弹(超出射程无伤害) + kBulletType_Normal = 1, //普通子弹 + kBulletType_Missile = 2, //导弹 + kBulletType_FireBomb = 3, //燃烧弹 + kBulletType_Trace = 4, //追踪弹(超出射程无伤害) }; enum ColliderTag_e { - ColliderTag_Grass = 1, //草丛 + kColliderTag_Grass = 1, //草丛 }; -const char* const PROJ_NAME_FMT = "game%d_gameserver"; -const char* const PROJ_ROOT_FMT = "/data/logs/%s"; +const char* const kPROJ_NAME_FMT = "game%d_gameserver"; +const char* const kPROJ_ROOT_FMT = "/data/logs/%s"; -const float TEN_W = 10000 * 10; +const float kTEN_W = 10000 * 10; -const int SYS_RESET_TIME = 2*60; //每日两点重置 +const int kSYS_RESET_TIME = 2*60; //每日两点重置 -const int DEF_WEAPON_ID = 12103; +const int kDEF_WEAPON_ID = 12103; -const int SERVER_FRAME_RATE = 20; -const int SYNC_FRAME_RATE = 10; -const float FRAME_RATE_MS = 1000.0f / SERVER_FRAME_RATE; +const int kSERVER_FRAME_RATE = 20; +const int kSYNC_FRAME_RATE = 10; +const float kFRAME_RATE_MS = 1000.0f / kSERVER_FRAME_RATE; -const int MAX_WEAPON_NUM = 5; -const int MAX_SKIN_LV = 9; +const int kMAX_WEAPON_NUM = 5; +const int kMAX_SKIN_LV = 9; -const int GUN_SLOT0 = 0; -const int GUN_SLOT1 = 1; -const int GUN_SLOT2 = 2; +const int kGUN_SLOT0 = 0; +const int kGUN_SLOT1 = 1; +const int kGUN_SLOT2 = 2; -const int FRAG_SLOT = 3; -const int SMOKE_SLOT = 4; +const int kFRAG_SLOT = 3; +const int kSMOKE_SLOT = 4; -const int MAP_CELL_WIDTH = 64 * 8; -const int MAP_GRID_WIDTH = 64; +const int kMAP_CELL_WIDTH = 64 * 8; +const int kMAP_GRID_WIDTH = 64; -const int DOOR_THING_ID = 61701; +const int kDOOR_THING_ID = 61701; -const int FIGHTING_MODE_BULLET_NUM = 10000 * 10000; +const int kFIGHTING_MODE_BULLET_NUM = 10000 * 10000; -const int MAX_NODE_ID = 8; -const int MAX_INSTANCE_ID = 500; +const int kMAX_NODE_ID = 8; +const int kMAX_INSTANCE_ID = 500; -const int MAX_TEAM_NUM = 4; +const int kMAX_TEAM_NUM = 4; -const int WEAPON_SLOT = 0; +const int kWEAPON_SLOT = 0; -const int ROOM_MAX_PLAYER_NUM = 10; +const int kROOM_MAX_PLAYER_NUM = 10; -const int FIRE_WALL_EQUIP_ID = 61401; +const int kFIRE_WALL_EQUIP_ID = 61401; diff --git a/server/gameserver/framemaker.cc b/server/gameserver/framemaker.cc index b51c49c..738a1ce 100644 --- a/server/gameserver/framemaker.cc +++ b/server/gameserver/framemaker.cc @@ -85,7 +85,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum) { if (room->BattleStarted()) { int game_left_time = MetaMgr::Instance()->game_duration * 1000 - - (room->frame_no - room->battle_start_frameno_) * FRAME_RATE_MS; + (room->frame_no - room->battle_start_frameno_) * kFRAME_RATE_MS; game_left_time = std::max(0, game_left_time); msg->set_game_left_time(game_left_time); } else { diff --git a/server/gameserver/gamelog.cc b/server/gameserver/gamelog.cc index e270a0b..76e9f37 100644 --- a/server/gameserver/gamelog.cc +++ b/server/gameserver/gamelog.cc @@ -71,9 +71,9 @@ void GameLog::GameEnd(Player* hum) prop->SetVal("map_name", hum->room->map_meta->i->map_name()); prop->SetVal("map_tpl_name", hum->room->map_tpl_name); if (!hum->dead) { - prop->SetVal("alive_time", hum->room->frame_no * 1000.0f / SERVER_FRAME_RATE); + prop->SetVal("alive_time", hum->room->frame_no * 1000.0f / kSERVER_FRAME_RATE); } else { - prop->SetVal("alive_time", hum->dead_frameno * 1000.0f / SERVER_FRAME_RATE); + prop->SetVal("alive_time", hum->dead_frameno * 1000.0f / kSERVER_FRAME_RATE); } f8::TGLog::Instance()->AddTrackLog(game_id, hum->account_id, hum->ip_saddr, logclass1, logclass2, prop); diff --git a/server/gameserver/global.cc b/server/gameserver/global.cc index 6f2140c..ef281c6 100755 --- a/server/gameserver/global.cc +++ b/server/gameserver/global.cc @@ -15,7 +15,7 @@ time_t Global::GetDaySeconds(time_t time, int incdays) bool Global::IsTimeToReset(int time) { - return BetweenDays(g_nowtime - 60 * SYS_RESET_TIME, time - 60 * SYS_RESET_TIME) > 0; + return BetweenDays(g_nowtime - 60 * kSYS_RESET_TIME, time - 60 * kSYS_RESET_TIME) > 0; } @@ -31,10 +31,10 @@ bool IsValidSlotId(int slot_id) bool IsValidBuffEffect(int buff_effect) { - return buff_effect > BET_Begin && buff_effect < BET_End; + return buff_effect > kBET_Begin && buff_effect < kBET_End; } bool IsValidHumanAttr(int attr_type) { - return attr_type > HAT_Begin && attr_type < HAT_End; + return attr_type > kHAT_Begin && attr_type < kHAT_End; } diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index c06ceae..12ccb88 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -34,8 +34,8 @@ Human::Human():Entity() default_weapon.ammo = 1; default_weapon.meta = MetaMgr::Instance()->GetEquip(default_weapon.weapon_id); default_weapon.Recalc(); - weapons.reserve(MAX_WEAPON_NUM); - for (size_t i = 0; i < MAX_WEAPON_NUM; ++i) { + weapons.reserve(kMAX_WEAPON_NUM); + for (size_t i = 0; i < kMAX_WEAPON_NUM; ++i) { auto& weapon = a8::FastAppend(weapons); weapon.weapon_idx = i; weapon.weapon_id = 0; @@ -47,12 +47,12 @@ Human::Human():Entity() inventory_[kIS_1XSCOPE] = 1; if (MetaMgr::Instance()->fighting_mode) { - 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; + inventory_[kIS_9MM] = kFIGHTING_MODE_BULLET_NUM; + inventory_[kIS_556MM] = kFIGHTING_MODE_BULLET_NUM; + inventory_[kIS_762MM] = kFIGHTING_MODE_BULLET_NUM; + inventory_[kIS_12GAUGE] = kFIGHTING_MODE_BULLET_NUM; + inventory_[kIS_RPG] = kFIGHTING_MODE_BULLET_NUM; + inventory_[kIS_TANK] = kFIGHTING_MODE_BULLET_NUM; } } @@ -72,7 +72,7 @@ void Human::Initialize() float Human::GetSpeed() { if (a8::HasBitFlag(status, HS_Assaulting)) { - Buff* buff = GetBuffByEffectId(BET_Assault); + Buff* buff = GetBuffByEffectId(kBET_Assault); if (buff) { return buff->meta->param2; } @@ -81,12 +81,12 @@ float Human::GetSpeed() if (action_type == kAT_Reload) { speed = ability.reload_speed; } else if (shot_hold) { - if (curr_weapon->weapon_idx == GUN_SLOT1 || - curr_weapon->weapon_idx == GUN_SLOT2) { + if (curr_weapon->weapon_idx == kGUN_SLOT1 || + curr_weapon->weapon_idx == kGUN_SLOT2) { speed = ability.shot_speed; } } - speed = (speed + buff_attr_abs_[HAT_Speed]) * (1 + buff_attr_rate_[HAT_Speed]); + speed = (speed + buff_attr_abs_[kHAT_Speed]) * (1 + buff_attr_rate_[kHAT_Speed]); return std::max(speed, 1.0f); } @@ -184,13 +184,13 @@ void Human::Shot() CancelAction(); } - if (HasBuffEffect(BET_Hide)) { - RemoveBuffByEffectId(BET_Hide); + if (HasBuffEffect(kBET_Hide)) { + RemoveBuffByEffectId(kBET_Hide); } DirectShot(curr_weapon->meta, 0); if (curr_weapon->meta->NeedTrace()) { - room->xtimer.AddDeadLineTimerAndAttach(curr_weapon->meta->i->time() * SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(curr_weapon->meta->i->time() * kSERVER_FRAME_RATE, a8::XParams() .SetSender(this) .SetParam1(curr_weapon->meta->i->id()) @@ -211,7 +211,7 @@ void Human::DirectShot(MetaData::Equip* bullet_meta, int skill_id) { for (size_t i = 0; i < bullet_meta->bullet_born_offset.size(); ++i) { auto& tuple = bullet_meta->bullet_born_offset[i]; - room->xtimer.AddDeadLineTimerAndAttach(std::get<0>(tuple) / FRAME_RATE_MS, + room->xtimer.AddDeadLineTimerAndAttach(std::get<0>(tuple) / kFRAME_RATE_MS, a8::XParams() .SetSender(this) .SetParam1(bullet_meta) @@ -381,7 +381,7 @@ void Human::UpdateSkill() if (skill_meta_) { if (curr_skill_phase < skill_meta_->phases.size()) { MetaData::SkillPhase* phase = &skill_meta_->phases[curr_skill_phase]; - if (phase->time_offset >= (int)((room->frame_no - last_use_skill_frameno_) * FRAME_RATE_MS)) { + if (phase->time_offset >= (int)((room->frame_no - last_use_skill_frameno_) * kFRAME_RATE_MS)) { ProcSkillPhase(phase); ++curr_skill_phase; } @@ -463,7 +463,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) stats.weapon_id = weapon_id; dead = true; dead_frameno = room->frame_no; - room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->revive_time * SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->revive_time * kSERVER_FRAME_RATE, a8::XParams() .SetSender(this), [] (const a8::XParams& param) @@ -554,8 +554,8 @@ bool Human::CanUseSkill() return false; } if (a8::HasBitFlag(status, HS_Assaulting) || - HasBuffEffect(BET_Vertigo) || - HasBuffEffect(BET_Dcgr) + HasBuffEffect(kBET_Vertigo) || + HasBuffEffect(kBET_Dcgr) ) { return false; } @@ -723,7 +723,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data) if (action_type != kAT_None) { int duration = std::max(0, action_duration - - (int)((room->frame_no - action_frameno) * 1.0f / SERVER_FRAME_RATE) * 1000 + (int)((room->frame_no - action_frameno) * 1.0f / kSERVER_FRAME_RATE) * 1000 ); player_data->set_action_item_id(action_item_id); player_data->set_action_duration(duration); @@ -754,7 +754,7 @@ void Human::FillMFGasData(cs::MFGasData* gas_data) { gas_data->set_mode(room->gas_data.gas_mode); if (room->gas_data.gas_mode == kGasInactive) { - long long duration = MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE - + long long duration = MetaMgr::Instance()->gas_inactive_time * kSERVER_FRAME_RATE - (room->frame_no - room->gas_data.gas_start_frameno); gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000); } else { @@ -967,7 +967,7 @@ void Human::UpdateAction() { int duration = std::max(0, action_duration - - (int)((room->frame_no - action_frameno) * 1.0f / SERVER_FRAME_RATE) * 1000 + (int)((room->frame_no - action_frameno) * 1.0f / kSERVER_FRAME_RATE) * 1000 ); if (duration <= 0) { switch (action_type) { @@ -997,15 +997,15 @@ void Human::DirectReload() { int ammo = curr_weapon->ammo; if (ammo < curr_weapon->GetClipVolume()) { - if (GetInventory(WEAPON_SLOT) > 0) { + if (GetInventory(kWEAPON_SLOT) > 0) { int add_num = 0; - if (GetInventory(WEAPON_SLOT) <= + if (GetInventory(kWEAPON_SLOT) <= curr_weapon->GetClipVolume() - ammo) { - add_num = GetInventory(WEAPON_SLOT); - DecInventory(WEAPON_SLOT, add_num); + add_num = GetInventory(kWEAPON_SLOT); + DecInventory(kWEAPON_SLOT, add_num); } else { add_num = curr_weapon->GetClipVolume() - ammo; - DecInventory(WEAPON_SLOT, add_num); + DecInventory(kWEAPON_SLOT, add_num); } curr_weapon->ammo += add_num; need_sync_active_player = true;; @@ -1071,7 +1071,7 @@ int Human::GetSkillLeftTime() if (last_use_skill_frameno_ == 0) { return 0; } else { - int passed_time = (room->frame_no - last_use_skill_frameno_) * FRAME_RATE_MS; + int passed_time = (room->frame_no - last_use_skill_frameno_) * kFRAME_RATE_MS; int skill_left_time = std::max(0, skill_meta_->i->skill_cd() * 1000 - passed_time); return skill_left_time; } @@ -1150,7 +1150,7 @@ void Human::AddBuff(MetaData::Buff* buff_meta) room->frame_event.AddBuff(this, buff); { room->xtimer.AddDeadLineTimerAndAttach( - buff_meta->i->duration_time() * SERVER_FRAME_RATE, + buff_meta->i->duration_time() * kSERVER_FRAME_RATE, a8::XParams() .SetSender(this) .SetParam1(buff_meta->i->buff_id()), @@ -1198,7 +1198,7 @@ void Human::RecalcBuffAttr() buff_attr_abs_ = {}; buff_attr_rate_ = {}; for (auto& buff : buff_list_) { - if (buff.meta->i->buff_effect() == BET_ChgAttr) { + if (buff.meta->i->buff_effect() == kBET_ChgAttr) { int attr_type = (int)buff.meta->param1; int calc_type = (int)buff.meta->param2; if (IsValidHumanAttr(attr_type)) { @@ -1215,15 +1215,15 @@ void Human::RecalcBuffAttr() void Human::ProcBuffEffect(Buff* buff) { switch (buff->meta->i->buff_effect()) { - case BET_ChgAttr: + case kBET_ChgAttr: { RecalcBuffAttr(); } break; - case BET_LastBurn: + case kBET_LastBurn: { room->xtimer.AddRepeatTimerAndAttach( - SERVER_FRAME_RATE, + kSERVER_FRAME_RATE, a8::XParams() .SetSender(this) .SetParam1(buff), @@ -1232,10 +1232,10 @@ void Human::ProcBuffEffect(Buff* buff) ); } break; - case BET_ReleaseDcgr: + case kBET_ReleaseDcgr: { room->xtimer.AddRepeatTimerAndAttach( - (buff->meta->param1 / 1000) * FRAME_RATE_MS, + (buff->meta->param1 / 1000) * kFRAME_RATE_MS, a8::XParams() .SetSender(this) .SetParam1(buff), @@ -1244,10 +1244,10 @@ void Human::ProcBuffEffect(Buff* buff) ); } break; - case BET_ReleaseFireBomb: + case kBET_ReleaseFireBomb: { room->xtimer.AddRepeatTimerAndAttach( - (buff->meta->param1 / 1000) * FRAME_RATE_MS, + (buff->meta->param1 / 1000) * kFRAME_RATE_MS, a8::XParams() .SetSender(this) .SetParam1(buff), @@ -1256,7 +1256,7 @@ void Human::ProcBuffEffect(Buff* buff) ); } break; - case BET_Assault: + case kBET_Assault: { a8::SetBitFlag(status, HS_Assaulting); Entity* entity = room->GetEntityByUniId(skill_target_id); @@ -1281,8 +1281,8 @@ void Human::OnAttack() void Human::OnHit() { - if (HasBuffEffect(BET_Hide)) { - RemoveBuffByEffectId(BET_Hide); + if (HasBuffEffect(kBET_Hide)) { + RemoveBuffByEffectId(kBET_Hide); } GrassTempShow(); } @@ -1312,7 +1312,7 @@ void Human::OnEnterGrass() } }; grass_hide_timer_list_ = - room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->grass_invisible_time * SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->grass_invisible_time * kSERVER_FRAME_RATE, a8::XParams() .SetSender(this), hide_func, @@ -1330,7 +1330,7 @@ void Human::OnLeaveGrass() room->xtimer.DeleteTimer(leave_grass_timer_list_); } leave_grass_timer_list_ = - room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->grass_show_time * SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->grass_show_time * kSERVER_FRAME_RATE, a8::XParams() .SetSender(this), [] (const a8::XParams& param) @@ -1378,12 +1378,12 @@ void Human::CheckGrass() void Human::GrassTempShow() { if (a8::HasBitFlag(status, HS_InGrass)) { - if (HasBuffEffect(BET_InGrass)) { - RemoveBuffByEffectId(BET_InGrass); + if (HasBuffEffect(kBET_InGrass)) { + RemoveBuffByEffectId(kBET_InGrass); } if (grass_hide_timer_list_) { room->xtimer.ModifyTimer(grass_hide_timer_list_, - MetaMgr::Instance()->grass_invisible_time2 * SERVER_FRAME_RATE); + MetaMgr::Instance()->grass_invisible_time2 * kSERVER_FRAME_RATE); } else { auto hide_func = [] (const a8::XParams& param) @@ -1396,7 +1396,7 @@ void Human::GrassTempShow() } }; grass_hide_timer_list_ = - room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->grass_invisible_time2 * SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(MetaMgr::Instance()->grass_invisible_time2 * kSERVER_FRAME_RATE, a8::XParams() .SetSender(this), hide_func, @@ -1408,22 +1408,22 @@ void Human::GrassTempShow() float* Human::GetAbilityById(int attr_id) { switch (attr_id) { - case HAT_Hp: + case kHAT_Hp: return &ability.hp; break; - case HAT_HPRecover: + case kHAT_HPRecover: return &ability.hp_recover; break; - case HAT_Atk: + case kHAT_Atk: return &ability.atk; break; - case HAT_Def: + case kHAT_Def: return &ability.def; break; - case HAT_Speed: + case kHAT_Speed: return &ability.speed; break; - case HAT_ShotRange: + case kHAT_ShotRange: return &ability.shot_range; break; case HAT_ShotSpeed: @@ -1491,8 +1491,8 @@ void Human::_UpdateMove(int speed) void Human::_UpdateAssaultMove() { - Buff* buff = GetBuffByEffectId(BET_Assault); - if (!buff || (room->frame_no - buff->add_frameno) * FRAME_RATE_MS < buff->meta->param1) { + Buff* buff = GetBuffByEffectId(kBET_Assault); + if (!buff || (room->frame_no - buff->add_frameno) * kFRAME_RATE_MS < buff->meta->param1) { return; } bool move_end = false; @@ -1519,7 +1519,7 @@ void Human::_UpdateAssaultMove() for (auto& cell : grid_list) { for (Human* hum : cell->human_list) { if (hum->team_id != team_id && hum->pos.Distance(skill_target_pos) < hum->GetRadius()) { - if (!hum->HasBuffEffect(BET_Invincible)) { + if (!hum->HasBuffEffect(kBET_Invincible)) { float power = phase->param1.GetDouble() + ability.atk; float def = hum->ability.def; float finally_dmg = power * (1 - def/MetaMgr::Instance()->K); @@ -1809,17 +1809,17 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase) }; switch (phase->func_id) { - case Skill_Jump: + case kSkill_Jump: { } break; - case Skill_Shot: + case kSkill_Shot: { MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt()); if (bullet_meta) { DirectShot(bullet_meta, skill_meta_->i->skill_id()); if (bullet_meta->NeedTrace()) { - room->xtimer.AddDeadLineTimerAndAttach(bullet_meta->i->time() * SERVER_FRAME_RATE, + room->xtimer.AddDeadLineTimerAndAttach(bullet_meta->i->time() * kSERVER_FRAME_RATE, a8::XParams() .SetSender(this) .SetParam1(phase->param1.GetInt()) @@ -1831,7 +1831,7 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase) } } break; - case Skill_SummonObject: + case kSkill_SummonObject: { Obstacle* obstacle = room->CreateObstacle(phase->param1.GetInt(), pos.x, pos.y); if (obstacle) { @@ -1841,7 +1841,7 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase) .SetSender(obstacle), frame_check_func, &obstacle->xtimer_attacher.timer_list_); - room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 5, + room->xtimer.AddDeadLineTimerAndAttach(kSERVER_FRAME_RATE * 5, a8::XParams() .SetSender(obstacle), explosion_check_func, @@ -1908,7 +1908,7 @@ void Human::InternalShot(MetaData::Equip* bullet_meta, int skill_id, size_t offs fly_distance, hit_time, 0, skill_id); } if (room->BattleStarted()) { - if (bullet_meta->i->equip_subtype() != BulletType_Missile) { + if (bullet_meta->i->equip_subtype() != kBulletType_Missile) { room->CreateBullet(this, bullet_meta, bullet_born_pos, bullet_dir, fly_distance, skill_id); } } diff --git a/server/gameserver/human.h b/server/gameserver/human.h index aac3dd5..d0e5f24 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -247,10 +247,10 @@ private: CircleCollider* self_collider_ = nullptr; long long last_sync_gas_frameno_ = 0; std::list buff_list_; - std::array buff_effect_ = {}; + std::array buff_effect_ = {}; - std::array buff_attr_abs_ = {}; - std::array buff_attr_rate_ = {}; + std::array buff_attr_abs_ = {}; + std::array buff_attr_rate_ = {}; bool already_report_battle_ = false; bool sent_game_end_ = false; diff --git a/server/gameserver/mapservice.cc b/server/gameserver/mapservice.cc index d1a1fc8..aeabac5 100644 --- a/server/gameserver/mapservice.cc +++ b/server/gameserver/mapservice.cc @@ -176,7 +176,7 @@ void MapService::GetColliders(float world_x, float world_y, std::setcollider->tag != ColliderTag_Grass) { + if (node->collider->tag != kColliderTag_Grass) { colliders.insert(node->collider); } } @@ -199,7 +199,7 @@ void MapService::GetGrassColliders(float world_x, float world_y, std::setcollider->tag == ColliderTag_Grass) { + if (node->collider->tag == kColliderTag_Grass) { colliders.insert(node->collider); } } diff --git a/server/gameserver/metadata.cc b/server/gameserver/metadata.cc index 7793dce..42c030b 100644 --- a/server/gameserver/metadata.cc +++ b/server/gameserver/metadata.cc @@ -42,14 +42,14 @@ namespace MetaData bool Equip::CanDrop() { - return i->equip_type() == EquipType_Bullet && MetaMgr::Instance()->fighting_mode; + return i->equip_type() == kEquipType_Bullet && MetaMgr::Instance()->fighting_mode; } bool Equip::NeedTrace() { - return i->equip_type() == EquipType_Bullet && - (i->equip_subtype() == BulletType_Missile || - i->equip_subtype() == BulletType_Trace); + return i->equip_type() == kEquipType_Bullet && + (i->equip_subtype() == kBulletType_Missile || + i->equip_subtype() == kBulletType_Trace); } void Player::Init() @@ -309,7 +309,7 @@ namespace MetaData auto field_desc = descriptor->FindFieldByName(a8::Format("phase%d_param2", {idx})); phase.param2_str = reflection->GetString(*(metatable::Skill*)i, field_desc); } - if (phase.func_id != Skill_FuncNone) { + if (phase.func_id != kSkill_FuncNone) { phase.param1 = a8::XValue(phase.param1_str); phase.param2 = a8::XValue(phase.param2_str); phases.push_back(phase); @@ -342,7 +342,7 @@ namespace MetaData bool Buff::EffectCanStack() { - return i->buff_effect() == BET_ChgAttr; + return i->buff_effect() == kBET_ChgAttr; } void Driver::Init() diff --git a/server/gameserver/metadata.h b/server/gameserver/metadata.h index 305fd13..e79b319 100755 --- a/server/gameserver/metadata.h +++ b/server/gameserver/metadata.h @@ -136,7 +136,7 @@ namespace MetaData { int phase_idx = 0; int time_offset = 0; - SkillFunc_e func_id = Skill_FuncNone; + SkillFunc_e func_id = kSkill_FuncNone; a8::XValue param1; a8::XValue param2; diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 141a513..5f70835 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -178,13 +178,13 @@ private: thing.Init(); } } - if (map_width < MAP_GRID_WIDTH || map_height < MAP_GRID_WIDTH) { + if (map_width < kMAP_GRID_WIDTH || map_height < kMAP_GRID_WIDTH) { abort(); } maptpl_hash[pair.first] = things; born_point_hash[pair.first] = born_point; maptpl_size_hash[pair.first] = std::make_tuple(map_width, map_height); - if (born_point.size() != ROOM_MAX_PLAYER_NUM) { + if (born_point.size() != kROOM_MAX_PLAYER_NUM) { abort(); } } diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index cfd3183..e8d1447 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -211,7 +211,7 @@ void Obstacle::Explosion() float def = hum->ability.def; float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K); hum->OnHit(); - if (!hum->HasBuffEffect(BET_Invincible)) { + if (!hum->HasBuffEffect(kBET_Invincible)) { hum->DecHP(finaly_dmg, kVP_Mine, "地雷", kVW_Mine); } } diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 1d25a61..e3f3bc7 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -36,13 +36,13 @@ void Player::Initialize() skill_lv_ = TankLv(); MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(tank_meta_->i->bullet_id()); if (weapon_meta) { - weapons[GUN_SLOT1].weapon_idx = GUN_SLOT1; - weapons[GUN_SLOT1].weapon_id = weapon_meta->i->id(); - weapons[GUN_SLOT1].weapon_lv = 1; - weapons[GUN_SLOT1].ammo = 0; - weapons[GUN_SLOT1].meta = weapon_meta; - weapons[GUN_SLOT1].Recalc(); - curr_weapon = &weapons[GUN_SLOT1]; + weapons[kGUN_SLOT1].weapon_idx = kGUN_SLOT1; + weapons[kGUN_SLOT1].weapon_id = weapon_meta->i->id(); + weapons[kGUN_SLOT1].weapon_lv = 1; + weapons[kGUN_SLOT1].ammo = 0; + weapons[kGUN_SLOT1].meta = weapon_meta; + weapons[kGUN_SLOT1].Recalc(); + curr_weapon = &weapons[kGUN_SLOT1]; DirectReload(); } } @@ -105,7 +105,7 @@ void Player::Update(int delta_time) void Player::UpdateMove() { - if (dead || HasBuffEffect(BET_Vertigo) || HasBuffEffect(BET_Dcgr)) { + if (dead || HasBuffEffect(kBET_Vertigo) || HasBuffEffect(kBET_Dcgr)) { moving = false; moved_frames = 0; last_collision_door = nullptr; @@ -125,7 +125,7 @@ void Player::UpdateMove() void Player::UpdateShot() { - if (dead || HasBuffEffect(BET_Vertigo) || HasBuffEffect(BET_Dcgr)) { + if (dead || HasBuffEffect(kBET_Vertigo) || HasBuffEffect(kBET_Dcgr)) { shot_start = false; shot_hold = false; series_shot_frames = 0; @@ -142,7 +142,7 @@ void Player::UpdateShot() ++series_shot_frames; if (last_shot_frameno_ == 0 || ( - (room->frame_no - last_shot_frameno_) * (1000 / SERVER_FRAME_RATE)) >= + (room->frame_no - last_shot_frameno_) * (1000 / kSERVER_FRAME_RATE)) >= curr_weapon->meta->i->fire_rate() ) { Shot(); @@ -418,50 +418,50 @@ void Player::UpdateDropWeapon() drop_ok = true; *weapon = default_weapon; } - } else if (weapon->weapon_idx == GUN_SLOT1) { + } else if (weapon->weapon_idx == kGUN_SLOT1) { drop_ok = true; *weapon = Weapon(); weapon->weapon_idx = drop_weapon_idx; if (curr_weapon == weapon) { - if (weapons[GUN_SLOT2].weapon_id != 0) { - curr_weapon = &weapons[GUN_SLOT2]; + if (weapons[kGUN_SLOT2].weapon_id != 0) { + curr_weapon = &weapons[kGUN_SLOT2]; } else { curr_weapon = &weapons[0]; } } - } else if (weapon->weapon_idx == GUN_SLOT2) { + } else if (weapon->weapon_idx == kGUN_SLOT2) { drop_ok = true; *weapon = Weapon(); weapon->weapon_idx = drop_weapon_idx; if (curr_weapon == weapon) { - if (weapons[GUN_SLOT1].weapon_id != 0) { - curr_weapon = &weapons[GUN_SLOT1]; + if (weapons[kGUN_SLOT1].weapon_id != 0) { + curr_weapon = &weapons[kGUN_SLOT1]; } else { curr_weapon = &weapons[0]; } } - } else if (weapon->weapon_idx == FRAG_SLOT) { + } else if (weapon->weapon_idx == kFRAG_SLOT) { drop_ok = true; *weapon = Weapon(); weapon->weapon_idx = drop_weapon_idx; if (curr_weapon == weapon) { - if (weapons[GUN_SLOT1].weapon_id != 0) { - curr_weapon = &weapons[GUN_SLOT1]; - } else if (weapons[GUN_SLOT2].weapon_id != 0) { - curr_weapon = &weapons[GUN_SLOT2]; + if (weapons[kGUN_SLOT1].weapon_id != 0) { + curr_weapon = &weapons[kGUN_SLOT1]; + } else if (weapons[kGUN_SLOT2].weapon_id != 0) { + curr_weapon = &weapons[kGUN_SLOT2]; } else { curr_weapon = &weapons[0]; } } - } else if (weapon->weapon_idx == SMOKE_SLOT) { + } else if (weapon->weapon_idx == kSMOKE_SLOT) { drop_ok = true; *weapon = Weapon(); weapon->weapon_idx = drop_weapon_idx; if (curr_weapon == weapon) { - if (weapons[GUN_SLOT1].weapon_id != 0) { - curr_weapon = &weapons[GUN_SLOT1]; - } else if (weapons[GUN_SLOT2].weapon_id != 0) { - curr_weapon = &weapons[GUN_SLOT2]; + if (weapons[kGUN_SLOT1].weapon_id != 0) { + curr_weapon = &weapons[kGUN_SLOT1]; + } else if (weapons[kGUN_SLOT2].weapon_id != 0) { + curr_weapon = &weapons[kGUN_SLOT2]; } else { curr_weapon = &weapons[0]; } @@ -469,8 +469,8 @@ void Player::UpdateDropWeapon() } if (drop_ok) { if (drop_weapon_idx == 0 || - drop_weapon_idx == GUN_SLOT1 || - drop_weapon_idx == GUN_SLOT2 + drop_weapon_idx == kGUN_SLOT1 || + drop_weapon_idx == kGUN_SLOT2 ) { a8::Vec2 dir = a8::Vec2::UP; dir.Rotate(a8::RandAngle()); diff --git a/server/gameserver/playermgr.cc b/server/gameserver/playermgr.cc index 37c2f62..f719e8a 100644 --- a/server/gameserver/playermgr.cc +++ b/server/gameserver/playermgr.cc @@ -66,17 +66,17 @@ Player* PlayerMgr::CreatePlayerByCMJoin(long ip_saddr, int socket, const cs::CMJ if (msg.weapon().weapon_id() != 0) { MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(msg.weapon().weapon_id()); if (weapon_meta) { - hum->weapons[GUN_SLOT0].weapon_idx = GUN_SLOT0; - hum->weapons[GUN_SLOT0].weapon_id = msg.weapon().weapon_id(); - hum->weapons[GUN_SLOT0].weapon_lv = msg.weapon().weapon_lv(); - hum->weapons[GUN_SLOT0].meta = weapon_meta; + hum->weapons[kGUN_SLOT0].weapon_idx = kGUN_SLOT0; + hum->weapons[kGUN_SLOT0].weapon_id = msg.weapon().weapon_id(); + hum->weapons[kGUN_SLOT0].weapon_lv = msg.weapon().weapon_lv(); + hum->weapons[kGUN_SLOT0].meta = weapon_meta; #if 1 - hum->weapons[GUN_SLOT0].ammo = hum->weapons[GUN_SLOT0].GetClipVolume(); + hum->weapons[kGUN_SLOT0].ammo = hum->weapons[kGUN_SLOT0].GetClipVolume(); #else - hum->weapons[GUN_SLOT0].ammo = FIGHTING_MODE_BULLET_NUM; + hum->weapons[kGUN_SLOT0].ammo = kFIGHTING_MODE_BULLET_NUM; #endif - hum->weapons[GUN_SLOT0].Recalc(); - hum->curr_weapon = &hum->weapons[GUN_SLOT0]; + hum->weapons[kGUN_SLOT0].Recalc(); + hum->curr_weapon = &hum->weapons[kGUN_SLOT0]; } } hum->SetTankInfo(msg.baseskin()); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 71b68df..80d57cc 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -39,12 +39,12 @@ void Room::Init() xtimer.Init(RoomXGetTickCount, this, 100, 100); xtimer_attacher.xtimer = &xtimer; frame_event.room = this; - grid_service.Init(map_width, map_height, MAP_CELL_WIDTH * 8); - map_service.Init(map_width / MAP_GRID_WIDTH, map_height / MAP_GRID_WIDTH, MAP_GRID_WIDTH); + grid_service.Init(map_width, map_height, kMAP_CELL_WIDTH * 8); + map_service.Init(map_width / kMAP_GRID_WIDTH, map_height / kMAP_GRID_WIDTH, kMAP_GRID_WIDTH); CreateThings(); if (App::Instance()->HasFlag(1)) { - xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3, + xtimer.AddDeadLineTimerAndAttach(kSERVER_FRAME_RATE * 3, a8::XParams() .SetSender(this), [] (const a8::XParams& param) @@ -55,7 +55,7 @@ void Room::Init() &xtimer_attacher.timer_list_); } born_points_ = MetaMgr::Instance()->GetMapBornPoints(map_tpl_name); - if (!born_points_ || born_points_->size() != ROOM_MAX_PLAYER_NUM) { + if (!born_points_ || born_points_->size() != kROOM_MAX_PLAYER_NUM) { abort(); } ShuaAndroid(); @@ -90,7 +90,7 @@ void Room::UnInit() void Room::Update(int delta_time) { xtimer.Update(); - if (game_over && frame_no - game_over_frameno > SERVER_FRAME_RATE * 20) { + if (game_over && frame_no - game_over_frameno > kSERVER_FRAME_RATE * 20) { return; } @@ -159,7 +159,7 @@ int Room::AliveCount() void Room::AddPlayer(Player* hum) { assert(gas_data.gas_mode == kGasInactive); - while (human_hash_.size() + 1 > ROOM_MAX_PLAYER_NUM) { + while (human_hash_.size() + 1 > kROOM_MAX_PLAYER_NUM) { RandRemoveAndroid(); } hum->entity_uniid = AllocUniid(); @@ -217,7 +217,7 @@ void Room::ShuaAndroid() int refresh_time = a8::RandEx(refresh_min_time, refresh_max_time); if (robot_num > 0 && refresh_time > 0) { CreateAndroid(robot_num); - xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * refresh_time, + xtimer.AddDeadLineTimerAndAttach(kSERVER_FRAME_RATE * refresh_time, a8::XParams() .SetSender(this), [] (const a8::XParams& param) @@ -242,7 +242,7 @@ void Room::CreateAndroid(int robot_num) abort(); } for (int i = 0; i < robot_num; ++i) { - if (human_hash_.size() >= ROOM_MAX_PLAYER_NUM) { + if (human_hash_.size() >= kROOM_MAX_PLAYER_NUM) { return; } @@ -422,7 +422,7 @@ void Room::CreateBuilding(int thing_id, float building_x, float building_y) MetaData::Building::Door* door_meta = &building->meta->doors[door_idx]; float x = building->pos.x + door_meta->state0->x() - building->meta->i->tilewidth() / 2.0; float y = building->pos.y + door_meta->state0->y() - building->meta->i->tileheight() / 2.0; - InternalCreateObstacle(DOOR_THING_ID, x, y, + InternalCreateObstacle(kDOOR_THING_ID, x, y, [building, door_meta] (Obstacle* entity) { entity->building = building; @@ -730,7 +730,7 @@ bool Room::CanJoin(const std::string& accountid) if (App::Instance()->HasFlag(5)) { return accountid_hash_.size() < 1; } else { - return accountid_hash_.size() < ROOM_MAX_PLAYER_NUM; + return accountid_hash_.size() < kROOM_MAX_PLAYER_NUM; } } @@ -815,17 +815,17 @@ void Room::UpdateGas() case kGasInactive: { if (frame_no - gas_data.gas_start_frameno >= - MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) { + MetaMgr::Instance()->gas_inactive_time * kSERVER_FRAME_RATE) { gas_data.gas_mode = kGasStarted; gas_data.gas_start_frameno = frame_no; - if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) { - CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size()); + if (human_hash_.size() < kROOM_MAX_PLAYER_NUM) { + CreateAndroid(kROOM_MAX_PLAYER_NUM - human_hash_.size()); NotifyUiUpdate(); } NotifyWxVoip(); RoomMgr::Instance()->ActiveRoom(room_uuid); battle_start_frameno_ = frame_no; - battle_report_timer_ = xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * MetaMgr::Instance()->game_duration, + battle_report_timer_ = xtimer.AddDeadLineTimerAndAttach(kSERVER_FRAME_RATE * MetaMgr::Instance()->game_duration, a8::XParams() .SetSender(this), [] (const a8::XParams& param) @@ -898,7 +898,7 @@ void Room::MatchTeam(Human* hum) pair.second->team_members = &team_hash_[pair.second->team_id]; pair.second->team_members->insert(pair.second); } - if (pair.second->team_members->size() < MAX_TEAM_NUM) { + if (pair.second->team_members->size() < kMAX_TEAM_NUM) { pair.second->team_members->insert(hum); hum->team_id = pair.second->team_id; hum->team_members = pair.second->team_members; @@ -1068,7 +1068,7 @@ void Room::BattleReport() int Room::AllocBornPoint() { std::set points; - for (int i = 0; i < ROOM_MAX_PLAYER_NUM; ++i) { + for (int i = 0; i < kROOM_MAX_PLAYER_NUM; ++i) { points.insert(i); } for (auto& pair : born_point_human_hash_) {