Merge commit 'origin/master' into 320

Conflicts:
	src/game/WorldSession.cpp
This commit is contained in:
tomrus88 2009-08-30 15:52:20 +04:00
commit 9c8a0d615e
13 changed files with 162 additions and 22 deletions

View file

@ -58,7 +58,8 @@ char remotes[NUM_REMOTES][MAX_REMOTE] = {
}; };
char remote_branch[MAX_REMOTE] = "master"; char remote_branch[MAX_REMOTE] = "master";
char rev_file[MAX_PATH] = "src/shared/revision_nr.h"; char rev_nr_file[MAX_PATH] = "src/shared/revision_nr.h";
char rev_sql_file[MAX_PATH] = "src/shared/revision_sql.h";
char sql_update_dir[MAX_PATH] = "sql/updates"; char sql_update_dir[MAX_PATH] = "sql/updates";
char new_index_file[MAX_PATH] = ".git/git_id_index"; char new_index_file[MAX_PATH] = ".git/git_id_index";
@ -80,6 +81,12 @@ char db_sql_file[NUM_DATABASES][MAX_PATH] = {
"sql/realmd.sql" "sql/realmd.sql"
}; };
char db_sql_rev_field[NUM_DATABASES][MAX_PATH] = {
"REVISION_DB_CHARACTERS",
"REVISION_DB_MANGOS",
"REVISION_DB_REALMD"
};
bool allow_replace = false; bool allow_replace = false;
bool local = false; bool local = false;
bool do_fetch = false; bool do_fetch = false;
@ -257,7 +264,7 @@ bool find_rev()
return rev > 0; return rev > 0;
} }
std::string generateHeader(char const* rev_str) std::string generateNrHeader(char const* rev_str)
{ {
std::ostringstream newData; std::ostringstream newData;
newData << "#ifndef __REVISION_NR_H__" << std::endl; newData << "#ifndef __REVISION_NR_H__" << std::endl;
@ -267,6 +274,17 @@ std::string generateHeader(char const* rev_str)
return newData.str(); return newData.str();
} }
std::string generateSqlHeader()
{
std::ostringstream newData;
newData << "#ifndef __REVISION_SQL_H__" << std::endl;
newData << "#define __REVISION_SQL_H__" << std::endl;
for(int i = 0; i < NUM_DATABASES; ++i)
newData << " #define " << db_sql_rev_field[i] << " \"required_" << last_sql_update[i] << "\"" << std::endl;
newData << "#endif // __REVISION_SQL_H__" << std::endl;
return newData.str();
}
void system_switch_index(const char *cmd) void system_switch_index(const char *cmd)
{ {
// do the command for the original index and then for the new index // do the command for the original index and then for the new index
@ -280,15 +298,39 @@ void system_switch_index(const char *cmd)
if(putenv(old_index_cmd) != 0) return; if(putenv(old_index_cmd) != 0) return;
} }
bool write_rev() bool write_rev_nr()
{ {
printf("+ writing revision_nr.h\n"); printf("+ writing revision_nr.h\n");
char rev_str[256]; char rev_str[256];
sprintf(rev_str, "%d", rev); sprintf(rev_str, "%d", rev);
std::string header = generateHeader(rev_str); std::string header = generateNrHeader(rev_str);
char prefixed_file[MAX_PATH]; char prefixed_file[MAX_PATH];
snprintf(prefixed_file, MAX_PATH, "%s%s", path_prefix, rev_file); snprintf(prefixed_file, MAX_PATH, "%s%s", path_prefix, rev_nr_file);
if(FILE* OutputFile = fopen(prefixed_file, "wb"))
{
fprintf(OutputFile,"%s", header.c_str());
fclose(OutputFile);
// add the file to both indices, to be committed later
snprintf(cmd, MAX_CMD, "git add %s", prefixed_file);
system_switch_index(cmd);
return true;
}
return false;
}
bool write_rev_sql()
{
if(new_sql_updates.empty()) return true;
printf("+ writing revision_sql.h\n");
std::string header = generateSqlHeader();
char prefixed_file[MAX_PATH];
snprintf(prefixed_file, MAX_PATH, "%s%s", path_prefix, rev_sql_file);
if(FILE* OutputFile = fopen(prefixed_file, "wb")) if(FILE* OutputFile = fopen(prefixed_file, "wb"))
{ {
@ -846,12 +888,13 @@ int main(int argc, char *argv[])
if(do_sql) if(do_sql)
DO( find_sql_updates() ); DO( find_sql_updates() );
DO( prepare_new_index() ); DO( prepare_new_index() );
DO( write_rev() ); DO( write_rev_nr() );
if(do_sql) if(do_sql)
{ {
DO( convert_sql_updates() ); DO( convert_sql_updates() );
DO( generate_sql_makefile() ); DO( generate_sql_makefile() );
DO( change_sql_database() ); DO( change_sql_database() );
DO( write_rev_sql() );
} }
DO( amend_commit() ); DO( amend_commit() );
DO( cleanup_new_index() ); DO( cleanup_new_index() );

View file

@ -854,9 +854,10 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket)
if (_player->GetMoney() < price) if (_player->GetMoney() < price)
return; return;
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT, slot);
_player->SetBankBagSlotCount(slot); _player->SetBankBagSlotCount(slot);
_player->ModifyMoney(-int32(price)); _player->ModifyMoney(-int32(price));
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT);
} }
void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket)

