Browse Source

Resolved a null pointer exception (this solution is faster anyways).

pull/4/head
Jessica James 8 years ago
parent
commit
25f6ef95dc
  1. 1
      RenX.Core/RenX_BanDatabase.h
  2. 79
      RenX.Core/RenX_Server.cpp
  3. 1
      RenX.Core/RenX_Server.h

1
RenX.Core/RenX_BanDatabase.h

@ -151,6 +151,7 @@ namespace RenX
* @param name Name of the player to ban * @param name Name of the player to ban
* @param ip IPv4 address of the player to ban * @param ip IPv4 address of the player to ban
* @param steamid SteamID of the player to ban * @param steamid SteamID of the player to ban
* @param hwid Hardware ID of the player to ban
* @param rdns RDNS of the player to ban * @param rdns RDNS of the player to ban
* @param banner Person implementing the ban * @param banner Person implementing the ban
* @param reason Reason the player is getting banned * @param reason Reason the player is getting banned

79
RenX.Core/RenX_Server.cpp

@ -1387,34 +1387,31 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
this->firstDeath = false; this->firstDeath = false;
RenX::PlayerInfo *player; RenX::PlayerInfo *player;
if (this->players.size() != 0) if (this->isSeamless() == false)
RenX::Server::wipePlayers();
else if (this->players.size() != 0)
{ {
for (Jupiter::DLList<RenX::PlayerInfo>::Node *n = this->players.getNode(0); n != nullptr; n = n->next) for (Jupiter::DLList<RenX::PlayerInfo>::Node *n = this->players.getNode(0); n != nullptr; n = n->next)
{ {
player = n->data; player = n->data;
if (player != nullptr) if (player != nullptr)
{ {
if (this->isSeamless()) player->score = 0.0f;
{ player->credits = 0.0f;
player->score = 0.0f; player->kills = 0;
player->credits = 0.0f; player->deaths = 0;
player->kills = 0; player->suicides = 0;
player->deaths = 0; player->headshots = 0;
player->suicides = 0; player->vehicleKills = 0;
player->headshots = 0; player->buildingKills = 0;
player->vehicleKills = 0; player->defenceKills = 0;
player->buildingKills = 0; player->beaconPlacements = 0;
player->defenceKills = 0; player->beaconDisarms = 0;
player->beaconPlacements = 0; player->proxy_placements = 0;
player->beaconDisarms = 0; player->proxy_disarms = 0;
player->proxy_placements = 0; player->captures = 0;
player->proxy_disarms = 0; player->steals = 0;
player->captures = 0; player->stolen = 0;
player->steals = 0;
player->stolen = 0;
}
else
this->removePlayer(player);
} }
} }
} }
@ -3409,22 +3406,7 @@ bool RenX::Server::reconnect(RenX::DisconnectReason reason)
void RenX::Server::wipeData() void RenX::Server::wipeData()
{ {
RenX::PlayerInfo *player; RenX::Server::wipePlayers();
Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins();
while (RenX::Server::players.size() != 0)
{
player = RenX::Server::players.remove(0U);
for (size_t index = 0; index < xPlugins.size(); ++index)
xPlugins.get(index)->RenX_OnPlayerDelete(this, player);
if (player->rdns_thread.joinable()) // Close the RDNS thread, if one exists
{
--this->player_rdns_resolutions_pending;
player->rdns_thread.join();
}
delete player;
}
RenX::Server::reliable = false; RenX::Server::reliable = false;
RenX::Server::m_team_mode = 3; RenX::Server::m_team_mode = 3;
RenX::Server::m_game_type = 1; RenX::Server::m_game_type = 1;
@ -3443,6 +3425,27 @@ void RenX::Server::wipeData()
RenX::Server::rconUser.truncate(RenX::Server::rconUser.size()); RenX::Server::rconUser.truncate(RenX::Server::rconUser.size());
} }
void RenX::Server::wipePlayers()
{
RenX::PlayerInfo *player;
Jupiter::ArrayList<RenX::Plugin> &xPlugins = *RenX::getCore()->getPlugins();
while (RenX::Server::players.size() != 0)
{
player = RenX::Server::players.remove(0U);
for (size_t index = 0; index < xPlugins.size(); ++index)
xPlugins.get(index)->RenX_OnPlayerDelete(this, player);
if (player->rdns_thread.joinable()) // Close the RDNS thread, if one exists
{
--this->player_rdns_resolutions_pending;
player->rdns_thread.join();
}
delete player;
}
}
unsigned int RenX::Server::getVersion() const unsigned int RenX::Server::getVersion() const
{ {
return RenX::Server::rconVersion; return RenX::Server::rconVersion;

1
RenX.Core/RenX_Server.h

@ -1008,6 +1008,7 @@ namespace RenX
/** Private members */ /** Private members */
private: private:
void init(const Jupiter::INIFile::Section &config); void init(const Jupiter::INIFile::Section &config);
void wipePlayers();
/** Tracking variables */ /** Tracking variables */
bool gameover_when_empty = false; bool gameover_when_empty = false;

Loading…
Cancel
Save