From a24e7d1680b744298cc41d102ea69fb452b7a60f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Jul 2024 16:28:37 +0800 Subject: [PATCH 001/102] 1 --- server/gameserver/constant.h | 2 ++ server/gameserver/creature.h | 1 + server/gameserver/room.cc | 12 ++++++++++++ server/gameserver/room.h | 4 ++++ server/tools/protobuild/cs_proto.proto | 4 ++++ 5 files changed, 23 insertions(+) diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index c0615f03..b9d942e0 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -281,6 +281,8 @@ enum PropertyType_e kPropLevelExp = 55, kPropLevelUp = 56, + + kPropBoxNum = 57, }; enum SkinSlot_e diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 1a23176a..370c71fe 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; Weapon second_weapon; glm::vec3 skill_pos; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 66d46b4e..08c527f1 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -4270,3 +4270,15 @@ void Room::MobaOver() OnGameOver(); } } + +int Room::GetMaxBoxNum() +{ + return max_box_num_; +} + +void Room::SetMaxBoxNum(int box_num) +{ + if (box_num > 0) { + max_box_num_ = box_num; + } +} diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 6d7d4b6d..6dff8203 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -305,6 +305,8 @@ public: void CalcMvp(); long long GetMobaOvertimeRaceFrameNo () { return moba_overtime_race_frameno_; } void MobaOver(); + int GetMaxBoxNum(); + void SetMaxBoxNum(int box_num); std::shared_ptr GetInGameVoice() { return ingame_voice_; } @@ -473,6 +475,8 @@ private: std::shared_ptr ingame_voice_; + int max_box_num_ = 0; + friend class Incubator; friend class Team; }; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 1ac6f624..981539ee 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -250,6 +250,9 @@ message MFVec3 property_subtype: 对象uniid value: 老等级 value2: 新等级 + property_type: 57 宝箱数量 + property_subtype: 对象uniid + value: 宝箱数量 */ message MFPropertyChg { @@ -411,6 +414,7 @@ message MFPlayerFull optional int32 armor_shield = 73; //护甲 optional int32 max_armor_shield = 74; //最大护甲 + optional int32 box_num = 75; //宝箱数量 } //阻挡物-部分 From 534c22990dcc977098ae19b7f679122f2b6c309a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Jul 2024 17:10:51 +0800 Subject: [PATCH 002/102] 1 --- server/gameserver/boxdrop.cc | 18 ++++++++++++++++++ server/gameserver/boxdrop.h | 15 +++++++++++++++ server/gameserver/room.cc | 16 ++++------------ server/gameserver/room.h | 7 +++---- 4 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 server/gameserver/boxdrop.cc create mode 100644 server/gameserver/boxdrop.h diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc new file mode 100644 index 00000000..f1a03737 --- /dev/null +++ b/server/gameserver/boxdrop.cc @@ -0,0 +1,18 @@ +#include "precompile.h" + +#include "boxdrop.h" + +BoxDrop::BoxDrop(Room* room):room_(room) +{ + +} + +void BoxDrop::Init() +{ + +} + +void BoxDrop::UnInit() +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h new file mode 100644 index 00000000..a0cc44e0 --- /dev/null +++ b/server/gameserver/boxdrop.h @@ -0,0 +1,15 @@ +#pragma once + +class Room; + +class BoxDrop : public std::enable_shared_from_this +{ + public: + + BoxDrop(Room* room); + void Init(); + void UnInit(); + + private: + Room* room_ = nullptr; +}; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 08c527f1..d8498a37 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(); @@ -4270,15 +4274,3 @@ void Room::MobaOver() OnGameOver(); } } - -int Room::GetMaxBoxNum() -{ - return max_box_num_; -} - -void Room::SetMaxBoxNum(int box_num) -{ - if (box_num > 0) { - max_box_num_ = box_num; - } -} diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 6dff8203..8467b067 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 { @@ -305,8 +306,7 @@ public: void CalcMvp(); long long GetMobaOvertimeRaceFrameNo () { return moba_overtime_race_frameno_; } void MobaOver(); - int GetMaxBoxNum(); - void SetMaxBoxNum(int box_num); + std::shared_ptr GetBoxDrop() { return box_drop_; } std::shared_ptr GetInGameVoice() { return ingame_voice_; } @@ -474,8 +474,7 @@ private: RoomAgent* room_agent_; std::shared_ptr ingame_voice_; - - int max_box_num_ = 0; + std::shared_ptr box_drop_; friend class Incubator; friend class Team; From 1fdbfcbdca16f8db740583693eab6fdafe2c3ab0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Jul 2024 17:32:01 +0800 Subject: [PATCH 003/102] 1 --- server/gameserver/boxdrop.cc | 10 ++++++++++ server/gameserver/boxdrop.h | 4 ++++ server/gameserver/hero.cc | 2 ++ server/gameserver/obstacle.cc | 7 ++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index f1a03737..13625f5d 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -16,3 +16,13 @@ void BoxDrop::UnInit() { } + +void BoxDrop::OnHeroDeadDrop(Hero* hero) +{ + +} + +void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index a0cc44e0..79af6dec 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -1,6 +1,8 @@ #pragma once class Room; +class Hero; +class Obstacle; class BoxDrop : public std::enable_shared_from_this { @@ -9,6 +11,8 @@ class BoxDrop : public std::enable_shared_from_this BoxDrop(Room* room); void Init(); void UnInit(); + void OnHeroDeadDrop(Hero* hero); + void OnObstacleDeadDrop(Obstacle* ob); private: Room* room_ = nullptr; 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/obstacle.cc b/server/gameserver/obstacle.cc index 5c2d0c51..61843d80 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); From b78e1c25420fdf3344a08d8b56b9e1a23bf33507 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Jul 2024 18:01:50 +0800 Subject: [PATCH 004/102] map 2009 ignore --- server/gameserver/mt/Map.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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(); } From 0731648ed883bc85c648e86f7df42165ecca0369 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Jul 2024 19:30:32 +0800 Subject: [PATCH 005/102] 1 --- server/gameserver/constant.h | 1 + 1 file changed, 1 insertion(+) diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index b9d942e0..9e4320d4 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -329,6 +329,7 @@ enum ObstacleType_e kObstacleStrengthenWall = 12, kObstacleMedicalStation = 13, kObstacleFlameSurface = 16, + kObstacleTreasureBox = 18, }; enum BulletHit_e From 60aa08a375a4249e541fb474ac6ca452a3612915 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 09:10:33 +0800 Subject: [PATCH 006/102] 1 --- server/gameserver/boxdrop.cc | 7 +++++++ server/gameserver/boxdrop.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 13625f5d..ce02dbe5 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -2,6 +2,8 @@ #include "boxdrop.h" +const int BOX_ID = 150001; + BoxDrop::BoxDrop(Room* room):room_(room) { @@ -26,3 +28,8 @@ void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) { } + +void BoxDrop::Drop(int num, const glm::vec3& center) +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 79af6dec..b0d4b105 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -14,6 +14,10 @@ class BoxDrop : public std::enable_shared_from_this void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); + private: + + void Drop(int num, const glm::vec3& center); + private: Room* room_ = nullptr; }; From d909066a76b25bb4a3ed38841b52aa10a219ef77 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 09:17:07 +0800 Subject: [PATCH 007/102] 1 --- server/gameserver/boxdrop.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index ce02dbe5..22723ed4 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -1,6 +1,7 @@ #include "precompile.h" #include "boxdrop.h" +#include "room.h" const int BOX_ID = 150001; @@ -31,5 +32,7 @@ void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) void BoxDrop::Drop(int num, const glm::vec3& center) { - + for (int i = 0; i < num; ++i) { + room_->CreateLoot(BOX_ID, center, center, 1, 1); + } } From c7fff6a7902c798719381c43190d476c6e04698e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 09:22:36 +0800 Subject: [PATCH 008/102] 1 --- server/gameserver/boxdrop.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 22723ed4..96665c85 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -2,6 +2,8 @@ #include "boxdrop.h" #include "room.h" +#include "hero.h" +#include "obstacle.h" const int BOX_ID = 150001; @@ -22,12 +24,12 @@ void BoxDrop::UnInit() void BoxDrop::OnHeroDeadDrop(Hero* hero) { - + Drop(1, hero->GetPos().ToGlmVec3()); } void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) { - + Drop(1, ob->GetPos().ToGlmVec3()); } void BoxDrop::Drop(int num, const glm::vec3& center) From 57422050fef93fe512633b1f75e38f6f0930156d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 09:54:37 +0800 Subject: [PATCH 009/102] 1 --- server/gameserver/boxdrop.cc | 3 ++- server/gameserver/commands.cc | 7 +++++++ server/gameserver/netdata.cc | 3 --- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 96665c85..c42c4499 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -35,6 +35,7 @@ void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) void BoxDrop::Drop(int num, const glm::vec3& center) { for (int i = 0; i < num; ++i) { - room_->CreateLoot(BOX_ID, center, center, 1, 1); + //room_->CreateLoot(BOX_ID, center, center, 1, 1); + room_->CreateObstacle(BOX_ID, center.x, center.y, center.z); } } diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 9152b39c..a17a3e90 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -25,6 +25,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) { @@ -410,6 +411,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]); diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 0b28b501..5828c627 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -1359,9 +1359,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) { From 30ec1bf9cb5e0d13f00c2078a8bfc6bbefa7509c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 11:21:42 +0800 Subject: [PATCH 010/102] 1 --- server/tools/protobuild/cs_proto.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 981539ee..e0c95acd 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -252,7 +252,8 @@ message MFVec3 value2: 新等级 property_type: 57 宝箱数量 property_subtype: 对象uniid - value: 宝箱数量 + value: 当前宝箱数量 + value2: 本次获得宝箱数(>0表现获得新的宝箱 <0表示死亡时掉落扣除的宝箱 ==0纯数据同步) */ message MFPropertyChg { From 4d8ea40d07ee497a499a35488dfc89953a9bb12f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 11:32:09 +0800 Subject: [PATCH 011/102] 1 --- server/gameserver/obstacle.cc | 10 ++++++++++ server/gameserver/obstacle.h | 1 + server/gameserver/pbutils.cc | 2 ++ 3 files changed, 13 insertions(+) diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index 61843d80..60ae43f7 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -298,6 +298,11 @@ bool Obstacle::DoInteraction(Human* sender) DoHideHouseInteraction(sender); } break; + case kObstacleTreasureBox: + { + DoTreasureBoxInteraction(sender); + } + break; default: { if (!IsDead(sender->room) && IsOpenInteraction()) { @@ -486,3 +491,8 @@ void Obstacle::SetRotate(float rotate) { rotate_ = rotate; } + +void Obstacle::DoTreasureBoxInteraction(Human* sender) +{ + +} 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..340c90e8 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -704,6 +704,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 +750,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); } From 2abae9c0f3ab3ca204bff4db107c712fb7237067 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 11:38:55 +0800 Subject: [PATCH 012/102] 1 --- server/gameserver/obstacle.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index 60ae43f7..d004b791 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -494,5 +494,24 @@ void Obstacle::SetRotate(float rotate) void Obstacle::DoTreasureBoxInteraction(Human* sender) { - + if (!IsDead(sender->room)) { + 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); + } } From 3c08d8e96ccebc3569499cb699d1d5d593ac419a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 13:19:54 +0800 Subject: [PATCH 013/102] 1 --- server/gameserver/creature.h | 2 +- server/gameserver/obstacle.cc | 3 +++ server/tools/protobuild/cs_proto.proto | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 370c71fe..d1b25778 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -99,7 +99,7 @@ class Creature : public MoveableEntity int max_armor_shield = 0; int revive_count = 0; CreatureWeakPtr master; - int box_num; + int box_num = 0; Weapon second_weapon; glm::vec3 skill_pos; diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index d004b791..60816fe3 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -495,6 +495,9 @@ void Obstacle::SetRotate(float rotate) void Obstacle::DoTreasureBoxInteraction(Human* sender) { if (!IsDead(sender->room)) { + ++sender->box_num; + 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 diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index e0c95acd..e6aaf942 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -251,7 +251,6 @@ message MFVec3 value: 老等级 value2: 新等级 property_type: 57 宝箱数量 - property_subtype: 对象uniid value: 当前宝箱数量 value2: 本次获得宝箱数(>0表现获得新的宝箱 <0表示死亡时掉落扣除的宝箱 ==0纯数据同步) */ From db1e076e5108428d5053b4d9703ac92ac3480d4d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 13:38:05 +0800 Subject: [PATCH 014/102] 1 --- server/gameserver/mt/MapMode.h | 1 + 1 file changed, 1 insertion(+) 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", From d4beb8537aaa2919edc2728735abdf294f292ca2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 15:48:51 +0800 Subject: [PATCH 015/102] 1 --- server/gameserver/boxdrop.cc | 28 +++++++++++++++++++++++++--- server/gameserver/boxdrop.h | 3 +++ server/gameserver/room.cc | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index c42c4499..1f210a60 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -5,6 +5,8 @@ #include "hero.h" #include "obstacle.h" +#include "mt/MapMode.h" + const int BOX_ID = 150001; BoxDrop::BoxDrop(Room* room):room_(room) @@ -14,7 +16,18 @@ BoxDrop::BoxDrop(Room* room):room_(room) void BoxDrop::Init() { - + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx + (SERVER_FRAME_RATE * 10, + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { + } + } + }, + &room_->xtimer_attacher_); + } } void BoxDrop::UnInit() @@ -24,12 +37,16 @@ void BoxDrop::UnInit() void BoxDrop::OnHeroDeadDrop(Hero* hero) { - Drop(1, hero->GetPos().ToGlmVec3()); + if (box_num_ > 0) { + Drop(1, hero->GetPos().ToGlmVec3()); + } } void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) { - Drop(1, ob->GetPos().ToGlmVec3()); + if (box_num_ > 0) { + Drop(1, ob->GetPos().ToGlmVec3()); + } } void BoxDrop::Drop(int num, const glm::vec3& center) @@ -39,3 +56,8 @@ void BoxDrop::Drop(int num, const glm::vec3& center) room_->CreateObstacle(BOX_ID, center.x, center.y, center.z); } } + +void BoxDrop::OnBattleStart() +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index b0d4b105..6a3b90e3 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -11,6 +11,7 @@ class BoxDrop : public std::enable_shared_from_this BoxDrop(Room* room); void Init(); void UnInit(); + void OnBattleStart(); void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); @@ -20,4 +21,6 @@ class BoxDrop : public std::enable_shared_from_this private: Room* room_ = nullptr; + a8::XTimerWp get_box_num_timer_; + int box_num_ = 0; }; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index d8498a37..4a06f5db 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -3216,6 +3216,7 @@ void Room::OnBattleStart() } battle_starting_ = false; SendSMTeamFull(nullptr); + GetBoxDrop()->OnBattleStart(); } bool Room::CanAddObstacle(const glm::vec3& pos, int obstacle_id) From b586ab8ec9ac4bc1c6d38b0a7af99e0f9fd8b4a6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 15:59:36 +0800 Subject: [PATCH 016/102] 1 --- server/gameserver/boxdrop.cc | 62 ++++++++++++++++++++++++++++++++++++ server/gameserver/boxdrop.h | 1 + 2 files changed, 63 insertions(+) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 1f210a60..6a1af057 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -1,9 +1,15 @@ #include "precompile.h" +#include + +#include + #include "boxdrop.h" #include "room.h" #include "hero.h" #include "obstacle.h" +#include "httpproxy.h" +#include "jsondatamgr.h" #include "mt/MapMode.h" @@ -23,6 +29,7 @@ void BoxDrop::Init() { if (a8::TIMER_EXEC_EVENT == event) { if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { + RequestBoxNum(); } } }, @@ -61,3 +68,58 @@ void BoxDrop::OnBattleStart() { } + +void BoxDrop::RequestBoxNum() +{ + std::string url; + JsonDataMgr::Instance()->GetApiUrl(url); + /* + if (custom_room_type == CUSTOM_ROOM_CUSTOM) { + if (url.find('?') != std::string::npos) { + url += "&c=Battle&a=getCustomBattleDataNew"; + } else { + url += "?&c=Battle&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"; + } + } 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()); + HttpProxy::Instance()->HttpGet + ( + [] + (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + { + if (ok) { + f8::UdpLog::Instance()->Info + ("GetBattleData ok %s", + { + rsp_obj->ToJsonStr() + }); + if (rsp_obj->GetType() != a8::XOT_OBJECT || + !rsp_obj->HasKey("errcode")) { + //cb(1, "", nullptr); + return; + } + } else { + f8::UdpLog::Instance()->Warning + ("GetCustomBattleData error %s", + { + "" + }); + //cb(1, "custom battle data error", nullptr); + } + }, + url.c_str(), + *url_params + ); +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 6a3b90e3..09126b0b 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -18,6 +18,7 @@ class BoxDrop : public std::enable_shared_from_this private: void Drop(int num, const glm::vec3& center); + void RequestBoxNum(); private: Room* room_ = nullptr; From f9cc27e85c60dd8b9bcb5a7326a406061adc6ccb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 16:42:52 +0800 Subject: [PATCH 017/102] 1 --- server/gameserver/boxdrop.cc | 59 +++++++++++++++--------------------- server/gameserver/boxdrop.h | 5 ++- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 6a1af057..a37cb12f 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -2,6 +2,7 @@ #include +#include #include #include "boxdrop.h" @@ -22,19 +23,6 @@ BoxDrop::BoxDrop(Room* room):room_(room) void BoxDrop::Init() { - if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { - get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx - (SERVER_FRAME_RATE * 10, - [this] (int event, const a8::Args* args) - { - if (a8::TIMER_EXEC_EVENT == event) { - if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { - RequestBoxNum(); - } - } - }, - &room_->xtimer_attacher_); - } } void BoxDrop::UnInit() @@ -66,34 +54,30 @@ void BoxDrop::Drop(int num, const glm::vec3& center) void BoxDrop::OnBattleStart() { - + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx + (SERVER_FRAME_RATE * 10, + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { + RequestAllocBoxNum(); + } + } + }, + &room_->xtimer_attacher_); + } } -void BoxDrop::RequestBoxNum() +void BoxDrop::RequestAllocBoxNum() { std::string url; JsonDataMgr::Instance()->GetApiUrl(url); - /* - if (custom_room_type == CUSTOM_ROOM_CUSTOM) { - if (url.find('?') != std::string::npos) { - url += "&c=Battle&a=getCustomBattleDataNew"; - } else { - url += "?&c=Battle&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"; - } - } else { - A8_ABORT(); - }*/ + int nowtime = f8::App::Instance()->GetNowTime(); 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()); + url_params->SetVal("c", "Battle"); + url_params->SetVal("a", "requestBoxNum"); + url_params->SetVal("timestamp", a8::XValue(nowtime)); HttpProxy::Instance()->HttpGet ( [] @@ -123,3 +107,8 @@ void BoxDrop::RequestBoxNum() *url_params ); } + +void BoxDrop::RequestReturnBoxNum() +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 09126b0b..056ec446 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -14,14 +14,17 @@ class BoxDrop : public std::enable_shared_from_this void OnBattleStart(); void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); + void RequestReturnBoxNum(); private: void Drop(int num, const glm::vec3& center); - void RequestBoxNum(); + void RequestAllocBoxNum(); private: Room* room_ = nullptr; a8::XTimerWp get_box_num_timer_; int box_num_ = 0; + int alloc_box_num_ = 0; + bool returned_ = false; }; From be4a0d0bdf29cba2a861c9882ee081ba42df1c5b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 16:46:21 +0800 Subject: [PATCH 018/102] 1 --- server/gameserver/room.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 4a06f5db..2caafb86 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -4147,6 +4147,7 @@ void Room::TryRoomReport(int try_count) *params.get(), content ); + GetBoxDrop()->RequestReturnBoxNum(); #ifdef MYDEBUG a8::XPrintf("RoomReportLen:%d\n", {params->ToJsonStr().size()}); #endif From b79e9ce548f1e8bd8b5d3d4d546447ee4d73eddc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 17:20:59 +0800 Subject: [PATCH 019/102] 1 --- server/bin/gameserver/dev_config/setting.json | 3 +- .../bin/gameserver/test_config/setting.json | 3 +- server/gameserver/boxdrop.cc | 45 ++++++++++++++++++- server/gameserver/jsondatamgr.cc | 1 + server/gameserver/jsondatamgr.h | 2 + 5 files changed, 50 insertions(+), 4 deletions(-) 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/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index a37cb12f..2a6f6438 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -76,7 +76,7 @@ void BoxDrop::RequestAllocBoxNum() int nowtime = f8::App::Instance()->GetNowTime(); auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Battle"); - url_params->SetVal("a", "requestBoxNum"); + url_params->SetVal("a", "requestAllocBoxNum"); url_params->SetVal("timestamp", a8::XValue(nowtime)); HttpProxy::Instance()->HttpGet ( @@ -110,5 +110,46 @@ void BoxDrop::RequestAllocBoxNum() void BoxDrop::RequestReturnBoxNum() { - + if (alloc_box_num_ <= 0) { + return; + } + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + if (returned_) { + return; + } + returned_ = true; + std::string url; + JsonDataMgr::Instance()->GetApiUrl(url); + auto url_params = a8::MutableXObject::CreateObject(); + url_params->SetVal("c", "Battle"); + url_params->SetVal("a", "requestReturnBoxNum"); + HttpProxy::Instance()->HttpGet + ( + [] + (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + { + if (ok) { + f8::UdpLog::Instance()->Info + ("GetBattleData ok %s", + { + rsp_obj->ToJsonStr() + }); + if (rsp_obj->GetType() != a8::XOT_OBJECT || + !rsp_obj->HasKey("errcode")) { + //cb(1, "", nullptr); + return; + } + } else { + f8::UdpLog::Instance()->Warning + ("GetCustomBattleData error %s", + { + "" + }); + //cb(1, "custom battle data error", nullptr); + } + }, + url.c_str(), + *url_params + ); + } } 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"; From 5d6c65f2a49aeb3ec81a55d326fb4e792c2182a1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 17:41:12 +0800 Subject: [PATCH 020/102] 1 --- server/gameserver/pbutils.cc | 62 ------------------------------------ 1 file changed, 62 deletions(-) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 340c90e8..bab6eee1 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -1664,68 +1664,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); From 89dbb3a3d09d49143bcded2286b2187773f92b44 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 17:51:55 +0800 Subject: [PATCH 021/102] 1 --- server/gameserver/boxdrop.cc | 4 ++-- server/gameserver/httpproxy.cc | 6 +++--- server/gameserver/httpproxy.h | 2 +- server/gameserver/human.cc | 2 +- server/gameserver/player.cc | 2 +- server/gameserver/roommgr.cc | 2 +- server/gameserver/team.cc | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 2a6f6438..1c1ec88a 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -104,7 +104,7 @@ void BoxDrop::RequestAllocBoxNum() } }, url.c_str(), - *url_params + url_params ); } @@ -149,7 +149,7 @@ void BoxDrop::RequestReturnBoxNum() } }, url.c_str(), - *url_params + url_params ); } } diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index b2920cc5..c1a4c728 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -64,7 +64,7 @@ void HttpProxy::UnInit() std::string HttpProxy::HttpGet( f8::HttpProxyCb cb, const char* url, - a8::XObject url_params + std::shared_ptr url_params ) { if (f8::App::Instance()->Terminated()) { @@ -74,7 +74,7 @@ std::string HttpProxy::HttpGet( request->req_id = CreateRequestId(); request->cb = cb; request->url = url; - request->url_params = url_params; + request->url_params = *url_params; request->add_tick = a8::XGetTickCount(); if (request_hash_.find(request->req_id) != request_hash_.end()) { abort(); @@ -85,7 +85,7 @@ std::string HttpProxy::HttpGet( 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, diff --git a/server/gameserver/httpproxy.h b/server/gameserver/httpproxy.h index d4855a40..05a35de3 100644 --- a/server/gameserver/httpproxy.h +++ b/server/gameserver/httpproxy.h @@ -20,7 +20,7 @@ class HttpProxy : public a8::Singleton std::string HttpGet( f8::HttpProxyCb cb, const char* url, - a8::XObject url_params + std::shared_ptr url_params ); std::string HttpPost( f8::HttpProxyCb cb, diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index fa89c33e..0a16500f 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -3671,7 +3671,7 @@ void Human::SendPersonalBattleReport() } }, url.c_str(), - *params.get() + params ); } diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 30448806..bf25b12c 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1428,7 +1428,7 @@ void Player::_CMRevive(f8::MsgHdr* hdr, const cs::CMRevive& msg) } }, url.c_str(), - *url_params + url_params ); } } diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index a5cca8f1..368d0e22 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -669,7 +669,7 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, } }, url.c_str(), - *url_params + url_params ); } } diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index 22692563..b09bcf63 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -269,7 +269,7 @@ void Team::SendTeamBattleReport(Human* sender) } }, url.c_str(), - *params.get() + params ); } From b68eff5b5e1806cabbe681501b9a93fe23ba7223 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 17:56:24 +0800 Subject: [PATCH 022/102] 1 --- server/gameserver/httpproxy.cc | 6 +++--- server/gameserver/httpproxy.h | 2 +- server/gameserver/room.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index c1a4c728..db0db9b1 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -129,7 +129,7 @@ std::string HttpProxy::HttpGet( std::string HttpProxy::HttpPost( f8::HttpProxyCb cb, const char* url, - a8::XObject url_params, + std::shared_ptr url_params, const std::string& content ) { @@ -140,7 +140,7 @@ std::string HttpProxy::HttpPost( request->req_id = CreateRequestId(); request->cb = cb; request->url = url; - request->url_params = url_params; + request->url_params = *url_params; request->add_tick = a8::XGetTickCount(); if (request_hash_.find(request->req_id) != request_hash_.end()) { abort(); @@ -151,7 +151,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, diff --git a/server/gameserver/httpproxy.h b/server/gameserver/httpproxy.h index 05a35de3..9c90d729 100644 --- a/server/gameserver/httpproxy.h +++ b/server/gameserver/httpproxy.h @@ -25,7 +25,7 @@ class HttpProxy : public a8::Singleton std::string HttpPost( f8::HttpProxyCb cb, const char* url, - a8::XObject url_params, + std::shared_ptr url_params, const std::string& content ); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 2caafb86..47bb36c0 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -2266,7 +2266,7 @@ void Room::TryMobaReport(int try_count) } }, url.c_str(), - *params.get(), + params, content ); #ifdef MYDEBUG @@ -4144,7 +4144,7 @@ void Room::TryRoomReport(int try_count) } }, url.c_str(), - *params.get(), + params, content ); GetBoxDrop()->RequestReturnBoxNum(); From 5fe5887d22611c4c731b752e7ad65a183108c39e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 18:05:46 +0800 Subject: [PATCH 023/102] =?UTF-8?q?=E5=AE=8C=E6=88=90ca=E6=AD=A3=E8=A7=84?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 7 ++----- server/gameserver/player.cc | 7 ++----- server/gameserver/room.cc | 14 ++++---------- server/gameserver/roommgr.cc | 15 ++++----------- server/gameserver/team.cc | 7 ++----- 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 0a16500f..1fd606d1 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -3650,11 +3650,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 diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index bf25b12c..2d161588 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1378,12 +1378,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); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 47bb36c0..4754ff94 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -2236,13 +2236,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()); @@ -4113,14 +4110,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(); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 368d0e22..cb366433 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -596,22 +596,15 @@ 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); diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index b09bcf63..0c2119d1 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -211,12 +211,9 @@ 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()); From cb97623222c2845b83ea3830cb5c705036a7b81b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 18:38:09 +0800 Subject: [PATCH 024/102] =?UTF-8?q?POST=E6=AD=A3=E8=A7=84=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/roommgr.cc | 7 ++++--- server/gameserver/team.cc | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index cb366433..397b9ea2 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -608,8 +608,8 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, 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()); - HttpProxy::Instance()->HttpGet + //url_params->SetVal("__POST", join_msg->payload_data()); + HttpProxy::Instance()->HttpPost ( [cb, custom_room_type] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) @@ -662,7 +662,8 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, } }, url.c_str(), - url_params + url_params, + join_msg->payload_data() ); } } diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index 0c2119d1..17c345a0 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -216,7 +216,7 @@ void Team::SendTeamBattleReport(Human* sender) 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(); @@ -232,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) @@ -266,7 +266,8 @@ void Team::SendTeamBattleReport(Human* sender) } }, url.c_str(), - params + params, + post_data->ToJsonStr() ); } From 9cd4413b8c4593fd71f8ca31107624fbb1e9c288 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 18:48:31 +0800 Subject: [PATCH 025/102] 1 --- server/gameserver/httpproxy.cc | 23 +++++++++++++++-------- server/gameserver/httpproxy.h | 2 ++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index db0db9b1..a387b081 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -18,7 +18,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; }; @@ -70,18 +70,18 @@ std::string HttpProxy::HttpGet( if (f8::App::Instance()->Terminated()) { return ""; } + AddSignParams(url, 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->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; - 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)); @@ -104,7 +104,7 @@ std::string HttpProxy::HttpGet( { cost_time, request->url, - request->url_params.ToJsonStr(), + request->url_params->ToJsonStr(), }); #endif } else { @@ -112,7 +112,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); @@ -136,11 +136,12 @@ std::string HttpProxy::HttpPost( 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; request->url = url; - request->url_params = *url_params; + request->url_params = url_params; request->add_tick = a8::XGetTickCount(); if (request_hash_.find(request->req_id) != request_hash_.end()) { abort(); @@ -172,7 +173,7 @@ std::string HttpProxy::HttpPost( { cost_time, request->url, - request->url_params.ToJsonStr(), + request->url_params->ToJsonStr(), }); #endif } else { @@ -180,7 +181,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 +212,9 @@ void HttpProxy::DestoryRequest(std::shared_ptr request) { request_hash_.erase(request->req_id); } + +void HttpProxy::AddSignParams(const char* url, + std::shared_ptr url_params, const std::string& post_data) +{ + +} diff --git a/server/gameserver/httpproxy.h b/server/gameserver/httpproxy.h index 9c90d729..f7a4902e 100644 --- a/server/gameserver/httpproxy.h +++ b/server/gameserver/httpproxy.h @@ -35,6 +35,8 @@ class HttpProxy : public a8::Singleton private: std::string CreateRequestId(); + void AddSignParams(const char* url, + std::shared_ptr url_params, const std::string& post_data); private: std::map> request_hash_; From 6aa85ac3707a15f7fb6f30b2b5099117ce586ff2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 18:56:44 +0800 Subject: [PATCH 026/102] 1 --- server/gameserver/boxdrop.cc | 4 ++-- server/gameserver/httpproxy.cc | 6 +++--- server/gameserver/httpproxy.h | 6 +++--- server/gameserver/human.cc | 2 +- server/gameserver/player.cc | 2 +- server/gameserver/room.cc | 4 ++-- server/gameserver/roommgr.cc | 2 +- server/gameserver/team.cc | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 1c1ec88a..ac5a8514 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -103,7 +103,7 @@ void BoxDrop::RequestAllocBoxNum() //cb(1, "custom battle data error", nullptr); } }, - url.c_str(), + url, url_params ); } @@ -148,7 +148,7 @@ void BoxDrop::RequestReturnBoxNum() //cb(1, "custom battle data error", nullptr); } }, - url.c_str(), + url, url_params ); } diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index a387b081..de9c0cb9 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -63,7 +63,7 @@ void HttpProxy::UnInit() std::string HttpProxy::HttpGet( f8::HttpProxyCb cb, - const char* url, + const std::string& url, std::shared_ptr url_params ) { @@ -128,7 +128,7 @@ std::string HttpProxy::HttpGet( std::string HttpProxy::HttpPost( f8::HttpProxyCb cb, - const char* url, + const std::string& url, std::shared_ptr url_params, const std::string& content ) @@ -213,7 +213,7 @@ void HttpProxy::DestoryRequest(std::shared_ptr request) request_hash_.erase(request->req_id); } -void HttpProxy::AddSignParams(const char* url, +void HttpProxy::AddSignParams(const std::string& url, std::shared_ptr url_params, const std::string& post_data) { diff --git a/server/gameserver/httpproxy.h b/server/gameserver/httpproxy.h index f7a4902e..01ddaf9e 100644 --- a/server/gameserver/httpproxy.h +++ b/server/gameserver/httpproxy.h @@ -19,12 +19,12 @@ class HttpProxy : public a8::Singleton std::string HttpGet( f8::HttpProxyCb cb, - const char* url, + const std::string& url, std::shared_ptr url_params ); std::string HttpPost( f8::HttpProxyCb cb, - const char* url, + const std::string& url, std::shared_ptr url_params, const std::string& content ); @@ -35,7 +35,7 @@ class HttpProxy : public a8::Singleton private: std::string CreateRequestId(); - void AddSignParams(const char* url, + void AddSignParams(const std::string& url, std::shared_ptr url_params, const std::string& post_data); private: diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 1fd606d1..90c704c9 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -3667,7 +3667,7 @@ void Human::SendPersonalBattleReport() }); } }, - url.c_str(), + url, params ); } diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 2d161588..8e4dfd84 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1424,7 +1424,7 @@ void Player::_CMRevive(f8::MsgHdr* hdr, const cs::CMRevive& msg) a8::UnSetBitFlag(hum->status, CS_Reviving); } }, - url.c_str(), + url, url_params ); } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 4754ff94..e5c284ac 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -2262,7 +2262,7 @@ void Room::TryMobaReport(int try_count) }); } }, - url.c_str(), + url, params, content ); @@ -4137,7 +4137,7 @@ void Room::TryRoomReport(int try_count) room->StartOverTimer(); } }, - url.c_str(), + url, params, content ); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 397b9ea2..e6445746 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -661,7 +661,7 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, cb(1, "custom battle data error", nullptr); } }, - url.c_str(), + url, url_params, join_msg->payload_data() ); diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index 17c345a0..b1f2a3d0 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -265,7 +265,7 @@ void Team::SendTeamBattleReport(Human* sender) } } }, - url.c_str(), + url, params, post_data->ToJsonStr() ); From 360ec469610e2302012f827d7f6c806f016aa713 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 19:21:56 +0800 Subject: [PATCH 027/102] 1 --- server/gameserver/httpproxy.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index de9c0cb9..c8e6905f 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -216,5 +217,25 @@ void HttpProxy::DestoryRequest(std::shared_ptr request) 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 * 10); + 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); } From 2884fdc92a521520223b6c353c81cd7457ff6eb4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 19:42:36 +0800 Subject: [PATCH 028/102] 1 --- server/gameserver/roommgr.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index e6445746..c489b220 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -608,8 +608,14 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, 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()); - HttpProxy::Instance()->HttpPost + 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] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) @@ -662,8 +668,7 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr join_msg, } }, url, - url_params, - join_msg->payload_data() + url_params ); } } From 0c9671ac5c3a5b07a6be843d8ec4820db46ea0ed Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 19:48:35 +0800 Subject: [PATCH 029/102] 1 --- server/gameserver/boxdrop.cc | 9 +++++++-- server/gameserver/boxdrop.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index ac5a8514..c32130b2 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -32,14 +32,14 @@ void BoxDrop::UnInit() void BoxDrop::OnHeroDeadDrop(Hero* hero) { - if (box_num_ > 0) { + if (GetRemainNum() > 0) { Drop(1, hero->GetPos().ToGlmVec3()); } } void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) { - if (box_num_ > 0) { + if (GetRemainNum() > 0) { Drop(1, ob->GetPos().ToGlmVec3()); } } @@ -153,3 +153,8 @@ void BoxDrop::RequestReturnBoxNum() ); } } + +int BoxDrop::GetRemainNum() +{ + return std::max(0, alloc_box_num_ - used_num_); +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 056ec446..9dee3435 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -20,11 +20,12 @@ class BoxDrop : public std::enable_shared_from_this void Drop(int num, const glm::vec3& center); void RequestAllocBoxNum(); + int GetRemainNum(); private: Room* room_ = nullptr; a8::XTimerWp get_box_num_timer_; - int box_num_ = 0; + int used_num_ = 0; int alloc_box_num_ = 0; bool returned_ = false; }; From 7f31959e06512420e163e1919f180a4648c73617 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 19:52:10 +0800 Subject: [PATCH 030/102] 1 --- server/gameserver/boxdrop.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index c32130b2..930063fb 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -73,11 +73,10 @@ void BoxDrop::RequestAllocBoxNum() { std::string url; JsonDataMgr::Instance()->GetApiUrl(url); - int nowtime = f8::App::Instance()->GetNowTime(); auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Battle"); url_params->SetVal("a", "requestAllocBoxNum"); - url_params->SetVal("timestamp", a8::XValue(nowtime)); + url_params->SetVal("room_uuid", room_->GetRoomUuid()); HttpProxy::Instance()->HttpGet ( [] @@ -123,6 +122,7 @@ void BoxDrop::RequestReturnBoxNum() auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Battle"); url_params->SetVal("a", "requestReturnBoxNum"); + url_params->SetVal("room_uuid", room_->GetRoomUuid()); HttpProxy::Instance()->HttpGet ( [] From e842a5b7cefba242d7704181e31e85cc9322ea53 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 19:56:38 +0800 Subject: [PATCH 031/102] 1 --- server/gameserver/boxdrop.cc | 5 +++++ server/gameserver/boxdrop.h | 1 + 2 files changed, 6 insertions(+) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 930063fb..90463584 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -158,3 +158,8 @@ int BoxDrop::GetRemainNum() { return std::max(0, alloc_box_num_ - used_num_); } + +bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id) +{ + return true; +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 9dee3435..93bfc305 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -21,6 +21,7 @@ class BoxDrop : public std::enable_shared_from_this void Drop(int num, const glm::vec3& center); void RequestAllocBoxNum(); int GetRemainNum(); + bool FillAccountIdSessionId(std::string account_id, std::string session_id); private: Room* room_ = nullptr; From d7eaa2b5d6e6586702da031aa053fc47292a7449 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 20:10:05 +0800 Subject: [PATCH 032/102] 1 --- server/gameserver/boxdrop.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 90463584..7dadef27 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -11,6 +11,7 @@ #include "obstacle.h" #include "httpproxy.h" #include "jsondatamgr.h" +#include "player.h" #include "mt/MapMode.h" @@ -71,12 +72,20 @@ void BoxDrop::OnBattleStart() 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 ( [] @@ -117,12 +126,21 @@ void BoxDrop::RequestReturnBoxNum() 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("room_uuid", room_->GetRoomUuid()); + url_params->SetVal("account_id", account_id); + url_params->SetVal("session_id", session_id); HttpProxy::Instance()->HttpGet ( [] @@ -161,5 +179,13 @@ int BoxDrop::GetRemainNum() bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id) { - return true; + bool ok = false; + room_->TraversePlayerList + ([&ok, &account_id, &session_id] (Player* hum) + { + ok = true; + account_id = hum->account_id; + session_id = hum->session_id; + }); + return ok; } From cf4689b3738ec1b2b1042e49c992edf612c76981 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 09:24:05 +0800 Subject: [PATCH 033/102] 1 --- server/gameserver/batchsync.cc | 3 ++- server/gameserver/boxdrop.cc | 3 ++- server/gameserver/incubator.cc | 2 +- server/gameserver/pbutils.cc | 6 ++++-- server/gameserver/player.cc | 3 ++- server/gameserver/room.cc | 9 ++++++--- server/gameserver/room.h | 2 +- 7 files changed, 18 insertions(+), 10 deletions(-) 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 index 7dadef27..30a0497b 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -181,11 +181,12 @@ bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session { bool ok = false; room_->TraversePlayerList - ([&ok, &account_id, &session_id] (Player* hum) + ([&ok, &account_id, &session_id] (Player* hum) -> bool { ok = true; account_id = hum->account_id; session_id = hum->session_id; + return true; }); return ok; } 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/pbutils.cc b/server/gameserver/pbutils.cc index bab6eee1..e0684b8c 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2514,9 +2514,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; }); } @@ -2529,9 +2530,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 8e4dfd84..0c867914 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1316,9 +1316,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); } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index e5c284ac..a65d342a 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1231,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; + } } } } @@ -3678,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, @@ -3700,6 +3702,7 @@ void Room::GMFastForward() grid_service->MoveCreature(hum); } } + return true; }); GetIncubator()->Clear(5); TraverseHumanList diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 8467b067..97496a81 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -154,7 +154,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); From ba2809123f4a68e6f16524a44d22e2b7823405d2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 09:26:36 +0800 Subject: [PATCH 034/102] 1 --- server/gameserver/boxdrop.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 30a0497b..8340b736 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -56,8 +56,8 @@ void BoxDrop::Drop(int num, const glm::vec3& center) void BoxDrop::OnBattleStart() { if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { - get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx - (SERVER_FRAME_RATE * 10, + get_box_num_timer_ = room_->xtimer.SetIntervalWpEx + (SERVER_FRAME_RATE * 20, [this] (int event, const a8::Args* args) { if (a8::TIMER_EXEC_EVENT == event) { From db0d36269e2f776e1cb22129e71aa40eaa011f9a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 09:43:42 +0800 Subject: [PATCH 035/102] 1 --- server/gameserver/boxdrop.cc | 10 ++++------ server/gameserver/httpproxy.cc | 2 +- server/gameserver/room.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 8340b736..2103a353 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -93,22 +93,20 @@ void BoxDrop::RequestAllocBoxNum() { if (ok) { f8::UdpLog::Instance()->Info - ("GetBattleData ok %s", + ("RequestAllocBoxNum ok %s", { rsp_obj->ToJsonStr() - }); + }); if (rsp_obj->GetType() != a8::XOT_OBJECT || !rsp_obj->HasKey("errcode")) { - //cb(1, "", nullptr); return; } } else { f8::UdpLog::Instance()->Warning - ("GetCustomBattleData error %s", + ("RequestAllocBoxNum error %s", { "" - }); - //cb(1, "custom battle data error", nullptr); + }); } }, url, diff --git a/server/gameserver/httpproxy.cc b/server/gameserver/httpproxy.cc index c8e6905f..dcfdddf5 100644 --- a/server/gameserver/httpproxy.cc +++ b/server/gameserver/httpproxy.cc @@ -221,7 +221,7 @@ void HttpProxy::AddSignParams(const std::string& url, A8_ABORT(); } std::string sign_data; - sign_data.reserve(1024 * 10); + sign_data.reserve(1024 * 64); int nowtime = f8::App::Instance()->GetNowTime(); { std::vector keys; diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 97496a81..944f9fae 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -76,7 +76,7 @@ enum RoomSwitch_e kRoomSwitchDisableShot, }; -class Room +class Room : public std::enable_shared_from_this { public: FrameEvent frame_event; From 3058200cd644599236039dc0727f43dddcadc6e4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 09:50:40 +0800 Subject: [PATCH 036/102] 1 --- server/gameserver/boxdrop.cc | 11 ++++++++++- server/gameserver/boxdrop.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 2103a353..50f4e692 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -88,7 +88,7 @@ void BoxDrop::RequestAllocBoxNum() url_params->SetVal("session_id", session_id); HttpProxy::Instance()->HttpGet ( - [] + [room_wp = room_->weak_from_this()] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) { if (ok) { @@ -101,6 +101,10 @@ void BoxDrop::RequestAllocBoxNum() !rsp_obj->HasKey("errcode")) { return; } + if (!room_wp.expired()) { + auto room = room_wp.lock(); + room->GetBoxDrop()->OnAllocOk(0); + } } else { f8::UdpLog::Instance()->Warning ("RequestAllocBoxNum error %s", @@ -188,3 +192,8 @@ bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session }); return ok; } + +void BoxDrop::OnAllocOk(int box_num) +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 93bfc305..524a82d8 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -22,6 +22,7 @@ class BoxDrop : public std::enable_shared_from_this void RequestAllocBoxNum(); int GetRemainNum(); bool FillAccountIdSessionId(std::string account_id, std::string session_id); + void OnAllocOk(int box_num); private: Room* room_ = nullptr; From b0a183cc45e7b4c8eab300f45c56bba88eeb9e93 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 09:52:13 +0800 Subject: [PATCH 037/102] 1 --- server/gameserver/boxdrop.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 50f4e692..930242fc 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -103,7 +103,8 @@ void BoxDrop::RequestAllocBoxNum() } if (!room_wp.expired()) { auto room = room_wp.lock(); - room->GetBoxDrop()->OnAllocOk(0); + int box_num = rsp_obj->Get("box_num").GetInt(); + room->GetBoxDrop()->OnAllocOk(box_num); } } else { f8::UdpLog::Instance()->Warning From 26dff62dd1d8be11d3066e7f896f5e27d93d87e2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 09:56:02 +0800 Subject: [PATCH 038/102] 1 --- server/gameserver/boxdrop.cc | 13 +++++++++++-- server/gameserver/boxdrop.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 930242fc..032ae78c 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -103,8 +103,12 @@ void BoxDrop::RequestAllocBoxNum() } if (!room_wp.expired()) { auto room = room_wp.lock(); - int box_num = rsp_obj->Get("box_num").GetInt(); - room->GetBoxDrop()->OnAllocOk(box_num); + 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 @@ -198,3 +202,8 @@ void BoxDrop::OnAllocOk(int box_num) { } + +void BoxDrop::OnAllocFail() +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 524a82d8..1116aa09 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -23,6 +23,7 @@ class BoxDrop : public std::enable_shared_from_this int GetRemainNum(); bool FillAccountIdSessionId(std::string account_id, std::string session_id); void OnAllocOk(int box_num); + void OnAllocFail(); private: Room* room_ = nullptr; From 1e328fb0daefc003348809884d92b7c7e3156308 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 09:58:48 +0800 Subject: [PATCH 039/102] 1 --- server/gameserver/boxdrop.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 032ae78c..b9e2666f 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -200,10 +200,14 @@ bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session void BoxDrop::OnAllocOk(int box_num) { - + if (!get_box_num_timer_.expired()) { + room_->xtimer.Delete(get_box_num_timer_); + } } void BoxDrop::OnAllocFail() { - + if (!get_box_num_timer_.expired()) { + room_->xtimer.Delete(get_box_num_timer_); + } } From 4f415520b66e0a72900440cbfa711014c319dc8e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 10:04:57 +0800 Subject: [PATCH 040/102] 1 --- server/gameserver/boxdrop.cc | 15 +++++++++++---- server/gameserver/boxdrop.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index b9e2666f..775d8931 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -86,15 +86,17 @@ void BoxDrop::RequestAllocBoxNum() url_params->SetVal("room_uuid", room_->GetRoomUuid()); url_params->SetVal("account_id", account_id); url_params->SetVal("session_id", session_id); + std::string room_uuid = room_->GetRoomUuid(); HttpProxy::Instance()->HttpGet ( - [room_wp = room_->weak_from_this()] + [room_wp = room_->weak_from_this(), room_uuid] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) { if (ok) { f8::UdpLog::Instance()->Info - ("RequestAllocBoxNum ok %s", + ("RequestAllocBoxNum ok room_uuid:%s %s", { + room_uuid, rsp_obj->ToJsonStr() }); if (rsp_obj->GetType() != a8::XOT_OBJECT || @@ -112,9 +114,9 @@ void BoxDrop::RequestAllocBoxNum() } } else { f8::UdpLog::Instance()->Warning - ("RequestAllocBoxNum error %s", + ("RequestAllocBoxNum error room_uuid:%s", { - "" + room_uuid }); } }, @@ -203,6 +205,11 @@ 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; } void BoxDrop::OnAllocFail() diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 1116aa09..8bb2e2bf 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -30,5 +30,6 @@ class BoxDrop : public std::enable_shared_from_this a8::XTimerWp get_box_num_timer_; int used_num_ = 0; int alloc_box_num_ = 0; + bool alloced_ = false; bool returned_ = false; }; From f0f4248806864266d3387e7bbe46ebe09910a6be Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 10:19:01 +0800 Subject: [PATCH 041/102] 1 --- server/gameserver/boxdrop.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 775d8931..2feb809a 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -86,10 +86,9 @@ void BoxDrop::RequestAllocBoxNum() url_params->SetVal("room_uuid", room_->GetRoomUuid()); url_params->SetVal("account_id", account_id); url_params->SetVal("session_id", session_id); - std::string room_uuid = room_->GetRoomUuid(); HttpProxy::Instance()->HttpGet ( - [room_wp = room_->weak_from_this(), room_uuid] + [room_wp = room_->weak_from_this(), room_uuid = room_->GetRoomUuid()] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) { if (ok) { @@ -147,32 +146,32 @@ void BoxDrop::RequestReturnBoxNum() auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Battle"); url_params->SetVal("a", "requestReturnBoxNum"); - url_params->SetVal("room_uuid", room_->GetRoomUuid()); url_params->SetVal("account_id", account_id); url_params->SetVal("session_id", session_id); + url_params->SetVal("used_num", used_num_); + 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 - ("GetBattleData ok %s", + ("RequestReturnBoxNum ok room_uuid:%s %s", { + room_uuid, rsp_obj->ToJsonStr() - }); + }); if (rsp_obj->GetType() != a8::XOT_OBJECT || !rsp_obj->HasKey("errcode")) { - //cb(1, "", nullptr); return; } } else { f8::UdpLog::Instance()->Warning - ("GetCustomBattleData error %s", + ("RequestReturnBoxNum error room_uuid:%s", { - "" - }); - //cb(1, "custom battle data error", nullptr); + room_uuid + }); } }, url, From 73215879662d512e7c5fd4e791438dc39583180c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 10:31:43 +0800 Subject: [PATCH 042/102] 1 --- server/gameserver/mt/Param.cc | 9 +++++++++ server/gameserver/mt/Param.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/server/gameserver/mt/Param.cc b/server/gameserver/mt/Param.cc index afb3e508..66560606 100644 --- a/server/gameserver/mt/Param.cc +++ b/server/gameserver/mt/Param.cc @@ -279,6 +279,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..1191859e 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -158,6 +158,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; From 5d3889cb15ae363778416da5be0f19197b2d8879 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 11:24:57 +0800 Subject: [PATCH 043/102] 1 --- server/gameserver/boxdrop.cc | 31 ++++++++++++++++++++++++++++++- server/gameserver/boxdrop.h | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 2feb809a..791afc99 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -8,12 +8,14 @@ #include "boxdrop.h" #include "room.h" #include "hero.h" -#include "obstacle.h" +#include "roomobstacle.h" #include "httpproxy.h" #include "jsondatamgr.h" #include "player.h" #include "mt/MapMode.h" +#include "mt/Hero.h" +#include "mt/MapThing.h" const int BOX_ID = 150001; @@ -209,6 +211,7 @@ void BoxDrop::OnAllocOk(int box_num) } alloced_ = true; alloc_box_num_ = box_num; + AllocBoxToRoom(); } void BoxDrop::OnAllocFail() @@ -217,3 +220,29 @@ void BoxDrop::OnAllocFail() room_->xtimer.Delete(get_box_num_timer_); } } + +void BoxDrop::AllocBoxToRoom() +{ + if (alloc_box_num_ <= 0) { + return; + } + std::vector hero_list; + std::vector box_list; + room_->TraverseEntityList + ( + [this, &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); + } + } else if (e->IsRoomObstacle()) { + RoomObstacle* ob = (RoomObstacle*)e; + if (ob->meta->HasDrop()) { + box_list.push_back(ob); + } + } + return true; + }); +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 8bb2e2bf..91707367 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -24,6 +24,7 @@ class BoxDrop : public std::enable_shared_from_this bool FillAccountIdSessionId(std::string account_id, std::string session_id); void OnAllocOk(int box_num); void OnAllocFail(); + void AllocBoxToRoom(); private: Room* room_ = nullptr; @@ -32,4 +33,5 @@ class BoxDrop : public std::enable_shared_from_this int alloc_box_num_ = 0; bool alloced_ = false; bool returned_ = false; + std::map drop_hash_; }; From 6525b795f5342d283b1157e1d9c37306fe77c9be Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 11:34:41 +0800 Subject: [PATCH 044/102] 1 --- server/gameserver/boxdrop.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 791afc99..3ec5aa23 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -1,5 +1,7 @@ #include "precompile.h" +#include + #include #include @@ -226,23 +228,45 @@ void BoxDrop::AllocBoxToRoom() if (alloc_box_num_ <= 0) { return; } + std::vector all_list; std::vector hero_list; std::vector box_list; room_->TraverseEntityList ( - [this, &hero_list, &box_list] (Entity* e) -> bool + [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 } From d24f428df0b0b6d964ae872172e9c6be596e8ae9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 12:04:12 +0800 Subject: [PATCH 045/102] 1 --- server/gameserver/boxdrop.cc | 38 ++++++++++++++++++++++++++---------- server/gameserver/boxdrop.h | 4 ++-- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 3ec5aa23..12e0809b 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -37,15 +37,17 @@ void BoxDrop::UnInit() void BoxDrop::OnHeroDeadDrop(Hero* hero) { - if (GetRemainNum() > 0) { - Drop(1, hero->GetPos().ToGlmVec3()); + int box_num = GetAndDecObjBoxNum(hero->GetUniId()); + if (box_num > 0) { + Drop(box_num, hero->GetPos().ToGlmVec3()); } } void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) { - if (GetRemainNum() > 0) { - Drop(1, ob->GetPos().ToGlmVec3()); + int box_num = GetAndDecObjBoxNum(ob->GetUniId()); + if (box_num > 0) { + Drop(box_num, ob->GetPos().ToGlmVec3()); } } @@ -152,7 +154,7 @@ void BoxDrop::RequestReturnBoxNum() url_params->SetVal("a", "requestReturnBoxNum"); url_params->SetVal("account_id", account_id); url_params->SetVal("session_id", session_id); - url_params->SetVal("used_num", used_num_); + url_params->SetVal("used_num", GetUsedBoxNum()); url_params->SetVal("alloc_box_num", alloc_box_num_); HttpProxy::Instance()->HttpGet ( @@ -184,11 +186,6 @@ void BoxDrop::RequestReturnBoxNum() } } -int BoxDrop::GetRemainNum() -{ - return std::max(0, alloc_box_num_ - used_num_); -} - bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id) { bool ok = false; @@ -269,4 +266,25 @@ void BoxDrop::AllocBoxToRoom() 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() +{ + return 0; } diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 91707367..8a5b4986 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -20,16 +20,16 @@ class BoxDrop : public std::enable_shared_from_this void Drop(int num, const glm::vec3& center); void RequestAllocBoxNum(); - int GetRemainNum(); 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 used_num_ = 0; int alloc_box_num_ = 0; bool alloced_ = false; bool returned_ = false; From 611785bea4590e0c1c7ee17f7bb03360b3832787 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 13:10:52 +0800 Subject: [PATCH 046/102] 1 --- server/gameserver/boxdrop.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 12e0809b..378aae05 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -54,8 +54,10 @@ void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) void BoxDrop::Drop(int num, const glm::vec3& center) { for (int i = 0; i < num; ++i) { - //room_->CreateLoot(BOX_ID, center, center, 1, 1); - room_->CreateObstacle(BOX_ID, center.x, center.y, center.z); + glm::vec3 dir = GlmHelper::UP; + GlmHelper::RotateY(dir, a8::RandAngle()); + const glm::vec3 pos = center + dir * (25.0f + rand() % 50); + room_->CreateObstacle(BOX_ID, pos.x, pos.y, pos.z); } } From 4cd54c4e0c63b0c32af252748e8621fa071e7ad0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 13:13:34 +0800 Subject: [PATCH 047/102] 1 --- server/gameserver/boxdrop.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 378aae05..11030e71 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -288,5 +288,13 @@ int BoxDrop::GetAndDecObjBoxNum(int uniid) int BoxDrop::GetUsedBoxNum() { - return 0; + int num = 0; + room_->TraverseHumanList + ( + [&num] (Human* hum) -> bool + { + num += hum->box_num; + return true; + }); + return num; } From e4bd8249c294ffd8e720b5cbe8e8a5977c0b9af5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 14:59:32 +0800 Subject: [PATCH 048/102] 1 --- server/gameserver/boxdrop.cc | 17 ++++++++++++++++- server/gameserver/boxdrop.h | 3 ++- server/gameserver/commands.cc | 7 +++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 11030e71..77554620 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -156,6 +156,7 @@ void BoxDrop::RequestReturnBoxNum() 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 @@ -188,7 +189,7 @@ void BoxDrop::RequestReturnBoxNum() } } -bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id) +bool BoxDrop::FillAccountIdSessionId(std::string& account_id, std::string& session_id) { bool ok = false; room_->TraversePlayerList @@ -298,3 +299,17 @@ int BoxDrop::GetUsedBoxNum() }); 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; +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 8a5b4986..10b9ab2f 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -15,12 +15,13 @@ class BoxDrop : public std::enable_shared_from_this void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); void RequestReturnBoxNum(); + bool GetNextBoxPos(glm::vec3& pos); private: void Drop(int num, const glm::vec3& center); void RequestAllocBoxNum(); - bool FillAccountIdSessionId(std::string account_id, std::string session_id); + bool FillAccountIdSessionId(std::string& account_id, std::string& session_id); void OnAllocOk(int box_num); void OnAllocFail(); void AllocBoxToRoom(); diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index a17a3e90..a30e6701 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -16,6 +16,7 @@ #include "loot.h" #include "ability.h" #include "trigger.h" +#include "boxdrop.h" #include "cs_proto.pb.h" @@ -69,6 +70,12 @@ 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); + 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]); From 16c743f12d370a6d87fb43360af422b0d8d987de Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 15:13:59 +0800 Subject: [PATCH 049/102] 1 --- server/gameserver/boxdrop.cc | 8 ++++++++ server/gameserver/boxdrop.h | 1 + server/gameserver/obstacle.cc | 3 +++ 3 files changed, 12 insertions(+) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 77554620..c8261a8b 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -313,3 +313,11 @@ bool BoxDrop::GetNextBoxPos(glm::vec3& pos) } 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 index 10b9ab2f..5d0477a6 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -16,6 +16,7 @@ class BoxDrop : public std::enable_shared_from_this void OnObstacleDeadDrop(Obstacle* ob); void RequestReturnBoxNum(); bool GetNextBoxPos(glm::vec3& pos); + void DropByUuid(int obj_uniid, const glm::vec3& center); private: diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index 60816fe3..de4a3239 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -318,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)) { From ba4eca4a1143bbb181df90e648660a1b295e6555 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 15:21:33 +0800 Subject: [PATCH 050/102] 1 --- server/gameserver/team.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index b1f2a3d0..49357ab8 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -759,6 +759,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; From a9c206ed2906357f51d0da6ff59b937573db7554 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2024 16:19:32 +0800 Subject: [PATCH 051/102] 1 --- server/gameserver/boxdrop.cc | 5 ++++- server/gameserver/commands.cc | 1 + server/gameserver/team.cc | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index c8261a8b..559612ae 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -70,11 +70,14 @@ void BoxDrop::OnBattleStart() { if (a8::TIMER_EXEC_EVENT == event) { if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { - RequestAllocBoxNum(); + if (!alloced_) { + RequestAllocBoxNum(); + } } } }, &room_->xtimer_attacher_); + RequestAllocBoxNum(); } } diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index a30e6701..9af7dbad 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -74,6 +74,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) 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) { diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index 49357ab8..993e5ee0 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -405,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; From 6acf456b7ae46d3d82c39f2e74ad119c4e680f1c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 2 Aug 2024 10:51:34 +0800 Subject: [PATCH 052/102] add skin --- server/gameserver/framemaker.cc | 2 ++ server/gameserver/pbutils.cc | 1 + server/gameserver/player.cc | 1 + server/tools/protobuild/cs_proto.proto | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/server/gameserver/framemaker.cc b/server/gameserver/framemaker.cc index d31c72cb..81342440 100644 --- a/server/gameserver/framemaker.cc +++ b/server/gameserver/framemaker.cc @@ -627,6 +627,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 +636,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_skin_id()->set_dead_hero_id(hum->GetNetData()->GetSkinId()); } } #ifdef MYDEBUG diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index e0684b8c..934df047 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -974,6 +974,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()); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 0c867914..cfa9d98b 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1839,6 +1839,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/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index e6aaf942..a7342b42 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -344,6 +344,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 } //玩家信息-全量 @@ -729,6 +730,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 @@ -1558,10 +1560,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; //死者皮肤 } //游戏内语音 From 03f450866d0bd17261b2fd6316f7826eca3dd764 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 2 Aug 2024 11:37:47 +0800 Subject: [PATCH 053/102] 1 --- server/gameserver/android.cc | 10 +++++++++- server/gameserver/framemaker.cc | 3 ++- server/gameserver/netdata.cc | 7 +++++++ server/gameserver/pbutils.cc | 1 + server/tools/protobuild/cs_proto.proto | 1 + 5 files changed, 20 insertions(+), 2 deletions(-) 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/framemaker.cc b/server/gameserver/framemaker.cc index 81342440..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" @@ -636,7 +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_skin_id()->set_dead_hero_id(hum->GetNetData()->GetSkinId()); + p->mutable_kill_info()->set_dead_skin_id(hum->GetNetData()->GetSkinId()); } } #ifdef MYDEBUG diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 5828c627..a2499174 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -1076,6 +1076,13 @@ void BattleDataContext::Init(Creature* c) if (weapon2_ability_) { weapon2_ability_->Init(c); } +#ifdef MYDEBUG + { + if (c->IsAndroid()) { + skin_id_ = 1 + c->GetHeroMeta()->skinlist(); + } + } +#endif if (skin_id_ && c->IsHuman()) { const mt::Item* item_meta = mt::Item::GetById(skin_id_); if (item_meta) { diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 934df047..69a8e574 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -1094,6 +1094,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) diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index a7342b42..c9616b32 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -765,6 +765,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]; //皮肤 } //队伍数据-全量 From d539ee5351b476da0d46d74f8c361b791d9cad51 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 2 Aug 2024 13:27:58 +0800 Subject: [PATCH 054/102] 1 --- server/gameserver/pbutils.cc | 1 + server/tools/protobuild/cs_proto.proto | 1 + 2 files changed, 2 insertions(+) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 69a8e574..449f72d9 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -1047,6 +1047,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); diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index c9616b32..d7eafbcd 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -1504,6 +1504,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; //击杀数 From ea516d2af086ca619e8f2e33fbea8e80db040891 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 9 Aug 2024 15:39:22 +0800 Subject: [PATCH 055/102] 1 --- server/gameserver/obstacle.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index de4a3239..e5fe6ef6 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -499,6 +499,13 @@ void Obstacle::DoTreasureBoxInteraction(Human* sender) { if (!IsDead(sender->room)) { ++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); From 9289503b34d6b6fc840394eab909d388b0fc1da0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 14 Aug 2024 16:20:52 +0800 Subject: [PATCH 056/102] 1 --- server/gameserver/handlermgr.cc | 9 --- server/tools/protobuild/cs_msgid.proto | 9 --- server/tools/protobuild/cs_proto.proto | 79 -------------------------- 3 files changed, 97 deletions(-) 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/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 d7eafbcd..59dfb032 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -1137,27 +1137,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 { @@ -1745,46 +1724,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; //消息内容 -} - /* 请求子弹伤害(追踪型子弹、上报型子弹) */ @@ -2046,11 +1985,6 @@ message SMLeave { } -//取消匹配 -message SMMatchCancel -{ -} - //断线通知 message SMDisconnectNotify { @@ -2120,19 +2054,6 @@ message SMShowTeamUI { } -//更新匹配信息 -message SMUpdateMatchInfo -{ - optional MFMatchInfo info = 1; //匹配信息 -} - -//匹配-队伍成员消息 -message SMMatchMemberMsgNotify -{ - optional string sender = 1; //消息发送者 - optional string content = 2; //消息内容 -} - //获得物品 message SMGetItemNotify { From 2a79e726120a21d3b434d3184f0ac4f28f2d2d87 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 14 Aug 2024 17:27:48 +0800 Subject: [PATCH 057/102] 1 --- README.md | 2 ++ server/gameserver/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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/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( From 6fb944a244db845e41a17c283a76da1133446aa4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 14 Aug 2024 19:32:14 +0800 Subject: [PATCH 058/102] fix FillSMGameOver memory leak --- server/gameserver/pbutils.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 449f72d9..07bb7500 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -1120,18 +1120,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->GetMobaTeamB()->FillMFSettlementNew(p.get()); *msg.mutable_common_settlement()->add_team_list() = *p; } } From f954be1479d2a66252b0ddd0ea216078d2e0d6ca Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 09:43:35 +0800 Subject: [PATCH 059/102] 1 --- server/gameserver/GGListener.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index dfd472c1..5ef35cf8 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -162,6 +162,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; } From 0094a8f732fec8eb8ab120ecb4ef2febc9ea9bdf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 10:17:42 +0800 Subject: [PATCH 060/102] 1 --- server/gameserver/roommgr.cc | 3 +++ third_party/f8 | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index c489b220..f1374d30 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) 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 From 7b6eda38bd85338538fffe90b0ba8cf6d41bc91b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 11:52:36 +0800 Subject: [PATCH 061/102] 1 --- server/gameserver/commands.cc | 27 ++++++++++++++++++++++++++- server/gameserver/room.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 9af7dbad..062f4986 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -245,7 +245,7 @@ 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); @@ -519,6 +519,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 diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 944f9fae..2b250a60 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -74,6 +74,7 @@ enum RoomSwitch_e kRoomSwitchDisableUseSkill, kRoomSwitchDisableUseItem, kRoomSwitchDisableShot, + kRoomSwitchPeaceMode, }; class Room : public std::enable_shared_from_this From 1e7b83be9a618669614d200fa153b320a76f791b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 12:04:07 +0800 Subject: [PATCH 062/102] 1 --- server/gameserver/commands.cc | 6 ++++++ server/gameserver/hero_agent.cc | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 062f4986..a54364b7 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -555,6 +555,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/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; From 96c1ae8039c854deb85d7e70b756c10ceb4a8f54 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 14:26:43 +0800 Subject: [PATCH 063/102] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=91=E4=BA=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/buff.cc | 42 ++++++++++++++++++++++++++++++++++++++ server/gameserver/human.cc | 4 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) 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/human.cc b/server/gameserver/human.cc index 90c704c9..bc5657f5 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -894,7 +894,7 @@ void Human::UpdateAction() break; case AT_Rescue: { - RemoveBuffByEffectId(kBET_InRescue); + RemoveBuffByEffectId(kBET_Rescuer); } break; default: @@ -1807,7 +1807,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; From dc03ded1f6187661fd888aac32feadf718d82bd4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 14:50:51 +0800 Subject: [PATCH 064/102] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=BE=99=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E6=8A=80=E8=83=BD=E8=83=BD=E9=87=8F=E6=8A=A4=E7=BD=A9?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/buff/callfunc.cc | 6 ++++++ 1 file changed, 6 insertions(+) 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); From 5db58d028a2aca4ca5fc638e1ba8ca3277119fb0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 15:06:12 +0800 Subject: [PATCH 065/102] 1 --- server/gameserver/player.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index cfa9d98b..a96708b6 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1093,7 +1093,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)) { From a0c8d9cd9fe677fd974af0408d07501c7d22f29b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 15:35:03 +0800 Subject: [PATCH 066/102] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dchild=5Fbuff=5F?= =?UTF-8?q?=E9=9A=90=E6=82=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/buff.h | 1 + server/gameserver/creature.cc | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) 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/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()])) { From 9c07d43b09ecb5a8fcb0de5e47768047c45dbabe Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 16:14:15 +0800 Subject: [PATCH 067/102] 1 --- server/robotserver/android_agent.cc | 6 ------ server/robotserver/handlermgr.cc | 3 --- server/robotserver/player.cc | 15 --------------- server/robotserver/player.h | 3 --- 4 files changed, 27 deletions(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 864740eb..498e676f 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -198,13 +198,7 @@ behaviac::EBTStatus AndroidAgent::CoJoin() msg.set_server_id(6); msg.set_team_uuid(""); 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()); owner_->SendMsg(msg); 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/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..eab6897f 100644 --- a/server/robotserver/player.h +++ b/server/robotserver/player.h @@ -45,7 +45,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 +58,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); From 827e95aa8de01e49c8238cbde35283da477e5c4a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 16:46:21 +0800 Subject: [PATCH 068/102] 1 --- server/robotserver/android_agent.cc | 4 +- server/robotserver/httpproxy.cc | 201 +--------------------------- server/robotserver/httpproxy.h | 47 +------ server/robotserver/jsondatamgr.cc | 1 + server/robotserver/jsondatamgr.h | 1 + server/robotserver/playermgr.cc | 2 +- 6 files changed, 7 insertions(+), 249 deletions(-) mode change 100644 => 120000 server/robotserver/httpproxy.cc mode change 100644 => 120000 server/robotserver/httpproxy.h create mode 120000 server/robotserver/jsondatamgr.cc create mode 120000 server/robotserver/jsondatamgr.h diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 498e676f..46165b0d 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -110,7 +110,7 @@ behaviac::EBTStatus AndroidAgent::CoLogin() } }, "https://game2006api-test.kingsome.cn/webapp/index.php", - *url_params + url_params ); } else { context->login_ok = false; @@ -118,7 +118,7 @@ behaviac::EBTStatus AndroidAgent::CoLogin() } }, "https://login-test.kingsome.cn/webapp/index.php", - *url_params + url_params ); } co->runing_cb = 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/playermgr.cc b/server/robotserver/playermgr.cc index bd140632..148e433c 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -21,7 +21,7 @@ void PlayerMgr::Init() int count = 0; f8::Timer::Instance()->SetInterval ( - 200, + 1, [this, count] (int et, const a8::Args* args) mutable { if (et == a8::TIMER_EXEC_EVENT) { From 71dd677d90114d78a77556483cb8105fbd1adb65 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 17:02:36 +0800 Subject: [PATCH 069/102] 1 --- server/robotserver/android_agent.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 46165b0d..a3cd4875 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -70,11 +70,14 @@ 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"); + //url_params->SetVal("gameid", 2006); + //url_params->SetVal("channel", 6513); + //url_params->SetVal("openid", owner_->GetIdx()); + 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) { @@ -118,7 +121,8 @@ behaviac::EBTStatus AndroidAgent::CoLogin() } }, "https://login-test.kingsome.cn/webapp/index.php", - url_params + url_params, + post_body->ToJsonStr() ); } co->runing_cb = From 298dad660aac9b377ccde6ad861a794fe7a55fda Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 17:12:48 +0800 Subject: [PATCH 070/102] 1 --- server/tools/protobuild/cs_proto.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 59dfb032..0bd488c2 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -416,6 +416,7 @@ message MFPlayerFull optional int32 max_armor_shield = 74; //最大护甲 optional int32 box_num = 75; //宝箱数量 + optional int32 hero_quality = 76; //英雄品阶<=1是N阶,1阶是2,2阶是3。。。。。 } //阻挡物-部分 From 727395db4d0efd21bec6c97b9e02ea7ed03ef66c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 17:34:46 +0800 Subject: [PATCH 071/102] 1 --- server/gameserver/human.cc | 10 ++++++++++ server/gameserver/human.h | 3 +++ server/gameserver/pbutils.cc | 2 ++ 3 files changed, 15 insertions(+) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index bc5657f5..79341851 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -3736,3 +3736,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/pbutils.cc b/server/gameserver/pbutils.cc index 07bb7500..e98d5908 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); @@ -831,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) From a411b20b6f1aea290e5e868f8d14d30f7754a758 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 17:49:54 +0800 Subject: [PATCH 072/102] 1 --- server/gameserver/obstacle.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index e5fe6ef6..162ee1d0 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -497,7 +497,7 @@ void Obstacle::SetRotate(float rotate) void Obstacle::DoTreasureBoxInteraction(Human* sender) { - if (!IsDead(sender->room)) { + if (!IsDead(sender->room) && sender->GetHeroQuality() > 1) { ++sender->box_num; sender->room->frame_event.AddPropChg ( From c1381fa750a745b6c8b0c1348ba68d5efbe38479 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 19:11:07 +0800 Subject: [PATCH 073/102] 1 --- server/robotserver/android_agent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index a3cd4875..a850a386 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -81,7 +81,7 @@ behaviac::EBTStatus AndroidAgent::CoLogin() ( [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) { From 6524322d0a5dbd0d8af1175a82a037f8a79e58ac Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 19:15:16 +0800 Subject: [PATCH 074/102] 1 --- server/bin/robotserver/test_config | 1 + server/robotserver/app.cc | 3 +++ 2 files changed, 4 insertions(+) create mode 120000 server/bin/robotserver/test_config 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/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(); From efd77daa0b1bdd5a530aa84ef95572642bdc4bf1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 15 Aug 2024 19:25:37 +0800 Subject: [PATCH 075/102] 1 --- server/robotserver/GGListener.cc | 5 +++-- server/robotserver/playermgr.cc | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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/playermgr.cc b/server/robotserver/playermgr.cc index 148e433c..d8ddd354 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -21,7 +21,7 @@ void PlayerMgr::Init() int count = 0; f8::Timer::Instance()->SetInterval ( - 1, + 200, [this, count] (int et, const a8::Args* args) mutable { if (et == a8::TIMER_EXEC_EVENT) { @@ -32,7 +32,7 @@ void PlayerMgr::Init() account_id_hash_[hum->GetAccountId()] = hum; socket_id_hash_[hum->GetSocketId()] = hum; ++count; - if (count >= 200) { + if (count >= 1) { f8::Timer::Instance()->DeleteCurrentTimer(); } } From 4f7315ce8a17cebae019c21cef9fea31b81a204d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 18 Aug 2024 10:38:59 +0800 Subject: [PATCH 076/102] 1 --- server/gameserver/constant.h | 1 + server/gameserver/netdata.cc | 5 +++++ server/gameserver/netdata.h | 1 + server/tools/protobuild/cs_proto.proto | 2 ++ 4 files changed, 9 insertions(+) diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 9e4320d4..10bfa7af 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -283,6 +283,7 @@ enum PropertyType_e kPropLevelUp = 56, kPropBoxNum = 57, + kPropShowOrHideBigEventBox = 58, }; enum SkinSlot_e diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index a2499174..f47b6b39 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -1377,3 +1377,8 @@ bool BattleDataContext::HasWing() } return false; } + +bool BattleDataContext::HideBigEventBox() +{ + return false; +} diff --git a/server/gameserver/netdata.h b/server/gameserver/netdata.h index 83c5815f..2dae29da 100644 --- a/server/gameserver/netdata.h +++ b/server/gameserver/netdata.h @@ -94,6 +94,7 @@ struct BattleDataContext int GetCurrentGetStar(); int GetBattleTimes(); bool HasWing(); + bool HideBigEventBox(); int GetHonor(); int GetElo() { return elo_; } diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 0bd488c2..8d36854d 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -253,6 +253,8 @@ message MFVec3 property_type: 57 宝箱数量 value: 当前宝箱数量 value2: 本次获得宝箱数(>0表现获得新的宝箱 <0表示死亡时掉落扣除的宝箱 ==0纯数据同步) + property_type: 58 显示/隐藏大事件宝箱显示(客户端默认显示) + value: 0:隐藏 1:显示 */ message MFPropertyChg { From 6cb4d307b5ec50ed92144170c6167be458e28327 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 18 Aug 2024 11:04:20 +0800 Subject: [PATCH 077/102] 1 --- server/gameserver/netdata.cc | 6 ++++++ server/gameserver/player.cc | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index f47b6b39..f0cfedb0 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -1380,5 +1380,11 @@ bool BattleDataContext::HasWing() bool BattleDataContext::HideBigEventBox() { + if (owner_.Get()->IsPlayer()) { + if (hero_dto) { + double lucky = hero_dto->Get("lucky", ""); + return lucky < 0.1f; + } + } return false; } diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index a96708b6..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); From 5065b6347593c6974946284f09c3c37367de24cf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 18 Aug 2024 17:42:42 +0800 Subject: [PATCH 078/102] 1 --- server/gameserver/boxdrop.cc | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 559612ae..63649c05 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -2,6 +2,7 @@ #include +#include #include #include @@ -14,6 +15,7 @@ #include "httpproxy.h" #include "jsondatamgr.h" #include "player.h" +#include "mapinstance.h" #include "mt/MapMode.h" #include "mt/Hero.h" @@ -56,8 +58,35 @@ 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()); - const glm::vec3 pos = center + dir * (25.0f + rand() % 50); - room_->CreateObstacle(BOX_ID, pos.x, pos.y, pos.z); + + 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); } } From 2dd2b5c805d2ee47aea6b0cfc9e661e65ee49991 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 20 Aug 2024 15:38:30 +0800 Subject: [PATCH 079/102] 1 --- server/gameserver/netdata.cc | 14 +++++++------- server/gameserver/netdata.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index f0cfedb0..7712fac6 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", ""); @@ -1380,11 +1381,10 @@ bool BattleDataContext::HasWing() bool BattleDataContext::HideBigEventBox() { - if (owner_.Get()->IsPlayer()) { - if (hero_dto) { - double lucky = hero_dto->Get("lucky", ""); - return lucky < 0.1f; - } - } - return false; + return GetTotalLucky() < 0.01f; +} + +float BattleDataContext::GetTotalLucky() +{ + return total_lucky_; } diff --git a/server/gameserver/netdata.h b/server/gameserver/netdata.h index 2dae29da..847a7ebe 100644 --- a/server/gameserver/netdata.h +++ b/server/gameserver/netdata.h @@ -95,6 +95,7 @@ struct BattleDataContext int GetBattleTimes(); bool HasWing(); bool HideBigEventBox(); + float GetTotalLucky(); int GetHonor(); int GetElo() { return elo_; } @@ -110,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_; From 695e04fcfd27bebc6cc2c84cc2edc4c69acd8caf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 20 Aug 2024 16:43:22 +0800 Subject: [PATCH 080/102] 1 --- server/gameserver/commands.cc | 3 +++ server/gameserver/obstacle.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index a54364b7..7589f8ed 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -17,6 +17,7 @@ #include "ability.h" #include "trigger.h" #include "boxdrop.h" +#include "netdata.h" #include "cs_proto.pb.h" @@ -251,6 +252,8 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) room->grid_service->MoveCreature(hum); 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; diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index 162ee1d0..e144bc02 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -497,7 +497,7 @@ void Obstacle::SetRotate(float rotate) void Obstacle::DoTreasureBoxInteraction(Human* sender) { - if (!IsDead(sender->room) && sender->GetHeroQuality() > 1) { + if (!IsDead(sender->room) && sender->GetNetData()->GetTotalLucky() > 0.1f) { ++sender->box_num; sender->room->frame_event.AddPropChg ( From b5ceb9cd04d3b2e3fc67362c3960f770382ea6e9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 20 Aug 2024 17:58:25 +0800 Subject: [PATCH 081/102] 1 --- server/gameserver/netdata.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 7712fac6..58d2d8da 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -1077,10 +1077,10 @@ void BattleDataContext::Init(Creature* c) if (weapon2_ability_) { weapon2_ability_->Init(c); } -#ifdef MYDEBUG +#if 1 { - if (c->IsAndroid()) { - skin_id_ = 1 + c->GetHeroMeta()->skinlist(); + if (c->IsAndroid() && a8::RandEx(0, 1000) < 100) { + skin_id_ = a8::RandEx(0, 3) + c->GetHeroMeta()->skinlist(); } } #endif From 30d33f97ab5939cc0bfe0bed348ca792ab4e0645 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 20 Aug 2024 18:03:29 +0800 Subject: [PATCH 082/102] 1 --- server/gameserver/stats.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From f0fb944f7e0cbf582fa2ab1fec658cb302582ead Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 10:30:07 +0800 Subject: [PATCH 083/102] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=98=9F=E5=8F=8B?= =?UTF-8?q?=E5=85=A8=E6=AD=BB=E5=90=8E=E4=B8=8D=E5=8F=91GameOver=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/commands.cc | 15 +++++++++++++++ server/gameserver/human.cc | 3 +++ server/gameserver/pbutils.cc | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 7589f8ed..2e3a0a56 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -252,6 +252,21 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) 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) { diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 79341851..07231b03 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1281,6 +1281,9 @@ void Human::OnDie() return true; }); } + if (IsPlayer()) { + int i = 0; + } if (real_dead) { std::set over_humans; if (!leave_) { diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index e98d5908..17c76a41 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -1539,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()) { @@ -1565,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; From 2f0183ba229044b9e196058bab7f314250292057 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 11:14:04 +0800 Subject: [PATCH 084/102] 1 --- server/robotserver/android_agent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index a850a386..ad70c6ed 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -163,7 +163,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; }; From d5e7d8c3ca0dc320e8be024c7726eb52285977bc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 13:25:18 +0800 Subject: [PATCH 085/102] 1 --- server/robotserver/android_agent.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index ad70c6ed..2d91d6a2 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -200,11 +200,28 @@ 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_proto_version(cs::ProtoVersion); - //weapons msg.set_session_id(owner_->GetSessionId()); + msg.set_proto_version(cs::ProtoVersion); + std::string payload_data = "ihCQQdNzoYFC^6q4ohsao39br%Ui!C9u2d^qvzek5hOB$3q1:|"; + { + auto xobj = a8::MutableXObject::CreateObject(); + auto team_list = a8::MutableXObject::CreateArray(); + { + auto member_list = a8::MutableXObject::CreateArray(); + + auto member = a8::MutableXObject::CreateObject(); + member->SetVal("account_id", owner_->GetAccountId()); + member->SetVal("session_id", owner_->GetSessionId()); + member_list->Push(*member.get()); + + team_list->SetVal("members", *member_list.get()); + } + 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()}); From 162a82befe4e65d1d402b884aa899ed505b8e92a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 13:33:03 +0800 Subject: [PATCH 086/102] 1 --- server/robotserver/android_agent.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 2d91d6a2..305c3ccc 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" @@ -209,14 +210,17 @@ behaviac::EBTStatus AndroidAgent::CoJoin() 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_list->Push(*member.get()); - team_list->SetVal("members", *member_list.get()); + team->SetVal("team_uuid", f8::App::Instance()->NewGlobalUuid()); + team->SetVal("members", *member_list.get()); + + team_list->Push(*team.get()); } xobj->SetVal("team_list", *team_list.get()); payload_data += xobj->ToJsonStr(); From 628c8fafc606d19f5c57cfd7f63918a72270431b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 15:55:35 +0800 Subject: [PATCH 087/102] 1 --- server/gameserver/netdata.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 58d2d8da..961993a8 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -1080,7 +1080,7 @@ void BattleDataContext::Init(Creature* c) #if 1 { if (c->IsAndroid() && a8::RandEx(0, 1000) < 100) { - skin_id_ = a8::RandEx(0, 3) + c->GetHeroMeta()->skinlist(); + skin_id_ = a8::RandEx(0, 1) + c->GetHeroMeta()->skinlist(); } } #endif From 43793fdd3cf617d08700d0fb08fd6443b1e95cda Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 17:25:53 +0800 Subject: [PATCH 088/102] 1 --- server/gameserver/pbutils.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 17c76a41..afd85fb7 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -1133,7 +1133,7 @@ void Human::FillSMGameOver(cs::SMGameOver& msg) room->GetMobaTeamB()->FillMFSettlementNew(p.get()); *msg.mutable_common_settlement()->add_team_list() = *p; } else { - room->GetMobaTeamB()->FillMFSettlementNew(p.get()); + room->GetMobaTeamA()->FillMFSettlementNew(p.get()); *msg.mutable_common_settlement()->add_team_list() = *p; } } @@ -1557,7 +1557,7 @@ void Human::SendGameOver() } else { SendNotifyMsg(msg); } -#ifdef MYDEBUG1 +#ifdef MYDEBUG if (IsPlayer()) { a8::XPrintf("SMGameOver:%s\n", {f8::PbToJson(&msg)}); } @@ -1584,7 +1584,7 @@ void Human::SendGameOver() } else { SendNotifyMsg(msg); } -#ifdef MYDEBUG1 +#ifdef MYDEBUG if (IsPlayer()) { a8::XPrintf("SMGameOver:%s\n", {f8::PbToJson(&msg)}); } From f1aae7a733c3754923fc1170d20c0e2a062cf0d1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 19:50:38 +0800 Subject: [PATCH 089/102] 1 --- server/gameserver/mt/Param.cc | 16 +++++++++++ server/gameserver/mt/Param.h | 2 ++ server/gameserver/room.cc | 53 +++++++++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/server/gameserver/mt/Param.cc b/server/gameserver/mt/Param.cc index 66560606..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; diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index 1191859e..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; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index a65d342a..8130395f 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -4172,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; }); @@ -4193,46 +4202,78 @@ 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\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, + }); + } +#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; } hum->stats->battle_score = battle_score; From 332f84648b75983118d30399f6be3f7f9a4bc46a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 21:53:50 +0800 Subject: [PATCH 090/102] 1 --- server/gameserver/room.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 8130395f..dca4ef34 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -4239,8 +4239,9 @@ void Room::CalcMvp() } #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\n", + 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, @@ -4253,6 +4254,8 @@ void Room::CalcMvp() max_damage, hum->stats->heal_amount, max_recover, + hum->GetHeroLevel(), + max_level }); } #endif @@ -4276,6 +4279,14 @@ void Room::CalcMvp() } 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; }); From ed541307fb7faac4ece03ff852462afad9881fe9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 22:23:05 +0800 Subject: [PATCH 091/102] 1 --- server/robotserver/android_agent.cc | 37 ++++++++++++++++++++++++----- server/robotserver/player.h | 3 +++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 305c3ccc..52c1c083 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -72,9 +72,6 @@ behaviac::EBTStatus AndroidAgent::CoLogin() auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Login"); url_params->SetVal("a", "auth2"); - //url_params->SetVal("gameid", 2006); - //url_params->SetVal("channel", 6513); - //url_params->SetVal("openid", owner_->GetIdx()); auto post_body = a8::MutableXObject::CreateObject(); post_body->SetVal("channel", 2); post_body->SetVal("data", owner_->GetIdx()); @@ -100,14 +97,42 @@ behaviac::EBTStatus AndroidAgent::CoLogin() } HttpProxy::Instance()->HttpGet ( - [context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + [context, hum] (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; + long long hero_uniid = rsp_obj->Get("hero_unid", ""); + hum->SetHeroUniId(hero_uniid); + if (hum->GetHeroUniId() <= 0) { + std::string account_id = rsp_obj->At("account_id")->AsXValue().GetString(); + std::string session_id = rsp_obj->At("session_id")->AsXValue().GetString(); + 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) { + ++Perf::Instance()->enter_ok_times; + context->login_ok = true; + } else { + context->login_ok = false; + ++Perf::Instance()->enter_fail_times; + } + }, + "https://game2006sapi-test.kingsome.cn/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; diff --git a/server/robotserver/player.h b/server/robotserver/player.h index eab6897f..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(); @@ -76,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; From 25dfbeb0ad6f7a3b0d18893d721caf0fe623a1e8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 22:25:16 +0800 Subject: [PATCH 092/102] 1 --- server/robotserver/playermgr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index d8ddd354..a888597a 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -26,7 +26,7 @@ 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; From 44dd7d03b7348c2b9c83c8c970d63acd4623fef5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 22:46:41 +0800 Subject: [PATCH 093/102] 1 --- server/robotserver/android_agent.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 52c1c083..7f1bfddf 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -97,17 +97,17 @@ behaviac::EBTStatus AndroidAgent::CoLogin() } HttpProxy::Instance()->HttpGet ( - [context, hum] (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) { - long long hero_uniid = rsp_obj->Get("hero_unid", ""); + auto info = rsp_obj->At("info"); + long long hero_uniid = info->Get("hero_uniid", ""); hum->SetHeroUniId(hero_uniid); if (hum->GetHeroUniId() <= 0) { - std::string account_id = rsp_obj->At("account_id")->AsXValue().GetString(); - std::string session_id = rsp_obj->At("session_id")->AsXValue().GetString(); auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "User"); url_params->SetVal("a", "selectFreeItemS"); @@ -126,7 +126,7 @@ behaviac::EBTStatus AndroidAgent::CoLogin() ++Perf::Instance()->enter_fail_times; } }, - "https://game2006sapi-test.kingsome.cn/webapp/index.php", + "https://game2006sapi-test.kingsome.cn/sapi/webapp/index.php", url_params ); } else { @@ -230,7 +230,7 @@ behaviac::EBTStatus AndroidAgent::CoJoin() msg.set_account_id(owner_->GetAccountId()); msg.set_session_id(owner_->GetSessionId()); msg.set_proto_version(cs::ProtoVersion); - std::string payload_data = "ihCQQdNzoYFC^6q4ohsao39br%Ui!C9u2d^qvzek5hOB$3q1:|"; + std::string payload_data = "ihCQQdNzoYFC^6q4ohsao39br%Ui!C9u2d^qvzek5hOB$3q1:normal_room|"; { auto xobj = a8::MutableXObject::CreateObject(); auto team_list = a8::MutableXObject::CreateArray(); From 9fa163e0281186eb8eec784a8493c6a9f7d87e48 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 22 Aug 2024 10:02:23 +0800 Subject: [PATCH 094/102] 1 --- server/robotserver/android_agent.cc | 9 +++++++++ server/robotserver/playermgr.cc | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 7f1bfddf..12401368 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -119,6 +119,9 @@ behaviac::EBTStatus AndroidAgent::CoLogin() [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 { @@ -240,6 +243,10 @@ behaviac::EBTStatus AndroidAgent::CoJoin() 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()); @@ -247,6 +254,8 @@ behaviac::EBTStatus AndroidAgent::CoJoin() 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(); } diff --git a/server/robotserver/playermgr.cc b/server/robotserver/playermgr.cc index a888597a..f22e6757 100644 --- a/server/robotserver/playermgr.cc +++ b/server/robotserver/playermgr.cc @@ -32,7 +32,7 @@ void PlayerMgr::Init() account_id_hash_[hum->GetAccountId()] = hum; socket_id_hash_[hum->GetSocketId()] = hum; ++count; - if (count >= 1) { + if (count >= 3) { f8::Timer::Instance()->DeleteCurrentTimer(); } } From b366492f0e4dd7b3b1c412fdc7f4ff23d3661021 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 14:42:02 +0800 Subject: [PATCH 095/102] 1 --- server/gameserver/boxdrop.cc | 26 ++++++++++++++++++++++++++ server/gameserver/boxdrop.h | 2 ++ server/gameserver/human.cc | 2 ++ server/gameserver/trigger.cc | 3 +++ 4 files changed, 33 insertions(+) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 63649c05..97f993e1 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -16,10 +16,13 @@ #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; @@ -53,6 +56,29 @@ void BoxDrop::OnObstacleDeadDrop(Obstacle* ob) } } +void BoxDrop::OnHumanDeadDrop(Human* hum) +{ + if (hum->box_num <= 0) { + return; + } + if (room_->IsGameOver()) { + return; + } + if (room_->GetVictoryTeam()) { + return; + } + int rnd = a8::RandEx(0, 100); + if (hum->stats->abandon_battle) { + if (rnd <= mt::Param::s().battle_event_end_loss_rate_quit * 100) { + Drop(hum->box_num, hum->GetPos().ToGlmVec3()); + } + } else { + if (rnd <= mt::Param::s().battle_event_end_loss_rate_dead * 100) { + Drop(hum->box_num, hum->GetPos().ToGlmVec3()); + } + } +} + void BoxDrop::Drop(int num, const glm::vec3& center) { for (int i = 0; i < num; ++i) { diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 5d0477a6..2ce4d118 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -3,6 +3,7 @@ class Room; class Hero; class Obstacle; +class Human; class BoxDrop : public std::enable_shared_from_this { @@ -14,6 +15,7 @@ class BoxDrop : public std::enable_shared_from_this 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); diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 07231b03..dc1bcbe2 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" @@ -3252,6 +3253,7 @@ void Human::InternalBeKill(int killer_id, const std::string& killer_name, int we } room->GetInGameVoice()->OnHumanBeKill(real_killer_id, this); } + room->GetBoxDrop()->OnHumanDeadDrop(this); SendViewerUiMemberUpdate({GetUniId(), killer_id, real_killer_id}); room->NotifyUiUpdate(); } diff --git a/server/gameserver/trigger.cc b/server/gameserver/trigger.cc index 7f0b5e8c..5c456048 100644 --- a/server/gameserver/trigger.cc +++ b/server/gameserver/trigger.cc @@ -520,6 +520,9 @@ void Trigger::RemoveEventHandlers(std::vector> handl } } +/* + !!! + */ void Trigger::DispatchEvent(int event_id, const std::vector& param) { auto itr = listeners_hash_.find(event_id); From bfde769e988b6503a8998e0ba2d0949af8938814 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 14:52:03 +0800 Subject: [PATCH 096/102] 1 --- server/gameserver/boxdrop.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 97f993e1..c55bedf8 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -71,10 +71,16 @@ void BoxDrop::OnHumanDeadDrop(Human* hum) if (hum->stats->abandon_battle) { if (rnd <= mt::Param::s().battle_event_end_loss_rate_quit * 100) { Drop(hum->box_num, hum->GetPos().ToGlmVec3()); + hum->box_num = 0; + room_->frame_event.AddPropChgEx(hum->GetWeakPtrRef(), kPropBoxNum, 0, hum->box_num, + 0, 0, false); } } else { if (rnd <= mt::Param::s().battle_event_end_loss_rate_dead * 100) { Drop(hum->box_num, hum->GetPos().ToGlmVec3()); + hum->box_num = 0; + room_->frame_event.AddPropChgEx(hum->GetWeakPtrRef(), kPropBoxNum, 0, hum->box_num, + 0, 0, false); } } } From 17166c21d32ec0e35dc7c8f7205ba4d6069e8ec7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 15:28:34 +0800 Subject: [PATCH 097/102] 1 --- server/gameserver/trigger.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/gameserver/trigger.cc b/server/gameserver/trigger.cc index 5c456048..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; @@ -529,7 +530,8 @@ void Trigger::DispatchEvent(int event_id, const std::vector& param) 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); } } } From c02c4542c49198a988d41ce70c26e812c59bdbe0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 16:40:40 +0800 Subject: [PATCH 098/102] 1 --- server/gameserver/boxdrop.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index c55bedf8..e7e1a904 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -67,22 +67,26 @@ void BoxDrop::OnHumanDeadDrop(Human* hum) if (room_->GetVictoryTeam()) { return; } - int rnd = a8::RandEx(0, 100); - if (hum->stats->abandon_battle) { - if (rnd <= mt::Param::s().battle_event_end_loss_rate_quit * 100) { - Drop(hum->box_num, hum->GetPos().ToGlmVec3()); - hum->box_num = 0; - room_->frame_event.AddPropChgEx(hum->GetWeakPtrRef(), kPropBoxNum, 0, hum->box_num, - 0, 0, false); - } - } else { - if (rnd <= mt::Param::s().battle_event_end_loss_rate_dead * 100) { - Drop(hum->box_num, hum->GetPos().ToGlmVec3()); - hum->box_num = 0; - room_->frame_event.AddPropChgEx(hum->GetWeakPtrRef(), kPropBoxNum, 0, hum->box_num, - 0, 0, false); + 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::max(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) From 0be164988a8d6de888ad98098a187b1235edd288 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 17:07:53 +0800 Subject: [PATCH 099/102] 1 --- server/gameserver/boxdrop.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index e7e1a904..a941e23a 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -80,7 +80,7 @@ void BoxDrop::OnHumanDeadDrop(Human* hum) } } } - drop_num = std::max(drop_num, hum->box_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; From c3aff411282a012771a44d6ef3a27e89359522f6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 17:16:13 +0800 Subject: [PATCH 100/102] 1 --- server/gameserver/boxdrop.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index a941e23a..e3a1b308 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -71,11 +71,11 @@ void BoxDrop::OnHumanDeadDrop(Human* hum) 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) { + 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) { + if (rnd <= (mt::Param::s().battle_event_end_loss_rate_dead * 100)) { ++drop_num; } } From d7f09c299fdaa22fcc07d005267b78b1b84dae72 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 21:43:17 +0800 Subject: [PATCH 101/102] 1 --- server/gameserver/human.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index dc1bcbe2..d6c1d079 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -3101,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; @@ -3253,7 +3254,6 @@ void Human::InternalBeKill(int killer_id, const std::string& killer_name, int we } room->GetInGameVoice()->OnHumanBeKill(real_killer_id, this); } - room->GetBoxDrop()->OnHumanDeadDrop(this); SendViewerUiMemberUpdate({GetUniId(), killer_id, real_killer_id}); room->NotifyUiUpdate(); } From 35e54cc45bc12ec9e06f4b5546f4f117d0195725 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 24 Aug 2024 07:30:50 +0800 Subject: [PATCH 102/102] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=BE=99=E7=82=AE?= =?UTF-8?q?=E5=8F=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/mt/Skill.cc | 4 ++-- server/gameserver/mt/Skill.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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;