View file

@ -1005,7 +1005,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x3D0*/ { "CMSG_TARGET_CAST", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3D0*/ { "CMSG_TARGET_CAST", STATUS_NEVER, &WorldSession::Handle_NULL },
/*0x3D1*/ { "CMSG_TARGET_SCRIPT_CAST", STATUS_NEVER, &WorldSession::Handle_NULL }, /*0x3D1*/ { "CMSG_TARGET_SCRIPT_CAST", STATUS_NEVER, &WorldSession::Handle_NULL },
/*0x3D2*/ { "CMSG_CHANNEL_DISPLAY_LIST", STATUS_LOGGEDIN, &WorldSession::HandleChannelDisplayListQuery }, /*0x3D2*/ { "CMSG_CHANNEL_DISPLAY_LIST", STATUS_LOGGEDIN, &WorldSession::HandleChannelDisplayListQuery },
/*0x3D3*/ { "CMSG_SET_ACTIVE_VOICE_CHANNEL", STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT, &WorldSession::HandleSetActiveVoiceChannel }, /*0x3D3*/ { "CMSG_SET_ACTIVE_VOICE_CHANNEL", STATUS_AUTHED, &WorldSession::HandleSetActiveVoiceChannel },
/*0x3D4*/ { "CMSG_GET_CHANNEL_MEMBER_COUNT", STATUS_LOGGEDIN, &WorldSession::HandleGetChannelMemberCount }, /*0x3D4*/ { "CMSG_GET_CHANNEL_MEMBER_COUNT", STATUS_LOGGEDIN, &WorldSession::HandleGetChannelMemberCount },
/*0x3D5*/ { "SMSG_CHANNEL_MEMBER_COUNT", STATUS_NEVER, &WorldSession::Handle_ServerSide }, /*0x3D5*/ { "SMSG_CHANNEL_MEMBER_COUNT", STATUS_NEVER, &WorldSession::Handle_ServerSide },
/*0x3D6*/ { "CMSG_CHANNEL_VOICE_ON", STATUS_LOGGEDIN, &WorldSession::HandleChannelVoiceOnOpcode }, /*0x3D6*/ { "CMSG_CHANNEL_VOICE_ON", STATUS_LOGGEDIN, &WorldSession::HandleChannelVoiceOnOpcode },

View file

@ -1261,6 +1261,30 @@ bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
return false; return false;
} }
void Aura::ReapplyAffectedPassiveAuras( Unit* target )
{
std::set<uint32> affectedPassives;
for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr)
{
// permanent passive
if (itr->second->IsPassive() && itr->second->IsPermanent() &&
// non deleted and not same aura (any with same spell id)
!itr->second->IsDeleted() && itr->second->GetId() != GetId() &&
// only applied by self and affected by aura
itr->second->GetCasterGUID() == target->GetGUID() && isAffectedOnSpell(itr->second->GetSpellProto()))
{
affectedPassives.insert(itr->second->GetId());
}
}
for(std::set<uint32>::const_iterator set_itr = affectedPassives.begin(); set_itr != affectedPassives.end(); ++set_itr)
{
target->RemoveAurasDueToSpell(*set_itr);
target->CastSpell(m_target, *set_itr, true);
}
}
/*********************************************************/ /*********************************************************/
/*** BASIC AURA FUNCTION ***/ /*** BASIC AURA FUNCTION ***/
/*********************************************************/ /*********************************************************/
@ -1317,19 +1341,17 @@ void Aura::HandleAddModifier(bool apply, bool Real)
((Player*)m_target)->AddSpellMod(m_spellmod, apply); ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
// reaplly talents to own passive persistent auras // reapply talents to own passive persistent auras
std::set<uint32> affectedPassives; ReapplyAffectedPassiveAuras(m_target);
for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().begin(); itr != m_target->GetAuras().end(); ++itr) // re-aplly talents and passives applied to pet (it affected by player spellmods)
if (itr->second->IsPassive() && itr->second->IsPermanent() && if(Pet* pet = m_target->GetPet())
itr->second->GetCasterGUID() == m_target->GetGUID() && isAffectedOnSpell(itr->second->GetSpellProto())) ReapplyAffectedPassiveAuras(pet);
affectedPassives.insert(itr->second->GetId());
for(std::set<uint32>::const_iterator set_itr = affectedPassives.begin(); set_itr != affectedPassives.end(); ++set_itr) for(int i = 0; i < MAX_TOTEM; ++i)
{ if(m_target->m_TotemSlot[i])
m_target->RemoveAurasDueToSpell(*set_itr); if(Creature* totem = m_target->GetMap()->GetCreature(m_target->m_TotemSlot[i]))
m_target->CastSpell(m_target, *set_itr, true); ReapplyAffectedPassiveAuras(totem);
}
} }
void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/) void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)
{ {
@ -5701,7 +5723,13 @@ void Aura::HandleSpellSpecificBoosts(bool apply)
} }
// Aspect of the Dragonhawk dodge // Aspect of the Dragonhawk dodge
else if (GetSpellProto()->SpellFamilyFlags2 & 0x00001000) else if (GetSpellProto()->SpellFamilyFlags2 & 0x00001000)
{
spellId1 = 61848; spellId1 = 61848;
// triggered spell have same category as main spell and cooldown
if (apply && m_target->GetTypeId()==TYPEID_PLAYER)
((Player*)m_target)->RemoveSpellCooldown(61848);
}
else else
return; return;
break; break;

