Removed IRC system. It was no longer used.
This commit is contained in:
parent
562e914f26
commit
742f91c50f
20 changed files with 4 additions and 1513 deletions
|
@ -22,10 +22,8 @@
|
|||
#include "../../common/Log.h"
|
||||
#include "../../common/ConfigReader.h"
|
||||
#include "../../common/PacketStruct.h"
|
||||
#include "../IRC/IRC.h"
|
||||
|
||||
extern ConfigReader configReader;
|
||||
extern IRC irc;
|
||||
|
||||
Chat::Chat() {
|
||||
m_channels.SetName("Chat::Channels");
|
||||
|
@ -273,27 +271,6 @@ bool Chat::TellChannel(Client *client, const char *channel_name, const char *mes
|
|||
else
|
||||
ret = (*itr)->TellChannel(client, message, name);
|
||||
|
||||
// if client = null then it came from irc, don't send it back to irc
|
||||
if (client) {
|
||||
IRCServer* server = 0;
|
||||
bool global = false;
|
||||
string msg;
|
||||
const char* safe_name = irc.GetSafeChannelName(channel_name);
|
||||
|
||||
// If global irc channel add "PlayerName says: " to the begining of the message
|
||||
if ((*itr)->IsGlobalIRCChannel()) {
|
||||
server = irc.GetGlobalServer();
|
||||
msg = string(client->GetPlayer()->GetName()) + string(" says: ") + string(message);
|
||||
global = true;
|
||||
}
|
||||
else
|
||||
server = irc.GetServer(client);
|
||||
|
||||
// if global channel don't send a client and send the modified message
|
||||
if (server && server->GetChannel(safe_name))
|
||||
irc.Say(global ? 0 : client, channel_name, global ? msg.c_str() : message);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ ChatChannel::ChatChannel() {
|
|||
level_restriction = 0;
|
||||
races = 0;
|
||||
classes = 0;
|
||||
m_globalIRCChannel = false;
|
||||
}
|
||||
|
||||
ChatChannel::~ChatChannel() {
|
||||
|
|
|
@ -33,8 +33,7 @@ using namespace std;
|
|||
enum ChatChannelType {
|
||||
CHAT_CHANNEL_TYPE_NONE = 0,
|
||||
CHAT_CHANNEL_TYPE_WORLD,
|
||||
CHAT_CHANNEL_TYPE_CUSTOM,
|
||||
CHAT_CHANNEL_TYPE_IRC
|
||||
CHAT_CHANNEL_TYPE_CUSTOM
|
||||
};
|
||||
|
||||
class ChatChannel {
|
||||
|
@ -66,8 +65,6 @@ public:
|
|||
bool TellChannelClient(Client* to_client, const char* message, const char* name2 = 0);
|
||||
bool SendChannelUserList(Client *client);
|
||||
|
||||
void SetGlobalIRCChannel(bool val) { m_globalIRCChannel = val; }
|
||||
bool IsGlobalIRCChannel() { return m_globalIRCChannel; }
|
||||
|
||||
private:
|
||||
char name[CHAT_CHANNEL_MAX_NAME + 1];
|
||||
|
@ -77,7 +74,6 @@ private:
|
|||
int16 level_restriction;
|
||||
int64 races;
|
||||
int64 classes;
|
||||
bool m_globalIRCChannel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// JA: for when we add world channel or IRC configs
|
||||
|
||||
#include "../../common/Log.h"
|
||||
#include "Chat.h"
|
||||
|
|
|
@ -41,7 +41,6 @@ along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "../../common/Log.h"
|
||||
#include "../../common/MiscFunctions.h"
|
||||
#include "../Languages.h"
|
||||
#include "../IRC/IRC.h"
|
||||
#include "../Traits/Traits.h"
|
||||
#include "../Chat/Chat.h"
|
||||
#include "../Rules/Rules.h"
|
||||
|
@ -68,7 +67,6 @@ extern MasterSkillList master_skill_list;
|
|||
extern MasterFactionList master_faction_list;
|
||||
extern GuildList guild_list;
|
||||
extern MasterLanguagesList master_languages_list;
|
||||
extern IRC irc;
|
||||
extern Chat chat;
|
||||
extern RuleManager rule_manager;
|
||||
extern MasterAAList master_aa_list;
|
||||
|
@ -5398,7 +5396,6 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
|
|||
case COMMAND_LOCATION_REMOVE : { Command_LocationRemove(client, sep); break; }
|
||||
case COMMAND_GRID : { Command_Grid(client); break; }
|
||||
case COMMAND_TRY_ON : { Command_TryOn(client, sep); break; }
|
||||
case COMMAND_IRC : { Command_IRC(client, sep); break; }
|
||||
case COMMAND_RANDOMIZE : { Command_Randomize(client, sep); break; }
|
||||
case COMMAND_AFK : { Command_AFK(client, sep); break; }
|
||||
case COMMAND_SHOW_CLOAK : { Command_ShowCloak(client, sep); break; }
|
||||
|
@ -6942,59 +6939,6 @@ void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteComma
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
Function: Command_IRC()
|
||||
Purpose : Handle the IRC functions
|
||||
Params : IRC Commands
|
||||
Dev : Scatman
|
||||
Example : /irc say #Channel Hello World!
|
||||
*/
|
||||
void Commands::Command_IRC(Client* client, Seperator* sep)
|
||||
{
|
||||
if (!rule_manager.GetGlobalRule(R_World, IRCEnabled)->GetBool()) {
|
||||
client->SimpleMessage(CHANNEL_STATUS, "IRC is currently disabled on this server");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sep && sep->arg[0][0]) {
|
||||
if (strcasecmp(sep->arg[0], "say") == 0) {
|
||||
if (sep->arg[1][0] && sep->arg[2][0]) {
|
||||
if (sep->IsNumber(sep->arg[1]))
|
||||
irc.Say(client, atoul(sep->arg[1]), sep->argplus[2]);
|
||||
else
|
||||
irc.Say(client, sep->arg[1], sep->argplus[2]);
|
||||
}
|
||||
else
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc say <channel name | channel index> <message>");
|
||||
}
|
||||
else if (strcasecmp(sep->arg[0], "join") == 0) {
|
||||
if (sep->arg[1][0])
|
||||
irc.JoinChannel(client, sep->arg[1]);
|
||||
else
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc join <channel name>");
|
||||
}
|
||||
else if (strcasecmp(sep->arg[0], "leave") == 0) {
|
||||
if (sep->arg[1][0])
|
||||
irc.LeaveChannel(client, sep->arg[1]);
|
||||
else
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc leave <channel name>");
|
||||
}
|
||||
else if (strcasecmp(sep->arg[0], "list") == 0)
|
||||
irc.ListChannels(client);
|
||||
else if (strcasecmp(sep->arg[0], "connect") == 0) {
|
||||
if (sep->arg[1][0] && sep->arg[2][0] && sep->IsNumber(2))
|
||||
irc.ConnectToServer(client, sep->arg[1], atoi(sep->arg[2]), sep->arg[3]);
|
||||
else
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Usage: /irc connect <host> <port> (nick)");
|
||||
}
|
||||
else if (strcasecmp(sep->arg[0], "disconnect") == 0)
|
||||
irc.DisconnectFromServer(client);
|
||||
else
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
|
||||
}
|
||||
else
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Unknown IRC command.");
|
||||
}
|
||||
/*
|
||||
Function: Command_Languages()
|
||||
Purpose : Show's languages the player knows
|
||||
|
|
|
@ -324,7 +324,6 @@ public:
|
|||
void Command_GuildsRemove(Client* client, Seperator* sep);
|
||||
void Command_InspectPlayer(Client* client, Seperator* sep);
|
||||
void Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteCommandString* command);
|
||||
void Command_IRC(Client* client, Seperator* sep);
|
||||
void Command_Languages(Client* client, Seperator* sep);
|
||||
void Command_SetLanguage(Client* client, Seperator* sep);
|
||||
void Command_LastName(Client* client, Seperator* sep);
|
||||
|
@ -862,7 +861,6 @@ private:
|
|||
#define COMMAND_TITLE_FIX 289
|
||||
#define COMMAND_LANGUAGES 290
|
||||
#define COMMAND_SET_LANGUAGE 291
|
||||
#define COMMAND_IRC 292
|
||||
#define COMMAND_ACCEPT_ADVANCEMENT 293
|
||||
|
||||
#define COMMAND_JOIN_CHANNEL 294
|
||||
|
|
|
@ -1,539 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#ifdef _WIN32
|
||||
#include <WinSock2.h>
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include "../../common/unix.h"
|
||||
#endif
|
||||
#include "IRCReplyCodes.h"
|
||||
#include "IRC.h"
|
||||
#include "../Chat/Chat.h"
|
||||
#include "../../common/Log.h"
|
||||
#include "../Rules/Rules.h"
|
||||
|
||||
extern Chat chat;
|
||||
extern RuleManager rule_manager;
|
||||
|
||||
IRC::IRC() {
|
||||
running = false;
|
||||
m_globalServer = 0;
|
||||
m_servers.SetName("IRC::servers");
|
||||
}
|
||||
|
||||
IRC::~IRC() {
|
||||
map<int32, IRCServer *>::iterator itr;
|
||||
|
||||
m_servers.writelock(__FUNCTION__, __LINE__);
|
||||
for (itr = servers.begin(); itr != servers.end(); itr++)
|
||||
safe_delete(itr->second);
|
||||
m_servers.releasewritelock(__FUNCTION__, __LINE__);
|
||||
|
||||
safe_delete(m_globalServer);
|
||||
}
|
||||
|
||||
ThreadReturnType ServerLoop(void *arg);
|
||||
|
||||
void IRC::Start() {
|
||||
if (running)
|
||||
return;
|
||||
|
||||
running = true;
|
||||
#ifdef _WIN32
|
||||
_beginthread(ServerLoop, 0, this);
|
||||
#else
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, ServerLoop, this);
|
||||
pthread_detach(thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32 IRC::GetNumServers() {
|
||||
int32 count;
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
count = servers.size();
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
const char * IRC::GetSafeChannelName(const char *channel_name) {
|
||||
char *safe_channel_name;
|
||||
size_t len;
|
||||
|
||||
assert(channel_name != NULL);
|
||||
|
||||
len = strlen(channel_name) + 2;
|
||||
safe_channel_name = new char[len];
|
||||
if (channel_name[0] != '#')
|
||||
snprintf(safe_channel_name, len, "#%s", channel_name);
|
||||
else
|
||||
strncpy(safe_channel_name, channel_name, len);
|
||||
|
||||
return safe_channel_name;
|
||||
}
|
||||
|
||||
void IRC::ConnectToServer(Client *client, const char *host, short port, const char *nick) {
|
||||
int32 character_id;
|
||||
IRCServer *server;
|
||||
int ret;
|
||||
|
||||
assert(client != NULL);
|
||||
assert(host != NULL);
|
||||
|
||||
character_id = client->GetCharacterID();
|
||||
|
||||
m_servers.writelock(__FUNCTION__, __LINE__);
|
||||
if (servers.count(character_id) > 0)
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You are already connected to IRC server %s.", servers[character_id]->GetHost());
|
||||
else {
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "Connecting to IRC server %s:%i.", host, port);
|
||||
server = new IRCServer(character_id, host, port, nick == NULL || strlen(nick) == 0 ? client->GetPlayer()->GetName() : nick);
|
||||
ret = server->Connect();
|
||||
|
||||
switch (ret) {
|
||||
case IRC_CONNECT_SUCCESS:
|
||||
servers[character_id] = server;
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Successfully connected to IRC server!");
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can now join channels on this server using /irc join <channel name>.");
|
||||
break;
|
||||
case IRC_CONNECT_ALREADY_CONNECTED:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already connected to this IRC server!");
|
||||
break;
|
||||
case IRC_CONNECT_NO_NICK:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. A nick was never given.");
|
||||
break;
|
||||
case IRC_CONNECT_WINSOCK_INIT:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. Failed to initailize Winsock.");
|
||||
break;
|
||||
case IRC_CONNECT_WINSOCK_VERSION:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. Winsock version 2.2 was not found. Contact your EQ2Emu server administrator.");
|
||||
break;
|
||||
case IRC_CONNECT_SOCKET:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. Failed to create a socket.");
|
||||
break;
|
||||
case IRC_CONNECT_NO_HOST:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. That host does not exist.");
|
||||
break;
|
||||
case IRC_CONNECT_FAIL:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. Failed to connect.");
|
||||
break;
|
||||
case IRC_CONNECT_SOCKET_OPT:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. Could not set socket options.");
|
||||
break;
|
||||
default:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "Could not connect to IRC server. Unknown error (%i).", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_servers.releasewritelock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
void IRC::ConnectToGlobalServer(const char *host, short port, const char *nick) {
|
||||
IRCServer* server = 0;
|
||||
ChatChannel* channel = 0;
|
||||
const char* channel_name = 0;
|
||||
int ret;
|
||||
|
||||
assert(host != NULL);
|
||||
assert(nick != NULL);
|
||||
|
||||
if (m_globalServer)
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "You are already connected to the global IRC server %s.", m_globalServer->GetHost());
|
||||
else {
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Connecting to IRC server %s:%i.", host, port);
|
||||
server = new IRCServer(host, port, nick);
|
||||
ret = server->Connect();
|
||||
|
||||
switch (ret) {
|
||||
case IRC_CONNECT_SUCCESS:
|
||||
m_globalServer = server;
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Successfully connected to the global IRC server!");
|
||||
|
||||
// Get the global irc channel
|
||||
channel_name = rule_manager.GetGlobalRule(R_World, IRCChan)->GetString();
|
||||
// Join the channel
|
||||
m_globalServer->JoinChannel(channel_name);
|
||||
|
||||
// Remove the leading # if there was one
|
||||
if (channel_name[0] == '#')
|
||||
channel_name++;
|
||||
|
||||
// Check to see if a EQ2 chat channel exists, if not create it
|
||||
if (!chat.ChannelExists(channel_name)) {
|
||||
//chat.CreateChannel(channel_name);
|
||||
ChatChannel* new_channel = new ChatChannel();
|
||||
new_channel->SetName(channel_name);
|
||||
|
||||
new_channel->SetLevelRestriction(0);
|
||||
new_channel->SetClassesAllowed(0);
|
||||
new_channel->SetRacesAllowed(0);
|
||||
new_channel->SetType(CHAT_CHANNEL_TYPE_WORLD);
|
||||
|
||||
chat.AddChannel(new_channel);
|
||||
}
|
||||
|
||||
// Get the EQ2 Channel
|
||||
channel = chat.GetChannel(channel_name);
|
||||
// Make sure we got the channel
|
||||
if (channel) {
|
||||
// Set the channel as the global IRC channel
|
||||
channel->SetGlobalIRCChannel(true);
|
||||
}
|
||||
else {
|
||||
// "Should" never end up here as we make sure the channel exists before we get it, send an error if we do end up in here some how
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Unable to set the global IRC channel");
|
||||
}
|
||||
|
||||
break;
|
||||
case IRC_CONNECT_ALREADY_CONNECTED:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "You are already connected to the global IRC server!");
|
||||
safe_delete(server);
|
||||
break;
|
||||
case IRC_CONNECT_NO_NICK:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. A nick was never given.");
|
||||
safe_delete(server);
|
||||
break;
|
||||
case IRC_CONNECT_WINSOCK_INIT:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. Failed to initailize Winsock.");
|
||||
safe_delete(server);
|
||||
break;
|
||||
case IRC_CONNECT_WINSOCK_VERSION:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. Winsock version 2.2 was not found. Contact your EQ2Emu server administrator.");
|
||||
safe_delete(server);
|
||||
break;
|
||||
case IRC_CONNECT_SOCKET:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. Failed to create a socket.");
|
||||
safe_delete(server);
|
||||
break;
|
||||
case IRC_CONNECT_NO_HOST:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. That host does not exist.");
|
||||
safe_delete(server);
|
||||
break;
|
||||
case IRC_CONNECT_FAIL:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. Failed to connect.");
|
||||
safe_delete(server);
|
||||
break;
|
||||
case IRC_CONNECT_SOCKET_OPT:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. Could not set socket options.");
|
||||
safe_delete(server);
|
||||
break;
|
||||
default:
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Could not connect to global IRC server. Unknown error (%i).", ret);
|
||||
safe_delete(server);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IRC::DisconnectFromServer(Client *client) {
|
||||
IRCServer *server;
|
||||
int32 character_id;
|
||||
|
||||
assert(client != NULL);
|
||||
|
||||
character_id = client->GetCharacterID();
|
||||
|
||||
m_servers.writelock(__FUNCTION__, __LINE__);
|
||||
if (servers.count(character_id) == 0)
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not connected to an IRC server!");
|
||||
else {
|
||||
server = servers[character_id];
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You have been disconnected from IRC server %s.", server->GetHost());
|
||||
server->Disconnect();
|
||||
safe_delete(server);
|
||||
servers.erase(character_id);
|
||||
}
|
||||
m_servers.releasewritelock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
void IRC::DisconnectFromGlobalServer() {
|
||||
if (!m_globalServer)
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "You are not connected to a global IRC server!");
|
||||
else {
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "You have been disconnected from the global IRC server (%s).", m_globalServer->GetHost());
|
||||
m_globalServer->Disconnect();
|
||||
safe_delete(m_globalServer);
|
||||
}
|
||||
}
|
||||
|
||||
void IRC::JoinChannel(Client *client, const char *channel_name) {
|
||||
const char *safe_channel_name;
|
||||
int32 character_id;
|
||||
int ret;
|
||||
|
||||
assert(client != NULL);
|
||||
assert(channel_name != NULL);
|
||||
|
||||
character_id = client->GetCharacterID();
|
||||
|
||||
//if the user didn't include a hash in the channel name, add it
|
||||
safe_channel_name = GetSafeChannelName(channel_name);
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
if (servers.count(character_id) == 0)
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not connected to an IRC server!");
|
||||
else {
|
||||
ret = servers[character_id]->JoinChannel(safe_channel_name);
|
||||
|
||||
switch (ret) {
|
||||
case IRC_JOIN_CHANNEL_SUCCESS:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "Joining IRC channel %s.", safe_channel_name);
|
||||
if (channel_name[0] == '#')
|
||||
channel_name++;
|
||||
|
||||
if (!chat.ChannelExists(channel_name))
|
||||
chat.CreateChannel(channel_name);
|
||||
if (!chat.IsInChannel(client, channel_name))
|
||||
chat.JoinChannel(client, channel_name);
|
||||
|
||||
break;
|
||||
case IRC_JOIN_CHANNEL_ALREADY_IN:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are already in that IRC channel!");
|
||||
break;
|
||||
default:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "Error joining channel. Unknown error (%i).", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
||||
safe_delete_array(safe_channel_name);
|
||||
}
|
||||
|
||||
void IRC::LeaveChannel(Client *client, const char *channel_name) {
|
||||
const char *safe_channel_name;
|
||||
int32 character_id;
|
||||
int ret;
|
||||
|
||||
assert(client != NULL);
|
||||
assert(channel_name != NULL);
|
||||
|
||||
character_id = client->GetCharacterID();
|
||||
|
||||
//if the user didn't include a hash in the channel name, add it
|
||||
safe_channel_name = GetSafeChannelName(channel_name);
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
if (servers.count(character_id) == 0)
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not connected to an IRC server!");
|
||||
else {
|
||||
ret = servers[character_id]->LeaveChannel(safe_channel_name);
|
||||
|
||||
switch (ret) {
|
||||
case IRC_LEAVE_CHANNEL_SUCCESS:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You have left IRC channel %s.", safe_channel_name);
|
||||
break;
|
||||
case IRC_LEAVE_CHANNEL_NOT_IN:
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not in that IRC channel.");
|
||||
break;
|
||||
default:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "Error leaving channel. Unknown error (%i).", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
||||
safe_delete_array(safe_channel_name);
|
||||
}
|
||||
|
||||
void IRC::ListChannels(Client *client) {
|
||||
vector<IRCChannel *> *channels;
|
||||
vector<IRCChannel *>::iterator itr;
|
||||
IRCServer *server;
|
||||
int32 character_id, i;
|
||||
|
||||
assert(client != NULL);
|
||||
|
||||
character_id = client->GetCharacterID();
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
if (servers.count(character_id) == 0)
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not connected to an IRC server!");
|
||||
else {
|
||||
server = servers[character_id];
|
||||
channels = server->GetChannels();
|
||||
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "IRC Channels you are logged into on %s:", server->GetHost());
|
||||
if (channels->size() == 0)
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, " None");
|
||||
else {
|
||||
i = 1;
|
||||
for (itr = channels->begin(); itr != channels->end(); itr++)
|
||||
client->Message(CHANNEL_COLOR_YELLOW, " %i) %s", i++, ((*itr)->GetName()));
|
||||
}
|
||||
}
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
void IRC::Say(Client *client, const char *channel_name, const char *message) {
|
||||
const char *safe_channel_name;
|
||||
int32 character_id;
|
||||
int ret;
|
||||
IRCServer* server = 0;
|
||||
|
||||
assert(channel_name != NULL);
|
||||
assert(message != NULL);
|
||||
|
||||
if (client)
|
||||
character_id = client->GetCharacterID();
|
||||
|
||||
//if the user didn't include a hash in the channel name, add it
|
||||
safe_channel_name = GetSafeChannelName(channel_name);
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
if (!m_globalServer && servers.count(character_id) == 0) {
|
||||
if (client)
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not connected to an IRC server!");
|
||||
else
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Not connected to a global IRC server");
|
||||
}
|
||||
else {
|
||||
if (client)
|
||||
server = servers[character_id];
|
||||
else
|
||||
server = m_globalServer;
|
||||
|
||||
ret = server->Say(safe_channel_name, message);
|
||||
|
||||
switch (ret) {
|
||||
case IRC_SAY_SUCCESS:
|
||||
//client->Message(CHANNEL_COLOR_YELLOW, "You say to %s, \"%s\"", safe_channel_name, message);
|
||||
break;
|
||||
case IRC_SAY_NOT_IN:
|
||||
if (client)
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You are not in channel %s. Use /irc list to see what channels you are in.", safe_channel_name);
|
||||
else
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Global IRC does not contain the channel %s.", safe_channel_name);
|
||||
break;
|
||||
default:
|
||||
if (client)
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "Error sending message to %s. Unknown error (%i).", safe_channel_name, ret);
|
||||
else
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Error sending message to %s. Unknown error (%i).", safe_channel_name, ret);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
||||
safe_delete_array(safe_channel_name);
|
||||
}
|
||||
|
||||
void IRC::Say(Client *client, int32 channel_index, const char *message) {
|
||||
IRCChannel *channel;
|
||||
int32 character_id;
|
||||
int ret;
|
||||
|
||||
assert(client != NULL);
|
||||
assert(message != NULL);
|
||||
|
||||
character_id = client->GetCharacterID();
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
if (servers.count(character_id) == 0)
|
||||
client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not connected to an IRC server!");
|
||||
else {
|
||||
ret = servers[character_id]->Say(channel_index, message);
|
||||
channel = servers[character_id]->GetChannel(channel_index);
|
||||
|
||||
switch (ret) {
|
||||
case IRC_SAY_SUCCESS:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You say to %s, \"%s\"", channel->GetName(), message);
|
||||
break;
|
||||
case IRC_SAY_NOT_IN:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You are not in a channel at index %u. Use /irc list to see what channels you are in.", channel_index);
|
||||
break;
|
||||
default:
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "Error sending message to channel at index %i. Unknown error (%i).", channel_index, ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
void IRC::Process() {
|
||||
map<int32, IRCServer *>::iterator itr;
|
||||
vector<int32> removes;
|
||||
vector<int32>::iterator itr_removes;
|
||||
int32 character_id;
|
||||
IRCServer *server;
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
for (itr = servers.begin(); itr != servers.end(); itr++) {
|
||||
server = itr->second;
|
||||
if (server->IsConnected()) {
|
||||
|
||||
//if this connection fails to process, disconnect it
|
||||
if (!server->Process())
|
||||
removes.push_back(itr->first);
|
||||
}
|
||||
}
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
||||
// Process the global irc server if there is one
|
||||
if (m_globalServer && m_globalServer->IsConnected())
|
||||
m_globalServer->Process();
|
||||
|
||||
//process any bad connections
|
||||
if (removes.size() > 0) {
|
||||
m_servers.writelock(__FUNCTION__, __LINE__);
|
||||
for (itr_removes = removes.begin(); itr_removes != removes.end(); itr_removes++) {
|
||||
character_id = *itr_removes;
|
||||
|
||||
if (servers.count(character_id) > 0) {
|
||||
safe_delete(servers[character_id]);
|
||||
servers.erase(character_id);
|
||||
}
|
||||
}
|
||||
m_servers.releasewritelock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
ThreadReturnType ServerLoop(void *arg) {
|
||||
IRC *irc = (IRC *)arg;
|
||||
|
||||
while (irc->IsRunning()) {
|
||||
irc->Process();
|
||||
|
||||
if (irc->GetNumServers() == 0)
|
||||
Sleep(1000);
|
||||
else
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
THREAD_RETURN(NULL);
|
||||
}
|
||||
|
||||
IRCServer* IRC::GetServer(Client* client) {
|
||||
IRCServer* ret = 0;
|
||||
|
||||
m_servers.readlock(__FUNCTION__, __LINE__);
|
||||
if (servers.count(client->GetCharacterID()) != 0)
|
||||
ret = servers[client->GetCharacterID()];
|
||||
m_servers.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef IRC_IRC_H_
|
||||
#define IRC_IRC_H_
|
||||
|
||||
#include <map>
|
||||
#include "../../common/types.h"
|
||||
#include "../../common/Mutex.h"
|
||||
#include "IRCServer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class IRC {
|
||||
public:
|
||||
IRC();
|
||||
virtual ~IRC();
|
||||
|
||||
void SetRunning(bool running) {this->running = running;}
|
||||
bool IsRunning() {return running;}
|
||||
int32 GetNumServers();
|
||||
|
||||
static const char * GetSafeChannelName(const char *channel_name);
|
||||
|
||||
void Start();
|
||||
void Process();
|
||||
|
||||
void ConnectToServer(Client *client, const char *host, short port, const char *nick = NULL);
|
||||
void ConnectToGlobalServer(const char *host, short port, const char *nick = NULL);
|
||||
void DisconnectFromServer(Client *client);
|
||||
void DisconnectFromGlobalServer();
|
||||
void JoinChannel(Client *client, const char *channel_name);
|
||||
void LeaveChannel(Client *client, const char *channel_name);
|
||||
void ListChannels(Client *client);
|
||||
void Say(Client *client, const char *channel_name, const char *message);
|
||||
void Say(Client *client, int32 channel_index, const char *message);
|
||||
|
||||
IRCServer* GetServer(Client* client);
|
||||
|
||||
IRCServer* GetGlobalServer() { return m_globalServer; }
|
||||
|
||||
private:
|
||||
bool running;
|
||||
Mutex m_servers;
|
||||
map<int32, IRCServer *> servers;
|
||||
IRCServer* m_globalServer;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "IRCChannel.h"
|
||||
|
||||
IRCChannel::IRCChannel(const char *name) {
|
||||
assert(name != NULL);
|
||||
|
||||
strncpy(this->name, name, IRC_CHANNEL_LEN_MAX);
|
||||
}
|
||||
|
||||
IRCChannel::~IRCChannel() {
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef IRC_IRCCHANNEL_H_
|
||||
#define IRC_IRCCHANNEL_H_
|
||||
|
||||
#define IRC_CHANNEL_LEN_MAX 32
|
||||
|
||||
class IRCChannel {
|
||||
public:
|
||||
IRCChannel(const char *name);
|
||||
virtual ~IRCChannel();
|
||||
|
||||
void SetJoining(bool joining) {this->joining = joining;}
|
||||
|
||||
const char * GetName() {return name;}
|
||||
bool IsJoining() {return joining;}
|
||||
|
||||
private:
|
||||
char name[IRC_CHANNEL_LEN_MAX + 1];
|
||||
bool joining;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "../../common/types.h"
|
||||
#include "IRCMessage.h"
|
||||
|
||||
IRCMessage::IRCMessage(const char *message, ...) {
|
||||
int n, size = 512;
|
||||
va_list ap;
|
||||
|
||||
len = 0;
|
||||
serialized = false;
|
||||
|
||||
while (true) {
|
||||
//allocate our buffer
|
||||
this->message = new char[size];
|
||||
|
||||
//print the format into the buffer
|
||||
va_start(ap, message);
|
||||
n = vsnprintf(this->message, size, message, ap);
|
||||
va_end(ap);
|
||||
|
||||
//did we write what we needed to?
|
||||
if (n > -1 && n < size)
|
||||
break;
|
||||
|
||||
#ifdef _WIN32
|
||||
size *= 2; //double the buffer
|
||||
#else
|
||||
if (n > -1)
|
||||
size = n + 1; //we know exactly how many bytes to write
|
||||
else
|
||||
size *= 2; //double the buffer
|
||||
#endif
|
||||
|
||||
safe_delete_array(this->message);
|
||||
}
|
||||
}
|
||||
|
||||
IRCMessage::~IRCMessage() {
|
||||
if (message != NULL)
|
||||
safe_delete_array(message);
|
||||
}
|
||||
|
||||
const char * IRCMessage::Serialize() {
|
||||
char *buf;
|
||||
|
||||
if (message == NULL || serialized)
|
||||
return message;
|
||||
|
||||
//allocate enough room for the /r/n, and of course the null
|
||||
len = strlen(message) + 3;
|
||||
buf = new char[len];
|
||||
snprintf(buf, len, "%s\r\n", message);
|
||||
|
||||
//now copy back into our true buffer
|
||||
safe_delete_array(message);
|
||||
message = new char[len];
|
||||
strncpy(message, buf, len);
|
||||
|
||||
//and finally free our temporary buffer
|
||||
safe_delete_array(buf);
|
||||
|
||||
//we don't want to do this process again if for some reason Serialize() is called again
|
||||
serialized = true;
|
||||
|
||||
//we don't want to include the trailing null in the length
|
||||
len--;
|
||||
|
||||
return message;
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef IRC_IRCMESSAGE_H_
|
||||
#define IRC_IRCMESSAGE_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
class IRCMessage {
|
||||
public:
|
||||
IRCMessage(const char *message, ...);
|
||||
virtual ~IRCMessage();
|
||||
|
||||
size_t GetLength() {return len;}
|
||||
const char *Serialize();
|
||||
|
||||
private:
|
||||
char *message;
|
||||
size_t len;
|
||||
bool serialized;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef IRC_IRCREPLYCODES_H_
|
||||
#define IRC_IRCREPLYCODES_H_
|
||||
|
||||
//the following are eq2emu specific irc reply codes
|
||||
#define IRC_CONNECT_SUCCESS 0
|
||||
#define IRC_CONNECT_ALREADY_CONNECTED 1 //already connected to this server
|
||||
#define IRC_CONNECT_NO_NICK 2 //a nick was never given
|
||||
#define IRC_CONNECT_WINSOCK_INIT 3 //couldn't initialize winsock
|
||||
#define IRC_CONNECT_WINSOCK_VERSION 4 //couldn't find the version of winsock we want
|
||||
#define IRC_CONNECT_SOCKET 5 //couldn't create a socket
|
||||
#define IRC_CONNECT_NO_HOST 6 //couldn't find the hostname
|
||||
#define IRC_CONNECT_FAIL 7 //failure connecting
|
||||
#define IRC_CONNECT_SOCKET_OPT 8 //couldn't set socket options
|
||||
|
||||
#define IRC_JOIN_CHANNEL_SUCCESS 0
|
||||
#define IRC_JOIN_CHANNEL_ALREADY_IN 1 //already in the channel
|
||||
|
||||
#define IRC_LEAVE_CHANNEL_SUCCESS 0
|
||||
#define IRC_LEAVE_CHANNEL_NOT_IN 1 //was never in the channel
|
||||
|
||||
#define IRC_SAY_SUCCESS 0
|
||||
#define IRC_SAY_NOT_IN 1 //was never the channel
|
||||
|
||||
#endif
|
|
@ -1,467 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef _WIN32
|
||||
#include <WinSock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "../../common/unix.h"
|
||||
#endif
|
||||
#include "../World.h"
|
||||
#include "IRCReplyCodes.h"
|
||||
#include "IRCServer.h"
|
||||
#include "../Chat/Chat.h"
|
||||
#include "../../common/Log.h"
|
||||
|
||||
extern ZoneList zone_list;
|
||||
extern Chat chat;
|
||||
|
||||
IRCServer::IRCServer() {
|
||||
character_id = 0;
|
||||
memset(host, 0, sizeof(host));
|
||||
port = 0;
|
||||
memset(nick, 0, sizeof(nick));
|
||||
sockfd = -1;
|
||||
connected = false;
|
||||
m_globalServer = false;
|
||||
}
|
||||
|
||||
IRCServer::IRCServer(int32 character_id, const char *host, short port, const char *nick) {
|
||||
assert(host != NULL);
|
||||
assert(nick != NULL);
|
||||
|
||||
this->character_id = character_id;
|
||||
strncpy(this->host, host, IRC_HOST_LEN_MAX);
|
||||
this->port = port;
|
||||
strncpy(this->nick, nick, IRC_NICK_LEN_MAX);
|
||||
sockfd = -1;
|
||||
connected = false;
|
||||
m_globalServer = false;
|
||||
}
|
||||
|
||||
IRCServer::IRCServer(const char *host, short port, const char *nick) {
|
||||
assert(host != NULL);
|
||||
assert(nick != NULL);
|
||||
|
||||
this->character_id = 0;
|
||||
strncpy(this->host, host, IRC_HOST_LEN_MAX);
|
||||
this->port = port;
|
||||
strncpy(this->nick, nick, IRC_NICK_LEN_MAX);
|
||||
sockfd = -1;
|
||||
connected = false;
|
||||
m_globalServer = true;
|
||||
}
|
||||
|
||||
IRCServer::~IRCServer() {
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
IRCChannel * IRCServer::GetChannel(const char *channel_name) {
|
||||
vector<IRCChannel *>::iterator itr;
|
||||
IRCChannel *channel = NULL;
|
||||
|
||||
assert(channel_name != NULL);
|
||||
|
||||
for (itr = channels.begin(); itr != channels.end(); itr++) {
|
||||
if (strncmp((*itr)->GetName(), channel_name, IRC_CHANNEL_LEN_MAX) == 0) {
|
||||
channel = *itr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
IRCChannel * IRCServer::GetChannel(int32 channel_index) {
|
||||
//channel indexes start at 1 according to the client
|
||||
channel_index--;
|
||||
|
||||
return channel_index < channels.size() ? channels[channel_index] : NULL;
|
||||
}
|
||||
|
||||
int IRCServer::Connect() {
|
||||
struct sockaddr_in server_addr;
|
||||
struct hostent *server;
|
||||
#ifdef _WIN32
|
||||
u_long nonblocking = 1;
|
||||
WSADATA wsa;
|
||||
#else
|
||||
int nonblocking = 1;
|
||||
#endif
|
||||
|
||||
//you're already connected numbnuts!
|
||||
if (connected)
|
||||
return IRC_CONNECT_ALREADY_CONNECTED;
|
||||
|
||||
//make sure a nick was given (should always have one)
|
||||
if (nick[0] == '\0')
|
||||
return IRC_CONNECT_NO_NICK;
|
||||
|
||||
#ifdef _WIN32
|
||||
//initialize winsock for version 2.2
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) {
|
||||
Disconnect();
|
||||
return IRC_CONNECT_WINSOCK_INIT;
|
||||
}
|
||||
|
||||
//make sure we support this version of winsock
|
||||
if (LOBYTE(wsa.wVersion) != 2 || HIBYTE(wsa.wHighVersion) != 2) {
|
||||
Disconnect();
|
||||
return IRC_CONNECT_WINSOCK_VERSION;
|
||||
}
|
||||
#endif
|
||||
|
||||
//attempt to create a tcp socket
|
||||
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
Disconnect();
|
||||
return IRC_CONNECT_SOCKET;
|
||||
}
|
||||
|
||||
//find the hostname
|
||||
if ((server = gethostbyname(host)) == NULL) {
|
||||
Disconnect();
|
||||
return IRC_CONNECT_NO_HOST;
|
||||
}
|
||||
|
||||
//setup the server info
|
||||
memset(&server_addr, 0, sizeof(server_addr));
|
||||
server_addr.sin_family = AF_INET;
|
||||
memcpy(&server_addr.sin_addr.s_addr, server->h_addr, server->h_length);
|
||||
server_addr.sin_port = htons(port);
|
||||
|
||||
//connect to the irc server
|
||||
if (connect(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
|
||||
Disconnect();
|
||||
return IRC_CONNECT_FAIL;
|
||||
}
|
||||
|
||||
//we want a non blocking socket
|
||||
#ifdef _WIN32
|
||||
if (ioctlsocket(sockfd, FIONBIO, &nonblocking) != 0) {
|
||||
#else
|
||||
if (ioctl(sockfd, FIONBIO, &nonblocking) != 0) {
|
||||
#endif
|
||||
Disconnect();
|
||||
return IRC_CONNECT_SOCKET_OPT;
|
||||
}
|
||||
|
||||
//woohoo! connected - send the register messages
|
||||
Send(new IRCMessage("NICK %s", nick));
|
||||
Send(new IRCMessage("USER %s 0 * :scott", nick));
|
||||
|
||||
connected = true;
|
||||
return IRC_CONNECT_SUCCESS;
|
||||
}
|
||||
|
||||
void IRCServer::Disconnect() {
|
||||
connected = false;
|
||||
#ifdef _WIN32
|
||||
if (sockfd > 0) {
|
||||
closesocket(sockfd);
|
||||
sockfd = -1;
|
||||
}
|
||||
WSACleanup();
|
||||
#else
|
||||
if (sockfd > 0) {
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<IRCChannel*>::iterator itr;
|
||||
for (itr = channels.begin(); itr != channels.end(); itr++) {
|
||||
safe_delete(*itr);
|
||||
}
|
||||
channels.clear();
|
||||
}
|
||||
|
||||
int IRCServer::JoinChannel(const char *channel_name) {
|
||||
vector<IRCChannel *>::iterator itr;
|
||||
IRCChannel *channel;
|
||||
|
||||
assert(channel_name != NULL);
|
||||
|
||||
//let's make sure they're already not in the channel
|
||||
for (itr = channels.begin(); itr != channels.end(); itr++) {
|
||||
if (strncmp((*itr)->GetName(), channel_name, IRC_CHANNEL_LEN_MAX) == 0)
|
||||
return IRC_JOIN_CHANNEL_ALREADY_IN;
|
||||
}
|
||||
|
||||
//add the channel to the list of channels and mark it as joining. we'll unmark it once we get a response back from the server
|
||||
channel = new IRCChannel(channel_name);
|
||||
channel->SetJoining(true);
|
||||
channels.push_back(channel);
|
||||
|
||||
//send the JOIN command to the IRC server
|
||||
Send(new IRCMessage("JOIN %s", channel_name));
|
||||
|
||||
return IRC_JOIN_CHANNEL_SUCCESS;
|
||||
}
|
||||
|
||||
int IRCServer::LeaveChannel(const char *channel_name) {
|
||||
vector<IRCChannel *>::iterator itr;
|
||||
IRCChannel *channel;
|
||||
|
||||
assert(channel_name != NULL);
|
||||
|
||||
for (itr = channels.begin(); itr != channels.end(); itr++) {
|
||||
channel = *itr;
|
||||
if (strncmp(channel->GetName(), channel_name, IRC_CHANNEL_LEN_MAX) == 0) {
|
||||
|
||||
//send the leave message to the IRC server
|
||||
Send(new IRCMessage("PART %s", channel->GetName()));
|
||||
|
||||
//free resourceses
|
||||
safe_delete(channel);
|
||||
channels.erase(itr);
|
||||
|
||||
return IRC_LEAVE_CHANNEL_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return IRC_LEAVE_CHANNEL_NOT_IN;
|
||||
}
|
||||
|
||||
int IRCServer::Say(const char *channel_name, const char *message) {
|
||||
IRCChannel *channel;
|
||||
|
||||
assert(channel_name != NULL);
|
||||
assert(message != NULL);
|
||||
|
||||
if ((channel = GetChannel(channel_name)) == NULL)
|
||||
return IRC_SAY_NOT_IN;
|
||||
|
||||
Say(channel, message);
|
||||
return IRC_SAY_SUCCESS;
|
||||
}
|
||||
|
||||
int IRCServer::Say(int32 channel_index, const char *message) {
|
||||
IRCChannel *channel;
|
||||
|
||||
assert(message != NULL);
|
||||
|
||||
if ((channel = GetChannel(channel_index)) == NULL)
|
||||
return IRC_SAY_NOT_IN;
|
||||
|
||||
Say(channel, message);
|
||||
return IRC_SAY_SUCCESS;
|
||||
}
|
||||
|
||||
void IRCServer::Say(IRCChannel *channel, const char *message) {
|
||||
assert(channel != NULL);
|
||||
assert(message != NULL);
|
||||
|
||||
Send(new IRCMessage("PRIVMSG %s %s", channel->GetName(), message));
|
||||
}
|
||||
|
||||
bool IRCServer::Process() {
|
||||
char *start, *end;
|
||||
char buf[8192];
|
||||
int i, count;
|
||||
Client *client = 0;
|
||||
|
||||
if (!connected)
|
||||
return false;
|
||||
|
||||
//make sure we can find a client associated with this character id
|
||||
if (!m_globalServer && (client = zone_list.GetClientByCharID(character_id)) == NULL) {
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "No client found with character ID %u", character_id);
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
|
||||
//read off the socket - remember this socket is non blocking
|
||||
memset(buf, 0, sizeof(buf));
|
||||
count = recv(sockfd, buf, sizeof(buf), 0);
|
||||
|
||||
//did server shut us down gracefully?
|
||||
if (count == 0) {
|
||||
if (client)
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You have been disconnected from IRC server %s.", host);
|
||||
else
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "You have been disconnected from global IRC server");
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
|
||||
//did we get an error?
|
||||
//if we get WSAWEOULDBLOCK or EAGAIN, then there was no data for us on the socket this time around, don't disconnect
|
||||
#ifdef _WIN32
|
||||
if (count < 0) {
|
||||
if (WSAGetLastError() == WSAEWOULDBLOCK)
|
||||
return true;
|
||||
#else
|
||||
if (count < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return true;
|
||||
#endif
|
||||
else {
|
||||
if (client)
|
||||
client->Message(CHANNEL_COLOR_YELLOW, "You have been disconnected from IRC server %s because of an error.", host);
|
||||
else
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "You have been disconnected from global IRC server because of an error");
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//if we made it here then we got data!
|
||||
//irc messages are separated by \r\n, so loop until we find a \n, replace it with a null to create a string then process it
|
||||
start = buf;
|
||||
end = buf;
|
||||
i = 0;
|
||||
|
||||
while (i < count) {
|
||||
if (*end == '\n') {
|
||||
*end = '\0';
|
||||
ProcessLine(client, start);
|
||||
|
||||
//move to the next potential string
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
i++;
|
||||
end++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IRCServer::ProcessLine(Client *client, const char *line) {
|
||||
char *ptr, *ptr2, *ptr3, *ptr4, *findme;
|
||||
size_t len;
|
||||
char *copy;
|
||||
|
||||
//assert(client != NULL);
|
||||
assert(line != NULL);
|
||||
|
||||
if ((len = strlen(line)) == 0) {
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Blank line recieved in IRCServer::ProcessLine");
|
||||
//fprintf(stderr, "Blank line received in IRCServer::ProcessLine\n");
|
||||
return;
|
||||
}
|
||||
|
||||
LogWrite(CHAT__DEBUG, 7, "IRC", "%s", line);
|
||||
//printf("%s\n", line);
|
||||
|
||||
//copy the line buffer so we dont ruin it with strtok
|
||||
copy = new char[len + 1];
|
||||
strncpy(copy, line, len);
|
||||
|
||||
if (len >= 4 && strncmp(line, "PING", 4) == 0)
|
||||
HandlePing();
|
||||
else if (line[0] == ':') {
|
||||
ptr = strtok(copy, " :");
|
||||
|
||||
if (ptr == NULL) {
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Unknown IRC line in IRCServer::ProcessLine: '%s'", line);
|
||||
//fprintf(stderr, "Unknown IRC line in IRCServer::ProcessLine: '%s'\n", line);
|
||||
}
|
||||
else {
|
||||
|
||||
//:scatman!scatman@hidden-BC7E1801.hsd1.pa.comcast.net PRIVMSG #EQ2Dev :test --from user, public channel msg
|
||||
//:scatman!scatman@hidden-BC7E1801.hsd1.pa.comcast.net PRIVMSG scatman :test --from user, private message
|
||||
|
||||
//is this message from the server or a user?
|
||||
if (strncmp(ptr, host, IRC_HOST_LEN_MAX) == 0) {
|
||||
}
|
||||
else {
|
||||
ptr2 = strtok(NULL, " :");
|
||||
if (ptr2 == NULL) {
|
||||
LogWrite(CHAT__DEBUG, 0, "IRC", "Unknown IRC line in IRCServer::ProcessLine: '%s'", line);
|
||||
//fprintf(stderr, "Unknown IRC line in IRCServer::ProcessLine: '%s'\n", line);
|
||||
}
|
||||
else {
|
||||
|
||||
if (strncmp(ptr2, "PRIVMSG", 7) == 0) {
|
||||
ptr3 = strtok(NULL, " :"); //channel
|
||||
ptr4 = strtok(NULL, "\r"); //message
|
||||
|
||||
//strip the user's address
|
||||
if ((findme = strstr(ptr, "!")) != NULL)
|
||||
*findme = '\0';
|
||||
|
||||
//remove the leading semi-colon from the beginning of the message
|
||||
if (ptr4[0] == ':')
|
||||
ptr4++;
|
||||
|
||||
if (ptr[0] == ':')
|
||||
ptr++;
|
||||
|
||||
//client->Message(CHANNEL_COLOR_YELLOW, "%s says to %s: \"%s\"", ptr, ptr3, ptr4);
|
||||
if (ptr3[0] == '#')
|
||||
ptr3++;
|
||||
|
||||
// Add "[IRC]" to the front of the name
|
||||
string name = string("[IRC]") + string(ptr);
|
||||
LogWrite(CHAT__DEBUG, 7, "IRC", "IRC sending chat to EQ2 channel (Channel Name: %s, Message: %s, Name: %s)", ptr3, ptr4, name.c_str());
|
||||
chat.TellChannel(client, ptr3, ptr4, name.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
safe_delete_array(copy);
|
||||
}
|
||||
|
||||
void IRCServer::Send(IRCMessage *message) {
|
||||
const char *msg;
|
||||
size_t len;
|
||||
int count;
|
||||
|
||||
assert(message != NULL);
|
||||
|
||||
msg = message->Serialize();
|
||||
len = message->GetLength();
|
||||
|
||||
if (msg == NULL) {
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Error sending IRC message to server %s. Message was null.", host);
|
||||
//fprintf(stderr, "Error sending IRC message to server %s. Message was null.", host);
|
||||
}
|
||||
else if (len == 0) {
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Error sending IRC message server %s. Message length was 0.", host);
|
||||
//fprintf(stderr, "Error sending IRC message server %s. Message length was 0.", host);
|
||||
}
|
||||
else {
|
||||
LogWrite(CHAT__DEBUG, 7, "IRC", "IRC MSG: '%s'", msg);
|
||||
//printf("IRC MSG: '%s'", msg);
|
||||
if ((count = send(sockfd, msg, len, 0)) != (int)len) {
|
||||
LogWrite(CHAT__ERROR, 0, "IRC", "Error sending IRC message '%s' to server %s. Tried to write %u bytes but only wrote %i", msg, host, len, count);
|
||||
//fprintf(stderr, "Error sending IRC message '%s' to server %s. Tried to write %u bytes but only wrote %i", msg, host, len, count);
|
||||
}
|
||||
}
|
||||
|
||||
safe_delete(message);
|
||||
}
|
||||
|
||||
void IRCServer::HandlePing() {
|
||||
Send(new IRCMessage("PONG %s", host));
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
EQ2Emulator: Everquest II Server Emulator
|
||||
Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
|
||||
|
||||
This file is part of EQ2Emulator.
|
||||
|
||||
EQ2Emulator is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
EQ2Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef IRC_SERVER_H_
|
||||
#define IRC_SERVER_H_
|
||||
|
||||
#include "../client.h"
|
||||
#include "IRCChannel.h"
|
||||
#include "IRCMessage.h"
|
||||
|
||||
//maximum host length for an irc server
|
||||
#define IRC_HOST_LEN_MAX 256
|
||||
|
||||
//maximum nick name on an irc server for the client
|
||||
#define IRC_NICK_LEN_MAX 32
|
||||
|
||||
class IRCServer {
|
||||
public:
|
||||
IRCServer();
|
||||
IRCServer(int32 character_id, const char *host, short port, const char *nick);
|
||||
IRCServer(const char *host, short port, const char *nick);
|
||||
virtual ~IRCServer();
|
||||
|
||||
const char * GetHost() {return host;}
|
||||
short GetPort() {return port;}
|
||||
bool IsConnected() {return connected;}
|
||||
vector<IRCChannel* > * GetChannels() {return &channels;}
|
||||
IRCChannel * GetChannel(const char *channel_name);
|
||||
IRCChannel * GetChannel(int32 channel_index);
|
||||
|
||||
int Connect();
|
||||
void Disconnect();
|
||||
int JoinChannel(const char *channel_name);
|
||||
int LeaveChannel(const char *channel_name);
|
||||
int Say(const char *channel_name, const char *message);
|
||||
int Say(int32 channel_index, const char *message);
|
||||
|
||||
bool Process();
|
||||
|
||||
private:
|
||||
int32 character_id;
|
||||
char host[IRC_HOST_LEN_MAX + 1]; //host (eg. irc.myircserver.com)
|
||||
short port; //port (default is typically 6667)
|
||||
char nick[IRC_NICK_LEN_MAX + 1];
|
||||
int sockfd; //socket used to connect to the irc server
|
||||
vector<IRCChannel *> channels;
|
||||
bool connected;
|
||||
void ProcessLine(Client *client, const char *line);
|
||||
void Send(IRCMessage *message);
|
||||
void HandlePing();
|
||||
void Say(IRCChannel *channel, const char *message);
|
||||
bool m_globalServer;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -291,11 +291,6 @@ void RuleManager::Init()
|
|||
RULE_INIT(R_World, EditorURL, "www.eq2emulator.net"); // default: www.eq2emulator.net
|
||||
RULE_INIT(R_World, EditorIncludeID, "0"); // default: 0 (0 = disabled, 1 = enabled)
|
||||
RULE_INIT(R_World, EditorOfficialServer, "0"); // default: 0 (0 = disabled, 1 = enabled)
|
||||
RULE_INIT(R_World, IRCEnabled, "0"); // default: 0 (0 = disabled, 1 = enabled)
|
||||
RULE_INIT(R_World, IRCGlobalEnabled, "0"); // default: 0 (0 = disabled, 1 = enabled)
|
||||
RULE_INIT(R_World, IRCAddress, "irc.eq2emulator.net"); // default: irc.eq2emulator.net
|
||||
RULE_INIT(R_World, IRCPort, "6667"); // default: 6667
|
||||
RULE_INIT(R_World, IRCChan, "#EQ2Emu"); // default: #EQ2Emu
|
||||
RULE_INIT(R_World, SavePaperdollImage, "1"); // default: true
|
||||
RULE_INIT(R_World, SaveHeadshotImage, "1"); // default: true
|
||||
RULE_INIT(R_World, SendPaperdollImagesToLogin, "1"); // default: true
|
||||
|
|
|
@ -147,11 +147,6 @@ enum RuleType {
|
|||
EditorURL,
|
||||
EditorIncludeID,
|
||||
EditorOfficialServer,
|
||||
IRCEnabled,
|
||||
IRCGlobalEnabled,
|
||||
IRCAddress,
|
||||
IRCPort,
|
||||
IRCChan,
|
||||
GroupSpellsTimer,
|
||||
SavePaperdollImage,
|
||||
SaveHeadshotImage,
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "Achievements/Achievements.h"
|
||||
#include "Recipes/Recipe.h"
|
||||
#include "Rules/Rules.h"
|
||||
#include "IRC/IRC.h"
|
||||
#include "../common/Log.h"
|
||||
#include "Traits/Traits.h"
|
||||
#include "Chat/Chat.h"
|
||||
|
@ -81,7 +80,6 @@ map<int16,OpcodeManager*>EQOpcodeManager;
|
|||
map<int16, int16> EQOpcodeVersions;
|
||||
WorldDatabase database;
|
||||
GuildList guild_list;
|
||||
IRC irc;
|
||||
Chat chat;
|
||||
|
||||
extern ConfigReader configReader;
|
||||
|
@ -216,11 +214,9 @@ void World::init(){
|
|||
database.LoadRuleSets();
|
||||
LogWrite(RULESYS__DEBUG, 1, "Rules", "-Load Rule Sets complete!");
|
||||
|
||||
LogWrite(CHAT__DEBUG, 1, "IRC", "-Starting IRC thread...");
|
||||
LoadItemBlueStats();
|
||||
//PopulateTOVStatMap();
|
||||
group_buff_updates.Start(rule_manager.GetGlobalRule(R_Client, GroupSpellsTimer)->GetInt32());
|
||||
irc.Start();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "Variables.h"
|
||||
#include "Rules/Rules.h"
|
||||
#include "Titles.h"
|
||||
#include "IRC/IRC.h"
|
||||
#include "Chat/Chat.h"
|
||||
#include "SpellProcess.h"
|
||||
#include "Zone/ChestTrap.h"
|
||||
|
@ -114,7 +113,6 @@ extern GuildList guild_list;
|
|||
extern MasterCollectionList master_collection_list;
|
||||
extern MasterAchievementList master_achievement_list;
|
||||
extern RuleManager rule_manager;
|
||||
extern IRC irc;
|
||||
extern Chat chat;
|
||||
extern MasterAAList master_aa_list;
|
||||
extern MasterAAList master_tree_nodes;
|
||||
|
@ -845,9 +843,6 @@ void Client::SendCharInfo() {
|
|||
if (player->GetHP() < player->GetTotalHP() || player->GetPower() < player->GetTotalPower())
|
||||
GetCurrentZone()->AddDamagedSpawn(player);
|
||||
|
||||
if (firstlogin && rule_manager.GetGlobalRule(R_World, IRCGlobalEnabled)->GetBool())
|
||||
Message(CHANNEL_BROADCAST, "This server has a global IRC channel, join the world channel %s to use", rule_manager.GetGlobalRule(R_World, IRCChan)->GetString());
|
||||
|
||||
if (firstlogin)
|
||||
firstlogin = false;
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ using namespace std;
|
|||
#include "Guilds/Guild.h"
|
||||
#include "Commands/ConsoleCommands.h"
|
||||
#include "Traits/Traits.h"
|
||||
#include "IRC/IRC.h"
|
||||
#include "Transmute.h"
|
||||
#include "Zone/ChestTrap.h"
|
||||
|
||||
|
@ -102,7 +101,6 @@ extern MasterSkillList master_skill_list;
|
|||
extern MasterItemList master_item_list;
|
||||
extern GuildList guild_list;
|
||||
extern Variables variables;
|
||||
extern IRC irc;
|
||||
ConfigReader configReader;
|
||||
int32 MasterItemList::next_unique_id = 0;
|
||||
int last_signal = 0;
|
||||
|
@ -375,19 +373,6 @@ int main(int argc, char** argv) {
|
|||
map<EQStream*, int32> connecting_clients;
|
||||
map<EQStream*, int32>::iterator cc_itr;
|
||||
|
||||
// Check to see if a global channel is enabled, if so try to connect to it
|
||||
if (rule_manager.GetGlobalRule(R_World, IRCGlobalEnabled)->GetBool()) {
|
||||
LogWrite(CHAT__INFO, 0, "IRC", "Starting global IRC server...");
|
||||
// Set the irc nick name to: ServerName[IRCBot]
|
||||
string world_name = net.GetWorldName();
|
||||
// Remove all white spaces from the server name
|
||||
world_name.erase(std::remove(world_name.begin(), world_name.end(), ' '), world_name.end());
|
||||
string nick = world_name + string("[IRCBot]");
|
||||
// Connect the global server
|
||||
irc.ConnectToGlobalServer(rule_manager.GetGlobalRule(R_World, IRCAddress)->GetString(), rule_manager.GetGlobalRule(R_World, IRCPort)->GetInt16(), nick.c_str());
|
||||
}
|
||||
|
||||
// JohnAdams - trying to make multi-char console input
|
||||
LogWrite(WORLD__DEBUG, 0, "Thread", "Starting console command thread...");
|
||||
#ifdef WIN32
|
||||
_beginthread(EQ2ConsoleListener, 0, NULL);
|
||||
|
@ -492,9 +477,6 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
LogWrite(WORLD__DEBUG, 0, "World", "The world is ending!");
|
||||
|
||||
LogWrite(WORLD__DEBUG, 0, "IRC", "Shutting IRC down");
|
||||
irc.SetRunning(false);
|
||||
|
||||
LogWrite(WORLD__DEBUG, 0, "World", "Shutting down zones...");
|
||||
zone_list.ShutDownZones();
|
||||
|
||||
|
|
Loading…
Reference in a new issue