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. 82
      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; return;
} }
void RenX::Plugin::RenX_OnIDChange(Server *, const PlayerInfo *, int)
{
return;
}
void RenX::Plugin::RenX_OnExecute(Server *, const PlayerInfo *, const Jupiter::ReadableString &) void RenX::Plugin::RenX_OnExecute(Server *, const PlayerInfo *, const Jupiter::ReadableString &)
{ {
return; 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_OnPart(Server *server, const PlayerInfo *player);
virtual void RenX_OnNameChange(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &newPlayerName); 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_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_OnExecute(Server *server, const PlayerInfo *player, const Jupiter::ReadableString &command);
virtual void RenX_OnPlayer(Server *server, const Jupiter::ReadableString &raw); virtual void RenX_OnPlayer(Server *server, const Jupiter::ReadableString &raw);

82
RenX.Core/RenX_Server.cpp

@ -590,7 +590,7 @@ void RenX::Server::sendPubChan(const char *fmt, ...) const
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Jupiter::StringL msg; Jupiter::StringL msg;
const Jupiter::ReadableString &serverPrefix = RenX::Server::IRCPrefix; const Jupiter::ReadableString &serverPrefix = RenX::Server::getPrefix();
if (serverPrefix.isEmpty() == false) if (serverPrefix.isEmpty() == false)
{ {
msg += serverPrefix; msg += serverPrefix;
@ -599,13 +599,25 @@ void RenX::Server::sendPubChan(const char *fmt, ...) const
} }
else msg.vformat(fmt, args); else msg.vformat(fmt, args);
va_end(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 void RenX::Server::sendPubChan(const Jupiter::ReadableString &msg) const
{ {
for (size_t i = 0; i != serverManager->size(); i++) const Jupiter::ReadableString &prefix = this->getPrefix();
serverManager->getServer(i)->messageChannels(RenX::Server::logChanType, msg); 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);
} }
void RenX::Server::sendAdmChan(const char *fmt, ...) const void RenX::Server::sendAdmChan(const char *fmt, ...) const
@ -622,17 +634,30 @@ void RenX::Server::sendAdmChan(const char *fmt, ...) const
} }
else msg.vformat(fmt, args); else msg.vformat(fmt, args);
va_end(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 void RenX::Server::sendAdmChan(const Jupiter::ReadableString &msg) const
{ {
for (size_t i = 0; i != serverManager->size(); i++) const Jupiter::ReadableString &prefix = this->getPrefix();
serverManager->getServer(i)->messageChannels(RenX::Server::adminLogChanType, msg); 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 void RenX::Server::sendLogChan(const char *fmt, ...) const
{ {
IRC_Bot *server;
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
Jupiter::StringL msg; Jupiter::StringL msg;
@ -645,17 +670,38 @@ void RenX::Server::sendLogChan(const char *fmt, ...) const
} }
else msg.vformat(fmt, args); else msg.vformat(fmt, args);
va_end(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 void RenX::Server::sendLogChan(const Jupiter::ReadableString &msg) const
{ {
for (size_t i = 0; i != serverManager->size(); i++) IRC_Bot *server;
const Jupiter::ReadableString &prefix = this->getPrefix();
if (prefix.isEmpty() == false)
{ {
IRC_Bot *server = serverManager->getServer(i); Jupiter::String m(msg.size() + prefix.size() + 1);
server->messageChannels(RenX::Server::logChanType, msg); m.set(prefix);
server->messageChannels(RenX::Server::adminLogChanType, msg); m += ' ';
m += msg;
for (size_t i = 0; i != serverManager->size(); 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);
}
} }
#define PARSE_PLAYER_DATA_P(DATA) \ #define PARSE_PLAYER_DATA_P(DATA) \
@ -1612,6 +1658,18 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
player->name = newName; player->name = newName;
onAction(); 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 else
{ {
Jupiter::ReferenceString raw = buff.gotoToken(1, RenX::DelimC); Jupiter::ReferenceString raw = buff.gotoToken(1, RenX::DelimC);

Loading…
Cancel
Save