View Single Post
  #1  
Old 05-09-2009, 08:49 AM
tsowl
Fire Beetle
 
Join Date: Jul 2004
Posts: 8
Default load player corpse decay time

zone/client_packet.cpp
Code:
			sec = (ttime/1000)%60; // Total seconds
			min = (ttime/60000)%60; // Total seconds
-			hour = (ttime/3600000)%60; // Total hours
-			day = (ttime/86400000)%24; // Total Days
+			hour = (ttime/3600000)%24; // Total hours
+			day = ttime/86400000; // Total Days
zone/playercorpse.cpp
Code:
	dbid = in_dbid;
	p_depop = false;
	charid = in_charid;
	itemlist = *in_itemlist;
	in_itemlist->clear();

	//we really should be loading the decay timer here...
+	LoadPlayerCorpseDecayTime(in_dbid);
	
	strcpy(orgname, in_charname);
	strcpy(name, in_charname);
add:
Code:
void Corpse::LoadPlayerCorpseDecayTime(int32 dbid){
	if(!dbid)
		return;
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;
    MYSQL_RES *result;
    MYSQL_ROW row;
	if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) FROM player_corpses WHERE id=%d and not timeofdeath=0", dbid), errbuf, &result)) {
		safe_delete_array(query);
		while (row = mysql_fetch_row(result)) {
			if(atoi(row[0]) > 0 && RuleI(Character, CorpseDecayTimeMS) > (atoi(row[0]) * 1000))
				corpse_decay_timer.SetTimer(RuleI(Character, CorpseDecayTimeMS) - (atoi(row[0]) * 1000));
			else
				corpse_decay_timer.SetTimer(5000);
		}
		mysql_free_result(result);
	}
	safe_delete_array(query);
}
zone/playercorpse.h
Code:
class Corpse : public Mob
{
public:
+	void LoadPlayerCorpseDecayTime(int32 dbid);
}
Reply With Quote