rename need_sync_active_player->MarkSyncActivePlayer

This commit is contained in:
aozhiwei 2022-11-14 15:33:38 +08:00
parent 6726c3245f
commit 3572bd7326
11 changed files with 109 additions and 40 deletions

View File

@ -266,7 +266,7 @@ void Buff::ProcBecome()
} }
} }
} }
caster_.Get()->need_sync_active_player = true; caster_.Get()->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__); caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
#ifdef DEBUG1 #ifdef DEBUG1
@ -300,7 +300,7 @@ void Buff::ProcDriver()
} }
} }
} }
caster_.Get()->need_sync_active_player = true; caster_.Get()->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__); caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
@ -314,7 +314,7 @@ void Buff::ProcPassenger()
{ {
hold_curr_weapon_idx_ = caster_.Get()->GetCurrWeapon()->weapon_idx; hold_curr_weapon_idx_ = caster_.Get()->GetCurrWeapon()->weapon_idx;
CalcPassengerShotOffset(); CalcPassengerShotOffset();
caster_.Get()->need_sync_active_player = true; caster_.Get()->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__); caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
@ -362,7 +362,7 @@ void Buff::RecoverHoldWeapons()
} }
#endif #endif
hold_weapons_.clear(); hold_weapons_.clear();
caster_.Get()->need_sync_active_player = true; caster_.Get()->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__); caster_.Get()->SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
@ -1000,7 +1000,7 @@ void Buff::ProcMachineGun()
} }
} }
} }
caster_.Get()->need_sync_active_player = true; caster_.Get()->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
caster_.Get()->UpdateCharImage(__FILE__, __LINE__, __func__); caster_.Get()->UpdateCharImage(__FILE__, __LINE__, __func__);
} }
if (skill_meta && skill_meta->number_meta) { if (skill_meta && skill_meta->number_meta) {

View File

@ -250,7 +250,7 @@ void Car::SwitchSeat(Human* passenger, int seat)
} else { } else {
Buff* buff = passenger->GetBuffByEffectId(kBET_Passenger); Buff* buff = passenger->GetBuffByEffectId(kBET_Passenger);
buff->CalcPassengerShotOffset(); buff->CalcPassengerShotOffset();
passenger->need_sync_active_player = true; passenger->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
room->frame_event.AddCarChg(passenger->GetWeakPtrRef()); room->frame_event.AddCarChg(passenger->GetWeakPtrRef());
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);

View File

@ -297,6 +297,7 @@ enum PropertyType_e
kPropShieldHp = 33, kPropShieldHp = 33,
kPropBeHook = 34, kPropBeHook = 34,
kPropSkillMinor = 35,
}; };
enum MapObjectType_e enum MapObjectType_e

View File

