diff --git a/README.md b/README.md index b95a323f..b0e7634c 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,6 @@ SMJoinedNotify SMMapInfo SMUiUpdate +https://www.cnblogs.com/fellow1988/p/17263427.html +export ASAN_OPTIONS=halt_on_error=false:print_scariness=true:fast_unwind_on_malloc=true:detect_leak=1 diff --git a/server/bin/gameserver/dev_config/setting.json b/server/bin/gameserver/dev_config/setting.json index 99befbb2..ec9bf879 100644 --- a/server/bin/gameserver/dev_config/setting.json +++ b/server/bin/gameserver/dev_config/setting.json @@ -1,3 +1,4 @@ { - "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php" + "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php", + "api_secret_key": "BIgDh5J%uUktooKxT!IM7#m$NtB51%la" } diff --git a/server/bin/gameserver/test_config/setting.json b/server/bin/gameserver/test_config/setting.json index 99befbb2..ec9bf879 100644 --- a/server/bin/gameserver/test_config/setting.json +++ b/server/bin/gameserver/test_config/setting.json @@ -1,3 +1,4 @@ { - "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php" + "api_url": "https://game2006api-test.kingsome.cn/webapp/index.php", + "api_secret_key": "BIgDh5J%uUktooKxT!IM7#m$NtB51%la" } diff --git a/server/bin/robotserver/test_config b/server/bin/robotserver/test_config new file mode 120000 index 00000000..37b3ea9e --- /dev/null +++ b/server/bin/robotserver/test_config @@ -0,0 +1 @@ +../gameserver/test_config \ No newline at end of file diff --git a/server/gameserver/CMakeLists.txt b/server/gameserver/CMakeLists.txt index 20e4fbea..7d45a86a 100644 --- a/server/gameserver/CMakeLists.txt +++ b/server/gameserver/CMakeLists.txt @@ -16,9 +16,9 @@ message(LIB_DIR: ${LIB_DIR} ) set(CMAKE_CXX_FLAGS_RELEASE "-Wall -g -std=gnu++1z -DGAME_ID=${GAME_ID} -DNDEBUG -DDT_VIRTUAL_QUERYFILTER -DNEW_WEAPON_SYS=1 -DNEW_NUM=1 -DA8_PERFT=1") if (${ASAN}) - set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++1z -DGAME_ID=${GAME_ID} -DMYDEBUG -DDT_VIRTUAL_QUERYFILTER -DNEW_WEAPON_SYS=1 -fsanitize=address -DNEW_NUM=1 -fno-omit-frame-pointer -DA8_PERFT=1") + set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++1z -DGAME_ID=${GAME_ID} -DMYDEBUG -DDT_VIRTUAL_QUERYFILTER -DNEW_WEAPON_SYS=1 -fsanitize=address -DNEW_NUM=1 -fno-omit-frame-pointer -DA8_PERFT=1 -fsanitize-recover=address") else() - set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++1z -DGAME_ID=${GAME_ID} -DMYDEBUG -DDT_VIRTUAL_QUERYFILTER -DNEW_WEAPON_SYS=1 -DNEW_NUM=1 -DA8_PERFT=1") + set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++1z -DGAME_ID=${GAME_ID} -DMYDEBUG -DDT_VIRTUAL_QUERYFILTER -DNEW_WEAPON_SYS=1 -DNEW_NUM=1 -DA8_PERFT=1 -fsanitize-recover=address") endif() include_directories( diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index 5bc70739..4ef2625e 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -168,6 +168,16 @@ void GGListener::Init() void GGListener::UnInit() { + std::vector> del_handlers; + for (auto& pair : disconnect_listener_hash_) { + SocketDisconnectHandler *handle = nullptr, *tmp = nullptr; + list_for_each_entry_safe(handle, tmp, &pair.second, entry) { + del_handlers.push_back(handle->holder); + } + } + for (auto& handler : del_handlers) { + RemoveSocketDisconnectHandler(handler); + } tcp_listener_ = nullptr; } diff --git a/server/gameserver/android.cc b/server/gameserver/android.cc index 8e066cd4..2cc8a682 100644 --- a/server/gameserver/android.cc +++ b/server/gameserver/android.cc @@ -45,7 +45,7 @@ void Android::Initialize() { Human::Initialize(); account_id = a8::Format("0000_2006_%d", {robot_meta->id()}); - RandSkin(); + //RandSkin(); GiveEquip(); RecalcBaseAttr(); SetInfiniteBulletMode(); @@ -63,6 +63,7 @@ void Android::Initialize() ); GetNetData()->Init(this); } + RandSkin(); SetHP(GetNetData()->GetMaxHP()); SetMaxHP(GetHP()); { @@ -176,6 +177,13 @@ void Android::GiveEquip() void Android::RandSkin() { +#ifdef MYDEBUG + { + Skin& skin = skins[0]; + skin.skin_id = 1 + meta->skinlist(); + skin.skin_lv = 1; + } +#endif #if 0 if (!robot_meta->_skin_id.empty()) { Skin& skin = skins[0]; diff --git a/server/gameserver/batchsync.cc b/server/gameserver/batchsync.cc index 776aaedd..3c7a9300 100644 --- a/server/gameserver/batchsync.cc +++ b/server/gameserver/batchsync.cc @@ -47,9 +47,10 @@ void BatchSync::AddGlobalObject(Creature* c) std::get<1>(*tuple).FillSMSyncPosition(sync_msg); room_->TraversePlayerList ( - [&sync_msg] (Player* hum) mutable + [&sync_msg] (Player* hum) mutable -> bool { hum->SendNotifyMsg(sync_msg); + return true; }); } }, diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc new file mode 100644 index 00000000..e3a1b308 --- /dev/null +++ b/server/gameserver/boxdrop.cc @@ -0,0 +1,391 @@ +#include "precompile.h" + +#include + +#include +#include + +#include +#include + +#include "boxdrop.h" +#include "room.h" +#include "hero.h" +#include "roomobstacle.h" +#include "httpproxy.h" +#include "jsondatamgr.h" +#include "player.h" +#include "mapinstance.h" +#include "human.h" +#include "stats.h" + +#include "mt/MapMode.h" +#include "mt/Hero.h" +#include "mt/MapThing.h" +#include "mt/Param.h" + +const int BOX_ID = 150001; + +BoxDrop::BoxDrop(Room* room):room_(room) +{ + +} + +void BoxDrop::Init() +{ +} + +void BoxDrop::UnInit() +{ + +} + +void BoxDrop::OnHeroDeadDrop(Hero* hero) +{ + int box_num = GetAndDecObjBoxNum(hero->GetUniId()); + if (box_num > 0) { + Drop(box_num, hero->GetPos().ToGlmVec3()); + } +} + +void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) +{ + int box_num = GetAndDecObjBoxNum(ob->GetUniId()); + if (box_num > 0) { + Drop(box_num, ob->GetPos().ToGlmVec3()); + } +} + +void BoxDrop::OnHumanDeadDrop(Human* hum) +{ + if (hum->box_num <= 0) { + return; + } + if (room_->IsGameOver()) { + return; + } + if (room_->GetVictoryTeam()) { + return; + } + int drop_num = 0; + for (int i = 0; i < hum->box_num; ++i) { + int rnd = a8::RandEx(0, 100); + if (hum->stats->abandon_battle) { + if (rnd <= (mt::Param::s().battle_event_end_loss_rate_quit * 100)) { + ++drop_num; + } + } else { + if (rnd <= (mt::Param::s().battle_event_end_loss_rate_dead * 100)) { + ++drop_num; + } + } + } + drop_num = std::min(drop_num, hum->box_num); + if (drop_num > 0) { + Drop(drop_num, hum->GetPos().ToGlmVec3()); + hum->box_num -= drop_num; + room_->frame_event.AddPropChgEx(hum->GetWeakPtrRef(), kPropBoxNum, 0, hum->box_num, + 0, 0, false); + } +} + +void BoxDrop::Drop(int num, const glm::vec3& center) +{ + for (int i = 0; i < num; ++i) { + glm::vec3 dir = GlmHelper::UP; + GlmHelper::RotateY(dir, a8::RandAngle()); + + glm::vec3 born_pos = center; + GlmHelper::Normalize(dir); + glm::vec3 start = born_pos; + room_->map_instance->Scale(start); + + glm::vec3 real_pos = born_pos; + float distance = 25.0f + rand() % 50; + for (int i = 0; i < 4; ++i) { + glm::vec3 end = born_pos + dir * distance; + glm::vec3 hit_point; + bool hit_result = false; + room_->map_instance->Scale(end); + if (room_->map_instance->Raycast(start, + end, + hit_point, + hit_result, + room_->map_instance->GetMoveIncludeFlags(), + room_->map_instance->GetMoveExcludeFlags())) { + room_->map_instance->UnScale(hit_point); + if (GlmHelper::Norm2D(hit_point - born_pos) > 5) { + real_pos = hit_point; + break; + } + } + GlmHelper::RotateY(dir, glm::radians(90.0f)); + } + + room_->CreateObstacle(BOX_ID, real_pos.x, real_pos.y, real_pos.z); + } +} + +void BoxDrop::OnBattleStart() +{ + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + get_box_num_timer_ = room_->xtimer.SetIntervalWpEx + (SERVER_FRAME_RATE * 20, + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { + if (!alloced_) { + RequestAllocBoxNum(); + } + } + } + }, + &room_->xtimer_attacher_); + RequestAllocBoxNum(); + } +} + +void BoxDrop::RequestAllocBoxNum() +{ + std::string account_id; + std::string session_id; + if (!FillAccountIdSessionId(account_id, session_id)) { + return; + } + + std::string url; + JsonDataMgr::Instance()->GetApiUrl(url); + auto url_params = a8::MutableXObject::CreateObject(); + url_params->SetVal("c", "Battle"); + url_params->SetVal("a", "requestAllocBoxNum"); + url_params->SetVal("room_uuid", room_->GetRoomUuid()); + url_params->SetVal("account_id", account_id); + url_params->SetVal("session_id", session_id); + HttpProxy::Instance()->HttpGet + ( + [room_wp = room_->weak_from_this(), room_uuid = room_->GetRoomUuid()] + (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + { + if (ok) { + f8::UdpLog::Instance()->Info + ("RequestAllocBoxNum ok room_uuid:%s %s", + { + room_uuid, + rsp_obj->ToJsonStr() + }); + if (rsp_obj->GetType() != a8::XOT_OBJECT || + !rsp_obj->HasKey("errcode")) { + return; + } + if (!room_wp.expired()) { + auto room = room_wp.lock(); + if (rsp_obj->Get("errcode").GetInt() == 0) { + int box_num = rsp_obj->Get("box_num").GetInt(); + room->GetBoxDrop()->OnAllocOk(box_num); + } else { + room->GetBoxDrop()->OnAllocFail(); + } + } + } else { + f8::UdpLog::Instance()->Warning + ("RequestAllocBoxNum error room_uuid:%s", + { + room_uuid + }); + } + }, + url, + url_params + ); +} + +void BoxDrop::RequestReturnBoxNum() +{ + if (alloc_box_num_ <= 0) { + return; + } + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + if (returned_) { + return; + } + returned_ = true; + + std::string account_id; + std::string session_id; + if (!FillAccountIdSessionId(account_id, session_id)) { + return; + } + + std::string url; + JsonDataMgr::Instance()->GetApiUrl(url); + auto url_params = a8::MutableXObject::CreateObject(); + url_params->SetVal("c", "Battle"); + url_params->SetVal("a", "requestReturnBoxNum"); + url_params->SetVal("account_id", account_id); + url_params->SetVal("session_id", session_id); + url_params->SetVal("room_uuid", room_->GetRoomUuid()); + url_params->SetVal("used_num", GetUsedBoxNum()); + url_params->SetVal("alloc_box_num", alloc_box_num_); + HttpProxy::Instance()->HttpGet + ( + [room_uuid = room_->GetRoomUuid()] + (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + { + if (ok) { + f8::UdpLog::Instance()->Info + ("RequestReturnBoxNum ok room_uuid:%s %s", + { + room_uuid, + rsp_obj->ToJsonStr() + }); + if (rsp_obj->GetType() != a8::XOT_OBJECT || + !rsp_obj->HasKey("errcode")) { + return; + } + } else { + f8::UdpLog::Instance()->Warning + ("RequestReturnBoxNum error room_uuid:%s", + { + room_uuid + }); + } + }, + url, + url_params + ); + } +} + +bool BoxDrop::FillAccountIdSessionId(std::string& account_id, std::string& session_id) +{ + bool ok = false; + room_->TraversePlayerList + ([&ok, &account_id, &session_id] (Player* hum) -> bool + { + ok = true; + account_id = hum->account_id; + session_id = hum->session_id; + return true; + }); + return ok; +} + +void BoxDrop::OnAllocOk(int box_num) +{ + if (!get_box_num_timer_.expired()) { + room_->xtimer.Delete(get_box_num_timer_); + } + if (alloced_) { + return; + } + alloced_ = true; + alloc_box_num_ = box_num; + AllocBoxToRoom(); +} + +void BoxDrop::OnAllocFail() +{ + if (!get_box_num_timer_.expired()) { + room_->xtimer.Delete(get_box_num_timer_); + } +} + +void BoxDrop::AllocBoxToRoom() +{ + if (alloc_box_num_ <= 0) { + return; + } + std::vector all_list; + std::vector hero_list; + std::vector box_list; + room_->TraverseEntityList + ( + [this, &all_list, &hero_list, &box_list] (Entity* e) -> bool + { + if (e->IsCreature(room_) && ((Creature*)e)->IsHero()) { + Hero* hero = (Hero*)e; + if (hero->meta->HasDrop()) { + hero_list.push_back(hero); + all_list.push_back(e); + } + } else if (e->IsRoomObstacle()) { + RoomObstacle* ob = (RoomObstacle*)e; + if (ob->meta->HasDrop()) { + box_list.push_back(ob); + all_list.push_back(e); + } + } + return true; + }); + std::shuffle(all_list.begin(), + all_list.end(), + std::default_random_engine(a8::XGetTickCount())); + std::shuffle(hero_list.begin(), + hero_list.end(), + std::default_random_engine(a8::XGetTickCount())); + std::shuffle(box_list.begin(), + box_list.end(), + std::default_random_engine(a8::XGetTickCount())); +#ifdef MYDEBUG + f8::UdpLog::Instance()->Info + ("AllocBoxToRoom room_uuid:%s all:%d hero:%d box:%d", + { + room_->GetRoomUuid(), + all_list.size(), + hero_list.size(), + box_list.size() + }); +#endif + for (int i = 0; i < alloc_box_num_; ++i) { + if (drop_hash_.size() < all_list.size()) { + drop_hash_[all_list.at(i)->GetUniId()] = 1; + } + } +} + +int BoxDrop::GetAndDecObjBoxNum(int uniid) +{ + auto itr = drop_hash_.find(uniid); + if (itr != drop_hash_.end()) { + int num = itr->second; + itr->second = 0; + return num; + } + return 0; +} + +int BoxDrop::GetUsedBoxNum() +{ + int num = 0; + room_->TraverseHumanList + ( + [&num] (Human* hum) -> bool + { + num += hum->box_num; + return true; + }); + return num; +} + +bool BoxDrop::GetNextBoxPos(glm::vec3& pos) +{ + for (auto& pair : drop_hash_) { + if (pair.second > 0) { + Entity* e = room_->GetEntityByUniId(pair.first); + if (e) { + pos = e->GetPos().ToGlmVec3(); + return true; + } + } + } + return false; +} + +void BoxDrop::DropByUuid(int obj_uniid, const glm::vec3& center) +{ + int box_num = GetAndDecObjBoxNum(obj_uniid); + if (box_num > 0) { + Drop(box_num, center); + } +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h new file mode 100644 index 00000000..2ce4d118 --- /dev/null +++ b/server/gameserver/boxdrop.h @@ -0,0 +1,41 @@ +#pragma once + +class Room; +class Hero; +class Obstacle; +class Human; + +class BoxDrop : public std::enable_shared_from_this +{ + public: + + BoxDrop(Room* room); + void Init(); + void UnInit(); + void OnBattleStart(); + void OnHeroDeadDrop(Hero* hero); + void OnObstacleDeadDrop(Obstacle* ob); + void OnHumanDeadDrop(Human* hum); + void RequestReturnBoxNum(); + bool GetNextBoxPos(glm::vec3& pos); + void DropByUuid(int obj_uniid, const glm::vec3& center); + + private: + + void Drop(int num, const glm::vec3& center); + void RequestAllocBoxNum(); + bool FillAccountIdSessionId(std::string& account_id, std::string& session_id); + void OnAllocOk(int box_num); + void OnAllocFail(); + void AllocBoxToRoom(); + int GetAndDecObjBoxNum(int uniid); + int GetUsedBoxNum(); + + private: + Room* room_ = nullptr; + a8::XTimerWp get_box_num_timer_; + int alloc_box_num_ = 0; + bool alloced_ = false; + bool returned_ = false; + std::map drop_hash_; +}; diff --git a/server/gameserver/buff.cc b/server/gameserver/buff.cc index 5cc5af66..be0054eb 100644 --- a/server/gameserver/buff.cc +++ b/server/gameserver/buff.cc @@ -3,6 +3,8 @@ #include #include +#include + #include "buff.h" #include "human.h" #include "room.h" @@ -49,10 +51,50 @@ void Buff::Init() res_scale = meta->GetResScale(this); res_scale_frameno = owner->room->GetFrameNo(); } +#ifdef MYDEBUG + switch (meta->buff_effect()) { + case kBET_InRescue: + case kBET_Rescuer: + { + a8::XPrintf("add jiuyuan role_name:%s type:%s buff_id:%d buff_effect:%\n", + { + owner->GetName(), + owner->IsPlayer() ? "player" : "android", + meta->buff_id(), + a8::GetEnumName(meta->buff_effect()) + }); + } + break; + default: + { + } + break; + } +#endif } void Buff::UnInit() { +#ifdef MYDEBUG + switch (meta->buff_effect()) { + case kBET_InRescue: + case kBET_Rescuer: + { + a8::XPrintf("remove jiuyuan role_name:%s type:%s buff_id:%d buff_effect:%\n", + { + owner->GetName(), + owner->IsPlayer() ? "player" : "android", + meta->buff_id(), + a8::GetEnumName(meta->buff_effect()) + }); + } + break; + default: + { + } + break; + } +#endif list_del_init(&effect_entry); if (!list_empty(&depend_entry)) { list_del_init(&depend_entry); diff --git a/server/gameserver/buff.h b/server/gameserver/buff.h index 87da9a89..98c4c80a 100644 --- a/server/gameserver/buff.h +++ b/server/gameserver/buff.h @@ -37,6 +37,7 @@ class Buff float res_scale = 1; long long res_scale_frameno = 0; std::shared_ptr> buff_vars; + std::shared_ptr> child_buff_uniids; Buff(); virtual ~Buff(); diff --git a/server/gameserver/buff/callfunc.cc b/server/gameserver/buff/callfunc.cc index b2efafba..32b314b1 100644 --- a/server/gameserver/buff/callfunc.cc +++ b/server/gameserver/buff/callfunc.cc @@ -548,6 +548,12 @@ void CallFuncBuff::ProcAddEnergyShield() if (dur_time < 0.00001f) { dur_time = 99999999; } + #if 1 + if (owner->energy_shield > 0) { + owner->energy_shield = 0; + owner->GetTrigger()->DestoryEnergyShield(); + } + #endif if (owner->energy_shield > 0) { is_valid_ = false; owner->GetTrigger()->UpdateEnergyShield(hold_param2_, dur_time); diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 9152b39c..2e3a0a56 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -16,6 +16,8 @@ #include "loot.h" #include "ability.h" #include "trigger.h" +#include "boxdrop.h" +#include "netdata.h" #include "cs_proto.pb.h" @@ -25,6 +27,7 @@ #include "mt/Buff.h" #include "mt/Robot.h" #include "mt/Hero.h" +#include "mt/MapThing.h" void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) { @@ -68,6 +71,13 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) room->grid_service->MoveCreature(this); } } + } else if (cmd == "goto_box") { + glm::vec3 pos; + if (room->GetBoxDrop()->GetNextBoxPos(pos)) { + GetMutablePos().FromGlmVec3(pos); + GetMovement()->ClearPath(); + room->grid_service->MoveCreature(this); + } } else if (cmd == "additem" && cmds.size() >= 3) { int item_id = a8::XValue(cmds[1]); int item_num = a8::XValue(cmds[2]); @@ -236,12 +246,29 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) ( [this] (Human* hum) -> bool { - a8::SetBitFlag(hum->status, CS_NoDie); + //a8::SetBitFlag(hum->status, CS_NoDie); hum->GetMovement()->ClearPath(); hum->GetMutablePos().FromGlmVec3(GetPos().ToGlmVec3()); room->grid_service->MoveCreature(hum); return true; }); + } else if (cmd == "dead_teammate") { + GetTeam()->TraverseMembers + ( + [this] (Human* hum) -> bool + { + if (hum != this && !hum->dead) { + hum->BeKill(VP_Gas, + TEXT("battle_server_killer_gas", "毒圈"), + VW_Gas, + VP_Gas, + TEXT("battle_server_killer_gas", "毒圈")); + return false; + } + return true; + }); + } else if (cmd == "total_lucky") { + SendDebugMsg(a8::Format("total_lucky:%f", {GetNetData()->GetTotalLucky()})); } else if (cmd == "randomobj" && cmds.size() >= 2) { int weapon_id = a8::XValue(cmds[1]); Human* target = nullptr; @@ -410,6 +437,12 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) #endif } } + } else if (cmd == "create_mapthing") { + int thing_id = a8::XValue(cmds[1]).GetDouble(); + const mt::MapThing* thing_meta = mt::MapThing::GetById(thing_id); + if (thing_meta) { + room->CreateObstacle(thing_id, GetPos().GetX(), GetPos().GetY(), GetPos().GetZ()); + } } else if (cmd == "use_skill") { if (cmds.size() >= 2 && GetCar() && GetCar()->IsDriver(this)) { int skill_id = a8::XValue(cmds[1]); @@ -504,6 +537,31 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) for (auto& str : strings) { SendDebugMsg("数值: " + str); } + } else if (cmd == "down_teammate") { + Human* target = nullptr; + GetTeam()->TraverseMembers + ( + [this, &target] (Human *hum) -> bool + { + if (!hum->dead && hum != this) { + if (!target) { + target = hum; + } else if (GetPos().Distance2D2(hum->GetPos()) < + GetPos().Distance2D2(target->GetPos())) { + target = hum; + } + } + return true; + }); + if (target) { + float dmg_out = 0.0f; + target->DecHP(100000.0f, VP_Gas, TEXT("battle_server_killer_gas", "毒圈"), VW_Gas, + VP_Gas, + TEXT("battle_server_killer_gas", "毒圈"), + dmg_out, + 0, + 0); + } } else if (cmd == "moba_pingju" && cmds.size() >= 0) { if (room->IsMobaModeRoom() && !room->IsGameOver() && room->GetMobaOvertimeRaceFrameNo() <= 0) { room->TraverseTeams @@ -515,6 +573,12 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) }); room->xtimer.ModifyTime(room->moba_over_timer, 0); } + } else if (cmd == "peace_mode" && cmds.size() >= 0) { + if (cmds[1] == "1") { + room->OpenRoomSwitch(kRoomSwitchPeaceMode); + } else { + room->CloseRoomSwitch(kRoomSwitchPeaceMode); + } } else if (cmd == "findpath" && cmds.size() >= 3) { float x = a8::XValue(cmds[1]).GetDouble(); float y = a8::XValue(cmds[2]).GetDouble(); diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index c0615f03..10bfa7af 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -281,6 +281,9 @@ enum PropertyType_e kPropLevelExp = 55, kPropLevelUp = 56, + + kPropBoxNum = 57, + kPropShowOrHideBigEventBox = 58, }; enum SkinSlot_e @@ -327,6 +330,7 @@ enum ObstacleType_e kObstacleStrengthenWall = 12, kObstacleMedicalStation = 13, kObstacleFlameSurface = 16, + kObstacleTreasureBox = 18, }; enum BulletHit_e diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 6d105100..c6dd5260 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -398,7 +398,18 @@ int Creature::AddBuff(Creature* caster, for (int child_buff_id : buff->meta->_child_buff_list) { const mt::Buff* child_buff_meta = mt::Buff::GetById(child_buff_id); if (child_buff_meta) { - AddBuff(caster, child_buff_meta, buff_skill_meta, true, init_args, buff_vars); + int child_buff_uniid = AddBuff(caster, + child_buff_meta, + buff_skill_meta, + true, + init_args, + buff_vars); + if (child_buff_uniid) { + if (!buff->child_buff_uniids) { + buff->child_buff_uniids = std::make_shared>(); + } + buff->child_buff_uniids->push_back(child_buff_uniid); + } } } } @@ -537,7 +548,7 @@ void Creature::RemoveBuffById(int buff_id) void Creature::RemoveBuffByUniId(int buff_uniid) { int buff_id = 0; - std::vector> removed_buffs; + std::vector>>> removed_buffs; std::shared_ptr buff; for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) { if ((*itr)->buff_uniid == buff_uniid) { @@ -553,7 +564,7 @@ void Creature::RemoveBuffByUniId(int buff_uniid) int i = 0; } #endif - removed_buffs.push_back(std::make_tuple(buff->meta, buff->GetCaster().Get())); + removed_buffs.push_back(std::make_tuple(buff->meta, buff->GetCaster().Get(), buff->child_buff_uniids)); OnBuffRemove(*buff.get()); buff->UnInit(); #ifdef MYDEBUG @@ -578,10 +589,19 @@ void Creature::RemoveBuffByUniId(int buff_uniid) for (auto& tuple1 : removed_buffs) { const mt::Buff* buff_meta = std::get<0>(tuple1); Creature* caster = std::get<1>(tuple1); + std::shared_ptr> child_buff_uniids = std::get<2>(tuple1); + #if 1 + if (child_buff_uniids) { + for (auto child_buff_uniid : *child_buff_uniids) { + RemoveBuffByUniId(child_buff_uniid); + } + } + #else for (int child_buff_id : buff_meta->_child_buff_list) { RemoveBuffById(child_buff_id); } + #endif if (!HasBuffEffect(buff_meta->buff_effect()) && !list_empty(&depend_effect_[buff_meta->buff_effect()])) { diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 1a23176a..d1b25778 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -99,6 +99,7 @@ class Creature : public MoveableEntity int max_armor_shield = 0; int revive_count = 0; CreatureWeakPtr master; + int box_num = 0; Weapon second_weapon; glm::vec3 skill_pos; diff --git a/server/gameserver/framemaker.cc b/server/gameserver/framemaker.cc index d31c72cb..7753575d 100644 --- a/server/gameserver/framemaker.cc +++ b/server/gameserver/framemaker.cc @@ -15,6 +15,7 @@ #include "sandtable.h" #include "stats.h" #include "ingamevoice.h" +#include "netdata.h" #include "mt/AirLine.h" #include "mt/Hero.h" @@ -627,6 +628,7 @@ void FrameMaker::SerializeVoices(cs::SMUpdate* msg, Room* room, Human* hum, Fram p->mutable_kill_info()->set_killer_uniid(hum->GetUniId()); p->mutable_kill_info()->set_killer_name(hum->GetName()); p->mutable_kill_info()->set_killer_hero_id(hum->GetHeroMeta()->id()); + p->mutable_kill_info()->set_killer_skin_id(hum->GetNetData()->GetSkinId()); } } if (v->dead_id) { @@ -635,6 +637,7 @@ void FrameMaker::SerializeVoices(cs::SMUpdate* msg, Room* room, Human* hum, Fram p->mutable_kill_info()->set_dead_uniid(hum->GetUniId()); p->mutable_kill_info()->set_dead_name(hum->GetName()); p->mutable_kill_info()->set_dead_hero_id(hum->GetHeroMeta()->id()); + p->mutable_kill_info()->set_dead_skin_id(hum->GetNetData()->GetSkinId()); } } #ifdef MYDEBUG diff --git a/server/gameserver/handlermgr.cc b/server/gameserver/handlermgr.cc index cd44b551..b357805e 100644 --- a/server/gameserver/handlermgr.cc +++ b/server/gameserver/handlermgr.cc @@ -110,15 +110,6 @@ void HandlerMgr::RegisterNetMsgHandlers() RegisterNetMsgHandler(&ggmsghandler, &CustomMember::_CMBattlePreSetReady); - #if 0 - RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchCancel); - RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchChoose); - RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchStartGame); - RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchCancelStartGame); - RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchSendMsg); - RegisterNetMsgHandler(&ggmsghandler, &MatchTeam::_CMMatchBroadcastMsg); - #endif - RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMImmediateMsg); RegisterNetMsgHandler(&ggmsghandler, &Player::_CMExecCommand); diff --git a/server/gameserver/hero.cc b/server/gameserver/hero.cc index 04e734ef..361d02b3 100644 --- a/server/gameserver/hero.cc +++ b/server/gameserver/hero.cc @@ -21,6 +21,7 @@ #include "movement.h" #include "ability.h" #include "skill.h" +#include "boxdrop.h" #include "f8/btmgr.h" @@ -332,6 +333,7 @@ void Hero::BeKill(int killer_id, const std::string& killer_name, int weapon_id) dead = true; if (meta->HasDrop() && !room->IsPveRoom()) { room->ScatterDrop(GetPos().ToGlmVec3(), meta->RandDrop(), false, &items); + room->GetBoxDrop()->OnHeroDeadDrop(this); } if (!room->IsPveRoom()) { for (int id : meta->_drop_list) { diff --git a/server/gameserver/hero_agent.cc b/server/gameserver/hero_agent.cc index aae07632..65370312 100644 --- a/server/gameserver/hero_agent.cc +++ b/server/gameserver/hero_agent.cc @@ -396,6 +396,12 @@ bool HeroAgent::MasterInRange(float range) behaviac::EBTStatus HeroAgent::SearchEnemy(float range) { +#ifdef MYDEBUG + if (owner_->room->HasRoomSwitch(kRoomSwitchPeaceMode) + ) { + return behaviac::BT_FAILURE; + } +#endif Creature* myself = owner_; Creature* target = nullptr; float last_distance = range + 1; @@ -435,6 +441,12 @@ behaviac::EBTStatus HeroAgent::SearchEnemy(float range) behaviac::EBTStatus HeroAgent::SearchHumanEnemy(float range) { +#ifdef MYDEBUG + if (owner_->room->HasRoomSwitch(kRoomSwitchPeaceMode) + ) { + return behaviac::BT_FAILURE; + } +#endif Creature* myself = owner_; Creature* target = nullptr; float last_distance = range + 1; diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index b2920cc5..dcfdddf5 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -18,7 +19,7 @@ struct HttpProxyRequest std::string req_id; f8::HttpProxyCb cb; std::string url; - a8::XObject url_params; + std::shared_ptr url_params; long long add_tick = 0; }; @@ -63,13 +64,14 @@ void HttpProxy::UnInit() std::string HttpProxy::HttpGet( f8::HttpProxyCb cb, - const char* url, - a8::XObject url_params + const std::string& url, + std::shared_ptr url_params ) { if (f8::App::Instance()->Terminated()) { return ""; } + AddSignParams(url, url_params, ""); std::shared_ptr request = std::make_shared(); request->req_id = CreateRequestId(); request->cb = cb; @@ -81,11 +83,10 @@ std::string HttpProxy::HttpGet( } request_hash_[request->req_id] = request; - auto proxy_url_params = a8::MutableXObject::CreateObject(); proxy_url_params->SetVal("seq_id", request->req_id); proxy_url_params->SetVal("target_url", std::string(url)); - proxy_url_params->SetVal("params", url_params.ToJsonStr()); + proxy_url_params->SetVal("params", url_params->ToJsonStr()); proxy_url_params->SetVal("cb_url", a8::Format("http://%s:%d/webapp/index.php?c=Proxy&a=callback", { JsonDataMgr::Instance()->ip, @@ -104,7 +105,7 @@ std::string HttpProxy::HttpGet( { cost_time, request->url, - request->url_params.ToJsonStr(), + request->url_params->ToJsonStr(), }); #endif } else { @@ -112,7 +113,7 @@ std::string HttpProxy::HttpGet( { cost_time, request->url, - request->url_params.ToJsonStr(), + request->url_params->ToJsonStr(), ctx->response }); request->cb(false, rsp_obj, ctx); @@ -128,14 +129,15 @@ std::string HttpProxy::HttpGet( std::string HttpProxy::HttpPost( f8::HttpProxyCb cb, - const char* url, - a8::XObject url_params, + const std::string& url, + std::shared_ptr url_params, const std::string& content ) { if (f8::App::Instance()->Terminated()) { return ""; } + AddSignParams(url, url_params, content); std::shared_ptr request = std::make_shared(); request->req_id = CreateRequestId(); request->cb = cb; @@ -151,7 +153,7 @@ std::string HttpProxy::HttpPost( auto proxy_url_params = a8::MutableXObject::CreateObject(); proxy_url_params->SetVal("seq_id", request->req_id); proxy_url_params->SetVal("target_url", std::string(url)); - proxy_url_params->SetVal("params", url_params.ToJsonStr()); + proxy_url_params->SetVal("params", url_params->ToJsonStr()); proxy_url_params->SetVal("cb_url", a8::Format("http://%s:%d/webapp/index.php?c=Proxy&a=callback", { JsonDataMgr::Instance()->ip, @@ -172,7 +174,7 @@ std::string HttpProxy::HttpPost( { cost_time, request->url, - request->url_params.ToJsonStr(), + request->url_params->ToJsonStr(), }); #endif } else { @@ -180,7 +182,7 @@ std::string HttpProxy::HttpPost( { cost_time, request->url, - request->url_params.ToJsonStr(), + request->url_params->ToJsonStr(), ctx->response }); request->cb(false, rsp_obj, ctx); @@ -211,3 +213,29 @@ void HttpProxy::DestoryRequest(std::shared_ptr request) { request_hash_.erase(request->req_id); } + +void HttpProxy::AddSignParams(const std::string& url, + std::shared_ptr url_params, const std::string& post_data) +{ + if (url.find('?') != std::string::npos) { + A8_ABORT(); + } + std::string sign_data; + sign_data.reserve(1024 * 64); + int nowtime = f8::App::Instance()->GetNowTime(); + { + std::vector keys; + url_params->GetKeys(keys); + for (auto& key : keys) { + std::string val = url_params->Get(key, "").GetString(); + sign_data += key + "=" + val + "&"; + } + sign_data += post_data; + } + { + sign_data += a8::XValue(nowtime).GetString() + JsonDataMgr::Instance()->GetApiSecretKey(); + } + std::string sign = a8::openssl::md5(sign_data); + url_params->SetVal("_timestamp", a8::XValue(nowtime).GetString()); + url_params->SetVal("_sign", sign); +} diff --git a/server/gameserver/httpproxy.h b/server/gameserver/httpproxy.h index d4855a40..01ddaf9e 100644 --- a/server/gameserver/httpproxy.h +++ b/server/gameserver/httpproxy.h @@ -19,13 +19,13 @@ class HttpProxy : public a8::Singleton std::string HttpGet( f8::HttpProxyCb cb, - const char* url, - a8::XObject url_params + const std::string& url, + std::shared_ptr url_params ); std::string HttpPost( f8::HttpProxyCb cb, - const char* url, - a8::XObject url_params, + const std::string& url, + std::shared_ptr url_params, const std::string& content ); @@ -35,6 +35,8 @@ class HttpProxy : public a8::Singleton private: std::string CreateRequestId(); + void AddSignParams(const std::string& url, + std::shared_ptr url_params, const std::string& post_data); private: std::map> request_hash_; diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index fa89c33e..d6c1d079 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -44,6 +44,7 @@ #include "hero.h" #include "bornpoint.h" #include "ingamevoice.h" +#include "boxdrop.h" #include "buff/sprint.h" @@ -894,7 +895,7 @@ void Human::UpdateAction() break; case AT_Rescue: { - RemoveBuffByEffectId(kBET_InRescue); + RemoveBuffByEffectId(kBET_Rescuer); } break; default: @@ -1281,6 +1282,9 @@ void Human::OnDie() return true; }); } + if (IsPlayer()) { + int i = 0; + } if (real_dead) { std::set over_humans; if (!leave_) { @@ -1807,7 +1811,7 @@ void Human::ProcUseItemAction() void Human::ProcReliveAction() { - RemoveBuffByEffectId(kBET_Rescuer); + RemoveBuffByEffectId(kBET_InRescue); Entity* entity = room->GetEntityByUniId(action_target_id); if (!entity->IsEntityType(ET_Player)) { return; @@ -3097,6 +3101,7 @@ void Human::InternalBeKill(int killer_id, const std::string& killer_name, int we } #endif if (!dead && !room->IsGameOver() && !real_dead) { + room->GetBoxDrop()->OnHumanDeadDrop(this); KillInfo info; { info.killer_id = killer_id; @@ -3650,11 +3655,8 @@ void Human::SendPersonalBattleReport() } std::string url; JsonDataMgr::Instance()->GetApiUrl(url); - if (url.find('?') != std::string::npos) { - url += "c=Battle&a=personalReport"; - } else { - url += "?c=Battle&a=personalReport"; - } + params->SetVal("c", "Battle"); + params->SetVal("a", "personalReport"); std::string data; params->ToUrlEncodeStr(data); HttpProxy::Instance()->HttpGet @@ -3670,8 +3672,8 @@ void Human::SendPersonalBattleReport() }); } }, - url.c_str(), - *params.get() + url, + params ); } @@ -3739,3 +3741,13 @@ void Human::SetIpSaddr(long ip_saddr) { ip_saddr_ = ip_saddr; } + +int Human::GetHeroQuality() +{ + return hero_quality_; +} + +void Human::SetHeroQuality(int quality) +{ + hero_quality_ = quality; +} diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 317aacc2..159f00f3 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -296,6 +296,8 @@ class Human : public Creature void SetSocketHandle(int socket_handle); long GetIpSaddr() { return ip_saddr_; }; void SetIpSaddr(long ip_saddr); + int GetHeroQuality(); + void SetHeroQuality(int quality); protected: void ProcLootWeapon(AddItemDTO& dto); @@ -378,6 +380,7 @@ protected: private: int socket_handle_ = 0; long ip_saddr_ = 0; + int hero_quality_ = 0; std::shared_ptr born_point_; FrameData framedata_; diff --git a/server/gameserver/incubator.cc b/server/gameserver/incubator.cc index 8d706331..6650b181 100644 --- a/server/gameserver/incubator.cc +++ b/server/gameserver/incubator.cc @@ -484,7 +484,7 @@ void Incubator::NextWave() #if 1 room->TraversePlayerList ( - [this] (Player* hum) + [this] (Player* hum) -> bool { int next_wave = hum->room->pve_data.GetWave() + 1 + 1; int max_wave = room->pve_data.max_wave; diff --git a/server/gameserver/jsondatamgr.cc b/server/gameserver/jsondatamgr.cc index 6e66988f..ae79b378 100644 --- a/server/gameserver/jsondatamgr.cc +++ b/server/gameserver/jsondatamgr.cc @@ -55,6 +55,7 @@ void JsonDataMgr::Init() if (setting_json_.GetType() == a8::XOT_OBJECT && setting_json_.HasKey("api_url")) { api_url_ = setting_json_.Get("api_url").GetString(); + api_secret_key_ = setting_json_.Get("api_secret_key").GetString(); } ip = GetConf()->At("ip")->AsXValue().GetString(); diff --git a/server/gameserver/jsondatamgr.h b/server/gameserver/jsondatamgr.h index 4304e34d..6fe48cce 100644 --- a/server/gameserver/jsondatamgr.h +++ b/server/gameserver/jsondatamgr.h @@ -21,11 +21,13 @@ public: std::string server_info; void GetApiUrl(std::string& url); + std::string GetApiSecretKey() { return api_secret_key_; }; void GetHttpGetProxyUrl(std::string& url); void GetHttpPostProxyUrl(std::string& url); private: std::string api_url_; + std::string api_secret_key_; private: std::string work_path_ = "../config"; diff --git a/server/gameserver/mt/Map.cc b/server/gameserver/mt/Map.cc index 4424f143..ade9460d 100644 --- a/server/gameserver/mt/Map.cc +++ b/server/gameserver/mt/Map.cc @@ -260,7 +260,7 @@ namespace mt void Map::Init2() { { - if (is_open() && !IsPveMap() && !is_moba() && safearea_list.empty()) { + if (IsOpen() && !IsPveMap() && !is_moba() && safearea_list.empty()) { A8_ABORT(); } for (const int area_type : safearea_list) { @@ -312,6 +312,9 @@ namespace mt bool Map::IsOpen() const { + if (map_id() == 2009) { + return false; + } return is_open(); } diff --git a/server/gameserver/mt/MapMode.h b/server/gameserver/mt/MapMode.h index a988ca9a..949964e5 100644 --- a/server/gameserver/mt/MapMode.h +++ b/server/gameserver/mt/MapMode.h @@ -6,6 +6,7 @@ namespace mt { const int kPvpRankMode = 401; + const int kTreasureBoxMode = 501; DECLARE_ID_TABLE(MapMode, mtb::MapMode, "mapMode@mapMode.json", diff --git a/server/gameserver/mt/Param.cc b/server/gameserver/mt/Param.cc index afb3e508..2fa9b34b 100644 --- a/server/gameserver/mt/Param.cc +++ b/server/gameserver/mt/Param.cc @@ -76,6 +76,22 @@ namespace mt s_.crit_effect_range.push_back(a8::XValue(str).GetDouble()); } } + { + std::string tmp_str = GetStringParam("performance_score_weight_4V4", ""); + std::vector strings; + a8::Split(tmp_str, strings, '|'); + for (auto& str : strings) { + s_.performance_score_weight_4V4.push_back(a8::XValue(str).GetDouble()); + } + } + { + std::string tmp_str = GetStringParam("performance_score_weight_BR", ""); + std::vector strings; + a8::Split(tmp_str, strings, '|'); + for (auto& str : strings) { + s_.performance_score_weight_BR.push_back(a8::XValue(str).GetDouble()); + } + } { std::string tmp_str = GetStringParam("block_effect_range", ""); std::vector strings; @@ -279,6 +295,15 @@ namespace mt s_.battle_score_param0 = a8::XValue(strings[0]).GetDouble(); s_.battle_score_param1 = a8::XValue(strings[1]).GetDouble(); } + { + std::vector strings; + a8::Split(GetStringParam("battle_event_end_loss_rate"), strings, '|'); + if (strings.size() >= 3) { + s_.battle_event_end_loss_rate_win = a8::XValue(strings[0]).GetDouble(); + s_.battle_event_end_loss_rate_dead = a8::XValue(strings[1]).GetDouble(); + s_.battle_event_end_loss_rate_quit = a8::XValue(strings[2]).GetDouble(); + } + } { { auto p = std::make_shared(); diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index d4f85bc1..164f9160 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -32,6 +32,8 @@ namespace mt float max_mount_horse_distance = 100.0f; int early_parachute_jump = 0; int pickup_weapon_replace_type = 0; + std::vector performance_score_weight_4V4; + std::vector performance_score_weight_BR; int downed_relive_recover_hp = 0; @@ -158,6 +160,10 @@ namespace mt float battle_score_param0 = 0.0f; float battle_score_param1 = 0.0f; + float battle_event_end_loss_rate_win = 0.0f; + float battle_event_end_loss_rate_dead = 0.5f; + float battle_event_end_loss_rate_quit = 1.0f; + std::vector block_effect_range; std::vector crit_effect_range; diff --git a/server/gameserver/mt/Skill.cc b/server/gameserver/mt/Skill.cc index 9366609d..eeb97c63 100644 --- a/server/gameserver/mt/Skill.cc +++ b/server/gameserver/mt/Skill.cc @@ -110,9 +110,9 @@ namespace mt } auto itr = _trigger_type_buffs.find(buff_meta->trigger_type()); if (itr != _trigger_type_buffs.end()) { - itr->second.insert(buff_meta); + itr->second.push_back(buff_meta); } else { - _trigger_type_buffs[buff_meta->trigger_type()] = std::set({buff_meta}); + _trigger_type_buffs[buff_meta->trigger_type()] = std::vector({buff_meta}); } } } diff --git a/server/gameserver/mt/Skill.h b/server/gameserver/mt/Skill.h index 76a25582..195405b2 100644 --- a/server/gameserver/mt/Skill.h +++ b/server/gameserver/mt/Skill.h @@ -37,7 +37,7 @@ namespace mt const mt::Skill* _base_skill_meta = nullptr; float _value_up = 0.0f; std::set _buff_list; - std::map> _trigger_type_buffs; + std::map> _trigger_type_buffs; std::vector _phases; std::vector _raw_phases; bool IsTurnOverSkill() const; diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 0b28b501..961993a8 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -526,6 +526,7 @@ void BattleDataContext::ParseResult(a8::XObject& obj) } level_ = obj.HasKey("level") ? obj.Get("level").GetInt() : 1; skin_id_ = obj.HasKey("hero_skin") ? obj.Get("hero_skin").GetInt() : 0; + total_lucky_ = obj.HasKey("total_lucky") ? obj.Get("total_lucky").GetDouble() : 0; if (obj.HasKey("hero_dto") && obj.At("hero_dto")->IsObject()) { hero_dto = obj.At("hero_dto"); hero_ability_->hero_uniid_ = hero_dto->Get("hero_uniid", ""); @@ -1076,6 +1077,13 @@ void BattleDataContext::Init(Creature* c) if (weapon2_ability_) { weapon2_ability_->Init(c); } +#if 1 + { + if (c->IsAndroid() && a8::RandEx(0, 1000) < 100) { + skin_id_ = a8::RandEx(0, 1) + c->GetHeroMeta()->skinlist(); + } + } +#endif if (skin_id_ && c->IsHuman()) { const mt::Item* item_meta = mt::Item::GetById(skin_id_); if (item_meta) { @@ -1359,9 +1367,6 @@ void BattleDataContext::RecalcCrit() bool BattleDataContext::HasWing() { -#ifdef MYDEBUG - return true; -#endif if (hero_dto) { long long token_id = hero_dto->Get("token_id", ""); if (token_id > 6240603010001668 && token_id <= 6240603010002168) { @@ -1373,3 +1378,13 @@ bool BattleDataContext::HasWing() } return false; } + +bool BattleDataContext::HideBigEventBox() +{ + return GetTotalLucky() < 0.01f; +} + +float BattleDataContext::GetTotalLucky() +{ + return total_lucky_; +} diff --git a/server/gameserver/netdata.h b/server/gameserver/netdata.h index 83c5815f..847a7ebe 100644 --- a/server/gameserver/netdata.h +++ b/server/gameserver/netdata.h @@ -94,6 +94,8 @@ struct BattleDataContext int GetCurrentGetStar(); int GetBattleTimes(); bool HasWing(); + bool HideBigEventBox(); + float GetTotalLucky(); int GetHonor(); int GetElo() { return elo_; } @@ -109,6 +111,7 @@ private: CreatureWeakPtr owner_; int revive_coin_ = 0; int match_mode_ = 0; + float total_lucky_ = 0.0f; std::shared_ptr hero_ability_; std::shared_ptr weapon1_ability_; diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index 5c2d0c51..e144bc02 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -15,6 +15,7 @@ #include "entityfactory.h" #include "pbutils.h" #include "netdata.h" +#include "boxdrop.h" #include "mt/Equip.h" #include "mt/MapThing.h" @@ -174,7 +175,10 @@ void Obstacle::OnBulletHit(IBullet* bullet) } if (IsDead(bullet->GetRoom())) { ProcDieExplosion(bullet->GetRoom()); - bullet->GetSender().Get()->DropItems(this); + if (meta->HasDrop()) { + bullet->GetSender().Get()->DropItems(this); + bullet->GetRoom()->GetBoxDrop()->OnObstacleDeadDrop(this); + } if (meta->thing_type() == kObstacleOilBucket) { const mt::MapThing* bomb_meta = mt::MapThing::GetById(meta->_int_param1); if (bomb_meta) { @@ -225,6 +229,7 @@ void Obstacle::OnExplosionHit(Explosion* e) for (int drop_id : drops) { e->GetRoom()->ScatterDrop(GetPos().ToGlmVec3(), drop_id); } + e->GetRoom()->GetBoxDrop()->OnObstacleDeadDrop(this); } if (meta->thing_type() == kObstacleOilBucket) { const mt::MapThing* bomb_meta = mt::MapThing::GetById(meta->_int_param1); @@ -293,6 +298,11 @@ bool Obstacle::DoInteraction(Human* sender) DoHideHouseInteraction(sender); } break; + case kObstacleTreasureBox: + { + DoTreasureBoxInteraction(sender); + } + break; default: { if (!IsDead(sender->room) && IsOpenInteraction()) { @@ -308,6 +318,9 @@ bool Obstacle::DoInteraction(Human* sender) if (a8::TIMER_EXEC_EVENT == event) { #if 1 sender->DropItems(center, drops); + if (!empty(drops)) { + sender->room->GetBoxDrop()->DropByUuid(obj_uniid, center); + } #else Entity* entity = sender->room->GetEntityByUniId(obj_uniid); if (entity && entity->IsEntityType(ET_Obstacle)) { @@ -481,3 +494,37 @@ void Obstacle::SetRotate(float rotate) { rotate_ = rotate; } + +void Obstacle::DoTreasureBoxInteraction(Human* sender) +{ + if (!IsDead(sender->room) && sender->GetNetData()->GetTotalLucky() > 0.1f) { + ++sender->box_num; + sender->room->frame_event.AddPropChg + ( + sender->GetWeakPtrRef(), + kPropPickUp, + 0, + GetUniId(), + false); + sender->room->frame_event.AddPropChgEx(sender->GetWeakPtrRef(), kPropBoxNum, 0, sender->box_num, + 1, 0, false); + Die(sender->room); + BroadcastFullState(sender->room); + sender->room->xtimer.SetTimeoutEx + (meta->delay_destroy() / FRAME_RATE_MS, + [sender, obj_uniid = GetUniId()] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + Entity* entity = sender->room->GetEntityByUniId(obj_uniid); + if (entity && entity->IsEntityType(ET_Obstacle)) { + Obstacle* ob = (Obstacle*)entity; + if (ob->IsRoomObstacle()) { + sender->room->RemoveObjectLater((RoomObstacle*)entity); + } + } + return; + } + }, + &sender->xtimer_attacher); + } +} diff --git a/server/gameserver/obstacle.h b/server/gameserver/obstacle.h index 41b6aeb4..fcbea910 100644 --- a/server/gameserver/obstacle.h +++ b/server/gameserver/obstacle.h @@ -50,6 +50,7 @@ class Obstacle : public Entity protected: Obstacle(); void DoHideHouseInteraction(Human* sender); + void DoTreasureBoxInteraction(Human* sender); std::tuple* GetInteractionData(Human* sender); void AddObstacleBuff(Creature* c); void ClearObstacleBuff(Creature* c); diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 151702c1..afd85fb7 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -164,6 +164,7 @@ static Player* InternalCreatePlayer(std::shared_ptr p, int quality = 1; hum->GetNetData()->GetHeroLvQuality(hero_uniid, hero_lv, quality); hum->hero_uniid = hero_uniid; + hum->SetHeroQuality(quality); } if (on_preadd) { on_preadd(hum); @@ -704,6 +705,7 @@ void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data p->set_hero_level(GetHeroLevel()); p->set_hero_exp(GetHeroExp()); p->set_hero_max_exp(GetHeroMaxExp()); + p->set_box_num(box_num); GetCurrWeapon()->ToPB(this, p->mutable_weapon()); PBUtils::Ability_FillMFAttrAdditionList(GetAbility().get(), this, p); if (GetCar()) { @@ -749,6 +751,7 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data p->set_max_energy_shield(max_energy_shield); p->set_armor_shield(armor_shield); p->set_max_armor_shield(max_armor_shield); + p->set_box_num(box_num); if (guild_id != 0) { p->set_guild_id(guild_id); } @@ -829,6 +832,7 @@ void Human::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data p->set_shield_max_hp(shield_max_hp_); } p->set_team_id(team_id); + p->set_hero_quality(GetHeroQuality()); } void Human::FillMFObjectImage(Room* room, Human* hum, cs::MFCharacterImage* image_data) @@ -972,6 +976,7 @@ void Human::FillMFTeamData(Human* hum, cs::MFTeamData* team_data, bool is_game_o team_data->set_hero_max_exp(GetHeroMaxExp()); team_data->set_score(stats->pve_rank_score); team_data->set_main_skill_cd(GetMainSkill()->GetLeftTime()); + team_data->set_skin_id(GetNetData()->GetSkinId()); if (is_game_over || !real_dead || room->GetFrameNo() - GetRealDeadFrameNo(room) < 4) { TypeConvert::ToPb(GetPos(), team_data->mutable_pos()); TypeConvert::ToPb(GetAttackDir(), team_data->mutable_dir()); @@ -1044,6 +1049,7 @@ void Human::FillMFMobaBattleDataMember(cs::MFMobaBattleDataMember* p) p->set_avatar_url(avatar_url); p->set_hero_id(GetNetData()->GetHeroId()); p->set_head_frame(head_frame); + p->set_skin_id(GetNetData()->GetSkinId()); for (auto& inv : GetInventoryData()) { p->add_inventory(inv.num); @@ -1091,6 +1097,7 @@ void Human::FillMFTeamMemberNew(cs::MFTeamMemberNew* p) p->set_hero_max_exp(GetHeroMaxExp()); p->set_main_skill_cd(GetMainSkill()->GetLeftTime()); p->set_main_skill_max_cd(GetMainSkill()->GetCd()); + p->set_skin_id(GetNetData()->GetSkinId()); } void Human::FillSMGameOver(cs::SMGameOver& msg) @@ -1115,18 +1122,18 @@ void Human::FillSMGameOver(cs::SMGameOver& msg) } #endif { - auto p = new cs::MFSettlementNew(); - GetTeam()->FillMFSettlementNew(p); + auto p = std::make_shared(); + GetTeam()->FillMFSettlementNew(p.get()); *msg.mutable_settlement_new() = *p; *msg.mutable_common_settlement()->add_team_list() = *p; } if (room->IsMobaModeRoom()) { - auto p = new cs::MFSettlementNew(); + auto p = std::make_shared(); if (room->GetMobaTeamA() == GetTeam()) { - room->GetMobaTeamB()->FillMFSettlementNew(p); + room->GetMobaTeamB()->FillMFSettlementNew(p.get()); *msg.mutable_common_settlement()->add_team_list() = *p; } else { - room->GetMobaTeamB()->FillMFSettlementNew(p); + room->GetMobaTeamA()->FillMFSettlementNew(p.get()); *msg.mutable_common_settlement()->add_team_list() = *p; } } @@ -1532,6 +1539,9 @@ void Human::SendUpdateMsg() void Human::SendGameOver() { + if (IsPlayer()){ + int i = 0; + } CalcStats(); if (stats->abandon_battle == 1 || (GetTeam()->HasPlayer()) || GetTeam()->MemberHasOb()) { if (room->IsAlreadyRoomReportBattle()) { @@ -1547,7 +1557,7 @@ void Human::SendGameOver() } else { SendNotifyMsg(msg); } -#ifdef MYDEBUG1 +#ifdef MYDEBUG if (IsPlayer()) { a8::XPrintf("SMGameOver:%s\n", {f8::PbToJson(&msg)}); } @@ -1558,7 +1568,8 @@ void Human::SendGameOver() sent_personal_report_ = true; } if (GetTeam()->team_rank && GetTeam()->HasPlayer() && !GetTeam()->IsViewTeam() && - stats->abandon_battle != 1 && !room->IsMobaModeRoom()) { + stats->abandon_battle != 1 && !room->IsMobaModeRoom() && + !GetTeam()->IsAlreadyReportBattle()) { GetTeam()->TrySendTeamBattleReport(this); } else { cs::SMGameOver msg; @@ -1573,7 +1584,7 @@ void Human::SendGameOver() } else { SendNotifyMsg(msg); } -#ifdef MYDEBUG1 +#ifdef MYDEBUG if (IsPlayer()) { a8::XPrintf("SMGameOver:%s\n", {f8::PbToJson(&msg)}); } @@ -1662,68 +1673,6 @@ void Human::SendShowCountdown(const std::string& msg, int countdown) SendNotifyMsg(notifymsg); } -void Human::SendBattleSettlement() -{ - if (!IsPlayer()) { - return; - } - if (room->GetBattleStartFrameNo() <= 0) { - return; - } - Player* p = (Player*)this; - std::shared_ptr params = a8::MutableXObject::CreateObject(); - { - params->SetVal("account_id", account_id); - params->SetVal("session_id", session_id); - params->SetVal("battle_uuid", GetTeam()->GetBattleUuid()); - params->SetVal("__POST", f8::PbToJson(p->settlement.get())); - } - - std::string url; - JsonDataMgr::Instance()->GetApiUrl(url); - if (url.find('?') != std::string::npos) { - url += "c=Battle&a=reportSettlement"; - } else { - url += "?c=Battle&a=reportSettlement"; - } - std::string data; - params->ToUrlEncodeStr(data); -#ifdef MYDEBUG - { - if (!f8::IsTestEnv()) { - a8::XPrintf("reportSettlement %s\n", {data}); - } - } -#endif - std::string room_uuid = room->GetRoomUuid(); - std::string tmp_account_id = account_id; - - HttpProxy::Instance()->HttpGet - ( - [room_uuid, tmp_account_id, data] - (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) - { - auto room = RoomMgr::Instance()->GetRoomByUuid(room_uuid); - if (!room) { - return; - } - Player* hum = room->GetPlayerByAccountId(tmp_account_id); - if (!hum) { - return; - } - if (!ok) { - f8::UdpLog::Instance()->Error("reportSettlement error params: %s response: %s", - { - data, - "" - }); - } - }, - url.c_str(), - *params.get() - ); -} - void Human::AddItem(int item_id, int item_num) { auto itr = items_.find(item_id); @@ -2574,9 +2523,10 @@ void Room::NotifyNewsTicker(int msg_type, std::vector msg_content) } TraversePlayerList ( - [¬ify_msg] (Player* hum) + [¬ify_msg] (Player* hum) -> bool { hum->SendNotifyMsg(notify_msg); + return true; }); } @@ -2589,9 +2539,10 @@ void Room::NotifyKillList(const std::vector& uniid_list) } TraversePlayerList ( - [¬ify_msg] (Player* hum) + [¬ify_msg] (Player* hum) -> bool { hum->SendNotifyMsg(notify_msg); + return true; }); } diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 30448806..56d660da 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -140,6 +140,14 @@ void Player::Initialize() { if (a8::TIMER_EXEC_EVENT == event) { SyncVolume(-1); + if (GetNetData()->HideBigEventBox()) { + room->frame_event.AddPropChg + (GetWeakPtrRef(), + kPropShowOrHideBigEventBox, + 0, + 0, + true); + } } }, &xtimer_attacher); @@ -1093,7 +1101,7 @@ void Player::_CMMove(f8::MsgHdr* hdr, const cs::CMMove& msg) a8::XPrintf("moving:%d times:%d\n", {moving ? 1 : 0, GetDisableAttackDirTimes()}); #endif if (moving && GetDisableAttackDirTimes() <= 0) { - #if 1 + #if 0 SetAttackDir(GetMoveDir()); #else if (!HasBuffEffect(kBET_HoldShield)) { @@ -1316,9 +1324,10 @@ void Player::_CMVoice(f8::MsgHdr* hdr, const cs::CMVoice& msg) cs::SMVoiceNotify notifymsg; notifymsg.set_account_id(account_id); notifymsg.set_download_url(msg.download_url()); - auto send_func = [¬ifymsg] (Player* hum) + auto send_func = [¬ifymsg] (Player* hum) -> bool { hum->SendNotifyMsg(notifymsg); + return true; }; room->TraversePlayerList(send_func); } @@ -1378,12 +1387,9 @@ void Player::_CMRevive(f8::MsgHdr* hdr, const cs::CMRevive& msg) { std::string url; JsonDataMgr::Instance()->GetApiUrl(url); - if (url.find('?') != std::string::npos) { - url += "&c=Battle&a=decReviveCoin"; - } else { - url += "?&c=Battle&a=decReviveCoin"; - } auto url_params = a8::MutableXObject::CreateObject(); + url_params->SetVal("c", "Battle"); + url_params->SetVal("a", "decReviveCoin"); url_params->SetVal("account_id", account_id); url_params->SetVal("session_id", session_id); url_params->SetVal("target_id", hum->account_id); @@ -1427,8 +1433,8 @@ void Player::_CMRevive(f8::MsgHdr* hdr, const cs::CMRevive& msg) a8::UnSetBitFlag(hum->status, CS_Reviving); } }, - url.c_str(), - *url_params + url, + url_params ); } } @@ -1841,6 +1847,7 @@ void Player::_CMGetSettlementTeamList(f8::MsgHdr* hdr, const cs::CMGetSettlement m->set_account_id(hum->account_id); m->set_name(hum->name); m->set_hero_id(hum->meta->id()); + m->set_skin_id(hum->GetNetData()->GetSkinId()); return true; }); ++team_rank; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 66d46b4e..dca4ef34 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -52,6 +52,7 @@ #include "httpproxy.h" #include "netdata.h" #include "stats.h" +#include "boxdrop.h" #include "mt/Param.h" #include "mt/Hero.h" @@ -133,6 +134,7 @@ void Room::Init() incubator_->room = this; incubator_->Init(); sand_table_ = std::make_shared(this); + box_drop_ = std::make_shared(this); #ifdef MYDEBUG InitDebugInfo(); #endif @@ -226,6 +228,8 @@ void Room::UnInit() #ifdef MYDEBUG UnInitDebugInfo(); #endif + box_drop_->UnInit(); + box_drop_ = nullptr; incubator_ = nullptr; timer_attacher.ClearTimerList(); xtimer_attacher_.ClearTimerList(); @@ -1227,11 +1231,13 @@ std::shared_ptr Room::NewViewTeam() return team; } -void Room::TraversePlayerList(std::function cb) +void Room::TraversePlayerList(std::function cb) { for (auto& pair : accountid_hash_) { if (pair.second && !pair.second->IsOb()) { - cb(pair.second); + if (!cb(pair.second)){ + break; + } } } } @@ -2232,13 +2238,10 @@ void Room::TryMobaReport(int try_count) } std::string url; JsonDataMgr::Instance()->GetApiUrl(url); - if (url.find('?') != std::string::npos) { - url += "c=Battle&a=mobaTeamReport"; - } else { - url += "?c=Battle&a=mobaTeamReport"; - } std::shared_ptr params = a8::MutableXObject::CreateObject(); std::shared_ptr post_data = a8::MutableXObject::CreateObject(); + params->SetVal("c", "Battle"); + params->SetVal("a", "mobaTeamReport"); params->SetVal("account_id", player->account_id); params->SetVal("session_id", player->session_id); GenBattleMobaReportData(post_data.get()); @@ -2261,8 +2264,8 @@ void Room::TryMobaReport(int try_count) }); } }, - url.c_str(), - *params.get(), + url, + params, content ); #ifdef MYDEBUG @@ -3212,6 +3215,7 @@ void Room::OnBattleStart() } battle_starting_ = false; SendSMTeamFull(nullptr); + GetBoxDrop()->OnBattleStart(); } bool Room::CanAddObstacle(const glm::vec3& pos, int obstacle_id) @@ -3676,7 +3680,7 @@ void Room::GMFastForward() } TraversePlayerList ( - [this] (Player* hum) + [this] (Player* hum) -> bool { glm::vec3 src_point = glm::vec3(GetGasData().new_area_meta->GetLastArea()->x1(), 6.0f, @@ -3698,6 +3702,7 @@ void Room::GMFastForward() grid_service->MoveCreature(hum); } } + return true; }); GetIncubator()->Clear(5); TraverseHumanList @@ -4108,14 +4113,11 @@ void Room::TryRoomReport(int try_count) } std::string url; JsonDataMgr::Instance()->GetApiUrl(url); - if (url.find('?') != std::string::npos) { - url += "c=Battle&a=roomReport"; - } else { - url += "?c=Battle&a=roomReport"; - } std::shared_ptr params = a8::MutableXObject::CreateObject(); std::shared_ptr post_data = a8::MutableXObject::CreateObject(); GenBattleRoomReportData(post_data.get()); + params->SetVal("c", "Battle"); + params->SetVal("a", "roomReport"); params->SetVal("account_id", player->account_id); params->SetVal("session_id", player->session_id); std::string content = post_data->ToJsonStr(); @@ -4138,10 +4140,11 @@ void Room::TryRoomReport(int try_count) room->StartOverTimer(); } }, - url.c_str(), - *params.get(), + url, + params, content ); + GetBoxDrop()->RequestReturnBoxNum(); #ifdef MYDEBUG a8::XPrintf("RoomReportLen:%d\n", {params->ToJsonStr().size()}); #endif @@ -4169,12 +4172,21 @@ void Room::CalcMvp() [this, &max_kill, &max_assist, &max_damage, &max_recover, &max_level, &max_alive] (Human* hum) mutable -> bool { + #if 1 + max_kill = std::max(max_kill, (float)hum->stats->kills); + max_assist = std::max(max_assist, (float)hum->stats->assist); + max_damage = std::max(max_damage, (float)hum->stats->damage_amount_out); + max_recover = std::max(max_recover, (float)hum->stats->heal_amount); + max_level = std::max(max_level, (float)hum->GetHeroLevel()); + max_alive = std::max(max_alive, (float)hum->stats->alive_time / 1000); + #else max_kill += hum->stats->kills; max_assist += hum->stats->assist; max_damage += hum->stats->damage_amount_out; max_recover += hum->stats->heal_amount; max_level += hum->GetHeroLevel(); max_alive += hum->stats->alive_time / 1000; + #endif return true; }); @@ -4190,48 +4202,91 @@ void Room::CalcMvp() kill_sco = (param1 - param0) / (max_kill - 0) * (kill - 0) + param0; } } - float assist_sco = 0.0f; + float assist_sco = param0; { if (max_assist > 0) { float assist = hum->stats->assist; assist_sco = (param1 - param0) / (max_assist - 0) * (assist - 0) + param0; } } - float damage_sco = 0.0f; + float damage_sco = param0; { if (max_damage > 0) { float damage = hum->stats->damage_amount_out; damage_sco = (param1 - param0) / (max_damage - 0) * (damage - 0) + param0; } } - float recover_sco = 0.0f; + float recover_sco = param0; { if (max_recover > 0) { float recover = hum->stats->heal_amount; recover_sco = (param1 - param0) / (max_recover - 0) * (recover - 0) + param0; } } - float level_sco = 0.0f; + float level_sco = param0; { if (max_level > 1.00000) { float level = hum->GetHeroLevel(); level_sco = (param1 - param0) / (max_level - 0) * (level - 0) + param0; } } - float alive_sco = 0.0f; + float alive_sco = param0; { if (max_alive > 0) { float alive = hum->stats->alive_time / 1000; alive_sco = (param1 - param0) / (max_alive - 0) * (alive - 0) + param0; } } +#ifdef MYDEBUG + if (hum->IsPlayer()) { + a8::XPrintf("kill_sco:%f assist_sco:%f damage_sco:%f recover_sco:%f alive_sco:%f " + "assist:%f max_assist:%f damage:%f max_damage:%f recover:%f max_recover:%f " + "level:%d max_level:%d""\n", + { + kill_sco, + assist_sco, + damage_sco, + recover_sco, + alive_sco, + hum->stats->assist, + max_assist, + hum->stats->damage_amount_out, + max_damage, + hum->stats->heal_amount, + max_recover, + hum->GetHeroLevel(), + max_level + }); + } +#endif float battle_score = 0.0f; if (IsMobaModeRoom()) { + if (mt::Param::s().performance_score_weight_4V4.size() >= 5) { + kill_sco *= mt::Param::s().performance_score_weight_4V4.at(0); + assist_sco *= mt::Param::s().performance_score_weight_4V4.at(1); + damage_sco *= mt::Param::s().performance_score_weight_4V4.at(2); + recover_sco *= mt::Param::s().performance_score_weight_4V4.at(3); + level_sco *= mt::Param::s().performance_score_weight_4V4.at(4); + } battle_score = std::round((kill_sco + assist_sco + damage_sco + recover_sco + level_sco) * 100.0f) / 100.0f; - } else { + if (mt::Param::s().performance_score_weight_BR.size() >= 5) { + kill_sco *= mt::Param::s().performance_score_weight_BR.at(0); + assist_sco *= mt::Param::s().performance_score_weight_BR.at(1); + damage_sco *= mt::Param::s().performance_score_weight_BR.at(2); + recover_sco *= mt::Param::s().performance_score_weight_BR.at(3); + alive_sco *= mt::Param::s().performance_score_weight_BR.at(4); + } battle_score = std::round((kill_sco + assist_sco + damage_sco + recover_sco + alive_sco) * 100.0f) / 100.0f; } +#ifdef MYDEBUG + if (hum->IsPlayer()) { + a8::XPrintf("battle_score:%f\n", + { + battle_score + }); + } +#endif hum->stats->battle_score = battle_score; return true; }); diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 6d7d4b6d..2b250a60 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -51,6 +51,7 @@ class CustomMember; class RoomAgent; class RoomOb; class InGameVoice; +class BoxDrop; struct Plane { @@ -73,9 +74,10 @@ enum RoomSwitch_e kRoomSwitchDisableUseSkill, kRoomSwitchDisableUseItem, kRoomSwitchDisableShot, + kRoomSwitchPeaceMode, }; -class Room +class Room : public std::enable_shared_from_this { public: FrameEvent frame_event; @@ -153,7 +155,7 @@ public: void FillSMJoinedNotify(Human* self_hum, cs::SMJoinedNotify& msg); - void TraversePlayerList(std::function cb); + void TraversePlayerList(std::function cb); void TraverseRawPlayerList(std::function cb); void TraverseHumanList(std::function cb); void TraverseRawHumanList(std::function cb); @@ -305,6 +307,7 @@ public: void CalcMvp(); long long GetMobaOvertimeRaceFrameNo () { return moba_overtime_race_frameno_; } void MobaOver(); + std::shared_ptr GetBoxDrop() { return box_drop_; } std::shared_ptr GetInGameVoice() { return ingame_voice_; } @@ -472,6 +475,7 @@ private: RoomAgent* room_agent_; std::shared_ptr ingame_voice_; + std::shared_ptr box_drop_; friend class Incubator; friend class Team; diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index c0b34e00..4868bcdd 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -58,6 +58,9 @@ void RoomMgr::UnInit() room_hash_.clear(); room_idx_hash_.clear(); over_room_hash_.clear(); + custom_room_hash_.clear(); + his_custom_room_hash_.clear(); + socket_hash_.clear(); } void RoomMgr::Update(int delta_time) @@ -603,26 +606,25 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, { std::string url; JsonDataMgr::Instance()->GetApiUrl(url); + auto url_params = a8::MutableXObject::CreateObject(); + url_params->SetVal("c", "Battle"); if (custom_room_type == CUSTOM_ROOM_CUSTOM) { - if (url.find('?') != std::string::npos) { - url += "&c=Battle&a=getCustomBattleDataNew"; - } else { - url += "?&c=Battle&a=getCustomBattleDataNew"; - } + url_params->SetVal("a", "getCustomBattleDataNew"); } else if (custom_room_type == CUSTOM_ROOM_NORMAL) { - if (url.find('?') != std::string::npos) { - url += "&c=Battle&a=getNormalBattleData"; - } else { - url += "?&c=Battle&a=getNormalBattleData"; - } + url_params->SetVal("a", "getNormalBattleData"); } else { A8_ABORT(); } - auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("account_id", join_msg->account_id()); url_params->SetVal("session_id", join_msg->session_id()); url_params->SetVal("version", 1); url_params->SetVal("__POST", join_msg->payload_data()); + std::string post_data; + { + //a8::XObject post_obj; + //post_obj.ReadFromJsonString(join_msg->payload_data()); + //post_data = post_obj.ToJsonStr(); + } HttpProxy::Instance()->HttpGet ( [cb, custom_room_type] @@ -675,8 +677,8 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, cb(1, "custom battle data error", nullptr); } }, - url.c_str(), - *url_params + url, + url_params ); } } diff --git a/server/gameserver/stats.cc b/server/gameserver/stats.cc index 9b7189e4..5ab97e77 100644 --- a/server/gameserver/stats.cc +++ b/server/gameserver/stats.cc @@ -220,7 +220,7 @@ void PlayerStats::Statement(Human* sender) game_time = f8::App::Instance()->GetNowTime(); if (sender->GetBattleStartTime() <= 0) { game_duration = 0; -#ifdef MYDEBUG +#ifdef MYDEBUG1 abort(); #endif } else { diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index 22692563..993e5ee0 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -211,15 +211,12 @@ void Team::SendTeamBattleReport(Human* sender) #endif std::string url; JsonDataMgr::Instance()->GetApiUrl(url); - if (url.find('?') != std::string::npos) { - url += "c=Battle&a=teamReport"; - } else { - url += "?c=Battle&a=teamReport"; - } std::shared_ptr params = a8::MutableXObject::CreateObject(); + params->SetVal("c", "Battle"); + params->SetVal("a", "teamReport"); params->SetVal("account_id", player->account_id); params->SetVal("session_id", player->session_id); - params->SetVal("__POST", post_data->ToJsonStr()); + //params->SetVal("__POST", post_data->ToJsonStr()); std::string room_uuid = room->GetRoomUuid(); int team_id = GetTeamId(); @@ -235,7 +232,7 @@ void Team::SendTeamBattleReport(Human* sender) }); return; } - HttpProxy::Instance()->HttpGet + HttpProxy::Instance()->HttpPost ( [room_uuid, team_id] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) @@ -268,8 +265,9 @@ void Team::SendTeamBattleReport(Human* sender) } } }, - url.c_str(), - *params.get() + url, + params, + post_data->ToJsonStr() ); } @@ -407,6 +405,7 @@ void Team::GenBattleReportData(a8::MutableXObject* params) member_pb->SetVal("max_hero_skill_lv", hum->stats->max_hero_skill_lv); member_pb->SetVal("abandon_battle", hum->stats->abandon_battle); member_pb->SetVal("assist", hum->stats->assist); + member_pb->SetVal("box_num", hum->box_num); { std::string weapons_type; std::string weapons_slot; @@ -761,6 +760,7 @@ void Team::GenRoomReportData(a8::MutableXObject* params) member_pb->SetVal("max_hero_skill_lv", hum->stats->max_hero_skill_lv); member_pb->SetVal("abandon_battle", hum->stats->abandon_battle); member_pb->SetVal("assist", hum->stats->assist); + member_pb->SetVal("box_num", hum->box_num); { std::string weapons_type; std::string weapons_slot; diff --git a/server/gameserver/trigger.cc b/server/gameserver/trigger.cc index 7f0b5e8c..4968a5b3 100644 --- a/server/gameserver/trigger.cc +++ b/server/gameserver/trigger.cc @@ -22,7 +22,7 @@ class EventHandler : public std::enable_shared_from_this { public: - a8::CommonCbProc cb; + std::shared_ptr cb; list_head entry; std::shared_ptr holder; @@ -497,7 +497,8 @@ std::weak_ptr Trigger::AddListener(int event_id, a8::CommonCbProc INIT_LIST_HEAD(&itr->second); } auto p = std::make_shared(); - p->cb = cb; + p->cb = std::make_shared(); + *p->cb = cb; list_add_tail(&p->entry, &itr->second); p->holder = p; return p; @@ -520,13 +521,17 @@ void Trigger::RemoveEventHandlers(std::vector> handl } } +/* + !!! + */ void Trigger::DispatchEvent(int event_id, const std::vector& param) { auto itr = listeners_hash_.find(event_id); if (itr != listeners_hash_.end()) { struct EventHandler *handle = nullptr, *tmp = nullptr; list_for_each_entry_safe(handle, tmp, &itr->second, entry) { - handle->cb(param); + auto cb = handle->cb; + (*cb)(param); } } } diff --git a/server/robotserver/GGListener.cc b/server/robotserver/GGListener.cc index 8668ad2c..924ad3eb 100644 --- a/server/robotserver/GGListener.cc +++ b/server/robotserver/GGListener.cc @@ -11,6 +11,7 @@ #include #include "app.h" +#include "jsondatamgr.h" #include "handlermgr.h" class GCClientSession: public a8::MixedSession @@ -102,8 +103,8 @@ void GGListener::Init() tcp_listener_->on_error = GSListeneron_error; tcp_listener_->bind_address = "0.0.0.0"; - tcp_listener_->bind_port = 3333; - //tcp_listener_->bind_port = JsonDataMgr::Instance()->GetConf()->At("listen_port")->AsXValue(); + //tcp_listener_->bind_port = 3333; + tcp_listener_->bind_port = JsonDataMgr::Instance()->GetConf()->At("listen_port")->AsXValue(); tcp_listener_->Open(); f8::MsgQueue::Instance()->RegisterCallBack diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 864740eb..12401368 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -8,6 +8,7 @@ #include #include +#include #include "android_agent.h" #include "player.h" @@ -70,15 +71,15 @@ behaviac::EBTStatus AndroidAgent::CoLogin() { auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Login"); - url_params->SetVal("a", "auth"); - url_params->SetVal("gameid", 2006); - url_params->SetVal("channel", 6513); - url_params->SetVal("openid", owner_->GetIdx()); - HttpProxy::Instance()->HttpGet + url_params->SetVal("a", "auth2"); + auto post_body = a8::MutableXObject::CreateObject(); + post_body->SetVal("channel", 2); + post_body->SetVal("data", owner_->GetIdx()); + HttpProxy::Instance()->HttpPost ( [context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) { -#if 0 +#if 1 a8::XPrintf("data:%s\n", {rsp_obj->ToJsonStr()}); #endif if (ok) { @@ -96,21 +97,52 @@ behaviac::EBTStatus AndroidAgent::CoLogin() } HttpProxy::Instance()->HttpGet ( - [context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + [context, hum, account_id, session_id] + (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) { #if 0 a8::XPrintf("data:%s\n", {rsp_obj->ToJsonStr()}); #endif if (ok) { - ++Perf::Instance()->enter_ok_times; - context->login_ok = true; + auto info = rsp_obj->At("info"); + long long hero_uniid = info->Get("hero_uniid", ""); + hum->SetHeroUniId(hero_uniid); + if (hum->GetHeroUniId() <= 0) { + auto url_params = a8::MutableXObject::CreateObject(); + url_params->SetVal("c", "User"); + url_params->SetVal("a", "selectFreeItemS"); + url_params->SetVal("account_id", account_id); + url_params->SetVal("session_id", session_id); + url_params->SetVal("itemId", 30100); + HttpProxy::Instance()->HttpGet + ( + [context, hum] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + { + if (ok) { + auto info = rsp_obj->At("property_chg")->At("user_info"); + long long hero_uniid = info->Get("hero_uniid", ""); + hum->SetHeroUniId(hero_uniid); + ++Perf::Instance()->enter_ok_times; + context->login_ok = true; + } else { + context->login_ok = false; + ++Perf::Instance()->enter_fail_times; + } + }, + "https://game2006sapi-test.kingsome.cn/sapi/webapp/index.php", + url_params + ); + } else { + ++Perf::Instance()->enter_ok_times; + context->login_ok = true; + } } else { context->login_ok = false; ++Perf::Instance()->enter_fail_times; } }, "https://game2006api-test.kingsome.cn/webapp/index.php", - *url_params + url_params ); } else { context->login_ok = false; @@ -118,7 +150,8 @@ behaviac::EBTStatus AndroidAgent::CoLogin() } }, "https://login-test.kingsome.cn/webapp/index.php", - *url_params + url_params, + post_body->ToJsonStr() ); } co->runing_cb = @@ -159,7 +192,7 @@ behaviac::EBTStatus AndroidAgent::CoConnectBattleServer() owner_->GetWebSocket()->on_connect = [this, context] (a8::WebSocketClient* ) { - //a8::XPrintf("id:%d WebSocketClient on_connect\n", {context->socket_id}); + a8::XPrintf("id:%d WebSocketClient on_connect\n", {context->socket_id}); context->pending = false; context->connect_ok = true; }; @@ -196,17 +229,37 @@ behaviac::EBTStatus AndroidAgent::CoJoin() PRE_ENTER_COROUTINE(); cs::CMJoin msg; msg.set_server_id(6); - msg.set_team_uuid(""); + msg.set_team_uuid("ihCQQdNzoYFC^6q4ohsao39br%Ui!C9u2d^qvzek5hOB$3q1"); msg.set_account_id(owner_->GetAccountId()); - msg.set_team_mode(2); - msg.set_proto_version(cs::ProtoVersion); - msg.set_auto_fill(1); - msg.set_name(""); - msg.set_avatar_url(""); - msg.set_mapid(2001); - msg.set_hero_id(30800); - //weapons msg.set_session_id(owner_->GetSessionId()); + msg.set_proto_version(cs::ProtoVersion); + std::string payload_data = "ihCQQdNzoYFC^6q4ohsao39br%Ui!C9u2d^qvzek5hOB$3q1:normal_room|"; + { + auto xobj = a8::MutableXObject::CreateObject(); + auto team_list = a8::MutableXObject::CreateArray(); + { + auto team = a8::MutableXObject::CreateObject(); + auto member_list = a8::MutableXObject::CreateArray(); + auto member = a8::MutableXObject::CreateObject(); + member->SetVal("account_id", owner_->GetAccountId()); + member->SetVal("session_id", owner_->GetSessionId()); + member->SetVal("hero_uniid", owner_->GetHeroUniId()); + if (owner_->GetHeroUniId() <= 0) { + A8_ABORT(); + } + member_list->Push(*member.get()); + + team->SetVal("team_uuid", f8::App::Instance()->NewGlobalUuid()); + team->SetVal("members", *member_list.get()); + + team_list->Push(*team.get()); + } + xobj->SetVal("room_uuid", f8::App::Instance()->NewGlobalUuid()); + xobj->SetVal("start_time", f8::App::Instance()->GetNowTime()); + xobj->SetVal("team_list", *team_list.get()); + payload_data += xobj->ToJsonStr(); + } + msg.set_payload_data(payload_data); owner_->SendMsg(msg); //a8::XPrintf("CoJoin %d\n", {owner_->GetSocketId()}); diff --git a/server/robotserver/app.cc b/server/robotserver/app.cc index 0ecc7c68..ef80d488 100644 --- a/server/robotserver/app.cc +++ b/server/robotserver/app.cc @@ -7,6 +7,7 @@ #include #include "app.h" +#include "jsondatamgr.h" #include "handlermgr.h" #include "player.h" #include "playermgr.h" @@ -30,6 +31,7 @@ void App::Init() f8::BtMgr::Instance()->SetLogging(true); #endif mt::MetaMgr::Instance()->Init(); + JsonDataMgr::Instance()->Init(); IoMgr::Instance()->Init(); HttpProxy::Instance()->Init(); PlayerMgr::Instance()->Init(); @@ -41,6 +43,7 @@ void App::UnInit() GGListener::Instance()->UnInit(); PlayerMgr::Instance()->UnInit(); HttpProxy::Instance()->UnInit(); + JsonDataMgr::Instance()->UnInit(); f8::BtMgr::Instance()->UnInit(); IoMgr::Instance()->UnInit(); Perf::Instance()->UnInit(); diff --git a/server/robotserver/handlermgr.cc b/server/robotserver/handlermgr.cc index 4f04778d..424fb602 100644 --- a/server/robotserver/handlermgr.cc +++ b/server/robotserver/handlermgr.cc @@ -58,7 +58,6 @@ void HandlerMgr::RegisterNetMsgHandlers() RegisterNetMsgHandler(&gsmsghandler, &Player::_SMReconnect); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMWatchWar); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMLeave); - RegisterNetMsgHandler(&gsmsghandler, &Player::_SMMatchCancel); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMJoinedNotify); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMMapInfo); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMUpdate); @@ -72,9 +71,7 @@ void HandlerMgr::RegisterNetMsgHandlers() RegisterNetMsgHandler(&gsmsghandler, &Player::_SMSysPiaoMsg); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMShowCountdown); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMShowTeamUI); - RegisterNetMsgHandler(&gsmsghandler, &Player::_SMUpdateMatchInfo); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMGetItemNotify); - RegisterNetMsgHandler(&gsmsghandler, &Player::_SMMatchMemberMsgNotify); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMPvePassWave); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMTeamMarkTargetPosList); RegisterNetMsgHandler(&gsmsghandler, &Player::_SMDebugCmd); diff --git a/server/robotserver/httpproxy.cc b/server/robotserver/httpproxy.cc deleted file mode 100644 index 40833398..00000000 --- a/server/robotserver/httpproxy.cc +++ /dev/null @@ -1,200 +0,0 @@ -#include "precompile.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include "httpproxy.h" -#include "app.h" -#include "handlermgr.h" - -#include "f8/httpclientpool.h" - -struct HttpProxyRequest -{ - std::string req_id; - f8::HttpProxyCb cb; - std::string url; - a8::XObject url_params; - long long add_tick = 0; -}; - -class HttpProxyPromise : public a8::Promise -{ - public: - HttpProxyPromise(const char* url, a8::XObject url_params, bool* ret, std::shared_ptr* rsp) - { - url_ = url; - url_params_ = url_params; - ret_ = ret; - rsp_ = rsp; - } - -protected: - - virtual void DoAwait() override - { - f8::HttpClientPool::Instance()->HttpGet - ( - [this, _self = shared_from_this()] - (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) - { - *ret_ = ok; - if (ok) { - **rsp_ = *rsp_obj; - } - DoDone(); - }, - url_.c_str(), - url_params_, - rand() % MAX_SYS_HTTP_NUM - ); - } - - private: - std::string url_; - a8::XObject url_params_; - bool* ret_ = nullptr; - std::shared_ptr* rsp_ = nullptr; -}; - -static void _ProxyCallback(std::shared_ptr request) -{ - #ifdef MYDEBUG - #if 0 - f8::UdpLog::Instance()->Debug("ProxyCallbBack request:%s", - { - request->GetParams()->ToJsonStr() - }); - #endif - #endif - std::string seq_id = request->GetParams()->Get("seq_id"); - std::shared_ptr req = HttpProxy::Instance()->GetRequest(seq_id); - if (req) { - a8::XObject data; - - data.ReadFromJsonString(request->GetParams()->Get("data").GetString()); - if (data.GetType() == a8::XOT_SIMPLE) { - data.ReadFromJsonString("{}"); - } - f8::HttpContext ctx; - if (request->GetParams()->HasKey("errcode") && - request->GetParams()->Get("errcode").GetInt() == 0) { - req->cb(true, &data, &ctx); - } else { - req->cb(false, request->GetParams().get(), &ctx); - } - HttpProxy::Instance()->DestoryRequest(req); - } -} - -void HttpProxy::Init() -{ - request_prefix_ = "robot2006_" + a8::XValue(a8::GetMilliSecond()).GetString() + "_"; - HandlerMgr::Instance()->RegisterGMMsgHandler("Proxy@callback", _ProxyCallback); -} - -void HttpProxy::UnInit() -{ - -} - -std::string HttpProxy::HttpGet( - f8::HttpProxyCb cb, - const char* url, - a8::XObject url_params - ) -{ - std::shared_ptr request = std::make_shared(); - request->req_id = CreateRequestId(); - request->cb = cb; - request->url = url; - request->url_params = url_params; - request->add_tick = a8::XGetTickCount(); - if (request_hash_.find(request->req_id) != request_hash_.end()) { - abort(); - } - request_hash_[request->req_id] = request; - - std::string local_ip; - a8::GetLocalIp(local_ip); - auto proxy_url_params = a8::MutableXObject::CreateObject(); - proxy_url_params->SetVal("seq_id", request->req_id); - proxy_url_params->SetVal("target_url", std::string(url)); - proxy_url_params->SetVal("params", url_params.ToJsonStr()); - proxy_url_params->SetVal - ("cb_url", - a8::Format("http://%s:%d/webapp/index.php?c=Proxy&a=callback", - { - local_ip, - 3333 - })); - std::string proxy_url = "http://192.168.100.21:8321/webapp/index.php?c=Proxy&a=get"; - if (f8::IsTestEnv()) { - proxy_url = "http://127.0.0.1:8321/webapp/index.php?c=Proxy&a=get"; - } - f8::HttpClientPool::Instance()->HttpGet - ( - [request] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) - { - long long cost_time = a8::XGetTickCount() - request->add_tick; - if (ok) { -#ifdef MYDEBUG - #if 0 - f8::UdpLog::Instance()->Debug("ProxyHttpGet ok cost_time:%d url:%s params:%s", - { - cost_time, - request->url, - request->url_params.ToJsonStr(), - }); - #endif -#endif - } else { - f8::UdpLog::Instance()->Warning("ProxyHttpGet error cost_time:%d url:%s params:%s response:%s", - { - cost_time, - request->url, - request->url_params.ToJsonStr(), - ctx->response - }); - request->cb(false, rsp_obj, ctx); - HttpProxy::Instance()->DestoryRequest(request); - } - }, - proxy_url.c_str(), - *proxy_url_params, - rand() % MAX_SYS_HTTP_NUM - ); - return request->req_id; -} - -std::string HttpProxy::CreateRequestId() -{ - return request_prefix_ + f8::App::Instance()->NewGlobalUuid(); -} - -std::shared_ptr HttpProxy::GetRequest(const std::string& req_id) -{ - auto itr = request_hash_.find(req_id); - return itr != request_hash_.end() ? itr->second : nullptr; -} - -void HttpProxy::DestoryRequest(std::shared_ptr request) -{ - request_hash_.erase(request->req_id); -} - -std::shared_ptr HttpProxy::CoHttpGet(const char* url, - a8::XObject url_params, - bool* ret, - std::shared_ptr* rsp) -{ - *ret = false; - *rsp = std::make_shared(); - return std::make_shared(url, url_params, ret, rsp); -} diff --git a/server/robotserver/httpproxy.cc b/server/robotserver/httpproxy.cc new file mode 120000 index 00000000..da2b2689 --- /dev/null +++ b/server/robotserver/httpproxy.cc @@ -0,0 +1 @@ +../gameserver/httpproxy.cc \ No newline at end of file diff --git a/server/robotserver/httpproxy.h b/server/robotserver/httpproxy.h deleted file mode 100644 index cd3aafd0..00000000 --- a/server/robotserver/httpproxy.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include - -#include "f8/httpclientpool.h" - -namespace a8 -{ - class Awaiter; -} - -struct HttpProxyRequest; -class HttpProxy : public a8::Singleton -{ - - private: - HttpProxy() {}; - friend class a8::Singleton; - - public: - - void Init(); - void UnInit(); - - std::string HttpGet( - f8::HttpProxyCb cb, - const char* url, - a8::XObject url_params - ); - std::shared_ptr GetRequest(const std::string& req_id); - void DestoryRequest(std::shared_ptr request); - - std::shared_ptr CoHttpGet(const char* url, - a8::XObject url_params, - bool* ret, - std::shared_ptr* rsp); - - private: - - std::string CreateRequestId(); - - private: - std::map> request_hash_; - std::string request_prefix_; - -}; diff --git a/server/robotserver/httpproxy.h b/server/robotserver/httpproxy.h new file mode 120000 index 00000000..08310b2b --- /dev/null +++ b/server/robotserver/httpproxy.h @@ -0,0 +1 @@ +../gameserver/httpproxy.h \ No newline at end of file diff --git a/server/robotserver/jsondatamgr.cc b/server/robotserver/jsondatamgr.cc new file mode 120000 index 00000000..b018ca30 --- /dev/null +++ b/server/robotserver/jsondatamgr.cc @@ -0,0 +1 @@ +../gameserver/jsondatamgr.cc \ No newline at end of file diff --git a/server/robotserver/jsondatamgr.h b/server/robotserver/jsondatamgr.h new file mode 120000 index 00000000..4aa9fed7 --- /dev/null +++ b/server/robotserver/jsondatamgr.h @@ -0,0 +1 @@ +../gameserver/jsondatamgr.h \ No newline at end of file diff --git a/server/robotserver/player.cc b/server/robotserver/player.cc index adbf60e3..97ecb275 100644 --- a/server/robotserver/player.cc +++ b/server/robotserver/player.cc @@ -134,11 +134,6 @@ void Player::_SMLeave(f8::MsgHdr* hdr, const cs::SMLeave& msg) f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); } -void Player::_SMMatchCancel(f8::MsgHdr* hdr, const cs::SMMatchCancel& msg) -{ - f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); -} - void Player::_SMJoinedNotify(f8::MsgHdr* hdr, const cs::SMJoinedNotify& msg) { //f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); @@ -206,21 +201,11 @@ void Player::_SMShowTeamUI(f8::MsgHdr* hdr, const cs::SMShowTeamUI& msg) f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); } -void Player::_SMUpdateMatchInfo(f8::MsgHdr* hdr, const cs::SMUpdateMatchInfo& msg) -{ - f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); -} - void Player::_SMGetItemNotify(f8::MsgHdr* hdr, const cs::SMGetItemNotify& msg) { f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); } -void Player::_SMMatchMemberMsgNotify(f8::MsgHdr* hdr, const cs::SMMatchMemberMsgNotify& msg) -{ - f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); -} - void Player::_SMPvePassWave(f8::MsgHdr* hdr, const cs::SMPvePassWave& msg) { f8::UdpLog::Instance()->Info("%s %s", {msg.GetTypeName(), f8::PbToJson(&msg)}); diff --git a/server/robotserver/player.h b/server/robotserver/player.h index b260058b..2491348c 100644 --- a/server/robotserver/player.h +++ b/server/robotserver/player.h @@ -32,6 +32,8 @@ public: const std::string& GetAccountId() { return account_id_; } const std::string& GetSessionId() { return session_id_; } void SetSessionId(const std::string& session_id) { session_id_ = session_id; } + void SetHeroUniId(long long hero_uniid) { hero_uniid_ = hero_uniid; } + long long GetHeroUniId() { return hero_uniid_; } auto GetWebSocket() { return web_socket_; } int GetIdx() { return idx_; } void SetLoginSucess(); @@ -45,7 +47,6 @@ public: void _SMReconnect(f8::MsgHdr* hdr, const cs::SMReconnect& msg); void _SMWatchWar(f8::MsgHdr* hdr, const cs::SMWatchWar& msg); void _SMLeave(f8::MsgHdr* hdr, const cs::SMLeave& msg); - void _SMMatchCancel(f8::MsgHdr* hdr, const cs::SMMatchCancel& msg); void _SMJoinedNotify(f8::MsgHdr* hdr, const cs::SMJoinedNotify& msg); void _SMMapInfo(f8::MsgHdr* hdr, const cs::SMMapInfo& msg); void _SMUpdate(f8::MsgHdr* hdr, const cs::SMUpdate& msg); @@ -59,9 +60,7 @@ public: void _SMSysPiaoMsg(f8::MsgHdr* hdr, const cs::SMSysPiaoMsg& msg); void _SMShowCountdown(f8::MsgHdr* hdr, const cs::SMShowCountdown& msg); void _SMShowTeamUI(f8::MsgHdr* hdr, const cs::SMShowTeamUI& msg); - void _SMUpdateMatchInfo(f8::MsgHdr* hdr, const cs::SMUpdateMatchInfo& msg); void _SMGetItemNotify(f8::MsgHdr* hdr, const cs::SMGetItemNotify& msg); - void _SMMatchMemberMsgNotify(f8::MsgHdr* hdr, const cs::SMMatchMemberMsgNotify& msg); void _SMPvePassWave(f8::MsgHdr* hdr, const cs::SMPvePassWave& msg); void _SMTeamMarkTargetPosList(f8::MsgHdr* hdr, const cs::SMTeamMarkTargetPosList& msg); void _SMDebugCmd(f8::MsgHdr* hdr, const cs::SMDebugCmd& msg); @@ -79,6 +78,7 @@ private: std::string session_id_; std::string remote_ip_; int remote_port_ = 0; + long long hero_uniid_ = 0; bool is_login_success_ = false; bool net_connected_ = false; diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index bd140632..f22e6757 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -26,13 +26,13 @@ void PlayerMgr::Init() { if (et == a8::TIMER_EXEC_EVENT) { int idx = account_id_hash_.size() + 1; - std::string account_id = a8::Format("6513_2006_%d", {idx}); + std::string account_id = a8::Format("2_2006_%d", {idx}); auto hum = std::make_shared(); hum->Init(idx, account_id); account_id_hash_[hum->GetAccountId()] = hum; socket_id_hash_[hum->GetSocketId()] = hum; ++count; - if (count >= 200) { + if (count >= 3) { f8::Timer::Instance()->DeleteCurrentTimer(); } } diff --git a/server/tools/protobuild/cs_msgid.proto b/server/tools/protobuild/cs_msgid.proto index f3525aa1..fb911b9d 100644 --- a/server/tools/protobuild/cs_msgid.proto +++ b/server/tools/protobuild/cs_msgid.proto @@ -17,12 +17,6 @@ enum CMMessageId_e _CMRevive = 210; _CMCancelRevive = 211; _CMExecCommand = 217; - _CMMatchCancel = 218; - _CMMatchChoose = 219; - _CMMatchStartGame = 220; - _CMMatchCancelStartGame = 221; - _CMMatchSendMsg = 222; - _CMMatchBroadcastMsg = 223; _CMRequestBulletDmg = 230; _CMStowShield = 231; _CMImmediateMsg = 232; @@ -47,7 +41,6 @@ enum SMMessageId_e _SMWatchWar = 208; _SMLeave = 209; - _SMMatchCancel = 218; _SMGetSettlementTeamList = 238; _SMWatchTarget = 241; _SMTeamComamnd = 242; @@ -66,9 +59,7 @@ enum SMMessageId_e _SMSysPiaoMsg = 1014; _SMShowCountdown = 1015; _SMShowTeamUI = 1016; - _SMUpdateMatchInfo = 1017; _SMGetItemNotify = 1018; - _SMMatchMemberMsgNotify = 1019; _SMPvePassWave = 1020; _SMTeamMarkTargetPosList = 1021; _SMDebugCmd = 1022; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 1ac6f624..8d36854d 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -250,6 +250,11 @@ message MFVec3 property_subtype: 对象uniid value: 老等级 value2: 新等级 + property_type: 57 宝箱数量 + value: 当前宝箱数量 + value2: 本次获得宝箱数(>0表现获得新的宝箱 <0表示死亡时掉落扣除的宝箱 ==0纯数据同步) + property_type: 58 显示/隐藏大事件宝箱显示(客户端默认显示) + value: 0:隐藏 1:显示 */ message MFPropertyChg { @@ -341,6 +346,7 @@ message MFSettlementMember2 optional string account_id = 2; //账号id optional string name = 3; //昵称 optional int32 hero_id = 4 [default = 0]; //英雄id + optional int32 skin_id = 5 [default = 0]; //皮肤id } //玩家信息-全量 @@ -411,6 +417,8 @@ message MFPlayerFull optional int32 armor_shield = 73; //护甲 optional int32 max_armor_shield = 74; //最大护甲 + optional int32 box_num = 75; //宝箱数量 + optional int32 hero_quality = 76; //英雄品阶<=1是N阶,1阶是2,2阶是3。。。。。 } //阻挡物-部分 @@ -725,6 +733,7 @@ message MFTeamData optional int32 hero_exp = 73; //hero经验 optional int32 hero_max_exp = 74; //hero max经验 optional int32 main_skill_cd = 80 [default = 0]; //技能cd时间 + optional int32 skin_id = 81 [default = 0]; //皮肤id(只同步一次) //一下字段只在结算的时候该字段才有内容 optional string account_id = 10; //账号id @@ -759,6 +768,7 @@ message MFTeamMemberNew optional int32 hero_max_exp = 24; //hero max经验 optional int32 main_skill_cd = 25 [default = 0]; //技能cd时间 optional int32 main_skill_max_cd = 26 [default = 0]; //技能cd上限时间 + optional int32 skin_id = 27 [default = 0]; //皮肤 } //队伍数据-全量 @@ -1130,27 +1140,6 @@ message MFRichTextElement optional MFHeroHeadElement union_obj_3 = 4; //英雄头像元素 } -message MFMatchTeamMember -{ - optional string account_id = 1; //账号id account_id - optional string name = 2; //角色名 - optional string avatar_url = 3; //头像 - optional int32 hero_id = 4; //英雄id - repeated MFWeapon weapons = 5; //武器列表 - optional bool is_leader = 8; //是否队长 - optional int32 state = 9; //0:准备 1:已准备 - optional int32 head_frame = 10; //头像框 -} - -//该消息每秒同步 -message MFMatchInfo -{ - repeated MFMatchTeamMember members = 1; //成员列表 - optional int32 phase = 2; //阶段 1:合并队伍(匹配中) 2:选择角色 3:锁定(已准备) - optional int32 countdown = 3; //倒计时(单位秒) - optional int32 predict_time = 4; //预计时间(单位秒) -} - //结算奖励项 message MFOverRewardItem { @@ -1497,6 +1486,7 @@ message MFMobaBattleDataMember optional string avatar_url = 4; //头像 optional int32 hero_id = 5; //英雄id optional int32 head_frame = 6; //头像框 + optional int32 skin_id = 7; //skin_id repeated int32 inventory = 11; //库存(相当于其他游戏里的背包) optional int32 kill_count = 12; //击杀数 @@ -1554,10 +1544,12 @@ message MFInGameVoiceKillInfo optional int32 killer_uniid = 1; //凶手uniid optional string killer_name = 2; //凶手名字 optional int32 killer_hero_id = 3; //凶手hero_id + optional int32 killer_skin_id = 4; //凶手皮肤 optional int32 dead_uniid = 11; //死者uniid optional string dead_name = 12; //死者名字 optional int32 dead_hero_id = 13; //死者hero_id + optional int32 dead_skin_id = 14; //死者皮肤 } //游戏内语音 @@ -1735,46 +1727,6 @@ message CMCancelRevive { } -//组队匹配-取消 -message CMMatchCancel -{ -} - -//组队匹配-选取英雄 -message CMMatchChoose -{ - optional int32 hero_id = 1; //英雄id - repeated MFWeapon weapons = 2; //武器列表 - repeated MFPair skill_list = 4; //技能列表 key:技能id value:预留给之后扩展,目前传0就行 - optional string hero_uniid = 7; //英雄唯一id -} - -//组队匹配-出击 -message CMMatchStartGame -{ -} - -//组队匹配-出击 -message CMMatchCancelStartGame -{ -} - -//组队匹配-指定成员发送消息 -message CMMatchSendMsg -{ - //成员将收到SMMatchMemberMsgNotify消息 - repeated string target_list = 1; //目标列表,目标收到SMMatchMemberMsgNotify消息 - optional string content = 2; //消息内容 -} - -//组队匹配-队伍内广播消息 -message CMMatchBroadcastMsg -{ - //成员将收到SMMatchMemberMsgNotify消息 - optional int32 exclude_self = 1; //include_self!=0时排除自己 - optional string content = 2; //消息内容 -} - /* 请求子弹伤害(追踪型子弹、上报型子弹) */ @@ -2036,11 +1988,6 @@ message SMLeave { } -//取消匹配 -message SMMatchCancel -{ -} - //断线通知 message SMDisconnectNotify { @@ -2110,19 +2057,6 @@ message SMShowTeamUI { } -//更新匹配信息 -message SMUpdateMatchInfo -{ - optional MFMatchInfo info = 1; //匹配信息 -} - -//匹配-队伍成员消息 -message SMMatchMemberMsgNotify -{ - optional string sender = 1; //消息发送者 - optional string content = 2; //消息内容 -} - //获得物品 message SMGetItemNotify { diff --git a/third_party/f8 b/third_party/f8 index cd6c3de9..9d627653 160000 --- a/third_party/f8 +++ b/third_party/f8 @@ -1 +1 @@ -Subproject commit cd6c3de96c917d5cc7603e609613531ec93ef339 +Subproject commit 9d627653179015b73f4f21c285b065a50e98a59e