Add ocreate and osave commands

This commit is contained in:
kinther 2025-12-31 14:35:19 -08:00
parent 691e15867e
commit aac7cee6dc
14 changed files with 321 additions and 28 deletions

View file

@ -642,4 +642,12 @@ hide, reinforcing the foot from the ground below.
11 0 0 0 0 ah 0 0 0 0 0 0 0
0 0 0 0
1 40 0 0 0
#168
unfinished object~
unfinished object made by Kinther~
This is an unfinished object created by Kinther on Wed Dec 31 14:19:06 2025~
~
0 0 0 0 0 a 0 0 0 0 0 0 0
0 0 0 0
0 0 0 0 0
$~

View file

@ -20,7 +20,7 @@ PROFILE =
CFLAGS = $(MYFLAGS) $(PROFILE)
OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
act.offensive.o act.other.o act.social.o act.wizard.o ban.o boards.o \
act.offensive.o act.other.o act.social.o act.wizard.o set.o ban.o boards.o \
castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \
house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \
objsave.o shop.o spec_assign.o spec_procs.o spell_parser.o \
@ -115,6 +115,10 @@ act.social.o: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h constants.h
$(CC) -c $(CFLAGS) act.wizard.c
set.o: set.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
$(CC) -c $(CFLAGS) set.c
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) -c $(CFLAGS) ban.c
boards.o: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \

View file

@ -22,7 +22,7 @@ BINDIR = ^.bin
CFLAGS = $(MYFLAGS) $(PROFILE)
OBJFILES = o.comm act.o.comm act.o.informative act.o.movement act.o.item \
act.o.offensive act.o.other act.o.social act.o.wizard o.ban o.boards \
act.o.offensive act.o.other act.o.social act.o.wizard o.set o.ban o.boards \
o.castle o.class o.config o.constants o.db o.fight o.graph o.handler \
o.house o.interpreter o.limits o.magic o.mail o.mobact o.modify \
o.objsave o.random o.shop o.spec_assign o.spec_procs \
@ -73,6 +73,11 @@ act.o.wizard: act.c.wizard h.conf h.sysdep h.structs \
h.utils h.comm h.interpreter h.handler \
h.db h.spells h.house h.screen h.constants
$(CC) -c $(CFLAGS) act.c.wizard -o act.o.wizard
o.set: c.set h.conf h.sysdep h.structs \
h.utils h.comm h.interpreter h.handler \
h.db h.constants h.genobj h.genolc h.genwld h.genzon h.oasis \
h.improved-edit h.modify h.dg_scripts h.set
$(CC) -c $(CFLAGS) c.set -o o.set
o.ban: c.ban h.conf h.sysdep h.structs h.utils h.comm h.interpreter h.handler h.db
$(CC) -c $(CFLAGS) c.ban
o.boards: c.boards h.conf h.sysdep h.structs h.utils h.comm h.db h.boards \

View file

@ -49,6 +49,7 @@ Dep_circledexe = \
act.informative.obj\
act.offensive.obj\
act.other.obj\
set.obj\
boards.obj\
ban.obj\
act.wizard.obj\
@ -93,6 +94,7 @@ act.item.obj+
act.informative.obj+
act.offensive.obj+
act.other.obj+
set.obj+
boards.obj+
ban.obj+
act.wizard.obj+
@ -163,6 +165,11 @@ act.other.obj : act.other.c
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.other.c
|
set.obj : set.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ set.c
|
boards.obj : boards.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ boards.c
@ -339,5 +346,3 @@ BccW32.cfg :
-WC
-g0
| $@

View file

@ -50,6 +50,7 @@ Dep_circledexe = \
act.informative.obj\
act.offensive.obj\
act.other.obj\
set.obj\
boards.obj\
ban.obj\
act.wizard.obj\
@ -94,6 +95,7 @@ act.item.obj+
act.informative.obj+
act.offensive.obj+
act.other.obj+
set.obj+
boards.obj+
ban.obj+
act.wizard.obj+
@ -162,6 +164,11 @@ act.other.obj : act.other.c
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ act.other.c
|
set.obj : set.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ set.c
|
boards.obj : boards.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_circledexe) $(CompInheritOptsAt_circledexe) -o$@ boards.c
@ -339,5 +346,3 @@ BccW32.cfg :
-WC
-g0
| $@

View file

