Browse Source

RenX.Core:

* Building health is now set to 0 when a building is destroyed.
* Added isPassworded() function to Server.
* Improved appearance of Building Bars.
RenX.IRCJoin:
* Removed unusable variables.
pull/3/head
JustinAJ 10 years ago
parent
commit
4fc735db9a
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 16
      RenX.Core/RenX_Server.cpp
  3. 10
      RenX.Core/RenX_Server.h
  4. 24
      RenX.Core/RenX_Tags.cpp
  5. 60
      RenX.IRCJoin/RenX_IRCJoin.cpp
  6. 8
      RenX.IRCJoin/RenX_IRCJoin.h

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

16
RenX.Core/RenX_Server.cpp

@ -597,6 +597,11 @@ time_t RenX::Server::getDelay() const
return RenX::Server::delay; return RenX::Server::delay;
} }
bool RenX::Server::isPassworded() const
{
return RenX::Server::passworded;
}
const Jupiter::ReadableString &RenX::Server::getPassword() const const Jupiter::ReadableString &RenX::Server::getPassword() const
{ {
return RenX::Server::pass; return RenX::Server::pass;
@ -1403,6 +1408,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
buff.shiftRight(1); buff.shiftRight(1);
this->port = static_cast<unsigned short>(buff.getToken(1, RenX::DelimC).asUnsignedInt(10)); this->port = static_cast<unsigned short>(buff.getToken(1, RenX::DelimC).asUnsignedInt(10));
this->serverName = buff.getToken(3, RenX::DelimC); this->serverName = buff.getToken(3, RenX::DelimC);
this->passworded = buff.getToken(5, RenX::DelimC).asBool();
this->map = buff.getToken(7, RenX::DelimC); this->map = buff.getToken(7, RenX::DelimC);
buff.shiftLeft(1); buff.shiftLeft(1);
} }
@ -1816,6 +1822,16 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
break; break;
case RenX::ObjectType::Building: case RenX::ObjectType::Building:
player->buildingKills++; player->buildingKills++;
{
auto internalsStr = "_Internals"_jrs;
RenX::BuildingInfo *building;
if (objectName.findi(internalsStr) != Jupiter::INVALID_INDEX)
objectName.truncate(internalsStr.size());
building = RenX::Server::getBuildingByName(objectName);
if (building != nullptr)
building->health = 0.0;
}
break; break;
case RenX::ObjectType::Defence: case RenX::ObjectType::Defence:
player->defenceKills++; player->defenceKills++;

10
RenX.Core/RenX_Server.h

@ -580,7 +580,14 @@ namespace RenX
time_t getDelay() const; time_t getDelay() const;
/** /**
* @brief Fetches the password of a server. * @brief Checks if the server has a game password.
*
* @return True if the game is passworded, false otherwise.
*/
bool isPassworded() const;
/**
* @brief Fetches the RCON password of a server.
* *
* @return String containing the password of the server. * @return String containing the password of the server.
*/ */
@ -806,6 +813,7 @@ namespace RenX
/** Tracking variables */ /** Tracking variables */
bool connected = false; bool connected = false;
bool seamless = false; bool seamless = false;
bool passworded = false;
bool needsCList = false; bool needsCList = false;
bool silenceParts = false; bool silenceParts = false;
bool silenceJoins = false; bool silenceJoins = false;

24
RenX.Core/RenX_Tags.cpp