@ -16,6 +16,8 @@
#include "skillhelper.h" #include "skillhelper.h"
#include "shot.h" #include "shot.h"
#include "framework/cpp/utils.h"
static int GetTraceTargetId(Creature* c) static int GetTraceTargetId(Creature* c)
{ {
return 0; return 0;
@ -509,7 +511,7 @@ void Creature::RecalcBuffAttr()
GetTrigger()->HpChg(); GetTrigger()->HpChg();
} }
if (IsHuman()) { if (IsHuman()) {
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
} }
@ -1404,7 +1406,7 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
if (IsHuman()) { if (IsHuman()) {
AsHuman()->RecalcVolume(); AsHuman()->RecalcVolume();
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
break; break;
case kBET_AddCarBuff: case kBET_AddCarBuff:
@ -1611,7 +1613,7 @@ void Creature::StartAction(ActionType_e action_type,
this->action_duration = action_duration; this->action_duration = action_duration;
this->action_item_id = item_id; this->action_item_id = item_id;
this->action_target_id = target_id; this->action_target_id = target_id;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
if (HasBuffEffect(kBET_Camouflage)) { if (HasBuffEffect(kBET_Camouflage)) {
RemoveBuffByEffectId(kBET_Camouflage); RemoveBuffByEffectId(kBET_Camouflage);
} }
@ -1642,7 +1644,7 @@ void Creature::ResetAction()
action_frameno = 0; action_frameno = 0;
action_item_id = 0; action_item_id = 0;
action_target_id = 0; action_target_id = 0;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
if (reload_delay_timer_) { if (reload_delay_timer_) {
room->xtimer.DeleteTimer(reload_delay_timer_); room->xtimer.DeleteTimer(reload_delay_timer_);
reload_delay_timer_ = nullptr; reload_delay_timer_ = nullptr;
@ -1861,7 +1863,7 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance, int
auto_switch_weapon = true; auto_switch_weapon = true;
} }
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
break; break;
@ -1881,7 +1883,7 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance, int
auto_switch_weapon = true; auto_switch_weapon = true;
} }
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
break; break;
@ -1901,7 +1903,7 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance, int
auto_switch_weapon = true; auto_switch_weapon = true;
} }
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
break; break;
@ -2987,7 +2989,7 @@ void Creature::AutoSwitchWeapon()
} }
} }
if (switch_ok) { if (switch_ok) {
c->need_sync_active_player = true; c->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
c->SyncAroundPlayers(__FILE__, __LINE__, __func__); c->SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
c->CheckLoadingBullet(); c->CheckLoadingBullet();
@ -3456,3 +3458,20 @@ bool Creature::IsHpFull()
{ {
return std::abs(GetMaxHP() - GetHP()) < 0.0001f; return std::abs(GetMaxHP() - GetHP()) < 0.0001f;
} }
void Creature::MarkSyncActivePlayer(const char* file, int line, const char* func)
{
#ifdef DEBUG
if (!f8::IsTestEnv()) {
if (IsPlayer()) {
a8::XPrintf("MarkSyncActivePlayer file:%s line:%d func:%s\n",
{
file,
line,
func
});
}
}
#endif
need_sync_active_player_ = true;
}

View File

@ -99,7 +99,6 @@ class Creature : public MoveableEntity
std::vector<std::tuple<int, int>> talent_list; std::vector<std::tuple<int, int>> talent_list;
bool need_sync_active_player = false;
std::function<void ()> on_loading_bullet; std::function<void ()> on_loading_bullet;
CreatureWeakPtr follow_target; CreatureWeakPtr follow_target;
@ -290,6 +289,7 @@ class Creature : public MoveableEntity
void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id); void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id);
void LockAttackDir(int time); void LockAttackDir(int time);
void PullTarget(const a8::Vec2& target_pos); void PullTarget(const a8::Vec2& target_pos);
void MarkSyncActivePlayer(const char* file, int line, const char* func);
protected: protected:
virtual void OnBuffRemove(Buff& buff); virtual void OnBuffRemove(Buff& buff);
@ -318,6 +318,7 @@ private:
protected: protected:
RaceType_e race_ = kHumanRace; RaceType_e race_ = kHumanRace;
bool need_sync_active_player_ = false;
ActionType_e action_type = AT_None; ActionType_e action_type = AT_None;
int action_duration = 0; int action_duration = 0;

View File

