merge master
This commit is contained in:
commit
81f5f5c983
@ -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
|
||||
|
@ -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<GridCell*>& grid_list)
|
||||
GetAllCells(new_grid_id, grid_list);
|
||||
}
|
||||
|
||||
void GridService::Get123(int grid_id, std::set<GridCell*>& 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<GridCell*>& 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<GridCell*>& 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<GridCell*>& 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<GridCell*>& 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<GridCell*>& 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_;
|
||||
|
@ -11,11 +11,6 @@ struct GridCell
|
||||
std::set<Bullet*> 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<GridCell*>& grid_list, Entity* entity);
|
||||
|
||||
private:
|
||||
void Get123(int grid_id, std::set<GridCell*>& grid_list);
|
||||
void Get456(int grid_id, std::set<GridCell*>& grid_list);
|
||||
void Get789(int grid_id, std::set<GridCell*>& grid_list);
|
||||
void Get147(int grid_id, std::set<GridCell*>& grid_list);
|
||||
void Get258(int grid_id, std::set<GridCell*>& grid_list);
|
||||
void Get369(int grid_id, std::set<GridCell*>& grid_list);
|
||||
|
||||
inline void GetGridList(int grid_id, int offset,
|
||||
std::set<GridCell*>& grid_list);
|
||||
void ComputeDiff(int old_grid_id, int new_grid_id,
|
||||
|
@ -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<std::string> strings1;
|
||||
a8::Split(extra_drop, strings1, '|');
|
||||
for (std::string& str1 : strings1) {
|
||||
std::vector<std::string> 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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -83,6 +83,8 @@ struct PlayerStats
|
||||
int gold = 0;
|
||||
int score = 0;
|
||||
|
||||
std::vector<std::pair<int, int>> extra_drop;
|
||||
|
||||
int killer_id = 0;
|
||||
std::string killer_name;
|
||||
int weapon_id = 0;
|
||||
|
@ -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; //杀手名称
|
||||
|
2
third_party/a8engine
vendored
2
third_party/a8engine
vendored
@ -1 +1 @@
|
||||
Subproject commit bb10963a71fbd0d6dd145dc7fd333b09ab708300
|
||||
Subproject commit 88b75d811aecd688865fddf4d47413a50f953d34
|
Loading…
x
Reference in New Issue
Block a user