Add rsave command

This commit is contained in:
kinther 2025-09-25 09:35:23 -07:00
parent b9acbbba9f
commit 2703cbcf25
5 changed files with 64 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#R 100 1758817753
.
#R 134 1758817885
O 132 0 200 0 0
X 0 0
X 1 0
X 2 0
X 3 0
W 0 0
W 1 0
W 2 0
W 3 0
V 0 8
V 1 0
V 2 0
V 3 0
V 4 0
V 5 0
V 6 0
V 7 0
.

View file

@ -327,6 +327,7 @@ ACMD(do_recent);
ACMD(do_restore);
void return_to_char(struct char_data * ch);
ACMD(do_return);
ACMD(do_rsave);
ACMD(do_saveall);
ACMD(do_send);
ACMD(do_set);

View file

@ -35,6 +35,7 @@
#include "quest.h"
#include "ban.h"
#include "screen.h"
#include "roomsave.h"
/* local utility functions with file scope */
static int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *val_arg);
@ -5876,4 +5877,43 @@ ACMD(do_msave)
}
inv_free_all(&inv);
}
ACMD(do_rsave)
{
room_rnum rnum = IN_ROOM(ch);
if (IS_NPC(ch)) {
send_to_char(ch, "Mobiles cant use this.\r\n");
return;
}
if (rnum == NOWHERE || rnum < 0 || rnum >= top_of_world) {
send_to_char(ch, "You are not in a valid room.\r\n");
return;
}
zone_rnum znum = world[rnum].zone;
if (znum < 0 || znum > top_of_zone_table) {
send_to_char(ch, "This room is not attached to a valid zone.\r\n");
return;
}
/* Builder permission: reuse your standard zone edit check */
if (!can_edit_zone(ch, znum)) {
send_to_char(ch, "You dont have permission to modify zone %d.\r\n",
zone_table[znum].number);
return;
}
/* Save immediately, regardless of ROOM_SAVE flag */
if (RoomSave_now(rnum)) {
send_to_char(ch, "rsave: room %d saved to roomsave file for zone %d.\r\n",
GET_ROOM_VNUM(rnum), zone_table[znum].number);
mudlog(CMP, GET_LEVEL(ch), TRUE, "RSAVE OK: %s saved room %d (zone %d).",
GET_NAME(ch), GET_ROOM_VNUM(rnum), zone_table[znum].number);
} else {
send_to_char(ch, "rsave: failed to save room %d.\r\n", GET_ROOM_VNUM(rnum));
mudlog(BRF, GET_LEVEL(ch), TRUE, "RSAVE FAIL: %s room %d (zone %d).",
GET_NAME(ch), GET_ROOM_VNUM(rnum), zone_table[znum].number);
}
}

View file

@ -257,6 +257,7 @@ void free_help_table(void);
void free_player_index(void);
void load_help(FILE *fl, char *name);
void new_mobile_data(struct char_data *ch);
void equip_mob_from_loadout(struct char_data *mob);
zone_rnum real_zone(zone_vnum vnum);
room_rnum real_room(room_vnum vnum);

View file

@ -261,6 +261,7 @@ cpp_extern const struct command_info cmd_info[] = {
{ "rlist" , "rlist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_RLIST },
{ "rcopy" , "rcopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_REDIT },
{ "roomflags", "roomflags", POS_DEAD , do_gen_tog , LVL_IMMORT, SCMD_SHOWVNUMS },
{ "rsave" , "rsave" , POS_DEAD , do_rsave , LVL_BUILDER, 0 },
{ "say" , "s" , POS_RESTING , do_say , 0, 0 },
{ "score" , "sc" , POS_DEAD , do_score , 0, 0 },