1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-14 06:27:45 +00:00

Fixing some array sizes and defining them in common

This commit is contained in:
Mordred 2023-02-18 15:26:50 +01:00
parent f91494fa7b
commit 3a71d90e71
8 changed files with 41 additions and 33 deletions

View file

@ -89,7 +89,7 @@ std::string PlayerMinimal::getInfoJson()
// class levels // class levels
auto levelsArray = nlohmann::json(); auto levelsArray = nlohmann::json();
for( int i = 0; i < Common::CLASSJOB_SLOTS; ++i ) for( int i = 0; i < Common::ARRSIZE_CLASSJOB; ++i )
{ {
// these must be strings // these must be strings
levelsArray.push_back( std::to_string( m_classMap[ i ] ) ); levelsArray.push_back( std::to_string( m_classMap[ i ] ) );
@ -186,16 +186,16 @@ void PlayerMinimal::saveAsNew()
{ {
std::vector< uint8_t > customize( 26 ); std::vector< uint8_t > customize( 26 );
std::vector< uint8_t > howTo( 33 ); std::vector< uint8_t > howTo( Common::ARRSIZE_HOWTO );
std::vector< uint8_t > aetherytes( 16 ); std::vector< uint8_t > aetherytes( Common::ARRSIZE_AETHERYTES );
std::vector< uint8_t > discovery( 421 ); std::vector< uint8_t > discovery( Common::ARRSIZE_DISCOVERY );
std::vector< uint8_t > questComplete( 342 ); std::vector< uint8_t > questComplete( Common::ARRSIZE_QUESTCOMPLETE );
std::vector< uint8_t > unlocks( 64 ); std::vector< uint8_t > unlocks( Common::ARRSIZE_UNLOCKS );
std::vector< uint8_t > mountGuide( 15 ); std::vector< uint8_t > mountGuide( Common::ARRSIZE_MOUNTS );
std::vector< uint8_t > orchestrion( 40 ); std::vector< uint8_t > orchestrion( Common::ARRSIZE_ORCHESTRION );
std::vector< uint8_t > modelEquip( 40 ); std::vector< uint8_t > modelEquip( 40 );
std::vector< uint8_t > questTracking8( 10 ); std::vector< uint8_t > questTracking8( 10 );
std::vector< uint8_t > monsterNote( 41 ); std::vector< uint8_t > monsterNote( sizeof( Common::HuntingLogEntry ) );
std::vector< int16_t > questTracking = { -1, -1, -1, -1, -1 }; std::vector< int16_t > questTracking = { -1, -1, -1, -1, -1 };
memset( questComplete.data(), 0, questComplete.size() ); memset( questComplete.data(), 0, questComplete.size() );
@ -314,7 +314,7 @@ void PlayerMinimal::saveAsNew()
auto stmtMonsterNote = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_MONSTERNOTE_INS ); auto stmtMonsterNote = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_MONSTERNOTE_INS );
stmtMonsterNote->setUInt64( 1, m_characterId ); stmtMonsterNote->setUInt64( 1, m_characterId );
for( uint8_t i = 1; i <= 12; ++i ) for( uint8_t i = 1; i <= Common::ARRSIZE_MONSTERNOTE; ++i )
stmtMonsterNote->setBinary( i + 1, monsterNote ); stmtMonsterNote->setBinary( i + 1, monsterNote );
g_charaDb.directExecute( stmtMonsterNote ); g_charaDb.directExecute( stmtMonsterNote );

View file

@ -25,7 +25,18 @@ namespace Sapphire::Common
const uint8_t CURRENT_EXPANSION_ID = 1; const uint8_t CURRENT_EXPANSION_ID = 1;
const uint8_t CLASSJOB_TOTAL = 34; const uint8_t CLASSJOB_TOTAL = 34;
const uint8_t CLASSJOB_SLOTS = 23;
const uint16_t ARRSIZE_CLASSJOB = 23u;
const uint16_t ARRSIZE_TITLELIST = 48u;
const uint16_t ARRSIZE_HOWTO = 32u;
const uint16_t ARRSIZE_MINIONS = 28u;
const uint16_t ARRSIZE_MOUNTS = 9u;
const uint16_t ARRSIZE_DISCOVERY = 400u;
const uint16_t ARRSIZE_QUESTCOMPLETE = 342u;
const uint16_t ARRSIZE_AETHERYTES = 12u;
const uint16_t ARRSIZE_UNLOCKS = 64u;
const uint16_t ARRSIZE_ORCHESTRION = 40u;
const uint16_t ARRSIZE_MONSTERNOTE = 12u;
const uint8_t TOWN_COUNT = 6; const uint8_t TOWN_COUNT = 6;

View file

@ -816,7 +816,7 @@ namespace Sapphire::Network::Packets::WorldPackets::Server
*/ */
struct FFXIVIpcTitleList : FFXIVIpcBasePacket< TitleList > struct FFXIVIpcTitleList : FFXIVIpcBasePacket< TitleList >
{ {
uint8_t TitleFlagsArray[32]; uint8_t TitleFlagsArray[48];
}; };
/** /**

View file

@ -567,7 +567,7 @@ void Lobby::GameConnection::handlePackets( const Network::Packets::FFXIVARR_PACK
BlowFish blowfish; BlowFish blowfish;
blowfish.initialize( m_encKey, 0x10 ); blowfish.initialize( m_encKey, 0x10 );
blowfish.Decode( ( uint8_t* ) ( &inPacket.data[ 0 ] ), ( uint8_t* ) ( &inPacket.data[ 0 ] ), blowfish.Decode( ( uint8_t* ) ( &inPacket.data[ 0 ] ), ( uint8_t* ) ( &inPacket.data[ 0 ] ),
( inPacket.data.size() ) - 0x10 ); static_cast< uint32_t >( inPacket.data.size() ) - 0x10 );
} }
switch( inPacket.segHdr.type ) switch( inPacket.segHdr.type )

View file

@ -32,10 +32,10 @@ void LobbyPacketContainer::addPacket( FFXIVPacketBasePtr pEntry )
{ {
BlowFish blowfish; BlowFish blowfish;
blowfish.initialize( m_encKey, 0x10 ); blowfish.initialize( m_encKey, 0x10 );
blowfish.Encode( m_dataBuf.data() + m_header.size + 0x10, m_dataBuf.data() + m_header.size + 0x10, pEntry->getSize() - 0x10 ); blowfish.Encode( m_dataBuf.data() + m_header.size + 0x10, m_dataBuf.data() + m_header.size + 0x10, static_cast< uint32_t >( pEntry->getSize() ) - 0x10 );
} }
m_header.size += pEntry->getSize(); m_header.size += static_cast< uint32_t >( pEntry->getSize() );
m_header.count++; m_header.count++;
} }

View file

@ -25,19 +25,19 @@ namespace Sapphire::Entity
class Player : public Chara class Player : public Chara
{ {
public: public:
using TitleList = std::array< uint8_t, 48 >; using TitleList = std::array< uint8_t, Common::ARRSIZE_TITLELIST >;
using HowToList = std::array< uint8_t, 34 >; using HowToList = std::array< uint8_t, Common::ARRSIZE_HOWTO >;
using MinionList = std::array< uint8_t, 40 >; using MinionList = std::array< uint8_t, Common::ARRSIZE_MINIONS >;
using MountList = std::array< uint8_t, 22 >; using MountList = std::array< uint8_t, Common::ARRSIZE_MOUNTS >;
using QuestComplete = std::array< uint8_t, 342 >; using QuestComplete = std::array< uint8_t, Common::ARRSIZE_QUESTCOMPLETE >;
using Discovery = std::array< uint8_t, 400 >; using Discovery = std::array< uint8_t, Common::ARRSIZE_DISCOVERY >;
using AetheryteList = std::array< uint8_t, 21 >; using AetheryteList = std::array< uint8_t, Common::ARRSIZE_AETHERYTES >;
using UnlockList = std::array< uint8_t, 64 >; using UnlockList = std::array< uint8_t, Common::ARRSIZE_UNLOCKS >;
using OrchestrionList = std::array< uint8_t, 40 >; using OrchestrionList = std::array< uint8_t, Common::ARRSIZE_ORCHESTRION >;
using StateFlags = std::array< uint8_t, 12 >; using StateFlags = std::array< uint8_t, 12 >;
using ClassList = std::array< uint16_t, 28 >; using ClassList = std::array< uint16_t, Common::ARRSIZE_CLASSJOB >;
using ExpList = std::array< uint32_t, 28 >; using ExpList = std::array< uint32_t, Common::ARRSIZE_CLASSJOB >;
struct AchievementData { struct AchievementData {
std::array< uint8_t, 2048 / 8 > unlockList; std::array< uint8_t, 2048 / 8 > unlockList;
@ -994,7 +994,7 @@ namespace Sapphire::Entity
Common::Util::SpawnIndexAllocator< uint8_t > m_objSpawnIndexAllocator; Common::Util::SpawnIndexAllocator< uint8_t > m_objSpawnIndexAllocator;
Common::Util::SpawnIndexAllocator< uint8_t > m_actorSpawnIndexAllocator; Common::Util::SpawnIndexAllocator< uint8_t > m_actorSpawnIndexAllocator;
std::array< Common::HuntingLogEntry, 12 > m_huntingLogEntries{}; std::array< Common::HuntingLogEntry, Common::ARRSIZE_MONSTERNOTE > m_huntingLogEntries{};
FriendListIDVec m_friendList{}; FriendListIDVec m_friendList{};
FriendListDataVec m_friendInviteList{}; FriendListDataVec m_friendInviteList{};

View file

@ -545,9 +545,6 @@ void DebugCommandMgr::add( char* data, Entity::Player& player, std::shared_ptr<
auto sequence = pCurrentZone->getNextEffectResultId(); auto sequence = pCurrentZone->getNextEffectResultId();
effectPacket->setSequence( sequence ); effectPacket->setSequence( sequence );
// effectPacket->setAnimationId( param1 );
// effectPacket->setEffectFlags( 0 );
server().queueForPlayer( player.getCharacterId(), effectPacket ); server().queueForPlayer( player.getCharacterId(), effectPacket );
} }
else if( subCommand == "achvGeneral" ) else if( subCommand == "achvGeneral" )
@ -597,8 +594,8 @@ void DebugCommandMgr::get( char* data, Entity::Player& player, std::shared_ptr<
int16_t map_id = exdData.getRow< Excel::TerritoryType >( player.getTerritoryTypeId() )->data().Map; int16_t map_id = exdData.getRow< Excel::TerritoryType >( player.getTerritoryTypeId() )->data().Map;
PlayerMgr::sendServerNotice( player, "Pos:\n {0}\n {1}\n {2}\n {3}\n MapId: {4}\n ZoneId:{5}", PlayerMgr::sendServerNotice( player, "Pos:\n {0}\n {1}\n {2}\n {3}\n MapId: {4}\n ZoneId:{5}",
player.getPos().x, player.getPos().y, player.getPos().z, player.getPos().x, player.getPos().y, player.getPos().z,
player.getRot(), map_id, player.getTerritoryTypeId() ); player.getRot(), map_id, player.getTerritoryTypeId() );
} }
else else
{ {

View file

@ -49,7 +49,7 @@ namespace Sapphire::Network::Packets::WorldPackets::Server
memcpy( m_data.Aetheryte, player.getAetheryteArray().data(), sizeof( m_data.Aetheryte ) ); memcpy( m_data.Aetheryte, player.getAetheryteArray().data(), sizeof( m_data.Aetheryte ) );
// Set the class levels and exp. // Set the class levels and exp.
for( uint8_t i = 0; i < Common::CLASSJOB_SLOTS; ++i ) for( uint8_t i = 0; i < Common::ARRSIZE_CLASSJOB; ++i )
{ {
m_data.Lv[ i ] = player.getClassArray()[ i ]; m_data.Lv[ i ] = player.getClassArray()[ i ];
m_data.Exp[ i ] = player.getExpArray()[ i ]; m_data.Exp[ i ] = player.getExpArray()[ i ];