Browse Source

Added ServerProfile structure; player part event is now silenced for open beta 3.

pull/3/head
JustinAJ 10 years ago
parent
commit
b36567d32b
  1. BIN
      Release/Plugins/RenX.Core.lib
  2. 2
      RenX.Core/RenX.Core.vcxproj
  3. 6
      RenX.Core/RenX.Core.vcxproj.filters
  4. 18
      RenX.Core/RenX_Server.cpp
  5. 3
      RenX.Core/RenX_Server.h
  6. 61
      RenX.Core/RenX_ServerProfile.cpp
  7. 47
      RenX.Core/RenX_ServerProfile.h

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

2
RenX.Core/RenX.Core.vcxproj

@ -77,6 +77,7 @@
<ClInclude Include="RenX_PlayerInfo.h" />
<ClInclude Include="RenX_Plugin.h" />
<ClInclude Include="RenX_Server.h" />
<ClInclude Include="RenX_ServerProfile.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Core.cpp" />
@ -84,6 +85,7 @@
<ClCompile Include="RenX_GameCommand.cpp" />
<ClCompile Include="RenX_Plugin.cpp" />
<ClCompile Include="RenX_Server.cpp" />
<ClCompile Include="RenX_ServerProfile.cpp" />
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib" />

6
RenX.Core/RenX.Core.vcxproj.filters

@ -44,6 +44,9 @@
<ClInclude Include="RenX_GameCommand.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RenX_ServerProfile.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RenX_Plugin.cpp">
@ -61,5 +64,8 @@
<ClCompile Include="RenX_GameCommand.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RenX_ServerProfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

18
RenX.Core/RenX_Server.cpp

