Post merge Log.Out converts and header/linker fixes

This commit is contained in:
Akkadius 2015-02-03 00:10:49 -06:00
parent dd6d1d5511
commit 3448dd1a9e
14 changed files with 67 additions and 40 deletions

View File

@ -2051,3 +2051,27 @@ void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Str
std::string query = StringFormat("UPDATE bots SET BotInspectMessage = '%s' WHERE BotID = %i", msg.c_str(), botid);
QueryDatabase(query);
}
bool SharedDatabase::VerifyToken(std::string token, int& status) {
status = 0;
if (token.length() > 64) {
token = token.substr(0, 64);
}
token = EscapeString(token);
std::string query = StringFormat("SELECT status FROM tokens WHERE token='%s'", token.c_str());
auto results = QueryDatabase(query);
if (!results.Success())
{
std::cerr << "Error in SharedDatabase::VerifyToken query '" << query << "' " << results.ErrorMessage() << std::endl;
return false;
}
if (results.RowCount() != 1) {
return false;
}
auto row = results.begin();
status = atoi(row[0]);
return true;
}

View File

@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "../common/global_define.h"
#include "web_interface_utils.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef COMMON_WEBINTUTIL_H
#define COMMON_WEBINTUTIL_H
#include "../common/debug.h"
#include "../common/global_define.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <iostream>

View File

