Browse Source

Added isFirstGame(), isFirstKill(), and isFirstDeath(). Join spam after map change is now filtered.

pull/3/head
JustinAJ 10 years ago
parent
commit
291b5cd947
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 146
      RenX.Core/RenX_Server.cpp
  3. 40
      RenX.Core/RenX_Server.h

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

146
RenX.Core/RenX_Server.cpp

@ -72,6 +72,21 @@ bool RenX::Server::isConnected() const
return RenX::Server::connected; return RenX::Server::connected;
} }
bool RenX::Server::isFirstGame() const
{
return RenX::Server::firstGame;
}
bool RenX::Server::isFirstKill() const
{
return RenX::Server::firstKill;
}
bool RenX::Server::isFirstDeath() const
{
return RenX::Server::firstDeath;
}
bool RenX::Server::isPublicLogChanType(int type) const bool RenX::Server::isPublicLogChanType(int type) const
{ {
return RenX::Server::logChanType == type; return RenX::Server::logChanType == type;
@ -491,72 +506,83 @@ inline RenX::PlayerInfo *getPlayerOrAdd(RenX::Server *server, const Jupiter::Rea
return r; return r;
} }
inline void onPreGameOver(RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore) void RenX::Server::processLine(const Jupiter::ReadableString &line)
{ {
RenX::PlayerInfo *player; /** Local functions */
auto onPreGameOver = [&](RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore)
if (server->players.size() != 0)
{ {
for (Jupiter::DLList<RenX::PlayerInfo>::Node *n = server->players.getNode(0); n != nullptr; n = n->next) RenX::PlayerInfo *player;
if (server->players.size() != 0)
{ {
player = n->data; for (Jupiter::DLList<RenX::PlayerInfo>::Node *n = server->players.getNode(0); n != nullptr; n = n->next)
if (player != nullptr)
{ {
if (player->team == team) player = n->data;
player->wins++; if (player != nullptr)
else player->loses++; {
if (player->team == team)
player->wins++;
else player->loses++;
}
} }
} }
} };
} auto onPostGameOver = [&](RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore)
inline void onPostGameOver(RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore)
{
RenX::PlayerInfo *player;
if (server->players.size() != 0)
{ {
for (Jupiter::DLList<RenX::PlayerInfo>::Node *n = server->players.getNode(0); n != nullptr; n = n->next) this->firstGame = false;
this->firstAction = false;
this->firstKill = false;
this->firstDeath = false;
RenX::PlayerInfo *player;
if (server->players.size() != 0)
{ {
player = n->data; for (Jupiter::DLList<RenX::PlayerInfo>::Node *n = server->players.getNode(0); n != nullptr; n = n->next)
if (player != nullptr)
{ {
player->kills = 0; player = n->data;
player->deaths = 0; if (player != nullptr)
player->suicides = 0; {
player->headshots = 0; player->kills = 0;
player->vehicleKills = 0; player->deaths = 0;
player->buildingKills = 0; player->suicides = 0;
player->defenceKills = 0; player->headshots = 0;
player->vehicleKills = 0;
player->buildingKills = 0;
player->defenceKills = 0;
}
} }
} }
} };
} auto onChat = [&](RenX::Server *server, RenX::PlayerInfo *player, const Jupiter::ReadableString &message, bool isPublic)
inline void onChat(RenX::Server *server, RenX::PlayerInfo *player, const Jupiter::ReadableString &message, bool isPublic)
{
const Jupiter::ReadableString &prefix = server->getCommandPrefix();
if (message.find(prefix) == 0 && message.size() != prefix.size())
{ {
Jupiter::ReferenceString command; const Jupiter::ReadableString &prefix = server->getCommandPrefix();
Jupiter::ReferenceString parameters; if (message.find(prefix) == 0 && message.size() != prefix.size())
if (containsSymbol(WHITESPACE, message.get(prefix.size())))
{ {
command = Jupiter::ReferenceString::getWord(message, 1, WHITESPACE); Jupiter::ReferenceString command;
parameters = Jupiter::ReferenceString::gotoWord(message, 2, WHITESPACE); Jupiter::ReferenceString parameters;
if (containsSymbol(WHITESPACE, message.get(prefix.size())))
{
command = Jupiter::ReferenceString::getWord(message, 1, WHITESPACE);
parameters = Jupiter::ReferenceString::gotoWord(message, 2, WHITESPACE);
}
else
{
command = Jupiter::ReferenceString::getWord(message, 0, WHITESPACE);
command.shiftRight(prefix.size());
parameters = Jupiter::ReferenceString::gotoWord(message, 1, WHITESPACE);
}
server->triggerCommand(command, player, parameters);
} }
else };
auto onAction = [&]()
{
if (this->firstAction == false)
{ {
command = Jupiter::ReferenceString::getWord(message, 0, WHITESPACE); this->firstAction = true;
command.shiftRight(prefix.size()); this->silenceJoins = false;
parameters = Jupiter::ReferenceString::gotoWord(message, 1, WHITESPACE);
} }
server->triggerCommand(command, player, parameters); };
}
}
void RenX::Server::processLine(const Jupiter::ReadableString &line)
{
Jupiter::ReferenceString buff = line; Jupiter::ReferenceString buff = line;
Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins(); Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins();
Jupiter::ReferenceString header = buff.getWord(0, RenX::DelimS); Jupiter::ReferenceString header = buff.getWord(0, RenX::DelimS);
@ -576,6 +602,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
if (objectType.match("*Beacon")) player->beaconPlacements++; if (objectType.match("*Beacon")) player->beaconPlacements++;
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDeploy(this, player, objectType); xPlugins.get(i)->RenX_OnDeploy(this, player, objectType);
onAction();
} }
else if (action.equals("suicided by")) else if (action.equals("suicided by"))
{ {
@ -585,6 +612,8 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
Jupiter::ReferenceString damageType = buff.getWord(3, RenX::DelimS); Jupiter::ReferenceString damageType = buff.getWord(3, RenX::DelimS);
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSuicide(this, player, damageType); xPlugins.get(i)->RenX_OnSuicide(this, player, damageType);
this->firstDeath = true;
onAction();
} }
else if (action.equals("killed")) else if (action.equals("killed"))
{ {
@ -615,6 +644,10 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnKill(this, player, victim, damageType); xPlugins.get(i)->RenX_OnKill(this, player, victim, damageType);
this->firstKill = true;
this->firstDeath = true;
onAction();
} }
else if (action.match("died by")) else if (action.match("died by"))
{ {
@ -623,6 +656,8 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
Jupiter::ReferenceString damageType = buff.getWord(3, RenX::DelimS); Jupiter::ReferenceString damageType = buff.getWord(3, RenX::DelimS);
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDie(this, player, damageType); xPlugins.get(i)->RenX_OnDie(this, player, damageType);
this->firstDeath = true;
onAction();
} }
else if (action.match("destroyed*")) else if (action.match("destroyed*"))
{ {
@ -647,6 +682,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
} }
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDestroy(this, player, victim, damageType, type); xPlugins.get(i)->RenX_OnDestroy(this, player, victim, damageType, type);
onAction();
} }
else if (playerData.match("??? wins (*)")) else if (playerData.match("??? wins (*)"))
{ {
@ -718,6 +754,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnChat(this, player, message); xPlugins.get(i)->RenX_OnChat(this, player, message);
} }
onAction();
} }
else if (header.equals("lPLAYER:")) else if (header.equals("lPLAYER:"))
{ {
@ -748,8 +785,9 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
break; break;
} }
for (size_t i = 0; i < xPlugins.size(); i++) if (this->silenceJoins == false)
xPlugins.get(i)->RenX_OnJoin(this, player); for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnJoin(this, player);
} }
else if (action.equals("changed name to:")) else if (action.equals("changed name to:"))
{ {
@ -759,6 +797,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
player->name = newName; player->name = newName;
if (RenX::Server::uuidMode == 1) if (RenX::Server::uuidMode == 1)
player->uuid = player->name; player->uuid = player->name;
onAction();
} }
} }
else if (header.equals("lRCON:")) else if (header.equals("lRCON:"))
@ -887,6 +926,11 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
else if (gameVersion.equals("Open Beta 3")) else if (gameVersion.equals("Open Beta 3"))
this->profile = RenX::openBeta3Profile; this->profile = RenX::openBeta3Profile;
if (this->profile->disconnectOnGameOver == false)
this->firstGame = true;
else if (this->firstGame == false)
this->silenceJoins = true;
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnVersion(this, buff); xPlugins.get(i)->RenX_OnVersion(this, buff);
buff.shiftLeft(1); buff.shiftLeft(1);

