1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-04 09:47:46 +00:00

More sql updates and conversions

This commit is contained in:
Mordred 2017-10-18 20:49:37 +02:00
parent de90cea796
commit e246c0a880
7 changed files with 84 additions and 157 deletions

View file

@ -13,62 +13,10 @@
-- Dumping structure for table sapphire.characlass -- Dumping structure for table sapphire.characlass
CREATE TABLE IF NOT EXISTS `characlass` ( CREATE TABLE IF NOT EXISTS `characlass` (
`Lv_0` int(5) DEFAULT '0',
`Exp_0` int(10) DEFAULT '0',
`Lv_1` int(5) DEFAULT '0',
`Exp_1` int(10) DEFAULT '0',
`Lv_2` int(5) DEFAULT '0',
`Exp_2` int(10) DEFAULT '0',
`Lv_3` int(5) DEFAULT '0',
`Exp_3` int(10) DEFAULT '0',
`Lv_4` int(5) DEFAULT '0',
`Exp_4` int(10) DEFAULT '0',
`Lv_5` int(5) DEFAULT '0',
`Exp_5` int(10) DEFAULT '0',
`Lv_6` int(5) DEFAULT '0',
`Exp_6` int(10) DEFAULT '0',
`Lv_7` int(5) DEFAULT '0',
`Exp_7` int(10) DEFAULT '0',
`Lv_8` int(5) DEFAULT '0',
`Exp_8` int(10) DEFAULT '0',
`Lv_9` int(5) DEFAULT '0',
`Exp_9` int(10) DEFAULT '0',
`Lv_10` int(5) DEFAULT '0',
`Exp_10` int(10) DEFAULT '0',
`Lv_11` int(5) DEFAULT '0',
`Exp_11` int(10) DEFAULT '0',
`Lv_12` int(5) DEFAULT '0',
`Exp_12` int(10) DEFAULT '0',
`Lv_13` int(5) DEFAULT '0',
`Exp_13` int(10) DEFAULT '0',
`Lv_14` int(5) DEFAULT '0',
`Exp_14` int(10) DEFAULT '0',
`Lv_15` int(5) DEFAULT '0',
`Exp_15` int(10) DEFAULT '0',
`Lv_16` int(5) DEFAULT '0',
`Exp_16` int(10) DEFAULT '0',
`Lv_17` int(5) DEFAULT '0',
`Exp_17` int(10) DEFAULT '0',
`Lv_18` int(5) DEFAULT '0',
`Exp_18` int(10) DEFAULT '0',
`Lv_19` int(5) NOT NULL DEFAULT '0',
`Exp_19` int(10) NOT NULL DEFAULT '0',
`Lv_20` int(5) NOT NULL DEFAULT '0',
`Exp_20` int(10) NOT NULL DEFAULT '0',
`Lv_21` int(5) NOT NULL DEFAULT '0',
`Exp_21` int(10) NOT NULL DEFAULT '0',
`Lv_22` int(5) NOT NULL DEFAULT '0',
`Exp_22` int(10) NOT NULL DEFAULT '0',
`Lv_23` int(5) DEFAULT '0',
`Exp_23` int(10) DEFAULT '0',
`Lv_24` int(5) NOT NULL DEFAULT '0',
`Exp_24` int(10) NOT NULL DEFAULT '0',
`Lv_25` int(5) NOT NULL DEFAULT '0',
`Exp_25` int(19) NOT NULL DEFAULT '0',
`CharacterId` int(20) NOT NULL DEFAULT '0', `CharacterId` int(20) NOT NULL DEFAULT '0',
`IS_DELETE` int(3) DEFAULT '0', `ClassIdx` int(3) DEFAULT '0',
`IS_NOT_ACTIVE_FLG` int(3) DEFAULT '0', `Exp` int(10) DEFAULT '0',
`UPDATE_DATE` datetime DEFAULT NULL, `Lvl` int(5) DEFAULT '0',
PRIMARY KEY (`CharacterId`) PRIMARY KEY (`CharacterId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View file

@ -10,10 +10,6 @@
-- ADD `container_33` INT(20) NOT NULL AFTER `container_32`, -- ADD `container_33` INT(20) NOT NULL AFTER `container_32`,
-- ADD `container_34` INT(20) NOT NULL AFTER `container_33`; -- ADD `container_34` INT(20) NOT NULL AFTER `container_33`;
-- --
-- ALTER TABLE `characlass` ADD `Lv_24` INT(5) NOT NULL DEFAULT '0' AFTER `Exp_23`,
-- ADD `Exp_24` INT(10) NOT NULL DEFAULT '0' AFTER `Lv_24`,
-- ADD `Lv_25` INT(5) NOT NULL DEFAULT '0' AFTER `Exp_24`,
-- ADD `Exp_25` INT(19) NOT NULL DEFAULT '0' AFTER `Lv_25`;
-- ------------------------------------------- -- -------------------------------------------
-- update.sql Before Merge into Other SQL's 30/08/2017 -- update.sql Before Merge into Other SQL's 30/08/2017
-- ------------------------------------------- -- -------------------------------------------

View file

@ -51,10 +51,6 @@ void Core::Db::CharaDbConnection::doPrepareStatements()
"Class, ContentId, BirthDay, BirthMonth " "Class, ContentId, BirthDay, BirthMonth "
"FROM charainfo WHERE CharacterId = ?;", CONNECTION_SYNC ); "FROM charainfo WHERE CharacterId = ?;", CONNECTION_SYNC );
prepareStatement( CHARA_CLASSINFO_SEL_LOAD, "SELECT * FROM characlass WHERE CharacterId = ?;", CONNECTION_SYNC );
prepareStatement( CHARA_SEARCHINFO_SEL_LOAD, "SELECT * FROM charainfosearch WHERE CharacterId = ?;", CONNECTION_SYNC );
prepareStatement( CHARA_QUESTINFO_SEL_LOAD, "SELECT * FROM charaquestnew WHERE CharacterId = ?;", CONNECTION_SYNC );
prepareStatement( CHARA_INS, "INSERT INTO charainfo (AccountId, CharacterId, ContentId, Name, Hp, Mp, " prepareStatement( CHARA_INS, "INSERT INTO charainfo (AccountId, CharacterId, ContentId, Name, Hp, Mp, "
"Customize, Voice, IsNewGame, TerritoryId, PosX, PosY, PosZ, PosR, ModelEquip, " "Customize, Voice, IsNewGame, TerritoryId, PosX, PosY, PosZ, PosR, ModelEquip, "
"IsNewAdventurer, GuardianDeity, Birthday, BirthMonth, Class, Status, FirstClass, " "IsNewAdventurer, GuardianDeity, Birthday, BirthMonth, Class, Status, FirstClass, "
@ -104,12 +100,13 @@ void Core::Db::CharaDbConnection::doPrepareStatements()
prepareStatement( CHARA_UP_UNLOCKS, "UPDATE charainfo SET Unlocks = ? WHERE CharacterId = ?;", CONNECTION_ASYNC ); prepareStatement( CHARA_UP_UNLOCKS, "UPDATE charainfo SET Unlocks = ? WHERE CharacterId = ?;", CONNECTION_ASYNC );
prepareStatement( CHARA_UP_CFPENATLY, "UPDATE charainfo SET CFPenaltyUntil = ? WHERE CharacterId = ?;", CONNECTION_ASYNC ); prepareStatement( CHARA_UP_CFPENATLY, "UPDATE charainfo SET CFPenaltyUntil = ? WHERE CharacterId = ?;", CONNECTION_ASYNC );
/// SEARCHINFO /// SEARCH INFO
prepareStatement( CHARA_SEARCHINFO_UP_SELECTCLASS, "UPDATE charainfosearch SET SelectClassId = ? WHERE CharacterId = ?;", CONNECTION_ASYNC ); prepareStatement( CHARA_SEARCHINFO_UP_SELECTCLASS, "UPDATE charainfosearch SET SelectClassId = ? WHERE CharacterId = ?;", CONNECTION_ASYNC );
prepareStatement( CHARA_SEARCHINFO_UP_SELECTREGION, "UPDATE charainfosearch SET SelectRegion = ? WHERE CharacterId = ?;", CONNECTION_ASYNC ); prepareStatement( CHARA_SEARCHINFO_UP_SELECTREGION, "UPDATE charainfosearch SET SelectRegion = ? WHERE CharacterId = ?;", CONNECTION_ASYNC );
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 );
prepareStatement( CHARA_SEARCHINFO_SEL, "SELECT * FROM charainfosearch WHERE CharacterId = ?;", CONNECTION_SYNC );
/// QUEST /// QUEST INFO
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 );
@ -121,6 +118,15 @@ void Core::Db::CharaDbConnection::doPrepareStatements()
prepareStatement( CHARA_QUEST_DEL, "DELETE FROM charaquestnew WHERE CharacterId = ? AND QuestId = ?;", CONNECTION_ASYNC ); prepareStatement( CHARA_QUEST_DEL, "DELETE FROM charaquestnew WHERE CharacterId = ? AND QuestId = ?;", CONNECTION_ASYNC );
prepareStatement( CHARA_QUEST_SEL, "SELECT * FROM charaquestnew WHERE CharacterId = ?;", CONNECTION_SYNC );
/// CLASS INFO
prepareStatement( CHARA_CLASS_SEL, "SELECT ClassIdx, Exp, Lvl FROM characlass WHERE CharacterId = ?;", CONNECTION_SYNC );
prepareStatement( CHARA_CLASS_INS, "INSERT INTO characlass ( CharacterId, ClassIdx, Exp, Lvl ) VALUES( ?,?,?,?);", CONNECTION_ASYNC );
prepareStatement( CHARA_CLASS_UP, "UPDATE characlass SET Exp = ?, SET Lvl = ? ) WHERE CharacterId = ? AND ClassIdx = ?;", CONNECTION_ASYNC );
prepareStatement( CHARA_CLASS_DEL, "DELETE FROM characlass WHERE CharacterId = ?;", CONNECTION_ASYNC );

View file

@ -13,9 +13,8 @@ enum CharaDbStatements : uint32_t
{ {
CHARA_SEL, CHARA_SEL,
CHARA_SEL_MINIMAL, CHARA_SEL_MINIMAL,
CHARA_CLASSINFO_SEL_LOAD, CHARA_SEARCHINFO_SEL,
CHARA_SEARCHINFO_SEL_LOAD, CHARA_QUEST_SEL,
CHARA_QUESTINFO_SEL_LOAD,
CHARA_INS, CHARA_INS,
CHARA_UP, CHARA_UP,
CHARA_UP_NAME, CHARA_UP_NAME,
@ -66,6 +65,11 @@ enum CharaDbStatements : uint32_t
CHARA_QUEST_UP, CHARA_QUEST_UP,
CHARA_QUEST_DEL, CHARA_QUEST_DEL,
CHARA_CLASS_SEL,
CHARA_CLASS_INS,
CHARA_CLASS_UP,
CHARA_CLASS_DEL,
MAX_STATEMENTS MAX_STATEMENTS
}; };

View file

@ -190,9 +190,8 @@ void Core::Network::SapphireAPI::deleteCharacter( std::string name, uint32_t acc
int32_t id = deletePlayer.getId(); int32_t id = deletePlayer.getId();
g_database.execute( "DELETE FROM charabase WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_database.execute( "DELETE FROM charainfo WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_database.execute( "DELETE FROM characlass WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_database.execute( "DELETE FROM characlass WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_database.execute( "DELETE FROM charadetail WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_database.execute( "DELETE FROM charaglobalitem WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_database.execute( "DELETE FROM charaglobalitem WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_database.execute( "DELETE FROM charainfoblacklist WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_database.execute( "DELETE FROM charainfoblacklist WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );
g_database.execute( "DELETE FROM charainfofriendlist WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_database.execute( "DELETE FROM charainfofriendlist WHERE CharacterId LIKE '" + std::to_string( id ) + "';" );

View file

@ -518,10 +518,11 @@ public:
// Database // Database
void updateAllQuests() const; void updateDbAllQuests() const;
void deleteQuest( uint16_t questId ) const; void deleteQuest( uint16_t questId ) const;
void insertQuest( uint16_t questId, uint8_t index, uint8_t seq ) const; void insertQuest( uint16_t questId, uint8_t index, uint8_t seq ) const;
void updateDbSearchInfo() const;
void updateDbClass() const;
private: private:
uint32_t m_lastWrite; uint32_t m_lastWrite;
@ -529,15 +530,12 @@ private:
bool m_bIsLogin; bool m_bIsLogin;
// ==== CHARABASE
uint64_t m_contentId; // This id will be the name of the folder for character settings in "My Games" uint64_t m_contentId; // This id will be the name of the folder for character settings in "My Games"
uint8_t m_mode; uint8_t m_mode;
private: private:
uint8_t m_mount;
uint8_t m_ignore;
uint8_t m_invincibleGM;
uint8_t m_voice; uint8_t m_voice;
uint64_t m_modelMainWeapon; uint64_t m_modelMainWeapon;
@ -546,31 +544,8 @@ private:
uint32_t m_modelEquip[10]; uint32_t m_modelEquip[10];
uint8_t m_emoteModeType;
// timestamp of first login
uint32_t m_firstLogin;
// id of initial language
uint32_t m_language;
bool m_bNewGame; bool m_bNewGame;
uint32_t m_primaryTerritoryType;
uint32_t m_primaryTerritoryId;
uint32_t m_primaryLayoutId;
uint32_t m_primaryExclusiveId;
uint32_t m_primaryMoveType;
uint32_t m_primaryContentId;
uint32_t m_secondaryTerritoryType;
uint32_t m_secondaryTerritoryId;
Common::FFXIVARR_POSITION3 m_secondaryPos;
float m_secondaryRot;
uint32_t m_secondaryLayoutId;
// !! END CHARABASE
// ==== CHARADETAIL
uint8_t m_guardianDeity; uint8_t m_guardianDeity;
uint8_t m_birthDay; uint8_t m_birthDay;
uint8_t m_birthMonth; uint8_t m_birthMonth;
@ -587,16 +562,13 @@ private:
uint16_t m_title; uint16_t m_title;
uint8_t m_titleList[48]; uint8_t m_titleList[48];
uint8_t m_achievement[16];
uint8_t m_howTo[33]; uint8_t m_howTo[33];
uint8_t m_minions[33]; uint8_t m_minions[33];
uint8_t m_mounts[13]; uint8_t m_mounts[13];
uint8_t m_homePoint; uint8_t m_homePoint;
uint8_t m_startTown; uint8_t m_startTown;
uint8_t m_favoritePoint[3];
uint16_t m_townWarpFstFlags; uint16_t m_townWarpFstFlags;
uint8_t m_questCompleteFlags[200]; uint8_t m_questCompleteFlags[200];
uint8_t m_chocoboTaxiStandFlags[8];
uint8_t m_discovery[420]; uint8_t m_discovery[420];
uint32_t m_playTime; uint32_t m_playTime;

View file

@ -208,7 +208,7 @@ bool Core::Entity::Player::load( uint32_t charId, Core::SessionPtr pSession )
bool Core::Entity::Player::loadActiveQuests() bool Core::Entity::Player::loadActiveQuests()
{ {
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_QUESTINFO_SEL_LOAD ); auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_QUEST_SEL );
stmt->setUInt( 1, m_id ); stmt->setUInt( 1, m_id );
auto res = g_charaDb.query( stmt ); auto res = g_charaDb.query( stmt );
@ -244,18 +244,19 @@ bool Core::Entity::Player::loadActiveQuests()
bool Core::Entity::Player::loadClassData() bool Core::Entity::Player::loadClassData()
{ {
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_CLASSINFO_SEL_LOAD ); // ClassIdx, Exp, Lvl
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_CLASS_SEL );
stmt->setUInt( 1, m_id ); stmt->setUInt( 1, m_id );
auto res = g_charaDb.query( stmt ); auto res = g_charaDb.query( stmt );
if( !res->next() ) while( res->next() )
return false;
for( uint8_t i = 0; i < 25; i++ )
{ {
uint8_t index = i * 2; auto index = res->getUInt16( 1 );
m_classArray[i] = res->getUInt16( index + 1 ); auto exp = res->getUInt( 2 );
m_expArray[i] = res->getUInt( index + 2 ); auto lvl = res->getUInt8( 3 );
m_classArray[index] = lvl;
m_expArray[index] = exp;
} }
return true; return true;
@ -263,7 +264,7 @@ bool Core::Entity::Player::loadClassData()
bool Core::Entity::Player::loadSearchInfo() bool Core::Entity::Player::loadSearchInfo()
{ {
auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_SEARCHINFO_SEL_LOAD ); auto stmt = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_SEARCHINFO_SEL );
stmt->setUInt( 1, m_id ); stmt->setUInt( 1, m_id );
auto res = g_charaDb.query( stmt ); auto res = g_charaDb.query( stmt );
@ -399,53 +400,54 @@ void Core::Entity::Player::updateSql()
g_charaDb.execute( stmt ); g_charaDb.execute( stmt );
////// Searchinfo ////// Searchinfo
auto stmtS = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_SEARCHINFO_UP_SELECTCLASS ); updateDbSearchInfo();
////// QUESTS
updateDbAllQuests();
////// Class
updateDbClass();
}
void Core::Entity::Player::updateDbClass() const
{
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx;
auto stmtS = g_charaDb.getPreparedStatement( Core::Db::CHARA_CLASS_UP );
stmtS->setInt( 1, getLevel() );
stmtS->setInt( 2, getExp() );
stmtS->setInt( 3, m_id );
stmtS->setInt( 4, classJobIndex );
g_charaDb.execute( stmtS );
}
void Core::Entity::Player::updateDbSearchInfo() const
{
auto stmtS = g_charaDb.getPreparedStatement( Core::Db::CHARA_SEARCHINFO_UP_SELECTCLASS );
stmtS->setInt( 1, m_searchSelectClass ); stmtS->setInt( 1, m_searchSelectClass );
stmtS->setInt( 2, m_id ); stmtS->setInt( 2, m_id );
g_charaDb.execute( stmtS ); g_charaDb.execute( stmtS );
auto stmtS1 = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_SEARCHINFO_UP_SELECTREGION ); auto stmtS1 = g_charaDb.getPreparedStatement( Core::Db::CHARA_SEARCHINFO_UP_SELECTREGION );
stmtS1->setInt( 1, m_searchSelectRegion ); stmtS1->setInt( 1, m_searchSelectRegion );
stmtS1->setInt( 2, m_id ); stmtS1->setInt( 2, m_id );
g_charaDb.execute( stmtS1 ); g_charaDb.execute( stmtS1 );
auto stmtS2 = g_charaDb.getPreparedStatement( Core::Db::CharaDbStatements::CHARA_SEARCHINFO_UP_SELECTREGION ); auto stmtS2 = g_charaDb.getPreparedStatement( Core::Db::CHARA_SEARCHINFO_UP_SELECTREGION );
stmtS2->setString( 1, std::string( m_searchMessage != nullptr ? m_searchMessage : "" ) ); stmtS2->setString( 1, string( m_searchMessage != nullptr ? m_searchMessage : "" ) );
stmtS2->setInt( 2, m_id ); stmtS2->setInt( 2, m_id );
g_charaDb.execute( stmtS2 ); g_charaDb.execute( stmtS2 );
////// QUESTS
updateAllQuests();
std::set< std::string > charaClassSet;
std::string dbName = g_serverZone.getConfig()->getValue< std::string >( "Settings.General.Mysql.Database", "sapphire" );
std::string updateCharaClass = "UPDATE " + dbName + ".characlass SET ";
std::string condition = " UPDATE_DATE = NOW() WHERE CharacterId = " + std::to_string( m_id ) + ";";
uint8_t classJobIndex = g_exdData.m_classJobInfoMap[static_cast< uint8_t >( getClass() )].exp_idx;
charaClassSet.insert( " Lv_" + std::to_string( classJobIndex ) + " = " + std::to_string( static_cast< uint32_t >( getLevel() ) ) );
charaClassSet.insert( " Exp_" + std::to_string( classJobIndex ) + " = " + std::to_string( getExp() ) );
if( !charaClassSet.empty() )
{
for( auto entry : charaClassSet )
updateCharaClass += entry + ", ";
updateCharaClass += condition;
g_database.execute( updateCharaClass );
}
} }
void Core::Entity::Player::updateAllQuests() const void Core::Entity::Player::updateDbAllQuests() 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] )
{ continue;
auto stmtS3 = g_charaDb.getPreparedStatement( Core::Db::CHARA_QUEST_UP ); auto stmtS3 = g_charaDb.getPreparedStatement( Core::Db::CHARA_QUEST_UP );
stmtS3->setInt( 1, m_activeQuests[i]->c.sequence ); stmtS3->setInt( 1, m_activeQuests[i]->c.sequence );
stmtS3->setInt( 2, m_activeQuests[i]->c.flags ); stmtS3->setInt( 2, m_activeQuests[i]->c.flags );
@ -459,7 +461,7 @@ void Core::Entity::Player::updateAllQuests() const
stmtS3->setInt( 10, m_id); stmtS3->setInt( 10, m_id);
stmtS3->setInt( 11, m_activeQuests[i]->c.questId ); stmtS3->setInt( 11, m_activeQuests[i]->c.questId );
g_charaDb.execute( stmtS3 ); g_charaDb.execute( stmtS3 );
}
} }
} }