cmd/flood: add room_num arg

This commit is contained in:
Marcin Kurczewski 2025-03-13 20:49:55 +01:00
parent 3bf7761872
commit 4ba1d96282
3 changed files with 18 additions and 10 deletions

View file

@ -24,7 +24,9 @@ Currently supported commands:
- `/flood`
`/drain`
Floods or drains the current room at will. For when drowning is preferable to puzzles!
- `/flood {room_num}`
`/drain {room_num}`
Floods or drains the chosen room at will. For when drowning is preferable to puzzles!
- `/give {item_name}`
`/give {num} {item_name}`

View file

@ -23,7 +23,9 @@ Currently supported commands:
- `/flood`
`/drain`
Floods or drains the current room at will. For when drowning is preferable to puzzles!
- `/flood {room_num}`
`/drain {room_num}`
Floods or drains the chosen room at will. For when drowning is preferable to puzzles!
- `/give {item_name}`
`/give {num} {item_name}`

View file

@ -7,19 +7,23 @@ static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
if (!String_IsEmpty(ctx->args)) {
return CR_BAD_INVOCATION;
}
int32_t room_num;
if (!String_ParseInteger(ctx->args, &room_num)) {
if (!String_IsEmpty(ctx->args)) {
return CR_BAD_INVOCATION;
}
ITEM *const lara_item = Lara_GetItem();
if (lara_item == nullptr) {
return CR_UNAVAILABLE;
ITEM *const lara_item = Lara_GetItem();
if (lara_item == nullptr) {
return CR_UNAVAILABLE;
}
room_num = lara_item->room_num;
}
if (String_Equivalent(ctx->prefix, "flood")) {
Room_Get(lara_item->room_num)->flags |= RF_UNDERWATER;
Room_Get(room_num)->flags |= RF_UNDERWATER;
} else if (String_Equivalent(ctx->prefix, "drain")) {
Room_Get(lara_item->room_num)->flags &= ~RF_UNDERWATER;
Room_Get(room_num)->flags &= ~RF_UNDERWATER;
} else {
return CR_UNAVAILABLE;
}