@ -48,6 +48,7 @@ OBJS=\
boards.obj \
ban.obj \
act.wizard.obj \
set.obj \
act.social.obj \
act.other.obj \
act.offensive.obj \
@ -494,6 +495,29 @@ ACT_WIZARD_C=\
act.wizard.obj: $(ACT_WIZARD_C) $(DISTDIR)\src\act.wizard.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.wizard.c
# Build SET.C
SET_C=\
$(DISTDIR)\src\sysdep.h\
$(DISTDIR)\src\structs.h\
$(DISTDIR)\src\utils.h\
$(DISTDIR)\src\comm.h\
$(DISTDIR)\src\interpreter.h\
$(DISTDIR)\src\handler.h\
$(DISTDIR)\src\db.h\
$(DISTDIR)\src\constants.h\
$(DISTDIR)\src\genobj.h\
$(DISTDIR)\src\genolc.h\
$(DISTDIR)\src\genwld.h\
$(DISTDIR)\src\genzon.h\
$(DISTDIR)\src\oasis.h\
$(DISTDIR)\src\improved-edit.h\
$(DISTDIR)\src\modify.h\
$(DISTDIR)\src\dg_scripts.h\
$(DISTDIR)\src\set.h\
set.obj: $(SET_C) $(DISTDIR)\src\set.c
$(CC) $(CFLAGS) $(DISTDIR)\src\set.c
# Build ACT.SOCIAL.C
ACT_SOCIAL_C=\
$(DISTDIR)\src\sysdep.h\
@ -598,4 +622,3 @@ ACT_COMM_C=\
act.comm.obj: $(ACT_COMM_C) $(DISTDIR)\src\act.comm.c
$(CC) $(CFLAGS) $(DISTDIR)\src\act.comm.c

View file

@ -37,6 +37,7 @@ MAKE = $(MAKE) /NOLOGO /S
OBJFILES = comm.obj act.comm.obj act.informative.obj act.movement.obj act.item.obj \
asciimap.obj act.offensive.obj act.other.obj act.social.obj act.wizard.obj \
set.obj \
ban.obj boards.obj castle.obj class.obj config.obj constants.obj db.obj \
dg_event.obj dg_scripts.obj dg_triggers.obj fight.obj genolc.obj graph.obj \
handler.obj house.obj ibt.obj interpreter.obj limits.obj lists.obj magic.obj \
@ -83,6 +84,10 @@ act.social.obj: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
act.wizard.obj: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h constants.h
$(CC) -c $(CFLAGS) act.wizard.c
set.obj: set.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
$(CC) -c $(CFLAGS) set.c
ban.obj: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) -c $(CFLAGS) ban.c
boards.obj: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \

View file

@ -22,7 +22,7 @@ LIB = -lsocket
CFLAGS = $(MYFLAGS) $(PROFILE)
OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
act.offensive.o act.other.o act.social.o act.wizard.o ban.o boards.o \
act.offensive.o act.other.o act.social.o act.wizard.o set.o ban.o boards.o \
castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \
house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \
objsave.o shop.o spec_assign.o spec_procs.o spell_parser.o \
@ -117,6 +117,10 @@ act.social.o: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h constants.h
$(CC) -c $(CFLAGS) act.wizard.c
set.o: set.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
$(CC) -c $(CFLAGS) set.c
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) -c $(CFLAGS) ban.c
boards.o: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \

View file

@ -18,7 +18,7 @@ CFLAGS = NOLINK $(MYFLAGS) $(PROFILE)
MAKE = SMAKE
OBJFILES = comm.o act.comm.o act.informative.o act.movement.o act.item.o \
act.offensive.o act.other.o act.social.o act.wizard.o ban.o boards.o \
act.offensive.o act.other.o act.social.o act.wizard.o set.o ban.o boards.o \
castle.o class.o config.o constants.o db.o fight.o graph.o handler.o \
house.o interpreter.o limits.o magic.o mail.o mobact.o modify.o \
objsave.o olc.o shop.o spec_assign.o spec_procs.o spell_parser.o \
@ -109,6 +109,10 @@ act.social.o: act.social.c conf.h sysdep.h structs.h utils.h comm.h \
act.wizard.o: act.wizard.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h spells.h house.h screen.h
$(CC) $(CFLAGS) act.wizard.c
set.o: set.c conf.h sysdep.h structs.h utils.h comm.h \
interpreter.h handler.h db.h constants.h genolc.h genwld.h genzon.h \
oasis.h improved-edit.h modify.h genobj.h dg_scripts.h set.h
$(CC) $(CFLAGS) set.c
ban.o: ban.c conf.h sysdep.h structs.h utils.h comm.h interpreter.h handler.h db.h
$(CC) $(CFLAGS) ban.c
boards.o: boards.c conf.h sysdep.h structs.h utils.h comm.h db.h boards.h \
@ -189,4 +193,3 @@ utils.o: utils.c conf.h sysdep.h structs.h utils.h comm.h screen.h spells.h \
weather.o: weather.c conf.h sysdep.h structs.h utils.h comm.h handler.h \
interpreter.h db.h
$(CC) $(CFLAGS) weather.c

