Ejemplo n.º 1
0
void MailSystem::UpdateMessages()
{
	if((++loopcount % 1200))
		return;

	QueryResult *result = CharacterDatabase.Query("SELECT * FROM mailbox WHERE expiry_time > 0 and expiry_time <= %u and deleted_flag = 0",(uint32)UNIXTIME);

	if(!result)
		return;

	MailMessage msg;
	do 
	{
		if (msg.LoadFromDB(result->Fetch()))
		{
			if (/*msg.Expired() &&*/ msg.items.size() == 0 && msg.money == 0)
			{
				if(msg.copy_made)
				{
					msg.deleted_flag = true;
					msg.SaveToDB();
				} else
				{
					CharacterDatabase.WaitExecute("DELETE FROM mailbox WHERE message_id = %u", msg.message_id);
				}
			} else
			{
				ReturnToSender(&msg);
			}

		}
	} while(result->NextRow());
	delete result;
}
Ejemplo n.º 2
0
void Mailbox::Load(QueryResult * result)
{
	if(!result)
		return;

	MailMessage msg;
	do 
	{
		if (msg.LoadFromDB(result->Fetch()))
		{
			AddMessage(&msg);// Add to the mailbox
		}
	} while(result->NextRow());
}