1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00

Started moveing more housing code into HousingMgr

This commit is contained in:
Mordred 2018-11-13 23:46:10 +01:00
parent a8040d9236
commit 361b0b463b
4 changed files with 349 additions and 337 deletions

View file

@ -10,310 +10,306 @@
// The following enumerations are structures to require their type be included.
// They are also defined within the Core::Common namespace to avoid collisions.
// +---------------------------------------------------------------------------
namespace Core {
namespace Network {
namespace ActorControl {
enum ActorControlType :
uint16_t
namespace Core::Network::ActorControl
{
/*! Toggles weapon status -> Sheathed/UnSheathed
\param param1 status 0|1 */
ToggleWeapon = 0x00,
/*! Toggles Autoattack status on/off
\param param1 status 0|1 */
AutoAttack = 0x01,
SetStatus = 0x02,
CastStart = 0x03,
ToggleAggro = 0x04,
ClassJobChange = 0x05,
DefeatMsg = 0x06,
GainExpMsg = 0x07,
LevelUpEffect = 0x0A,
ExpChainMsg = 0x0C,
HpSetStat = 0x0D,
DeathAnimation = 0x0E,
CastInterrupt = 0x0F,
ActionStart = 0x11,
StatusEffectGain = 0x14,
StatusEffectLose = 0x15,
HPFloatingText = 0x17,
UpdateRestedExp = 0x018,
Unk2 = 0x19,
Flee = 0x1B,
Unk3 = 0x20, // Animation related?
CombatIndicationShow = 0x22,
SpawnEffect = 0x25,
ToggleInvisible = 0x26,
ToggleActionUnlock = 0x29,
UpdateUiExp = 0x2B,
DmgTakenMsg = 0x2D,
SetTarget = 0x32,
ToggleNameHidden = 0x36,
LimitbreakStart = 0x47,
LimitbreakPartyStart = 0x48,
BubbleText = 0x49,
DamageEffect = 0x50,
RaiseAnimation = 0x51,
TreasureScreenMsg = 0x57,
SetOwnerId = 0x59,
ItemRepairMsg = 0x5C,
DirectorInit = 0x64,
DirectorClear = 0x65,
LeveStartAnim = 0x66,
LeveStartError = 0x67,
DirectorEObjMod = 0x6A,
DirectorUpdate = 0x6D,
ItemObtainMsg = 0x75,
DutyQuestScreenMsg = 0x7B,
ItemObtainIcon = 0x84,
FateItemFailMsg = 0x85,
ItemFailMsg = 0x86,
ActionLearnMsg1 = 0x87,
FreeEventPos = 0x8A,
SetBGM = 0xA1,
UnlockAetherCurrentMsg = 0xA4,
RemoveName = 0xA8,
ScreenFadeOut = 0xAA,
ZoneIn = 0xC8,
ZoneInDefaultPos = 0xC9,
TeleportStart = 0xCB,
TeleportDone = 0xCD,
TeleportDoneFadeOut = 0xCE,
DespawnZoneScreenMsg = 0xCF,
InstanceSelectDlg = 0xD2,
ActorDespawnEffect = 0xD4,
CompanionUnlock = 0xFD,
ObtainBarding = 0xFE,
EquipBarding = 0xFF,
CompanionMsg1 = 0x102,
CompanionMsg2 = 0x103,
ShowPetHotbar = 0x104,
ActionLearnMsg = 0x109,
ActorFadeOut = 0x10A,
ActorFadeIn = 0x10B,
WithdrawMsg = 0x10C,
OrderMinion = 0x10D,
ToggleMinion = 0x10E,
LearnMinion = 0x10F,
ActorFateOut1 = 0x110,
Emote = 0x122,
EmoteInterrupt = 0x123,
SetPose = 0x127,
CraftingUnk = 0x12C,
GatheringSenseMsg = 0x130,
PartyMsg = 0x131,
GatheringSenseMsg1 = 0x132,
GatheringSenseMsg2 = 0x138,
FishingMsg = 0x140,
FishingBaitMsg = 0x145,
FishingReachMsg = 0x147,
FishingFailMsg = 0x148,
MateriaConvertMsg = 0x15E,
MeldSuccessMsg = 0x15F,
MeldFailMsg = 0x160,
MeldModeToggle = 0x161,
AetherRestoreMsg = 0x163,
DyeMsg = 0x168,
ToggleCrestMsg = 0x16A,
ToggleBulkCrestMsg = 0x16B,
MateriaRemoveMsg = 0x16C,
GlamourCastMsg = 0x16D,
GlamourRemoveMsg = 0x16E,
RelicInfuseMsg = 0x179,
AetherReductionDlg = 0x17D,
Unk6 = 0x19C,
EObjAnimation = 0x19D,
SetTitle = 0x1F4,
SetStatusIcon = 0x1F8,
LimitBreakGauge = 0x1F9, // Max level, amount, build type (chop sound), lb type(0=pve lb 1=pvp lb)
SetHomepoint = 0x1FB,
SetFavorite = 0x1FC,
LearnTeleport = 0x1FD,
OpenRecommendationGuide = 0x200,
ArmoryErrorMsg = 0x201,
AchievementPopup = 0x203,
LogMsg = 0x205, // LogMessage?
AchievementMsg = 0x206,
SetItemLevel = 0x209,
ChallengeEntryCompleteMsg = 0x20B,
ChallengeEntryUnlockMsg = 0x20C,
GilTrailMsg = 0x211,
SetMaxGearSets = 0x230,
SetCharaGearParamUI = 0x260,
ToggleWireframeRendering = 0x261,
ExamineError = 0x2BF,
GearSetEquipMsg = 0x321,
SetFestival = 0x386, // param1: festival.exd index
ToggleOrchestrionUnlock = 0x396,
Dismount = 0x3A0,
// Duty Recorder
BeginReplayAck = 0x3A1,
EndReplayAck = 0x3A2,
// Housing
ShowHousingItemUI = 0x3F7,
ShowBuildPresetUI = 0x3E9,
BuildPresetResponse = 0x3ED,
// PvP Duel
SetPvPState = 0x5E0, // param3 must be 6 to engage a duel (hardcoded in the client)
EndDuelSession = 0x5E1, // because someone went oob?
StartDuelCountdown = 0x5E2, // begins a countdown; also does some duel bgm thing.
StartDuel = 0x5E3, // actually all it does is set the challenger actor id;
DuelResultScreen = 0x5E4, // win/lose thing, also reset a target id just like what EndDuelSession does.
// Duty Action
SetDutyActionId = 0x5E8, // ContentExAction
SetDutyActionHud = 0x5E9, // disable/enable
SetDutyActionActive = 0x5EA,
SetDutyActionRemaining = 0x5EB,
};
enum ClientTriggerType
enum ActorControlType : uint16_t
{
ToggleSheathe = 0x01,
ToggleAutoAttack = 0x02,
ChangeTarget = 0x03,
/*! Toggles weapon status -> Sheathed/UnSheathed
\param param1 status 0|1 */
ToggleWeapon = 0x00,
/*! Toggles Autoattack status on/off
\param param1 status 0|1 */
AutoAttack = 0x01,
SetStatus = 0x02,
CastStart = 0x03,
ToggleAggro = 0x04,
ClassJobChange = 0x05,
DefeatMsg = 0x06,
GainExpMsg = 0x07,
DismountReq = 0x65,
LevelUpEffect = 0x0A,
RemoveStatusEffect = 0x68,
CastCancel = 0x69,
ExpChainMsg = 0x0C,
HpSetStat = 0x0D,
DeathAnimation = 0x0E,
CastInterrupt = 0x0F,
Return = 0xC8, // return dead / accept raise
FinishZoning = 0xC9,
Teleport = 0xCA,
ActionStart = 0x11,
Examine = 0x12C,
MarkPlayer = 0x12D, // Mark player, visible to party only
SetTitleReq = 0x12E,
TitleList = 0x12F,
StatusEffectGain = 0x14,
StatusEffectLose = 0x15,
UpdatedSeenHowTos = 0x133,
AllotAttribute = 0x135,
HPFloatingText = 0x17,
UpdateRestedExp = 0x018,
Unk2 = 0x19,
ClearWaymarks = 0x13A,
CameraMode = 0x13B, // param12, 1 = camera mode enable, 0 = disable
CharaNameReq = 0x13D, // requests character name by content id
HuntingLogDetails = 0x194,
Flee = 0x1B,
Timers = 0x1AB,
Unk3 = 0x20, // Animation related?
DyeItem = 0x1B5,
CombatIndicationShow = 0x22,
RequestChocoboInventory = 0x1C4,
SpawnEffect = 0x25,
ToggleInvisible = 0x26,
EmoteReq = 0x1F4,
EmoteCancel = 0x1F6,
PersistentEmoteCancel = 0x1F7,
PoseChange = 0x1F9,
PoseReapply = 0x1FA,
PoseCancel = 0x1FB,
ToggleActionUnlock = 0x29,
AchievementCrit = 0x202,
AchievementComp = 0x203,
AchievementCatChat = 0x206,
UpdateUiExp = 0x2B,
DmgTakenMsg = 0x2D,
QuestJournalUpdateQuestVisibility = 0x2BE,
QuestJournalClosed = 0x2BF,
SetTarget = 0x32,
ToggleNameHidden = 0x36,
AbandonQuest = 0x320,
LimitbreakStart = 0x47,
LimitbreakPartyStart = 0x48,
BubbleText = 0x49,
DirectorInitFinish = 0x321,
DamageEffect = 0x50,
RaiseAnimation = 0x51,
TreasureScreenMsg = 0x57,
SetOwnerId = 0x59,
ItemRepairMsg = 0x5C,
DirectorSync = 0x328, // unsure what exactly triggers it, starts director when returning to instance though
DirectorInit = 0x64,
DirectorClear = 0x65,
EnterTerritoryEventFinished = 0x330,
RequestInstanceLeave = 0x333, // df menu button
LeveStartAnim = 0x66,
LeveStartError = 0x67,
DirectorEObjMod = 0x6A,
AchievementCritReq = 0x3E8,
AchievementList = 0x3E9,
DirectorUpdate = 0x6D,
RequestHousingBuildPreset = 0x44C,
RequestHousingSign = 0x451,
RequestHousingInfoSign = 0x452,
RequestHousingRename = 0x45A,
RequestHousingItemUI = 0x463,
RequestSharedEstateSettings = 0x46F,
ItemObtainMsg = 0x75,
DutyQuestScreenMsg = 0x7B,
CompanionAction = 0x6A4,
CompanionSetBarding = 0x6A5,
CompanionActionUnlock = 0x6A6,
ItemObtainIcon = 0x84,
FateItemFailMsg = 0x85,
ItemFailMsg = 0x86,
ActionLearnMsg1 = 0x87,
OpenPerformInstrumentUI = 0x71C,
FreeEventPos = 0x8A,
StartReplay = 0x7BC,
EndReplay = 0x7BD, // request for restoring the original player state (actor, buff, gauge, etc..)
SetBGM = 0xA1,
OpenDuelUI = 0x898, // Open a duel ui
DuelRequestResult = 0x899, // either accept/reject
UnlockAetherCurrentMsg = 0xA4,
};
RemoveName = 0xA8,
} /* ActorControl */
} /* Common */
} /* Core */
ScreenFadeOut = 0xAA,
ZoneIn = 0xC8,
ZoneInDefaultPos = 0xC9,
TeleportStart = 0xCB,
TeleportDone = 0xCD,
TeleportDoneFadeOut = 0xCE,
DespawnZoneScreenMsg = 0xCF,
InstanceSelectDlg = 0xD2,
ActorDespawnEffect = 0xD4,
CompanionUnlock = 0xFD,
ObtainBarding = 0xFE,
EquipBarding = 0xFF,
CompanionMsg1 = 0x102,
CompanionMsg2 = 0x103,
ShowPetHotbar = 0x104,
ActionLearnMsg = 0x109,
ActorFadeOut = 0x10A,
ActorFadeIn = 0x10B,
WithdrawMsg = 0x10C,
OrderMinion = 0x10D,
ToggleMinion = 0x10E,
LearnMinion = 0x10F,
ActorFateOut1 = 0x110,
Emote = 0x122,
EmoteInterrupt = 0x123,
SetPose = 0x127,
CraftingUnk = 0x12C,
GatheringSenseMsg = 0x130,
PartyMsg = 0x131,
GatheringSenseMsg1 = 0x132,
GatheringSenseMsg2 = 0x138,
FishingMsg = 0x140,
FishingBaitMsg = 0x145,
FishingReachMsg = 0x147,
FishingFailMsg = 0x148,
MateriaConvertMsg = 0x15E,
MeldSuccessMsg = 0x15F,
MeldFailMsg = 0x160,
MeldModeToggle = 0x161,
AetherRestoreMsg = 0x163,
DyeMsg = 0x168,
ToggleCrestMsg = 0x16A,
ToggleBulkCrestMsg = 0x16B,
MateriaRemoveMsg = 0x16C,
GlamourCastMsg = 0x16D,
GlamourRemoveMsg = 0x16E,
RelicInfuseMsg = 0x179,
AetherReductionDlg = 0x17D,
Unk6 = 0x19C,
EObjAnimation = 0x19D,
SetTitle = 0x1F4,
SetStatusIcon = 0x1F8,
LimitBreakGauge = 0x1F9, // Max level, amount, build type (chop sound), lb type(0=pve lb 1=pvp lb)
SetHomepoint = 0x1FB,
SetFavorite = 0x1FC,
LearnTeleport = 0x1FD,
OpenRecommendationGuide = 0x200,
ArmoryErrorMsg = 0x201,
AchievementPopup = 0x203,
LogMsg = 0x205, // LogMessage?
AchievementMsg = 0x206,
SetItemLevel = 0x209,
ChallengeEntryCompleteMsg = 0x20B,
ChallengeEntryUnlockMsg = 0x20C,
GilTrailMsg = 0x211,
SetMaxGearSets = 0x230,
SetCharaGearParamUI = 0x260,
ToggleWireframeRendering = 0x261,
ExamineError = 0x2BF,
GearSetEquipMsg = 0x321,
SetFestival = 0x386, // param1: festival.exd index
ToggleOrchestrionUnlock = 0x396,
Dismount = 0x3A0,
// Duty Recorder
BeginReplayAck = 0x3A1,
EndReplayAck = 0x3A2,
// Housing
ShowHousingItemUI = 0x3F7,
ShowBuildPresetUI = 0x3E9,
BuildPresetResponse = 0x3ED,
// PvP Duel
SetPvPState = 0x5E0, // param3 must be 6 to engage a duel (hardcoded in the client)
EndDuelSession = 0x5E1, // because someone went oob?
StartDuelCountdown = 0x5E2, // begins a countdown; also does some duel bgm thing.
StartDuel = 0x5E3, // actually all it does is set the challenger actor id;
DuelResultScreen = 0x5E4, // win/lose thing, also reset a target id just like what EndDuelSession does.
// Duty Action
SetDutyActionId = 0x5E8, // ContentExAction
SetDutyActionHud = 0x5E9, // disable/enable
SetDutyActionActive = 0x5EA,
SetDutyActionRemaining = 0x5EB,
};
enum ClientTriggerType
{
ToggleSheathe = 0x01,
ToggleAutoAttack = 0x02,
ChangeTarget = 0x03,
DismountReq = 0x65,
RemoveStatusEffect = 0x68,
CastCancel = 0x69,
Return = 0xC8, // return dead / accept raise
FinishZoning = 0xC9,
Teleport = 0xCA,
Examine = 0x12C,
MarkPlayer = 0x12D, // Mark player, visible to party only
SetTitleReq = 0x12E,
TitleList = 0x12F,
UpdatedSeenHowTos = 0x133,
AllotAttribute = 0x135,
ClearWaymarks = 0x13A,
CameraMode = 0x13B, // param12, 1 = camera mode enable, 0 = disable
CharaNameReq = 0x13D, // requests character name by content id
HuntingLogDetails = 0x194,
Timers = 0x1AB,
DyeItem = 0x1B5,
RequestChocoboInventory = 0x1C4,
EmoteReq = 0x1F4,
EmoteCancel = 0x1F6,
PersistentEmoteCancel = 0x1F7,
PoseChange = 0x1F9,
PoseReapply = 0x1FA,
PoseCancel = 0x1FB,
AchievementCrit = 0x202,
AchievementComp = 0x203,
AchievementCatChat = 0x206,
QuestJournalUpdateQuestVisibility = 0x2BE,
QuestJournalClosed = 0x2BF,
AbandonQuest = 0x320,
DirectorInitFinish = 0x321,
DirectorSync = 0x328, // unsure what exactly triggers it, starts director when returning to instance though
EnterTerritoryEventFinished = 0x330,
RequestInstanceLeave = 0x333, // df menu button
AchievementCritReq = 0x3E8,
AchievementList = 0x3E9,
RequestHousingBuildPreset = 0x44C,
RequestLandSignFree = 0x451,
RequestLandSignOwned = 0x452,
RequestEstateRename = 0x45A,
RequestHousingItemUI = 0x463,
RequestSharedEstateSettings = 0x46F,
CompanionAction = 0x6A4,
CompanionSetBarding = 0x6A5,
CompanionActionUnlock = 0x6A6,
OpenPerformInstrumentUI = 0x71C,
StartReplay = 0x7BC,
EndReplay = 0x7BD, // request for restoring the original player state (actor, buff, gauge, etc..)
OpenDuelUI = 0x898, // Open a duel ui
DuelRequestResult = 0x899, // either accept/reject
};
}
#endif

