Browse Source

Package as .tar.gz when building PackagedBuild for linux; update submodules; various minor fixes and cleanup

release/1.1
Jessica James 3 years ago
parent
commit
c1b240985c
  1. 10
      .github/workflows/cmake.yml
  2. 36
      CMakeLists.txt
  3. 47
      baseline/Configs/IRC.Core.ini
  4. 1
      build/Clang/CMakeLists.txt
  5. 1
      build/GNU/CMakeLists.txt
  6. 10
      src/Bot/src/Main.cpp
  7. 2
      src/Bot/src/ServerManager.cpp
  8. 5
      src/CMakeLists.txt
  9. 4
      src/Plugins/ChannelRelay/ChannelRelay.cpp
  10. 8
      src/Plugins/CoreCommands/CoreCommands.cpp
  11. 2
      src/Plugins/RenX/RenX.Announcements/RenX_Announcements.h
  12. 4
      src/Plugins/RenX/RenX.Core/RenX_Core.cpp
  13. 4
      src/Plugins/RenX/RenX.Listen/RenX_Listen.cpp
  14. 4
      src/Plugins/RenX/RenX.Relay/RenX_Relay.cpp
  15. 6
      src/Plugins/RenX/RenX.ServerList/RenX_ServerList.cpp

10
.github/workflows/cmake.yml

@ -33,10 +33,16 @@ jobs:
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -D$(git rev-parse --short "$GITHUB_SHA")
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
run: cmake --build . --config --target=PackagedBuild $BUILD_TYPE
- name: Archive build package / binaries
uses: actions/upload-artifact@v2
with:
name: build-package
path: ${{github.workspace}}/bin/$(git rev-parse --short "$GITHUB_SHA")

36
CMakeLists.txt

