diff --git a/server/gameserver/CMakeLists.txt b/server/gameserver/CMakeLists.txt index f0e2247..b231a3d 100644 --- a/server/gameserver/CMakeLists.txt +++ b/server/gameserver/CMakeLists.txt @@ -1,17 +1,12 @@ project(gameserver) cmake_minimum_required(VERSION 2.8) -if (${GAME_ID}) - message(GAME_ID: ${GAME_ID}) -else() - set(GAME_ID 2001) - message(GAME_ID: ${GAME_ID}) -endif() +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} -DA8_TCP_SESSION2=1") -set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID} -DA8_TCP_SESSION2=1") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -std=gnu++11 -DGAME_ID=${GAME_ID}") +set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -std=gnu++11 -DGAME_ID=${GAME_ID}") include_directories( AFTER diff --git a/server/gameserver/gridservice.cc b/server/gameserver/gridservice.cc index 4a84a7d..c600db6 100644 --- a/server/gameserver/gridservice.cc +++ b/server/gameserver/gridservice.cc @@ -4,6 +4,12 @@ #include "human.h" #include "bullet.h" +/* + 1 2 3 + 4 5 6 + 7 8 9 + */ + GridService::GridService() { @@ -74,48 +80,6 @@ void GridService::GetAllCellsByXy(int x, int y, std::set& grid_list) GetAllCells(new_grid_id, grid_list); } -void GridService::Get123(int grid_id, std::set& grid_list) -{ - GetGridList(grid_id, 1, grid_list); - GetGridList(grid_id, 2, grid_list); - GetGridList(grid_id, 3, grid_list); -} - -void GridService::Get456(int grid_id, std::set& grid_list) -{ - GetGridList(grid_id, 4, grid_list); - GetGridList(grid_id, 5, grid_list); - GetGridList(grid_id, 6, grid_list); -} - -void GridService::Get789(int grid_id, std::set& grid_list) -{ - GetGridList(grid_id, 7, grid_list); - GetGridList(grid_id, 8, grid_list); - GetGridList(grid_id, 9, grid_list); -} - -void GridService::Get147(int grid_id, std::set& grid_list) -{ - GetGridList(grid_id, 1, grid_list); - GetGridList(grid_id, 4, grid_list); - GetGridList(grid_id, 7, grid_list); -} - -void GridService::Get258(int grid_id, std::set& grid_list) -{ - GetGridList(grid_id, 2, grid_list); - GetGridList(grid_id, 5, grid_list); - GetGridList(grid_id, 8, grid_list); -} - -void GridService::Get369(int grid_id, std::set& grid_list) -{ - GetGridList(grid_id, 3, grid_list); - GetGridList(grid_id, 6, grid_list); - GetGridList(grid_id, 9, grid_list); -} - void GridService::AddHuman(Human* hum) { int x = (int)hum->pos.x + cell_width_; diff --git a/server/gameserver/gridservice.h b/server/gameserver/gridservice.h index 2f12519..52510bf 100644 --- a/server/gameserver/gridservice.h +++ b/server/gameserver/gridservice.h @@ -11,11 +11,6 @@ struct GridCell std::set bullet_list; }; -/* - 1 2 3 - 4 5 6 - 7 8 9 - */ class Human; class Entity; class Room; @@ -47,13 +42,6 @@ class GridService void RemoveFromGridList(std::set& grid_list, Entity* entity); private: - void Get123(int grid_id, std::set& grid_list); - void Get456(int grid_id, std::set& grid_list); - void Get789(int grid_id, std::set& grid_list); - void Get147(int grid_id, std::set& grid_list); - void Get258(int grid_id, std::set& grid_list); - void Get369(int grid_id, std::set& grid_list); - inline void GetGridList(int grid_id, int offset, std::set& grid_list); void ComputeDiff(int old_grid_id, int new_grid_id, diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index f8049e7..6b3c453 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1983,6 +1983,22 @@ void Human::InternalSendGameOver() hum->stats.history_kills = data.Get("kill_his"); hum->stats.history_damage_amount = data.Get("harm_his"); hum->stats.history_heal_amount = data.Get("add_HP_his"); + { + std::string extra_drop = data.Get("extra_drop"); + std::vector strings1; + a8::Split(extra_drop, strings1, '|'); + for (std::string& str1 : strings1) { + std::vector strings2; + a8::Split(str1, strings2, ':'); + if (strings2.size() == 2) { + hum->stats.extra_drop.push_back(std::make_pair( + a8::XValue(strings2[0]).GetInt(), + a8::XValue(strings2[1]).GetInt() + ) + ); + } + } + } cs::SMGameOver msg; hum->FillSMGameOver(msg); hum->SendNotifyMsg(msg); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 5d0470a..4b74c1d 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -961,11 +961,13 @@ void Player::UpdateDropWeapon() if (drop_ok) { if (drop_weapon_idx == 0 || drop_weapon_idx == GUN_SLOT1 || - drop_weapon_idx == GUN_SLOT2 + drop_weapon_idx == GUN_SLOT2 || + drop_weapon_idx == FRAG_SLOT || + drop_weapon_idx == SMOKE_SLOT ) { a8::Vec2 dir = a8::Vec2::UP; dir.Rotate(a8::RandAngle()); - room->CreateLoot(weapon_id, pos + dir * (25 + rand() % 50), 1, weapon_lv); + room->CreateLoot(weapon_id, pos + dir * (40 + rand() % 50), 1, weapon_lv); } if (weapon_ammo > 0) { MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet()); @@ -973,7 +975,8 @@ void Player::UpdateDropWeapon() int volume = GetVolume(bullet_meta->i->_inventory_slot()); int inventory = GetInventory(bullet_meta->i->_inventory_slot()); int add_inventory = std::min(weapon_ammo, volume - std::min(volume, inventory)); - if (add_inventory > 0) { + if (add_inventory > 0 && + !(drop_weapon_idx == FRAG_SLOT || drop_weapon_idx == SMOKE_SLOT)) { AddInventory(bullet_meta->i->_inventory_slot(), add_inventory); } int drop_num = weapon_ammo - add_inventory; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index c8023b9..2e4e217 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -44,20 +44,6 @@ void Room::Init() map_service.Init(MAP_WIDTH / MAP_GRID_WIDTH, MAP_HEIGHT / MAP_GRID_WIDTH, MAP_GRID_WIDTH); CreateThings(); - #if 0 - stats_timer_ = a8::Timer::Instance()->AddRepeatTimer( - 1000 * 5, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Room* room = (Room*)param.sender.GetUserData(); - if (!room->game_over) { - room->OutputDebugLog(); - } - } - ); - #endif if (App::Instance()->HasFlag(1)) { xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3, a8::XParams() @@ -80,10 +66,6 @@ void Room::UnInit() game_over_timer = nullptr; } xtimer_attacher.ClearTimerList(); - if (stats_timer_) { - a8::Timer::Instance()->DeleteTimer(stats_timer_); - stats_timer_ = nullptr; - } for (auto& pair : accountid_hash_) { PlayerMgr::Instance()->RemovePlayerBySocket(pair.second->socket_handle); } @@ -138,9 +120,6 @@ void Room::Update(int delta_time) elapsed_time_ -= 50; } long long end_tick = a8::XGetTickCount(); - if (end_tick - begin_tick > profile.max_rundelay) { - profile.max_rundelay = end_tick - begin_tick; - } } int Room::GetPlayerNum() @@ -1080,44 +1059,6 @@ bool Room::GenSmallCircle(a8::Vec2 big_circle_pos, float big_circle_rad, float s return true; } -void Room::OutputDebugLog() -{ - a8::UdpLog::Instance()->Debug("roomid:%d max_rundelay:%d frame_no:%d game_over:%d game_over_frameno:%d " - "elapsed_time:%d alive_count:%d current_uniid:%d " - "state:%d accountid_hash.size:%d moveable_hash_.size:%d " - "uniid_hash.size:%d human_hash.size:%d ", - { - room_uuid, - profile.max_rundelay, - frame_no, - game_over ? 1 : 0, - game_over_frameno, - elapsed_time_, - alive_count_, - current_uniid, - (int)gas_data.gas_mode, - accountid_hash_.size(), - moveable_hash_.size(), - uniid_hash_.size(), - human_hash_.size(), - }); - { - int entity_num_arr[ET_MAX] = {0}; - a8::MutableXObject* logobj = a8::MutableXObject::NewObject(); - for (auto& pair : uniid_hash_) { - if (pair.second->entity_type >= 0 && pair.second->entity_type < ET_MAX) { - ++(entity_num_arr[pair.second->entity_type]); - } - } - for (int i = 0; i < ET_MAX; ++i) { - logobj->SetVal(a8::XValue(i).GetString(), entity_num_arr[i]); - } - a8::UdpLog::Instance()->Debug("roomid:%d %s", {room_uuid, logobj->ToJsonStr()}); - delete logobj; - } - profile.max_rundelay = 0; -} - void Room::AutoMatchTeam() { #if 0 diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 80fe864..dc8e307 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -16,11 +16,6 @@ namespace MetaData struct AirLine; } -struct RoomProfile -{ - long long max_rundelay = 0; -}; - struct timer_list; struct xtimer_list; class Entity; @@ -45,7 +40,6 @@ public: long long game_over_frameno = 0; long long game_over_tick = 0; timer_list* game_over_timer = nullptr; - RoomProfile profile; a8::XTimer xtimer; Plane plane; GridService grid_service; @@ -105,7 +99,6 @@ private: void UpdateGas(); bool GenSmallCircle(a8::Vec2 big_circle_pos, float big_circle_rad, float small_circle_rad, a8::Vec2& out_pos); - void OutputDebugLog(); void AutoMatchTeam(); void MatchTeam(Human* hum); void InitAirDrop(); @@ -124,7 +117,6 @@ private: void NotifyWxVoip(); private: - timer_list* stats_timer_ = nullptr; int elapsed_time_ = 0; int alive_count_ = 0; MetaData::AirLine* airline_ = nullptr; diff --git a/server/gameserver/types.h b/server/gameserver/types.h index d95fe21..273b7dc 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -83,6 +83,8 @@ struct PlayerStats int gold = 0; int score = 0; + std::vector> extra_drop; + int killer_id = 0; std::string killer_name; int weapon_id = 0; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index a66b2f6..facaf89 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -532,6 +532,8 @@ message MFPlayerStats optional int32 gold = 10; //金币 optional int32 score = 11; //积分 + repeated MFPair extra_drop = 12; //额外掉落,key:item_id value:数量(看广告) + optional bool dead = 5; //是否已死亡 optional int32 killer_id = 7; //杀手id(自杀时为自己) 特殊id: -1:倒在安全区 optional string killer_name = 40; //杀手名称 diff --git a/third_party/a8engine b/third_party/a8engine index bb10963..88b75d8 160000 --- a/third_party/a8engine +++ b/third_party/a8engine @@ -1 +1 @@ -Subproject commit bb10963a71fbd0d6dd145dc7fd333b09ab708300 +Subproject commit 88b75d811aecd688865fddf4d47413a50f953d34