@ -452,6 +452,35 @@ void FrameEvent::AddPropChg(CreatureWeakPtr& sender, int type, int subtype, floa
} }
} }
void FrameEvent::AddPropChgEx(CreatureWeakPtr& sender, int type, int subtype,
float value, float value2, float value3, bool only_self)
{
if (!sender.Get()) {
return;
}
auto& p = a8::FastAppend(chged_props_);
std::get<0>(p) = sender;
std::get<1>(p).set_obj_id(sender.Get()->GetUniId());
std::get<1>(p).set_property_type(type);
std::get<1>(p).set_property_subtype(subtype);
std::get<1>(p).set_value(value);
std::get<1>(p).set_value2(value2);
std::get<1>(p).set_value3(value3);
int idx = chged_props_.size() - 1;
if (only_self) {
if (sender.Get()->IsHuman()) {
sender.Get()->AsHuman()->GetFrameData().chged_props_.push_back(idx);
}
} else {
sender.Get()->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{
hum->GetFrameData().chged_props_.push_back(idx);
});
}
}
void FrameEvent::Clear() void FrameEvent::Clear()
{ {
if (!explosions_.empty()) { if (!explosions_.empty()) {

View File

@ -48,6 +48,8 @@ public:
void AddRevive(CreatureWeakPtr& sender); void AddRevive(CreatureWeakPtr& sender);
void AddCarChg(CreatureWeakPtr& sender); void AddCarChg(CreatureWeakPtr& sender);
void AddPropChg(CreatureWeakPtr& sender, int type, int subtype, float value, bool only_self = false); void AddPropChg(CreatureWeakPtr& sender, int type, int subtype, float value, bool only_self = false);
void AddPropChgEx(CreatureWeakPtr& sender, int type, int subtype,
float value, float value2, float value3, bool only_self = false);
void Clear(); void Clear();
private: private:

View File

@ -1603,6 +1603,16 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func)
void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data) void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
{ {
#ifdef DEBUG1
a8::XPrintf("FillMFActivePlayerData isPlayer:%d id:%d name:%s need_sync_active_player:%d send_msg_times:%d\n",
{
IsPlayer() ? 1 : 0,
GetUniId(),
name,
need_sync_active_player ? 1 : 0,
send_msg_times
});
#endif
{ {
player_data->set_action_type(action_type); player_data->set_action_type(action_type);
if (action_type != AT_None) { if (action_type != AT_None) {
@ -1812,10 +1822,10 @@ void Human::SendUpdateMsg()
long long end_tick = a8::XGetTickCount(); long long end_tick = a8::XGetTickCount();
#endif #endif
cs::MFActivePlayerData* active_player_data_pb = nullptr; cs::MFActivePlayerData* active_player_data_pb = nullptr;
if (send_msg_times == 0 || need_sync_active_player) { if (send_msg_times == 0 || need_sync_active_player_) {
active_player_data_pb = new cs::MFActivePlayerData(); active_player_data_pb = new cs::MFActivePlayerData();
FillMFActivePlayerData(active_player_data_pb); FillMFActivePlayerData(active_player_data_pb);
need_sync_active_player = false; need_sync_active_player_ = false;
} }
#ifdef DEBUG #ifdef DEBUG
end_tick = a8::XGetTickCount(); end_tick = a8::XGetTickCount();
@ -1845,7 +1855,7 @@ void Human::SendUpdateMsg()
} }
++send_msg_times; ++send_msg_times;
} else { } else {
need_sync_active_player = false; need_sync_active_player_ = false;
} }
#ifdef DEBUG #ifdef DEBUG
end_tick1 = a8::XGetTickCount(); end_tick1 = a8::XGetTickCount();
@ -2425,7 +2435,7 @@ void Human::DeadDrop()
} }
} }
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
void Human::SendBattleReport() void Human::SendBattleReport()
@ -2554,7 +2564,7 @@ void Human::ProcNormalItem(AddItemDTO& dto)
{ {
AddItem(dto.item_meta->i->id(), 1); AddItem(dto.item_meta->i->id(), 1);
dto.handled = true; dto.handled = true;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
void Human::ProcSpoils(AddItemDTO& dto) void Human::ProcSpoils(AddItemDTO& dto)
@ -3145,7 +3155,7 @@ void Human::ProcReloadAction()
DecInventory(bullet_meta->i->_inventory_slot(), add_num); DecInventory(bullet_meta->i->_inventory_slot(), add_num);
} }
p_weapon->ammo += add_num; p_weapon->ammo += add_num;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
if (p_weapon->meta->i->reloadtype() == 1) { if (p_weapon->meta->i->reloadtype() == 1) {
room->xtimer.AddDeadLineTimerAndAttach room->xtimer.AddDeadLineTimerAndAttach
(1, (1,
@ -3226,7 +3236,7 @@ void Human::ProcUseItemAction()
AddHp(item_meta->i->heal()); AddHp(item_meta->i->heal());
} }
DecInventory(item_meta->i->_inventory_slot(), 1); DecInventory(item_meta->i->_inventory_slot(), 1);
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
GetTrigger()->UseItemAction(action_item_id); GetTrigger()->UseItemAction(action_item_id);
} }
break; break;
@ -3245,7 +3255,7 @@ void Human::ProcUseItemAction()
AddHp(item_meta->i->heal()); AddHp(item_meta->i->heal());
} }
DecInventory(item_meta->i->_inventory_slot(), 1); DecInventory(item_meta->i->_inventory_slot(), 1);
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
GetTrigger()->UseItemAction(action_item_id); GetTrigger()->UseItemAction(action_item_id);
} }
break; break;
@ -3347,7 +3357,7 @@ void Human::OnBuffRemove(Buff& buff)
} }
} }
RecalcVolume(); RecalcVolume();
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
break; break;
case kBET_CamouflageAddition: case kBET_CamouflageAddition:
@ -3587,7 +3597,7 @@ void Human::GMAddItem(int item_id, int item_num)
dto.handled = false; dto.handled = false;
dto.item_meta = item_meta; dto.item_meta = item_meta;
ProcAddItemDto(dto); ProcAddItemDto(dto);
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
@ -3775,7 +3785,7 @@ void Human::ProcLootBag(AddItemDTO& dto)
backpack = dto.item_meta->i->id(); backpack = dto.item_meta->i->id();
RecalcVolume(); RecalcVolume();
dto.handled = true; dto.handled = true;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
@ -3805,7 +3815,7 @@ void Human::ProcLootProtection(AddItemDTO& dto)
RecalcBaseAttr(); RecalcBaseAttr();
} }
dto.handled = true; dto.handled = true;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
@ -3900,7 +3910,7 @@ void Human::ProcLootSpecItem(AddItemDTO& dto)
((Loot*)entity)->count -= add_num; ((Loot*)entity)->count -= add_num;
((Loot*)entity)->BroadcastFullState(room); ((Loot*)entity)->BroadcastFullState(room);
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
if (action_type == AT_None) { if (action_type == AT_None) {
AutoLoadingBullet(); AutoLoadingBullet();
} }
@ -3910,7 +3920,7 @@ void Human::ProcLootSpecItem(AddItemDTO& dto)
if (action_type == AT_None) { if (action_type == AT_None) {
AutoLoadingBullet(); AutoLoadingBullet();
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
dto.handled = true; dto.handled = true;
} }
@ -3951,7 +3961,7 @@ void Human::ProcLootWeapon(AddItemDTO& dto)
weapons[0].meta = dto.item_meta; weapons[0].meta = dto.item_meta;
weapons[0].Recalc(); weapons[0].Recalc();
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} else { } else {
if (FreezeOperate()) { if (FreezeOperate()) {
@ -3976,7 +3986,7 @@ void Human::ProcLootWeapon(AddItemDTO& dto)
if (switch_gun) { if (switch_gun) {
SetCurrWeapon(weapon); SetCurrWeapon(weapon);
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
dto.handled = true; dto.handled = true;
@ -4200,7 +4210,7 @@ void Human::DropWeapon(int weapon_idx)
} }
} }
} }
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
} }
} }

