add $whatene command

This commit is contained in:
Martin Michelsen
2025-03-29 21:50:11 -07:00
parent e0d1db0363
commit d9c549bef5
2 changed files with 106 additions and 92 deletions
+1 -1
View File
@@ -555,7 +555,7 @@ Some commands only work on the game server and not on the proxy server. The chat
* You'll be placed into the last available slot in lobbies and games instead of the first, unless you're joining a BB solo-mode game.
* You'll be able to join games with any PSO version, not only those for which cross-version play is normally enabled. See the "Cross-version play" section above for details on this.
* Most of the commands in this section are enabled. (A few of them are always enabled and don't require `$debug`.)
* `$whatobj` (game server only): Tells you what the closest object is to your position, along with its coordinates and object ID. The object's full definition is also printed to the server's log. This command can be used without `$debug` enabled.
* `$whatobj` and `$whatene` (game server only): Tells you what the closest object or enemy spawn point is to your position, along with its coordinates and object or enemy ID. The full definition is also printed to the server's log. These commands can be used without `$debug` enabled.
* `$readmem <address>` (game server only): Read 4 bytes from the given address and show you the values.
* `$writemem <address> <data>` (game server only): Write data to the given address. Data is not required to be any specific size.
* `$nativecall <address> [arg1 ...]` (game server only, GC only): Call a native function on your client. Only arguments passed in registers are supported; calling functions that take many arguments is not supported.
+17 -3
View File
@@ -2771,9 +2771,7 @@ ChatCommandDefinition cc_what(
},
unavailable_on_proxy_server);
ChatCommandDefinition cc_whatobj(
{"$whatobj"},
+[](const ServerArgs& a) -> void {
static void whatobj_whatene_fn(const ServerArgs& a, bool include_objs, bool include_enes) {
auto s = a.c->require_server_state();
auto l = a.c->require_lobby();
a.check_is_game(true);
@@ -2822,6 +2820,7 @@ ChatCommandDefinition cc_whatobj(
}
};
if (include_objs) {
for (const auto& it : l->map_state->iter_object_states(a.c->version())) {
if (it->super_obj && (it->super_obj->floor == a.c->floor)) {
const auto& def = it->super_obj->version(a.c->version());
@@ -2830,6 +2829,8 @@ ChatCommandDefinition cc_whatobj(
}
}
}
}
if (include_enes) {
for (const auto& it : l->map_state->iter_enemy_states(a.c->version())) {
if (it->super_ene && (it->super_ene->floor == a.c->floor)) {
const auto& def = it->super_ene->version(a.c->version());
@@ -2838,6 +2839,7 @@ ChatCommandDefinition cc_whatobj(
}
}
}
}
// Since we check all objects first, nearest_ene will only be set if
// there is an enemy closer than all objects. So, we print that if it's
@@ -2865,6 +2867,18 @@ ChatCommandDefinition cc_whatobj(
} else {
throw precondition_failed("$C4No objects or\nenemies are nearby");
}
}
ChatCommandDefinition cc_whatobj(
{"$whatobj"},
+[](const ServerArgs& a) -> void {
whatobj_whatene_fn(a, true, false);
},
unavailable_on_proxy_server);
ChatCommandDefinition cc_whatene(
{"$whatene"},
+[](const ServerArgs& a) -> void {
whatobj_whatene_fn(a, false, true);
},
unavailable_on_proxy_server);