Fix mail, professions, group loot, console spam, and some fixes. Big thx to TOM_RUS.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-04-11 11:16:42 +04:00
parent 457df07bd4
commit be95faff23
34 changed files with 302 additions and 299 deletions
+15 -30
View File
@@ -5087,9 +5087,9 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
sLog.outDebug("Returning mails current time: hour: %d, minute: %d, second: %d ", localtime(&basetime)->tm_hour, localtime(&basetime)->tm_min, localtime(&basetime)->tm_sec);
//delete all old mails without item and without body immediately, if starting server
if (!serverUp)
CharacterDatabase.PExecute("DELETE FROM mail WHERE expire_time < '" UI64FMTD "' AND has_items = '0' AND itemTextId = 0", (uint64)basetime);
CharacterDatabase.PExecute("DELETE FROM mail WHERE expire_time < '" UI64FMTD "' AND has_items = '0' AND body = ''", (uint64)basetime);
// 0 1 2 3 4 5 6 7 8 9
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,itemTextId,has_items,expire_time,cod,checked,mailTemplateId FROM mail WHERE expire_time < '" UI64FMTD "'", (uint64)basetime);
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,has_items,expire_time,cod,checked,mailTemplateId FROM mail WHERE expire_time < '" UI64FMTD "'", (uint64)basetime);
if (!result)
{
barGoLink bar(1);
@@ -5118,13 +5118,12 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
m->messageType = fields[1].GetUInt8();
m->sender = fields[2].GetUInt32();
m->receiver = fields[3].GetUInt32();
m->itemTextId = fields[4].GetUInt32();
bool has_items = fields[5].GetBool();
m->expire_time = (time_t)fields[6].GetUInt64();
bool has_items = fields[4].GetBool();
m->expire_time = (time_t)fields[5].GetUInt64();
m->deliver_time = 0;
m->COD = fields[7].GetUInt32();
m->checked = fields[8].GetUInt32();
m->mailTemplateId = fields[9].GetInt16();
m->COD = fields[6].GetUInt32();
m->checked = fields[7].GetUInt32();
m->mailTemplateId = fields[8].GetInt16();
Player *pl = 0;
if (serverUp)
@@ -5153,7 +5152,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
while (resultItems->NextRow());
}
//if it is mail from AH, it shouldn't be returned, but deleted
if (m->messageType != MAIL_NORMAL || (m->checked & (MAIL_CHECK_MASK_AUCTION | MAIL_CHECK_MASK_COD_PAYMENT | MAIL_CHECK_MASK_RETURNED)))
if (m->messageType != MAIL_NORMAL || m->messageType == MAIL_AUCTION || (m->checked & (MAIL_CHECK_MASK_COD_PAYMENT | MAIL_CHECK_MASK_RETURNED)))
{
// mail open and then not returned
for (std::vector<MailItemInfo>::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
@@ -5168,9 +5167,6 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
}
}
if (m->itemTextId)
CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", m->itemTextId);
//deletemail = true;
//delmails << m->messageID << ", ";
CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID);
@@ -6061,28 +6057,17 @@ uint32 ObjectMgr::GenerateMailID()
return m_mailid++;
}
uint32 ObjectMgr::GenerateItemTextID()
void ObjectMgr::CreateItemText(uint32 guid, std::string text)
{
if (m_ItemTextId >= 0xFFFFFFFE)
{
sLog.outError("Item text ids overflow!! Can't continue, shutting down server. ");
World::StopNow(ERROR_EXIT_CODE);
}
return m_ItemTextId++;
}
uint32 ObjectMgr::CreateItemText(std::string text)
{
uint32 newItemTextId = GenerateItemTextID();
//insert new itempage to container
mItemTexts[ newItemTextId ] = text;
//save new itempage
// insert new item text to container
mItemTexts[ guid ] = text;
// save new item text
CharacterDatabase.escape_string(text);
//any Delete query needed, itemTextId is maximum of all ids
std::ostringstream query;
query << "INSERT INTO item_text (id,text) VALUES ('" << newItemTextId << "', '" << text << "')";
query << "INSERT INTO item_text (id,text) VALUES ( '" << guid << "', '" << text << "')";
CharacterDatabase.Execute(query.str().c_str()); //needs to be run this way, because mail body may be more than 1024 characters
return newItemTextId;
}
uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)