View file

@ -19,7 +19,7 @@
#define _ACT_H_
#include "utils.h" /* for the ACMD macro */
#include "rset.h"
#include "set.h"
#ifndef MAX_EMOTE_TOKENS
#define MAX_EMOTE_TOKENS 16

View file

@ -229,7 +229,9 @@ cpp_extern const struct command_info cmd_info[] = {
{ "olc" , "olc" , POS_DEAD , do_show_save_list, LVL_BUILDER, 0 },
{ "olist" , "olist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_OLIST },
{ "oedit" , "oedit" , POS_DEAD , do_oasis_oedit, LVL_BUILDER, 0 },
{ "ocreate" , "ocreate" , POS_DEAD , do_ocreate , LVL_BUILDER, 0 },
{ "ooc" , "oo" , POS_RESTING , do_ooc , 0, 0 },
{ "osave" , "osave" , POS_DEAD , do_osave , LVL_BUILDER, 0 },
{ "oset" , "oset" , POS_DEAD , do_oset, LVL_BUILDER, 0 },
{ "ocopy" , "ocopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_OEDIT },

View file

@ -1,14 +0,0 @@
/**
* @file rset.h
* Room creation/configuration and utility headers.
*
* This set of code was not originally part of the circlemud distribution.
*/
#ifndef RSET_H
#define RSET_H
ACMD(do_rset);
ACMD(do_rcreate);
#endif

View file

@ -1,6 +1,6 @@
/**
* @file rset.c
* Room creation/configuration and utility routines.
* @file set.c
* Builder room/object creation and utility functions.
*
* This set of code was not originally part of the circlemud distribution.
*/
@ -21,8 +21,10 @@
#include "oasis.h"
#include "improved-edit.h"
#include "modify.h"
#include "genobj.h"
#include "dg_scripts.h"
#include "rset.h"
#include "set.h"
static void rset_show_usage(struct char_data *ch)
{
@ -1290,3 +1292,230 @@ ACMD(do_rset)
rset_show_usage(ch);
}
static struct obj_data *find_obj_vnum_nearby(struct char_data *ch, obj_vnum vnum)
{
struct obj_data *obj;
if (!ch || IN_ROOM(ch) == NOWHERE)
return NULL;
for (obj = ch->carrying; obj; obj = obj->next_content)
if (CAN_SEE_OBJ(ch, obj) && GET_OBJ_VNUM(obj) == vnum)
return obj;
for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj->next_content)
if (CAN_SEE_OBJ(ch, obj) && GET_OBJ_VNUM(obj) == vnum)
return obj;
return NULL;
}
ACMD(do_ocreate)
{
char arg[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
char namebuf[MAX_NAME_LENGTH];
char timestr[MAX_STRING_LENGTH];
struct obj_data *newobj;
struct obj_data *obj;
obj_vnum vnum;
zone_rnum znum;
time_t ct;
if (IS_NPC(ch) || ch->desc == NULL) {
send_to_char(ch, "ocreate is only usable by connected players.\r\n");
return;
}
one_argument(argument, arg);
if (!*arg) {
send_to_char(ch,
"Creates a new unfinished object which can be configured.\r\n"
"\r\n"
"Usage:\r\n"
" ocreate <vnum>\r\n"
"\r\n"
"Examples:\r\n"
" ocreate 1001\r\n");
return;
}
if (!is_number(arg)) {
send_to_char(ch,
"Creates a new unfinished object which can be configured.\r\n"
"\r\n"
"Usage:\r\n"
" ocreate <vnum>\r\n"
"\r\n"
"Examples:\r\n"
" ocreate 1001\r\n");
return;
}
vnum = atoi(arg);
if (vnum < IDXTYPE_MIN || vnum > IDXTYPE_MAX) {
send_to_char(ch, "That object VNUM can't exist.\r\n");
return;
}
if (real_object(vnum) != NOTHING) {
send_to_char(ch, "Object %d already exists.\r\n", vnum);
return;
}
znum = real_zone_by_thing(vnum);
if (znum == NOWHERE) {
send_to_char(ch, "Sorry, there is no zone for that number!\r\n");
return;
}
if (!can_edit_zone(ch, znum)) {
send_cannot_edit(ch, zone_table[znum].number);
return;
}
CREATE(newobj, struct obj_data, 1);
clear_object(newobj);
newobj->name = strdup("unfinished object");
strlcpy(namebuf, GET_NAME(ch), sizeof(namebuf));
snprintf(buf, sizeof(buf), "unfinished object made by %s", namebuf);
newobj->short_description = strdup(buf);
ct = time(0);
strftime(timestr, sizeof(timestr), "%c", localtime(&ct));
snprintf(buf, sizeof(buf),
"This is an unfinished object created by %s on ", namebuf);
strlcat(buf, timestr, sizeof(buf));
newobj->description = strdup(buf);
SET_BIT_AR(GET_OBJ_WEAR(newobj), ITEM_WEAR_TAKE);
if (add_object(newobj, vnum) == NOTHING) {
free_object_strings(newobj);
free(newobj);
send_to_char(ch, "ocreate: failed to add object %d.\r\n", vnum);
return;
}
if (in_save_list(zone_table[znum].number, SL_OBJ))
remove_from_save_list(zone_table[znum].number, SL_OBJ);
free_object_strings(newobj);
free(newobj);
obj = read_object(vnum, VIRTUAL);
if (obj == NULL) {
send_to_char(ch, "ocreate: failed to instantiate object %d.\r\n", vnum);
return;
}
obj_to_char(obj, ch);
send_to_char(ch,
"Object %d created (temporary). Use osave to write it to disk.\r\n",
vnum);
}
ACMD(do_osave)
{
char arg[MAX_INPUT_LENGTH];
struct obj_data *obj;
struct obj_data *proto;
obj_rnum robj_num;
obj_vnum vnum;
zone_rnum znum;
if (IS_NPC(ch) || ch->desc == NULL) {
send_to_char(ch, "osave is only usable by connected players.\r\n");
return;
}
one_argument(argument, arg);
if (!*arg) {
send_to_char(ch,
"Saves an object and its current properties to disk, which will load upon next boot.\r\n"
"\r\n"
"Usage:\r\n"
" osave <vnum>\r\n"
"\r\n"
"Examples:\r\n"
" osave 1001\r\n");
return;
}
if (!is_number(arg)) {
send_to_char(ch,
"Saves an object and its current properties to disk, which will load upon next boot.\r\n"
"\r\n"
"Usage:\r\n"
" osave <vnum>\r\n"
"\r\n"
"Examples:\r\n"
" osave 1001\r\n");
return;
}
vnum = atoi(arg);
if (vnum < IDXTYPE_MIN || vnum > IDXTYPE_MAX) {
send_to_char(ch, "That object VNUM can't exist.\r\n");
return;
}
obj = find_obj_vnum_nearby(ch, vnum);
if (obj == NULL) {
send_to_char(ch,
"osave: object %d is not in your inventory or room.\r\n", vnum);
return;
}
znum = real_zone_by_thing(vnum);
if (znum == NOWHERE) {
send_to_char(ch, "Sorry, there is no zone for that number!\r\n");
return;
}
if (!can_edit_zone(ch, znum)) {
send_cannot_edit(ch, zone_table[znum].number);
return;
}
CREATE(proto, struct obj_data, 1);
clear_object(proto);
copy_object(proto, obj);
proto->in_room = NOWHERE;
proto->carried_by = NULL;
proto->worn_by = NULL;
proto->worn_on = NOWHERE;
proto->in_obj = NULL;
proto->contains = NULL;
proto->next_content = NULL;
proto->next = NULL;
proto->sitting_here = NULL;
proto->events = NULL;
proto->script = NULL;
proto->script_id = 0;
if ((robj_num = add_object(proto, vnum)) == NOTHING) {
free_object_strings(proto);
free(proto);
send_to_char(ch, "osave: failed to update object %d.\r\n", vnum);
return;
}
free_object_strings(proto);
free(proto);
for (obj = object_list; obj; obj = obj->next) {
if (obj->item_number != robj_num)
continue;
if (SCRIPT(obj))
extract_script(obj, OBJ_TRIGGER);
free_proto_script(obj, OBJ_TRIGGER);
copy_proto_script(&obj_proto[robj_num], obj, OBJ_TRIGGER);
assign_triggers(obj, OBJ_TRIGGER);
}
save_objects(znum);
send_to_char(ch, "osave: object %d saved to disk.\r\n", vnum);
}

14
src/set.h Normal file
View file

@ -0,0 +1,14 @@
/**
* @file set.h
* Builder room/object creation and utility headers.
*/
#ifndef SET_H
#define SET_H
ACMD(do_rset);
ACMD(do_rcreate);
ACMD(do_ocreate);
ACMD(do_osave);
#endif