1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 08:27:46 +00:00

Fix for quest sql operations

This commit is contained in:
Mordred 2017-10-15 23:16:28 +02:00
parent a4dfc28129
commit e934528f48
4 changed files with 19 additions and 11 deletions

View file

@ -110,7 +110,7 @@ void Core::Db::CharaDbConnection::doPrepareStatements()
prepareStatement( CHARA_SEARCHINFO_UP_SEARCHCOMMENT, "UPDATE charainfosearch SET SearchComment = ? WHERE CharacterId = ?;", CONNECTION_ASYNC ); prepareStatement( CHARA_SEARCHINFO_UP_SEARCHCOMMENT, "UPDATE charainfosearch SET SearchComment = ? WHERE CharacterId = ?;", CONNECTION_ASYNC );
/// QUEST /// 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_1, Variables_2, Variables_3, Variables_4, "
"Variables_5, Variables_6 ) VALUES( ?,?,?,?,?,?,?,?,?,?,?,? );", CONNECTION_ASYNC ); "Variables_5, Variables_6 ) VALUES( ?,?,?,?,?,?,?,?,?,?,?,? );", CONNECTION_ASYNC );

View file

@ -616,7 +616,6 @@ private:
std::map< uint32_t, uint8_t > m_actorIdTohateSlotMap; 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< 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::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]; boost::shared_ptr< Common::QuestActive > m_activeQuests[30];
int16_t m_questTracking[5]; int16_t m_questTracking[5];
uint8_t m_stateFlags[7]; uint8_t m_stateFlags[7];

View file

@ -66,7 +66,6 @@ void Core::Entity::Player::removeQuest( uint16_t questId )
boost::shared_ptr<QuestActive> pQuest = m_activeQuests[idx]; boost::shared_ptr<QuestActive> pQuest = m_activeQuests[idx];
m_activeQuests[idx].reset(); m_activeQuests[idx].reset();
m_freeQuestIdxQueue.push( idx );
m_questIdToQuestIdx.erase( questId ); m_questIdToQuestIdx.erase( questId );
m_questIdxToQuestId.erase( idx ); m_questIdxToQuestId.erase( idx );
@ -866,7 +865,7 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence )
if( hasQuest( questId ) ) if( hasQuest( questId ) )
{ {
int16_t index = getQuestIndex( questId ); uint8_t index = getQuestIndex( questId );
auto pNewQuest = m_activeQuests[index]; auto pNewQuest = m_activeQuests[index];
GamePacketNew< FFXIVIpcQuestUpdate, ServerZoneIpcType > pe_qa( getId() ); GamePacketNew< FFXIVIpcQuestUpdate, ServerZoneIpcType > pe_qa( getId() );
pNewQuest->c.sequence = sequence; pNewQuest->c.sequence = sequence;
@ -878,10 +877,17 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint8_t sequence )
else else
{ {
uint8_t idx = m_freeQuestIdxQueue.front(); uint8_t idx = 0;
m_freeQuestIdxQueue.pop(); bool hasFreeSlot = false;
for( ; idx < 30; idx++ )
if( !m_activeQuests[idx] )
{
hasFreeSlot = true;
break;
}
if( !hasFreeSlot )
return;
boost::shared_ptr< QuestActive > pNewQuest( new QuestActive() ); boost::shared_ptr< QuestActive > pNewQuest( new QuestActive() );
pNewQuest->c.questId = questId; pNewQuest->c.questId = questId;

View file

@ -17,6 +17,7 @@
#include <Server_Common/Database/CharaDbConnection.h> #include <Server_Common/Database/CharaDbConnection.h>
#include <Server_Common/Database/DbWorkerPool.h> #include <Server_Common/Database/DbWorkerPool.h>
#include <Server_Common/Database/PreparedStatement.h> #include <Server_Common/Database/PreparedStatement.h>
#include <servers/Server_Common/Common.h>
#include "Player.h" #include "Player.h"
@ -215,7 +216,7 @@ bool Core::Entity::Player::loadActiveQuests()
while( res->next() ) 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.questId = res->getUInt16( 3 );
@ -440,6 +441,7 @@ void Core::Entity::Player::updateSql()
void Core::Entity::Player::updateAllQuests() const void Core::Entity::Player::updateAllQuests() const
{ {
for( int32_t i = 0; i < 30; i++ ) for( int32_t i = 0; i < 30; i++ )
{ {
if( m_activeQuests[i] != nullptr ) 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( 6, m_activeQuests[i]->c.UI8D );
stmtS3->setInt( 7, m_activeQuests[i]->c.UI8E ); stmtS3->setInt( 7, m_activeQuests[i]->c.UI8E );
stmtS3->setInt( 8, m_activeQuests[i]->c.UI8F ); stmtS3->setInt( 8, m_activeQuests[i]->c.UI8F );
stmtS3->setInt( 9, m_id); stmtS3->setInt( 9, m_activeQuests[i]->c.padding1 );
stmtS3->setInt( 10, m_activeQuests[i]->c.questId ); stmtS3->setInt( 10, m_id);
stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
g_charaDb.execute( stmtS3 ); g_charaDb.execute( stmtS3 );
} }
} }