Kaynağa Gözat

Merge branch 'master' of https://git.eq2emu.com/devn00b/EQ2EMu

theFoof 1 yıl önce
ebeveyn
işleme
27cc0415c0

+ 0 - 381
EQ2/source/WorldServer/LoginServer.cpp

@@ -89,20 +89,10 @@ LoginServer::LoginServer(const char* iAddress, int16 iPort) {
 	statusupdate_timer = new Timer(LoginServer_StatusUpdateInterval);
 	tcpc = new TCPConnection(false);
 	pTryReconnect = true;
-	try_auto_update = true;
-	updates_always = false;
-	updates_verbose = false;
-	updates_auto_data = false;
-	updates_ask = false;
 	minLockedStatus = 100;
 	maxPlayers = -1;
 	minGameFullStatus = 100;
-	update_server_verified = false;
 	last_checked_time = 0;
-	UpdateServerPort = 0;
-	UpdateServerIP = 0;
-	update_server_completed = false;
-	data_waiting = 0;
 	zone_updates = 0;
 	loginEquip_updates = 0;
 }
@@ -211,29 +201,6 @@ bool LoginServer::Process() {
 
 				break;
 			}
-		case ServerOP_GetTableData:{
-			LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): ServerOP_GetTableData", pack->opcode, pack->opcode);
-
-			uchar* tmp = new uchar[pack->size];
-			memcpy(tmp, pack->pBuffer, pack->size);
-			data_updates_waiting.push_back(tmp);
-			break;
-		}
-		case ServerOP_GetTableQuery:{
-			LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): ServerOP_GetTableQuery", pack->opcode, pack->opcode);
-
-			uchar* tmp = new uchar[pack->size];
-			memcpy(tmp, pack->pBuffer, pack->size);
-			table_updates_waiting.push_back(tmp);
-			break;
-		}
-		case ServerOP_GetLatestTables:{
-			LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): ServerOP_GetLatestTables", pack->opcode, pack->opcode);
-
-			data_waiting = new uchar[pack->size];
-			memcpy(data_waiting, pack->pBuffer, pack->size);
-			break;
-		}
 
 		// Push Character Select "item appearances" to login_equipment table
 		case ServerOP_LoginEquipment:{
@@ -422,24 +389,6 @@ bool LoginServer::Process() {
 			database.ResetDatabase();
 			break;
 		}
-		case UpdateServerOP_Verified:{
-			LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): UpdateServerOP_Verified", pack->opcode, pack->opcode);
-
-			update_server_verified = true;
-			break;
-		}
-		case UpdateServerOP_DisplayMsg:{
-			LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): UpdateServerOP_DisplayMsg", pack->opcode, pack->opcode);
-
-			LogWrite(WORLD__WARNING, 0, "World", "\t%s", pack->pBuffer);
-			break;
-		}
-		case UpdateServerOP_Completed:{
-			LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): UpdateServerOP_Completed", pack->opcode, pack->opcode);
-
-			update_server_completed = true;
-			break;
-		}
 
 		default:
 			{
@@ -494,337 +443,7 @@ void LoginServer::InitLoginServerVariables()
 	minGameFullStatus	= rule_manager.GetGlobalRule(R_World, MaxPlayersOverrideStatus)->GetSInt16();
 }
 
-void LoginServer::ProcessDataUpdate(uchar* data){
-	TableDataQuery data_query;
-	TableQuery table_queries;
-	data_query.DeSerialize(data);
-	string query;
-
-	for(int32 i=0;i<data_query.num_queries;i++)
-	{
-		query = string("replace into ").append(data_query.tablename).append(" ");
-		query.append(data_query.columns).append(" values(").append(data_query.queries[i]->query).append(")\0");
-		char* new_query = new char[query.length() + 1];
-		memset(new_query, 0, query.length() + 1);
-		memcpy(new_query, query.c_str(), query.length());
-		table_queries.AddQuery(new_query);
-	}
-
-	strcpy(table_queries.tablename, data_query.tablename);
-	table_queries.latest_version = data_query.version;
-	string queries = table_queries.GetQueriesString();
-	char answer = 0;
-
-	if(UpdatesAsk() || UpdatesVerbose())
-		LogWrite(INIT__PATCHER_WARNING, 0, "Patcher", "Pending Queries:\n%s", queries.c_str());
-
-	if(!UpdatesAuto() && UpdatesAsk())
-	{
-		LogWrite(INIT__PATCHER_WARNING, 0, "Patcher", "Update to the latest data version? ([Y]es, [N]o, [A]ll)");
-		cin >> answer;
-		if(toupper(answer) == 'A')
-			UpdatesAuto(true);
-	}
-	if(UpdatesAuto() || (answer && toupper(answer) == 'Y'))
-	{
-		bool success = database.RunDatabaseQueries(&table_queries, false, true);
-		string table = string(data_query.tablename);
-		if(table != last_data_update_table)
-		{
-			if(success)
-				LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "\tData Updated: '%s' = SUCCESS!", data_query.tablename);
-			else
-				LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Data Updated: '%s' = FAILED!", data_query.tablename);
-				
-			last_data_update_table = table;
-		}
-	}
-}
-
-void LoginServer::ProcessTableUpdate(uchar* data) {
-	TableQuery table_query;
-	table_query.DeSerialize(data);
-	string queries = table_query.GetQueriesString();
-	char answer = 0;
-	if(UpdatesAsk() || UpdatesVerbose())
-	{
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "\tUpdate Found for '%s'!", table_query.tablename);
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "\tNew Version: %i", table_query.latest_version);
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "\tYour Version: %i", table_query.your_version);
-		LogWrite(INIT__PATCHER_WARNING, 0, "Patcher", "Pending Query:\n%s", queries.c_str());
-	}
-	if(!UpdatesAuto() && UpdatesAsk())
-	{
-		LogWrite(INIT__PATCHER_WARNING, 0, "Patcher", "Update to the latest table version? ([Y]es, [N]o, [A]ll)");
-		cin >> answer;
-		if(toupper(answer) == 'A')
-			UpdatesAuto(true);
-	}
-	if(UpdatesAuto() || (answer && toupper(answer) == 'Y'))
-	{
-		bool success = database.RunDatabaseQueries(&table_query, false);
-		if(success)
-			LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "\tUpdate Table: '%s' = SUCCESS!", table_query.tablename);
-		else
-			LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Update Table: '%s' = FAILED!", table_query.tablename);
-	}
-}
-
-int32 LoginServer::ProcessTableUpdates(uchar* data) {
-	int32 ret = 0;
-	/*LatestTableVersions table_versions;
-	table_versions.DeSerialize(data);
-	int32 total_tables = table_versions.GetTotalTables();
-	
-	int32 max_version = CURRENT_DATABASE_MAJORVERSION*100 + CURRENT_DATABASE_MINORVERSION;
-	LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Max Version: %i", max_version);
-
-	vector<ServerPacket*> packet_requests;
-	ServerPacket* outpack = 0;
-	for(int32 i=0;i<total_tables;i++){
-		float version = database.CheckTableVersions(table_versions.GetTable(i).name);
-		if( (version < table_versions.GetTable(i).version) )
-		{
-			outpack = new ServerPacket(ServerOP_GetTableQuery, sizeof(TableVersion));
-			TableVersion* out_version = (TableVersion*)outpack->pBuffer;
-			strcpy(out_version->name, table_versions.GetTable(i).name);
-			out_version->max_table_version = max_version;
-			out_version->version = (int32)version;
-			out_version->last = 0;
-			packet_requests.push_back(outpack);
-			ret++;
-		}
-	}
-	if( ret )
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Found Table Updates!");
-	else
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--No Table Updates, continuing...");
-
-	int32 total_packets = packet_requests.size();
-	for(int32 i=0;i<total_packets;i++)
-	{
-		outpack = packet_requests[i];
-		if((i+1) == total_packets)
-		{
-			TableVersion* out_version = (TableVersion*)outpack->pBuffer;
-			out_version->last = 1;
-		}
-		SendPacket(outpack);
-		safe_delete(outpack);
-	}*/
-	return ret;
-}
-
-int32 LoginServer::ProcessDataUpdates(uchar* data) {
-	int32 ret = 0;
-	/*LatestTableVersions table_versions;
-	table_versions.DeSerialize(data);
-	int32 total_tables = table_versions.GetTotalTables();
-	vector<ServerPacket*> packet_requests;
-	ServerPacket* outpack = 0;
-	for(int32 i=0;i<total_tables;i++){
-		if(UpdatesAutoData()){
-			float version = database.GetLatestDataTableVersion(table_versions.GetTable(i).name);
-			if(version >= 0 && version < table_versions.GetTable(i).data_version )
-			{
-				ServerPacket* outpack = new ServerPacket(ServerOP_GetTableData, sizeof(TableVersion));
-				TableVersion* out_version = (TableVersion*)outpack->pBuffer;
-				strcpy(out_version->name, table_versions.GetTable(i).name);
-				out_version->max_data_version = CURRENT_DATABASE_MAJORVERSION*100 + CURRENT_DATABASE_MINORVERSION;
-				out_version->data_version = (sint32)version;
-				out_version->last = 0;
-				memset(out_version->column_names, 0, 1000);
-				string columns = database.GetColumnNames(out_version->name);
-				if(columns.length() > 1)
-					strcpy(out_version->column_names, columns.c_str());
-				packet_requests.push_back(outpack);
-				ret++;
-			}
-		}
-	}
-	if( ret )
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Found Data Updates!");
-
-	int32 total_packets = packet_requests.size();
-	for(int32 i=0;i<total_packets;i++)
-	{
-		outpack = packet_requests[i];
-		if((i+1) == total_packets)
-		{
-			TableVersion* out_version = (TableVersion*)outpack->pBuffer;
-			out_version->last = 1;
-		}
-		SendPacket(outpack);
-		safe_delete(outpack);
-	}*/
-	return ret;
-}
 
