mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 16:37:45 +00:00
Fc is being loaded and sent to the master character. Member lists not maintained yet.
This commit is contained in:
parent
8d46426599
commit
7af6846395
7 changed files with 176 additions and 89 deletions
32
sql/migrations/20230702121200_ChangeFcFieldSizes.sql
Normal file
32
sql/migrations/20230702121200_ChangeFcFieldSizes.sql
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
ALTER TABLE `freecompany` CHANGE `FreeCompanyId` `FreeCompanyId` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `MasterCharacterId` `MasterCharacterId` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `FcCredit` `FcCredit` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `FcCreditAccumu` `FcCreditAccumu` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `FcPoint` `FcPoint` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `CrestId` `CrestId` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `Reputation_0` `Reputation_0` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `Reputation_1` `Reputation_1` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `Reputation_2` `Reputation_2` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `MoveGcDate` `MoveGcDate` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `ActiveActionList_0` `ActiveActionList_0` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `ActiveActionList_1` `ActiveActionList_1` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `ActiveActionList_2` `ActiveActionList_2` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `ActiveActionLeftTime_0` `ActiveActionLeftTime_0` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `ActiveActionLeftTime_1` `ActiveActionLeftTime_1` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `ActiveActionLeftTime_2` `ActiveActionLeftTime_2` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_0` `StockActionList_0` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_1` `StockActionList_1` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_2` `StockActionList_2` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_3` `StockActionList_3` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_4` `StockActionList_4` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_5` `StockActionList_5` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_6` `StockActionList_6` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_7` `StockActionList_7` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_8` `StockActionList_8` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_9` `StockActionList_9` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_10` `StockActionList_10` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_11` `StockActionList_11` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_12` `StockActionList_12` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_13` `StockActionList_13` BIGINT(20) NULL DEFAULT NULL;
|
||||
ALTER TABLE `freecompany` CHANGE `StockActionList_14` `StockActionList_14` BIGINT(20) NULL DEFAULT NULL;
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include <Network/GameConnection.h>
|
||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||
|
||||
#include <Network/PacketWrappers/FreeCompanyResultPacket.h>
|
||||
#include <Network/PacketDef/ClientIpcs.h>
|
||||
|
||||
#include "Session.h"
|
||||
|
@ -161,6 +161,7 @@ FreeCompanyPtr FreeCompanyMgr::createFreeCompany( const std::string& name, const
|
|||
chatChannelMgr.addToChannel( chatChannelId, player );
|
||||
|
||||
uint64_t masterId = player.getCharacterId();
|
||||
Logger::debug( "MasterID# {}", masterId );
|
||||
|
||||
uint32_t createDate = Common::Util::getTimeSeconds();
|
||||
|
||||
|
@ -195,7 +196,14 @@ FreeCompanyPtr FreeCompanyMgr::createFreeCompany( const std::string& name, const
|
|||
|
||||
db.directExecute( stmt );
|
||||
|
||||
sendFreeCompanyResult( player, freeCompanyId, FreeCompanyMgr::ResultType::Create, 2, 0, FreeCompanyMgr::UpdateStatus::Execute );
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
|
||||
auto fcResult = makeFcResult( player, freeCompanyId,
|
||||
2, FreeCompanyResultPacket::ResultType::Create,
|
||||
0, FreeCompanyResultPacket::UpdateStatus::Execute,
|
||||
fcPtr->getName(), fcPtr->getTag() );
|
||||
|
||||
server.queueForPlayer( player.getCharacterId(), fcResult );
|
||||
|
||||
return fcPtr;
|
||||
}
|
||||
|
@ -269,29 +277,6 @@ void FreeCompanyMgr::sendFcInviteList( Entity::Player& player )
|
|||
server.queueForPlayer( player.getCharacterId(), inviteListPacket );
|
||||
}
|
||||
|
||||
void FreeCompanyMgr::sendFreeCompanyResult( Entity::Player& player, uint64_t fcId, ResultType resultType, uint64_t target, uint32_t result,
|
||||
FreeCompanyMgr::UpdateStatus updateStatus )
|
||||
{
|
||||
auto fc = getFreeCompanyById( fcId );
|
||||
if( !fc )
|
||||
return;
|
||||
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
|
||||
auto fcResult = makeZonePacket< FFXIVIpcFreeCompanyResult >( player.getId() );
|
||||
auto& fcResultData = fcResult->data();
|
||||
fcResultData.FreeCompanyID = fcId;
|
||||
std::strcpy( fcResultData.FreeCompanyName, fc->getName().c_str() );
|
||||
std::strcpy( fcResultData.TargetName, fc->getName().c_str() );
|
||||
fcResultData.Result = result;
|
||||
fcResultData.TargetCharacterID = target;
|
||||
fcResultData.Type = resultType;
|
||||
fcResultData.UpdateStatus = updateStatus;
|
||||
|
||||
server.queueForPlayer( player.getCharacterId(), fcResult );
|
||||
}
|
||||
|
||||
|
||||
void FreeCompanyMgr::sendFcStatus( Entity::Player& player )
|
||||
{
|
||||
auto fc = getPlayerFreeCompany( player );
|
||||
|
@ -315,3 +300,24 @@ void FreeCompanyMgr::sendFcStatus( Entity::Player& player )
|
|||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
server.queueForPlayer( player.getCharacterId(), fcResultPacket );
|
||||
}
|
||||
|
||||
void FreeCompanyMgr::onFcLogin( uint64_t characterId )
|
||||
{
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
auto player = server.getPlayer( characterId );
|
||||
if( !player )
|
||||
return;
|
||||
|
||||
auto fc = getPlayerFreeCompany( *player );
|
||||
if( !fc )
|
||||
return;
|
||||
|
||||
auto fcResult = makeFcResult( *player, fc->getId(),
|
||||
2, FreeCompanyResultPacket::ResultType::FcLogin,
|
||||
0, FreeCompanyResultPacket::UpdateStatus::Execute,
|
||||
fc->getName(), fc->getTag() );
|
||||
|
||||
server.queueForPlayer( player->getCharacterId(), fcResult );
|
||||
|
||||
// todo - send packet to rest of fc members
|
||||
}
|
||||
|
|
|
@ -19,68 +19,7 @@ namespace Sapphire::World::Manager
|
|||
FreeCompanyPtr getFcByName( const std::string& name );
|
||||
|
||||
public:
|
||||
enum ResultType : int32_t
|
||||
{
|
||||
Create = 0x1,
|
||||
Leave = 0x2,
|
||||
Kick = 0x3,
|
||||
Disband = 0x4,
|
||||
SetHierarchyName = 0x5,
|
||||
SetAuthorityList = 0x6,
|
||||
MoveHierarchy = 0x7,
|
||||
AddHierarchy = 0x8,
|
||||
RemoveHierarchy = 0x9,
|
||||
SortHierarchy = 0xA,
|
||||
CreateComplete = 0xB,
|
||||
ForceDisband = 0xC,
|
||||
SetCompanyBoard = 0xD,
|
||||
ChangeMaster = 0xE,
|
||||
FcLogin = 0xF,
|
||||
FcLogout = 0x10,
|
||||
RenameCreate = 0x11,
|
||||
Rename = 0x12,
|
||||
RenameTag = 0x13,
|
||||
FcRankUp = 0x14,
|
||||
FcReputationUp = 0x15,
|
||||
MoveGrandCompany = 0x16,
|
||||
MoveGcComplete = 0x17,
|
||||
SetCompanyMotto = 0x18,
|
||||
SetCrestId = 0x19,
|
||||
ChestLock = 0x1A,
|
||||
BuyFcAction = 0x1B,
|
||||
RemoveFcAction = 0x1C,
|
||||
ExecuteFcAction = 0x1D,
|
||||
CancelFcAction = 0x1E,
|
||||
ClearFcParams = 0x1F,
|
||||
TimeoutFcAction = 0x20,
|
||||
MoveZone = 0x21,
|
||||
Reload = 0x22,
|
||||
LandGet = 0x23,
|
||||
LandRemove = 0x24,
|
||||
LandAutoRemove = 0x25,
|
||||
HouseBuild = 0x26,
|
||||
HouseRemove = 0x27,
|
||||
SetFcMemo = 0x28,
|
||||
HouseLock = 0x29,
|
||||
HouseUnlock = 0x2A,
|
||||
AddJoinRequest = 0x2B,
|
||||
RemoveJoinRequest = 0x2C,
|
||||
SetInfoFcData = 0x2D,
|
||||
DisbandJoinRequest = 0x2E,
|
||||
MasterDemote = 0x2F,
|
||||
PRoomGet = 0x30,
|
||||
PRoomRemove = 0x31,
|
||||
PRoomAutoRemove = 0x32,
|
||||
FcCreateAccept = 0x65,
|
||||
Join = 0x66,
|
||||
};
|
||||
|
||||
enum UpdateStatus : uint8_t
|
||||
{
|
||||
Execute = 0xA,
|
||||
Target = 0xB,
|
||||
Member = 0xC,
|
||||
};
|
||||
|
||||
FreeCompanyMgr() = default;
|
||||
|
||||
|
@ -93,7 +32,8 @@ namespace Sapphire::World::Manager
|
|||
|
||||
bool renameFreeCompany( uint64_t fcId, const std::string& name, const std::string& tag, Entity::Player& player );
|
||||
|
||||
void sendFreeCompanyResult( Entity::Player& player, uint64_t fcId, ResultType resultType, uint64_t target, uint32_t result, UpdateStatus updateStatus );
|
||||
//void sendFreeCompanyResult( Entity::Player& player, uint64_t fcId, ResultType resultType, uint64_t target,
|
||||
// uint32_t result, UpdateStatus updateStatus, std::string targetName );
|
||||
|
||||
void sendFcInviteList( Entity::Player& player );
|
||||
void sendFcStatus( Entity::Player& player );
|
||||
|
@ -116,6 +56,7 @@ namespace Sapphire::World::Manager
|
|||
// void leaveLinkshell( uint64_t lsId, uint64_t characterId );
|
||||
// void joinLinkshell( uint64_t lsId, uint64_t characterId );
|
||||
|
||||
void onFcLogin( uint64_t characterId );
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -498,4 +498,4 @@ bool LinkshellMgr::renameLinkshell( uint64_t linkshellId, const std::string &nam
|
|||
writeLinkshell( lsPtr->getId() );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -58,7 +58,6 @@ namespace Sapphire::World::Manager
|
|||
void leaveLinkshell( uint64_t lsId, uint64_t characterId );
|
||||
void joinLinkshell( uint64_t lsId, uint64_t characterId );
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <Manager/AchievementMgr.h>
|
||||
#include <Manager/PartyMgr.h>
|
||||
#include <Manager/HousingMgr.h>
|
||||
#include <Manager/FreeCompanyMgr.h>
|
||||
|
||||
#include "Script/ScriptMgr.h"
|
||||
#include "WorldServer.h"
|
||||
|
@ -341,6 +342,7 @@ void PlayerMgr::onZone( Sapphire::Entity::Player& player )
|
|||
auto& housingMgr = Common::Service< HousingMgr >::ref();
|
||||
auto& partyMgr = Common::Service< World::Manager::PartyMgr >::ref();
|
||||
auto& server = Common::Service< World::WorldServer >::ref();
|
||||
auto& fcMgr = Common::Service< World::Manager::FreeCompanyMgr >::ref();
|
||||
|
||||
auto pZone = teriMgr.getTerritoryByGuId( player.getTerritoryId() );
|
||||
if( !pZone )
|
||||
|
@ -421,6 +423,8 @@ void PlayerMgr::onZone( Sapphire::Entity::Player& player )
|
|||
partyMgr.onMoveZone( player );
|
||||
}
|
||||
|
||||
fcMgr.onFcLogin( player.getCharacterId() );
|
||||
|
||||
}
|
||||
|
||||
////////// Helper ///////////
|
||||
|
|
105
src/world/Network/PacketWrappers/FreeCompanyResultPacket.h
Normal file
105
src/world/Network/PacketWrappers/FreeCompanyResultPacket.h
Normal file
|
@ -0,0 +1,105 @@
|
|||
#pragma once
|
||||
|
||||
#include <Network/GamePacket.h>
|
||||
#include "Forwards.h"
|
||||
#include <Util/Util.h>
|
||||
#include <Util/UtilMath.h>
|
||||
#include <Common.h>
|
||||
|
||||
namespace Sapphire::Network::Packets::WorldPackets::Server
|
||||
{
|
||||
|
||||
class FreeCompanyResultPacket : public ZoneChannelPacket< FFXIVIpcFreeCompanyResult >
|
||||
{
|
||||
public:
|
||||
enum ResultType : int32_t
|
||||
{
|
||||
Create = 0x1,
|
||||
Leave = 0x2,
|
||||
Kick = 0x3,
|
||||
Disband = 0x4,
|
||||
SetHierarchyName = 0x5,
|
||||
SetAuthorityList = 0x6,
|
||||
MoveHierarchy = 0x7,
|
||||
AddHierarchy = 0x8,
|
||||
RemoveHierarchy = 0x9,
|
||||
SortHierarchy = 0xA,
|
||||
CreateComplete = 0xB,
|
||||
ForceDisband = 0xC,
|
||||
SetCompanyBoard = 0xD,
|
||||
ChangeMaster = 0xE,
|
||||
FcLogin = 0xF,
|
||||
FcLogout = 0x10,
|
||||
RenameCreate = 0x11,
|
||||
Rename = 0x12,
|
||||
RenameTag = 0x13,
|
||||
FcRankUp = 0x14,
|
||||
FcReputationUp = 0x15,
|
||||
MoveGrandCompany = 0x16,
|
||||
MoveGcComplete = 0x17,
|
||||
SetCompanyMotto = 0x18,
|
||||
SetCrestId = 0x19,
|
||||
ChestLock = 0x1A,
|
||||
BuyFcAction = 0x1B,
|
||||
RemoveFcAction = 0x1C,
|
||||
ExecuteFcAction = 0x1D,
|
||||
CancelFcAction = 0x1E,
|
||||
ClearFcParams = 0x1F,
|
||||
TimeoutFcAction = 0x20,
|
||||
MoveZone = 0x21,
|
||||
Reload = 0x22,
|
||||
LandGet = 0x23,
|
||||
LandRemove = 0x24,
|
||||
LandAutoRemove = 0x25,
|
||||
HouseBuild = 0x26,
|
||||
HouseRemove = 0x27,
|
||||
SetFcMemo = 0x28,
|
||||
HouseLock = 0x29,
|
||||
HouseUnlock = 0x2A,
|
||||
AddJoinRequest = 0x2B,
|
||||
RemoveJoinRequest = 0x2C,
|
||||
SetInfoFcData = 0x2D,
|
||||
DisbandJoinRequest = 0x2E,
|
||||
MasterDemote = 0x2F,
|
||||
PRoomGet = 0x30,
|
||||
PRoomRemove = 0x31,
|
||||
PRoomAutoRemove = 0x32,
|
||||
FcCreateAccept = 0x65,
|
||||
Join = 0x66,
|
||||
};
|
||||
|
||||
enum UpdateStatus : uint8_t
|
||||
{
|
||||
Execute = 0xA,
|
||||
Target = 0xB,
|
||||
Member = 0xC,
|
||||
};
|
||||
|
||||
FreeCompanyResultPacket( Entity::Player& player, uint64_t fcId, uint64_t targetId,
|
||||
ResultType type, uint32_t result, UpdateStatus updateStatus, const std::string& fcName, const std::string& targetName ) :
|
||||
|
||||
ZoneChannelPacket< FFXIVIpcFreeCompanyResult >( player.getId(), player.getId() )
|
||||
{
|
||||
initialize( player, fcId, targetId, type, result, updateStatus, fcName, targetName );
|
||||
};
|
||||
|
||||
private:
|
||||
void initialize( Entity::Player& player, uint64_t fcId, uint64_t targetId,
|
||||
ResultType type, uint32_t result, UpdateStatus updateStatus, const std::string& fcName, const std::string& targetName )
|
||||
{
|
||||
m_data.FreeCompanyID = fcId;
|
||||
m_data.Identity = 0xFF;
|
||||
m_data.Type = static_cast< uint32_t >( type );
|
||||
m_data.Result = result;
|
||||
m_data.UpdateStatus = updateStatus;
|
||||
m_data.TargetCharacterID = targetId;
|
||||
strcpy( m_data.FreeCompanyName, fcName.c_str() );
|
||||
strcpy( m_data.TargetName, targetName.c_str() );
|
||||
};
|
||||
};
|
||||
template< typename... Args >
|
||||
std::shared_ptr< FreeCompanyResultPacket > makeFcResult( Args... args )
|
||||
{
|
||||
return std::make_shared< FreeCompanyResultPacket >( args... );
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue