From 6f5f9f11e6f6e2539d0e7aa3799e47a6c229cc83 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 5 Jan 2023 19:16:24 +0800 Subject: [PATCH] 1 --- server/gameserver/mt/MapArea.cc | 30 ++++++++++++++++++++++++ server/gameserver/mt/MapArea.h | 24 +++++++++++++++++++ server/gameserver/mt/MetaMgr.cc | 2 ++ server/gameserver/mtb/MapArea.h | 40 ++++++++++++++++++++++++++++++++ server/gameserver/mtb/mtb.all.cc | 16 +++++++++++++ server/tools/protobuild/mt.proto | 16 ++++++++++--- 6 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 server/gameserver/mt/MapArea.cc create mode 100644 server/gameserver/mt/MapArea.h create mode 100644 server/gameserver/mtb/MapArea.h diff --git a/server/gameserver/mt/MapArea.cc b/server/gameserver/mt/MapArea.cc new file mode 100644 index 00000000..f74b834b --- /dev/null +++ b/server/gameserver/mt/MapArea.cc @@ -0,0 +1,30 @@ +#include "precompile.h" + +#include "mt/MapArea.h" + +IMPL_TABLE(mt::MapArea) +std::map> mt::MapArea::map_areas; + +namespace mt +{ + void MapArea::Init1() + { + auto itr = map_areas.find(map_id()); + if (itr != map_areas.end()) { + itr->second.push_back(this); + } else { + map_areas[map_id()] = std::vector({this}); + } + { + std::vector strings; + a8::Split(area_center(), strings, ':'); + } + } + + std::vector* MapArea::GetAreas(int map_id) + { + auto itr = map_areas.find(map_id); + return itr != map_areas.end() ? &itr->second : nullptr; + } + +} diff --git a/server/gameserver/mt/MapArea.h b/server/gameserver/mt/MapArea.h new file mode 100644 index 00000000..61a87ca3 --- /dev/null +++ b/server/gameserver/mt/MapArea.h @@ -0,0 +1,24 @@ +#pragma once + +#include "mt/macro.h" +#include "mtb/MapArea.h" + +namespace mt +{ + + DECLARE_AUTO_ID_TABLE(MapArea, mtb::MapArea, + "mapArea@mapArea.csv" + ) + public: + + void Init1(); + const glm::vec2 GetCenter() { return center_; }; + + static std::vector* GetAreas(int map_id); + + private: + glm::vec2 center_ = glm::vec2(0.0f, 0.0f); + static std::map> map_areas; + }; + +} diff --git a/server/gameserver/mt/MetaMgr.cc b/server/gameserver/mt/MetaMgr.cc index 9fa001bb..d147e4b5 100644 --- a/server/gameserver/mt/MetaMgr.cc +++ b/server/gameserver/mt/MetaMgr.cc @@ -36,6 +36,7 @@ #include "mt/SafeAreaPos.h" #include "mt/Skill.h" #include "mt/SkillNumber.h" +#include "mt/MapArea.h" #include "app.h" @@ -102,6 +103,7 @@ namespace mt RegMetaTable(res_path_); RegMetaTable(res_path_); RegMetaTable(res_path_); + RegMetaTable(res_path_); } void MetaMgr::Load() diff --git a/server/gameserver/mtb/MapArea.h b/server/gameserver/mtb/MapArea.h new file mode 100644 index 00000000..d32c9b37 --- /dev/null +++ b/server/gameserver/mtb/MapArea.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +namespace mtb +{ + + class MapArea + { + public: + + a8::reflect::Class* GetClass() const; + int map_id() const { return map_id_; }; + int area_type() const { return area_type_; }; + int area_subtype() const { return area_subtype_; }; + const std::string area_center() const { return area_center_; }; + float area_width() const { return area_width_; }; + float area_height() const { return area_height_; }; + + bool has_map_id() const { return __flags__.test(0);}; + bool has_area_type() const { return __flags__.test(1);}; + bool has_area_subtype() const { return __flags__.test(2);}; + bool has_area_center() const { return __flags__.test(3);}; + bool has_area_width() const { return __flags__.test(4);}; + bool has_area_height() const { return __flags__.test(5);}; + + protected: + + int map_id_ = 0; + int area_type_ = 0; + int area_subtype_ = 0; + std::string area_center_; + float area_width_ = 0.0f; + float area_height_ = 0.0f; + +public: + std::bitset<6> __flags__; + }; + +}; diff --git a/server/gameserver/mtb/mtb.all.cc b/server/gameserver/mtb/mtb.all.cc index dfca90af..b9fabac0 100644 --- a/server/gameserver/mtb/mtb.all.cc +++ b/server/gameserver/mtb/mtb.all.cc @@ -4,6 +4,7 @@ #include "mtb/Parameter.h" #include "mtb/Attr.h" #include "mtb/Map.h" +#include "mtb/MapArea.h" #include "mtb/MapThing.h" #include "mtb/SafeArea.h" #include "mtb/SafeAreaPos.h" @@ -89,6 +90,21 @@ namespace mtb return meta_class; } + a8::reflect::Class* MapArea::GetClass() const + { + a8::reflect::Class* meta_class = nullptr; + if (!meta_class) { + meta_class = new a8::reflect::Class("MapArea", 6, 0); + meta_class->SetSimpleField(0, "map_id", a8::reflect::ET_INT32, my_offsetof2(MapArea, map_id_)); + meta_class->SetSimpleField(1, "area_type", a8::reflect::ET_INT32, my_offsetof2(MapArea, area_type_)); + meta_class->SetSimpleField(2, "area_subtype", a8::reflect::ET_INT32, my_offsetof2(MapArea, area_subtype_)); + meta_class->SetSimpleField(3, "area_center", a8::reflect::ET_STRING, my_offsetof2(MapArea, area_center_)); + meta_class->SetSimpleField(4, "area_width", a8::reflect::ET_FLOAT, my_offsetof2(MapArea, area_width_)); + meta_class->SetSimpleField(5, "area_height", a8::reflect::ET_FLOAT, my_offsetof2(MapArea, area_height_)); + } + return meta_class; + } + a8::reflect::Class* MapThing::GetClass() const { a8::reflect::Class* meta_class = nullptr; diff --git a/server/tools/protobuild/mt.proto b/server/tools/protobuild/mt.proto index 42b51984..ffbc1a4d 100755 --- a/server/tools/protobuild/mt.proto +++ b/server/tools/protobuild/mt.proto @@ -15,9 +15,9 @@ message Attr message Map { - optional int32 map_id = 1; //地图id - optional string template_list = 2; //模板列表 - optional string map_name = 3; //地图名 + optional int32 map_id = 1; + optional string template_list = 2; + optional string map_name = 3; optional float map_width = 4; optional float map_height = 5; optional string airdrops = 6; @@ -35,6 +35,16 @@ message Map optional float scale = 18; } +message MapArea +{ + optional int32 map_id = 1; + optional int32 area_type = 2; + optional int32 area_subtype = 3; + optional string area_center = 4; + optional float area_width = 5; + optional float area_height = 6; +} + message MapThing { optional int32 thing_id = 1; //物件id