DB-Schema/World/creature: Added possibility to override npcflag, unit_flags, dynamicflags in creature table

Core/Player: Fixed bad query in previous revision

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-10-09 17:52:00 +02:00
parent 324de6fb4c
commit 91a97c7b83
7 changed files with 82 additions and 15 deletions
+28 -6
View File
@@ -367,17 +367,21 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data)
else
setFaction(cInfo->faction_A);
uint32 npcflag, unit_flags, dynamicflags;
ObjectMgr::ChooseCreatureFlags(cInfo, npcflag, unit_flags, dynamicflags, data);
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT)
SetUInt32Value(UNIT_NPC_FLAGS,cInfo->npcflag | sGameEventMgr.GetNPCFlag(this));
SetUInt32Value(UNIT_NPC_FLAGS, npcflag | sGameEventMgr.GetNPCFlag(this));
else
SetUInt32Value(UNIT_NPC_FLAGS,cInfo->npcflag);
SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
SetAttackTime(BASE_ATTACK, cInfo->baseattacktime);
SetAttackTime(OFF_ATTACK, cInfo->baseattacktime);
SetAttackTime(RANGED_ATTACK,cInfo->rangeattacktime);
SetUInt32Value(UNIT_FIELD_FLAGS,cInfo->unit_flags);
SetUInt32Value(UNIT_DYNAMIC_FLAGS,cInfo->dynamicflags);
SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
SetUInt32Value(UNIT_DYNAMIC_FLAGS, dynamicflags);
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
@@ -1008,7 +1012,7 @@ void Creature::SaveToDB()
return;
}
SaveToDB(GetMapId(), data->spawnMask,GetPhaseMask());
SaveToDB(GetMapId(), data->spawnMask, GetPhaseMask());
}
void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
@@ -1019,6 +1023,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
CreatureData& data = sObjectMgr.NewOrExistCreatureData(m_DBTableGuid);
uint32 displayId = GetNativeDisplayId();
uint32 npcflag = GetUInt32Value(UNIT_NPC_FLAGS);
uint32 unit_flags = GetUInt32Value(UNIT_FIELD_FLAGS);
uint32 dynamicflags = GetUInt32Value(UNIT_DYNAMIC_FLAGS);
// check if it's a custom model and if not, use 0 for displayId
CreatureInfo const *cinfo = GetCreatureInfo();
@@ -1027,6 +1034,15 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 ||
displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
displayId = 0;
if (npcflag == cinfo->npcflag)
npcflag = 0;
if (unit_flags == cinfo->unit_flags)
unit_flags = 0;
if (dynamicflags == cinfo->dynamicflags)
dynamicflags = 0;
}
// data->guid = guid don't must be update at save
@@ -1050,6 +1066,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.movementType = !m_respawnradius && GetDefaultMovementType() == RANDOM_MOTION_TYPE
? IDLE_MOTION_TYPE : GetDefaultMovementType();
data.spawnMask = spawnMask;
data.npcflag = npcflag;
data.unit_flags = unit_flags;
data.dynamicflags = dynamicflags;
// updated in DB
SQLTransaction trans = WorldDatabase.BeginTransaction();
@@ -1075,7 +1094,10 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
<< GetHealth() << "," //curhealth
<< GetPower(POWER_MANA) << "," //curmana
<< (m_isDeadByDefault ? 1 : 0) << "," //is_dead
<< GetDefaultMovementType() << ")"; //default movement generator type
<< GetDefaultMovementType() << "," //default movement generator type
<< npcflag << ","
<< unit_flags << ","
<< dynamicflags << ")";
trans->Append(ss.str().c_str());
@@ -247,6 +247,9 @@ struct CreatureData
bool is_dead;
uint8 movementType;
uint8 spawnMask;
uint32 npcflag;
uint32 unit_flags; // enum UnitFlags mask values
uint32 dynamicflags;
bool dbData;
};
+1 -1
View File
@@ -18086,7 +18086,7 @@ void Player::_SaveInventory(SQLTransaction& trans)
bagTestGUID = test2->GetGUIDLow();
sLog.outError("Player(GUID: %u Name: %s)::_SaveInventory - the bag(%u) and slot(%u) values for the item with guid %u (state %d) are incorrect, the player doesn't have an item at that position!", lowGuid, GetName(), item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), (int32)item->GetState());
// according to the test that was just performed nothing should be in this slot, delete
trans->PAppend("DELETE FROM character_inventory WHERE bag=%u AND slot=%u", bagTestGUID, item->GetSlot());
trans->PAppend("DELETE FROM character_inventory WHERE bag=%u AND slot=%u AND guid=%u", bagTestGUID, item->GetSlot(), lowGuid);
// also THIS item should be somewhere else, cheat attempt
item->FSetState(ITEM_REMOVED); // we are IN updateQueue right now, can't use SetState which modifies the queue
DeleteRefundReference(item->GetGUIDLow());