fix a lot of issues on psogc; add proxy module
- $ann implemented - concurrency removed; server is now single-threaded, event-driven and much more stable - rare seed is no longer the game id; ids are sequential from server startup so they weren't random at all before - supports dropping privileges; now you can run it as root so it can open a sockets on low ports, then it will switch to the given user before serving any traffic - newserv now behaves like a proxy if you run it with the --proxy-destination=<IP_OR_HOSTNAME> argument; there's also an (invisible) shell in this mode where you can inject commands to the server or client. e.g. it can always be christmas in the lobby if you do `sc DA 01 00 00` - increased the mtu on PSODolphinConfig's tap0 configuration; this seems to make the connection more stable - fixed some uninitialized memory bugs - the shell is now event-driven and now uses libevent too; unfortunately this means readline doesn't work anymore (no history and vim-like shortcuts) - made network command display consistent for input vs. output (the header appears in both cases now) - fixed bugs in some subcommand handling (the BB logic was being applied to non-BB clients erroneously, causing most item drops not to work at all) - fixed player tags in the short lobby data struct. unclear if this was actually a problem but it was inconsistent with other servers - fixed "unused" field in game join command (actually it appears to be disable_udp and should be 1, not 0) - cleaned up Server abstraction a bit - rewrote some text functions; asan was complaining about the built-in ones for some reason - added an optional welcome message
This commit is contained in:
+12
-28
@@ -262,7 +262,7 @@ static void command_ax(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
static void command_announce(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
shared_ptr<Client> c, const char16_t* args) {
|
||||
check_privileges(c, Privilege::Announce);
|
||||
// TODO: implement this
|
||||
send_text_message(s, args);
|
||||
}
|
||||
|
||||
static void command_arrow(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
@@ -289,7 +289,6 @@ static void command_cheat(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
|
||||
// if cheat mode was disabled, turn off all the cheat features that were on
|
||||
if (!(l->flags & LobbyFlag::CheatsEnabled)) {
|
||||
rw_guard g(l->lock, true);
|
||||
for (size_t x = 0; x < l->max_clients; x++) {
|
||||
auto c = l->clients[x];
|
||||
if (!c) {
|
||||
@@ -315,10 +314,7 @@ static void command_lobby_event(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
rw_guard g(l->lock, true);
|
||||
l->event = new_event;
|
||||
}
|
||||
l->event = new_event;
|
||||
send_command(l, 0xDA, l->event, NULL, 0);
|
||||
}
|
||||
|
||||
@@ -339,10 +335,7 @@ static void command_lobby_event_all(shared_ptr<ServerState> s, shared_ptr<Lobby>
|
||||
continue;
|
||||
}
|
||||
|
||||
{
|
||||
rw_guard g(l->lock, true);
|
||||
l->event = new_event;
|
||||
}
|
||||
l->event = new_event;
|
||||
send_command(l, 0xDA, new_event, NULL, 0);
|
||||
}
|
||||
}
|
||||
@@ -360,15 +353,11 @@ static void command_lobby_type(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
rw_guard g(l->lock, true);
|
||||
l->type = new_type;
|
||||
if (l->type < ((l->flags & LobbyFlag::Episode3) ? 20 : 15)) {
|
||||
l->type = l->block - 1;
|
||||
}
|
||||
l->type = new_type;
|
||||
if (l->type < ((l->flags & LobbyFlag::Episode3) ? 20 : 15)) {
|
||||
l->type = l->block - 1;
|
||||
}
|
||||
|
||||
rw_guard g(l->lock, false);
|
||||
for (size_t x = 0; x < l->max_clients; x++) {
|
||||
if (l->clients[x]) {
|
||||
send_join_lobby(l->clients[x], l);
|
||||
@@ -402,10 +391,7 @@ static void command_min_level(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
check_is_leader(l, c);
|
||||
|
||||
u16string buffer;
|
||||
{
|
||||
rw_guard g(l->lock, true);
|
||||
l->min_level = stoull(encode_sjis(args)) - 1;
|
||||
}
|
||||
l->min_level = stoull(encode_sjis(args)) - 1;
|
||||
send_text_message_printf(l, "$C6Minimum level set to %" PRIu32,
|
||||
l->min_level + 1);
|
||||
}
|
||||
@@ -415,12 +401,9 @@ static void command_max_level(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
check_is_game(l, true);
|
||||
check_is_leader(l, c);
|
||||
|
||||
{
|
||||
rw_guard g(l->lock, true);
|
||||
l->max_level = stoull(encode_sjis(args)) - 1;
|
||||
if (l->max_level >= 200) {
|
||||
l->max_level = 0xFFFFFFFF;
|
||||
}
|
||||
l->max_level = stoull(encode_sjis(args)) - 1;
|
||||
if (l->max_level >= 200) {
|
||||
l->max_level = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
if (l->max_level == 0xFFFFFFFF) {
|
||||
@@ -576,7 +559,6 @@ static void command_silence(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
return;
|
||||
}
|
||||
|
||||
rw_guard g(target->lock, true);
|
||||
target->can_chat = !target->can_chat;
|
||||
send_text_message_printf(l, "$C6%s %ssilenced", target->player.disp.name,
|
||||
target->can_chat ? "un" : "");
|
||||
@@ -726,6 +708,8 @@ static void command_item(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
memcpy(&l->next_drop_item.data.item_data1, data.data(), 12);
|
||||
memcpy(&l->next_drop_item.data.item_data2, data.data() + 12, 12 - data.size());
|
||||
}
|
||||
|
||||
send_text_message(c, u"$C6Next drop chosen.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user