Skip to content

Commit 3aa690d

Browse files
committed
make folder default to section.
1 parent 4e4883d commit 3aa690d

2 files changed

Lines changed: 4 additions & 32 deletions

File tree

src/game/game_thread.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void GameThread::load_games() {
4646
auto sections = config_reader.Sections();
4747
std::unordered_set<std::string> games_to_open;
4848
for (const auto &section : sections) {
49-
std::string folder_name = config_reader.GetString(section, "folder", "");
49+
std::string folder_name = config_reader.GetString(section, "folder", section);
5050
int tickrate = config_reader.GetInteger(section, "tickrate", 0);
5151
if (tickrate < 16) {
5252
tickrate = 0;
@@ -674,7 +674,6 @@ void GameThread::remove_peer_from_lobby(GameData &game, LobbyData &lobby, std::s
674674
game.lobbies_updated.insert(lobby.id);
675675
if ((is_host && (lobby.disband_on_leave || game.disband_on_leave)) || lobby.peer_ids.empty()) {
676676
game.lobbies.erase(lobby.id);
677-
lobby.close();
678677
}
679678
}
680679

@@ -923,15 +922,8 @@ void GameThread::on_create_lobby(
923922
.create_time = now,
924923
.game_id = peer.game_id,
925924
.sealed = decode_bool_or_default(data_val, "s", game.seal),
926-
.tags = lobby_tags,
927-
.lua = ScriptLua{.scripts_folder = game.lua.scripts_folder,
928-
.folder_name = game.lua.folder_name,
929-
.script_entrypoint = "main.lua",
930-
.logs_folder = game.lua.logs_folder,
931-
.game_thread = this,
932-
.enabled = game.lua.enabled}});
925+
.tags = lobby_tags});
933926
auto &lobby = game.lobbies[small_uuid];
934-
lobby.open();
935927
game.lobby_listing_peers.erase(peer.id);
936928
// SCRIPTED CALL
937929
if (game.enabled_callbacks.find("_can_create_lobby") != game.enabled_callbacks.end()) {
@@ -942,7 +934,6 @@ void GameThread::on_create_lobby(
942934
if (has_error && std::holds_alternative<std::string>(func_result.value)) {
943935
// revert the changes
944936
peer.leave_lobby();
945-
lobby.close();
946937
game.lobbies.erase(small_uuid);
947938
return on_error(game, command_id, peer.id, std::get<std::string>(func_result.value),
948939
false, has_error);
@@ -1896,14 +1887,8 @@ AnyElement GameThread::scripted_function_call(std::string peer_id, std::string l
18961887
bool &has_error) {
18971888
if (game.lua.enabled) {
18981889
AnyElement result;
1899-
if (lobby_id != "" && game.lobbies.find(lobby_id) != game.lobbies.end()) {
1900-
// lobby function call
1901-
auto &lobby = game.lobbies[lobby_id];
1902-
result = lobby.lua.func_call(funcname, args, peer_id, lobby_id, game.id, has_error);
1903-
} else {
1904-
// game function call
1905-
result = game.lua.func_call(funcname, args, peer_id, lobby_id, game.id, has_error);
1906-
}
1890+
// game function call
1891+
result = game.lua.func_call(funcname, args, peer_id, lobby_id, game.id, has_error);
19071892
// if dictionary with error, put error
19081893
auto result_dict =
19091894
std::get_if<boost::container::flat_map<std::string, AnyElement>>(&result.value);

src/game/lobby_data.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <unordered_set>
77

88
#include "../common/any_type.h"
9-
#include "../lua/script_lua.h"
109
#include "peer_data.h"
1110

1211
struct LobbyData {
@@ -34,7 +33,6 @@ struct LobbyData {
3433
bool max_players_dirty = false;
3534
bool sealed_dirty = false;
3635
bool name_dirty = false;
37-
ScriptLua lua;
3836

3937
boost::container::flat_map<std::string, AnyElement> to_dict(bool include_private = false) {
4038
boost::container::flat_map<std::string, AnyElement> lobby_dict;
@@ -53,15 +51,4 @@ struct LobbyData {
5351
}
5452
return lobby_dict;
5553
}
56-
57-
void close() {
58-
if (lua.enabled) {
59-
lua.close();
60-
}
61-
}
62-
void open() {
63-
if (lua.enabled) {
64-
lua.open();
65-
}
66-
}
6754
};

0 commit comments

Comments
 (0)