1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Class and db table for basic FC representation

This commit is contained in:
Mordred 2023-02-02 10:57:49 +01:00
parent 0929726ea5
commit 68a5040fb9
7 changed files with 424 additions and 13 deletions

View file

@ -0,0 +1,45 @@
CREATE TABLE IF NOT EXISTS FreeCompany (
FreeCompanyId int(20) NOT NULL,
MasterCharacterId int(20),
MasterCharacterName VARCHAR(32),
FcName VARCHAR(23),
FcTag VARCHAR(6),
FcCredit int(20),
FcCreditAccumu int(20),
FcRank smallint(6),
FcPoint int(20),
CrestId int(20),
CreateDate int(11),
GrandCompanyID int(3),
Reputation_0 int(20),
Reputation_1 int(20),
Reputation_2 int(20),
FcStatus int(3),
FcBoard varchar(193),
MoveGcDate int(20),
FcMotto varchar(193),
FcVersion int(11),
ActiveActionList_0 int(20),
ActiveActionList_1 int(20),
ActiveActionList_2 int(20),
ActiveActionLeftTime_0 int(20),
ActiveActionLeftTime_1 int(20),
ActiveActionLeftTime_2 int(20),
StockActionList_0 int(20),
StockActionList_1 int(20),
StockActionList_2 int(20),
StockActionList_3 int(20),
StockActionList_4 int(20),
StockActionList_5 int(20),
StockActionList_6 int(20),
StockActionList_7 int(20),
StockActionList_8 int(20),
StockActionList_9 int(20),
StockActionList_10 int(20),
StockActionList_11 int(20),
StockActionList_12 int(20),
StockActionList_13 int(20),
StockActionList_14 int(20),
`UPDATE_DATE` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`FreeCompanyId`),
KEY `index` (`MasterCharacterId`) )ENGINE=InnoDB DEFAULT CHARSET=utf8;

View file

