Skip to content

Commit

Permalink
Give items to players from RCON. Warp them too. Make them rich, also …
Browse files Browse the repository at this point in the history
…other commands like round_restart.
  • Loading branch information
geneotech committed Nov 26, 2023
1 parent a929c56 commit 9d59bc9
Show file tree
Hide file tree
Showing 20 changed files with 489 additions and 131 deletions.
56 changes: 29 additions & 27 deletions docs/pages/todo/brainstorm_now.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,36 @@ permalink: brainstorm_now
summary: That which we are brainstorming at the moment.
---

- Miniature generation should trigger "dirty" revision

# BEFORE STEAM

- Add Join our Discord link to description

- Trailer
- Gameplay segment
- Decide on which maps to show - we don't have do to a lot
- de_cyberaqua
- virtual_reality_1
- de_silo
- de_rambo
- de_duel_practice
- For trailer it's enough only the shown maps are copyright-free
- We can fix other maps post-release
- 1) No intro, just fade into gameplay right away
- 2) A ~5 second gameplay segment per each map with map name shown in top left every time
- Editor segment
- 1) "Create custom maps from scratch!" - Simple Map creation timelapse
- Just make a good map offline to prepare a long command history. THEN turn on obs recording whilst you replay actions with Redo.
- (Instead of trying to record a perfect session of you creating the map)
- 2) "Clone existing maps!" ~10 sec segment - Close up on tweaking existing full-blown maps like cyberaqua with shown mouse movements.
- 3) "Playtest your work online with a single click!" - ~5 sec segment
## For trailer

- simple chat/rcon commands to set players by nickname in position and give them weapons would come a long way
- text area in rcon even
- on exec, autorestart round if it's won/lost already
- give a hotkey to exec custom rcon commands
- seteq nickname 2Xzamiec electric_armor
- we have to do 2X because with "zamiec zamiec" we don't know if the other should be held or in backpack

- Preps
- Decide sound effects

## Post trailer (During review)

- fix those movement flags not propagading through respawns in ffa

- Host multiple official servers to accomodate a potential spike in the number of players
- Each instance will can have the same config directory
- Except they will have differing configs for map cycles, no?
- We can make a --config CLI to read another config from the cwd that works like config.force.lua
- server1.force.lua
- server2.force.lua (all can be next to config.force.lua)
- etc.
- Otherwise they'll all just read from .config/Hypersomnia or local folder

- Miniature generation should trigger "dirty" revision
- logarithmic audio slider

- we'll seriously need to support reading user files from a different cwd
- + trivial appimage launches
Expand All @@ -40,12 +46,8 @@ summary: That which we are brainstorming at the moment.
- set by AppRun to $HOME/.config so we don't have to call readenv
- default will just work like always

- Consider taking the small logo from hypersomnia overlayed over pavement rather than glass


- logarithmic audio slider

- fix small capsule
- GIFs for Steam description
- Add Join our Discord link to description

# REST

Expand Down
3 changes: 3 additions & 0 deletions docs/pages/todo/todo_done.md
Original file line number Diff line number Diff line change
Expand Up @@ -6642,3 +6642,6 @@ This will discard your redo history."
- Ricochets chapter should come immediately after shooting chapter
- Leave backpack/deagles akimbo chapter at the end

- Consider taking the small logo from hypersomnia overlayed over pavement rather than glass

