diff --git a/server/gameserver/CMakeLists.txt b/server/gameserver/CMakeLists.txt index b231a3d..e03a6cb 100644 --- a/server/gameserver/CMakeLists.txt +++ b/server/gameserver/CMakeLists.txt @@ -5,7 +5,7 @@ set(GAME_ID 2001) set(CMAKE_BUILD_TYPE "Debug") set(CMAKE_BUILD_TYPE "Release") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID}") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID}") set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID}") include_directories( diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 42a0ae0..eab57f3 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1476,21 +1476,11 @@ void Room::NotifyWxVoip() &xtimer_attacher.timer_list_); } -void Room::CreateBornPoint(int x, int y, int width, int height, int hum_limit) -{ - BornPoint born_point; - born_point.born_point_id = AllocUniid(); - born_point.pos = a8::Vec2(x, y); - born_point.rad = std::min(width, height); - born_point.hum_limit = hum_limit; - born_point_hash_[born_point.born_point_id] = born_point; -} - BornPoint* Room::AllocBornPoint(Human* hum) { BornPoint* born_point = nullptr; for (auto& pair : born_point_hash_) { - if (pair.second.player_num + pair.second.android_num < pair.second.hum_limit) { + if (pair.second.player_num + pair.second.android_num < pair.second.thing_tpl->i->param1()) { born_point = &pair.second; break; } @@ -1555,10 +1545,7 @@ void Room::CreateMapObject(MetaData::MapTplThing& thing_tpl) void Room::CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl) { - CreateBornPoint(thing_tpl.i->x(), - thing_tpl.i->y(), - thing_tpl.i->width(), - thing_tpl.i->height(), - thing_tpl.i->param1() - ); + BornPoint born_point; + born_point.thing_tpl = &thing_tpl; + born_point_hash_[AllocUniid()] = born_point; } diff --git a/server/gameserver/room.h b/server/gameserver/room.h index e2baf6a..13a674a 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -121,7 +121,6 @@ private: void OnGameOver(); void RandRemoveAndroid(); void NotifyWxVoip(); - void CreateBornPoint(int x, int y, int width, int height, int hum_limit); BornPoint* AllocBornPoint(Human* hum); void CreateMapObject(MetaData::MapTplThing& thing_tpl); void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl); diff --git a/server/gameserver/types.cc b/server/gameserver/types.cc index a041cea..2d20546 100644 --- a/server/gameserver/types.cc +++ b/server/gameserver/types.cc @@ -33,13 +33,21 @@ void Skin::ToPB(cs::MFSkin* pb_obj) a8::Vec2 BornPoint::RandPoint() const { - a8::Vec2 born_point = pos; - a8::Vec2 dir = born_point; - dir.Normalize(); - dir.Rotate(a8::RandAngle()); - if (rad < 2) { - return born_point; - } else { - return born_point + dir * (rand() % (int)rad); + a8::Vec2 born_point = a8::Vec2(thing_tpl->i->x(), thing_tpl->i->y()); + MetaData::Player* hum_meta = MetaMgr::Instance()->GetPlayer(40002); + if (hum_meta) { + born_point.x -= thing_tpl->i->width() / 2; + born_point.y -= thing_tpl->i->height() / 2; + born_point.x += hum_meta->i->radius() / 2; + born_point.y += hum_meta->i->radius() / 2; + int rand_x = thing_tpl->i->width() - hum_meta->i->radius(); + int rand_y = thing_tpl->i->height() - hum_meta->i->radius(); + if (rand_x > 0) { + born_point.x += rand() % rand_x; + } + if (rand_y > 0) { + born_point.y += rand() % rand_y; + } } + return born_point; } diff --git a/server/gameserver/types.h b/server/gameserver/types.h index 52e1c4f..ac3131c 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -22,6 +22,7 @@ namespace MetaData struct SafeArea; struct Equip; struct EquipUpgrade; + struct MapTplThing; } namespace cs @@ -121,13 +122,9 @@ struct CarObject struct BornPoint { - int born_point_id = 0; - a8::Vec2 pos; - float rad = 0.0f; - + MetaData::MapTplThing* thing_tpl = nullptr; int player_num = 0; int android_num = 0; - int hum_limit = 0; a8::Vec2 RandPoint() const; };