@ -1,13 +1,16 @@
#include "../common/eqemu_logsys.h"
#include "web_interface.h"
#include "method_handler.h"
#include "remote_call.h"
EQEmuLogSys Log;
volatile bool run = true;
TimeoutManager timeout_manager;
const EQEmuConfig *config = nullptr;
WorldServer *worldserver = nullptr;
libwebsocket_context *context = nullptr;
SharedDatabase *db = nullptr;
std::map<std::string, per_session_data_eqemu*> sessions;
std::map<std::string, std::pair<int, MethodHandler>> authorized_methods;
std::map<std::string, MethodHandler> unauthorized_methods;
@ -135,18 +138,20 @@ static struct libwebsocket_protocols protocols[] = {
int main() {
RegisterExecutablePlatform(ExePlatformWebInterface);
Log.LoadLogSettingsDefaults();
set_exception_handler();
register_methods();
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
_log(WEB_INTERFACE__INIT, "Starting EQEmu Web Server.");
Log.Out(Logs::General, Logs::WebInterface_Server, "Starting EQEmu Web Server.");
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
_log(WEB_INTERFACE__ERROR, "Could not set signal handler");
Log.Out(Logs::General, Logs::Error, "Could not set signal handler");
return 1;
}
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
_log(WEB_INTERFACE__ERROR, "Could not set signal handler");
Log.Out(Logs::General, Logs::Error, "Could not set signal handler");
return 1;
}
@ -162,15 +167,15 @@ int main() {
context = libwebsocket_create_context(&info);
if (context == NULL) {
_log(WEB_INTERFACE__ERROR, "Could not create websocket handler.");
Log.Out(Logs::General, Logs::Error, "Could not create websocket handler.");
return 1;
}
db = new SharedDatabase();
_log(WEB_INTERFACE__TRACE, "Connecting to database...");
Log.Out(Logs::General, Logs::WebInterface_Server, "Connecting to database...");
if(!db->Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
_log(WEB_INTERFACE__TRACE, "Unable to connect to the database, cannot continue without a database connection");
Log.Out(Logs::General, Logs::WebInterface_Server, "Unable to connect to the database, cannot continue without a database connection");
return 1;
}

View File

@ -18,7 +18,7 @@
#ifndef WI_WEB_INTERFACE_H
#define WI_WEB_INTERFACE_H
#include "../common/debug.h"
#include "../common/global_define.h"
#include "../common/opcodemgr.h"
#include "../common/eq_stream_factory.h"
#include "../common/rulesys.h"

View File

@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "../common/global_define.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
@ -44,7 +44,7 @@ WorldServer::~WorldServer(){
}
void WorldServer::OnConnected(){
_log(WEB_INTERFACE__INIT, "Connected to World.");
Log.Out(Logs::General, Logs::WebInterface_Server, "Connected to World.");
WorldConnection::OnConnected();
}
@ -55,7 +55,7 @@ void WorldServer::Process(){
ServerPacket *pack = nullptr;
while((pack = tcpc.PopPacket())){
_log(WEB_INTERFACE__TRACE, "Received Opcode: %4X", pack->opcode);
Log.Out(Logs::General, Logs::Netcode, "Received Opcode: %4X", pack->opcode);
switch(pack->opcode) {
case 0: { break; }
case ServerOP_KeepAlive: { break; }

View File

@ -268,7 +268,7 @@ bool Console::Process() {
}
else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeWebInterface)
{
_log(WORLD__CONSOLE, "New WI Connection from %s:%d", inet_ntoa(in), GetPort());
Log.Out(Logs::Detail, Logs::World_Server, "New WI Connection from %s:%d", inet_ntoa(in), GetPort());
WILink.SetConnection(tcpc);
tcpc = 0;
}

View File

@ -108,6 +108,8 @@ uint32 numclients = 0;
uint32 numzones = 0;
bool holdzones = false;
EQEmuLogSys Log;
extern ConsoleList console_list;
void CatchSignal(int sig_num);

View File

@ -1,8 +1,7 @@
#include <string>
#include "../common/debug.h"
#include "../common/logsys.h"
#include "../common/logtypes.h"
#include "../common/global_define.h"
#include "../common/eqemu_logsys.h"
#include "../common/md5.h"
#include "../common/emu_tcp_connection.h"
#include "../common/packet_dump.h"

View File

@ -1,12 +1,11 @@
#include "../common/debug.h"
#include "../common/global_define.h"
#include "web_interface.h"
#include "world_config.h"
#include "clientlist.h"
#include "zonelist.h"
#include "zoneserver.h"
#include "remote_call.h"
#include "../common/logsys.h"
#include "../common/logtypes.h"
#include "../common/eqemu_logsys.h"
#include "../common/md5.h"
#include "../common/emu_tcp_connection.h"
#include "../common/packet_dump.h"
@ -25,7 +24,7 @@ void WebInterfaceConnection::SetConnection(EmuTCPConnection *inStream)
{
if(stream)
{
_log(WEB_INTERFACE__ERROR, "Incoming WebInterface Connection while we were already connected to a WebInterface.");
Log.Out(Logs::General, Logs::WebInterface_Server, "Incoming WebInterface Connection while we were already connected to a WebInterface.");
stream->Disconnect();
}
@ -59,7 +58,7 @@ bool WebInterfaceConnection::Process()
{
struct in_addr in;
in.s_addr = GetIP();
_log(WEB_INTERFACE__ERROR, "WebInterface authorization failed.");
Log.Out(Logs::General, Logs::Error, "WebInterface authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
@ -71,7 +70,7 @@ bool WebInterfaceConnection::Process()
{
struct in_addr in;
in.s_addr = GetIP();
_log(WEB_INTERFACE__ERROR, "WebInterface authorization failed.");
Log.Out(Logs::General, Logs::Error, "WebInterface authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
@ -81,7 +80,7 @@ bool WebInterfaceConnection::Process()
}
else
{
_log(WEB_INTERFACE__ERROR, "**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthorized zone access.");
Log.Out(Logs::General, Logs::Error, "**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthorized zone access.");
authenticated = true;
}
delete pack;
@ -99,7 +98,7 @@ bool WebInterfaceConnection::Process()
}
case ServerOP_ZAAuth:
{
_log(WEB_INTERFACE__ERROR, "Got authentication from WebInterface when they are already authenticated.");
Log.Out(Logs::General, Logs::Error, "Got authentication from WebInterface when they are already authenticated.");
break;
}
case ServerOP_WIRemoteCall:
@ -159,7 +158,7 @@ bool WebInterfaceConnection::Process()
}
default:
{
_log(WEB_INTERFACE__ERROR, "Unknown ServerOPcode from WebInterface 0x%04x, size %d", pack->opcode, pack->size);
Log.Out(Logs::General, Logs::Error, "Unknown ServerOPcode from WebInterface 0x%04x, size %d", pack->opcode, pack->size);
DumpPacket(pack->pBuffer, pack->size);
break;
}

View File

@ -4362,7 +4362,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
params.push_back(std::to_string(ppu->x_pos));
params.push_back(std::to_string(ppu->y_pos));
params.push_back(std::to_string(ppu->z_pos));
params.push_back(std::to_string(heading));
params.push_back(std::to_string(m_Position.w));
params.push_back(std::to_string(GetClass()));
params.push_back(std::to_string(GetRace()));
RemoteCallSubscriptionHandler::Instance()->OnEvent("Client.Position", params);

View File

@ -1233,10 +1233,10 @@ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){
std::vector<std::string> params;
params.push_back(std::to_string((long)GetID()));
params.push_back(GetCleanName());
params.push_back(std::to_string((double)x_pos));
params.push_back(std::to_string((double)y_pos));
params.push_back(std::to_string((double)z_pos));
params.push_back(std::to_string((double)heading));
params.push_back(std::to_string((double)m_Position.x));
params.push_back(std::to_string((double)m_Position.y));
params.push_back(std::to_string((double)m_Position.z));
params.push_back(std::to_string((double)m_Position.w));
params.push_back(std::to_string((double)GetClass()));
params.push_back(std::to_string((double)GetRace()));
RemoteCallSubscriptionHandler::Instance()->OnEvent("NPC.Position", params);

View File

@ -1,7 +1,6 @@
#include "../common/debug.h"
#include "../common/global_define.h"
#include "../common/emu_tcp_connection.h"
#include "../common/logsys.h"
#include "../common/logtypes.h"
#include "../common/eqemu_logsys.h"
#include "../common/md5.h"
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"
@ -184,10 +183,10 @@ void handle_rc_get_initial_entity_positions(const std::string &method, const std
res["ent_id"] = itoa(c->GetEntityID());
res["type"] = "Door";
res["name"] = c->GetDoorName();
res["x"] = itoa(c->GetX());
res["y"] = itoa(c->GetY());
res["z"] = itoa(c->GetZ());
res["h"] = itoa(c->GetHeading());
res["x"] = itoa(c->GetPosition().x);
res["y"] = itoa(c->GetPosition().y);
res["z"] = itoa(c->GetPosition().z);
res["h"] = itoa(c->GetPosition().w);
RemoteCallResponse(connection_id, request_id, res, error);
}
std::list<Object*> object_list;

View File

@ -1,6 +1,5 @@
#include "../common/debug.h"
#include "../common/logsys.h"
#include "../common/logtypes.h"
#include "../common/global_define.h"
#include "../common/eqemu_logsys.h"
#include "../common/md5.h"
#include "../common/emu_tcp_connection.h"
#include "../common/packet_functions.h"