-bool LoginServer::CheckAndWait(Timer* timer){
-	Timer::SetCurrentTime();
-	if(timer->Check(false)){
-		if(timer->GetDuration() == 5000){
-			LogWrite(INIT__PATCHER_WARNING, 0, "Patcher", "Please wait...");
-			timer->SetTimer(25000);
-			timer->Start();
-		}
-		else
-			return false;
-	}
-	Sleep(10);
-	if(!loginserver.Process())
-		tcpc->Disconnect();
-	return Connected();
-}
-
-bool LoginServer::ConnectToUpdateServer(const char* iAddress, int16 iPort)
-{
-	if(!try_auto_update)
-		return true;
-
-	char errbuf[TCPConnection_ErrorBufferSize];
-	memset(errbuf, 0, TCPConnection_ErrorBufferSize);
-
-	if (iAddress == 0) 
-	{
-		LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "PatchServer::ConnectToUpdateServer: address == 0");
-		return false;
-	}
-	else 
-	{
-		if ((UpdateServerIP = ResolveIP(iAddress, errbuf)) == 0) 
-		{
-			LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "LoginServer::ConnectToUpdateServer: Resolving IP address: '%s'", errbuf[0] == '\0' ? errbuf : " ");
-			return false;
-		}
-	}
-
-	if (iPort != 0)
-		UpdateServerPort = iPort;
-
-	if (UpdateServerIP == 0 || UpdateServerPort == 0) 
-	{
-		LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "PatchServer::ConnectToUpdateServer: Connect info incomplete, cannot connect.");
-		return false;
-	}
-
-	if (tcpc->Connect(UpdateServerIP, UpdateServerPort, errbuf)) 
-	{
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "-Connected to Update Server: %s:%i", iAddress, UpdateServerPort);
-		SendInfo();
-
-		//wait for a max of 30 seconds to be verified by patcher
-		//display a message at 5 seconds
-		Timer waitTimer(5000);
-		waitTimer.Start();
-
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "-Checking for updates.");
-		GetLatestTables();
-
-		while(CheckAndWait(&waitTimer) && !update_server_verified);
-		database.CheckVersionTable();
-
-		if(!update_server_verified)
-			LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Error while getting updates!");
-
-		if(update_server_verified)
-		{
-			update_server_completed = false;
-			waitTimer.SetTimer(5000);
-			waitTimer.Start();
-
-			while(CheckAndWait(&waitTimer) && !data_waiting);
-
-			if(data_waiting)
-			{
-				int32 requests = ProcessTableUpdates(data_waiting);
-
-				if(requests > 0)
-					LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Found Table Updates.");
-
-				uchar* data = 0;
-				waitTimer.SetTimer(30000);
-				waitTimer.Start();
-
-				if(requests > 0)
-				{
-					LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Processing Table Updates.");
-					database.DisableConstraints();
-					deque<uchar*> alter_table_updates_waiting;
-
-					while((CheckAndWait(&waitTimer) && !update_server_completed) || table_updates_waiting.size() > 0)
-					{
-						if(table_updates_waiting.size() > 0)
-						{
-							data = table_updates_waiting.front();
-							table_updates_waiting.pop_front();
-							ProcessTableUpdate(data);
-							safe_delete(data);
-							waitTimer.SetTimer(30000);
-							waitTimer.Start();
-						}
-					}
-
-					if(!CheckAndWait(&waitTimer))
-						LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Timeout waiting for updates to complete! Try again later.");
-					else
-						LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Table Update complete.");
-
-					database.EnableConstraints();
-				}
-				else
-					LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "-No changes to DB Schema...");
-
-				requests = ProcessDataUpdates(data_waiting);
-
-				if(requests > 0)
-				{
-					LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Processing Data Updates.");
-					LogWrite(INIT__PATCHER_WARNING, 0, "Patcher", "** Data Updates are SLOW! Do not abort! **");
-
-					database.DisableConstraints();
-
-					deque<uchar*> alter_table_updates_waiting;
-					int32 count = 0;
-
-					while((CheckAndWait(&waitTimer) && count < requests) || data_updates_waiting.size() > 0)
-					{
-						if(data_updates_waiting.size() > 0)
-						{
-							data = data_updates_waiting.front();
-							data_updates_waiting.pop_front();
-							ProcessDataUpdate(data);
-							count++;
-							safe_delete_array(data);
-							waitTimer.SetTimer(30000);
-							waitTimer.Start();
-						}
-					}
-
-					if(!CheckAndWait(&waitTimer))
-						LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Timeout waiting for updates to complete!  Try again later.");
-					else
-						LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Data Updates complete.");
-
-					database.EnableConstraints();
-				}
-				else
-					LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "-No changes to DB Data...");
-
-				safe_delete_array(data_waiting);
-			}	
-			try_auto_update = false;
-		}
-
-		tcpc->Disconnect();
-		return update_server_verified;
-	}
-	else 
-	{
-		LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "PatchServer::ConnectToUpdateServer: '%s'", errbuf[0] == '\0' ? errbuf : " ");
-		return false;
-	}
-}
 
 bool LoginServer::Connect(const char* iAddress, int16 iPort) {
 	if(!pTryReconnect)

+ 1 - 23
EQ2/source/WorldServer/LoginServer.h

@@ -53,19 +53,6 @@ public:
 	void SendPacket(ServerPacket* pack) { tcpc->SendPacket(pack); }
 	int8 GetState() { return tcpc->GetState(); }
 	bool Connected() { return tcpc->Connected(); }
-	int32 ProcessTableUpdates(uchar* data);
-	int32 ProcessDataUpdates(uchar* data);
-	void ProcessTableUpdate(uchar* data);
-	void ProcessDataUpdate(uchar* data);
-	bool CheckAndWait(Timer* timer);
-	bool UpdatesAuto(){ return updates_always; }
-	void UpdatesAuto(bool val){ updates_always = val; }
-	void UpdatesAsk(bool val){ updates_ask = val; }
-	bool UpdatesAsk(){ return updates_ask; }
-	void UpdatesVerbose(bool val){ updates_verbose = val; }
-	bool UpdatesVerbose(){ return updates_verbose; }
-	void UpdatesAutoData(bool val){ updates_auto_data = val; }
-	bool UpdatesAutoData(){ return updates_auto_data; }
 
 	void SendFilterNameResponse ( int8 resp , int32 acct_id , int32 char_id );
 
@@ -90,17 +77,8 @@ private:
 	int32	LoginServerIP;
 	int32	UpdateServerIP;
 	int16	LoginServerPort;
-	int16	UpdateServerPort;
-	bool updates_ask;
-	bool updates_always;
-	bool updates_verbose;
-	bool updates_auto_data;
-	bool update_server_verified;
-	bool update_server_completed;
+
 	uchar* data_waiting;
-	string last_data_update_table;
-	deque<uchar*> table_updates_waiting;
-	deque<uchar*> data_updates_waiting;
 	MutexMap<int32, LoginZoneUpdate>* zone_updates;
 	MutexMap<int32, LoginEquipmentUpdate>* loginEquip_updates;
 	int32 last_checked_time;

+ 0 - 220
EQ2/source/WorldServer/Patch/buffer.cpp

@@ -1,220 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include "buffer.h"
-
-Buffer::Buffer() {
-    buf = NULL;
-    capacity = 0;
-    len = 0;
-}
-
-Buffer::~Buffer() {
-    if (buf != NULL)
-        free(buf);
-}
-
-unsigned int Buffer::GetLength() {
-    return len;
-}
-
-int Buffer::IndexOf(char c) {
-    unsigned int i;
-
-    for (i = 0; i < len; i++) {
-        if (buf[i] == c)
-            return (int)i;
-    }
-
-    return -1;
-}
-
-void Buffer::Clear() {
-    if (buf != NULL) {
-        free(buf);
-        buf = NULL;
-    }
-    capacity = 0;
-    len = 0;
-}
-
-const char * Buffer::Peek() {
-    return buf;
-}
-
-void Buffer::PeekReadPrimitive(void *buf, unsigned int size, bool peek) {
-    if (len >= size) {
-        memcpy(buf, this->buf, size);
-        if (!peek) {
-            memmove(this->buf, this->buf + size, len - size);
-            len -= size;
-        }
-    }
-}
-
-uint32_t Buffer::PeekUInt32() {
-    uint32_t ret = 0;
-
-    PeekReadPrimitive(&ret, sizeof(ret), true);
-
-    return ret;
-}
-
-unsigned int Buffer::Read(unsigned int len, char **dst) {
-    unsigned int actual = len;
-
-    if (actual > this->len)
-        actual = this->len;
-
-    *dst = (char *)malloc(actual);
-    if (*dst == NULL)
-        return 0;
-
-    return Read(actual, *dst, actual);
-}
-
-unsigned int Buffer::Read(unsigned int len, char *dst, unsigned int size) {
-    unsigned int actual = len;
-
-    if (actual > size)
-        actual = size;
-    if (actual > this->len)
-        actual = this->len;
-
-    memcpy(dst, buf, actual);
-    memmove(buf, buf + actual, this->len - actual);
-    this->len -= actual;
-
-    return actual;
-}
-
-uint32_t Buffer::ReadUInt32() {
-    uint32_t ret = 0;
-
-    PeekReadPrimitive(&ret, sizeof(ret), false);
-
-    return ret;
-}
-
-bool Buffer::Write(const char *data, unsigned int len) {
-    unsigned int new_capacity;
-    char *new_buf;
-
-    while (this->len + len > capacity) {
-        new_capacity = capacity == 0 ? 512 : capacity * 2;
-        new_buf = (char *)realloc(buf, new_capacity);
-        if (new_buf == NULL)
-            return false;
-
-        capacity = new_capacity;
-        buf = new_buf;
-    }
-
-    memcpy(buf + this->len, data, len);
-    this->len += len;
-
-    return true;
-}
-
-bool Buffer::Write(const char *data) {
-    return Write(data, (unsigned int)strlen(data));
-}
-
-bool Buffer::Write(const unsigned char *data, unsigned int len) {
-    return Write((const char *)data, len);
-}
-
-bool Buffer::WriteInt8(int8_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteUInt8(uint8_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteInt16(int16_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteUInt16(uint16_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteInt32(int32_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteUInt32(uint32_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteInt64(int64_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteUInt64(uint64_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteChar(char data) {
-    return Write(&data, sizeof(data));
-}
-
-bool Buffer::WriteDouble(double data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return Write(buf, sizeof(buf));
-}
-
-bool Buffer::WriteAt(unsigned int index, const char *data, unsigned int len) {
-    unsigned int new_capacity;
-    char *new_buf;
-
-    while (this->len + len > capacity) {
-        new_capacity = capacity == 0 ? 512 : capacity * 2;
-        new_buf = (char *)realloc(buf, new_capacity);
-        if (new_buf == NULL)
-            return false;
-
-        capacity = new_capacity;
-        buf = new_buf;
-    }
-
-    memmove(buf + index + len, buf + index, this->len - index);
-    memcpy(buf + index, data, len);
-    this->len += len;
-
-    return true;
-}
-
-bool Buffer::WriteAtUInt32(unsigned int index, uint32_t data) {
-    char buf[sizeof(data)];
-
-    memcpy(buf, &data, sizeof(buf));
-    return WriteAt(index, buf, sizeof(buf));
-}

+ 0 - 46
EQ2/source/WorldServer/Patch/buffer.h

@@ -1,46 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-
-class Buffer {
-public:
-    Buffer();
-    ~Buffer();
-
-    unsigned int GetLength();
-
-    int IndexOf(char c);
-
-    void Clear();
-
-    const char * Peek();
-    uint32_t PeekUInt32();
-
-    unsigned int Read(unsigned int len, char **dst);
-    unsigned int Read(unsigned int len, char *dst, unsigned int size);
-    uint32_t ReadUInt32();
-
-    bool Write(const char *data, unsigned int len);
-    bool Write(const char *data);
-    bool Write(const unsigned char *data, unsigned int len);
-    bool WriteUInt8(uint8_t data);
-    bool WriteInt8(int8_t data);
-    bool WriteUInt16(uint16_t data);
-    bool WriteInt16(int16_t data);
-    bool WriteUInt32(uint32_t data);
-    bool WriteInt32(int32_t data);
-    bool WriteUInt64(uint64_t data);
-    bool WriteInt64(int64_t data);
-    bool WriteChar(char data);
-    bool WriteDouble(double data);
-
-    bool WriteAt(unsigned int index, const char *data, unsigned int len);
-    bool WriteAtUInt32(unsigned int index, uint32_t data);
-
-private:
-    char *buf;
-    unsigned int capacity;
-    unsigned int len;
-
-    void PeekReadPrimitive(void *buf, unsigned int size, bool peek);
-};

+ 0 - 200
EQ2/source/WorldServer/Patch/patch.cpp

@@ -1,200 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <vector>
-#include "../../common/MiscFunctions.h"
-#include "../../common/Log.h"
-#include "buffer.h"
-#include "../WorldDatabase.h"
-#include "../../common/version.h"
-#include "patch.h"
-
-using namespace std;
-
-extern WorldDatabase database;
-extern PatchServer patch;
-
-static void TCPClientDisconnect(TCPClient *tcp) {
-}
-
-static void TCPClientData(TCPClient *tcp, const char *data, unsigned int len) {
-    static FILE *f = NULL;
-
-    if (f == NULL) {
-        if (len == 1) {
-			LogWrite(PATCHER__INFO, 0, "Patcher", "Server is up to date");
-            patch.SetReading(false);
-            return;
-        }
-
-        if (strncmp(data, "ERROR", 5) == 0) {
-			LogWrite(PATCHER__ERROR, 0, "Patcher", "There was an error downloading updates");
-            tcp->Disconnect();
-            patch.SetReading(false);
-            patch.SetQuitAfter(true);
-            return;
-        }
-
-        if (strncmp(data, "SPEED", 5) == 0) {
-			LogWrite(PATCHER__ERROR, 0, "Patcher", "You have tried to download updates too quickly and are now locked out, try again later");
-            tcp->Disconnect();
-            patch.SetReading(false);
-            patch.SetQuitAfter(true);
-            return;
-        }
-
-        if (strncmp(data, "LOCKOUT", 7) == 0) {
-			LogWrite(PATCHER__ERROR, 0, "Patcher", "You are locked out, try again later");
-            tcp->Disconnect();
-            patch.SetReading(false);
-            patch.SetQuitAfter(true);
-            return;
-        }
-
-        if (strncmp(data, "UNKNOWN", 7) == 0) {
-			LogWrite(PATCHER__ERROR, 0, "Patcher", "An unknown error occured");
-            tcp->Disconnect();
-            patch.SetReading(false);
-            patch.SetQuitAfter(true);
-            return;
-        }
-
-        f = fopen("eq2-updates.sql", "wb");
-        if (f == NULL) {
-			LogWrite(PATCHER__ERROR, 0, "Patcher", "Failed to open 'eve-updates.sql' for writing: %s", strerror(errno));
-            tcp->Disconnect();
-            patch.SetReading(false);
-            patch.SetQuitAfter(true);
-            return;
-        }
-
-        fprintf(f, "SET unique_checks=0;\n");
-        fprintf(f, "SET foreign_key_checks=0;\n");
-		LogWrite(PATCHER__INFO, 0, "Patcher", "Downloading updates");
-    }
-
-    if (memchr(data, '\0', len) == NULL)
-        fwrite(data, sizeof(*data), len, f);
-    else {
-        fwrite(data, sizeof(*data), len - 1, f);
-        fprintf(f, "SET foreign_key_checks=1;\n");
-        fprintf(f, "SET unique_checks=1;\n");
-        fclose(f);
-        f = NULL;
-		LogWrite(PATCHER__INFO, 0, "Patcher", "Updates finished downloading");
-
-		LogWrite(PATCHER__INFO, 0, "Patcher", "Executing updates");
-        //database.BeginTransaction();
-        if (!database.QueriesFromFile("eq2-updates.sql")) {
-            //database.RollbackTransaction();
-			LogWrite(PATCHER__INFO, 0, "Patcher", "Failed to update database");
-        }
-        else {
-            //database.CommitTransaction();
-			LogWrite(PATCHER__INFO, 0, "Patcher", "Database updated");
-        }
-        patch.SetReading(false);
-    }
-}
-
-PatchServer::PatchServer() {
-    enabled = true;
-    reading = false;
-    quit_after = false;
-}
-
-PatchServer::~PatchServer() {
-    Stop();
-}
-
-void PatchServer::SetHost(const char *host) {
-    tcp.SetHost(host);
-}
-
-void PatchServer::SetPort(const char *port) {
-    tcp.SetPort(port);
-}
-
-void PatchServer::SetEnabled(bool enabled) {
-    this->enabled = enabled;
-}
-
-void PatchServer::SetReading(bool reading) {
-    this->reading = reading;
-}
-
-void PatchServer::SetQuitAfter(bool quit_after) {
-    this->quit_after = quit_after;
-}
-
-bool PatchServer::IsEnabled() {
-    return enabled;
-}
-
-bool PatchServer::QuitAfter() {
-    return quit_after;
-}
-
-bool PatchServer::Start() {
-    TCPClientCallbacks callbacks;
-    vector<TableVersion *> table_versions;
-    vector<TableVersion *>::iterator itr;
-    Buffer buffer;
-
-    TCP::Start();
-
-    if (!enabled) {
-		LogWrite(PATCHER__INFO, 0, "Patcher", "Skipping check for database updates from the patch server");
-        return true;
-    }
-    
-    callbacks.data = TCPClientData;
-    callbacks.disconnect = TCPClientDisconnect;
-    tcp.SetCallbacks(&callbacks);
-
-    if (!tcp.Start()) {
-		LogWrite(PATCHER__ERROR, 0, "Patcher", "Failed to connect to patch server at %s:%s: %s", tcp.GetHost()[0] == '\0' ? "localhost" : tcp.GetHost(), tcp.GetPort(), tcp.GetError());
-        return false;
-    }
-
-	LogWrite(PATCHER__INFO, 0, "Patcher", "Connected to patch server at %s:%s", tcp.GetHost()[0] == '\0' ? "localhost" : tcp.GetHost(), tcp.GetPort());
-
-    if (!database.GetTableVersions(&table_versions))
-        return false;
-	
-	int32 version = (CURRENT_DATABASE_MAJORVERSION * 100) + CURRENT_DATABASE_MINORVERSION;
-    buffer.WriteUInt32(version);
-    for (itr = table_versions.begin(); itr != table_versions.end(); itr++) {
-        buffer.WriteUInt8((*itr)->name_len);
-        buffer.Write((*itr)->name, (*itr)->name_len);
-        buffer.WriteUInt32((*itr)->version);
-        buffer.WriteUInt32((*itr)->data_version);
-
-        free(*itr);
-    }
-    buffer.WriteAtUInt32(0, buffer.GetLength());
-
-    reading = true;
-
-    return tcp.Queue(buffer.Peek(), buffer.GetLength());
-}
-
-void PatchServer::Stop() {
-    tcp.Stop();
-    TCP::Stop();
-}
-
-bool PatchServer::Process() {
-    bool success = true;
-
-    if (!enabled)
-        return true;
-
-    while (success && reading) {
-        success = tcp.Process(0);
-        SleepMS(10);
-    }
-
-    return success;
-}

+ 0 - 28
EQ2/source/WorldServer/Patch/patch.h

@@ -1,28 +0,0 @@
-#pragma once
-
-#include "tcp-client.h"
-
-class PatchServer {
-public:
-    PatchServer();
-    ~PatchServer();
-
-    void SetHost(const char *host);
-    void SetPort(const char *port);
-    void SetEnabled(bool enabled);
-    void SetReading(bool reading);
-    void SetQuitAfter(bool quit_after);
-
-    bool IsEnabled();
-    bool QuitAfter();
-
-    bool Start();
-    void Stop();
-    bool Process();
-
-private:
-    TCPClient tcp;
-    bool enabled;
-    bool reading;
-    bool quit_after;
-};

+ 0 - 246
EQ2/source/WorldServer/Patch/tcp-client.cpp

@@ -1,246 +0,0 @@
-#include <stdlib.h>
-#include "string.h"
-#include "tcp-client.h"
-#include "../../common/MiscFunctions.h"
-
-TCPClient::TCPClient() {
-    host[0] = '\0';
-    port[0] = '\0';
-    connected = false;
-    memset(&callbacks, 0, sizeof(callbacks));
-    error[0] = '\0';
-    fds.fd = SOCKET_INVALID;
-//    memset(&addr, 0, sizeof(addr));
-//    addr_len = 0;
-    outgoing = NULL;
-    outgoing_size = 0;
-    outgoing_len = 0;
-}
-
-TCPClient::~TCPClient() {
-    Stop();
-}
-
-void TCPClient::SetHost(const char *host) {
-    if (host == NULL)
-        this->host[0] = '\0';
-    else
-        strlcpy(this->host, host, sizeof(this->host));
-}
-
-void TCPClient::SetPort(const char *port) {
-    strlcpy(this->port, port, sizeof(this->port));
-}
-
-void TCPClient::SetCallbacks(TCPClientCallbacks *callbacks) {
-    memcpy(&this->callbacks, callbacks, sizeof(this->callbacks));
-}
-
-const char * TCPClient::GetHost() {
-    return host;
-}
-
-const char * TCPClient::GetPort() {
-    return port;
-}
-
-bool TCPClient::IsConnected() {
-    return connected;
-}
-
-bool TCPClient::HasError() {
-    return error[0] != '\0';
-}
-
-const char * TCPClient::GetError() {
-    return error;
-}
-
-//struct sockaddr_storage * TCPClient::GetAddress() {
-//    return &addr;
-//}
-
-bool TCPClient::Start() {
-    struct addrinfo hints, *server, *p;
-    socket_t fd;
-    int ret;
-
-    if (connected)
-        return true;
-
-    memset(&hints, 0, sizeof(hints));
-    hints.ai_family = AF_INET;
-    hints.ai_socktype = SOCK_STREAM;
-    hints.ai_flags = AI_PASSIVE;
-
-    //get list of networks
-    ret = getaddrinfo(host[0] == '\0' ? NULL : host, port, &hints, &server);
-    if (ret != 0) {
-        strlcpy(error, gai_strerror(ret), sizeof(error));
-        return false;
-    }
-
-    //loop through the addresses and bind to the first one we can
-    for (p = server; p != NULL; p = p->ai_next) {
-        fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
-        if (fd == SOCKET_INVALID) {
-            TCP::StoreError(error, sizeof(error));
-            continue;
-        }
-
-        //connect to the server
-        if (connect(fd, p->ai_addr, (int)p->ai_addrlen) == SOCKET_ERROR) {
-            TCP::StoreError(error, sizeof(error));
-            SOCKET_CLOSE(fd);
-            continue;
-        }
-
-        break;
-    }
-
-    connected = p != NULL;
-
-    if (connected) {
-        fds.fd = fd;
-        fds.events = POLLIN | POLLOUT;
-        fds.revents = 0;
-//        memcpy(&addr, p->ai_addr, sizeof(addr));
-//        addr_len = p->ai_addrlen;
-        error[0] = '\0';
-    }
-
-    freeaddrinfo(server);
-
-    return connected;
-}
-
-void TCPClient::Stop() {
-    if (connected)
-        DisconnectHelper(false);
-}
-
-void TCPClient::DisconnectHelper(bool silent) {
-    if (!silent && callbacks.disconnect != NULL)
-        callbacks.disconnect(this);
-
-    connected = false;
-    error[0] = '\0';
-
-    if (fds.fd != SOCKET_INVALID)
-        SOCKET_CLOSE(fds.fd);
-
-//    memset(&addr, 0, sizeof(addr));
-//    addr_len = 0;
-
-    if (outgoing != NULL) {
-        free(outgoing);
-        outgoing = NULL;
-    }
-    outgoing_size = 0;
-    outgoing_len = 0;
-}
-
-void TCPClient::Disconnect() {
-    DisconnectHelper(true);
-}
-
-bool TCPClient::Read() {
-    char buf[4096];
-    int count;
-
-    count = recv(fds.fd, buf, sizeof(buf), 0);
-
-    if (count == SOCKET_ERROR) {
-        TCP::StoreError(error, sizeof(error));
-        return false;
-    }
-
-    //disconnected
-    if (count == 0) {
-        DisconnectHelper(false);
-        return true;
-    }
-
-    callbacks.data(this, buf, count);
-
-    return true;
-}
-
-bool TCPClient::Write() {
-    int count;
-
-    count = send(fds.fd, outgoing, outgoing_len, 0);
-    if (count == SOCKET_ERROR) {
-        TCP::StoreError(error, sizeof(error));
-        return false;
-    }
-
-    outgoing_len -= count;
-
-    return true;
-}
-
-bool TCPClient::Process(unsigned int timeout) {
-    int count;
-
-    if (!connected)
-        return false;
-
-    count = poll(&fds, 1, timeout);
-
-    if (count == SOCKET_ERROR) {
-        TCP::StoreError(error, sizeof(error));
-        return false;
-    }
-
-    if (fds.revents == 0)
-        return true;
-
-    //socket is bad
-    if (fds.revents & POLLERR) {
-        DisconnectHelper(false);
-        return false;
-    }
-
-    //hung up
-    if (fds.revents & POLLHUP) {
-        DisconnectHelper(false);
-        return false;
-    }
-
-    //socket is ready for reading
-    if (fds.revents & POLLIN) {
-        if (!Read())
-            return false;
-    }
-
-    //socket is ready for writing
-    if (fds.revents & POLLOUT) {
-        if (outgoing_len > 0) {
-            if (!Write())
-                return false;
-        }
-    }
-
-    return true;
-}
-
-bool TCPClient::Queue(const char *buf, unsigned int len) {
-    unsigned int new_size;
-    char *new_outgoing;
-
-    while (outgoing_len + len > outgoing_size) {
-        new_size = outgoing_size == 0 ? 1024 : outgoing_size * 2;
-        new_outgoing = (char *)realloc(outgoing, new_size);
-        if (new_outgoing == NULL)
-            return false;
-
-        outgoing = new_outgoing;
-        outgoing_size = new_size;
-    }
-
-    memcpy(outgoing + outgoing_len, buf, len);
-    outgoing_len += len;
-
-    return true;
-}

+ 0 - 55
EQ2/source/WorldServer/Patch/tcp-client.h

@@ -1,55 +0,0 @@
-#pragma once
-
-#include "tcp.h"
-
-class TCPClient;
-
-typedef void(*TCPClientDisconnectCallback)(TCPClient *);
-typedef void(*TCPClientDataCallback)(TCPClient *, const char *, unsigned int);
-
-typedef struct {
-    TCPClientDisconnectCallback disconnect;
-    TCPClientDataCallback data;
-} TCPClientCallbacks;
-
-class TCPClient {
-public:
-    TCPClient();
-    ~TCPClient();
-
-    void SetHost(const char *host);
-    void SetPort(const char *port);
-    void SetCallbacks(TCPClientCallbacks *callbacks);
-
-    const char * GetHost();
-    const char * GetPort();
-    bool IsConnected();
-    bool HasError();
-
-    const char * GetError();
-//    struct sockaddr_storage * GetAddress();
-
-    bool Start();
-    void Stop();
-    bool Process(unsigned int timeout);
-
-    void Disconnect();
-    bool Queue(const char *buf, unsigned int len);
-
-private:
-    char host[64];
-    char port[16];
-    bool connected;
-    TCPClientCallbacks callbacks;
-    char error[256];
-    struct pollfd fds;
-//    struct sockaddr_storage addr;
-//    socklen_t addr_len;
-    char *outgoing;
-    unsigned int outgoing_size;
-    unsigned int outgoing_len;
-
-    void DisconnectHelper(bool silent);
-    bool Read();
-    bool Write();
-};

+ 0 - 77
EQ2/source/WorldServer/Patch/tcp.cpp

@@ -1,77 +0,0 @@
-#include "stdio.h"
-#include "string.h"
-#if defined(_WIN32)
-#else
-# include <errno.h>
-#endif
-#include "tcp.h"
-
-#include "../../common/MiscFunctions.h"
-
-#if defined(_WIN32)
-static int initialized = 0;
-#endif
-
-bool TCP::Start() {
-#if defined(_WIN32)
-    WSAData wsa;
-
-    //each program only needs to do this once. so if mulitple TCP servers or
-    //clients are being used, we only need to initialize WinSock once
-    if (initialized == 0) {
-        if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
-            return false;
-    }
-
-    ++initialized;
-#endif
-
-    return true;
-}
-
-void TCP::Stop() {
-#if defined(_WIN32)
-    if (initialized > 0) {
-        if (--initialized == 0)
-            WSACleanup();
-    }
-#endif
-}
-
-void TCP::StoreError(char *dst, unsigned int size) {
-#if defined(_WIN32)
-    char *ptr;
-
-    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, WSAGetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&ptr, 0, NULL);
-    strlcpy(dst, ptr, size);
-    LocalFree(ptr);
-
-    ptr = strchr(dst, '\n');
-    if (ptr != NULL)
-        *ptr = '\0';
-#else
-    strlcpy(dst, strerror(errno), size);
-#endif
-}
-
-bool TCP::GetIPAddressString(struct sockaddr_storage *addr, char *host, unsigned int host_size, char *port, unsigned int port_size) {
-    switch (addr->ss_family) {
-        case AF_INET:
-            inet_ntop(AF_INET, &(((struct sockaddr_in *)addr)->sin_addr), host, host_size);
-            if (port != NULL)
-                snprintf(port, port_size, "%u", ((struct sockaddr_in *)addr)->sin_port);
-            break;
-        case AF_INET6:
-            inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)addr)->sin6_addr), host, host_size);
-            if (port != NULL)
-                snprintf(port, port_size, "%u", ((struct sockaddr_in6 *)addr)->sin6_port);
-            break;
-        default:
-            host[0] = '\0';
-            if (port != NULL)
-                port[0] = '\0';
-            break;
-    }
-
-    return host[0] != '\0' && (port == NULL || port[0] != '\0');
-}

+ 0 - 35
EQ2/source/WorldServer/Patch/tcp.h

@@ -1,35 +0,0 @@
-#pragma once
-
-#if defined(_WIN32)
-# include <WinSock2.h>
-# include <WS2tcpip.h>
-# define SOCKET_INVALID                     INVALID_SOCKET
-# define SOCKET_CLOSE(s)                    do {closesocket(s); (s) = SOCKET_INVALID;} while(0)
-# define SOCKET_SOCKOPT_REUSEADDR_CAST(opt) (char *)(&(opt))
-# define poll                               WSAPoll
-typedef SOCKET socket_t;
-typedef BOOL sockopt_reuseaddr_t;
-#else
-# include <unistd.h>
-# include <sys/socket.h>
-# include <sys/poll.h>
-# include <netinet/in.h>
-# include <arpa/inet.h>
-# include <netdb.h>
-# define SOCKET_INVALID                     (-1)
-# define SOCKET_ERROR                       (-1)
-# define SOCKET_CLOSE(s)                    do {close(s); (s) = SOCKET_INVALID;} while(0)
-# define SOCKET_SOCKOPT_REUSEADDR_CAST(opt) (&(opt))
-typedef int socket_t;
-typedef int sockopt_reuseaddr_t;
-#endif
-
-class TCP {
-public:
-    static bool Start();
-    static void Stop();
-
-    static void StoreError(char *dst, unsigned int size);
-
-    static bool GetIPAddressString(struct sockaddr_storage *addr, char *host, unsigned int host_size, char *port, unsigned int port_size);
-};

+ 0 - 123
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -4491,7 +4491,6 @@ void WorldDatabase::LoadPlayerMail(Client* client, bool new_only) {
 				if ( time_sent > Timer::GetUnixTimeStamp() )
 					continue; // should have not been received yet
 
-
 				hasMail = true;
 				Mail* mail = new Mail;
 				mail->mail_id = atoul(row[0]);
@@ -4562,100 +4561,6 @@ void WorldDatabase::GetPetNames(ZoneServer* zone)
 	}
 }
 
-int32 WorldDatabase::CheckTableVersions(char* tablename) {
-	Query query;
-	char* escaped_name = getEscapeString(tablename);
-	LogWrite(INIT__PATCHER_DEBUG, 1, "Patcher", "\tChecking current version for table: %s", tablename);
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT version FROM table_versions WHERE name='%s';", escaped_name);
-	int32 ret_version = 0;
-	if(result && mysql_num_rows(result) > 0)
-	{
-		MYSQL_ROW row;
-		row = mysql_fetch_row(result);
-		ret_version = atoul(row[0]);
-	}
-	safe_delete_array(escaped_name);
-	return ret_version;
-}
-
-bool WorldDatabase::RunDatabaseQueries(TableQuery* queries, bool output_result, bool data){
-	for(int16 i=0;i<queries->num_queries;i++){
-		Query query;
-		if(string(queries->GetQuery(i)).length() > 5)
-			query.RunQuery2(string(queries->GetQuery(i)), Q_UPDATE);
-		if(query.GetErrorNumber() && query.GetError() && query.GetErrorNumber() < 0xFFFFFFFF)
-		{
-			if(output_result)
-				LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "FAILED!");
-			LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Error in updating tables query '%s': %s", query.GetQuery(), query.GetError());
-			return false;
-		}
-	}
-	if(output_result)
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "SUCCESS!");
-	if(data)
-		UpdateDataTableVersion(queries->tablename, queries->latest_version);
-	else
-		UpdateTableVersion(queries->tablename, queries->latest_version);
-	return true;
-}
-
-void WorldDatabase::UpdateDataTableVersion(char* name, int32 version){
-	Query query;
-	char* escaped_name = getEscapeString(name);
-	query.RunQuery2(Q_UPDATE, "update table_versions set download_version=%u where name='%s'", version, escaped_name);
-	if(query.GetErrorNumber() && query.GetError() && query.GetErrorNumber() < 0xFFFFFFFF)
-	{
-		LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Error in updating version table query '%s': %s", query.GetQuery(), query.GetError());
-	}
-	safe_delete_array(escaped_name);
-}
-
-void WorldDatabase::UpdateTableVersion(char* name, int32 version){
-	Query query;
-	char* escaped_name = getEscapeString(name);
-	query.RunQuery2(Q_UPDATE, "INSERT into table_versions (name, version) values('%s', %u) ON DUPLICATE KEY UPDATE version=%u", escaped_name, version, version);
-	if(query.GetErrorNumber() && query.GetError() && query.GetErrorNumber() < 0xFFFFFFFF)
-	{
-		LogWrite(WORLD__ERROR, 0, "Patcher", "Error in updating version table query '%s': %s", query.GetQuery(), query.GetError());
-	}
-	safe_delete_array(escaped_name);
-}
-
-bool WorldDatabase::CheckVersionTable() {
-	Query query;
-
-	// todo: suppress SQL errors while this command is running, because ERROR is normal on a new DB creation (Zcoretri)
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SHOW COLUMNS FROM table_versions");
-	if(result && mysql_num_rows(result) > 0) {
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--DB Schema exists! Checking for updates...");
-		return true;
-	}
-	else {
-		LogWrite(INIT__PATCHER_ERROR, 0, "Patcher", "Version Table NOT Found! Creating...");
-		Query query2;
-		query2.RunQuery2(Q_UPDATE, "CREATE TABLE `table_versions` (`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(64) NOT NULL DEFAULT '',`version` INT(10) UNSIGNED NOT NULL DEFAULT '0',`download_version` INT(10) UNSIGNED NOT NULL DEFAULT '0',PRIMARY KEY  (`id`),UNIQUE KEY `UniqueName` (`name`)) ENGINE=INNODB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;");
-
-		LogWrite(INIT__PATCHER_DEBUG, 0, "Patcher", "--Setting table_version = 1...");
-		Query query3;
-		query3.RunQuery2(Q_INSERT, "INSERT INTO table_versions (name, version) VALUES ('table_versions', 1)");
-	}
-	return false;
-}
-
-sint32 WorldDatabase::GetLatestDataTableVersion(char* name){
-	Query query;
-	char* escaped_name = getEscapeString(name);
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT download_version FROM table_versions where name='%s'", escaped_name);
-	sint32 ret_version = 0;
-	if(result && mysql_num_rows(result) > 0) {
-		MYSQL_ROW row;
-		row = mysql_fetch_row(result);
-		ret_version = atol(row[0]);
-	}
-	safe_delete_array(escaped_name);
-	return ret_version;
-}
 
 int32 WorldDatabase::GetMaxHotBarID(){
 	Query query;
@@ -6112,34 +6017,6 @@ bool WorldDatabase::LocationExists(int32 location_id) {
 	return ret;
 }
 
-bool WorldDatabase::GetTableVersions(vector<TableVersion*>* table_versions) {
-	DatabaseResult result;
-	TableVersion *table_version;
-	bool success;
-
-	//don't treat 1146 (table not found) as an error since the patch server will create it
-	database_new.SetIgnoredErrno(1146);
-
-	success = database_new.Select(&result, "SELECT `name`,`version`,`download_version`\n"
-										   "FROM `table_versions`\n");
-	
-	database_new.RemoveIgnoredErrno(1146);
-
-	if (!success)
-		return false;
-
-	while (result.Next()) {
-		table_version = (TableVersion *)malloc(sizeof(*table_version));
-		table_version->name_len = (unsigned int)strlcpy(table_version->name, result.GetString(0), sizeof(table_version->name));
-		table_version->version = result.GetInt32(1);
-		table_version->data_version = result.GetInt32(2);
-
-		table_versions->push_back(table_version);
-	}
-
-	return true;
-}
-
 bool WorldDatabase::QueriesFromFile(const char * file) {
 	return database_new.QueriesFromFile(file);
 }

+ 1 - 79
EQ2/source/WorldServer/net.cpp

@@ -86,8 +86,6 @@ LuaInterface* lua_interface = new LuaInterface();
 #include "Languages.h"
 #include "Achievements/Achievements.h"
 
-#include "Patch/patch.h"
-
 volatile bool RunLoops = true;
 sint32 numclients = 0;
 sint32 numzones = 0;
@@ -110,7 +108,7 @@ MasterLanguagesList master_languages_list;
 ChestTrapList chest_trap_list;
 extern MasterAchievementList master_achievement_list;
 extern map<int16, int16> EQOpcodeVersions;
-PatchServer patch;
+
 
 ThreadReturnType ItemLoad (void* tmp);
 ThreadReturnType AchievmentLoad (void* tmp);
@@ -166,28 +164,7 @@ int main(int argc, char** argv) {
 	srand(time(NULL));
 
 	net.ReadLoginINI();
-	if(loginserver.UpdatesAuto() || loginserver.UpdatesAsk() || loginserver.UpdatesAutoData()){
-		LogWrite(INIT__PATCHER_INFO, 0, "Patcher", "Connecting to DB PatchServer...");
-		// Old DB patch server
-		/*int16 updateport = 0;
-		char* updateaddress = net.GetUpdateServerInfo(&updateport);
-		loginserver.ConnectToUpdateServer(updateaddress, updateport);
-		LogWrite(INIT__PATCHER_INFO, 0, "Patcher", "DB Update check completed...");*/
-
 		
-		//New patch server
-		if (!patch.IsEnabled())
-			LogWrite(INIT__PATCHER_INFO, 0, "Patcher", "Not checking patch server for updates");
-		else {
-			bool success = patch.Start();
-			if (success)
-				success = patch.Process();
-			patch.Stop();
-			//if (patch.QuitAfter())
-				//looping = false;
-		}
-	}
-	
 	// JA: Grouping all System (core) data loads together for timing purposes
 	LogWrite(WORLD__INFO, 0, "World", "Loading System Data...");
 	int32 t_now = Timer::GetUnixTimeStamp();
@@ -731,20 +708,6 @@ bool NetConnection::ReadLoginINI() {
 					strncpy (worldaddress, buf, 250);
 				}
 			}
-			if (!strncasecmp(type, "autotableupdates", 16)) {
-				if(strlen(buf) >= 3 && !strncasecmp(buf, "ask", 3))
-					loginserver.UpdatesAsk(true);
-				else if(strlen(buf) >= 6 && !strncasecmp(buf, "always", 6))
-					loginserver.UpdatesAuto(true);
-			}
-			if (!strncasecmp (type, "autotableverbose", 16)) {
-				if(strlen(buf) >= 4 && !strncasecmp(buf, "true", 4))
-					loginserver.UpdatesVerbose(true);
-			}
-			if (!strncasecmp (type, "autotabledata", 13)) {
-				if(strlen(buf) >= 4 && !strncasecmp(buf, "true", 4))
-					loginserver.UpdatesAutoData(true);
-			}
 			if (!strncasecmp (type, "internalworldaddress", 20)) {
 				if (strlen(buf) >= 3) {
 					strncpy(internalworldaddress, buf, 20);
@@ -828,52 +791,11 @@ bool NetConnection::ReadLoginINI() {
 	}
 	fclose (f);
 
-	f=fopen (MAIN_INI_FILE, "r");
-	do {
-		if (fgets (buf, 200, f) == NULL || feof(f))
-		{
-			LogWrite(INIT__ERROR, 0, "Init", "[UpdateServer] block not found in %s", MAIN_INI_FILE);
-			fclose (f);
-			return true;
-		}
-
-	}
-	while (strncasecmp (buf, "[UpdateServer]\n", 15) != 0 && strncasecmp (buf, "[UpdateServer]\r\n", 16) != 0);
-
-	while (!feof (f))
-	{
-#ifdef WIN32
-		if (fscanf (f, "%[^=]=%[^\n]\r\n", type, buf) == 2)
-#else
-		if (fscanf (f, "%[^=]=%[^\r\n]\n", type, buf) == 2)
-#endif
-		{
-			if (!strcasecmp(type, "updateserveraddress")) {
-				strncpy (updateaddress, buf, 250);
-				patch.SetHost(buf);
-			}
-			if (!strcasecmp(type, "updateserverport")) {
-				updateport=atoi(buf);
-				patch.SetPort(buf);
-			}
-		}
-	}
-	fclose (f);
-	
 	LogWrite(INIT__DEBUG, 0, "Init", "%s read...", MAIN_INI_FILE);
 	LoginServerInfo=1;
 	return true;
 }
 
-char* NetConnection::GetUpdateServerInfo(int16* oPort) {
-	if (oPort == 0)
-		return 0;
-	if (updateaddress[0] == 0)
-		return 0;
-
-	*oPort = updateport;
-	return updateaddress;
-}
 
 char* NetConnection::GetLoginInfo(int16* oPort) {
 	if (oPort == 0)

+ 0 - 5
EQ2/source/WorldServer/net.h

@@ -54,9 +54,7 @@ public:
 			loginport[i] = LOGIN_PORT;
 		}
 		listening_socket = 0;
-		updateport = 0;
 		memset(worldname, 0, sizeof(worldname));
-		memset(updateaddress, 0, sizeof(updateaddress));
 		memset(worldaccount, 0, sizeof(worldaccount));
 		memset(worldpassword, 0, sizeof(worldpassword));
 		memset(worldaddress, 0, sizeof(worldaddress));
@@ -74,7 +72,6 @@ public:
 	bool LoginServerInfo;
 	bool UpdateStats;
 	char* GetLoginInfo(int16* oPort);
-	char* GetUpdateServerInfo(int16* oPort);
 	inline char* GetLoginAddress(int8 i)	{ return loginaddress[i]; }
 	inline int16 GetLoginPort(int8 i)		{ return loginport[i]; }
 	inline char* GetWorldName()			{ return worldname; }
@@ -88,9 +85,7 @@ public:
 private:
 	int		listening_socket;
 	char	loginaddress[3][255];
-	char	updateaddress[255];
 	int16	loginport[3];
-	int16	updateport;
 	char	worldname[201];
 	char	worldaccount[31];
 	char	worldpassword[31];