- fix small capsule
1 change: 1 addition & 0 deletions hypersomnia/default_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ return {
U = "TEAM_CHAT",

F8 = "SERVER_ADMIN_PANEL",
F10 = "EXECUTE_RCON_GAME_COMMANDS",

RightMouseButton = "SPECTATE_PREVIOUS",
LeftMouseButton = "SPECTATE_NEXT"
Expand Down
1 change: 1 addition & 0 deletions src/application/app_intent_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum class general_gui_intent_type {
TEAM_CHAT,
BUY_MENU,
SERVER_ADMIN_PANEL,
EXECUTE_RCON_GAME_COMMANDS,

CHOOSE_TEAM,

Expand Down
5 changes: 5 additions & 0 deletions src/application/gui/client/client_gui_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ bool client_gui_state::control(const handle_input_before_game_input in) {
s = !s;
return true;
}

if (*it == general_gui_intent_type::EXECUTE_RCON_GAME_COMMANDS) {
rcon.request_execute_custom_game_commands = true;
return true;
}

auto invoke_chat = [&](const chat_target_type t) {
chat.open_input_bar(t);
Expand Down
3 changes: 3 additions & 0 deletions src/application/gui/client/rcon_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "application/setups/client/rcon_pane.h"
#include "application/setups/server/server_vars.h"
#include "application/setups/server/rcon_level.h"
#include "game/modes/mode_commands/mode_entropy_structs.h"
#include "augs/log.h"

struct rcon_gui_state {
Expand All @@ -12,6 +13,8 @@ struct rcon_gui_state {
server_vars edited_sv_vars;

server_runtime_info runtime_info;
custom_game_commands_string_type custom_commands_text;
bool request_execute_custom_game_commands = false;

bool show = false;

Expand Down
32 changes: 32 additions & 0 deletions src/application/gui/client/rcon_gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
#include "augs/misc/imgui/imgui_utils.h"
#include "application/setups/debugger/detail/maybe_different_colors.h"

template <class F>
void do_pending_rcon_payloads(
rcon_gui_state& state,
F&& on_new_payload
) {
auto& custom_commands = state.custom_commands_text;

if (state.request_execute_custom_game_commands) {
on_new_payload(custom_commands);
state.request_execute_custom_game_commands = false;
}
}

template <class F>
void perform_rcon_gui(
rcon_gui_state& state,
Expand All @@ -23,6 +36,7 @@ void perform_rcon_gui(
centered_text(window_name);

const auto level = state.level;
auto& custom_commands = state.custom_commands_text;

if (level == rcon_level_type::INTEGRATED_ONLY) {
text_color("This is an integrated server. Only the host has RCON access.", red);
Expand Down Expand Up @@ -113,6 +127,24 @@ void perform_rcon_gui(
do_command_button(format_enum(cmd), cmd);
});

ImGui::Separator();

text_color("Execute custom game commands", yellow);

input_multiline_text("##CommandsArea", custom_commands, 10);

{
const auto len = custom_commands.length();
const bool len_valid = len > 0 && len <= default_max_std_string_length_v;

auto scope = maybe_disabled_cols({}, !len_valid);

if (ImGui::Button("Execute") || state.request_execute_custom_game_commands) {
on_new_payload(custom_commands);
state.request_execute_custom_game_commands = false;
}
}

break;


Expand Down
6 changes: 6 additions & 0 deletions src/application/network/net_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ namespace net_messages {
return true;
}

template <class Stream>
bool serialize(Stream& s, std::string& e) {
/* Default to max 8 KB per std::string */
return serialize_stdstring(s, e, 0, default_max_std_string_length_v);
}

template <class Stream>
bool serialize(Stream& s, wielding_setup& p) {
return serialize_trivial_as_bytes(s, p);
Expand Down
19 changes: 11 additions & 8 deletions src/application/network/rcon_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
#include "application/setups/server/server_vars.h"
#include "game/modes/mode_commands/match_command.h"

using custom_game_commands_string_type = std::string;

enum class server_maintenance_command : unsigned char {
SHUTDOWN,
RESTART,
CHECK_FOR_UPDATES_NOW,
REQUEST_RUNTIME_INFO,
DOWNLOAD_LOGS,
SHUTDOWN,
RESTART,
CHECK_FOR_UPDATES_NOW,
REQUEST_RUNTIME_INFO,
DOWNLOAD_LOGS,

COUNT
};
COUNT
};

using rcon_command_variant = std::variant<
std::monostate,
match_command,
server_maintenance_command
server_maintenance_command,
custom_game_commands_string_type
>;
15 changes: 11 additions & 4 deletions src/application/setups/client/client_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ custom_imgui_result client_setup::perform_custom_imgui(
rcon_gui.show = false;
}

if (!arena_gui.scoreboard.show && rcon_gui.show) {
{
auto on_new_payload = [&]<typename P>(const P& new_payload) {
if constexpr(std::is_same_v<P, server_vars>) {
send_payload(
Expand All @@ -1233,11 +1233,18 @@ custom_imgui_result client_setup::perform_custom_imgui(
}
};

const bool is_remote_server = true;
if (!arena_gui.scoreboard.show && rcon_gui.show) {
const bool is_remote_server = true;

perform_rcon_gui(
::perform_rcon_gui(
rcon_gui,
is_remote_server,
on_new_payload
);
}

::do_pending_rcon_payloads(
rcon_gui,
is_remote_server,
on_new_payload
);
}
Expand Down
15 changes: 10 additions & 5 deletions src/application/setups/server/server_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ message_handler_result server_setup::handle_rcon_payload(
constexpr auto abort_v = message_handler_result::ABORT_AND_DISCONNECT;
constexpr auto continue_v = message_handler_result::CONTINUE;

if constexpr(std::is_same_v<P, match_command>) {
if constexpr(is_one_of_v<P, match_command, custom_game_commands_string_type>) {
local_collected.mode_general.special_command = typed_payload;

return continue_v;
Expand Down Expand Up @@ -2312,11 +2312,11 @@ custom_imgui_result server_setup::perform_custom_imgui(const perform_custom_imgu

auto& rcon_gui = integrated_client_gui.rcon;

if (!arena_gui.scoreboard.show && rcon_gui.show) {
auto on_new_payload = [&](const auto& new_payload) {
handle_rcon_payload(rcon_level_type::MASTER, new_payload);
};
auto on_new_payload = [&](const auto& new_payload) {
handle_rcon_payload(rcon_level_type::MASTER, new_payload);
};

if (!arena_gui.scoreboard.show && rcon_gui.show) {
const bool has_maintenance = false;

rcon_gui.level = rcon_level_type::MASTER;
Expand All @@ -2327,6 +2327,11 @@ custom_imgui_result server_setup::perform_custom_imgui(const perform_custom_imgu
on_new_payload
);
}

::do_pending_rcon_payloads(
rcon_gui,
on_new_payload
);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/augs/network/network_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ constexpr std::size_t block_fragment_size_v = 1 * 1024;
constexpr std::size_t max_packet_size_v = 4 * 1024;

constexpr std::size_t max_address_string_length_v = 255;
constexpr std::size_t default_max_std_string_length_v = 1024 * 8;

using server_name_type = augs::constant_size_string<max_server_name_length_v>;
using game_mode_name_type = augs::constant_size_string<max_game_mode_name_length_v>;
Expand Down
1 change: 1 addition & 0 deletions src/game/components/text_details_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace invariants {
static constexpr bool allow_nontriviality = true;

// GEN INTROSPECTOR struct invariants::text_details
entity_name_str resource_id;
entity_name_str name;
entity_name_str description;
// END GEN INTROSPECTOR
Expand Down
Loading

0 comments on commit 9d59bc9

Please sign in to comment.