40
RenX.Core/RenX_Server.h

@ -73,6 +73,41 @@ namespace RenX
*/ */
bool isConnected() const; bool isConnected() const;
/**
* @brief Checks if the game in progress is the first game.
*
* @return True if this is the first game, false otherwise.
*/
bool isFirstGame() const;
/**
* @brief Checks if the first kill has already been processed.
* Note: This does not set to "true" until AFTER the first kill has been fully processed.
* This includes processing by plugins.
*
* @return True if the first kill has been fully processed, false otherwise.
*/
bool isFirstKill() const;
/**
* @brief Checks if the first death has already been processed.
* Note: This does not set to "true" until AFTER the first death has been fully processed.
* This includes processing by plugins.
*
* @return True if the first death has been fully processed, false otherwise.
*/
bool isFirstDeath() const;
/**
* @brief Checks if the first action has already been processed.
* Note: This does not set to "true" until AFTER the first action has been fully processed.
* This includes processing by plugins.
* An action is a kill, death, message, destroy, or any other player-induced interaction other than a join or part.
*
* @return True if the first action has been fully processed, false otherwise.
*/
bool isFirstAction() const;
/** /**
* @brief Checks if a channel type is a public channel type. * @brief Checks if a channel type is a public channel type.
* *
@ -438,6 +473,8 @@ namespace RenX
bool connected = false; bool connected = false;
bool needsCList = false; bool needsCList = false;
bool silenceParts = false; bool silenceParts = false;
bool silenceJoins = false;
bool firstGame = true;
unsigned int rconVersion = 0; unsigned int rconVersion = 0;
unsigned short port; unsigned short port;
int logChanType; int logChanType;
@ -446,6 +483,9 @@ namespace RenX
time_t delay; time_t delay;
int steamFormat; /** 16 = hex, 10 = base 10, 8 = octal, -2 = SteamID 2, -3 = SteamID 3 */ int steamFormat; /** 16 = hex, 10 = base 10, 8 = octal, -2 = SteamID 2, -3 = SteamID 3 */
unsigned int uuidMode; /** 0 = steam, 1 = nickname */ unsigned int uuidMode; /** 0 = steam, 1 = nickname */
bool firstKill = false;
bool firstDeath = false;
bool firstAction = false;
Jupiter::TCPSocket sock; Jupiter::TCPSocket sock;
Jupiter::CStringS clientHostname; Jupiter::CStringS clientHostname;
Jupiter::CStringS hostname; Jupiter::CStringS hostname;

Loading…
Cancel
Save