This commit is contained in:
aozhiwei 2019-03-13 17:05:22 +08:00
parent 4faa965d7f
commit 1ad123d4c1
9 changed files with 80 additions and 251 deletions

View File

@ -3,9 +3,6 @@
enum SocketFrom_e
{
SF_GameGate,
SF_DBServer,
SF_BattleServer,
SF_DBProxy,
};
enum InnerMesssage_e
@ -16,10 +13,7 @@ enum InnerMesssage_e
IM_DBSConnDisconnect,
IM_BSConnDisconnect,
IM_LoadConfig,
IM_DPSConnDisconnect,
IM_HttpResponse,
IM_AddHero2PVPTeam = 200,
};
//网络处理对象
@ -30,16 +24,6 @@ enum NetHandler_e
HID_Room,
HID_RoomMgr,
HID_GGListener,
HID_Storage,
HID_DBEngine,
HID_Mission,
HID_Shop,
HID_MailMgr,
HID_ArenaMgr,
HID_ActivityMgr,
HID_FriendMgr,
HID_GuildMgr,
HID_SpaMgr,
};
enum PlayerState_e
@ -58,230 +42,13 @@ enum VirtualItemId_e
enum SyncData_e
{
SYNC_Data_Exp = 0,
SYNC_Data_Gold,
SYNC_Status_Flags,
SYNC_Place_Param,
SYNC_Opened_stage,
SYNC_Passed_stage,
SYNC_Bag_Capacity,
SYNC_Bag_Unlock_Remain_Seconds,
SYNC_Hero_list,
SYNC_Current_Chapter_Id,
SYNC_passed_chapter_id,
SYNC_explored_max_chapter_id,
SYNC_soul_utensil,
SYNC_soul_stone,
SYNC_Pickaxe,
SYNC_Dig_Mine_Count_Day,
SYNC_spa_id,
SYNC_spa_reward_box_count,
SYNC_pve_leader_id,
SYNC_Place_Param2,
SYNC_Place_Param3,
SYNC_curr_pos_x,
SYNC_curr_pos_y,
SYNC_data_guild_id,
SYNC_path_points,
SYNC_hint_flags,
SYNC_level,
SYNC_fight_value,
};
enum HeroAbilityType
{
HAT_hp = 1,
HAT_pa = 2,
HAT_pd = 3,
HAT_ma = 4,
HAT_md = 5,
HAT_cc = 6,
HAT_anger = 7,
HAT_ct = 8,
HAT_dd = 9,
};
enum MailType
{
MT_NORMAL_PERSONAL_MAIL = 0,
MT_SYS_PERSONAL_MAIL = 1,
MT_GROUP_MAIL = 2,
};
enum HintFlag
{
HF_xx0 = 0,
HF_ACTIVITY = 1,
HF_UNREAD_MAIL = 2,
HF_DAILY_MISSION_RECEIVABLE = 3,
HF_CHALLENGE_MISSION_RECEIVABLE = 4,
HF_ACHIEVMENT_MISSION_RECEIVABLE = 5,
HF_DAILY_MISSION_ACTIVE_RECEIVABLE = 6,
HF_HAS_PET_LOTTERY_DAILY_FREE = 7,
HF_HAS_PET_LOTTERY_LUXURY_FREE = 8,
HF_HAS_PET_MISSION_RECEIVABLE = 9,
HF_ACTIVITY_SIGNIN = 10,
HF_DIANJIN = 11,
HF_GUILD_MISSION_RECEIVABLE = 12,
HF_GUILD_SKILL_CAN_UPDATE = 13,
HF_GUILD_BOSS_AWARD_RECEIVABLE = 14,
HF_HAS_NEW_TITLE = 15,
HF_HAS_PARTY_INVITE = 16,
HF_HAS_UNUSE_VOW_TIMES = 17,
};
enum ACTIVITY_TYPE
{
AT_FIRST_RECHARGE = 1, //首充
AT_SEVEN_DAY = 2, //7日礼包
AT_LEVEL_AWARD = 3, //等级礼包
AT_SIGN = 4, //月签到
AT_ACCUMULATIVE_RECHARGE = 5, //累计充值
AT_LEVEL_LIMIT = 6, //限量等级礼包
AT_FIGHT_RANK = 7, //战力达人
AT_GROW_UP = 8, //成长计划
AT_ACCUMULATIVE_CRYSTAL = 9, //累计消费
AT_WHEEL = 10, //转盘
AT_ONLINETIME = 11, //在线时长
AT_RECHARGE_FEEDBACK = 12, //单笔反馈
AT_RECHARGE_DAY = 13, //累计充值天数
AT_RECHARGE_SELECT = 14, //自选豪礼
AT_RECHARGE_DAY_SMALL = 15, //天天礼包
};
enum TASK_NO
{
TN_mission_point = 1, // 记录日常任务活跃点数
TN_mission_treasurebox = 2, // 记录玩家每日任务宝箱领取状态 1:每日任务宝箱,按位存
TN_enter_arena_count = 10, //进入竞技场次数 0累计 1:今天
TN_equip_compose_count = 11, //装备合成次数 0累计 1:今天
TN_hero_upgrade_count = 12, //武将升级次数 0累计 1:今天
TN_enter_spa_count = 13, //进入温泉次数 0累计 1:今天
TN_summon_hero_count = 14, //召唤武将次数 0累计 1:今天
TN_arena = 20, // 1:挑战次数 2:购买次数
TN_spa_obtain_hero_count = 30, //温泉领取英雄宝箱次数 只可领取一次
TN_activity1 = 41, //1:已签到天数, 2:今天是否签到
TN_activity2 = 42, //1:当前已经领取的id
TN_activity3 = 43, //1:今天已经领取的id
TN_login = 80, //1:今天登陆次数
TN_last_quit_guild_time = 220, // 退出公会的24小时内不可操作某些功能此为记录该最后退出公会时间
TN_guild_donate_count = 240, // 每日公会贡献记录 (1 : 每日 2: 累计)
};
enum MissionType_e
{
MT_daily = 1, //每日任务
MT_challenge,
MT_achievment,
};
enum MissionStatus_e
{
MS_default = 1, //未接取
MS_complete_already_taken, //完成且已领奖
MS_accept, //已接取
MS_complete_not_taken, //完成但是未领奖
};
enum MissionBoxTakenStatus_e
{
MBTS_cannot_take = 1, //未满足条件 不能领取
MBTS_can_take, // 可领取
MBTS_already_taken, //已经领取
};
enum BattleType_e
{
BT_NormalInstance = 0, //普通副本
BT_ElitistInstance = 1, //精英副本
BT_Arena = 2, //竞技场
};
enum RankingType_e
{
RT_Arena = 1, //竞技场排行
};
enum GetRoleType_e
{
GR_Arena = 1,
};
enum GetHumanInfo_e
{
GH_Arena = 1,
};
enum Week_e
{
MONDAY = 1,
};
enum HintFlags_e
{
HF_Mail = 0,
HF_Activity = 1,
HF_Daily_Mission_Receivable = 2,
HF_Spa = 3,
};
//Item产出原因
enum ItemProduceReason_e
{
IPR_Pass_Stage = 1, //通关
IPR_Place = 2, //挂机
IPR_Activity = 3, //活动
IPR_Mail = 4, //邮件附件
IPR_Hero_Summon = 5, //英雄合成
IPR_Enjoy_Spa = 6, //泡温泉
};
//Item消耗原因
enum ItemConsumeReason_e
{
ICR_Hero_Summon = 1, //英雄合成
ICR_Hero_Upgrade_Level = 2, //英雄升级
ICR_Hero_Upgrade_Quality = 3, //英雄进阶
ICR_Hero_Upgrade_Equip_Level = 4, //装备强化
ICR_Hero_Upgrade_Equip_Quality = 5, //装备进阶
};
enum NoticeType
{
NT_Obtain_Hero = 10001, //获得英雄
};
const char* const PROJ_NAME_FMT = "game%d_gameserver";
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
const int POSTFIX_LEN = 7;
const float TEN_W = 10000 * 10;
const int INIT_CHAPTER_ID = 110100;
const int PLACE_REWARD_ITEM_CAPACITY = 6;
const int QUALITY_MAX = 5; //最高品质
const int EQUIP_POS_MAX = 6; //装备最高位
const int EQUIP_HERO_INTERVAL_LEVEL = 5; //装备等级不超过武将等级5级
const int SOUL_UTENSIL_INTERVAL_LEVEL = 1; //魂石等级不超过魂导器等级1级
const int SYS_RESET_TIME = 2*60; //每日两点重置
const int ELITIST_INSTANCE_TILI = 5; //精英副本体力
const int GEMSTONE_SLOT = 3; //宝石槽数量
const int SPA_MEMBER = 3; //泡温泉用户数量
const int SPA_ENJOY_TIME = 4; //泡温泉时间4个小时 单位s
const int SPA_BARRAGE_COUNT = 100; //温泉弹幕缓存量
const int STORAGE_GRID_MAX = 50; //仓库格子上限
const int REFRESH_COST = 10; //商店刷新需要的钱
const int MAX_PVP_RANK = 2000;
const int MAX_PLACE_REWARD_COUNT = 8;//算上经验和金币两个