View file

@ -341,6 +341,7 @@ class MANGOS_DLL_SPEC Aura
void PeriodicDummyTick(); void PeriodicDummyTick();
bool IsCritFromAbilityAura(Unit* caster, uint32& damage); bool IsCritFromAbilityAura(Unit* caster, uint32& damage);
void ReapplyAffectedPassiveAuras(Unit* target);
Modifier m_modifier; Modifier m_modifier;
SpellModifier *m_spellmod; SpellModifier *m_spellmod;

View file

@ -1000,6 +1000,8 @@ void SpellMgr::LoadSpellBonusess()
DoSpellBonusess worker(sbe); DoSpellBonusess worker(sbe);
doForHighRanks(entry,worker); doForHighRanks(entry,worker);
++count;
} while( result->NextRow() ); } while( result->NextRow() );
delete result; delete result;

View file

@ -234,7 +234,11 @@ bool WorldSession::Update(uint32 /*diff*/)
break; break;
} }
m_playerRecentlyLogout = false; // single from authed time opcodes send in to after logout time
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
m_playerRecentlyLogout = false;
(this->*opHandle.handler)(*packet); (this->*opHandle.handler)(*packet);
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos()) if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
LogUnprocessedTail(packet); LogUnprocessedTail(packet);
@ -582,7 +586,7 @@ void WorldSession::LoadGlobalAccountData()
void WorldSession::LoadAccountData(QueryResult* result, uint32 mask) void WorldSession::LoadAccountData(QueryResult* result, uint32 mask)
{ {
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i) for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
if(mask & (1 << i)) if (mask & (1 << i))
m_accountData[i] = AccountData(); m_accountData[i] = AccountData();
if(!result) if(!result)

View file

@ -38,6 +38,7 @@
#include "RASocket.h" #include "RASocket.h"
#include "ScriptCalls.h" #include "ScriptCalls.h"
#include "Util.h" #include "Util.h"
#include "revision_sql.h"
#include "sockets/TcpSocket.h" #include "sockets/TcpSocket.h"
#include "sockets/Utility.h" #include "sockets/Utility.h"
@ -416,6 +417,9 @@ bool Master::_StartDB()
return false; return false;
} }
if(!WorldDatabase.CheckRequiredField("db_version",REVISION_DB_MANGOS))
return false;
if(!sConfig.GetString("CharacterDatabaseInfo", &dbstring)) if(!sConfig.GetString("CharacterDatabaseInfo", &dbstring))
{ {
sLog.outError("Character Database not specified in configuration file"); sLog.outError("Character Database not specified in configuration file");
@ -430,6 +434,9 @@ bool Master::_StartDB()
return false; return false;
} }
if(!CharacterDatabase.CheckRequiredField("character_db_version",REVISION_DB_CHARACTERS))
return false;
///- Get login database info from configuration file ///- Get login database info from configuration file
if(!sConfig.GetString("LoginDatabaseInfo", &dbstring)) if(!sConfig.GetString("LoginDatabaseInfo", &dbstring))
{ {
@ -445,6 +452,9 @@ bool Master::_StartDB()
return false; return false;
} }
if(!loginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD))
return false;
///- Get the realm Id from the configuration file ///- Get the realm Id from the configuration file
realmID = sConfig.GetIntDefault("RealmID", 0); realmID = sConfig.GetIntDefault("RealmID", 0);
if(!realmID) if(!realmID)

