diff --git a/server/gameserver/battledatacontext.cc b/server/gameserver/battledatacontext.cc index a9c11886..ed54da1c 100644 --- a/server/gameserver/battledatacontext.cc +++ b/server/gameserver/battledatacontext.cc @@ -13,6 +13,7 @@ #include "room.h" #include "explosion.h" #include "roommgr.h" +#include "config.h" #include "attrhelper.h" @@ -325,7 +326,7 @@ private: BattleDataContext::BattleDataContext() { hero_ability_ = std::make_shared(); - hero_ability_->hero_meta = MetaMgr::Instance()->human_meta; + hero_ability_->hero_meta = Config::Instance()->human_meta; } void BattleDataContext::Clear() diff --git a/server/gameserver/buff.cc b/server/gameserver/buff.cc index a3727062..48aba78a 100644 --- a/server/gameserver/buff.cc +++ b/server/gameserver/buff.cc @@ -16,6 +16,7 @@ #include "trigger.h" #include "virtualbullet.h" #include "bullet.h" +#include "config.h" Buff::Buff() { @@ -817,15 +818,15 @@ void Buff::ProcDive() } Human* hum = owner->AsHuman(); if (hum->GetOxygen() > 0) { - hum->DecOxygen(MetaMgr::Instance()->dive_oxygen_consume); + hum->DecOxygen(Config::Instance()->dive_oxygen_consume); hum->room->frame_event.AddPropChg(hum->GetWeakPtrRef(), kPropDive, - MetaMgr::Instance()->dive_oxygen_total, + Config::Instance()->dive_oxygen_total, hum->GetOxygen(), true); return; } - hum->DecHP(MetaMgr::Instance()->dive_hp_consume, + hum->DecHP(Config::Instance()->dive_hp_consume, VP_Water, "water", 0, @@ -855,7 +856,7 @@ void Buff::ProcInWater() owner->AsHuman()->room->frame_event.AddPropChg (owner->AsHuman()->GetWeakPtrRef(), kPropDive, - MetaMgr::Instance()->dive_oxygen_total, + Config::Instance()->dive_oxygen_total, owner->AsHuman()->GetOxygen(), true); @@ -871,13 +872,14 @@ void Buff::ProcInWater() } Human* hum = owner->AsHuman(); if (!hum->HasBuffEffect(kBET_Dive) && - hum->GetOxygen() < MetaMgr::Instance()->dive_oxygen_total) { - hum->AddOxygen(MetaMgr::Instance()->inwater_oxygen_recover); - hum->room->frame_event.AddPropChg(hum->GetWeakPtrRef(), - kPropDive, - MetaMgr::Instance()->dive_oxygen_total, - hum->GetOxygen(), - true); + hum->GetOxygen() < Config::Instance()->dive_oxygen_total) { + hum->AddOxygen(Config::Instance()->inwater_oxygen_recover); + hum->room->frame_event.AddPropChg + (hum->GetWeakPtrRef(), + kPropDive, + Config::Instance()->dive_oxygen_total, + hum->GetOxygen(), + true); return; } } @@ -902,11 +904,11 @@ void Buff::ProcRemoveInWater() hum->room->xtimer.DeleteCurrentTimer(); return; } - if (hum->GetOxygen() >= MetaMgr::Instance()->dive_oxygen_total) { + if (hum->GetOxygen() >= Config::Instance()->dive_oxygen_total) { hum->room->xtimer.DeleteCurrentTimer(); return; } - hum->AddOxygen(MetaMgr::Instance()->inwater_oxygen_recover); + hum->AddOxygen(Config::Instance()->inwater_oxygen_recover); }, &hum->xtimer_attacher ); diff --git a/server/gameserver/bullet.cc b/server/gameserver/bullet.cc index eb0e5bd5..5268bf29 100644 --- a/server/gameserver/bullet.cc +++ b/server/gameserver/bullet.cc @@ -18,6 +18,7 @@ #include "car.h" #include "creature.h" #include "skillhelper.h" +#include "config.h" Bullet::Bullet():MoveableEntity() { @@ -342,7 +343,7 @@ void Bullet::ProcSmokeBomb() &task->xtimer_attacher); room->xtimer.SetTimeoutEx - (SERVER_FRAME_RATE * MetaMgr::Instance()->GetSysParamAsInt("smoke_duration", 10), + (SERVER_FRAME_RATE * Config::Instance()->GetSysParamAsInt("smoke_duration", 10), [task] (int event, const a8::Args* args) { if (a8::TIMER_DELETE_EVENT == event) { @@ -378,7 +379,7 @@ void Bullet::MapServiceUpdate() if (sender.Get()) { float move_length = gun_meta->pb->bullet_speed() / (float)SERVER_FRAME_RATE; do { - float step_len = move_length - MetaMgr::Instance()->bullet_planck_step_length; + float step_len = move_length - Config::Instance()->bullet_planck_step_length; if (step_len <= 0.001f) { if (move_length > 0.1f) { step_len = move_length; diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 0f430c03..d1d6cf97 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -16,6 +16,7 @@ #include "skillhelper.h" #include "shot.h" #include "movehelper.h" +#include "config.h" #include "f8/utils.h" @@ -795,7 +796,7 @@ bool Creature::CanUseSkill(int skill_id) return false; } if (room->GetGasData().GetGasMode() == GasInactive && - !MetaMgr::Instance()->prebattle_can_use_skill) { + !Config::Instance()->prebattle_can_use_skill) { return false; } if (HasBuffEffect(kBET_Vertigo) || diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 7a56c953..564e9408 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -39,6 +39,7 @@ #include "battledatacontext.h" #include "mapinstance.h" #include "movehelper.h" +#include "config.h" const int kReviveTimeAdd = 12; const int kSkinNum = 4; @@ -370,7 +371,7 @@ Human::Human():Creature() } weapons[0] = default_weapon; - if (MetaMgr::Instance()->fighting_mode) { + if (Config::Instance()->fighting_mode) { AddInventory(IS_9MM, FIGHTING_MODE_BULLET_NUM); AddInventory(IS_556MM, FIGHTING_MODE_BULLET_NUM); AddInventory(IS_762MM, FIGHTING_MODE_BULLET_NUM); @@ -392,7 +393,7 @@ void Human::Initialize() volume_ = meta->volume; observers_.insert(this); SetCurrWeapon(&weapons[0]); - SetOxygen(MetaMgr::Instance()->dive_oxygen_total); + SetOxygen(Config::Instance()->dive_oxygen_total); } float Human::GetSpeed() @@ -456,7 +457,7 @@ float Human::GetSpeed() (1 + GetAbility()->GetAttrRate(kHAT_Speed)); #endif if (a8::HasBitFlag(cell_flags_, kColliderTag_Water)) { - speed *= MetaMgr::Instance()->water_move_coefficient; + speed *= Config::Instance()->water_move_coefficient; } return std::max(speed, 1.0f); } @@ -1202,7 +1203,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i SyncAroundPlayers(__FILE__, __LINE__, __func__); } else { if (HasNoDownedTeammate() && !room->IsPveRoom()) { - SetHP(MetaMgr::Instance()->GetSysParamAsInt("downed_recover_hp")); + SetHP(Config::Instance()->GetSysParamAsInt("downed_recover_hp")); downed = true; if (HasBuffEffect(kBET_Camouflage)) { RemoveBuffByEffectId(kBET_Camouflage); @@ -1235,7 +1236,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i info->real_killer_id, info->real_killer_name); return; } - int dec_hp = MetaMgr::Instance()->GetSysParamAsInt("downed_dec_hp"); + int dec_hp = Config::Instance()->GetSysParamAsInt("downed_dec_hp"); DecHP(dec_hp, info->killer_id, info->killer_name, info->weapon_id, info->real_killer_id, info->real_killer_name); } @@ -1426,7 +1427,7 @@ void Human::DoGetOn(int obj_uniid) if (!entity) { return; } - if (GetPos().Distance2D2(entity->GetPos()) > MetaMgr::Instance()->max_mount_horse_distance) { + if (GetPos().Distance2D2(entity->GetPos()) > Config::Instance()->max_mount_horse_distance) { return; } if (downed) { @@ -1651,7 +1652,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data) player_data->set_cur_weapon_idx(GetCurrWeapon()->weapon_idx); player_data->set_cur_scope(curr_scope_idx); if (HasBuffEffect(kBET_InWater)) { - player_data->set_dive_oxygen_max(MetaMgr::Instance()->dive_oxygen_total); + player_data->set_dive_oxygen_max(Config::Instance()->dive_oxygen_total); player_data->set_dive_oxygen_curr(oxygen_); } for (auto& weapon : weapons) { @@ -1767,7 +1768,7 @@ void Human::FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState if (!pain_killer_timer.expired()) { int passed_time = (room->GetFrameNo() - pain_killer_frameno) * FRAME_RATE_MS; int left_time = std::max(0, pain_killer_lastingtime * 1000 - passed_time); - int anodyne_max_time = MetaMgr::Instance()->GetSysParamAsInt("anodyne_max_time"); + int anodyne_max_time = Config::Instance()->GetSysParamAsInt("anodyne_max_time"); left_time = std::min(left_time, anodyne_max_time * 1000); cs::MFBodyState* state = states->Add(); @@ -2298,8 +2299,8 @@ void Human::GenBattleReportData(a8::MutableXObject* params) { float rank_param = MetaMgr::Instance()->GetRankRewardParam(rank); float kill_param = MetaMgr::Instance()->GetKillRewardParam(stats.kills); - int coin_num = (rank_param * MetaMgr::Instance()->rank_param) + - (kill_param * MetaMgr::Instance()->kill_param); + int coin_num = (rank_param * Config::Instance()->rank_param) + + (kill_param * Config::Instance()->kill_param); stats.gold = coin_num; params->SetVal("coin_num", coin_num); } @@ -2489,7 +2490,7 @@ void Human::DeadDrop() } } for (size_t slot = 0; slot < GetInventoryData().size(); ++slot) { - if (GetInventory(slot) > 0 && !MetaMgr::Instance()->fighting_mode) { + if (GetInventory(slot) > 0 && !Config::Instance()->fighting_mode) { MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquipBySlotId(slot); if (equip_meta) { int drop_num = equip_meta->pb->group_num(); @@ -2933,7 +2934,7 @@ void Human::DropItems(Obstacle* obstacle) void Human::Revive() { { - int wait_revive_time = MetaMgr::Instance()->GetSysParamAsInt("revive_time", 25) + + int wait_revive_time = Config::Instance()->GetSysParamAsInt("revive_time", 25) + kReviveTimeAdd; revive_timer = room->xtimer.SetTimeoutWpEx (SERVER_FRAME_RATE * wait_revive_time, @@ -3300,7 +3301,7 @@ void Human::ProcUseItemAction() if (!pain_killer_timer.expired()) { int passed_time = (room->GetFrameNo() - pain_killer_frameno) * FRAME_RATE_MS; int left_time = std::max(0, pain_killer_lastingtime * 1000 - passed_time); - int anodyne_max_time = MetaMgr::Instance()->GetSysParamAsInt("anodyne_max_time"); + int anodyne_max_time = Config::Instance()->GetSysParamAsInt("anodyne_max_time"); left_time = std::min(left_time, anodyne_max_time * 1000); pain_killer_lastingtime += std::min(item_meta->pb->time() * 1000, anodyne_max_time * 1000 - left_time) / 1000; @@ -3336,7 +3337,7 @@ void Human::ProcUseItemAction() +stats.use_medicine_times; if (!dead) { if (downed) { - SetHP(MetaMgr::Instance()->downed_relive_recover_hp); + SetHP(Config::Instance()->downed_relive_recover_hp); downed = false; if (!downed_timer.expired()) { room->xtimer.Delete(downed_timer); @@ -3368,7 +3369,7 @@ void Human::ProcReliveAction() hum->CancelAction(); } if (!dead && downed) { - SetHP(MetaMgr::Instance()->GetSysParamAsFloat("downed_relive_recover_hp") * GetMaxHP()); + SetHP(Config::Instance()->GetSysParamAsFloat("downed_relive_recover_hp") * GetMaxHP()); downed = false; if (!downed_timer.expired()) { room->xtimer.Delete(downed_timer); @@ -3653,7 +3654,7 @@ void Human::UpdateViewObjects() std::vector deleted_humans; for (Human* hum : view_objects_) { if (hum->dead || - hum->GetPos().ManhattanDistance2D(GetPos()) > MetaMgr::Instance()->view_objects_out_distance) { + hum->GetPos().ManhattanDistance2D(GetPos()) > Config::Instance()->view_objects_out_distance) { deleted_humans.push_back(hum); } } @@ -3668,7 +3669,7 @@ void Human::UpdateViewObjects() { if (hum->IsAndroid() && !hum->dead && view_objects_.find(hum) == view_objects_.end()) { if (hum->GetPos().ManhattanDistance2D(GetPos()) < - MetaMgr::Instance()->view_objects_in_distance) { + Config::Instance()->view_objects_in_distance) { view_objects_.insert(hum); } if (view_objects_.size() >= 2) { @@ -3681,9 +3682,10 @@ void Human::UpdateViewObjects() if (view_objects_.size() < 2) { room->GetIncubator()->AllocAndroid(this, 1 + rand() % 2); if (!refresh_view_timer_.expired()) { - room->xtimer.ModifyTime(refresh_view_timer_, - SERVER_FRAME_RATE * (MetaMgr::Instance()->refresh_view_time + (rand() % 3)) - ); + room->xtimer.ModifyTime + (refresh_view_timer_, + SERVER_FRAME_RATE * (Config::Instance()->refresh_view_time + (rand() % 3)) + ); } } } @@ -3800,7 +3802,7 @@ void Human::OnExplosionHit(Explosion* e) HasBuffEffect(kBET_Fly)) { return; } - if (HasBuffEffect(kBET_Dive) && !MetaMgr::Instance()->dive_explosion_dmg_switch) { + if (HasBuffEffect(kBET_Dive) && !Config::Instance()->dive_explosion_dmg_switch) { return; } int real_killer_id = 0; @@ -3892,7 +3894,7 @@ void Human::StartRefreshViewTimer() } refresh_view_timer_ = room->xtimer.SetIntervalWpEx ( - SERVER_FRAME_RATE * MetaMgr::Instance()->refresh_view_time, + SERVER_FRAME_RATE * Config::Instance()->refresh_view_time, [this] (int event, const a8::Args* args) { if (a8::TIMER_EXEC_EVENT == event) { @@ -4552,7 +4554,7 @@ void Human::TraverseObservers(std::function func) void Human::AddOxygen(int val) { oxygen_ += val; - oxygen_ = std::min(MetaMgr::Instance()->dive_oxygen_total, oxygen_); + oxygen_ = std::min(Config::Instance()->dive_oxygen_total, oxygen_); } void Human::DecOxygen(int val) @@ -4609,9 +4611,9 @@ void Human::InternalBeKill(int killer_id, const std::string& killer_name, int we real_dead = false; OnDie(); KillMgr::Instance()->OnHumanDead(this, &info); - room->frame_event.AddDead(GetWeakPtrRef(), 1000 * MetaMgr::Instance()->revive_time); + room->frame_event.AddDead(GetWeakPtrRef(), 1000 * Config::Instance()->revive_time); dead_timer = room->xtimer.SetTimeoutWpEx - (MetaMgr::Instance()->revive_time * SERVER_FRAME_RATE, + (Config::Instance()->revive_time * SERVER_FRAME_RATE, [this] (int event, const a8::Args* args) { if (a8::TIMER_EXEC_EVENT == event) { @@ -4802,7 +4804,7 @@ void Human::CalcAssists(Human* target) if (hum->GetUniId() == this->GetUniId()) { return true; } - int assist_time = MetaMgr::Instance()->GetSysParamAsInt("assist_time", 5); + int assist_time = Config::Instance()->GetSysParamAsInt("assist_time", 5); auto itr = target->attacker_hash_.find(hum->GetUniId()); if (itr != target->attacker_hash_.end()) { if (hum->room->GetFrameNo() - itr->second < diff --git a/server/gameserver/incubator.cc b/server/gameserver/incubator.cc index 6b39743e..caa02813 100644 --- a/server/gameserver/incubator.cc +++ b/server/gameserver/incubator.cc @@ -6,6 +6,7 @@ #include "metamgr.h" #include "hero.h" #include "player.h" +#include "config.h" #include "cs_proto.pb.h" @@ -63,7 +64,7 @@ void Incubator::AllocAndroid(Human* target, int num) a8::Vec2 dir = a8::Vec2::UP; while (num > 0 && try_count < 20 && !hold_humans_.empty()) { dir.Rotate(a8::RandAngle()); - int rand_len = rand() % MetaMgr::Instance()->incubator_rand_length; + int rand_len = rand() % Config::Instance()->incubator_rand_length; Human* hum = hold_humans_[0]; Position old_pos = hum->GetPos(); // 999 @@ -135,7 +136,7 @@ void Incubator::RecycleAndroid(Human* hum) hum->RemoveBuffByEffectId(kBET_BeRecycle); return; } - if (distance < MetaMgr::Instance()->incubator_canset_distance) { + if (distance < Config::Instance()->incubator_canset_distance) { #ifdef DEBUG room->BroadcastDebugMsg(a8::Format("回收机器人 %d:%s 距离太近", {hum->GetUniId(), @@ -144,7 +145,7 @@ void Incubator::RecycleAndroid(Human* hum) hum->RemoveBuffByEffectId(kBET_BeRecycle); return; } - if (distance > MetaMgr::Instance()->incubator_canset_distance + 100) { + if (distance > Config::Instance()->incubator_canset_distance + 100) { hum->RemoveBuffByEffectId(kBET_BeRecycle); hold_humans_.push_back(hum); room->DisableHuman(hum); @@ -170,7 +171,7 @@ bool Incubator::CanSee(Human* hum, Human* exclude_hum) { if (hum != exclude_hum) { if (target->GetPos().ManhattanDistance2D(hum->GetPos()) < - MetaMgr::Instance()->incubator_canset_distance) { + Config::Instance()->incubator_canset_distance) { can_see = false; return false; } diff --git a/server/gameserver/killmgr.cc b/server/gameserver/killmgr.cc index a9971290..7743c2e1 100644 --- a/server/gameserver/killmgr.cc +++ b/server/gameserver/killmgr.cc @@ -5,6 +5,7 @@ #include "metamgr.h" #include "room.h" #include "player.h" +#include "config.h" #include "cs_proto.pb.h" @@ -228,13 +229,13 @@ void KillMgr::BoradcastRollMsgCb(Human* dead_hum, if (element->element_type() == kTextElement) { int color = element->mutable_union_obj_1()->color(); if (info->killer_id == hum->GetUniId()){ - color = MetaMgr::Instance()->self_kill_color; + color = Config::Instance()->self_kill_color; } else if (killer_team_id == hum->team_id) { - color = MetaMgr::Instance()->teammate_kill_color; + color = Config::Instance()->teammate_kill_color; } else if (dead_hum == hum) { - color = MetaMgr::Instance()->self_bekill_color; + color = Config::Instance()->self_bekill_color; } else if (dead_hum->team_id == hum->team_id) { - color = MetaMgr::Instance()->teammate_bekill_color; + color = Config::Instance()->teammate_bekill_color; } if (element->mutable_union_obj_1()->color() != color) { element->mutable_union_obj_1()->set_color(color); diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index e3022d36..c1e7d38e 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -13,6 +13,7 @@ #include "metamgr.h" #include "room.h" #include "entityfactory.h" +#include "config.h" #include "roommgr.h" @@ -63,7 +64,7 @@ void MapInstance::Init() grid_service_ = new GridService(); grid_service_->Init(map_meta_->pb->map_width(), map_meta_->pb->map_height(), - MetaMgr::Instance()->map_cell_width); + Config::Instance()->map_cell_width); map_service_->Init(map_meta_->pb->map_width() / MAP_GRID_WIDTH, map_meta_->pb->map_height() / MAP_GRID_WIDTH, MAP_GRID_WIDTH); diff --git a/server/gameserver/matchteam.cc b/server/gameserver/matchteam.cc index 8b86b07c..5fc69ea4 100644 --- a/server/gameserver/matchteam.cc +++ b/server/gameserver/matchteam.cc @@ -7,6 +7,7 @@ #include "GGListener.h" #include "metamgr.h" #include "roommgr.h" +#include "config.h" #include "f8/utils.h" @@ -82,7 +83,7 @@ void MatchTeam::Init(f8::MsgHdr& hdr, const cs::CMJoin& msg) ); phase_= kMatchCombining; phase_start_tick_ = a8::XGetTickCount(); - countdown_ = MetaMgr::Instance()->match_team_time; + countdown_ = Config::Instance()->match_team_time; AddRawMember(hdr, msg); } @@ -272,7 +273,7 @@ void MatchTeam::SyncMatchInfo() } notifymsg.mutable_info()->set_phase(phase_); notifymsg.mutable_info()->set_countdown(phase_left_time_); - notifymsg.mutable_info()->set_predict_time(MetaMgr::Instance()->match_team_time); + notifymsg.mutable_info()->set_predict_time(Config::Instance()->match_team_time); for (auto& member : curr_member_hash_) { if (member->socket_handle != 0) { GGListener::Instance()->SendToClient(member->socket_handle, 0, notifymsg); @@ -336,7 +337,7 @@ void MatchTeam::UpdateMaster() ChooseLeader(); phase_ = kMatchChoose; phase_start_tick_ = a8::XGetTickCount(); - countdown_ = MetaMgr::Instance()->match_choose_time; + countdown_ = Config::Instance()->match_choose_time; } } break; @@ -345,7 +346,7 @@ void MatchTeam::UpdateMaster() UpdateTeamState(); CheckChoose(); CheckPrepare(); - if ((phase_left_time_ <= MetaMgr::Instance()->match_lock_time) || + if ((phase_left_time_ <= Config::Instance()->match_lock_time) || IsAllPrepare()) { AutoChoose(true); for (auto& member : curr_member_hash_) { @@ -353,7 +354,7 @@ void MatchTeam::UpdateMaster() } phase_ = kMatchLock; phase_start_tick_ = a8::XGetTickCount(); - countdown_ = MetaMgr::Instance()->match_lock_time; + countdown_ = Config::Instance()->match_lock_time; } } break; @@ -592,7 +593,7 @@ int MatchTeam::GetMapId() bool MatchTeam::IsShuaRobotTime() { return phase_ == kMatchCombining && - phase_left_time_ <= MetaMgr::Instance()->match_robot_time; + phase_left_time_ <= Config::Instance()->match_robot_time; } int MatchTeam::GetPhaseLeftTime() diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 6a1473c5..9d3d7243 100644 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -295,7 +295,7 @@ public: LoadMetaFile(res_path, "pveGeminiMode@pveGeminiMode", pve_gemini_mode_meta_list); LoadMetaFile(res_path, "npcStandard@npcStandard", npc_standard_meta_list); BindToMetaData(); - #if 1 + #if 0 { MetaMgr::Instance()->gas_inactive_time = MetaMgr::Instance()->GetSysParamAsInt("gas_inactive_time"); @@ -562,6 +562,7 @@ private: void Check() { + #if 0 { if (MetaMgr::Instance()->level0room_shua_robot_min_time > MetaMgr::Instance()->level0room_shua_robot_max_time) { @@ -599,6 +600,7 @@ private: A8_ABORT(); } } + #endif { for (auto& skill : skill_list) { skill.Init2(); @@ -613,6 +615,7 @@ private: map.Init2(); } } + #if 0 if (MetaMgr::Instance()->match_team_time <= 0) { A8_ABORT(); } @@ -631,6 +634,7 @@ private: if (MetaMgr::Instance()->match_lock_time >= MetaMgr::Instance()->match_choose_time) { A8_ABORT(); } + #endif { for (int i = 1; i <= 15; ++i) { if (!MetaMgr::Instance()->GetNpcStandard(i)) { @@ -925,24 +929,6 @@ void MetaMgr::Reload() loader_->Load(); } -int MetaMgr::GetSysParamAsInt(const std::string& param_name, int def_val) -{ - auto itr = loader_->parameter_hash.find(param_name); - return itr != loader_->parameter_hash.end() ? itr->second->int_val: def_val; -} - -double MetaMgr::GetSysParamAsFloat(const std::string& param_name, double def_val) -{ - auto itr = loader_->parameter_hash.find(param_name); - return itr != loader_->parameter_hash.end() ? itr->second->float_val: def_val; -} - -std::string MetaMgr::GetSysParamAsString(const std::string& param_name, const char* def_val) -{ - auto itr = loader_->parameter_hash.find(param_name); - return itr != loader_->parameter_hash.end() ? itr->second->str_val: def_val; -} - MetaData::Map* MetaMgr::GetMap(int map_id) { auto itr = loader_->gamemap_hash.find(map_id); diff --git a/server/gameserver/metamgr.h b/server/gameserver/metamgr.h index d3a4c674..64446344 100644 --- a/server/gameserver/metamgr.h +++ b/server/gameserver/metamgr.h @@ -18,9 +18,6 @@ class MetaMgr : public a8::Singleton void UnInit(); void Reload(); - int GetSysParamAsInt(const std::string& param_name, int def_val = 0); - double GetSysParamAsFloat(const std::string& param_name, double def_val = 0.0f); - std::string GetSysParamAsString(const std::string& param_name, const char* def_val = ""); MetaData::Map* GetMap(int map_id); std::list* GetMaps(); MetaData::MapThing* GetMapThing(int mapthing_id); @@ -68,85 +65,6 @@ class MetaMgr : public a8::Singleton void CheckMapSpawnPoint(); - int gas_inactive_time = 10; - float kill_param = 0.0f; - float rank_param = 0.0f; - int fighting_mode = 0; - float max_oil = 0.0f; - float max_mount_horse_distance = 100.0f; - - int downed_relive_recover_hp = 0; - - int level0room_shua_robot_min_time = 0; - int level0room_shua_robot_max_time = 0; - int level0room_shua_robot_min_num = 0; - int level0room_shua_robot_max_num = 0; - int level0room_die_robot_min_time = 0; - int level0room_die_robot_max_time = 0; - int level0room_die_robot_min_num = 0; - int level0room_die_robot_max_num = 0; - int level0room_robot_water = 0; - int level0room_robot_protect_time = 0; - int level0room_robot_autodie_time = 0; - int level0room_robot_autodie_distance = 0; - - int level1room_shua_robot_min_time = 0; - int level1room_shua_robot_max_time = 0; - int level1room_shua_robot_min_num = 0; - int level1room_shua_robot_max_num = 0; - int level1room_die_robot_min_time = 0; - int level1room_die_robot_max_time = 0; - int level1room_die_robot_min_num = 0; - int level1room_die_robot_max_num = 0; - int level1room_robot_water = 0; - int level1room_robot_autodie_time = 0; - int level1room_robot_autodie_distance = 0; - std::string level1room_born_point; - - float water_show_time = 0.5f; - float water_invisible_time2 = 2.0f; - double water_move_coefficient = 0.75f; - float ice_invisible_time = 0.5; - float ice_show_time = 0.5f; - float ice_invisible_time2 = 2.0f; - - int view_objects_out_distance = 580; - int view_objects_in_distance = 580; - - int incubator_base_length = 580; - int incubator_rand_length = 100; - int incubator_canset_distance = 100; - - int refresh_view_time = 8; - - int teammate_kill_color = 0xFFFF00; - int teammate_bekill_color = 0xFF0000; - - int self_kill_color = 0xFFFF00; - int self_bekill_color = 0xFF0000; - - int map_cell_width = 64 * 8; - int bullet_planck_step_length = 15; - MetaData::Player* human_meta = nullptr; - MetaData::Player* android_meta = nullptr; - - int prebattle_can_use_skill = 0; - int watchable = 0; - int prebattle_combine_team = 1; - - int match_team_time = 0; - int match_robot_time = 0; - int match_choose_time = 0; - int match_lock_time = 0; - - int dive_oxygen_total = 0; - int dive_oxygen_consume = 0; - int dive_hp_consume = 0; - int dive_explosion_dmg_switch = 0; - int inwater_oxygen_recover = 0; - - int revive_time = 15; - private: MetaDataLoader* loader_ = nullptr; diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index bf3c1698..6fc5d854 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -24,6 +24,7 @@ #include "httpproxy.h" #include "roommgr.h" #include "movehelper.h" +#include "config.h" const int kREVIVE_BUFF_ID = 1005; @@ -695,7 +696,7 @@ void Player::HumanInteraction(Human* hum) if (hum->GetActionType() == AT_Rescue) { return; } - int downed_relive_time = MetaMgr::Instance()->GetSysParamAsInt("downed_relive_time") * 1000; + int downed_relive_time = Config::Instance()->GetSysParamAsInt("downed_relive_time") * 1000; downed_relive_time -= GetAbility()->GetAttrAbs(kHAT_RescueTime); downed_relive_time = std::max(0, downed_relive_time); StartAction( @@ -1021,7 +1022,7 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg) #endif } else if (cmd == "jiuyuan") { TryAddBuff(this, kRescuerBuffId); - int downed_relive_time = MetaMgr::Instance()->GetSysParamAsInt("downed_relive_time") * 1000; + int downed_relive_time = Config::Instance()->GetSysParamAsInt("downed_relive_time") * 1000; downed_relive_time -= GetAbility()->GetAttrAbs(kHAT_RescueTime); downed_relive_time = std::max(0, downed_relive_time); downed_relive_time = 1000 * 30; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index ec6fd61a..a3c49d84 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -34,6 +34,7 @@ #include "incubator.h" #include "team.h" #include "matchteam.h" +#include "config.h" const int SHUA_RANGE = 580; @@ -853,7 +854,7 @@ void Room::AdjustPosInnerMap(Position& pos, float radius) Human* Room::GetWatchWarTarget(Human* hum) { - if (!MetaMgr::Instance()->watchable) { + if (!Config::Instance()->watchable) { return nullptr; } if (hum->GetTeam()) { @@ -1270,7 +1271,7 @@ void Room::UpdateGasInactivePvp() ShuaPlane(); InitAndroidAI(); RoomMgr::Instance()->ActiveRoom(GetRoomUuid()); - int auto_jump_interval = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_interval"); + int auto_jump_interval = Config::Instance()->GetSysParamAsInt("auto_jump_interval"); auto_jump_timer_ = xtimer.SetIntervalWpEx (SERVER_FRAME_RATE * auto_jump_interval, [this] (int event, const a8::Args* args) @@ -1278,8 +1279,8 @@ void Room::UpdateGasInactivePvp() if (a8::TIMER_EXEC_EVENT != event) { return; } - int auto_jump_min_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_min_num"); - int auto_jump_max_num = MetaMgr::Instance()->GetSysParamAsInt("auto_jump_max_num"); + int auto_jump_min_num = Config::Instance()->GetSysParamAsInt("auto_jump_min_num"); + int auto_jump_max_num = Config::Instance()->GetSysParamAsInt("auto_jump_max_num"); int jump_num = a8::RandEx(auto_jump_min_num, auto_jump_max_num); if (last_player_jump_pos.Distance(plane.curr_pos) < 64 * 8) { jump_num = 1 + rand() % 2; @@ -1499,7 +1500,7 @@ void Room::MatchTeam(Human* hum) } } }//end for human_hash_ - if (MetaMgr::Instance()->prebattle_combine_team) { + if (Config::Instance()->prebattle_combine_team) { if (!hum->GetTeam() && hum->auto_fill && combineable_team_hash_.size() > 1) { for (auto& pair : combineable_team_hash_) { Team* team = pair.second; @@ -1527,7 +1528,7 @@ void Room::MatchTeam(Human* hum) void Room::CombineTeam() { return; - if (MetaMgr::Instance()->prebattle_combine_team) { + if (Config::Instance()->prebattle_combine_team) { return; } std::map need_combine_teams; @@ -2260,7 +2261,7 @@ void Room::NotifyGameStart() }, &xtimer_attacher_); xtimer.SetTimeoutEx - (MetaMgr::Instance()->GetSysParamAsInt("prepare_time", 3000) / FRAME_RATE_MS, + (Config::Instance()->GetSysParamAsInt("prepare_time", 3000) / FRAME_RATE_MS, [this] (int event, const a8::Args* args) { if (a8::TIMER_EXEC_EVENT == event) { @@ -2308,7 +2309,7 @@ long long Room::GetGasInactiveTime() if (IsPveRoom()) { return 10; } else { - return MetaMgr::Instance()->gas_inactive_time; + return Config::Instance()->gas_inactive_time; } } @@ -2380,21 +2381,21 @@ void Room::ShuaAndroidTimerFunc() { if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) { int shua_time = a8::RandEx( - MetaMgr::Instance()->level0room_shua_robot_min_time, - MetaMgr::Instance()->level0room_shua_robot_max_time + Config::Instance()->level0room_shua_robot_min_time, + Config::Instance()->level0room_shua_robot_max_time ); int shua_num = a8::RandEx( - MetaMgr::Instance()->level0room_shua_robot_min_num, - MetaMgr::Instance()->level0room_shua_robot_max_num + Config::Instance()->level0room_shua_robot_min_num, + Config::Instance()->level0room_shua_robot_max_num ); if (room_type_ == RT_MidBrid) { shua_time = a8::RandEx( - MetaMgr::Instance()->level1room_shua_robot_min_time, - MetaMgr::Instance()->level1room_shua_robot_max_time + Config::Instance()->level1room_shua_robot_min_time, + Config::Instance()->level1room_shua_robot_max_time ); shua_num = a8::RandEx( - MetaMgr::Instance()->level1room_shua_robot_min_num, - MetaMgr::Instance()->level1room_shua_robot_max_num + Config::Instance()->level1room_shua_robot_min_num, + Config::Instance()->level1room_shua_robot_max_num ); } xtimer.SetTimeoutEx @@ -2416,21 +2417,21 @@ void Room::DieAndroidTimerFunc() { if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) { int die_time = a8::RandEx( - MetaMgr::Instance()->level0room_die_robot_min_time, - MetaMgr::Instance()->level0room_die_robot_max_time + Config::Instance()->level0room_die_robot_min_time, + Config::Instance()->level0room_die_robot_max_time ); int die_num = a8::RandEx( - MetaMgr::Instance()->level0room_die_robot_min_num, - MetaMgr::Instance()->level0room_die_robot_max_num + Config::Instance()->level0room_die_robot_min_num, + Config::Instance()->level0room_die_robot_max_num ); if (room_type_ == RT_MidBrid) { die_time = a8::RandEx( - MetaMgr::Instance()->level1room_die_robot_min_time, - MetaMgr::Instance()->level1room_die_robot_max_time + Config::Instance()->level1room_die_robot_min_time, + Config::Instance()->level1room_die_robot_max_time ); die_num = a8::RandEx( - MetaMgr::Instance()->level1room_die_robot_min_num, - MetaMgr::Instance()->level1room_die_robot_max_num + Config::Instance()->level1room_die_robot_min_num, + Config::Instance()->level1room_die_robot_max_num ); } xtimer.SetTimeoutEx @@ -3086,11 +3087,11 @@ void Room::InstallCheckAutoDieTimer(Human* hum) int autodie_time = 10; int autodie_distance = 500; if (room_type_ == RT_NewBrid) { - autodie_time = MetaMgr::Instance()->level0room_robot_autodie_time; - autodie_distance = MetaMgr::Instance()->level0room_robot_autodie_distance; + autodie_time = Config::Instance()->level0room_robot_autodie_time; + autodie_distance = Config::Instance()->level0room_robot_autodie_distance; } else if (room_type_ == RT_MidBrid) { - autodie_time = MetaMgr::Instance()->level1room_robot_autodie_time; - autodie_distance = MetaMgr::Instance()->level1room_robot_autodie_distance; + autodie_time = Config::Instance()->level1room_robot_autodie_time; + autodie_distance = Config::Instance()->level1room_robot_autodie_distance; } xtimer.SetTimeoutEx @@ -3135,11 +3136,11 @@ int Room::GetCanShuaNum(int shua_num) int real_shua_num = shua_num; if (room_type_ == RT_NewBrid) { real_shua_num = std::max(0, - MetaMgr::Instance()->level0room_robot_water - RealAliveCount() + + Config::Instance()->level0room_robot_water - RealAliveCount() + (int)accountid_hash_.size()); } else if (room_type_ == RT_MidBrid) { real_shua_num = std::max(0, - MetaMgr::Instance()->level1room_robot_water - RealAliveCount() + + Config::Instance()->level1room_robot_water - RealAliveCount() + (int)accountid_hash_.size()); } return real_shua_num; @@ -3731,7 +3732,7 @@ void Room::AddTeam(class MatchTeam* team) ); hum->meta = MetaMgr::Instance()->GetPlayer(msg.hero_id()); if (!hum->meta) { - hum->meta = MetaMgr::Instance()->human_meta; + hum->meta = Config::Instance()->human_meta; } hum->room = this; hum->SetBattleContext(member->battle_context); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 9af3e694..93d122e9 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -18,6 +18,7 @@ #include "matchmgr.h" #include "matchteam.h" #include "httpproxy.h" +#include "config.h" #include "f8/httpclientpool.h" #include "f8/utils.h" @@ -202,7 +203,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) ); hum->meta = MetaMgr::Instance()->GetPlayer(msg.hero_id()); if (!hum->meta) { - hum->meta = MetaMgr::Instance()->human_meta; + hum->meta = Config::Instance()->human_meta; } hum->room = room; hum->SetBattleContext(results.at(0)); diff --git a/server/gameserver/shot.cc b/server/gameserver/shot.cc index 7446bab6..b9e64175 100644 --- a/server/gameserver/shot.cc +++ b/server/gameserver/shot.cc @@ -9,6 +9,7 @@ #include "creature.h" #include "room.h" #include "car.h" +#include "config.h" static const auto hero_transform = glm::rotate( @@ -214,7 +215,7 @@ static void InternalCreateBullet(BulletInfo& bullet_info) bullet_info.bullet_dir = c->GetShotDir(); } int bullet_uniid = 0; - if (MetaMgr::Instance()->prebattle_can_use_skill || + if (Config::Instance()->prebattle_can_use_skill || !(c->HasBuffEffect(kBET_Jump) || c->HasBuffEffect(kBET_Fly))) { bullet_uniid = c->room->CreateBullet (c, diff --git a/server/gameserver/virtualbullet.cc b/server/gameserver/virtualbullet.cc index d4d137f2..b2945827 100644 --- a/server/gameserver/virtualbullet.cc +++ b/server/gameserver/virtualbullet.cc @@ -9,6 +9,7 @@ #include "collider.h" #include "roomobstacle.h" #include "human.h" +#include "config.h" float VirtualBullet::GetStrengthenWall() { @@ -68,7 +69,7 @@ void VirtualBullet::Update(int delta_time) if (sender.Get()) { float move_length = gun_meta->pb->bullet_speed() / (float)SERVER_FRAME_RATE; do { - float step_len = move_length - MetaMgr::Instance()->bullet_planck_step_length; + float step_len = move_length - Config::Instance()->bullet_planck_step_length; if (step_len <= 0.001f) { if (move_length > 0.1f) { step_len = move_length;