From caf5428532c553fa3e3f4e295b04bc38a834d6ad Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 17 Apr 2017 17:24:11 +0300 Subject: [PATCH] [General] Rename mwmp::Attack vars in preparation for Actor support --- apps/openmw/mwclass/npc.cpp | 6 +++--- apps/openmw/mwmp/LocalPlayer.cpp | 10 +++++----- apps/openmw/mwmp/MechanicsHelper.cpp | 10 +++++----- components/openmw-mp/Base/BaseStructs.hpp | 8 +++++--- .../openmw-mp/Packets/Player/PacketPlayerAttack.cpp | 7 ++++--- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 75b59f395..43a370603 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -629,7 +629,7 @@ namespace MWClass mwmp::Main::get().getLocalPlayer()->attack.success = true; mwmp::DedicatedPlayer *dedicatedPlayer = mwmp::Players::getPlayer(victim); if (dedicatedPlayer != nullptr) - mwmp::Main::get().getLocalPlayer()->attack.target = dedicatedPlayer->guid; + mwmp::Main::get().getLocalPlayer()->attack.targetGuid = dedicatedPlayer->guid; } /* End of tes3mp addition @@ -930,8 +930,8 @@ namespace MWClass { mwmp::Attack *attack = &mwmp::Main::get().getLocalPlayer()->attack; attack->damage = damage; - attack->attacker = mwmp::Main::get().getLocalPlayer()->guid; - attack->target = victimPlayer->guid; + attack->attackerGuid = mwmp::Main::get().getLocalPlayer()->guid; + attack->targetGuid = victimPlayer->guid; attack->knockdown = getCreatureStats(ptr).getKnockedDown(); mwmp::Main::get().getLocalPlayer()->sendAttack(mwmp::Attack::MELEE); // todo: make this sensitive to different weapon types } diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index ee9c951b4..680135038 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -532,10 +532,10 @@ void LocalPlayer::updateAttackState(bool forceUpdate) { const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); - attack.attacker = guid; + attack.attackerGuid = guid; attack.type = Attack::MAGIC; attack.pressed = true; - attack.refId = spell; + attack.spellId = spell; } else if (state == MWMechanics::DrawState_Weapon) { @@ -1185,7 +1185,7 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state) const string &spell = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); attack.success = Misc::Rng::roll0to99() < MWMechanics::getSpellSuccessChance(spell, getPlayerPtr()); state = true; - attack.refId = spell; + attack.spellId = spell; } else { @@ -1196,8 +1196,8 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state) attack.type = type; attack.knockdown = false; attack.block = false; - attack.target = RakNet::RakNetGUID(); - attack.attacker = guid; + attack.targetGuid = RakNet::RakNetGUID(); + attack.attackerGuid = guid; getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send(); diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index 35042f00b..a26bbeba6 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -44,14 +44,14 @@ void MechanicsHelper::processAttack(const MWWorld::Ptr& attacker, Attack attack) } MWMechanics::CreatureStats &attackerStats = attacker.getClass().getNpcStats(attacker); - attackerStats.getSpells().setSelectedSpell(attack.refId); + attackerStats.getSpells().setSelectedSpell(attack.spellId); MWWorld::Ptr victim; - if (attack.target == mwmp::Main::get().getLocalPlayer()->guid) + if (attack.targetGuid == mwmp::Main::get().getLocalPlayer()->guid) victim = MWBase::Environment::get().getWorld()->getPlayerPtr(); - else if (Players::getPlayer(attack.target) != 0) - victim = Players::getPlayer(attack.target)->getPtr(); + else if (Players::getPlayer(attack.targetGuid) != 0) + victim = Players::getPlayer(attack.targetGuid)->getPtr(); // Get the weapon used (if hand-to-hand, weapon = inv.end()) if (attackerStats.getDrawState() == MWMechanics::DrawState_Weapon) @@ -84,7 +84,7 @@ void MechanicsHelper::processAttack(const MWWorld::Ptr& attacker, Attack attack) } else { - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", attack.refId.c_str()); + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", attack.spellId.c_str()); LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", attack.success); } } diff --git a/components/openmw-mp/Base/BaseStructs.hpp b/components/openmw-mp/Base/BaseStructs.hpp index 0ddbe1efb..54bfd1523 100644 --- a/components/openmw-mp/Base/BaseStructs.hpp +++ b/components/openmw-mp/Base/BaseStructs.hpp @@ -8,8 +8,9 @@ namespace mwmp class Attack { public: - RakNet::RakNetGUID target; - RakNet::RakNetGUID attacker; + RakNet::RakNetGUID targetGuid; + RakNet::RakNetGUID attackerGuid; + char type; // 0 - melee, 1 - magic, 2 - throwable enum TYPE { @@ -17,7 +18,8 @@ namespace mwmp MAGIC, THROWABLE }; - std::string refId; // id of spell (e.g. "fireball") + + std::string spellId; // id of spell (e.g. "fireball") char success; char block; float damage; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp b/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp index f8e45e540..c80c9fbab 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAttack.cpp @@ -16,9 +16,10 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send) { PlayerPacket::Packet(bs, send); - RW(player->attack.attacker, send); - RW(player->attack.target, send); - RW(player->attack.refId, send); + RW(player->attack.attackerGuid, send); + RW(player->attack.targetGuid, send); + + RW(player->attack.spellId, send); RW(player->attack.type, send); RW(player->attack.success, send); RW(player->attack.damage, send);