1
This commit is contained in:
parent
8891048577
commit
9460f0b290
@ -86,26 +86,6 @@ float* Ability::GetBuffAttrRatePtr(int attr_id)
|
|||||||
return &buff_attr_rate_[attr_id];
|
return &buff_attr_rate_[attr_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ability::FillMFAttrAdditionList(Room* room, Human* hum,
|
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFAttrAddition>* pb_attr_list)
|
|
||||||
{
|
|
||||||
for (int attr_id = 0; attr_id < kHAT_End; ++attr_id) {
|
|
||||||
if (!(attr_id == 12 || attr_id == 33)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (buff_attr_flag_[attr_id]) {
|
|
||||||
auto pb_attr = pb_attr_list->Add();
|
|
||||||
pb_attr->set_attr_id(attr_id);
|
|
||||||
pb_attr->set_abs_val(buff_attr_abs_[attr_id]);
|
|
||||||
#if 1
|
|
||||||
pb_attr->set_rate_val(buff_attr_rate_[attr_id]);
|
|
||||||
#else
|
|
||||||
pb_attr->set_rate_val(buff_attr_rate_[attr_id] * 100);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Ability::AddSpeedAddition(float rate)
|
void Ability::AddSpeedAddition(float rate)
|
||||||
{
|
{
|
||||||
speed_addition_rate_ += rate;
|
speed_addition_rate_ += rate;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cs_proto.pb.h"
|
|
||||||
#include "weakptr.h"
|
#include "weakptr.h"
|
||||||
|
|
||||||
class Room;
|
class Room;
|
||||||
@ -17,8 +16,6 @@ class Ability
|
|||||||
float GetBuffAttrRate(int attr_id);
|
float GetBuffAttrRate(int attr_id);
|
||||||
float* GetBuffAttrAbsPtr(int attr_id);
|
float* GetBuffAttrAbsPtr(int attr_id);
|
||||||
float* GetBuffAttrRatePtr(int attr_id);
|
float* GetBuffAttrRatePtr(int attr_id);
|
||||||
void FillMFAttrAdditionList(Room* room, Human* hum,
|
|
||||||
::google::protobuf::RepeatedPtrField<::cs::MFAttrAddition>* pb_attr_list);
|
|
||||||
void AddSpeedAddition(float rate);
|
void AddSpeedAddition(float rate);
|
||||||
void DelSpeedAddition(float rate);
|
void DelSpeedAddition(float rate);
|
||||||
float GetSpeedAddition();
|
float GetSpeedAddition();
|
||||||
@ -89,4 +86,5 @@ class Ability
|
|||||||
|
|
||||||
std::map<int, int> immune_tags_;
|
std::map<int, int> immune_tags_;
|
||||||
|
|
||||||
|
friend class PBUtils;
|
||||||
};
|
};
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
#include "mt/KillPoint.h"
|
#include "mt/KillPoint.h"
|
||||||
#include "mt/Drop.h"
|
#include "mt/Drop.h"
|
||||||
|
|
||||||
|
#include "pbutils.h"
|
||||||
|
|
||||||
const int kReviveTimeAdd = 12;
|
const int kReviveTimeAdd = 12;
|
||||||
const int kSkinNum = 4;
|
const int kSkinNum = 4;
|
||||||
|
|
||||||
@ -516,7 +518,11 @@ void Human::FillMFObjectLess(Room* room, Human* hum, cs::MFPlayerFull* full_data
|
|||||||
p->set_shoot_offset_x(shoot_offset.x);
|
p->set_shoot_offset_x(shoot_offset.x);
|
||||||
p->set_shoot_offset_y(shoot_offset.y);
|
p->set_shoot_offset_y(shoot_offset.y);
|
||||||
GetCurrWeapon()->ToPB(this, p->mutable_weapon());
|
GetCurrWeapon()->ToPB(this, p->mutable_weapon());
|
||||||
|
#if 1
|
||||||
|
PBUtils::FillMFAttrAdditionList(GetAbility().get(), this, p);
|
||||||
|
#else
|
||||||
GetAbility()->FillMFAttrAdditionList(room, this, p->mutable_attr_addition());
|
GetAbility()->FillMFAttrAdditionList(room, this, p->mutable_attr_addition());
|
||||||
|
#endif
|
||||||
if (GetCar()) {
|
if (GetCar()) {
|
||||||
p->set_car_uniid(GetCar()->car_uniid);
|
p->set_car_uniid(GetCar()->car_uniid);
|
||||||
p->set_car_seat(GetSeat());
|
p->set_car_seat(GetSeat());
|
||||||
@ -1690,7 +1696,11 @@ void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
|||||||
FillSkillList(player_data->mutable_skill_list());
|
FillSkillList(player_data->mutable_skill_list());
|
||||||
player_data->set_shoot_offset_x(shoot_offset.x);
|
player_data->set_shoot_offset_x(shoot_offset.x);
|
||||||
player_data->set_shoot_offset_y(shoot_offset.y);
|
player_data->set_shoot_offset_y(shoot_offset.y);
|
||||||
|
#if 1
|
||||||
|
PBUtils::FillMFAttrAdditionList(GetAbility().get(), this, player_data);
|
||||||
|
#else
|
||||||
GetAbility()->FillMFAttrAdditionList(room, this, player_data->mutable_attr_addition());
|
GetAbility()->FillMFAttrAdditionList(room, this, player_data->mutable_attr_addition());
|
||||||
|
#endif
|
||||||
if (GetBuffByEffectId(kBET_HoldShield)) {
|
if (GetBuffByEffectId(kBET_HoldShield)) {
|
||||||
player_data->set_shield_hp(shield_hp_);
|
player_data->set_shield_hp(shield_hp_);
|
||||||
player_data->set_shield_max_hp(shield_max_hp_);
|
player_data->set_shield_max_hp(shield_max_hp_);
|
||||||
|
36
server/gameserver/pbutils.cc
Normal file
36
server/gameserver/pbutils.cc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include "cs_proto.pb.h"
|
||||||
|
|
||||||
|
#include "pbutils.h"
|
||||||
|
#include "ability.h"
|
||||||
|
|
||||||
|
void Ability_FillMFAttrAdditionList(Ability* p , Human* hum,
|
||||||
|
::google::protobuf::RepeatedPtrField<::cs::MFAttrAddition>* pb_attr_list)
|
||||||
|
{
|
||||||
|
for (int attr_id = 0; attr_id < kHAT_End; ++attr_id) {
|
||||||
|
if (!(attr_id == 12 || attr_id == 33)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p->buff_attr_flag_[attr_id]) {
|
||||||
|
auto pb_attr = pb_attr_list->Add();
|
||||||
|
pb_attr->set_attr_id(attr_id);
|
||||||
|
pb_attr->set_abs_val(p->buff_attr_abs_[attr_id]);
|
||||||
|
#if 1
|
||||||
|
pb_attr->set_rate_val(p->buff_attr_rate_[attr_id]);
|
||||||
|
#else
|
||||||
|
pb_attr->set_rate_val(p->buff_attr_rate_[attr_id] * 100);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PBUtils::FillMFAttrAdditionList(Ability* p, Human* hum, cs::MFActivePlayerData* player_data)
|
||||||
|
{
|
||||||
|
Ability_FillMFAttrAdditionList(p, hum, player_data->mutable_attr_addition());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PBUtils::FillMFAttrAdditionList(Ability* p, Human* hum, cs::MFPlayerFull* full_data)
|
||||||
|
{
|
||||||
|
Ability_FillMFAttrAdditionList(p, hum, full_data->mutable_attr_addition());
|
||||||
|
}
|
18
server/gameserver/pbutils.h
Normal file
18
server/gameserver/pbutils.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace cs
|
||||||
|
{
|
||||||
|
class MFActivePlayerData;
|
||||||
|
class MFPlayerFull;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Ability;
|
||||||
|
class Human;
|
||||||
|
class PBUtils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void FillMFAttrAdditionList(Ability* p, Human* hum, cs::MFActivePlayerData* player_data);
|
||||||
|
static void FillMFAttrAdditionList(Ability* p, Human* hum, cs::MFPlayerFull* full_data);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user