mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 16:37:45 +00:00
Fix for quest sql operations
This commit is contained in:
parent
df9ff71e1b
commit
c23d401aa5
4 changed files with 19 additions and 11 deletions
|
@ -110,7 +110,7 @@ void Core::Db::CharaDbConnection::doPrepareStatements()
|
|||
prepareStatement( CHARA_SEARCHINFO_UP_SEARCHCOMMENT, "UPDATE charainfosearch SET SearchComment = ? WHERE CharacterId = ?;", CONNECTION_ASYNC );
|
||||
|
||||
/// QUEST
|
||||
prepareStatement( CHARA_QUEST_INS, "INSERT INTO charaquestnew ( CharacterId, SlotId, QuestId, Sequence, Flags, Variables_0 "
|
||||
prepareStatement( CHARA_QUEST_INS, "INSERT INTO charaquestnew ( CharacterId, SlotId, QuestId, Sequence, Flags, Variables_0, "
|
||||
"Variables_1, Variables_2, Variables_3, Variables_4, "
|
||||
"Variables_5, Variables_6 ) VALUES( ?,?,?,?,?,?,?,?,?,?,?,? );", CONNECTION_ASYNC );
|
||||
|
||||
|
|
|
@ -616,7 +616,6 @@ private:
|
|||
std::map< uint32_t, uint8_t > m_actorIdTohateSlotMap;
|
||||
std::map< uint32_t, uint8_t > m_questIdToQuestIdx; // quest mapping, quest id to quest container index
|
||||
std::map< uint8_t, uint32_t > m_questIdxToQuestId; // quest mapping, quest container index to questId
|
||||
std::queue< uint8_t > m_freeQuestIdxQueue; // queue with quest indices free to be assigned
|
||||
boost::shared_ptr< Common::QuestActive > m_activeQuests[30];
|
||||
int16_t m_questTracking[5];
|
||||
uint8_t m_stateFlags[7];
|
||||
|
|
|
@ -66,7 +66,6 @@ void Core::Entity::Player::removeQuest( uint16_t questId )
|
|||
boost::shared_ptr<QuestActive> pQuest = m_activeQuests[idx];
|
||||
m_activeQuests[idx].reset();
|
||||
|
||||
m_freeQuestIdxQueue.push( idx );
|
||||
m_questIdToQuestIdx.erase( questId );
|
||||
m_questIdxToQuestId.erase( idx );
|
||||
|
||||
|
@ -866,7 +865,7 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence )
|
|||
if( hasQuest( questId ) )
|
||||
{
|
||||
|
||||
int16_t index = getQuestIndex( questId );
|
||||
uint8_t index = getQuestIndex( questId );
|
||||
auto pNewQuest = m_activeQuests[index];
|
||||
GamePacketNew< FFXIVIpcQuestUpdate, ServerZoneIpcType > pe_qa( getId() );
|
||||
pNewQuest->c.sequence = sequence;
|
||||
|
@ -878,10 +877,17 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence )
|
|||
else
|
||||
{
|
||||
|
||||
uint8_t idx = m_freeQuestIdxQueue.front();
|
||||
m_freeQuestIdxQueue.pop();
|
||||
|
||||
uint8_t idx = 0;
|
||||
bool hasFreeSlot = false;
|
||||
for( ; idx < 30; idx++ )
|
||||
if( !m_activeQuests[idx] )
|
||||
{
|
||||
hasFreeSlot = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if( !hasFreeSlot )
|
||||
return;
|
||||
|
||||
boost::shared_ptr< QuestActive > pNewQuest( new QuestActive() );
|
||||
pNewQuest->c.questId = questId;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <Server_Common/Database/CharaDbConnection.h>
|
||||
#include <Server_Common/Database/DbWorkerPool.h>
|
||||
#include <Server_Common/Database/PreparedStatement.h>
|
||||
#include <servers/Server_Common/Common.h>
|
||||
|
||||
#include "Player.h"
|
||||
|
||||
|
@ -215,9 +216,9 @@ bool Core::Entity::Player::loadActiveQuests()
|
|||
while( res->next() )
|
||||
{
|
||||
|
||||
auto slotId = res->getUInt8( 1 );
|
||||
auto slotId = res->getUInt8( 2 );
|
||||
|
||||
boost::shared_ptr<QuestActive> pActiveQuest( new QuestActive() );
|
||||
boost::shared_ptr< QuestActive > pActiveQuest( new QuestActive() );
|
||||
pActiveQuest->c.questId = res->getUInt16( 3 );
|
||||
pActiveQuest->c.sequence = res->getUInt8( 4 );
|
||||
pActiveQuest->c.flags = res->getUInt8( 5 );
|
||||
|
@ -440,6 +441,7 @@ void Core::Entity::Player::updateSql()
|
|||
|
||||
void Core::Entity::Player::updateAllQuests() const
|
||||
{
|
||||
|
||||
for( int32_t i = 0; i < 30; i++ )
|
||||
{
|
||||
if( m_activeQuests[i] != nullptr )
|
||||
|
@ -453,8 +455,9 @@ void Core::Entity::Player::updateAllQuests() const
|
|||
stmtS3->setInt( 6, m_activeQuests[i]->c.UI8D );
|
||||
stmtS3->setInt( 7, m_activeQuests[i]->c.UI8E );
|
||||
stmtS3->setInt( 8, m_activeQuests[i]->c.UI8F );
|
||||
stmtS3->setInt( 9, m_id);
|
||||
stmtS3->setInt( 10, m_activeQuests[i]->c.questId );
|
||||
stmtS3->setInt( 9, m_activeQuests[i]->c.padding1 );
|
||||
stmtS3->setInt( 10, m_id);
|
||||
stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
|
||||
g_charaDb.execute( stmtS3 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue