Merge pull request #197 from addtheice/RunQueryToDatabaseQuery_world_zoneserver

Run query to database query world zoneserver
This commit is contained in:
Alex 2014-08-21 14:04:50 -07:00
commit 1c295453da

View File

@ -446,31 +446,34 @@ bool ZoneServer::Process() {
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
}
else if (cle->Online() == CLE_Status_Zoning) {
if (!scm->noreply) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
//MYSQL_ROW row; Trumpcard - commenting. Currently unused.
if (!scm->noreply)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
char *telldate=asctime(timeinfo);
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT name from character_ where name='%s'",scm->deliverto), errbuf, &result)) {
safe_delete(query);
if (result!=0) {
if (database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO tellque (Date,Receiver,Sender,Message) values('%s','%s','%s','%s')",telldate,scm->deliverto,scm->from,scm->message), errbuf, &result))
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to);
else
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
safe_delete(query);
}
else
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
mysql_free_result(result);
}
else
safe_delete(query);
std::string query = StringFormat("SELECT name FROM character_ WHERE name = '%s'",scm->deliverto);
auto results = database.QueryDatabase(query);
if (!results.Success())
break;
if (results.RowCount() == 0) {
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
break;
}
query = StringFormat("INSERT INTO tellque "
"(Date, Receiver, Sender, Message) "
"VALUES('%s', '%s', '%s', '%s')",
telldate, scm->deliverto, scm->from, scm->message);
results = database.QueryDatabase(query);
if (results.Success())
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to);
else
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
}
// zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
}