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. 62
      RenX.Core/RenX_Server.cpp
  3. 40
      RenX.Core/RenX_Server.h

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

62
RenX.Core/RenX_Server.cpp

@ -72,6 +72,21 @@ bool RenX::Server::isConnected() const
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
{
return RenX::Server::logChanType == type;
@ -491,7 +506,10 @@ inline RenX::PlayerInfo *getPlayerOrAdd(RenX::Server *server, const Jupiter::Rea
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)
{
/** Local functions */
auto onPreGameOver = [&](RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore)
{
RenX::PlayerInfo *player;
@ -508,10 +526,13 @@ inline void onPreGameOver(RenX::Server *server, RenX::WinType winType, RenX::Tea
}
}
}
}
inline void onPostGameOver(RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore)
};
auto onPostGameOver = [&](RenX::Server *server, RenX::WinType winType, RenX::TeamType team, int gScore, int nScore)
{
this->firstGame = false;
this->firstAction = false;
this->firstKill = false;
this->firstDeath = false;
RenX::PlayerInfo *player;
if (server->players.size() != 0)
@ -531,9 +552,8 @@ inline void onPostGameOver(RenX::Server *server, RenX::WinType winType, RenX::Te
}
}
}
}
inline void onChat(RenX::Server *server, RenX::PlayerInfo *player, const Jupiter::ReadableString &message, bool isPublic)
};
auto 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())
@ -553,10 +573,16 @@ inline void onChat(RenX::Server *server, RenX::PlayerInfo *player, const Jupiter
}
server->triggerCommand(command, player, parameters);
}
};
auto onAction = [&]()
{
if (this->firstAction == false)
{
this->firstAction = true;
this->silenceJoins = false;
}
};
void RenX::Server::processLine(const Jupiter::ReadableString &line)
{
Jupiter::ReferenceString buff = line;
Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins();
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++;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDeploy(this, player, objectType);
onAction();
}
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);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnSuicide(this, player, damageType);
this->firstDeath = true;
onAction();
}
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++)
xPlugins.get(i)->RenX_OnKill(this, player, victim, damageType);
this->firstKill = true;
this->firstDeath = true;
onAction();
}
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);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnDie(this, player, damageType);
this->firstDeath = true;
onAction();
}
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++)
xPlugins.get(i)->RenX_OnDestroy(this, player, victim, damageType, type);
onAction();
}
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++)
xPlugins.get(i)->RenX_OnChat(this, player, message);
}
onAction();
}
else if (header.equals("lPLAYER:"))
{
@ -748,6 +785,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
break;
}
if (this->silenceJoins == false)
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnJoin(this, player);
}
@ -759,6 +797,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
player->name = newName;
if (RenX::Server::uuidMode == 1)
player->uuid = player->name;
onAction();
}
}
else if (header.equals("lRCON:"))
@ -887,6 +926,11 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
else if (gameVersion.equals("Open Beta 3"))
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++)
xPlugins.get(i)->RenX_OnVersion(this, buff);
buff.shiftLeft(1);

40
RenX.Core/RenX_Server.h

@ -73,6 +73,41 @@ namespace RenX
*/
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.
*
@ -438,6 +473,8 @@ namespace RenX
bool connected = false;
bool needsCList = false;
bool silenceParts = false;
bool silenceJoins = false;
bool firstGame = true;
unsigned int rconVersion = 0;
unsigned short port;
int logChanType;
@ -446,6 +483,9 @@ namespace RenX
time_t delay;
int steamFormat; /** 16 = hex, 10 = base 10, 8 = octal, -2 = SteamID 2, -3 = SteamID 3 */
unsigned int uuidMode; /** 0 = steam, 1 = nickname */
bool firstKill = false;
bool firstDeath = false;
bool firstAction = false;
Jupiter::TCPSocket sock;
Jupiter::CStringS clientHostname;
Jupiter::CStringS hostname;

Loading…
Cancel
Save