View File

@ -7,22 +7,22 @@ namespace MetaData
struct Map
{
const metatable::Map* meta = nullptr;
const metatable::Map* i = nullptr;
};
struct SafeArea
{
const metatable::SafeArea* meta = nullptr;
const metatable::SafeArea* i = nullptr;
};
struct Item
{
const metatable::Item* meta = nullptr;
const metatable::Item* i = nullptr;
};
struct Equip
{
const metatable::Equip* meta = nullptr;
const metatable::Equip* i = nullptr;
};
}

View File

@ -47,26 +47,26 @@ private:
for (auto& meta : map_meta_list) {
MetaData::Map& item = a8::FastAppend(map_list);
item.meta = &meta;
gamemap_hash[item.meta->map_id()] = &item;
item.i = &meta;
gamemap_hash[item.i->map_id()] = &item;
}
for (auto& meta : safearea_meta_list) {
MetaData::SafeArea& item = a8::FastAppend(safearea_list);
item.meta = &meta;
safearea_hash[item.meta->id()] = &item;
item.i = &meta;
safearea_hash[item.i->id()] = &item;
}
for (auto& meta : item_meta_list) {
MetaData::Item& item = a8::FastAppend(item_list);
item.meta = &meta;
item_hash[item.meta->id()] = &item;
item.i = &meta;
item_hash[item.i->id()] = &item;
}
for (auto& meta : equip_meta_list) {
MetaData::Equip& item = a8::FastAppend(equip_list);
item.meta = &meta;
equip_hash[item.meta->id()] = &item;
item.i = &meta;
equip_hash[item.i->id()] = &item;
}
}