@ -56,7 +56,7 @@ TagsImp::TagsImp()
this->uniqueTag = STRING_LITERAL_AS_REFERENCE("\0\0\0\0\0\0"); this->uniqueTag = STRING_LITERAL_AS_REFERENCE("\0\0\0\0\0\0");
const Jupiter::ReadableString &configSection = Jupiter::IRC::Client::Config->get(STRING_LITERAL_AS_REFERENCE("RenX"), STRING_LITERAL_AS_REFERENCE("TagDefinitions"), STRING_LITERAL_AS_REFERENCE("RenX.Tags")); const Jupiter::ReadableString &configSection = Jupiter::IRC::Client::Config->get(STRING_LITERAL_AS_REFERENCE("RenX"), STRING_LITERAL_AS_REFERENCE("TagDefinitions"), STRING_LITERAL_AS_REFERENCE("RenX.Tags"));
TagsImp::bar_width = Jupiter::IRC::Client::Config->getInt(configSection, STRING_LITERAL_AS_REFERENCE("BarWidth"), 20); TagsImp::bar_width = Jupiter::IRC::Client::Config->getInt(configSection, STRING_LITERAL_AS_REFERENCE("BarWidth"), 19);
/** Global formats */ /** Global formats */
this->dateFmt = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("DateFormat"), STRING_LITERAL_AS_REFERENCE("%A, %B %d, %Y")); this->dateFmt = Jupiter::IRC::Client::Config->get(configSection, STRING_LITERAL_AS_REFERENCE("DateFormat"), STRING_LITERAL_AS_REFERENCE("%A, %B %d, %Y"));
@ -289,17 +289,27 @@ Jupiter::StringS TagsImp::get_building_health_bar(const RenX::BuildingInfo *buil
Jupiter::String r(TagsImp::bar_width); Jupiter::String r(TagsImp::bar_width);
if (greenBars != 0) if (greenBars != 0)
{ {
r = IRCCOLOR "09,09"; r = IRCCOLOR "02,09";
do do
r += " "; {
if (index % 2 == 0)
r += '/';
else
r += ' ';
}
while (++index != greenBars); while (++index != greenBars);
if (greenBars == TagsImp::bar_width) if (index == TagsImp::bar_width)
return r += IRCNORMAL; return r += IRCNORMAL;
} }
r += IRCCOLOR "04,04"; r += IRCCOLOR "02,04";
do do
r += " "; {
while (++greenBars != TagsImp::bar_width); if (index % 2 == 0)
r += '\\';
else
r += ' ';
}
while (++index != TagsImp::bar_width);
return r += IRCNORMAL; return r += IRCNORMAL;
} }