@ -1403,6 +1403,15 @@ namespace Sapphire::Common
Completed = 8,
};
enum struct FreeCompanyStatus : uint8_t
{
Invalid = 0x0,
InviteStart = 0x1,
InviteComplete = 0x2,
Normal= 0x3,
Freeze = 0x4,
};
enum struct ChatType : uint16_t
{
LogKindError,

View file

@ -45,8 +45,35 @@ class ComDefFreeCompany : public Sapphire::ScriptAPI::EventScript
void onYield( uint32_t eventId, uint16_t sceneId, uint8_t yieldId, Entity::Player& player, const std::string& resultString, uint64_t resultInt ) override
{
if( yieldId == 0x11 )
eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 3, 2, 7, 2149548032, 118598, 1, 0, 1, 1, 1 } );
if( sceneId == 0 )
eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 } );
else if( sceneId == 5 )
{
/*
* GetFcStatusResult
{
uint64_t FreeCompanyID;
uint64_t AuthorityList;
uint64_t ChannelID;
uint64_t CrestID;
uint64_t CharaFcState;
uint64_t CharaFcParam;
uint16_t Param;
uint8_t FcStatus;
uint8_t GrandCompanyID;
uint8_t HierarchyType;
uint8_t FcRank;
uint8_t IsCrest;
uint8_t IsDecal;
uint8_t IsFcAction;
uint8_t IsChestExt1;
uint8_t IsChestLock;
};*/
// { 3, 1, 3, 1234567290, 2444, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0 } valid fc
// { 3, 2, 7, 1234567890, 111223, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0 } valid fc
// { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } not in company yet and able to get a petition
eventMgr().resumeScene( player, eventId, sceneId, yieldId, { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } );
}
}
@ -62,8 +89,10 @@ class ComDefFreeCompany : public Sapphire::ScriptAPI::EventScript
void Scene00000Return( Entity::Player& player, const Event::SceneResult& result )
{
//Scene00001( player );
if( result.getResult( 0 ) == 1 )
Scene00001( player );
else if( result.getResult( 0 ) == 5 )
Scene00005( player );
}
//////////////////////////////////////////////////////////////////////
@ -79,6 +108,7 @@ class ComDefFreeCompany : public Sapphire::ScriptAPI::EventScript
//////////////////////////////////////////////////////////////////////
// disband fc
void Scene00002( Entity::Player& player )
{
eventMgr().playScene( player, getId(), 2, NONE, bindSceneReturn( &ComDefFreeCompany::Scene00002Return ) );
@ -90,6 +120,7 @@ class ComDefFreeCompany : public Sapphire::ScriptAPI::EventScript
//////////////////////////////////////////////////////////////////////
//change fc state
void Scene00003( Entity::Player& player )
{
eventMgr().playScene( player, getId(), 3, NONE, bindSceneReturn( &ComDefFreeCompany::Scene00003Return ) );
@ -101,6 +132,7 @@ class ComDefFreeCompany : public Sapphire::ScriptAPI::EventScript
//////////////////////////////////////////////////////////////////////
// submit petition
void Scene00004( Entity::Player& player )
{
eventMgr().playScene( player, getId(), 4, NONE, bindSceneReturn( &ComDefFreeCompany::Scene00004Return ) );

View file

@ -10,6 +10,7 @@ file( GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
ContentFinder/*.cpp
DebugCommand/*.cpp
Event/*.cpp
FreeCompany/*.cpp
Inventory/*.cpp
Linkshell/*.cpp
Manager/*.cpp

View file

@ -0,0 +1,196 @@
#include "FreeCompany.h"
#include <utility>
Sapphire::FreeCompany::FreeCompany( uint64_t id, std::string name, std::string tag, uint64_t masterId, uint64_t chatChannelId, std::set< uint64_t > members,
std::set< uint64_t > invites ) :
m_id( id ),
m_name( std::move( name ) ),
m_tag( std::move( tag ) ),
m_chatChannelId( chatChannelId ),
m_masterCharacterId( masterId ),
m_memberIds( std::move( members ) ),
m_inviteIds( std::move( invites ) )
{
}
uint64_t Sapphire::FreeCompany::getId() const
{
return m_id;
}
const std::string& Sapphire::FreeCompany::getName() const
{
return m_name;
}
void Sapphire::FreeCompany::setName( std::string name )
{
m_name = std::move( name );
}
const std::string& Sapphire::FreeCompany::getTag() const
{
return m_tag;
}
void Sapphire::FreeCompany::setTag( std::string tag )
{
m_tag = std::move( tag );
}
uint64_t Sapphire::FreeCompany::getMasterId() const
{
return m_masterCharacterId;
}
void Sapphire::FreeCompany::setMasterId( uint64_t masterId )
{
m_masterCharacterId = masterId;
}
uint64_t Sapphire::FreeCompany::getCredit() const
{
return m_credit;
}
void Sapphire::FreeCompany::setCredit( uint64_t credit )
{
m_credit = credit;
}
uint64_t Sapphire::FreeCompany::getCreditAccumulated() const
{
return m_creditAccumulated;
}
void Sapphire::FreeCompany::setCreditAccumulated( uint64_t credit )
{
m_creditAccumulated = credit;
}
uint8_t Sapphire::FreeCompany::getRank() const
{
return m_rank;
}
void Sapphire::FreeCompany::setRank( uint8_t rank )
{
m_rank = rank;
}
uint64_t Sapphire::FreeCompany::getPoints() const
{
return m_points;
}
void Sapphire::FreeCompany::setPoints( uint64_t points )
{
m_points = points;
}
uint64_t Sapphire::FreeCompany::getCrest() const
{
return m_crest;
}
void Sapphire::FreeCompany::setCrest( uint64_t crest )
{
m_crest = crest;
}
uint32_t Sapphire::FreeCompany::getCreateDate() const
{
return m_createDate;
}
void Sapphire::FreeCompany::setCreateDate( uint32_t createDate )
{
m_createDate = createDate;
}
uint8_t Sapphire::FreeCompany::getGrandCompany() const
{
return m_gc;
}
void Sapphire::FreeCompany::setGrandCompany( uint8_t gcIndex )
{
if( gcIndex > 2 )
return;
m_gc = gcIndex;
}
uint64_t Sapphire::FreeCompany::getGcReputation( uint8_t gcIndex ) const
{
if( gcIndex > 2 )
return 0;
return m_gcReputation[ gcIndex ];
}
void Sapphire::FreeCompany::setGcReputation( uint8_t gcIndex, uint64_t reputation )
{
if( gcIndex > 2 )
return;
m_gcReputation[ gcIndex ] = reputation;
}
Sapphire::Common::FreeCompanyStatus Sapphire::FreeCompany::getFcStatus() const
{
return m_status;
}
void Sapphire::FreeCompany::setFcStatus( Sapphire::Common::FreeCompanyStatus status )
{
m_status = status;
}
const std::string& Sapphire::FreeCompany::getFcBoard() const
{
return m_fcBoard;
}
void Sapphire::FreeCompany::setFcBoard( const std::string& board )
{
m_fcBoard = board;
}
const std::string& Sapphire::FreeCompany::getFcMotto() const
{
return m_fcMotto;
}
void Sapphire::FreeCompany::setFcMotto( const std::string& motto )
{
m_fcMotto = motto;
}
uint32_t Sapphire::FreeCompany::getFcVersion() const
{
return m_fcVersion;
}
void Sapphire::FreeCompany::setFcVersion( uint32_t version )
{
m_fcVersion = version;
}
const uint64_t *Sapphire::FreeCompany::getActiveActionIdArr() const
{
return m_activeActionId;
}
const uint64_t *Sapphire::FreeCompany::getActiveActionTimeLeftArr() const
{
return m_activeActionTimeLeft;
}
const uint64_t *Sapphire::FreeCompany::getActionStockArr() const
{
return m_actionStock;
}

View file

@ -0,0 +1,137 @@
#pragma once
#include <Common.h>
#include <set>
#include <string>
namespace Sapphire
{
class FreeCompany
{
private:
/*! unique ID of the fc */
uint64_t m_id;
/*! ID of the master character */
uint64_t m_masterCharacterId;
std::string m_masterCharacterName;
/*! Name of the fc */
std::string m_name;
/*! Tag of the fc */
std::string m_tag;
/*! Fc Credit info */
uint64_t m_credit;
uint64_t m_creditAccumulated;
/*! Rank of the fc */
uint8_t m_rank;
/*! Points of the fc */
uint64_t m_points;
/*! Crest of the fc */
uint64_t m_crest;
/*! Creation timestamp of the fc */
uint32_t m_createDate;
/*! Current grand company of the fc */
uint8_t m_gc;
/*! Grand company reputation array */
uint64_t m_gcReputation[ 3 ];
/*! Status of the Company, Common::FreeCompanyStatus */
Common::FreeCompanyStatus m_status;
/*! Fc board text */
std::string m_fcBoard;
/*! Fc Motto text */
std::string m_fcMotto;
/*! Fc Version, unsure what this is used for */
uint32_t m_fcVersion;
/*! List of active actions */
uint64_t m_activeActionId[ 3 ];
/*! List of remaining action times */
uint64_t m_activeActionTimeLeft[ 3 ];
/*! List of actions in stock */
uint64_t m_actionStock[ 15 ];
/*! ID list of all members */
std::set< uint64_t > m_memberIds;
/*! list of IDs of pending character invites */
std::set< uint64_t > m_inviteIds;
/*! chat channel ID associated with fc */
uint64_t m_chatChannelId;
public:
FreeCompany( uint64_t id,
std::string name,
std::string tag,
uint64_t masterId,
uint64_t chatChannelId,
std::set< uint64_t > members,
std::set< uint64_t > invites );
uint64_t getId() const;
const std::string& getName() const;
void setName( std::string name );
const std::string& getTag() const;
void setTag( std::string tag );
uint64_t getMasterId() const;
void setMasterId( uint64_t masterId );
uint64_t getCredit() const;
void setCredit( uint64_t credit );
uint64_t getCreditAccumulated() const;
void setCreditAccumulated( uint64_t credit );
uint8_t getRank() const;
void setRank( uint8_t );
uint64_t getPoints() const;
void setPoints( uint64_t points );
uint64_t getCrest() const;
void setCrest( uint64_t crest );
uint32_t getCreateDate() const;
void setCreateDate( uint32_t createDate );
uint8_t getGrandCompany() const;
void setGrandCompany( uint8_t gcIndex );
uint64_t getGcReputation( uint8_t gcIndex ) const;
void setGcReputation( uint8_t gcIndex, uint64_t reputation );
Common::FreeCompanyStatus getFcStatus() const;
void setFcStatus( Common::FreeCompanyStatus status );
const std::string& getFcBoard() const;
void setFcBoard( const std::string& board );
const std::string& getFcMotto() const;
void setFcMotto( const std::string& motto );
uint32_t getFcVersion() const;
void setFcVersion( uint32_t version );
const uint64_t* getActiveActionIdArr() const;
const uint64_t* getActiveActionTimeLeftArr() const;
const uint64_t* getActionStockArr() const;
const std::set< uint64_t >& getMemberIdList() const;
std::set< uint64_t >& getMemberIdList();
const std::set< uint64_t >& getInviteIdList() const;
std::set< uint64_t >& getInviteIdList();
uint64_t getChatChannel() const;
void addMember( uint64_t memberId );
void removeMember( uint64_t memberId );
void addInvite( uint64_t memberId );
void removeInvite( uint64_t memberId );
};
}

View file

@ -123,16 +123,7 @@ std::string EventMgr::getEventName( uint32_t eventId )
case Event::EventHandler::EventHandlerType::Shop:
{
//auto shopInfo = exdData.getRow< Excel::ShopStruct >( eventId );
return "GilShop" + std::to_string( eventId );
/*if( shopInfo )
{
if( shopInfo->name.empty() || shopInfo->name == " " )
return "GilShop" + std::to_string( eventId );
return shopInfo->name;
}*/
//return unknown + "GilShop";
}
case Event::EventHandler::EventHandlerType::SwitchTalk: