DB Layer:
- Make SQL Transactions actual objects used in code. (Thanks to Derex for the idea) * Uncommitted transactions will be automatically rolled back and cleaned up using ACE_Refcounted_Auto_Ptr, so no need to call Rollback() in the code. * Prevents recursive transactions and makes developers aware of transactions going on. * Gets rid of unneccesary overhead iterating over a concurrent map. - Some cleanups in affected code, including better usage of transaction control in AH / mail related code to prevent data loss. *** Experimental, use at own risk, recommended to backup your DBs. *** --HG-- branch : trunk
This commit is contained in:
@@ -181,10 +181,10 @@ void GameEventMgr::StopEvent(uint16 event_id, bool overwrite)
|
||||
std::map<uint32 /*condition id*/, GameEventFinishCondition>::iterator itr;
|
||||
for (itr = mGameEvent[event_id].conditions.begin(); itr != mGameEvent[event_id].conditions.end(); ++itr)
|
||||
itr->second.done = 0;
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM game_event_save WHERE event_id = '%u'",event_id);
|
||||
CharacterDatabase.PExecute("DELETE FROM game_event_condition_save WHERE event_id = '%u'",event_id);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM game_event_save WHERE event_id = '%u'",event_id);
|
||||
trans->PAppend("DELETE FROM game_event_condition_save WHERE event_id = '%u'",event_id);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1627,10 +1627,10 @@ void GameEventMgr::HandleQuestComplete(uint32 quest_id)
|
||||
if (citr->second.done > citr->second.reqNum)
|
||||
citr->second.done = citr->second.reqNum;
|
||||
// save the change to db
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM game_event_condition_save WHERE event_id = '%u' AND condition_id = '%u'",event_id,condition);
|
||||
CharacterDatabase.PExecute("INSERT INTO game_event_condition_save (event_id, condition_id, done) VALUES (%u,%u,%f)",event_id,condition,citr->second.done);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM game_event_condition_save WHERE event_id = '%u' AND condition_id = '%u'",event_id,condition);
|
||||
trans->PAppend("INSERT INTO game_event_condition_save (event_id, condition_id, done) VALUES (%u,%u,%f)",event_id,condition,citr->second.done);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
// check if all conditions are met, if so, update the event state
|
||||
if (CheckOneGameEventConditions(event_id))
|
||||
{
|
||||
@@ -1663,13 +1663,13 @@ bool GameEventMgr::CheckOneGameEventConditions(uint16 event_id)
|
||||
|
||||
void GameEventMgr::SaveWorldEventStateToDB(uint16 event_id)
|
||||
{
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM game_event_save WHERE event_id = '%u'",event_id);
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM game_event_save WHERE event_id = '%u'",event_id);
|
||||
if (mGameEvent[event_id].nextstart)
|
||||
CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("UI64FMTD"))",event_id,mGameEvent[event_id].state,(uint64)(mGameEvent[event_id].nextstart));
|
||||
trans->PAppend("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("UI64FMTD"))",event_id,mGameEvent[event_id].state,(uint64)(mGameEvent[event_id].nextstart));
|
||||
else
|
||||
CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u','0000-00-00 00:00:00')",event_id,mGameEvent[event_id].state);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
trans->PAppend("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u','0000-00-00 00:00:00')",event_id,mGameEvent[event_id].state);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
void GameEventMgr::HandleWorldEventGossip(Player *plr, Creature *c)
|
||||
|
||||
Reference in New Issue
Block a user