View file

@ -327,71 +327,23 @@ void Core::Network::GameConnection::clientTriggerHandler( const Packets::FFXIVAR
break;
}
case ClientTriggerType::RequestHousingSign:
case ClientTriggerType::RequestLandSignFree:
{
auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() );
uint8_t ward = ( param12 & 0xFF00 ) >> 8;
uint8_t plot = ( param12 & 0xFF );
pLog->debug( " Ward: " + std::to_string( ward ) + " Plot: " + std::to_string( plot ) );
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
if( !hZone )
return;
auto land = hZone->getLand( plot );
plotPricePacket->data().price = land->getCurrentPrice();
plotPricePacket->data().timeLeft = land->getDevaluationTime();
player.queuePacket( plotPricePacket );
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
auto plot = static_cast< uint8_t >( param12 & 0xFF );
auto pHousingMgr = g_fw.get< HousingMgr >();
pHousingMgr->sendLandSignFree( player, ward, plot );
break;
}
case ClientTriggerType::RequestHousingInfoSign:
case ClientTriggerType::RequestLandSignOwned:
{
auto landInfoSignPacket = makeZonePacket< Server::FFXIVIpcLandInfoSign >( player.getId() );
uint8_t ward = ( param12 & 0xFF00 ) >> 8;
uint8_t plot = ( param12 & 0xFF );
pLog->debug( " Ward: " + std::to_string( ward ) + " Plot: " + std::to_string( plot ) );
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
auto land = hZone->getLand( plot );
if( !land )
{
auto pHousingMgr = g_fw.get< HousingMgr >();
land = pHousingMgr->getLandByOwnerId( player.getId() );
}
uint32_t playerId = land->getPlayerOwner();
std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( playerId );
//memcpy( &landInfoSignPacket->data().estateGreeting, "Hello World", 11 );
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
landInfoSignPacket->data().houseSize = land->getPlotSize();
landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
landInfoSignPacket->data().landId = land->getLandId();
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() );
landInfoSignPacket->data().wardNum = land->getWardNum();
landInfoSignPacket->data().worldId = 67;
landInfoSignPacket->data().zoneId = land->getZoneId();
player.queuePacket( landInfoSignPacket );
auto ward = static_cast< uint8_t >( ( param12 & 0xFF00 ) >> 8 );
auto plot = static_cast< uint8_t >( param12 & 0xFF );
auto pHousingMgr = g_fw.get< HousingMgr >();
pHousingMgr->sendLandSignOwned( player, ward, plot );
break;
}
case ClientTriggerType::RequestHousingRename:
case ClientTriggerType::RequestEstateRename:
{
auto landRenamePacket = makeZonePacket< Server::FFXIVIpcLandRename >( player.getId() );

View file

@ -3,6 +3,11 @@
#include <Logging/Logger.h>
#include <Database/DatabaseDef.h>
#include <Exd/ExdDataGenerated.h>
#include <Network/PacketContainer.h>
#include <Network/PacketDef/Zone/ServerZoneDef.h>
#include <Network/PacketWrappers/ActorControlPacket142.h>
#include <Network/PacketWrappers/ActorControlPacket143.h>
#include <Network/CommonActorControl.h>
#include <unordered_map>
@ -13,6 +18,12 @@
#include "HousingMgr.h"
#include "Land.h"
#include "Framework.h"
#include "ServerZone.h"
using namespace Core::Common;
using namespace Core::Network;
using namespace Core::Network::Packets;
using namespace Core::Network::Packets::Server;
extern Core::Framework g_fw;
@ -84,3 +95,53 @@ Core::LandPtr Core::HousingMgr::getLandByOwnerId( uint32_t id )
}
return nullptr;
}
void Core::HousingMgr::sendLandSignOwned( Entity::Player& player, uint8_t ward, uint8_t plot )
{
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
if( !hZone )
return;
auto land = hZone->getLand( plot );
if( !land )
{
land = getLandByOwnerId( player.getId() );
}
auto landInfoSignPacket = makeZonePacket< Server::FFXIVIpcLandInfoSign >( player.getId() );
uint32_t playerId = land->getPlayerOwner();
std::string playerName = g_fw.get< Core::ServerZone >()->getPlayerNameFromDb( playerId );
//memcpy( &landInfoSignPacket->data().estateGreeting, "Hello World", 11 );
//memcpy( &landInfoSignPacket->data().estateName, land->getLandName().c_str(), land->getLandName().size() );
landInfoSignPacket->data().houseSize = land->getPlotSize();
landInfoSignPacket->data().houseType = static_cast< uint8_t >( land->getLandType() );
landInfoSignPacket->data().landId = land->getLandId();
landInfoSignPacket->data().ownerId = player.getContentId(); // should be real owner contentId, not player.contentId()
memcpy( &landInfoSignPacket->data().ownerName, playerName.c_str(), playerName.size() );
landInfoSignPacket->data().wardNum = land->getWardNum();
landInfoSignPacket->data().worldId = 67;
landInfoSignPacket->data().zoneId = land->getZoneId();
player.queuePacket( landInfoSignPacket );
}
void Core::HousingMgr::sendLandSignFree( Entity::Player& player, uint8_t ward, uint8_t plot )
{
player.setActiveLand( plot, ward );
auto zone = player.getCurrentZone();
auto hZone = std::dynamic_pointer_cast< HousingZone >( zone );
if( !hZone )
return;
auto land = hZone->getLand( plot );
auto plotPricePacket = makeZonePacket< Server::FFXIVIpcLandPriceUpdate >( player.getId() );
plotPricePacket->data().price = land->getCurrentPrice();
plotPricePacket->data().timeLeft = land->getDevaluationTime();
player.queuePacket( plotPricePacket );
}

View file

@ -28,6 +28,9 @@ namespace Core
Core::Data::HousingZonePtr getHousingZoneByLandSetId( uint32_t id );
Core::LandPtr getLandByOwnerId( uint32_t id );
void sendLandSignOwned( Entity::Player& player, uint8_t ward, uint8_t plot );
void sendLandSignFree( Entity::Player& player, uint8_t ward, uint8_t plot );
private:
using HousingZonePtrMap = std::unordered_map< uint16_t, Core::Data::HousingZonePtr >;
uint16_t m_lastLandId;