@ -115,7 +115,7 @@ int RenX::Server::sendMessage(const Jupiter::ReadableString &message)
int RenX::Server::sendMessage(RenX::PlayerInfo *player, const Jupiter::ReadableString &message)
{
if (RenX::Server::gameVersion.equals("Open Beta 2"))
if (RenX::Server::profile->privateMessages == false)
return RenX::Server::sendMessage(message);
return RenX::Server::sock.send(Jupiter::StringS::Format("cevaprivatesay pid%d %.*s\n", player->id, message.size(), message.ptr()));
@ -621,6 +621,9 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
iWinType = Base;
this->needsCList = true;
if (this->profile->disconnectOnGameOver)
this->silenceParts = true;
onPreGameOver(this, iWinType, team, gScore, nScore);
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnGameOver(this, iWinType, team, gScore, nScore);
@ -632,6 +635,9 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
int nScore = buff.getWord(3, RenX::DelimS).gotoWord(1, "=").asInt(10);
this->needsCList = true;
if (this->profile->disconnectOnGameOver)
this->silenceParts = true;
if (gScore == nScore)
{
onPreGameOver(this, Tie, Other, gScore, nScore);
@ -675,6 +681,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
PARSE_PLAYER_DATA();
if (action.equals("disconnected"))
{
if (this->silenceParts == false)
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnPart(this, player);
this->removePlayer(player);
@ -829,6 +836,14 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
buff.shiftRight(1);
this->rconVersion = buff.asInt(10);
this->gameVersion = buff.substring(3);
if (this->rconVersion == 1)
this->profile = RenX::openBeta1Profile;
else if (gameVersion.equals("Open Beta 2"))
this->profile = RenX::openBeta2Profile;
else if (gameVersion.equals("Open Beta 3"))
this->profile = RenX::openBeta3Profile;
for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnVersion(this, buff);
buff.shiftLeft(1);
@ -870,6 +885,7 @@ bool RenX::Server::connect()
RenX::Server::sock.send(STRING_LITERAL_AS_REFERENCE("s\n"));
RenX::Server::sock.send(STRING_LITERAL_AS_REFERENCE("clogclientlist\n"));
RenX::Server::connected = true;
RenX::Server::silenceParts = false;
return true;
}
RenX::Server::connected = false;

3
RenX.Core/RenX_Server.h

@ -31,6 +31,7 @@
#include "Jupiter/INIFile.h"
#include "Jupiter/Thinker.h"
#include "RenX.h"
#include "RenX_ServerProfile.h"
/** DLL Linkage Nagging */
#if defined _MSC_VER
@ -63,6 +64,7 @@ namespace RenX
public: // RenX::Server
Jupiter::DLList<RenX::PlayerInfo> players; /** A list of players in the server */
Jupiter::INIFile varData; /** This may be replaced later with a more dedicated type. */
const RenX::ServerProfile *profile = RenX::defaultProfile;
/**
* @brief Checks if the server is connected to RCON.
@ -419,6 +421,7 @@ namespace RenX
private:
bool connected = false;
bool needsCList = false;
bool silenceParts = false;
unsigned int rconVersion = 0;
unsigned short port;
int logChanType;

61
RenX.Core/RenX_ServerProfile.cpp

@ -0,0 +1,61 @@
/**
* Copyright (C) 2014 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
* component of this program must not be commercial, unless explicit
* permission is granted from the original author. The use of this
* program for non-profit purposes is permitted.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* In the event that this license restricts you from making desired use of this program, contact the original author.
* Written by Justin James <justin.aj@hotmail.com>
*/
#include "RenX_ServerProfile.h"
struct BaseProfile : RenX::ServerProfile
{
BaseProfile()
{
supported = true;
privateMessages = true;
disconnectOnGameOver = false;
}
};
struct IdealProfile : BaseProfile
{
} _idealProfile;
const RenX::ServerProfile *RenX::defaultProfile = &_idealProfile;
struct OpenBeta1Profile : BaseProfile
{
OpenBeta1Profile()
{
supported = false;
privateMessages = false;
}
} _openBeta1Profile;
const RenX::ServerProfile *RenX::openBeta1Profile = &_openBeta1Profile;
struct OpenBeta2Profile : BaseProfile
{
OpenBeta2Profile()
{
privateMessages = false;
}
} _openBeta2Profile;
const RenX::ServerProfile *RenX::openBeta2Profile = &_openBeta2Profile;
struct OpenBeta3Profile : BaseProfile
{
OpenBeta3Profile()
{
disconnectOnGameOver = true;
}
} _openBeta3Profile;
const RenX::ServerProfile *RenX::openBeta3Profile = &_openBeta3Profile;

47
RenX.Core/RenX_ServerProfile.h

@ -0,0 +1,47 @@
/**
* Copyright (C) 2014 Justin James.
*
* This license must be preserved.
* Any applications, libraries, or code which make any use of any
* component of this program must not be commercial, unless explicit
* permission is granted from the original author. The use of this
* program for non-profit purposes is permitted.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* In the event that this license restricts you from making desired use of this program, contact the original author.
* Written by Justin James <justin.aj@hotmail.com>
*/
#if !defined _RENX_SERVERPROFILE_H_HEADER
#define _RENX_SERVERPROFILE_H_HEADER
/**
* @file RenX_ServerProfile.h
* @brief Defines the ServerProfile class, and known profiles.
*/
#include "RenX.h"
namespace RenX
{
/**
* @brief Contains information about features supported by a server version.
*/
struct RENX_API ServerProfile
{
bool supported;
bool privateMessages;
bool disconnectOnGameOver;
};
RENX_API extern const ServerProfile *defaultProfile; /** Default server profile */
RENX_API extern const ServerProfile *openBeta1Profile; /** Open Beta 1 server profile */
RENX_API extern const ServerProfile *openBeta2Profile; /** Open Beta 2 server profile */
RENX_API extern const ServerProfile *openBeta3Profile; /** Open Beta 3 server profile */
}
#endif // _RENX_SERVERPROFILE_H_HEADER
Loading…
Cancel
Save