mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-09 00:52:24 +00:00
GetEventLogs converted to QueryDatabase
This commit is contained in:
parent
046da9efae
commit
e60658c684
@ -411,12 +411,6 @@ void ZoneDatabase::SetDoorPlace(uint8 value,uint8 door_id,const char* zone_name)
|
|||||||
|
|
||||||
void ZoneDatabase::GetEventLogs(const char* name,char* target,uint32 account_id,uint8 eventid,char* detail,char* timestamp, CharacterEventLog_Struct* cel)
|
void ZoneDatabase::GetEventLogs(const char* name,char* target,uint32 account_id,uint8 eventid,char* detail,char* timestamp, CharacterEventLog_Struct* cel)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
query = new char[256];
|
|
||||||
uint32 count = 0;
|
|
||||||
char modifications[200];
|
char modifications[200];
|
||||||
if(strlen(name) != 0)
|
if(strlen(name) != 0)
|
||||||
sprintf(modifications,"charname=\'%s\'",name);
|
sprintf(modifications,"charname=\'%s\'",name);
|
||||||
@ -424,46 +418,42 @@ void ZoneDatabase::GetEventLogs(const char* name,char* target,uint32 account_id,
|
|||||||
sprintf(modifications,"accountid=%i",account_id);
|
sprintf(modifications,"accountid=%i",account_id);
|
||||||
|
|
||||||
if(strlen(target) != 0)
|
if(strlen(target) != 0)
|
||||||
sprintf(modifications,"%s AND target like \'%%%s%%\'",modifications,target);
|
sprintf(modifications,"%s AND target LIKE \'%%%s%%\'",modifications,target);
|
||||||
|
|
||||||
if(strlen(detail) != 0)
|
if(strlen(detail) != 0)
|
||||||
sprintf(modifications,"%s AND description like \'%%%s%%\'",modifications,detail);
|
sprintf(modifications,"%s AND description LIKE \'%%%s%%\'",modifications,detail);
|
||||||
|
|
||||||
if(strlen(timestamp) != 0)
|
if(strlen(timestamp) != 0)
|
||||||
sprintf(modifications,"%s AND time like \'%%%s%%\'",modifications,timestamp);
|
sprintf(modifications,"%s AND time LIKE \'%%%s%%\'",modifications,timestamp);
|
||||||
|
|
||||||
if(eventid == 0)
|
if(eventid == 0)
|
||||||
eventid =1;
|
eventid =1;
|
||||||
sprintf(modifications,"%s AND event_nid=%i",modifications,eventid);
|
sprintf(modifications,"%s AND event_nid=%i",modifications,eventid);
|
||||||
|
|
||||||
MakeAnyLenString(&query, "SELECT id,accountname,accountid,status,charname,target,time,descriptiontype,description FROM eventlog where %s",modifications);
|
std::string query = StringFormat("SELECT id, accountname, accountid, status, charname, target, "
|
||||||
if (RunQuery(query, strlen(query), errbuf, &result))
|
"time, descriptiontype, description FROM eventlog WHERE %s", modifications);
|
||||||
{
|
auto results = QueryDatabase(query);
|
||||||
safe_delete_array(query);
|
if (!results.Success())
|
||||||
while((row = mysql_fetch_row(result)))
|
return;
|
||||||
{
|
|
||||||
if(count > 255)
|
int index = 0;
|
||||||
break;
|
for (auto row = results.begin(); row != results.end(); ++row, ++index) {
|
||||||
cel->eld[count].id = atoi(row[0]);
|
if(index == 255)
|
||||||
strn0cpy(cel->eld[count].accountname,row[1],64);
|
break;
|
||||||
cel->eld[count].account_id = atoi(row[2]);
|
|
||||||
cel->eld[count].status = atoi(row[3]);
|
cel->eld[index].id = atoi(row[0]);
|
||||||
strn0cpy(cel->eld[count].charactername,row[4],64);
|
strn0cpy(cel->eld[index].accountname,row[1],64);
|
||||||
strn0cpy(cel->eld[count].targetname,row[5],64);
|
cel->eld[index].account_id = atoi(row[2]);
|
||||||
sprintf(cel->eld[count].timestamp,"%s",row[6]);
|
cel->eld[index].status = atoi(row[3]);
|
||||||
strn0cpy(cel->eld[count].descriptiontype,row[7],64);
|
strn0cpy(cel->eld[index].charactername,row[4],64);
|
||||||
strn0cpy(cel->eld[count].details,row[8],128);
|
strn0cpy(cel->eld[index].targetname,row[5],64);
|
||||||
cel->eventid = eventid;
|
sprintf(cel->eld[index].timestamp,"%s",row[6]);
|
||||||
count++;
|
strn0cpy(cel->eld[index].descriptiontype,row[7],64);
|
||||||
cel->count = count;
|
strn0cpy(cel->eld[index].details,row[8],128);
|
||||||
}
|
cel->eventid = eventid;
|
||||||
mysql_free_result(result);
|
cel->count = index + 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: Invalid item length in database
|
|
||||||
safe_delete_array(query);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load child objects for a world container (i.e., forge, bag dropped to ground, etc)
|
// Load child objects for a world container (i.e., forge, bag dropped to ground, etc)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user