View File

@ -94,7 +94,7 @@ void Player::Initialize()
} }
} }
#endif #endif
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
} }
@ -375,7 +375,7 @@ void Player::UpdateSelectWeapon()
if (weapon->weapon_id != 0) { if (weapon->weapon_id != 0) {
SetCurrWeapon(weapon); SetCurrWeapon(weapon);
ResetAction(); ResetAction();
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__); SyncAroundPlayers(__FILE__, __LINE__, __func__);
if (old_weapon != weapon) { if (old_weapon != weapon) {
AutoLoadingBullet(); AutoLoadingBullet();
@ -456,7 +456,7 @@ void Player::UpdateUseItemId()
ProcUseItem(use_item_id); ProcUseItem(use_item_id);
use_item_id = 0; use_item_id = 0;
has_use_item_id = false; has_use_item_id = false;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
void Player::UpdateSpectate() void Player::UpdateSpectate()
@ -714,7 +714,7 @@ void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
} }
); );
last_sync_gas_frameno = 0; last_sync_gas_frameno = 0;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
cs::SMReconnect respmsg; cs::SMReconnect respmsg;
respmsg.set_errcode(0); respmsg.set_errcode(0);
respmsg.set_errmsg(TEXT("battle_server_reconnect_ok", "战斗重连成功")); respmsg.set_errmsg(TEXT("battle_server_reconnect_ok", "战斗重连成功"));
@ -1082,7 +1082,7 @@ void Player::UpdateUseScope()
if (IS_1XSCOPE + use_scope_idx >= IS_1XSCOPE && IS_1XSCOPE + use_scope_idx <= IS_15XSCOPE) { if (IS_1XSCOPE + use_scope_idx >= IS_1XSCOPE && IS_1XSCOPE + use_scope_idx <= IS_15XSCOPE) {
if (GetInventory(IS_1XSCOPE + use_scope_idx) > 0) { if (GetInventory(IS_1XSCOPE + use_scope_idx) > 0) {
curr_scope_idx = use_scope_idx; curr_scope_idx = use_scope_idx;
need_sync_active_player = true; MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
} }
use_scope = false; use_scope = false;

View File

@ -202,7 +202,7 @@ void Skill::AddMinorMode(
skill->minor_mode_timer_ = nullptr; skill->minor_mode_timer_ = nullptr;
} }
); );
owner->need_sync_active_player = true; owner->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
void Skill::DoMinorMode() void Skill::DoMinorMode()
@ -213,7 +213,7 @@ void Skill::DoMinorMode()
minor_cd_time_ = 0; minor_cd_time_ = 0;
minor_cb_ = nullptr; minor_cb_ = nullptr;
ResetSkillCd(); ResetSkillCd();
owner->need_sync_active_player = true; owner->MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
} }
} }

View File

@ -50,7 +50,7 @@ package cs;
// //
enum Constant_e enum Constant_e
{ {
ProtoVersion = 2022032201; // ProtoVersion = 2022111601; //
} }
// //
@ -161,6 +161,11 @@ message MFVec2
property_type: 34 property_type: 34
property_subtype: property_subtype:
valule: valule:
property_type: 35
property_subtype:
valule: cd时间()
value2: cd时间()
value3: id
*/ */
message MFPropertyChg message MFPropertyChg
{ {
@ -168,6 +173,8 @@ message MFPropertyChg
optional int32 property_type = 2; // optional int32 property_type = 2; //
optional int32 property_subtype = 3; // optional int32 property_subtype = 3; //
optional float value = 4; // optional float value = 4; //
optional float value2 = 5; //2
optional float value3 = 6; //3
} }
// //