1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-08 03:37:45 +00:00

Load hunting log data

This commit is contained in:
Mordred 2019-03-26 00:04:27 +01:00
parent f5697e0a01
commit 8b6e78877d
7 changed files with 51 additions and 2 deletions

View file

@ -263,6 +263,12 @@ namespace Sapphire::Common
};
struct HuntingLogEntry
{
uint8_t rank;
uint8_t entries[10][4];
};
enum class UnlockEntry : uint16_t
{
Return = 1,

View file

@ -200,6 +200,14 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
" WHERE CharacterId = ?;",
CONNECTION_ASYNC );
/// CLASS INFO
prepareStatement( CHARA_MONSTERNOTE_SEL, "SELECT Category_0, Category_1, Category_2, "
"Category_3, Category_4, Category_5, "
"Category_6, Category_7, Category_8, "
"Category_9, Category_10, Category_11 FROM charamonsternote "
"WHERE CharacterId = ?;",
CONNECTION_SYNC );
/// ZONE QUERIES
prepareStatement( ZONE_SEL_BNPCTEMPLATES,
"SELECT Id, Name, bNPCBaseId, bNPCNameId, mainWeaponModel, "

View file

@ -78,6 +78,7 @@ namespace Sapphire::Db
CHARA_MONSTERNOTE_INS,
CHARA_MONSTERNOTE_UP,
CHARA_MONSTERNOTE_SEL,
ZONE_SEL_BNPCTEMPLATES,
ZONE_SEL_SPAWNGROUPS,

View file

@ -8,6 +8,7 @@
#include <set>
#include <map>
#include <queue>
#include <array>
namespace Sapphire::Entity
{
@ -66,7 +67,7 @@ namespace Sapphire::Entity
} m_baseStats;
// array for bonuses, 80 to have some spare room.
uint32_t m_bonusStats[ 80 ];
std::array< uint32_t, 80 > m_bonusStats;
protected:
char m_name[34];

View file

@ -1976,3 +1976,9 @@ void Sapphire::Entity::Player::sendLandFlagsSlot( Common::LandFlagsSlot slot )
queuePacket( landFlags );
}
Sapphire::Common::HuntingLogEntry& Sapphire::Entity::Player::getHuntingLogEntry( uint8_t index )
{
assert( index < m_huntingLogEntries.size() );
return m_huntingLogEntries[ index ];
}

View file

@ -11,6 +11,7 @@
#include "Event/EventHandler.h"
#include <map>
#include <queue>
#include <array>
namespace Sapphire::Entity
{
@ -705,6 +706,9 @@ namespace Sapphire::Entity
/*! load search info */
bool loadSearchInfo();
/*! load hunting log entries */
bool loadHuntingLog();
// Player Network Handling
//////////////////////////////////////////////////////////////////////////////////////////////////////
/*! send current models ( equipment ) */
@ -960,6 +964,7 @@ namespace Sapphire::Entity
Sapphire::ItemPtr dropInventoryItem( Common::InventoryType type, uint16_t slotId );
Common::HuntingLogEntry& getHuntingLogEntry( uint8_t index );
//////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1092,6 +1097,8 @@ namespace Sapphire::Entity
Util::SpawnIndexAllocator< uint8_t > m_objSpawnIndexAllocator;
Util::SpawnIndexAllocator< uint8_t > m_actorSpawnIndexAllocator;
std::array< Common::HuntingLogEntry, 12 > m_huntingLogEntries;
};
}

View file

@ -205,7 +205,7 @@ bool Sapphire::Entity::Player::load( uint32_t charId, World::SessionPtr pSession
m_pCell = nullptr;
if( !loadActiveQuests() || !loadClassData() || !loadSearchInfo() )
if( !loadActiveQuests() || !loadClassData() || !loadSearchInfo() || loadHuntingLog() )
Logger::error( "Player #{0} data corrupt!", char_id_str );
m_maxHp = getMaxHp();
@ -334,6 +334,26 @@ bool Sapphire::Entity::Player::loadSearchInfo()
}
bool Sapphire::Entity::Player::loadHuntingLog()
{
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
auto stmt = pDb->getPreparedStatement( Db::ZoneDbStatements::CHARA_MONSTERNOTE_SEL );
stmt->setUInt( 1, m_id );
auto res = pDb->query( stmt );
if( !res->next() )
return false;
for( auto i = 0; i < 12; ++i )
{
std::string catStr = fmt::format( "Category_{}", i );
auto cat = res->getBlobVector( catStr );
m_huntingLogEntries[i].rank = cat[0];
memcpy( reinterpret_cast< char* >( m_huntingLogEntries[i].entries ), cat.data() + 1, cat.size() - 1 );
}
return true;
}
void Sapphire::Entity::Player::updateSql()
{
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();