From 40a0455c9e7313db5f7f23f94f1c8468fd00abb5 Mon Sep 17 00:00:00 2001 From: Matthe815 Date: Fri, 6 Jan 2023 23:40:31 -0500 Subject: [PATCH] fix: Fixed oversight where currency record not inserting --- src/api/PlayerMinimal.cpp | 9 ++++++++- src/api/PlayerMinimal.h | 2 ++ src/common/Database/ZoneDbConnection.cpp | 4 ++++ src/common/Database/ZoneDbConnection.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/api/PlayerMinimal.cpp b/src/api/PlayerMinimal.cpp index 023a2e0a..cf8e989b 100644 --- a/src/api/PlayerMinimal.cpp +++ b/src/api/PlayerMinimal.cpp @@ -309,7 +309,7 @@ void PlayerMinimal::saveAsNew() createInvDbContainer( InventoryType::ArmoryMain ); createInvDbContainer( InventoryType::ArmorySoulCrystal ); - createInvDbContainer( InventoryType::Currency ); + createCurrencyDbContainer(); createInvDbContainer( InventoryType::Crystal ); auto stmtMonsterNote = g_charaDb.getPreparedStatement( Db::ZoneDbStatements::CHARA_MONSTERNOTE_INS ); @@ -453,6 +453,13 @@ void PlayerMinimal::createInvDbContainer( uint16_t slot ) const g_charaDb.directExecute( stmtCreateInv ); } +void PlayerMinimal::createCurrencyDbContainer() const +{ + auto stmtCreateInv = g_charaDb.getPreparedStatement( Db::CHARA_CURRENCYINV_INS ); + stmtCreateInv->setUInt64( 1, m_characterId ); + g_charaDb.directExecute( stmtCreateInv ); +} + uint64_t PlayerMinimal::getNextUId64() const { g_charaDb.directExecute( std::string( "INSERT INTO uniqueiddata( IdName ) VALUES( 'NOT_SET' );" ) ); diff --git a/src/api/PlayerMinimal.h b/src/api/PlayerMinimal.h index 923059bb..8023acbd 100644 --- a/src/api/PlayerMinimal.h +++ b/src/api/PlayerMinimal.h @@ -159,6 +159,8 @@ namespace Sapphire::Api void createInvDbContainer( uint16_t slot ) const; + void createCurrencyDbContainer() const; + uint32_t m_modelEquip[10]; uint64_t getNextUId64() const; diff --git a/src/common/Database/ZoneDbConnection.cpp b/src/common/Database/ZoneDbConnection.cpp index 3fe57e69..0cf393a3 100644 --- a/src/common/Database/ZoneDbConnection.cpp +++ b/src/common/Database/ZoneDbConnection.cpp @@ -176,6 +176,10 @@ void Sapphire::Db::ZoneDbConnection::doPrepareStatements() "INSERT INTO charaiteminventory ( CharacterId, storageId, UPDATE_DATE ) VALUES ( ?, ?, NOW() );", CONNECTION_BOTH ); + prepareStatement( CHARA_CURRENCYINV_INS, + "INSERT INTO charaitemcurrency ( CharacterId, storageId, idx, UPDATE_DATE ) VALUES ( ?, 2000, 2, NOW() );", + CONNECTION_BOTH ); + /// ITEM GLOBAL prepareStatement( CHARA_ITEMGLOBAL_INS, "INSERT INTO charaglobalitem ( CharacterId, ItemId, catalogId, stack, UPDATE_DATE ) VALUES ( ?, ?, ?, ?, NOW() );", diff --git a/src/common/Database/ZoneDbConnection.h b/src/common/Database/ZoneDbConnection.h index 7a1c3b41..291454a8 100644 --- a/src/common/Database/ZoneDbConnection.h +++ b/src/common/Database/ZoneDbConnection.h @@ -70,6 +70,7 @@ namespace Sapphire::Db CHARA_CLASS_DEL, CHARA_ITEMINV_INS, + CHARA_CURRENCYINV_INS, CHARA_ITEMGLOBAL_SELECT, CHARA_ITEMGLOBAL_INS,