This commit is contained in:
aozhiwei 2019-07-20 14:40:19 +08:00
parent ec39cb553c
commit 8e66fe2b1d
14 changed files with 60 additions and 80 deletions

View File

@ -29,7 +29,7 @@ public:
if (buflen - offset < sizeof(f8::WSProxyPackHead_C) + p->packlen) { if (buflen - offset < sizeof(f8::WSProxyPackHead_C) + p->packlen) {
break; break;
} }
App::Instance()->AddSocketMsg(SF_GameGate, App::Instance()->AddSocketMsg(kSFGameGate,
(socket_handle << 16) + p->socket_handle, (socket_handle << 16) + p->socket_handle,
p->ip_saddr, p->ip_saddr,
p->msgid, p->msgid,
@ -52,7 +52,7 @@ public:
virtual void OnRawHttpGet(const std::string& url, const std::string& querystr, virtual void OnRawHttpGet(const std::string& url, const std::string& querystr,
std::string& response) override std::string& response) override
{ {
App::Instance()->AddIMMsg(IM_ExecGM, App::Instance()->AddIMMsg(kIM_ExecGM,
a8::XParams() a8::XParams()
.SetSender(socket_handle) .SetSender(socket_handle)
.SetParam1(url) .SetParam1(url)
@ -63,7 +63,7 @@ public:
virtual void OnDisConnect() override virtual void OnDisConnect() override
{ {
App::Instance()->AddIMMsg(IM_ClientSocketDisconnect, App::Instance()->AddIMMsg(kIM_ClientSocketDisconnect,
a8::XParams() a8::XParams()
.SetSender(socket_handle) .SetSender(socket_handle)
.SetParam1(1)); .SetParam1(1));

View File

@ -118,7 +118,7 @@ void AndroidAI::DoMove()
void AndroidAI::DoAttack() void AndroidAI::DoAttack()
{ {
Human* hum = (Human*)owner; Human* hum = (Human*)owner;
if (hum->room->gas_data.gas_mode == GasInactive) { if (hum->room->gas_data.gas_mode == kGasInactive) {
return; return;
} }
if (hum->HasBuffEffect(BET_Vertigo) || hum->HasBuffEffect(BET_Dcgr)) { if (hum->HasBuffEffect(BET_Vertigo) || hum->HasBuffEffect(BET_Dcgr)) {

View File

@ -41,7 +41,7 @@ void Android::Initialize()
void Android::Update(int delta_time) void Android::Update(int delta_time)
{ {
if (action_type != AT_None) { if (action_type != kAT_None) {
UpdateAction(); UpdateAction();
} }
ai->Update(delta_time); ai->Update(delta_time);

View File

@ -367,7 +367,7 @@ void App::DispatchMsg()
hdr.offset = 0; hdr.offset = 0;
hdr.ip_saddr = pdelnode->ip_saddr; hdr.ip_saddr = pdelnode->ip_saddr;
switch (pdelnode->sockfrom) { switch (pdelnode->sockfrom) {
case SF_GameGate: case kSFGameGate:
{ {
ProcessGameGateMsg(hdr); ProcessGameGateMsg(hdr);
} }
@ -445,12 +445,12 @@ void App::ProcessIMMsg()
delete param; delete param;
} }
break; break;
case IM_ClientSocketDisconnect: case kIM_ClientSocketDisconnect:
{ {
PlayerMgr::Instance()->OnClientDisconnect(pdelnode->params); PlayerMgr::Instance()->OnClientDisconnect(pdelnode->params);
} }
break; break;
case IM_ExecGM: case kIM_ExecGM:
{ {
HandlerMgr::Instance()->ProcGMMsg(pdelnode->params.param3, HandlerMgr::Instance()->ProcGMMsg(pdelnode->params.param3,
pdelnode->params.sender, pdelnode->params.sender,

View File

@ -2,18 +2,18 @@
enum SocketFrom_e enum SocketFrom_e
{ {
SF_GameGate, kSFGameGate,
}; };
enum InnerMesssage_e enum InnerMesssage_e
{ {
IM_ClientSocketDisconnect = 100, kIM_ClientSocketDisconnect = 100,
IM_PlayerOffline, kIM_PlayerOffline,
IM_ExecGM, kIM_ExecGM,
IM_DBSConnDisconnect, kIM_DBSConnDisconnect,
IM_BSConnDisconnect, kIM_BSConnDisconnect,
IM_LoadConfig, kIM_LoadConfig,
IM_HttpResponse, kIM_HttpResponse,
}; };
//网络处理对象 //网络处理对象
@ -26,41 +26,23 @@ enum NetHandler_e
HID_GGListener, HID_GGListener,
}; };
enum PlayerState_e
{
PS_None
};
enum VirtualItemId_e
{
VID_Item_Gold = 50001,
VID_Item_Exp = 50002,
VID_Soul_Stone = 50018,
VID_Pickaxe = 50019
};
enum SyncData_e
{
SYNC_Data_Exp = 0,
};
enum DoorState_e enum DoorState_e
{ {
DoorStateClose = 0, kDoorStateClose = 0,
DoorStateOpen = 1 kDoorStateOpen = 1
}; };
enum GasMode_e enum GasMode_e
{ {
GasInactive = 0, kGasInactive = 0,
GasStarted = 1, kGasStarted = 1,
}; };
enum ActionType_e enum ActionType_e
{ {
AT_None = 0, kAT_None = 0,
AT_Reload = 1, kAT_Reload = 1,
AT_UseItem = 2, kAT_UseItem = 2,
}; };
enum InventorySlot_e enum InventorySlot_e
@ -181,6 +163,13 @@ enum BuffTriggerType_e
BTT_UseItem = 6 //使用道具触发 BTT_UseItem = 6 //使用道具触发
}; };
enum BuffTargetType_e
{
kBuffTargetSelf = 1, //自己
kBuffTargetFriendly = 2, //友军
kBuffTargetEnemy = 3, //敌军
};
enum BuffEffectType_e enum BuffEffectType_e
{ {
BET_Begin = 0, BET_Begin = 0,
@ -216,7 +205,7 @@ enum HumanAttrType_e
HAT_Speed = 5, HAT_Speed = 5,
HAT_ShotRange = 6, HAT_ShotRange = 6,
HAT_ShotSpeed = 7, HAT_ShotSpeed = 7,
HAT_ReloadSpeed = 8, HkAT_ReloadSpeed = 8,
HAT_End HAT_End
}; };

View File

@ -3,14 +3,6 @@
int g_hint_flags = 0; int g_hint_flags = 0;
bool Global::IsVirtualItem(int itemid)
{
return (itemid == VID_Item_Exp ||
itemid == VID_Item_Gold ||
itemid == VID_Soul_Stone ||
itemid == VID_Pickaxe);
}
time_t Global::BetweenDays(time_t time1, time_t time2) time_t Global::BetweenDays(time_t time1, time_t time2)
{ {
return (time1 + g_time_zone*3600)/3600/24 - (time2 + g_time_zone*3600)/3600/24; return (time1 + g_time_zone*3600)/3600/24 - (time2 + g_time_zone*3600)/3600/24;

View File

@ -10,7 +10,6 @@ class Global : public a8::Singleton<Global>
friend class a8::Singleton<Global>; friend class a8::Singleton<Global>;
public: public:
static bool IsVirtualItem(int itemid);
static bool IsTimeToReset(int time); static bool IsTimeToReset(int time);
static time_t BetweenDays(time_t time1, time_t time2); static time_t BetweenDays(time_t time1, time_t time2);
static time_t GetDaySeconds(time_t time, int incdays = 0); static time_t GetDaySeconds(time_t time, int incdays = 0);

View File

@ -78,7 +78,7 @@ float Human::GetSpeed()
} }
} }
float speed = ability.speed; float speed = ability.speed;
if (action_type == AT_Reload) { if (action_type == kAT_Reload) {
speed = ability.reload_speed; speed = ability.reload_speed;
} else if (shot_hold) { } else if (shot_hold) {
if (curr_weapon->weapon_idx == GUN_SLOT1 || if (curr_weapon->weapon_idx == GUN_SLOT1 ||
@ -178,7 +178,7 @@ void Human::Shot()
return; return;
} }
if (action_type == AT_Reload) { if (action_type == kAT_Reload) {
CancelAction(); CancelAction();
} }
@ -403,7 +403,7 @@ void Human::AutoLoadingBullet(bool manual)
if ((curr_weapon->ammo <= 0 || if ((curr_weapon->ammo <= 0 ||
(manual && curr_weapon->ammo < curr_weapon->GetClipVolume())) (manual && curr_weapon->ammo < curr_weapon->GetClipVolume()))
) { ) {
StartAction(AT_Reload, StartAction(kAT_Reload,
curr_weapon->meta->i->reload_time(), curr_weapon->meta->i->reload_time(),
curr_weapon->weapon_id, curr_weapon->weapon_id,
curr_weapon->weapon_idx); curr_weapon->weapon_idx);
@ -436,7 +436,7 @@ void Human::CancelAction()
void Human::ResetAction() void Human::ResetAction()
{ {
action_type = AT_None; action_type = kAT_None;
action_duration = 0; action_duration = 0;
action_frameno = 0; action_frameno = 0;
action_item_id = 0; action_item_id = 0;
@ -699,7 +699,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
{ {
{ {
player_data->set_action_type(action_type); player_data->set_action_type(action_type);
if (action_type != AT_None) { if (action_type != kAT_None) {
int duration = std::max(0, int duration = std::max(0,
action_duration - action_duration -
(int)((room->frame_no - action_frameno) * 1.0f / SERVER_FRAME_RATE) * 1000 (int)((room->frame_no - action_frameno) * 1.0f / SERVER_FRAME_RATE) * 1000
@ -736,7 +736,7 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
void Human::FillMFGasData(cs::MFGasData* gas_data) void Human::FillMFGasData(cs::MFGasData* gas_data)
{ {
gas_data->set_mode(room->gas_data.gas_mode); gas_data->set_mode(room->gas_data.gas_mode);
if (room->gas_data.gas_mode == GasInactive) { if (room->gas_data.gas_mode == kGasInactive) {
long long duration = MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE - long long duration = MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE -
(room->frame_no - room->gas_data.gas_start_frameno); (room->frame_no - room->gas_data.gas_start_frameno);
gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000); gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000);
@ -954,7 +954,7 @@ void Human::UpdateAction()
); );
if (duration <= 0) { if (duration <= 0) {
switch (action_type) { switch (action_type) {
case AT_Reload: case kAT_Reload:
{ {
if (curr_weapon->weapon_idx == action_target_id && if (curr_weapon->weapon_idx == action_target_id &&
curr_weapon->weapon_id == action_item_id curr_weapon->weapon_id == action_item_id
@ -965,7 +965,7 @@ void Human::UpdateAction()
} }
} }
break; break;
case AT_UseItem: case kAT_UseItem:
{ {
} }
break; break;
@ -1079,21 +1079,21 @@ void Human::TriggerBuff(MetaData::Skill* sender_skill_meta,
} }
Human* hum = (Human*)entity; Human* hum = (Human*)entity;
switch (buff_meta->i->buff_target()) { switch (buff_meta->i->buff_target()) {
case 1: //自己 case kBuffTargetSelf: //自己
{ {
if (hum == this) { if (hum == this) {
hum->AddBuff(buff_meta); hum->AddBuff(buff_meta);
} }
} }
break; break;
case 2: //友军 case kBuffTargetFriendly: //友军
{ {
if (hum->team_id == team_id) { if (hum->team_id == team_id) {
hum->AddBuff(buff_meta); hum->AddBuff(buff_meta);
} }
} }
break; break;
case 3: //敌军 case kBuffTargetEnemy: //敌军
{ {
if (sender_skill_meta->i->skill_id() == 41008) { if (sender_skill_meta->i->skill_id() == 41008) {
hum->AddBuff(buff_meta); hum->AddBuff(buff_meta);
@ -1418,7 +1418,7 @@ float* Human::GetAbilityById(int attr_id)
case HAT_ShotSpeed: case HAT_ShotSpeed:
return &ability.shot_speed; return &ability.shot_speed;
break; break;
case HAT_ReloadSpeed: case HkAT_ReloadSpeed:
return &ability.reload_speed; return &ability.reload_speed;
break; break;
default: default:

View File

@ -51,7 +51,7 @@ class Human : public Entity
std::string avatar_url; std::string avatar_url;
bool dead = false; bool dead = false;
bool disconnected = false; bool disconnected = false;
ActionType_e action_type = AT_None; ActionType_e action_type = kAT_None;
long long action_frameno = 0; long long action_frameno = 0;
int action_duration = 0; int action_duration = 0;
int action_item_id = 0; int action_item_id = 0;

View File

@ -54,7 +54,7 @@ void Obstacle::RecalcSelfCollider()
} }
pos = old_pos; pos = old_pos;
} }
if (door_state == DoorStateClose) { if (door_state == kDoorStateClose) {
self_collider2_->_min = a8::Vec2(0.0f - door_state0->width() / 2.0f, self_collider2_->_min = a8::Vec2(0.0f - door_state0->width() / 2.0f,
0.0f - door_state0->height() / 2.0f); 0.0f - door_state0->height() / 2.0f);
self_collider2_->_max = a8::Vec2(door_state0->width() / 2.0f, door_state0->height() / 2.0f); self_collider2_->_max = a8::Vec2(door_state0->width() / 2.0f, door_state0->height() / 2.0f);
@ -126,7 +126,7 @@ void Obstacle::FillMFObjectFull(cs::MFObjectFull* full_data)
p->set_door_new_state((int)door_state); p->set_door_new_state((int)door_state);
p->set_door_house_uniid(door_house_uniid); p->set_door_house_uniid(door_house_uniid);
p->set_door_house_id(building->meta->i->mapid()); p->set_door_house_id(building->meta->i->mapid());
if (door_state == DoorStateClose) { if (door_state == kDoorStateClose) {
p->set_door_width(door_state0->width()); p->set_door_width(door_state0->width());
p->set_door_height(door_state0->height()); p->set_door_height(door_state0->height());
} else { } else {

View File

@ -29,7 +29,7 @@ class Obstacle : public Entity
bool is_door = false; bool is_door = false;
int door_id = 0; int door_id = 0;
int door_open_times = 0; int door_open_times = 0;
DoorState_e door_state = DoorStateClose; DoorState_e door_state = kDoorStateClose;
Building* building = nullptr; Building* building = nullptr;
int door_house_uniid = 0; int door_house_uniid = 0;
Human* master = nullptr; Human* master = nullptr;

View File

@ -86,7 +86,7 @@ void Player::Update(int delta_time)
if (use_item) { if (use_item) {
UpdateUseItemIdx(); UpdateUseItemIdx();
} }
if (action_type != AT_None) { if (action_type != kAT_None) {
UpdateAction(); UpdateAction();
} }
if (spectate) { if (spectate) {
@ -208,7 +208,7 @@ void Player::UpdateUseItemIdx()
void Player::UpdateSpectate() void Player::UpdateSpectate()
{ {
if (room->gas_data.gas_mode == GasInactive) { if (room->gas_data.gas_mode == kGasInactive) {
spectate = false; spectate = false;
return; return;
} }
@ -260,12 +260,12 @@ void Player::ProcInteraction()
void Player::ObstacleInteraction(Obstacle* entity) void Player::ObstacleInteraction(Obstacle* entity)
{ {
if (entity->is_door) { if (entity->is_door) {
if (entity->door_state == DoorStateClose) { if (entity->door_state == kDoorStateClose) {
entity->door_state = DoorStateOpen; entity->door_state = kDoorStateOpen;
entity->pos = a8::Vec2(entity->building->pos.x + entity->door_state1->x() - entity->building->meta->i->tilewidth() / 2.0, entity->pos = a8::Vec2(entity->building->pos.x + entity->door_state1->x() - entity->building->meta->i->tilewidth() / 2.0,
entity->building->pos.y + entity->door_state1->y() - entity->building->meta->i->tileheight() / 2.0); entity->building->pos.y + entity->door_state1->y() - entity->building->meta->i->tileheight() / 2.0);
} else { } else {
entity->door_state = DoorStateClose; entity->door_state = kDoorStateClose;
entity->pos = a8::Vec2(entity->building->pos.x + entity->door_state0->x() - entity->building->meta->i->tilewidth() / 2.0, entity->pos = a8::Vec2(entity->building->pos.x + entity->door_state0->x() - entity->building->meta->i->tilewidth() / 2.0,
entity->building->pos.y + entity->door_state0->y() - entity->building->meta->i->tileheight() / 2.0); entity->building->pos.y + entity->door_state0->y() - entity->building->meta->i->tileheight() / 2.0);
} }

View File

@ -158,7 +158,7 @@ int Room::AliveCount()
void Room::AddPlayer(Player* hum) void Room::AddPlayer(Player* hum)
{ {
assert(gas_data.gas_mode == GasInactive); assert(gas_data.gas_mode == kGasInactive);
while (human_hash_.size() + 1 > ROOM_MAX_PLAYER_NUM) { while (human_hash_.size() + 1 > ROOM_MAX_PLAYER_NUM) {
RandRemoveAndroid(); RandRemoveAndroid();
} }
@ -206,7 +206,7 @@ int Room::AllocUniid()
void Room::ShuaAndroid() void Room::ShuaAndroid()
{ {
if (gas_data.gas_mode != GasInactive) { if (gas_data.gas_mode != kGasInactive) {
return; return;
} }
int robot_min_num = MetaMgr::Instance()->GetSysParamAsInt("refresh_robot_min_num", 5); int robot_min_num = MetaMgr::Instance()->GetSysParamAsInt("refresh_robot_min_num", 5);
@ -428,7 +428,7 @@ void Room::CreateBuilding(int thing_id, float building_x, float building_y)
entity->building = building; entity->building = building;
entity->is_door = true; entity->is_door = true;
entity->door_id = door_meta->door_id; entity->door_id = door_meta->door_id;
entity->door_state = DoorStateClose; entity->door_state = kDoorStateClose;
entity->building = building; entity->building = building;
entity->door_house_uniid = building->entity_uniid; entity->door_house_uniid = building->entity_uniid;
entity->door_state0 = door_meta->state0; entity->door_state0 = door_meta->state0;
@ -721,7 +721,7 @@ int Room::GetAliveTeamNum()
bool Room::CanJoin(const std::string& accountid) bool Room::CanJoin(const std::string& accountid)
{ {
if (gas_data.gas_mode != GasInactive) { if (gas_data.gas_mode != kGasInactive) {
return false; return false;
} }
if (accountid_hash_.find(accountid) != accountid_hash_.end()) { if (accountid_hash_.find(accountid) != accountid_hash_.end()) {
@ -812,11 +812,11 @@ void Room::TouchEntityList(a8::XParams param,
void Room::UpdateGas() void Room::UpdateGas()
{ {
switch (gas_data.gas_mode) { switch (gas_data.gas_mode) {
case GasInactive: case kGasInactive:
{ {
if (frame_no - gas_data.gas_start_frameno >= if (frame_no - gas_data.gas_start_frameno >=
MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) { MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE) {
gas_data.gas_mode = GasStarted; gas_data.gas_mode = kGasStarted;
gas_data.gas_start_frameno = frame_no; gas_data.gas_start_frameno = frame_no;
if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) { if (human_hash_.size() < ROOM_MAX_PLAYER_NUM) {
CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size()); CreateAndroid(ROOM_MAX_PLAYER_NUM - human_hash_.size());
@ -837,7 +837,7 @@ void Room::UpdateGas()
} }
} }
break; break;
case GasStarted: case kGasStarted:
{ {
} }
break; break;

View File

@ -29,7 +29,7 @@ namespace cs
struct GasData struct GasData
{ {
GasMode_e gas_mode = GasInactive; GasMode_e gas_mode = kGasInactive;
a8::Vec2 pos_old; a8::Vec2 pos_old;
a8::Vec2 pos_old_bk; a8::Vec2 pos_old_bk;
a8::Vec2 pre_pos_old; a8::Vec2 pre_pos_old;