diff --git a/server/bin/restart.sh b/server/bin/restart.sh new file mode 100755 index 0000000..b0b4343 --- /dev/null +++ b/server/bin/restart.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +source /etc/profile +source /root/.bash_profile + +pid=$(ps -ef|grep "gameserver2004 -n $2 -i $1"|grep -v grep|awk '{print $2}') +echo $pid + +if [[ $pid != "" ]] +then + echo $pid|xargs kill -9 +else + echo "pid 为空" +fi + +nohup ./gameserver2004 -n $2 -i $1 >> gameserver2004$2_$1.out & diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index 178c6ca..9d1f09c 100755 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -145,11 +145,12 @@ bool App::Init(int argc, char* argv[]) PlayerMgr::Instance()->Init(); GGListener::Instance()->Init(); - a8::UdpLog::Instance()->Info("gameserver starting instance_id:%d pid:%d debug_mode:%d", + a8::UdpLog::Instance()->Info("gameserver starting instance_id:%d pid:%d debug_mode:%d channel:%d", { instance_id, getpid(), - debug_mode + debug_mode, + JsonDataMgr::Instance()->channel }); { int perf_log_time = 1000 * 30; diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 3b6f12b..df5515d 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -324,7 +324,8 @@ enum ColliderTag_e enum GameChannel_e { - kWxChannelId = 6001 + kWxChannelId = 6001, + kTouTiaoChannelId = 6006 }; const char* const PROJ_NAME_FMT = "game%d_gameserver"; diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index c085530..89ab99d 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -23,6 +23,7 @@ #include "buff.h" #include "roomobstacle.h" #include "aicomponent.h" +#include "jsondatamgr.h" #include "framework/cpp/utils.h" #include "framework/cpp/httpclientpool.h" @@ -2436,6 +2437,20 @@ void Human::GenZbModeBattleReportData(a8::MutableXObject* params) void Human::DeadDrop() { + auto SkinCanDrop = + [this] (Skin* skin) -> bool + { + #ifdef DEBUG + return false; + #else + if (JsonDataMgr::Instance()->channel == kTouTiaoChannelId) { + return false; + } else { + return skin->skin_id != 0; + } + #endif + }; + if (GetRace() == kHumanRace && !HasBuffEffect(kBET_Terminator)) { for (auto& weapon : weapons) { if (weapon.weapon_id != 0 && weapon.weapon_id != default_weapon.weapon_id) { @@ -2449,7 +2464,7 @@ void Human::DeadDrop() } { Skin* old_skin = GetSkinByIdx(kSkinSlot_HAT); - if (old_skin && old_skin->skin_id != 0) { + if (old_skin && old_skin->skin_id != 0 && SkinCanDrop(old_skin)) { a8::Vec2 dir = a8::Vec2::UP; dir.Rotate(a8::RandAngle()); room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1); @@ -2458,7 +2473,7 @@ void Human::DeadDrop() } { Skin* old_skin = GetSkinByIdx(kSkinSlot_CLOTH); - if (old_skin && old_skin->skin_id != 0) { + if (old_skin && old_skin->skin_id != 0 && SkinCanDrop(old_skin)) { a8::Vec2 dir = a8::Vec2::UP; dir.Rotate(a8::RandAngle()); room->CreateLoot(old_skin->skin_id, GetPos() + dir * (40 + rand() % 50), 1, 1); @@ -2514,10 +2529,24 @@ void Human::SendBattleReport() if (App::Instance()->HasFlag(3)) { url = "http://192.168.100.41/webapp/index.php?c=Role&a=battleReport"; } else { - url = "https://game2004api-test.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; + if (JsonDataMgr::Instance()->channel != 0) { + url = a8::Format("http://game2004api-test.kingsome.cn/%d/webapp/index.php?c=Role&a=battleReport", + { + JsonDataMgr::Instance()->channel + }); + } else { + url = "https://game2004api-test.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; + } } } else { - url = "http://game2004api.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; + if (JsonDataMgr::Instance()->channel != 0) { + url = a8::Format("http://game2004api.kingsome.cn/%d/webapp/index.php?c=Role&a=battleReport", + { + JsonDataMgr::Instance()->channel + }); + } else { + url = "http://game2004api.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; + } } std::string data; params->ToUrlEncodeStr(data); diff --git a/server/gameserver/human.h b/server/gameserver/human.h index f403b5a..920d0e3 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -45,6 +45,7 @@ class Human : public MoveableEntity bool auto_fill = false; int today_enter_times = 0; int account_registertime = 0; + int channel = 0; MetaData::Player* meta = nullptr; MetaData::Equip* helmet_meta = nullptr; MetaData::Equip* chest_meta = nullptr; diff --git a/server/gameserver/jsondatamgr.cc b/server/gameserver/jsondatamgr.cc index ff19a58..4e81bcc 100644 --- a/server/gameserver/jsondatamgr.cc +++ b/server/gameserver/jsondatamgr.cc @@ -34,6 +34,9 @@ void JsonDataMgr::Init() gameserver_cluster_json_.ReadFromFile(gameserver_cluster_json_file); ip = GetConf()->At("ip")->AsXValue().GetString(); listen_port = GetConf()->At("listen_port")->AsXValue(); + if (GetConf()->HasKey("channel")) { + channel = GetConf()->At("channel")->AsXValue(); + } server_info = a8::Format("%s:%d", {ip, listen_port}); Reload(); } @@ -44,10 +47,13 @@ void JsonDataMgr::UnInit() std::shared_ptr JsonDataMgr::GetConf() { - if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > gameserver_cluster_json_.Size()) { - abort(); + for (int i = 0; i < gameserver_cluster_json_.Size(); ++i) { + std::shared_ptr conf = gameserver_cluster_json_.At(i); + if (conf->At("instance_id")->AsXValue().GetInt() == App::Instance()->instance_id) { + return conf; + } } - return gameserver_cluster_json_[App::Instance()->instance_id - 1]; + abort(); } std::shared_ptr JsonDataMgr::GetMasterServerClusterConf() diff --git a/server/gameserver/jsondatamgr.h b/server/gameserver/jsondatamgr.h index 37a254e..ffd259a 100644 --- a/server/gameserver/jsondatamgr.h +++ b/server/gameserver/jsondatamgr.h @@ -15,7 +15,7 @@ public: std::string ip; int listen_port = 0; - + int channel = 0; std::string server_info; void Reload(); diff --git a/server/gameserver/metadata.cc b/server/gameserver/metadata.cc index 9035774..4d9a06e 100644 --- a/server/gameserver/metadata.cc +++ b/server/gameserver/metadata.cc @@ -104,8 +104,8 @@ namespace MetaData } { std::vector strings; - if (!i->spera_type().empty()) { - a8::Split(i->spera_type(), strings, '|'); + if (!i->spera_attr().empty()) { + a8::Split(i->spera_attr(), strings, '|'); } else { a8::Split(i->attr_type(), strings, '|'); } diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 72fc810..35f448d 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -7,6 +7,7 @@ #include "metamgr.h" #include "app.h" +#include "jsondatamgr.h" #define METAMGR_READ(field_name, def_val) MetaMgr::Instance()->field_name = \ a8::XValue(MetaMgr::Instance()->GetSysParamAsString(#field_name, #def_val)); @@ -94,18 +95,20 @@ public: { if (!f8::IsOnlineEnv()) { if (f8::IsTestEnv()) { - res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.test/res/", + res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.test/res%d/", { GAME_ID, App::Instance()->instance_id, - GAME_ID + GAME_ID, + App::Instance()->instance_id }); } else { - res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.dev/res/", + res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver.dev/res%d/", { GAME_ID, App::Instance()->instance_id, - GAME_ID + GAME_ID, + App::Instance()->instance_id }); } } else { diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 7457e5a..245de3c 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -284,6 +284,14 @@ void Player::UpdateUseItemId() MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(use_item_id); if (item_meta && item_meta->i->equip_type() == EQUIP_TYPE_CAMOUFLAGE) { int item_num = GetItemNum(use_item_id); + if (JsonDataMgr::Instance()->channel == kTouTiaoChannelId) { + item_num = 1; + } + #ifdef DEBUG + if (channel == kTouTiaoChannelId) { + item_num = 1; + } + #endif if (item_num > 0) { MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(item_meta->i->buffid()); if (buff_meta && !GetBuffById(item_meta->i->buffid())) { diff --git a/server/gameserver/playermgr.cc b/server/gameserver/playermgr.cc index 5e8a40a..5218bda 100644 --- a/server/gameserver/playermgr.cc +++ b/server/gameserver/playermgr.cc @@ -63,6 +63,7 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum, hum->today_enter_times = msg.today_enter_times(); hum->create_tick = a8::XGetTickCount(); hum->account_registertime = f8::ExtractRegisterTimeFromSessionId(msg.session_id()); + hum->channel = f8::ExtractChannelIdFromAccountId(msg.account_id()); hum->atk_add = msg.atk_add(); hum->emoji1 = msg.emoji1(); hum->emoji2 = msg.emoji2(); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 9abdd7f..7e4ce44 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -2731,7 +2731,8 @@ void Room::AddPlayerPostProc(Player* hum) { Human* hum = (Human*)param.sender.GetUserData(); std::string debugmsg = a8::Format("weapon_id:%d weapon_lv:%d atk:%f fire_rate:%f " - "volume:%d maxhp:%f curr_hp:%f", + "volume:%d maxhp:%f hp:%f curr_hp:%f curr_max_hp:%f " + "base_reload_time:%f grow_reload_time:%f finaly_reload_time:%f", { hum->curr_weapon->weapon_id, hum->curr_weapon->weapon_lv, @@ -2739,7 +2740,14 @@ void Room::AddPlayerPostProc(Player* hum) hum->curr_weapon->GetAttrValue(kHAT_FireRate), hum->curr_weapon->GetAttrValue(kHAT_Volume), hum->curr_weapon->GetAttrValue(kHAT_MaxHp), - hum->GetHP() + hum->curr_weapon->GetAttrValue(kHAT_Hp), + hum->GetHP(), + hum->GetMaxHP(), + hum->curr_weapon->meta->i->reload_time(), + hum->curr_weapon->GetUpgradeMeta() ? + hum->curr_weapon->GetUpgradeMeta()->GetAttrValue + (hum->curr_weapon->weapon_lv, kHAT_ReloadTime) : 0, + hum->curr_weapon->GetAttrValue(kHAT_ReloadTime) }); hum->SendDebugMsg(debugmsg); }, diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 07f0a27..c51ab1a 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -166,6 +166,15 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) hum->ProcPrepareItems2(msg.prepare_items2()); room->AddPlayer(hum); PlayerMgr::Instance()->IncAccountNum(msg.account_id()); + if (JsonDataMgr::Instance()->channel != 0 && + JsonDataMgr::Instance()->channel != channel) { + a8::UdpLog::Instance()->Warning + ("join room channel not match channel:%d account_id:%s", + { + JsonDataMgr::Instance()->channel, + msg.account_id() + }); + } } void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg) @@ -376,6 +385,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po url_params->SetVal("port", JsonDataMgr::Instance()->listen_port); url_params->SetVal("online_num", PlayerMgr::Instance()->OnlineNum()); url_params->SetVal("room_num", RoomNum()); + url_params->SetVal("channel", JsonDataMgr::Instance()->channel); url_params->SetVal("alive_count", PerfMonitor::Instance()->real_alive_count); url_params->SetVal("servicing", App::Instance()->servicing ? 1 : 0); f8::HttpClientPool::Instance()->HttpGet(a8::XParams() diff --git a/server/tools/protobuild/metatable.proto b/server/tools/protobuild/metatable.proto index 9ff3ce9..112126c 100755 --- a/server/tools/protobuild/metatable.proto +++ b/server/tools/protobuild/metatable.proto @@ -104,7 +104,7 @@ message EquipUpgrade { optional int32 id = 1; optional string attr_type = 4; - optional string spera_type = 5; + optional string spera_attr = 5; } message Player diff --git a/third_party/framework b/third_party/framework index 203adbe..ea69b96 160000 --- a/third_party/framework +++ b/third_party/framework @@ -1 +1 @@ -Subproject commit 203adbe1f4d7cf2f9d57e8bf8b80102c5fdd47a1 +Subproject commit ea69b96451e7004430e99b86db1cfd3ae4d76c6b