From 24b37d8d32e4fc5a582f6f263bfb240a110e0299 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 7 Sep 2019 21:30:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9C=B0=E5=9B=BE=E8=AF=BB?= =?UTF-8?q?=E8=A1=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/constant.h | 5 ---- server/gameserver/room.cc | 33 ++++++++++++++++--------- server/tools/protobuild/metatable.proto | 2 ++ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 0e3b2b9..10d7458 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -192,11 +192,6 @@ const int GUN_SLOT2 = 2; const int FRAG_SLOT = 3; const int SMOKE_SLOT = 4; -const int MAP_HEIGHT = 8192; -const int MAP_WIDTH = 8192; -const int MAP_CELL_WIDTH = 64 * 8; -const int MAP_GRID_WIDTH = 64; - const int DOOR_THING_ID = 61701; const int FIGHTING_MODE_BULLET_NUM = 10000 * 10000; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 3588c77..32843ba 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -39,6 +39,15 @@ Room::~Room() void Room::Init() { +const int MAP_HEIGHT = 8192; +const int MAP_WIDTH = 8192; +const int MAP_CELL_WIDTH = 64 * 8; +const int MAP_GRID_WIDTH = 64; + #if 1 + ((metatable::Map*)map_meta->i)->set_map_width(MAP_WIDTH); + ((metatable::Map*)map_meta->i)->set_map_height(MAP_HEIGHT); + #endif + xtimer.Init(RoomXGetTickCount, this, 100, 100); xtimer_attacher.xtimer = &xtimer; grid_service.Init(MAP_WIDTH, MAP_HEIGHT, MAP_CELL_WIDTH); @@ -518,14 +527,14 @@ int Room::CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv) entity->pos = pos; #if 1 { - if (entity->pos.x >= MAP_WIDTH) { - entity->pos.x = MAP_WIDTH - 1; + if (entity->pos.x >= map_meta->i->map_width()) { + entity->pos.x = map_meta->i->map_width() - 1; } if (entity->pos.x < 1.0f) { entity->pos.x = 1.0f; } - if (entity->pos.y >= MAP_HEIGHT) { - entity->pos.y = MAP_HEIGHT - 1; + if (entity->pos.y >= map_meta->i->map_height()) { + entity->pos.y = map_meta->i->map_height() - 1; } if (entity->pos.y < 1.0f) { entity->pos.y = 1.0f; @@ -646,14 +655,14 @@ bool Room::OverBorder(const a8::Vec2 pos, float radius) return true; } int right_x = pos.x + radius; - if (right_x > MAP_WIDTH) { + if (right_x > map_meta->i->map_width()) { return true; } } //检查y轴 { int up_y = pos.y + radius; - if (up_y > MAP_HEIGHT) { + if (up_y > map_meta->i->map_height()) { return true; } int down_y = pos.y - radius; @@ -980,8 +989,8 @@ void Room::UpdateGas() gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002); gas_data.gas_progress = gas_data.old_area_meta->i->rad(); gas_data.gas_start_frameno = frame_no; - gas_data.pos_old = a8::Vec2(MAP_WIDTH / 2.0f, - MAP_HEIGHT / 2.0f); + gas_data.pos_old = a8::Vec2(map_meta->i->map_width() / 2.0f, + map_meta->i->map_height() / 2.0f); gas_data.pos_old_bk = gas_data.pos_old; { bool gen_ok = GenSmallCircle(gas_data.pos_old, @@ -1253,14 +1262,14 @@ void Room::AirDrop(int appear_time, int box_id) if (box_pos.x < 1.0f) { box_pos.x = 1.0f; } - if (box_pos.x >= MAP_WIDTH) { - box_pos.x = MAP_WIDTH - 1; + if (box_pos.x >= map_meta->i->map_width()) { + box_pos.x = map_meta->i->map_width() - 1; } if (box_pos.y < 1.0f) { box_pos.y = 1.0f; } - if (box_pos.y >= MAP_HEIGHT) { - box_pos.y = MAP_HEIGHT - 1; + if (box_pos.y >= map_meta->i->map_height()) { + box_pos.y = map_meta->i->map_height() - 1; } AabbCollider air_drop_aabb_box; { diff --git a/server/tools/protobuild/metatable.proto b/server/tools/protobuild/metatable.proto index 09aea6b..b4b2bc0 100755 --- a/server/tools/protobuild/metatable.proto +++ b/server/tools/protobuild/metatable.proto @@ -17,6 +17,8 @@ message Map optional int32 map_id = 1; //地图id optional string template_list = 2; //模板列表 optional string map_name = 3; //地图名 + optional float map_width = 4; + optional float map_height = 5; } message MapThing