mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-23 09:45:53 +02:00
Sort servers by players by default; allow / in server names
- The server browser opens sorted by most players, in the overlay and the native menu; official and friends' servers still come first - Dedicated server names may contain "/" (builds before this hide a server whose name has one)
This commit is contained in:
1 parent
101e1af6e4
commit
3d259667d7
6 files changed
+14
-11
No files matched your search
@@ -13,16 +13,16 @@
|
||||
|
||||
namespace dingosdk {
|
||||
constexpr unsigned max_map_rotation = 1440; // minutes a server's rotation keeps one map, at most
|
||||
// A dedicated server's name: 1 to 64 letters, digits, spaces and - _ [ ] ( ), with a
|
||||
// A dedicated server's name: 1 to 64 letters, digits, spaces and - _ / [ ] ( ), with a
|
||||
// letter or digit among them and no space at either end. A server refuses any other
|
||||
// name, and the server browser does not show one.
|
||||
inline constexpr char server_name_rule[] = "1 to 64 letters, numbers, spaces and - _ [ ] ( )";
|
||||
inline constexpr char server_name_rule[] = "1 to 64 letters, numbers, spaces and - _ / [ ] ( )";
|
||||
[[nodiscard]] constexpr bool valid_server_name(std::string_view name) noexcept {
|
||||
if (name.empty() || name.size() > 64 || name.front() == ' ' || name.back() == ' ') return false;
|
||||
bool named{};
|
||||
for (const auto c : name) {
|
||||
const bool word = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
|
||||
if (!word && std::string_view(" -_[]()").find(c) == std::string_view::npos) return false;
|
||||
if (!word && std::string_view(" -_/[]()").find(c) == std::string_view::npos) return false;
|
||||
named |= word;
|
||||
}
|
||||
return named;
|
||||
|
||||
@@ -57,6 +57,7 @@ int main() {
|
||||
check(missing_tabs({1, 2, 3, 4}, 8, false) == std::vector<unsigned>{0},
|
||||
"The Multiplayer page does not wait for the overlay's tool callbacks");
|
||||
MultiplayerModel model;
|
||||
const BrowserOptions by_name{{}, false, Sort::name};
|
||||
model.local_id = 77; model.map = "Levels/San_Vansterdam";
|
||||
for (unsigned i = 0; i < 14; ++i) {
|
||||
MultiplayerLobby lobby;
|
||||
@@ -66,7 +67,7 @@ int main() {
|
||||
lobby.players = static_cast<int>(i + 1); lobby.capacity = 16;
|
||||
model.lobbies.push_back(lobby);
|
||||
}
|
||||
auto result = browse(model, {});
|
||||
auto result = browse(model, by_name);
|
||||
check(result.total == 14 && result.lobbies.size() == 14, "All matching lobbies remain scrollable");
|
||||
check(result.lobbies.front()->id == 100 && result.lobbies[6]->id == 112 && result.lobbies.back()->id == 113,
|
||||
"Stable ordering of duplicate names across the full list");
|
||||
@@ -84,12 +85,12 @@ int main() {
|
||||
result = browse(model, options);
|
||||
check(result.lobbies[0]->id == 105 && result.lobbies[1]->id == 102 && result.lobbies[2]->players == 14,
|
||||
"Official servers are not first when sorting by players");
|
||||
result = browse(model, {});
|
||||
result = browse(model, by_name);
|
||||
check(result.lobbies[0]->id == 102 && result.lobbies[1]->id == 105 && result.lobbies[2]->id == 100,
|
||||
"Official servers are not first when sorting by name");
|
||||
// Then the servers friends are in, which a search for a friend's name finds too.
|
||||
model.lobbies[9].friends = {"Ana"};
|
||||
result = browse(model, {});
|
||||
result = browse(model, by_name);
|
||||
check(result.lobbies[0]->id == 102 && result.lobbies[1]->id == 105 && result.lobbies[2]->id == 109 && result.lobbies[3]->id == 100,
|
||||
"A friend's server is not next after the official ones");
|
||||
BrowserOptions by_friend;
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
namespace dingosdk::multiplayer::menu_view {
|
||||
enum class Sort { name, players, map };
|
||||
struct BrowserOptions { std::string query; bool same_map{}; Sort sort{}; };
|
||||
// The busiest servers first, until the player picks another order.
|
||||
struct BrowserOptions { std::string query; bool same_map{}; Sort sort = Sort::players; };
|
||||
|
||||
// Owned pages: Multiplayer and Custom Stuff (needs the overlay's tool callbacks).
|
||||
inline constexpr unsigned page_count = 2, tools_page = 1;
|
||||
|
||||
@@ -31,7 +31,7 @@ struct SkateMenu {
|
||||
std::optional<int> map_rotation_pending; // the rotation slider, likewise
|
||||
double map_rotation_until{};
|
||||
bool ban_confirm_on_server{}; // the Ban popup bans from a dedicated server
|
||||
int multiplayer_lobby_sort = 0;
|
||||
int multiplayer_lobby_sort = 1; // most players first
|
||||
float multiplayer_code_height = 0; // what the join-by-code card took last frame
|
||||
// Bans: the manual add form, and the player a Ban button is asking about.
|
||||
std::array<char, 24> ban_id{};
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ straight away (players are told to rejoin). Turn this off with
|
||||
|
||||
ReSkateServer.json
|
||||
------------------
|
||||
name Shown in the browser: 1-64 letters, numbers, spaces and - _ [ ] ( ).
|
||||
name Shown in the browser: 1-64 letters, numbers, spaces and - _ / [ ] ( ).
|
||||
map The map everyone skates, named like the game's load command:
|
||||
"San Vansterdam", "Isle of Grom", "Super Ultra Mega Resort",
|
||||
"Stadium 1", or a custom map such as "bbcity" (see Custom maps).
|
||||
|
||||
@@ -62,8 +62,9 @@ int run() {
|
||||
check(token_refused(tokened), "An overlong steam_token was accepted");
|
||||
save_config(reloaded);
|
||||
|
||||
// Server names: letters, digits, spaces and - _ [ ] ( ) only.
|
||||
check(valid_server_name("Old Server") && valid_server_name("[EU] Skate_Park-2 (24x7)") && valid_server_name("a"),
|
||||
// Server names: letters, digits, spaces and - _ / [ ] ( ) only.
|
||||
check(valid_server_name("Old Server") && valid_server_name("[EU] Skate_Park-2 (24x7)") && valid_server_name("a") &&
|
||||
valid_server_name("EU/West 24/7") && !valid_server_name("///") && !valid_server_name("a\\b"),
|
||||
"A plain server name was refused");
|
||||
check(!valid_server_name("") && !valid_server_name(std::string(65, 'a')) && !valid_server_name("Best! Server") &&
|
||||
!valid_server_name("caf\xC3\xA9") && !valid_server_name("a.b") && !valid_server_name("<b>x</b>") &&
|
||||
|
||||
Reference in new issue
Block a user