mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-10 07:52:26 +00:00
UpdateSpawn2Timeleft converted to QueryDatabase
This commit is contained in:
parent
693dde04e3
commit
bcdfd32bc0
@ -193,29 +193,26 @@ void ZoneDatabase::UpdateSpawn2Timeleft(uint32 id, uint16 instance_id, uint32 ti
|
|||||||
gettimeofday(&tv, nullptr);
|
gettimeofday(&tv, nullptr);
|
||||||
uint32 cur = tv.tv_sec;
|
uint32 cur = tv.tv_sec;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
|
|
||||||
//if we pass timeleft as 0 that means we clear from respawn time
|
//if we pass timeleft as 0 that means we clear from respawn time
|
||||||
//otherwise we update with a REPLACE INTO
|
//otherwise we update with a REPLACE INTO
|
||||||
if(timeleft == 0)
|
if(timeleft == 0) {
|
||||||
{
|
std::string query = StringFormat("DELETE FROM respawn_times WHERE id=%lu "
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "DELETE FROM respawn_times WHERE id=%lu "
|
"AND instance_id = %lu",(unsigned long)id, (unsigned long)instance_id);
|
||||||
"AND instance_id=%lu",(unsigned long)id, (unsigned long)instance_id),errbuf))
|
auto results = QueryDatabase(query);
|
||||||
{
|
if (!results.Success())
|
||||||
LogFile->write(EQEMuLog::Error, "Error in UpdateTimeLeft query %s: %s", query, errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in UpdateTimeLeft query %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
return;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "REPLACE INTO respawn_times (id,start,duration,instance_id) "
|
|
||||||
"VALUES(%lu,%lu,%lu,%lu)",(unsigned long)id, (unsigned long)cur, (unsigned long)timeleft, (unsigned long)instance_id),errbuf))
|
|
||||||
{
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in UpdateTimeLeft query %s: %s", query, errbuf);
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string query = StringFormat("REPLACE INTO respawn_times (id, start, duration, instance_id) "
|
||||||
|
"VALUES (%lu, %lu, %lu, %lu)",
|
||||||
|
(unsigned long)id, (unsigned long)cur,
|
||||||
|
(unsigned long)timeleft, (unsigned long)instance_id);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success())
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in UpdateTimeLeft query %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user