2023-02-03 22:52:52 +01:00
|
|
|
#include <iterator>
|
|
|
|
|
|
|
|
#include <Common.h>
|
|
|
|
#include <Exd/ExdData.h>
|
|
|
|
#include <Service.h>
|
|
|
|
|
|
|
|
#include <Logging/Logger.h>
|
|
|
|
#include <Database/DatabaseDef.h>
|
|
|
|
#include <Manager/ChatChannelMgr.h>
|
|
|
|
#include <Network/GamePacket.h>
|
|
|
|
|
|
|
|
#include "FreeCompany/FreeCompany.h"
|
|
|
|
#include "FreeCompanyMgr.h"
|
|
|
|
|
|
|
|
#include "Actor/Player.h"
|
|
|
|
|
|
|
|
#include "WorldServer.h"
|
|
|
|
|
|
|
|
#include <Network/GameConnection.h>
|
|
|
|
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
2023-02-07 14:13:47 +01:00
|
|
|
#include <Network/PacketWrappers/FreeCompanyResultPacket.h>
|
2023-02-03 22:52:52 +01:00
|
|
|
#include <Network/PacketDef/ClientIpcs.h>
|
|
|
|
|
|
|
|
#include "Session.h"
|
|
|
|
|
|
|
|
using namespace Sapphire;
|
|
|
|
using namespace Sapphire::Network::Packets;
|
|
|
|
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
|
|
|
using namespace Sapphire::World::Manager;
|
|
|
|
|
|
|
|
bool FreeCompanyMgr::loadFreeCompanies()
|
|
|
|
{
|
|
|
|
auto& chatChannelMgr = Common::Service< Manager::ChatChannelMgr >::ref();
|
|
|
|
|
2023-02-09 12:19:00 +01:00
|
|
|
auto fcList = dbSelectFcsAll();
|
2023-02-03 22:52:52 +01:00
|
|
|
|
2023-02-09 12:19:00 +01:00
|
|
|
for( const auto& fcPtr : fcList )
|
2023-02-03 22:52:52 +01:00
|
|
|
{
|
2023-02-09 12:19:00 +01:00
|
|
|
if( m_maxFcId < fcPtr->getId() )
|
|
|
|
m_maxFcId = fcPtr->getId();
|
2023-02-03 22:52:52 +01:00
|
|
|
|
|
|
|
auto chatChannelId = chatChannelMgr.createChatChannel( Common::ChatChannelType::FreeCompanyChat );
|
2023-02-09 12:19:00 +01:00
|
|
|
fcPtr->setChatChannel( chatChannelId );
|
|
|
|
m_fcIdMap[ fcPtr->getId() ] = fcPtr;
|
|
|
|
m_fcNameMap[ fcPtr->getName() ] = fcPtr;
|
2023-02-03 22:52:52 +01:00
|
|
|
|
2023-02-09 12:19:00 +01:00
|
|
|
auto members = dbSelectMembersByFc( fcPtr->getId() );
|
|
|
|
for( const auto& member : members )
|
2023-02-08 15:22:26 +01:00
|
|
|
{
|
2023-02-09 12:19:00 +01:00
|
|
|
fcPtr->addMember( member.characterId, member.hierarchyId, member.lastLogout );
|
|
|
|
m_charaIdToFcIdMap[ member.characterId ] = fcPtr->getId();
|
2023-02-08 15:22:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-03 22:52:52 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeCompanyMgr::writeFreeCompany( uint64_t fcId )
|
|
|
|
{
|
|
|
|
auto fc = getFreeCompanyById( fcId );
|
|
|
|
|
|
|
|
if( !fc )
|
|
|
|
{
|
2023-02-09 12:19:00 +01:00
|
|
|
Logger::error( "FreeCompanyMgr: FreeCompany {} not found for write!", fcId );
|
2023-02-08 15:22:26 +01:00
|
|
|
return;
|
2023-02-03 22:52:52 +01:00
|
|
|
}
|
|
|
|
|
2023-02-09 12:19:00 +01:00
|
|
|
dbUpdateFc( *fc );
|
2023-02-03 22:52:52 +01:00
|
|
|
}
|
|
|
|
|
2023-02-08 15:22:26 +01:00
|
|
|
FreeCompanyPtr FreeCompanyMgr::getFreeCompanyByName( const std::string& name )
|
2023-02-03 22:52:52 +01:00
|
|
|
{
|
|
|
|
auto it = m_fcNameMap.find( name );
|
|
|
|
if( it == m_fcNameMap.end() )
|
|
|
|
return nullptr;
|
|
|
|
else
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeCompanyPtr FreeCompanyMgr::getFreeCompanyById( uint64_t fcId )
|
|
|
|
{
|
|
|
|
auto it = m_fcIdMap.find( fcId );
|
|
|
|
if( it == m_fcIdMap.end() )
|
|
|
|
return nullptr;
|
|
|
|
else
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeCompanyPtr FreeCompanyMgr::createFreeCompany( const std::string& name, const std::string& tag, Entity::Player& player )
|
|
|
|
{
|
2023-02-09 07:55:18 +01:00
|
|
|
uint64_t freeCompanyId = ++m_maxFcId;
|
2023-02-03 22:52:52 +01:00
|
|
|
|
|
|
|
// check if a fc with the same name already exists
|
|
|
|
auto lsIt = m_fcNameMap.find( name );
|
|
|
|
if( lsIt != m_fcNameMap.end() )
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
auto& chatChannelMgr = Common::Service< Manager::ChatChannelMgr >::ref();
|
|
|
|
auto chatChannelId = chatChannelMgr.createChatChannel( Common::ChatChannelType::FreeCompanyChat );
|
|
|
|
chatChannelMgr.addToChannel( chatChannelId, player );
|
|
|
|
|
|
|
|
uint64_t masterId = player.getCharacterId();
|
2023-02-08 15:22:26 +01:00
|
|
|
m_charaIdToFcIdMap[ masterId ] = freeCompanyId;
|
2023-02-03 22:52:52 +01:00
|
|
|
|
|
|
|
uint32_t createDate = Common::Util::getTimeSeconds();
|
|
|
|
|
2023-02-05 22:46:46 +01:00
|
|
|
auto fcPtr = std::make_shared< FreeCompany >( freeCompanyId, name, tag, masterId, chatChannelId );
|
2023-02-03 22:52:52 +01:00
|
|
|
fcPtr->setCreateDate( createDate );
|
|
|
|
fcPtr->setGrandCompany( player.getGc() );
|
2023-02-05 22:46:46 +01:00
|
|
|
fcPtr->setFcStatus( Common::FreeCompanyStatus::InviteStart );
|
|
|
|
fcPtr->setRank( 1 );
|
2023-02-03 22:52:52 +01:00
|
|
|
m_fcIdMap[ freeCompanyId ] = fcPtr;
|
|
|
|
m_fcNameMap[ name ] = fcPtr;
|
|
|
|
|
2023-02-09 12:19:00 +01:00
|
|
|
dbInsertFc( *fcPtr );
|
2023-02-08 23:27:12 +01:00
|
|
|
dbInsertMember( freeCompanyId, masterId, 0 );
|
2023-02-03 22:52:52 +01:00
|
|
|
|
2023-02-08 15:22:26 +01:00
|
|
|
fcPtr->addMember( masterId, 0, createDate );
|
|
|
|
|
2023-02-07 14:13:47 +01:00
|
|
|
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 );
|
2023-02-06 15:49:47 +01:00
|
|
|
|
2023-02-03 22:52:52 +01:00
|
|
|
return fcPtr;
|
|
|
|
}
|
|
|
|
|
2023-02-05 22:46:46 +01:00
|
|
|
void FreeCompanyMgr::sendFreeCompanyStatus( Entity::Player& player )
|
|
|
|
{
|
|
|
|
auto& server = Common::Service< World::WorldServer >::ref();
|
|
|
|
|
|
|
|
auto fcStatusResult = makeZonePacket< FFXIVIpcGetFcStatusResult >( player.getId() );
|
|
|
|
|
2023-02-08 23:27:12 +01:00
|
|
|
auto playerFc = getPlayerFreeCompany( player.getCharacterId() );
|
2023-02-05 22:46:46 +01:00
|
|
|
if( !playerFc )
|
|
|
|
return;
|
|
|
|
|
|
|
|
fcStatusResult->data().AuthorityList = 0;
|
|
|
|
fcStatusResult->data().ChannelID = playerFc->getChatChannel();
|
|
|
|
fcStatusResult->data().Param = 2; // this appears to control which packets are requested afterwards
|
|
|
|
fcStatusResult->data().CharaFcParam = 0;
|
|
|
|
fcStatusResult->data().CrestID = playerFc->getCrest();
|
|
|
|
fcStatusResult->data().FcRank = playerFc->getRank();
|
|
|
|
fcStatusResult->data().FcStatus = static_cast< uint8_t >( playerFc->getFcStatus() );
|
|
|
|
fcStatusResult->data().FreeCompanyID = playerFc->getId();
|
|
|
|
fcStatusResult->data().GrandCompanyID = playerFc->getGrandCompany();
|
|
|
|
|
|
|
|
server.queueForPlayer( player.getCharacterId(), fcStatusResult );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-08 23:27:12 +01:00
|
|
|
FreeCompanyPtr FreeCompanyMgr::getPlayerFreeCompany( uint64_t characterId )
|
2023-02-03 22:52:52 +01:00
|
|
|
{
|
2023-02-08 23:27:12 +01:00
|
|
|
auto it = m_charaIdToFcIdMap.find( characterId );
|
2023-02-08 15:43:11 +01:00
|
|
|
if( it != m_charaIdToFcIdMap.end() )
|
|
|
|
return getFreeCompanyById( it->second );
|
|
|
|
|
2023-02-03 22:52:52 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
2023-02-06 15:49:47 +01:00
|
|
|
|
|
|
|
void FreeCompanyMgr::sendFcInviteList( Entity::Player& player )
|
|
|
|
{
|
2023-02-08 23:27:12 +01:00
|
|
|
auto fc = getPlayerFreeCompany( player.getCharacterId() );
|
2023-02-06 15:49:47 +01:00
|
|
|
if( !fc )
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto& server = Common::Service< World::WorldServer >::ref();
|
|
|
|
|
|
|
|
auto inviteListPacket = makeZonePacket< FFXIVIpcGetFcInviteListResult >( player.getId() );
|
|
|
|
inviteListPacket->data().GrandCompanyID = fc->getGrandCompany();
|
|
|
|
inviteListPacket->data().FreeCompanyID = fc->getId();
|
|
|
|
std::strcpy( inviteListPacket->data().FcTag, fc->getTag().c_str() );
|
|
|
|
std::strcpy( inviteListPacket->data().FreeCompanyName, fc->getName().c_str() );
|
|
|
|
|
|
|
|
// fill master character data
|
|
|
|
auto masterCharacter = server.getPlayer( fc->getMasterId() );
|
|
|
|
if( !masterCharacter )
|
|
|
|
Logger::error( "FreeCompanyMgr: Unable to look up master character#{}!", fc->getMasterId() );
|
|
|
|
|
|
|
|
inviteListPacket->data().MasterCharacter.GrandCompanyID = masterCharacter->getGc();
|
|
|
|
inviteListPacket->data().MasterCharacter.CharacterID = masterCharacter->getCharacterId();
|
|
|
|
strcpy( inviteListPacket->data().MasterCharacter.CharacterName, masterCharacter->getName().c_str() );
|
|
|
|
inviteListPacket->data().MasterCharacter.SelectRegion = masterCharacter->getSearchSelectRegion();
|
2023-02-08 15:22:26 +01:00
|
|
|
inviteListPacket->data().MasterCharacter.OnlineStatus = static_cast< uint64_t >( masterCharacter->getOnlineStatus() );
|
2023-02-06 15:49:47 +01:00
|
|
|
inviteListPacket->data().MasterCharacter.GrandCompanyRank[ 0 ] = masterCharacter->getGcRankArray()[ 0 ];
|
|
|
|
inviteListPacket->data().MasterCharacter.GrandCompanyRank[ 1 ] = masterCharacter->getGcRankArray()[ 1 ];
|
|
|
|
inviteListPacket->data().MasterCharacter.GrandCompanyRank[ 2 ] = masterCharacter->getGcRankArray()[ 2 ];
|
|
|
|
|
2023-02-08 15:22:26 +01:00
|
|
|
uint8_t idx = 0;
|
|
|
|
for( auto& entry : fc->getMemberIdList() )
|
|
|
|
{
|
2023-02-08 23:27:12 +01:00
|
|
|
if( entry == 0 || entry == fc->getMasterId() )
|
2023-02-08 15:22:26 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
auto signee = server.getPlayer( entry );
|
|
|
|
if( !signee )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
inviteListPacket->data().InviteCharacter[ idx ].CharacterID = signee->getCharacterId();
|
|
|
|
strcpy( inviteListPacket->data().InviteCharacter[ idx ].CharacterName, signee->getName().c_str() );
|
|
|
|
inviteListPacket->data().InviteCharacter[ idx ].SelectRegion = signee->getSearchSelectRegion();
|
|
|
|
inviteListPacket->data().InviteCharacter[ idx ].OnlineStatus = static_cast< uint64_t >( masterCharacter->getOnlineStatus() );
|
|
|
|
idx++;
|
|
|
|
}
|
2023-02-06 15:49:47 +01:00
|
|
|
|
|
|
|
server.queueForPlayer( player.getCharacterId(), inviteListPacket );
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeCompanyMgr::sendFcStatus( Entity::Player& player )
|
|
|
|
{
|
2023-02-08 23:27:12 +01:00
|
|
|
auto fc = getPlayerFreeCompany( player.getCharacterId() );
|
2023-02-06 15:49:47 +01:00
|
|
|
auto fcResultPacket = makeZonePacket< FFXIVIpcGetFcStatusResult >( player.getId() );
|
|
|
|
auto& resultData = fcResultPacket->data();
|
|
|
|
resultData.CharaFcParam = 1;
|
|
|
|
|
|
|
|
if( fc )
|
|
|
|
{
|
|
|
|
resultData.FreeCompanyID = fc->getId();
|
|
|
|
resultData.AuthorityList = 0;
|
2023-02-09 07:55:18 +01:00
|
|
|
resultData.HierarchyType = player.getCharacterId() == fc->getMasterId() ? 0 : 1;
|
2023-02-06 15:49:47 +01:00
|
|
|
resultData.GrandCompanyID = fc->getGrandCompany();
|
|
|
|
resultData.FcRank = fc->getRank();
|
|
|
|
resultData.CrestID = fc->getCrest();
|
|
|
|
resultData.FcStatus = static_cast< uint8_t >( fc->getFcStatus() );
|
|
|
|
resultData.ChannelID = fc->getChatChannel();
|
2023-02-09 07:55:18 +01:00
|
|
|
//resultData.CharaFcParam = 1;
|
|
|
|
//resultData.CharaFcState = 1;
|
2023-02-06 15:49:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
auto& server = Common::Service< World::WorldServer >::ref();
|
|
|
|
server.queueForPlayer( player.getCharacterId(), fcResultPacket );
|
|
|
|
}
|
2023-02-07 14:13:47 +01:00
|
|
|
|
|
|
|
void FreeCompanyMgr::onFcLogin( uint64_t characterId )
|
|
|
|
{
|
|
|
|
auto& server = Common::Service< World::WorldServer >::ref();
|
|
|
|
auto player = server.getPlayer( characterId );
|
|
|
|
if( !player )
|
|
|
|
return;
|
|
|
|
|
2023-02-08 23:27:12 +01:00
|
|
|
auto fc = getPlayerFreeCompany( player->getCharacterId() );
|
2023-02-07 14:13:47 +01:00
|
|
|
if( !fc )
|
|
|
|
return;
|
|
|
|
|
2023-02-08 15:22:26 +01:00
|
|
|
uint64_t onlinePlayers = 1;
|
|
|
|
auto fcResult = makeFcResult( *player, fc->getId(), onlinePlayers,
|
|
|
|
FreeCompanyResultPacket::ResultType::FcLogin,
|
2023-02-07 14:13:47 +01:00
|
|
|
0, FreeCompanyResultPacket::UpdateStatus::Execute,
|
|
|
|
fc->getName(), fc->getTag() );
|
|
|
|
|
|
|
|
server.queueForPlayer( player->getCharacterId(), fcResult );
|
|
|
|
|
|
|
|
// todo - send packet to rest of fc members
|
|
|
|
}
|
2023-02-08 15:22:26 +01:00
|
|
|
|
|
|
|
void FreeCompanyMgr::onSignPetition( Entity::Player& source, Entity::Player& target )
|
|
|
|
{
|
|
|
|
|
2023-02-08 23:27:12 +01:00
|
|
|
auto fc = getPlayerFreeCompany( target.getCharacterId() );
|
|
|
|
if( !fc )
|
|
|
|
return;
|
|
|
|
|
|
|
|
addMember( fc->getId(), source.getCharacterId() );
|
|
|
|
// todo - send fcresult packets
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeCompanyMgr::addMember( uint64_t fcId, uint64_t memberId )
|
|
|
|
{
|
|
|
|
auto pFc = getFreeCompanyById( fcId );
|
|
|
|
if( !pFc )
|
|
|
|
return;
|
|
|
|
|
|
|
|
dbInsertMember( fcId, memberId, 0 );
|
|
|
|
pFc->addMember( memberId, 0, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeCompanyMgr::dbInsertMember( uint64_t fcId, uint64_t characterId, uint8_t hierarchyId )
|
|
|
|
{
|
|
|
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
|
|
|
|
|
|
|
/*! FreeCompanyId, FcMemberId, HierarchyType, LastLogout */
|
|
|
|
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::FC_MEMBERS_INS );
|
|
|
|
stmt->setUInt64( 1, fcId );
|
|
|
|
stmt->setUInt64( 2, characterId );
|
|
|
|
stmt->setUInt( 3, hierarchyId );
|
|
|
|
stmt->setUInt( 4, 0 );
|
|
|
|
db.directExecute( stmt );
|
2023-02-08 15:22:26 +01:00
|
|
|
}
|
2023-02-09 12:19:00 +01:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/// DB Related functions
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
void FreeCompanyMgr::dbInsertFc( const FreeCompany& fc )
|
|
|
|
{
|
|
|
|
//FreeCompanyId, MasterCharacterId, FcName, FcTag, FcCredit, FcCreditAccumu, FcRank, FcPoint,
|
|
|
|
//ReputationList, CrestId, CreateDate, GrandCompanyID, FcStatus, FcBoard, FcMotto
|
|
|
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
|
|
|
auto stmt = db.getPreparedStatement( Db::ZoneDbStatements::FC_INS );
|
|
|
|
stmt->setUInt64( 1, fc.getId() );
|
|
|
|
stmt->setUInt64( 2, fc.getMasterId() );
|
|
|
|
stmt->setString( 3, fc.getName() );
|
|
|
|
stmt->setString( 4, fc.getTag() );
|
|
|
|
stmt->setUInt64( 5, 0 );
|
|
|
|
stmt->setUInt64( 6, 0 );
|
|
|
|
stmt->setUInt( 7, 1 );
|
|
|
|
stmt->setUInt64( 8, 0 );
|
|
|
|
std::vector< uint8_t > rep( 24 );
|
|
|
|
stmt->setBinary( 9, rep );
|
|
|
|
stmt->setUInt64( 10, 0 );
|
|
|
|
stmt->setUInt( 11, Common::Util::getTimeSeconds() );
|
|
|
|
stmt->setUInt( 12, fc.getGrandCompany() );
|
|
|
|
stmt->setUInt( 13, static_cast< uint8_t >( Common::FreeCompanyStatus::InviteStart ) );
|
|
|
|
stmt->setString( 14, std::string( "" ) );
|
|
|
|
stmt->setString( 15, std::string( "" ) );
|
|
|
|
db.directExecute( stmt );
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeCompanyMgr::dbUpdateFc( const FreeCompany& fc )
|
|
|
|
{
|
|
|
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
|
|
|
auto query = db.getPreparedStatement( Db::FC_UP );
|
|
|
|
|
|
|
|
/* MasterCharacterId = ?, FcName = ?, FcTag = ?, FcCredit = ?, FcCreditAccumu = ?,
|
|
|
|
* FcRank = ?, FcPoint = ?, ReputationList = ?, CrestId = ?,"
|
|
|
|
* CreateDate = ?, GrandCompanyID = ?, FcStatus = ?, FcBoard = ?, "
|
|
|
|
* FcMotto = ?, ActiveActionList = ?, , ActiveActionLeftTimeList = ?, StockActionList = ? "
|
|
|
|
*/
|
|
|
|
|
|
|
|
query->setUInt64( 1, fc.getMasterId() );
|
|
|
|
query->setString( 2, fc.getName() );
|
|
|
|
query->setString( 3, fc.getTag() );
|
|
|
|
query->setUInt64( 4, fc.getCredit() );
|
|
|
|
query->setUInt64( 5, fc.getCreditAccumulated() );
|
|
|
|
query->setUInt( 6, fc.getRank() );
|
|
|
|
query->setUInt64( 7, fc.getPoints() );
|
|
|
|
std::vector< uint8_t > repList( 24 );
|
|
|
|
query->setBinary( 8, repList );
|
|
|
|
query->setUInt64( 9, fc.getCrest() );
|
|
|
|
query->setUInt( 10, fc.getCreateDate() );
|
|
|
|
query->setUInt( 11, fc.getGrandCompany() );
|
|
|
|
query->setUInt( 12, static_cast< uint8_t >( fc.getFcStatus() ) );
|
|
|
|
query->setString( 13, fc.getFcBoard() );
|
|
|
|
query->setString( 14, fc.getFcMotto() );
|
|
|
|
std::vector< uint8_t > activeActionList( 24 );
|
|
|
|
query->setBinary( 15, activeActionList );
|
|
|
|
std::vector< uint8_t > activeActionLeftTimeList( 24 );
|
|
|
|
query->setBinary( 16, activeActionLeftTimeList );
|
|
|
|
std::vector< uint8_t > stockActionList( 120 );
|
|
|
|
query->setBinary( 17, stockActionList );
|
|
|
|
|
|
|
|
query->setInt64( 18, static_cast< int64_t >( fc.getId() ) );
|
|
|
|
db.execute( query );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector< FreeCompanyPtr > FreeCompanyMgr::dbSelectFcsAll()
|
|
|
|
{
|
|
|
|
std::vector< FreeCompanyPtr > fcList;
|
|
|
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
|
|
|
auto query = db.getPreparedStatement( Db::FC_SEL_ALL );
|
|
|
|
auto res = db.query( query );
|
|
|
|
|
|
|
|
/* FreeCompanyId, MasterCharacterId, FcName, FcTag, FcCredit, FcCreditAccumu, FcRank, FcPoint, CrestId, CreateDate, GrandCompanyID, "
|
|
|
|
" ReputationList, FcStatus, FcBoard, FcMotto, ActiveActionList, ActiveActionLeftTimeList, StockActionList */
|
|
|
|
while( res->next() )
|
|
|
|
{
|
|
|
|
uint64_t fcId = res->getUInt64( 1 );
|
|
|
|
uint64_t masterId = res->getUInt64( 2 );
|
|
|
|
std::string name = res->getString( 3 );
|
|
|
|
std::string tag = res->getString( 4 );
|
|
|
|
uint64_t credit = res->getUInt64( 5 );
|
|
|
|
uint64_t creditAcc = res->getUInt64( 6 );
|
|
|
|
uint8_t rank = res->getUInt8( 7 );
|
|
|
|
uint64_t points = res->getUInt64( 8 );
|
|
|
|
uint64_t crestId = res->getUInt64( 9 );
|
|
|
|
uint32_t creationDate = res->getUInt( 10 );
|
|
|
|
uint8_t gcId = res->getUInt8( 11 );
|
|
|
|
auto reputationListVec = res->getBlobVector( 12 );
|
|
|
|
uint8_t status = res->getUInt8( 13 );
|
|
|
|
std::string board = res->getString( 14 );
|
|
|
|
std::string motto = res->getString( 15 );
|
|
|
|
|
|
|
|
auto fcPtr = std::make_shared< FreeCompany >( fcId, name, tag, masterId, 0 );
|
|
|
|
fcPtr->setCredit( credit );
|
|
|
|
fcPtr->setCreditAccumulated( creditAcc );
|
|
|
|
fcPtr->setRank( rank );
|
|
|
|
fcPtr->setPoints( points );
|
|
|
|
fcPtr->setCrest( crestId );
|
|
|
|
fcPtr->setCreateDate( creationDate );
|
|
|
|
fcPtr->setGrandCompany( gcId );
|
|
|
|
fcPtr->setFcStatus( static_cast< Common::FreeCompanyStatus >( status ) );
|
|
|
|
fcPtr->setFcBoard( board );
|
|
|
|
fcPtr->setFcMotto( motto );
|
|
|
|
fcList.push_back( fcPtr );
|
|
|
|
}
|
|
|
|
return fcList;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector< FreeCompany::FcMember > FreeCompanyMgr::dbSelectMembersByFc( uint64_t fcId )
|
|
|
|
{
|
|
|
|
std::vector< FreeCompany::FcMember > memberList;
|
|
|
|
auto& db = Common::Service< Db::DbWorkerPool< Db::ZoneDbConnection > >::ref();
|
|
|
|
|
|
|
|
/* FcMemberId, HierarchyType, LastLogout */
|
|
|
|
auto queryMember = db.getPreparedStatement( Db::FC_MEMBERS_SEL_FC );
|
|
|
|
queryMember->setUInt64( 1, fcId );
|
|
|
|
auto resMember = db.query( queryMember );
|
|
|
|
while( resMember->next() )
|
|
|
|
{
|
|
|
|
struct FreeCompany::FcMember member;
|
|
|
|
member.characterId = resMember->getUInt64( 1 );
|
|
|
|
member.hierarchyId = resMember->getUInt8( 2 );
|
|
|
|
member.lastLogout = resMember->getUInt( 3 );
|
|
|
|
memberList.push_back( member );
|
|
|
|
}
|
|
|
|
return memberList;
|
|
|
|
}
|