View File

@ -15,6 +15,7 @@ class Player
enum { HID = HID_Player };
public:
std::string account_id;
int obj_uniid = 0;
float health = 0.0;

View File

@ -0,0 +1,30 @@
#include "precompile.h"
#include "playermgr.h"
#include "player.h"
#include "cs_proto.pb.h"
#include "room.h"
const int ROOM_MAX_PLAYER_NUM = 50;
bool Room::IsFull()
{
return accountid_hash_.size() >= ROOM_MAX_PLAYER_NUM;
}
int Room::GetPlayerNum()
{
return accountid_hash_.size();
}
Player* Room::GetPlayerByAccountId(const std::string& accountid)
{
auto itr = accountid_hash_.find(accountid);
return itr != accountid_hash_.end() ? itr->second : nullptr;
}
Player* Room::GetPlayerByUniId(int uniid)
{
auto itr = uniid_hash_.find(uniid);
return itr != uniid_hash_.end() ? itr->second : nullptr;
}

View File

@ -1,8 +1,32 @@
#pragma once
enum RoomState_e
{
RS_Inactive = 0,
RS_Waiting = 1,
RS_Moveing = 2
};
namespace MetaData
{
struct Map;
}
class Player;
class Room
{
public:
MetaData::Map* map_meta = nullptr;
bool IsFull();
int GetPlayerNum();
Player* GetPlayerByAccountId(const std::string& accountid);
Player* GetPlayerByUniId(int uniid);
private:
long long room_id_ = 0;
RoomState_e state_ = RS_Inactive;
std::map<std::string, Player*> accountid_hash_;
std::map<int, Player*> uniid_hash_;
};

View File

@ -3,6 +3,7 @@
#include "roommgr.h"
#include "room.h"
#include "cs_proto.pb.h"
#include "GGListener.h"
void RoomMgr::Init()
{
@ -16,5 +17,6 @@ void RoomMgr::UnInit()
void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
{
cs::SMJoinedNotify notifymsg;
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
}

View File

@ -5,6 +5,7 @@ namespace cs
class CMJoin;
}
class Room;
class RoomMgr : public a8::Singleton<RoomMgr>
{
public:
@ -19,4 +20,8 @@ class RoomMgr : public a8::Singleton<RoomMgr>
void UnInit();
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
private:
std::map<long, long, Room*> inactive_room_hash_;
std::map<long long, Room*> room_hash_;
};

View File

@ -449,7 +449,7 @@ message SMReConnect
message CMJoin
{
optional string team_uuid = 2; //id ()
optional int32 team_mode = 3; //
optional int32 team_mode = 3; // 0: 1:
optional int32 player_count = 4; //(1)
optional int32 auto_fill = 5; //
optional int32 bot = 6; //
@ -542,10 +542,10 @@ message CMVoice
//
message SMJoinedNotify
{
optional int32 team_mode = 1;
optional int32 player_id = 2;
optional bool started = 3;
repeated MFPlayerInfo player_infos = 4;
optional int32 team_mode = 1; // 0: 1:
optional int32 player_id = 2; //id
optional bool started = 3; //
repeated MFPlayerInfo player_infos = 4; //
optional int32 map_type = 5;
optional bool elo_start = 6;
}