@ -3,10 +3,8 @@ project(jupiter_bot)
set(CMAKE_CXX_STANDARD 20)
set(TAR_FILENAME "Jupiter Bot Binaries.zip")
if (DEFINED JUPITER_VERSION_SHORT)
add_compile_definitions(JUPITER_VERSION_SHORT="${JUPITER_VERSION_SHORT}")
set(TAR_FILENAME "Jupiter Bot Binaries.${JUPITER_VERSION_SHORT}.zip")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
@ -24,6 +22,18 @@ if(NOT DEFINED PACKAGED_BUILD_PATH)
endif()
message(STATUS "PackagedBuild Path: ${PACKAGED_BUILD_PATH}")
set(jessilib_target_file)
get_target_property(jessilib_target_type jessilib TYPE)
if (jessilib_target_type STREQUAL "SHARED_LIBRARY")
set(jessilib_target_file "$<TARGET_FILE:jessilib>")
endif()
set(jupiter_target_file)
get_target_property(jupiter_target_type jupiter TYPE)
if (jupiter_target_type STREQUAL "SHARED_LIBRARY")
set(jupiter_target_file "$<TARGET_FILE:jupiter>")
endif()
add_custom_target(PackagedBuild)
add_dependencies(PackagedBuild FullBotBuild)
add_custom_command(TARGET PackagedBuild
@ -34,7 +44,7 @@ add_custom_command(TARGET PackagedBuild
COMMAND ${CMAKE_COMMAND} -E make_directory ${PACKAGED_BUILD_PATH}/Plugins/)
add_custom_command(TARGET PackagedBuild
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:jupiter> $<TARGET_FILE:Bot> ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${PACKAGED_BUILD_PATH}/)
COMMAND ${CMAKE_COMMAND} -E copy ${jupiter_target_file} ${jessilib_target_file} $<TARGET_FILE:Bot> ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${PACKAGED_BUILD_PATH}/)
add_custom_command(TARGET PackagedBuild
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/baseline ${PACKAGED_BUILD_PATH}/)
@ -46,10 +56,26 @@ foreach(plugin ${JUPITER_PLUGINS})
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${plugin}> ${PACKAGED_BUILD_PATH}/Plugins/)
endforeach()
# Wrap it all into a .zip
# Wrap it all into a .zip / .tar.gz
set(TAR_FORMAT)
set(TAR_EXTENSION ".tar.gz")
set(TAR_CREATE_FLAGS "cfz")
if (WIN32)
set(TAR_FORMAT "--format=zip")
set(TAR_EXTENSION ".zip")
set(TAR_CREATE_FLAGS "cf")
endif()
if (DEFINED JUPITER_VERSION_SHORT)
set(TAR_EXTENSION ".${JUPITER_VERSION_SHORT}${TAR_EXTENSION}")
endif()
set(TAR_FILENAME "Jupiter Bot Binaries${TAR_EXTENSION}")
add_custom_command(TARGET PackagedBuild
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E chdir "${PACKAGED_BUILD_PATH}/" tar cf ../${TAR_FILENAME} --format=zip -- *)
WORKING_DIRECTORY "${PACKAGED_BUILD_PATH}/"
COMMAND ${CMAKE_COMMAND} -E chdir "${PACKAGED_BUILD_PATH}/" tar ${TAR_CREATE_FLAGS} ../${TAR_FILENAME} ${TAR_FORMAT} -- *)
add_custom_command(TARGET PackagedBuild
POST_BUILD

47
baseline/Configs/IRC.Core.ini

@ -3,7 +3,7 @@
; Servers=String (Format: Server1 Server2 ...)
; Lists server sections to instantiate IRC connections with
Servers=CnCIRC
Servers=CT
; [Default]
;
@ -28,7 +28,7 @@ Servers=CnCIRC
; per-IP basis), do not set these.
;
; Settings:
; Hostname=String ("irc.cncirc.net" if unspecified)
; Hostname=String (example: "irc.rencorner.com")
; Port=Positive Integer (194 or 994 if unspecified)
; SSL=Bool (Default: false)
; STARTTLS=Bool (Default: true)
@ -94,14 +94,13 @@ Prefix=!
; also be applied here. Values here supercede any value
; which is set within the Default block.
;
[CnCIRC]
; CnCIRC includes the Renegade X IRC server. :)
Hostname=irc.cncirc.net
SASL.Password=your_NickServ_Password
[CT]
Hostname=irc.ctgamehosts.uk
RawData.1=PRIVMSG NickServ :IDENTIFY your_NickServ_Password
[[Channels]]
; Temporary: all channel names must be lowercase
[[[#renx-irc]]]
AutoJoin=True
@ -110,19 +109,35 @@ SASL.Password=your_NickServ_Password
[[[#renx-irc.admin]]]
AutoJoin=True
Type=2
[CT]
Hostname=irc.ConstructiveTyranny.com
[EKT]
Hostname=irc.elitekamikazeteam.com
RawData.1=PRIVMSG NickServ :IDENTIFY your_NickServ_Password
[[Channels]]
[[[#RenX-IRC]]]
; Temporary: all channel names must be lowercase
[[[#renx-irc]]]
AutoJoin=True
Type=1
[[[#RenX-IRC.Admin]]]
[[[#renx-irc.admin]]]
AutoJoin=True
Type=2
[RenCorner]
Hostname=irc.rencorner.com
RawData.1=PRIVMSG NickServ :IDENTIFY your_NickServ_Password
[[Channels]]
; Temporary: all channel names must be lowercase
[[[#renx-irc]]]
AutoJoin=True
Type=1
[[[#renx-irc.admin]]]
AutoJoin=True
Type=2
;EOF

1
build/Clang/CMakeLists.txt

@ -2,3 +2,4 @@
# Enable pthreads
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

1
build/GNU/CMakeLists.txt

@ -2,3 +2,4 @@
# Enable pthreads
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

10
src/Bot/src/Main.cpp

@ -108,7 +108,7 @@ void inputLoop() {
cmd->trigger(Jupiter::ReferenceString::gotoWord(console_input.input, 1, WHITESPACE));
}
else {
printf("Error: Command \"%.*s\" not found." ENDL, command.size(), command.ptr());
printf("Error: Command \"%.*s\" not found." ENDL, static_cast<int>(command.size()), command.ptr());
}
}
console_input.input_mutex.unlock();
@ -174,12 +174,12 @@ int main(int argc, const char **args) {
if (plugins_directory.isNotEmpty()) {
Jupiter::Plugin::setDirectory(plugins_directory);
printf("Plugins will be loaded from \"%.*s\"." ENDL, plugins_directory.size(), plugins_directory.ptr());
printf("Plugins will be loaded from \"%.*s\"." ENDL, static_cast<int>(plugins_directory.size()), plugins_directory.ptr());
}
if (configs_directory.isNotEmpty()) {
Jupiter::Plugin::setConfigDirectory(configs_directory);
printf("Plugin configs will be loaded from \"%.*s\"." ENDL, configs_directory.size(), configs_directory.ptr());
printf("Plugin configs will be loaded from \"%.*s\"." ENDL, static_cast<int>(configs_directory.size()), configs_directory.ptr());
}
puts("Loading plugins...");
@ -201,9 +201,9 @@ int main(int argc, const char **args) {
time_taken = static_cast<double>(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - load_start).count()) / 1000.0;
if (load_success)
printf("\"%.*s\" loaded successfully (%fms)." ENDL, plugin.size(), plugin.ptr(), time_taken);
printf("\"%.*s\" loaded successfully (%fms)." ENDL, static_cast<int>(plugin.size()), plugin.ptr(), time_taken);
else
fprintf(stderr, "WARNING: Failed to load plugin \"%.*s\" (%fms)!" ENDL, plugin.size(), plugin.ptr(), time_taken);
fprintf(stderr, "WARNING: Failed to load plugin \"%.*s\" (%fms)!" ENDL, static_cast<int>(plugin.size()), plugin.ptr(), time_taken);
}
// OnPostInitialize

2
src/Bot/src/ServerManager.cpp

@ -29,7 +29,7 @@ ServerManager *serverManager = &g_serverManager;
int ServerManager::think() {
for (auto itr = m_servers.begin(); itr != m_servers.end();) {
if ((*itr)->think() != 0) {
itr = m_servers.erase(itr + 1);
itr = m_servers.erase(itr);
continue;
}
++itr;

5
src/CMakeLists.txt

@ -1,8 +1,13 @@
# Setup output paths for jupiter and Bot
# TODO: these paths probably aren't needed anymore, per PackagedLib target, though can still be useful when running from
# repo dir. Not sure if anybody is relying on that functionality
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_SHARED_LIBRARY_PREFIX)
# We need Jupiter and jessilib to be shared libs, and there aren't separate targets for shared/static variants
set(BUILD_SHARED_LIBS ON)
# Add primary components (Jupiter, Bot, jessilib)
add_subdirectory(Jupiter)
add_subdirectory(jessilib)

4
src/Plugins/ChannelRelay/ChannelRelay.cpp

@ -53,14 +53,14 @@ void ChannelRelayPlugin::OnChat(Jupiter::IRC::Client *server, const Jupiter::Rea
int type = chan->getType();
if (ChannelRelayPlugin::types.contains(type))
{
unsigned int serverCount = serverManager->size();
size_t serverCount = serverManager->size();
char prefix = chan->getUserPrefix(nick);
Jupiter::String str;
if (prefix == 0) {
str = "<"_jrs + nick + "> "_jrs + message;
}
else {
str = "<"_js + prefix + nick + "> "_jrs + message;
str = "<"_jrs + prefix + nick + "> "_jrs + message;
}
while (serverCount != 0) {

8
src/Plugins/CoreCommands/CoreCommands.cpp

@ -44,7 +44,7 @@ void HelpConsoleCommand::trigger(const Jupiter::ReadableString &parameters) {
Jupiter::ReferenceString command = Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE);
ConsoleCommand *cmd = getConsoleCommand(command);
if (cmd == nullptr) {
printf("Error: Command \"%.*s\" not found." ENDL, command.size(), command.ptr());
printf("Error: Command \"%.*s\" not found." ENDL, static_cast<int>(command.size()), command.ptr());
return;
}
@ -141,12 +141,12 @@ RehashGenericCommand::RehashGenericCommand() {
}
Jupiter::GenericCommand::ResponseLine *RehashGenericCommand::trigger(const Jupiter::ReadableString &parameters) {
unsigned int r = Jupiter::rehash();
size_t hash_errors = Jupiter::rehash();
if (r == 0)
if (hash_errors == 0)
return new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("All %u objects were successfully rehashed.", Jupiter::getRehashableCount()), GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("%u of %u objects failed to successfully rehash.", r, Jupiter::getRehashableCount()), GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("%u of %u objects failed to successfully rehash.", hash_errors, Jupiter::getRehashableCount()), GenericCommand::DisplayType::PublicError);
}
const Jupiter::ReadableString &RehashGenericCommand::getHelp(const Jupiter::ReadableString &) {

2
src/Plugins/RenX/RenX.Announcements/RenX_Announcements.h

@ -38,7 +38,7 @@ public: // Jupiter::Plugin
private:
bool random;
unsigned int lastLine;
size_t lastLine;
Jupiter::Timer *timer;
Jupiter::File announcementsFile;
};

4
src/Plugins/RenX/RenX.Core/RenX_Core.cpp

@ -54,7 +54,7 @@ bool RenX::Core::initialize() {
server = std::make_unique<RenX::Server>(Jupiter::ReferenceString::getWord(serverList, i, WHITESPACE));
if (server->connect() == false) {
fprintf(stderr, "[RenX] ERROR: Failed to connect to %.*s on port %u. Error code: %d" ENDL, server->getHostname().size(), server->getHostname().c_str(), server->getPort(), Jupiter::Socket::getLastError());
fprintf(stderr, "[RenX] ERROR: Failed to connect to %s on port %u. Error code: %d" ENDL, server->getHostname().c_str(), server->getPort(), Jupiter::Socket::getLastError());
continue;
}
@ -180,7 +180,7 @@ void RenX::Core::banCheck() {
int RenX::Core::think() {
for (auto itr = m_servers.begin(); itr != m_servers.end();) {
if ((*itr)->think() != 0) {
itr = m_servers.erase(itr + 1);
itr = m_servers.erase(itr);
continue;
}
++itr;

4
src/Plugins/RenX/RenX.Listen/RenX_Listen.cpp

@ -40,8 +40,8 @@ int RenX_ListenPlugin::think() {
if (sock != nullptr) {
sock->setBlocking(false);
std::unique_ptr<RenX::Server> server = std::make_unique<RenX::Server>(std::move(*sock), RenX_ListenPlugin::serverSection);
printf("Incoming server connected from %.*s:%u" ENDL, server->getSocketHostname().size(), server->getSocketHostname().c_str(), server->getSocketPort());
server->sendLogChan("Incoming server connected from " IRCCOLOR "12%.*s:%u", server->getSocketHostname().size(), server->getSocketHostname().c_str(), server->getSocketPort());
printf("Incoming server connected from %s:%u" ENDL, server->getSocketHostname().c_str(), server->getSocketPort());
server->sendLogChan("Incoming server connected from " IRCCOLOR "12%s:%u", server->getSocketHostname().c_str(), server->getSocketPort());
RenX::getCore()->addServer(std::move(server));
delete sock;
}

4
src/Plugins/RenX/RenX.Relay/RenX_Relay.cpp

@ -460,7 +460,7 @@ void RenX_RelayPlugin::process_renx_message(RenX::Server& server, upstream_serve
if (player != nullptr) {
// Initialize the engine here using the init time, so that player fake IPs will be consistent
// Also include player ID so we get different IPs between players and for each match
std::mt19937 randgen(m_init_time.time_since_epoch().count() + (player->id * 2));
std::mt19937_64 randgen(m_init_time.time_since_epoch().count() + (player->id * 2));
std::uniform_int_distribution<uint32_t> dist(10, 200);
// Replace real IP with fake
@ -480,7 +480,7 @@ void RenX_RelayPlugin::process_renx_message(RenX::Server& server, upstream_serve
if (player != nullptr) {
// Initialize the engine here using the init time, so that player fake HWIDs will be consistent
// Also include player ID so we get different HWIDs between players and for each match
std::mt19937 randgen(m_init_time.time_since_epoch().count() + (player->id * 2 + 69));
std::mt19937_64 randgen(m_init_time.time_since_epoch().count() + (player->id * 2 + 69));
std::uniform_int_distribution<uint64_t> dist(0, 0x0000FFFFFFFFFFFFULL);
HWID hwid{};

6
src/Plugins/RenX/RenX.ServerList/RenX_ServerList.cpp

@ -512,7 +512,7 @@ void RenX_ServerListPlugin::updateServerList() {
void RenX_ServerListPlugin::updateMetadata() {
const auto& servers = RenX::getCore()->getServers();
unsigned int server_count{};
unsigned int player_count{};
size_t player_count{};
for (size_t index = 0; index != servers.size(); ++index) {
RenX::Server* server = servers[index];
@ -522,10 +522,10 @@ void RenX_ServerListPlugin::updateMetadata() {
}
}
m_metadata_json.format(R"json({"player_count":%u,"server_count":%u})json",
m_metadata_json.format(R"json({"player_count":%zu,"server_count":%u})json",
player_count, server_count);
m_metadata_prometheus.format("player_count %u\nserver_count %u\n",
m_metadata_prometheus.format("player_count %zu\nserver_count %u\n",
player_count, server_count);
}

Loading…
Cancel
Save