Browse Source

Various dev-bot related changes

RenX.ServerList: Added "long" (human readable) version of server list
RenX.Core/RenX_Functions.cpp: Removed a debug line
pull/3/head
Jessica James 9 years ago
parent
commit
ac78d031ed
  1. 1030
      .vs/config/applicationhost.config
  2. BIN
      Jupiter Bot.VC.db
  3. BIN
      Release/Plugins/RenX.Core.lib
  4. 2
      RenX.Core/RenX_Functions.cpp
  5. 10
      RenX.Core/RenX_Server.cpp
  6. 4
      RenX.ModSystem/RenX_ModSystem.cpp
  7. 146
      RenX.ServerList/RenX_ServerList.cpp
  8. 5
      RenX.ServerList/RenX_ServerList.h

1030
.vs/config/applicationhost.config

File diff suppressed because it is too large

BIN
Jupiter Bot.VC.db

Binary file not shown.

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

2
RenX.Core/RenX_Functions.cpp

@ -959,8 +959,6 @@ Jupiter::String RenX::escapifyRCON(const Jupiter::ReadableString &str)
result += 'u'; result += 'u';
result += Jupiter_asHex_upper(value >> 8); result += Jupiter_asHex_upper(value >> 8);
result += Jupiter_asHex_upper(value & 0x00FF); result += Jupiter_asHex_upper(value & 0x00FF);
printf(ENDL ENDL ENDL "\\u%x%x" ENDL ENDL ENDL ENDL, value >> 8, value & 0x00FF);
} }
// else // This is an invalid 1 byte sequence // else // This is an invalid 1 byte sequence
} }

10
RenX.Core/RenX_Server.cpp

@ -2562,9 +2562,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
{ {
player->global_rank = itr->rank; player->global_rank = itr->rank;
if (this->rconVersion >= 4) if (this->rconVersion >= 4)
this->sendData(Jupiter::StringS::Format("xset_rank %d %d\n", player->id, player->global_rank)); this->sendData(Jupiter::StringS::Format("dset_rank %d %d\n", player->id, player->global_rank));
else
this->sendData(Jupiter::StringS::Format("xset_rank%c%d%c%d\n", RenX::DelimC3, player->id, RenX::DelimC3, player->global_rank));
} }
break; break;
} }
@ -2632,9 +2630,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
if (this->devBot && player->global_rank != 0U) if (this->devBot && player->global_rank != 0U)
{ {
if (this->rconVersion >= 4) if (this->rconVersion >= 4)
this->sendData(Jupiter::StringS::Format("xset_rank %d %d\n", player->id, player->global_rank)); this->sendData(Jupiter::StringS::Format("dset_rank %d %d\n", player->id, player->global_rank));
else
this->sendData(Jupiter::StringS::Format("xset_rank%c%d%c%d\n", RenX::DelimC, player->id, RenX::DelimC, player->global_rank));
} }
for (size_t i = 0; i < xPlugins.size(); i++) for (size_t i = 0; i < xPlugins.size(); i++)
xPlugins.get(i)->RenX_OnIDChange(this, player, oldID); xPlugins.get(i)->RenX_OnIDChange(this, player, oldID);
@ -3148,7 +3144,7 @@ void RenX::Server::processLine(const Jupiter::ReadableString &line)
} }
break; break;
case 'x': case 'd':
{ {
// We don't actually need to use this output for anything atm; tend to this later. // We don't actually need to use this output for anything atm; tend to this later.
} }

4
RenX.ModSystem/RenX_ModSystem.cpp

@ -178,9 +178,9 @@ int RenX_ModSystemPlugin::auth(RenX::Server *server, const RenX::PlayerInfo *pla
if (server->isDevBot()) if (server->isDevBot())
{ {
if (server->getVersion() >= 4) if (server->getVersion() >= 4)
server->sendData(Jupiter::StringS::Format("xset_dev %d\n", player->id)); server->sendData(Jupiter::StringS::Format("dset_dev %d\n", player->id));
else else
server->sendData(Jupiter::StringS::Format("xset_dev%c%d\n", RenX::DelimC, player->id)); server->sendData(Jupiter::StringS::Format("d%d\n", player->id));
} }
} }
Jupiter::String playerName = RenX::getFormattedPlayerName(player); Jupiter::String playerName = RenX::getFormattedPlayerName(player);

146
RenX.ServerList/RenX_ServerList.cpp