View file

@ -31,6 +31,7 @@
#include "SystemConfig.h" #include "SystemConfig.h"
#include "revision.h" #include "revision.h"
#include "revision_nr.h" #include "revision_nr.h"
#include "revision_sql.h"
#include "Util.h" #include "Util.h"
#include <openssl/opensslv.h> #include <openssl/opensslv.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
@ -325,6 +326,9 @@ bool StartDB(std::string &dbstring)
return false; return false;
} }
if(!loginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD))
return false;
return true; return true;
} }

View file

@ -189,3 +189,43 @@ bool Database::DirectPExecute(const char * format,...)
return DirectExecute(szQuery); return DirectExecute(szQuery);
} }
bool Database::CheckRequiredField( char const* table_name, char const* required_name )
{
// check required field
QueryResult* result = PQuery("SELECT %s FROM %s LIMIT 1",required_name,table_name);
if(result)
{
delete result;
return true;
}
// check fail, prepare readabale error message
// search current required_* field in DB
QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1",table_name);
if(result2)
{
QueryFieldNames const& namesMap = result2->GetFieldNames();
std::string reqName;
for(QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr)
{
if(itr->substr(0,9)=="required_")
{
reqName = *itr;
break;
}
}
delete result;
if(!reqName.empty())
{
sLog.outErrorDb("Table `%s` have field `%s` but expected `%s`! Not all sql updates applied?",table_name,reqName.c_str(),required_name);
return false;
}
}
sLog.outErrorDb("Table `%s` not have required_* field but expected `%s`! Not all sql updates applied?",table_name,required_name);
return false;
}

View file

@ -129,6 +129,7 @@ class MANGOS_DLL_SPEC Database
// sets the result queue of the current thread, be careful what thread you call this from // sets the result queue of the current thread, be careful what thread you call this from
void SetResultQueue(SqlResultQueue * queue); void SetResultQueue(SqlResultQueue * queue);
bool CheckRequiredField(char const* table_name, char const* required_name);
private: private:
bool m_logSQL; bool m_logSQL;
std::string m_logsDir; std::string m_logsDir;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8433" #define REVISION_NR "8441"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__

View file

@ -0,0 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_8433_01_characters_character_account_data"
#define REVISION_DB_MANGOS "required_8416_01_mangos_spell_learn_spell"
#define REVISION_DB_REALMD "required_8332_01_realmd_realmcharacters"
#endif // __REVISION_SQL_H__