mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-24 13:47:46 +00:00
use prepared statement for item loading, network item stain
This commit is contained in:
parent
35a7db9f54
commit
1c8ca42d6c
6 changed files with 36 additions and 6 deletions
|
@ -175,6 +175,12 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements()
|
||||||
"INSERT INTO charaglobalitem ( CharacterId, ItemId, catalogId, stack, UPDATE_DATE ) VALUES ( ?, ?, ?, ?, NOW() );",
|
"INSERT INTO charaglobalitem ( CharacterId, ItemId, catalogId, stack, UPDATE_DATE ) VALUES ( ?, ?, ?, ?, NOW() );",
|
||||||
CONNECTION_SYNC );
|
CONNECTION_SYNC );
|
||||||
|
|
||||||
|
prepareStatement( CHARA_ITEMGLOBAL_SELECT,
|
||||||
|
"SELECT catalogId, stack, reservedFlag, signatureId, flags, durability, refine, materia_0, materia_1, "
|
||||||
|
"materia_2, materia_3, materia_4, stain, pattern, buffer_0, buffer_1, buffer_2, buffer_3, buffer_4 "
|
||||||
|
"FROM charaglobalitem WHERE itemId = ?",
|
||||||
|
CONNECTION_SYNC );
|
||||||
|
|
||||||
/// CHARA MONSTERNOTE
|
/// CHARA MONSTERNOTE
|
||||||
prepareStatement( CHARA_MONSTERNOTE_INS,
|
prepareStatement( CHARA_MONSTERNOTE_INS,
|
||||||
"INSERT INTO charamonsternote ( CharacterId, Category_0, Category_1, Category_2,"
|
"INSERT INTO charamonsternote ( CharacterId, Category_0, Category_1, Category_2,"
|
||||||
|
|
|
@ -72,6 +72,7 @@ namespace Sapphire::Db
|
||||||
|
|
||||||
CHARA_ITEMINV_INS,
|
CHARA_ITEMINV_INS,
|
||||||
|
|
||||||
|
CHARA_ITEMGLOBAL_SELECT,
|
||||||
CHARA_ITEMGLOBAL_INS,
|
CHARA_ITEMGLOBAL_INS,
|
||||||
CHARA_ITEMGLOBAL_UP,
|
CHARA_ITEMGLOBAL_UP,
|
||||||
CHARA_ITEMGLOBAL_DELETE,
|
CHARA_ITEMGLOBAL_DELETE,
|
||||||
|
|
|
@ -151,17 +151,25 @@ void Sapphire::Entity::Player::updateModels( GearSetSlot equipSlotId, const Sapp
|
||||||
{
|
{
|
||||||
uint64_t model = pItem->getModelId1();
|
uint64_t model = pItem->getModelId1();
|
||||||
uint64_t model2 = pItem->getModelId2();
|
uint64_t model2 = pItem->getModelId2();
|
||||||
|
uint64_t stain = pItem->getStain();
|
||||||
|
|
||||||
switch( equipSlotId )
|
switch( equipSlotId )
|
||||||
{
|
{
|
||||||
case MainHand:
|
case MainHand:
|
||||||
m_modelMainWeapon = model;
|
m_modelMainWeapon = model | ( stain << 48 );
|
||||||
|
|
||||||
m_modelSubWeapon = model2;
|
m_modelSubWeapon = model2;
|
||||||
|
|
||||||
|
if( m_modelSubWeapon > 0 )
|
||||||
|
{
|
||||||
|
m_modelSubWeapon = m_modelSubWeapon | ( stain << 48 );
|
||||||
|
}
|
||||||
|
|
||||||
equipWeapon( pItem, updateClass );
|
equipWeapon( pItem, updateClass );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OffHand:
|
case OffHand:
|
||||||
m_modelSubWeapon = model;
|
m_modelSubWeapon = model | ( stain << 48 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SoulCrystal:
|
case SoulCrystal:
|
||||||
|
@ -175,6 +183,8 @@ void Sapphire::Entity::Player::updateModels( GearSetSlot equipSlotId, const Sapp
|
||||||
auto modelSlot = equipSlotToModelSlot( equipSlotId );
|
auto modelSlot = equipSlotToModelSlot( equipSlotId );
|
||||||
if( modelSlot == GearModelSlot::ModelInvalid )
|
if( modelSlot == GearModelSlot::ModelInvalid )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
model = model | stain << 24;
|
||||||
m_modelEquip[ static_cast< uint8_t >( modelSlot ) ] = static_cast< uint32_t >( model );
|
m_modelEquip[ static_cast< uint8_t >( modelSlot ) ] = static_cast< uint32_t >( model );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,10 @@ bool Sapphire::Entity::Player::loadSearchInfo()
|
||||||
auto res = pDb->query( stmt );
|
auto res = pDb->query( stmt );
|
||||||
|
|
||||||
if( !res->next() )
|
if( !res->next() )
|
||||||
|
{
|
||||||
|
Logger::error( "Failed to load search info for character#{}", m_id );
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_searchSelectClass = res->getUInt8( 2 );
|
m_searchSelectClass = res->getUInt8( 2 );
|
||||||
m_searchSelectRegion = res->getUInt8( 3 );
|
m_searchSelectRegion = res->getUInt8( 3 );
|
||||||
|
@ -343,7 +346,10 @@ bool Sapphire::Entity::Player::loadHuntingLog()
|
||||||
auto res = pDb->query( stmt );
|
auto res = pDb->query( stmt );
|
||||||
|
|
||||||
if( !res->next() )
|
if( !res->next() )
|
||||||
|
{
|
||||||
|
Logger::error( "Failed to load hunting log data for character#{}", m_id );
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for( auto i = 0; i < 12; ++i )
|
for( auto i = 0; i < 12; ++i )
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,9 +124,14 @@ Sapphire::ItemPtr Sapphire::World::Manager::ItemMgr::loadItem( uint64_t uId )
|
||||||
{
|
{
|
||||||
auto pExdData = framework()->get< Data::ExdDataGenerated >();
|
auto pExdData = framework()->get< Data::ExdDataGenerated >();
|
||||||
auto pDb = framework()->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
auto pDb = framework()->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||||
// load actual item
|
|
||||||
auto itemRes = pDb->query(
|
// 1 catalogId, 2 stack, 3 reservedFlag, 4 signatureId, 5 flags, 6 durability, 7 refine, 8 materia_0, 9 materia_1,
|
||||||
"SELECT catalogId, stack, flags FROM charaglobalitem WHERE itemId = " + std::to_string( uId ) + ";" );
|
// 10 materia_2, 11 materia_3, 12 materia_4, 13 stain, 14 pattern, 15 buffer_0, 16 buffer_1, 17 buffer_2,
|
||||||
|
// 18 buffer_3, 19 buffer_4
|
||||||
|
auto query = pDb->getPreparedStatement( Db::CHARA_ITEMGLOBAL_SELECT );
|
||||||
|
query->setUInt64( 1, uId );
|
||||||
|
|
||||||
|
auto itemRes = pDb->query( query );
|
||||||
if( !itemRes->next() )
|
if( !itemRes->next() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -141,6 +146,8 @@ Sapphire::ItemPtr Sapphire::World::Manager::ItemMgr::loadItem( uint64_t uId )
|
||||||
isHq );
|
isHq );
|
||||||
|
|
||||||
pItem->setStackSize( itemRes->getUInt( 2 ) );
|
pItem->setStackSize( itemRes->getUInt( 2 ) );
|
||||||
|
pItem->setStain( itemRes->getUInt16( 13 ) );
|
||||||
|
pItem->setDurability( itemRes->getInt16( 6 ) );
|
||||||
|
|
||||||
return pItem;
|
return pItem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace Sapphire::Network::Packets::Server
|
||||||
|
|
||||||
auto item = player.getItemAt( Common::GearSet0, Common::GearSetSlot::MainHand );
|
auto item = player.getItemAt( Common::GearSet0, Common::GearSetSlot::MainHand );
|
||||||
if( item )
|
if( item )
|
||||||
m_data.mainWeaponModel = item->getModelId1();
|
m_data.mainWeaponModel = player.getModelMainWeapon();
|
||||||
m_data.secWeaponModel = player.getModelSubWeapon();
|
m_data.secWeaponModel = player.getModelSubWeapon();
|
||||||
|
|
||||||
m_data.models[ Common::GearModelSlot::ModelHead ] = player.getModelForSlot( Common::GearModelSlot::ModelHead );
|
m_data.models[ Common::GearModelSlot::ModelHead ] = player.getModelForSlot( Common::GearModelSlot::ModelHead );
|
||||||
|
|
Loading…
Add table
Reference in a new issue