60
RenX.IRCJoin/RenX_IRCJoin.cpp

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2014 Justin James. * Copyright (C) 2014-2015 Justin James.
* *
* This license must be preserved. * This license must be preserved.
* Any applications, libraries, or code which make any use of any * Any applications, libraries, or code which make any use of any
@ -27,8 +27,6 @@ void RenX_IRCJoinPlugin::init()
RenX_IRCJoinPlugin::publicOnly = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("PublicOnly"), true); RenX_IRCJoinPlugin::publicOnly = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("PublicOnly"), true);
RenX_IRCJoinPlugin::joinMsgAlways = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.MsgAlways"), false); RenX_IRCJoinPlugin::joinMsgAlways = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.MsgAlways"), false);
RenX_IRCJoinPlugin::partMsgAlways = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MsgAlways"), false); RenX_IRCJoinPlugin::partMsgAlways = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MsgAlways"), false);
RenX_IRCJoinPlugin::minAccessJoinMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.MinAccess"), 0);
RenX_IRCJoinPlugin::maxAccessJoinMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.MaxAccess"), -1);
RenX_IRCJoinPlugin::minAccessPartMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MinAccess"), 0); RenX_IRCJoinPlugin::minAccessPartMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MinAccess"), 0);
RenX_IRCJoinPlugin::maxAccessPartMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MaxAccess"), -1); RenX_IRCJoinPlugin::maxAccessPartMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MaxAccess"), -1);
RenX_IRCJoinPlugin::nameTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("NameTag"), STRING_LITERAL_AS_REFERENCE("{NAME}")); RenX_IRCJoinPlugin::nameTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("NameTag"), STRING_LITERAL_AS_REFERENCE("{NAME}"));
@ -41,13 +39,10 @@ void RenX_IRCJoinPlugin::init()
void RenX_IRCJoinPlugin::OnJoin(Jupiter::IRC::Client *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick) void RenX_IRCJoinPlugin::OnJoin(Jupiter::IRC::Client *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick)
{ {
int access = source->getAccessLevel(channel, nick); if (RenX_IRCJoinPlugin::joinFmt.isNotEmpty())
if (access >= RenX_IRCJoinPlugin::minAccessJoinMessage && (RenX_IRCJoinPlugin::maxAccessJoinMessage == -1 || access <= RenX_IRCJoinPlugin::maxAccessJoinMessage))
{ {
RenX::Server *server; RenX::Server *server;
int type = source->getChannel(channel)->getType(); int type = source->getChannel(channel)->getType();
Jupiter::String msg = RenX_IRCJoinPlugin::joinFmt; Jupiter::String msg = RenX_IRCJoinPlugin::joinFmt;
msg.replace(RenX_IRCJoinPlugin::nameTag, nick); msg.replace(RenX_IRCJoinPlugin::nameTag, nick);
msg.replace(RenX_IRCJoinPlugin::chanTag, channel); msg.replace(RenX_IRCJoinPlugin::chanTag, channel);
@ -70,34 +65,37 @@ void RenX_IRCJoinPlugin::OnJoin(Jupiter::IRC::Client *source, const Jupiter::Rea
void RenX_IRCJoinPlugin::OnPart(Jupiter::IRC::Client *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &reason) void RenX_IRCJoinPlugin::OnPart(Jupiter::IRC::Client *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &reason)
{ {
int access = source->getAccessLevel(channel, nick); if (RenX_IRCJoinPlugin::partFmt.isNotEmpty())
if (access >= RenX_IRCJoinPlugin::minAccessPartMessage && (RenX_IRCJoinPlugin::maxAccessPartMessage == -1 || access <= RenX_IRCJoinPlugin::maxAccessPartMessage))
{ {
RenX::Server *server; int access = source->getAccessLevel(channel, nick);
int type = source->getChannel(channel)->getType();
Jupiter::String msg; if (access >= RenX_IRCJoinPlugin::minAccessPartMessage && (RenX_IRCJoinPlugin::maxAccessPartMessage == -1 || access <= RenX_IRCJoinPlugin::maxAccessPartMessage))
if (reason.isEmpty())
msg = RenX_IRCJoinPlugin::partFmtNoReason;
else
msg = RenX_IRCJoinPlugin::partFmt;
msg.replace(RenX_IRCJoinPlugin::nameTag, nick);
msg.replace(RenX_IRCJoinPlugin::chanTag, channel);
msg.replace(RenX_IRCJoinPlugin::partReasonTag, reason);
auto checkType = [&]()
{ {
if (this->publicOnly) RenX::Server *server;
return server->isPublicLogChanType(type); int type = source->getChannel(channel)->getType();
Jupiter::String msg;
if (reason.isEmpty())
msg = RenX_IRCJoinPlugin::partFmtNoReason;
else else
return server->isLogChanType(type); msg = RenX_IRCJoinPlugin::partFmt;
}; msg.replace(RenX_IRCJoinPlugin::nameTag, nick);
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) msg.replace(RenX_IRCJoinPlugin::chanTag, channel);
{ msg.replace(RenX_IRCJoinPlugin::partReasonTag, reason);
server = RenX::getCore()->getServer(i);
if (checkType() && (RenX_IRCJoinPlugin::partMsgAlways || server->players.size() != 0)) auto checkType = [&]()
server->sendMessage(msg); {
if (this->publicOnly)
return server->isPublicLogChanType(type);
else
return server->isLogChanType(type);
};
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++)
{
server = RenX::getCore()->getServer(i);
if (checkType() && (RenX_IRCJoinPlugin::partMsgAlways || server->players.size() != 0))
server->sendMessage(msg);
}
} }
} }
} }

8
RenX.IRCJoin/RenX_IRCJoin.h

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2014 Justin James. * Copyright (C) 2014-2015 Justin James.
* *
* This license must be preserved. * This license must be preserved.
* Any applications, libraries, or code which make any use of any * Any applications, libraries, or code which make any use of any
@ -33,11 +33,11 @@ public: // Jupiter::Plugin
private: private:
void init(); void init();
// Config Variables
bool publicOnly; bool publicOnly;
bool joinMsgAlways; bool joinMsgAlways;
bool partMsgAlways; bool partMsgAlways;
int minAccessJoinMessage;
int maxAccessJoinMessage;
int minAccessPartMessage; int minAccessPartMessage;
int maxAccessPartMessage; int maxAccessPartMessage;
Jupiter::StringS nameTag; Jupiter::StringS nameTag;
@ -46,6 +46,8 @@ private:
Jupiter::StringS joinFmt; Jupiter::StringS joinFmt;
Jupiter::StringS partFmt; Jupiter::StringS partFmt;
Jupiter::StringS partFmtNoReason; Jupiter::StringS partFmtNoReason;
// Internal Variables
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.IRCJoin"); STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.IRCJoin");
}; };

Loading…
Cancel
Save