Browse Source

IRCPrefix is now prepended to all IRC output messages, if one is defined; Added RenX_OnIDChange() event

pull/3/head
JustinAJ 10 years ago
parent
commit
073955e899
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 5
      RenX.Core/RenX_Plugin.cpp
  3. 1
      RenX.Core/RenX_Plugin.h
  4. 68
      RenX.Core/RenX_Server.cpp

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

5
RenX.Core/RenX_Plugin.cpp

@ -80,6 +80,11 @@ void RenX::Plugin::RenX_OnTeamChange(Server *, const PlayerInfo *, const TeamTyp
return;
}
void RenX::Plugin::RenX_OnIDChange(Server *, const PlayerInfo *, int)
{
return;
}
void RenX::Plugin::RenX_OnExecute(Server *, const PlayerInfo *, const Jupiter::ReadableString &)
{
return;

1
RenX.Core/RenX_Plugin.h

@ -52,6 +52,7 @@ namespace RenX
virtual void RenX_OnPart(Server *server, const PlayerInfo *player);
virtual void RenX_OnNameChange(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &newPlayerName);
virtual void RenX_OnTeamChange(Server *server, const PlayerInfo *player, const TeamType &oldTeam);
virtual void RenX_OnIDChange(Server *server, const PlayerInfo *player, int oldID);
virtual void RenX_OnExecute(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &command);
virtual void RenX_OnPlayer(Server *server, const Jupiter::ReadableString &raw);

68
RenX.Core/RenX_Server.cpp

@ -590,7 +590,7 @@ void RenX::Server::sendPubChan(const char *fmt, ...) const
va_list args;
va_start(args, fmt);
Jupiter::StringL msg;
const Jupiter::ReadableString &serverPrefix = RenX::Server::IRCPrefix;
const Jupiter::ReadableString &serverPrefix = RenX::Server::getPrefix();
if (serverPrefix.isEmpty() == false)
{
msg += serverPrefix;
@ -599,11 +599,23 @@ void RenX::Server::sendPubChan(const char *fmt, ...) const
}
else msg.vformat(fmt, args);
va_end(args);
RenX::Server::sendPubChan(msg);
for (size_t i = 0; i != serverManager->size(); i++)
serverManager->getServer(i)->messageChannels(RenX::Server::logChanType, msg);
}
void RenX::Server::sendPubChan(const Jupiter::ReadableString &msg) const
{
const Jupiter::ReadableString &prefix = this->getPrefix();
if (prefix.isEmpty() == false)
{
Jupiter::String m(msg.size() + prefix.size() + 1);
m.set(prefix);
m += ' ';
m += msg;
for (size_t i = 0; i != serverManager->size(); i++)
serverManager->getServer(i)->messageChannels(RenX::Server::logChanType, m);
}
else
for (size_t i = 0; i != serverManager->size(); i++)
serverManager->getServer(i)->messageChannels(RenX::Server::logChanType, msg);
}
@ -622,17 +634,30 @@ void RenX::Server::sendAdmChan(const char *fmt, ...) const
}
else msg.vformat(fmt, args);
va_end(args);
RenX::Server::sendAdmChan(msg);
for (size_t i = 0; i != serverManager->size(); i++)
serverManager->getServer(i)->messageChannels(RenX::Server::adminLogChanType, msg);
}
void RenX::Server::sendAdmChan(const Jupiter::ReadableString &msg) const
{
const Jupiter::ReadableString &prefix = this->getPrefix();
if (prefix.isEmpty() == false)
{
Jupiter::String m(msg.size() + prefix.size() + 1);
m.set(prefix);
m += ' ';
m += msg;
for (size_t i = 0; i != serverManager->size(); i++)
serverManager->getServer(i)->messageChannels(RenX::Server::adminLogChanType, m);
}
else
for (size_t i = 0; i != serverManager->size(); i++)
serverManager->getServer(i)->messageChannels(RenX::Server::adminLogChanType, msg);
}
void RenX::Server::sendLogChan(const char *fmt, ...) const
{
IRC_Bot *server;
va_list args;
va_start(args, fmt);
Jupiter::StringL msg;
@ -645,14 +670,35 @@ void RenX::Server::sendLogChan(const char *fmt, ...) const
}
else msg.vformat(fmt, args);
va_end(args);
RenX::Server::sendLogChan(msg);
for (size_t i = 0; i != serverManager->size(); i++)
{
server = serverManager->getServer(i);
server->messageChannels(RenX::Server::logChanType, msg);
server->messageChannels(RenX::Server::adminLogChanType, msg);
}
}
void RenX::Server::sendLogChan(const Jupiter::ReadableString &msg) const
{
IRC_Bot *server;
const Jupiter::ReadableString &prefix = this->getPrefix();
if (prefix.isEmpty() == false)
{
Jupiter::String m(msg.size() + prefix.size() + 1);
m.set(prefix);
m += ' ';
m += msg;
for (size_t i = 0; i != serverManager->size(); i++)
{
IRC_Bot *server = serverManager->getServer(i);
server = serverManager->getServer(i);
server->messageChannels(RenX::Server::logChanType, m);
server->messageChannels(RenX::Server::adminLogChanType, m);
}
}
else
for (size_t i = 0; i != serverManager->size(); i++)
{
server = serverManager->getServer(i);
server->messageChannels(RenX::Server::logChanType, msg);
server->messageChannels(RenX::Server::adminLogChanType, msg);
}
@ -1612,6 +1658,18 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
player->name = newName;
onAction();
}
else if (subHeader.equals("ChangeID;"))
{
// "to" | New ID | "from" | Old ID
int oldID = buff.getToken(5, RenX::DelimC).asInt();
RenX::PlayerInfo *player = this->getPlayer(oldID);
if (player != nullptr)
{
player->id = buff.getToken(3, RenX::DelimC).asInt();
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnIDChange(this, player, oldID);
}
}
else
{
Jupiter::ReferenceString raw = buff.gotoToken(1, RenX::DelimC);

Loading…
Cancel
Save