@ -88,8 +88,9 @@ RenX_ServerListPlugin::RenX_ServerListPlugin()
{ {
RenX_ServerListPlugin::web_hostname = Jupiter::IRC::Client::Config->get(this->name, "Hostname"_jrs, ""_jrs); RenX_ServerListPlugin::web_hostname = Jupiter::IRC::Client::Config->get(this->name, "Hostname"_jrs, ""_jrs);
RenX_ServerListPlugin::web_path = Jupiter::IRC::Client::Config->get(this->name, "Path"_jrs, "/"_jrs); RenX_ServerListPlugin::web_path = Jupiter::IRC::Client::Config->get(this->name, "Path"_jrs, "/"_jrs);
RenX_ServerListPlugin::server_list_page_name = Jupiter::IRC::Client::Config->get(this->name, "ServersPageName"_jrs, "servers.json"_jrs); RenX_ServerListPlugin::server_list_page_name = Jupiter::IRC::Client::Config->get(this->name, "ServersPageName"_jrs, "servers.jsp"_jrs);
RenX_ServerListPlugin::server_page_name = Jupiter::IRC::Client::Config->get(this->name, "ServerPageName"_jrs, "server.json"_jrs); RenX_ServerListPlugin::server_list_long_page_name = Jupiter::IRC::Client::Config->get(this->name, "HumanServersPageName"_jrs, "servers_long.jsp"_jrs);
RenX_ServerListPlugin::server_page_name = Jupiter::IRC::Client::Config->get(this->name, "ServerPageName"_jrs, "server.jsp"_jrs);
/** Initialize content */ /** Initialize content */
Jupiter::HTTP::Server &server = getHTTPServer(); Jupiter::HTTP::Server &server = getHTTPServer();
@ -102,6 +103,14 @@ RenX_ServerListPlugin::RenX_ServerListPlugin()
content->free_result = false; content->free_result = false;
server.hook(RenX_ServerListPlugin::web_hostname, RenX_ServerListPlugin::web_path, content); server.hook(RenX_ServerListPlugin::web_hostname, RenX_ServerListPlugin::web_path, content);
// Server list (long) page
content = new Jupiter::HTTP::Server::Content(RenX_ServerListPlugin::server_list_long_page_name, handle_server_list_long_page);
content->language = &Jupiter::HTTP::Content::Language::ENGLISH;
content->type = &CONTENT_TYPE_APPLICATION_JSON;
content->charset = &Jupiter::HTTP::Content::Type::Text::Charset::UTF8;
content->free_result = true;
server.hook(RenX_ServerListPlugin::web_hostname, RenX_ServerListPlugin::web_path, content);
// Server page (GUIDs) // Server page (GUIDs)
content = new Jupiter::HTTP::Server::Content(RenX_ServerListPlugin::server_page_name, handle_server_page); content = new Jupiter::HTTP::Server::Content(RenX_ServerListPlugin::server_page_name, handle_server_page);
content->language = &Jupiter::HTTP::Content::Language::ENGLISH; content->language = &Jupiter::HTTP::Content::Language::ENGLISH;
@ -160,12 +169,12 @@ Jupiter::StringS server_as_json(const RenX::Server *server)
server->getPort(), server->getPort(),
server->getSocketHostname().size(), server->getSocketHostname().ptr()); server->getSocketHostname().size(), server->getSocketHostname().ptr());
server_json_block += "}"_jrs; server_json_block += '}';
return server_json_block; return server_json_block;
} }
Jupiter::StringS server_as_hr_json(const RenX::Server *server) Jupiter::StringS server_as_long_json(const RenX::Server *server)
{ {
Jupiter::String server_json_block(128); Jupiter::String server_json_block(128);
@ -264,8 +273,10 @@ Jupiter::StringS server_as_hr_json(const RenX::Server *server)
return server_json_block; return server_json_block;
} }
void RenX_ServerListPlugin::addServerToServerList(const RenX::Server *server) void RenX_ServerListPlugin::addServerToServerList(RenX::Server *server)
{ {
Jupiter::String server_json_block(256);
// append to server_list_json // append to server_list_json
if (RenX_ServerListPlugin::server_list_json.isEmpty()) if (RenX_ServerListPlugin::server_list_json.isEmpty())
@ -281,48 +292,6 @@ void RenX_ServerListPlugin::addServerToServerList(const RenX::Server *server)
RenX_ServerListPlugin::server_list_json += server_as_json(server); RenX_ServerListPlugin::server_list_json += server_as_json(server);
RenX_ServerListPlugin::server_list_json += ']'; RenX_ServerListPlugin::server_list_json += ']';
} }
}
void RenX_ServerListPlugin::updateServerList()
{
Jupiter::ArrayList<RenX::Server> servers = RenX::getCore()->getServers();
size_t index = 0;
RenX::Server *server;
// regenerate server_list_json
RenX_ServerListPlugin::server_list_json = '[';
while (index != servers.size())
{
server = servers.get(index);
if (server->isConnected() && server->isFullyConnected())
{
RenX_ServerListPlugin::server_list_json += server_as_json(server);
++index;
break;
}
++index;
}
while (index != servers.size())
{
server = servers.get(index);
if (server->isConnected() && server->isFullyConnected())
{
RenX_ServerListPlugin::server_list_json += ',';
RenX_ServerListPlugin::server_list_json += server_as_json(server);
}
++index;
}
RenX_ServerListPlugin::server_list_json += ']';
}
void RenX_ServerListPlugin::RenX_OnServerFullyConnected(RenX::Server *server)
{
Jupiter::String server_json_block(256);
this->addServerToServerList(server);
// add to individual listing // add to individual listing
@ -353,7 +322,9 @@ void RenX_ServerListPlugin::RenX_OnServerFullyConnected(RenX::Server *server)
// Mutators // Mutators
if (server->mutators.size() != 0) if (server->mutators.size() != 0)
{ {
server_json_block += ",\"Mutators\":["_jrs; if (server->maps.size() != 0)
server_json_block += ","_jrs;
server_json_block += "\"Mutators\":["_jrs;
server_json_block += "{\"Name\":\""_jrs; server_json_block += "{\"Name\":\""_jrs;
server_json_block += jsonify(*server->mutators.get(0)); server_json_block += jsonify(*server->mutators.get(0));
@ -374,6 +345,46 @@ void RenX_ServerListPlugin::RenX_OnServerFullyConnected(RenX::Server *server)
server->varData.set(this->name, "j"_jrs, server_json_block); server->varData.set(this->name, "j"_jrs, server_json_block);
} }
void RenX_ServerListPlugin::updateServerList()
{
Jupiter::ArrayList<RenX::Server> servers = RenX::getCore()->getServers();
size_t index = 0;
RenX::Server *server;
// regenerate server_list_json
RenX_ServerListPlugin::server_list_json = '[';
while (index != servers.size())
{
server = servers.get(index);
if (server->isConnected() && server->isFullyConnected())
{
RenX_ServerListPlugin::server_list_json += server_as_json(server);
++index;
break;
}
++index;
}
while (index != servers.size())
{
server = servers.get(index);
if (server->isConnected() && server->isFullyConnected())
{
RenX_ServerListPlugin::server_list_json += ',';
RenX_ServerListPlugin::server_list_json += server_as_json(server);
}
++index;
}
RenX_ServerListPlugin::server_list_json += ']';
}
void RenX_ServerListPlugin::RenX_OnServerFullyConnected(RenX::Server *server)
{
this->addServerToServerList(server);
}
void RenX_ServerListPlugin::RenX_OnServerDisconnect(RenX::Server *server, RenX::DisconnectReason) void RenX_ServerListPlugin::RenX_OnServerDisconnect(RenX::Server *server, RenX::DisconnectReason)
{ {
this->updateServerList(); this->updateServerList();
@ -400,6 +411,45 @@ Jupiter::ReadableString *handle_server_list_page(const Jupiter::ReadableString &
return pluginInstance.getServerListJSON(); return pluginInstance.getServerListJSON();
} }
Jupiter::ReadableString *handle_server_list_long_page(const Jupiter::ReadableString &)
{
Jupiter::ArrayList<RenX::Server> servers = RenX::getCore()->getServers();
size_t index = 0;
RenX::Server *server;
Jupiter::String *server_list_long_json = new Jupiter::String(256 * servers.size());
// regenerate server_list_json
*server_list_long_json = "["_jrs;
while (index != servers.size())
{
server = servers.get(index);
if (server->isConnected() && server->isFullyConnected())
{
*server_list_long_json += "\n\t"_jrs;
*server_list_long_json += server_as_long_json(server);
++index;
break;
}
++index;
}
while (index != servers.size())
{
server = servers.get(index);
if (server->isConnected() && server->isFullyConnected())
{
*server_list_long_json += ",\n\t"_jrs;
*server_list_long_json += server_as_long_json(server);
}
++index;
}
*server_list_long_json += "\n]"_jrs;
return server_list_long_json;
}
Jupiter::ReadableString *handle_server_page(const Jupiter::ReadableString &query_string) Jupiter::ReadableString *handle_server_page(const Jupiter::ReadableString &query_string)
{ {
Jupiter::HTTP::HTMLFormResponse html_form_response(query_string); Jupiter::HTTP::HTMLFormResponse html_form_response(query_string);

5
RenX.ServerList/RenX_ServerList.h

@ -28,7 +28,7 @@ class RenX_ServerListPlugin : public RenX::Plugin
public: // RenX_ServerListPlugin public: // RenX_ServerListPlugin
Jupiter::ReadableString *getServerListJSON(); Jupiter::ReadableString *getServerListJSON();
void addServerToServerList(const RenX::Server *server); void addServerToServerList(RenX::Server *server);
void updateServerList(); void updateServerList();
RenX_ServerListPlugin(); RenX_ServerListPlugin();
@ -48,10 +48,11 @@ private:
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.ServerList"); STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.ServerList");
Jupiter::StringS server_list_json; Jupiter::StringS server_list_json;
Jupiter::StringS web_hostname, web_path, server_list_page_name, server_page_name; Jupiter::StringS web_hostname, web_path, server_list_page_name, server_list_long_page_name, server_page_name;
}; };
Jupiter::ReadableString *handle_server_list_page(const Jupiter::ReadableString &); Jupiter::ReadableString *handle_server_list_page(const Jupiter::ReadableString &);
Jupiter::ReadableString *handle_server_list_long_page(const Jupiter::ReadableString &);
Jupiter::ReadableString *handle_server_page(const Jupiter::ReadableString &query_string); Jupiter::ReadableString *handle_server_page(const Jupiter::ReadableString &query_string);
#endif // _RENX_SERVERLIST_H_HEADER #endif // _RENX_SERVERLIST_H_HEADER

Loading…
Cancel
Save