Files
grenzland-mud/src/oedit.c
Rumble ebc985f010 jeremyosborne | 2008-04-04 02:36:38 +0200 (Fri, 04 Apr 2008) | 1 line
Minor Bugfix: All game configuration settings now reference the world config 
structure, not the individual config variables found in config.c.
------------------------------------------------------------------------
 rumble | 2008-03-22 13:27:00 +0100 (Sat, 22 Mar 2008) | 1 line

Added lib/world/qst/ directory, index, index.mini, and 0.qst.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:27:51 +0100 (Sat, 08 Mar 2008) | 3 lines

Bugfix: the include directory (for .h files) is now referenced correctly in the
depend statement.
Deletion: listrent.c removed as a separate utility.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:08:51 +0100 (Sat, 08 Mar 2008) | 1 line

Enhancement: utils/ Makefile will now use a depends file, and looks for dependen
cies in the ../ directory (shrinks the necessary information to make each utilit
y).
------------------------------------------------------------------------
 Rumble | 2008-03-06 23:39:35 +0100 (Thu, 06 Mar 2008) | 1 line

Made TBA specific changes. do_cheat, removed help level checking, and advance to
level 32.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:37:12 +0100 (Thu, 06 Mar 2008) | 1 line

Minor Update: Changed header of Makefile.in to read 'tbaMUD' and also added in a
ttribution for the changes. (Thanks seqwith.)
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:31:07 +0100 (Thu, 06 Mar 2008) | 4 lines

Changed Makefile.in to use glob expressions when building the objects. This 
translates into no longer a need to update Makefile.in whenever a new .c file 
is added to the mud code. Other Makefile.* have not yet been changed (and 
need review, anyway).

All CXREF cruft left in Makefile.in has been removed. tbaMUD is now using 
Doxygen. Technically, CXREF provides a bit more auto-documentation than Doxygen
does, however the tbaMUD (and legacy circle code) has never been marked-up with 
the special CXREF codes required to effectively use the program. Since Doxygen 
is easier to use, and provides almost as much functionality as CXREF, CXREF 
support has been dropped.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:31:02 +0100 (Thu, 06 Mar 2008) | 1 line

Bug Fix: asciiflag_conv* functions now can handle a negative numeric value.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:16:06 +0100 (Thu, 06 Mar 2008) | 1 line

Bug fix/enhancement: Charmed mobs (specifically charmed mobs with a ->master) 
will no longer attempt to wander off.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:13:38 +0100 (Thu, 06 Mar 2008) | 6 lines

Based on the compiler warning about mag_materials being an unused function, and
the clone spell being unused.

Bug fix: Clone can now be cast. It is an 'ignore' target spell.

Fix and Modification: Clone, being an effectively unused spell that is only used
by mortal Magic Users at level 30, is now implemented as very simple example of
how to use mag_materials(). The item required by mag_materials is vnum 161, 
which in stock tbaMUD is some sacrificial entrails.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:43:09 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix for "Did you mean:" including DG commands.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:29:18 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix: do_simple_move slightly rewritten to handle Leave triggers that purge a
 door.

Documentation: do_simple_move documented.
------------------------------------------------------------------------
 Laoris | 2008-03-01 08:22:12 +0100 (Sat, 01 Mar 2008) | 1 line

Trial run of columnizer function on commands list to see how people like it.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-26 22:36:17 +0100 (Tue, 26 Feb 2008) | 1 line

asciimap, an in game automap, along with a couple of minor bug fixes to do with
the automap, patched in (Thanks Jamdog).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:08:05 +0100 (Fri, 22 Feb 2008) | 1 line

Minor update: Relocate local variable declaration to the top of ACMD(do_help)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:04:37 +0100 (Fri, 22 Feb 2008) | 6 lines

Checked in the following placeholders for do_gen_tog:
#define SCMD_AUTOLOOT   24
#define SCMD_AUTOGOLD   25
#define SCMD_AUTOSPLIT  26
#define SCMD_AUTOSAC    27
#define SCMD_AUTOASSIST 28
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 03:57:06 +0100 (Fri, 22 Feb 2008) | 1 line

The Autoquest patch, along with a couple of minor bug fixes, has been integrated
into tbaMUD. (Thanks Jamdog, Kenneth Ray and Morgaelin.)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 21:46:45 +0100 (Mon, 18 Feb 2008) | 2 lines

Minor Fix:
Casted NOWHERE, NOTHING, NOBODY and NOFLAG as IDXTYPE for the signed short int 
index types.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 03:36:16 +0100 (Mon, 18 Feb 2008) | 7 lines

Added a new atoidx() conversion function for dealing with string to IDXTYPE 
conversions (in utils.c, prototype exported through utils.h).
Added IDXTYPE_MIN and IDXTYPE_MAX defines (in structs.h).
Replaced atoi references with atoidx in do_oasis_zedit (in zedit.c).
------------------------------------------------------------------------
 Rumble | 2008-02-18 01:44:13 +0100 (Mon, 18 Feb 2008) | 1 line

Fixed direction mapping to give readable directions instead of sub commands. 
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:26:15 +0100 (Mon, 18 Feb 2008) | 5 lines

Since general olc editing are automatically saved to disk, 'shutdown reboot' has
been changed to not-autosave by default. (Small change made to do_shutdown in 
act.wizard.c).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:12:12 +0100 (Mon, 18 Feb 2008) | 3 lines

Changed:
struct attack_hit_type moved to fight.h
attack_hit_text exported through fight.h
------------------------------------------------------------------------
 jeremyosborne | 2008-02-17 22:32:51 +0100 (Sun, 17 Feb 2008) | 7 lines

- do_file heads or tails files correctly and has also been enhanced to return 
file info (act.wizard.c)
- defines made for common log files created by autorun, and those used by 
do_file (db.h)
- utility functions added: file_head(), file_tail(), file_sizeof(), and 
file_numlines() (defined utils.c and exported through utils.h)
------------------------------------------------------------------------
 Rumble | 2008-02-16 23:24:05 +0100 (Sat, 16 Feb 2008) | 1 line

Fixed export command. (thanks Kyle)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-16 22:42:46 +0100 (Sat, 16 Feb 2008) | 1 line

Files are now tagged as executable. Should be able to be checked out from subver
sion and executed without running chmod.
------------------------------------------------------------------------
 Rumble | 2008-02-15 17:03:06 +0100 (Fri, 15 Feb 2008) | 1 line

 Fixed strcat() writing out of bounds in cedit.c since strdup() only malloc() 
strlen(str)+1 bytes. (thanks Buggo) and moved attack_hit_text back.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-13 20:41:02 +0100 (Wed, 13 Feb 2008) | 1 line

Event queue function definitions, global variables and defines doxygenated.
------------------------------------------------------------------------
 Rumble | 2008-02-12 00:23:38 +0100 (Tue, 12 Feb 2008) | 1 line

Updated levels command to use an arg/range and added color parsing to greetings.
 (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-11 21:06:10 +0100 (Mon, 11 Feb 2008) | 1 line

Doxygen comments completed for weather.c
------------------------------------------------------------------------
 Rumble | 2008-02-11 03:52:50 +0100 (Mon, 11 Feb 2008) | 1 line

Corrected several 64-bit warnings. (thanks Buggo)
------------------------------------------------------------------------
 Rumble | 2008-02-10 22:56:56 +0100 (Sun, 10 Feb 2008) | 1 line

Added get_flag_by_name allowing for new trigedit variable checks like 
%actor.pref(FLAG)% checks. (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-08 21:22:26 +0100 (Fri, 08 Feb 2008) | 3 lines

COMPLETE: tbaMUD code re-org of global and local scope function and variable 
declarations. There may be a few things that I did not catch (some non extern 
keyword declarations of function prototypes within other functions, for 
example).

BUG FIX: Unused functions encrypt_hex() and decrypt_hex() removed from mail.c.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 23:31:09 +0100 (Tue, 05 Feb 2008) | 2 lines

Continued clean-up of 'extern' references to functions and variables.
BUG UNCOVERED: set_title() in class.c incorrectly handles the const nature of 
the char * returned from title_female and title_male.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 19:38:17 +0100 (Tue, 05 Feb 2008) | 3 lines

More work on mud clean-up.
New file: spec_procs.h
Created this file to house the legacy special procedures (spec_procs.c and 
castle.c) and special feature assignment in general.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 00:59:44 +0100 (Tue, 05 Feb 2008) | 3 lines

- Minor Bugfix: Fixed parse error in mobact.c
- Minor Bugfix: act.h is now included in all of the act functions. Forgot to do
that the first time :(
- Additions: ban.h has been added as the external entry point into the ban.c 
globals and functions. Files needing ban.h have been updated.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 20:02:11 +0100 (Mon, 04 Feb 2008) | 1 line

All act*.c functions, defines and globals have been prototyped/declared in 
act.h. The file act.h does not contain every ACMD, only those ACMDs and 
utility functions available within the act*.c files.
------------------------------------------------------------------------
 Rumble | 2008-02-04 17:59:47 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed the last few flags missed for the 128 bit conversion.
------------------------------------------------------------------------
 Laoris | 2008-02-04 07:27:56 +0100 (Mon, 04 Feb 2008) | 3 lines

Adding a column formatter for lists.  Accepts printf-like arguments.
Only used by medit right now.

------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 07:09:19 +0100 (Mon, 04 Feb 2008) | 2 lines

- Changed the 'struct queue' to 'struct dg_queue' to avoid namespace conflicts.
- Ongoing cleanup to mud project.
------------------------------------------------------------------------
 Rumble | 2008-02-04 00:07:09 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed run_autowiz which ran twice on advancement.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 03:46:22 +0100 (Sun, 03 Feb 2008) | 1 line

act.h created and added. This header will be the external entry point for the 
functions, function subcommands and variables within the act*.c files. It is 
not designed to be the entry point for all ACMD functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 02:44:29 +0100 (Sun, 03 Feb 2008) | 1 line

Merge of another part of the code cleanup, the dg script stuff.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 08:56:03 +0100 (Sat, 02 Feb 2008) | 1 line

Modularizing and organizing files continues. Committing comm.c and comm.h 
because they are hairy, and I don't want to do them over if my hard drive 
crashes.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 07:05:08 +0100 (Sat, 02 Feb 2008) | 4 lines

- Marking all file scope functions as 'static'
- Reorganization of the global variables and functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 10:20:47 +0100 (Thu, 31 Jan 2008) | 1 line

* Protected the conf.h.* system config files from multiple calls.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:56:18 +0100 (Thu, 31 Jan 2008) | 1 line

* Removed extraneous references to TRUE / FALSE and YES / NO defines.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:46:20 +0100 (Thu, 31 Jan 2008) | 2 lines

* BUGFIX: NUM_POSITIONS set to 8 (was incorrectly set to 15 before)
* Migrated NUM_* settings from oasis.h to more appropriate locations near where
they are defined. (For Example: NUM_POSITIONS moved to structs.h next to the 
POSITION_* defines.)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 03:58:28 +0100 (Thu, 31 Jan 2008) | 1 line

Added Appendix A - Coder Support. Right now, it simply speaks to the fact that 
we have included doxygen config files, are working to document the source code, 
and provides a rudimentary "do this" guide to create the doxygen cross 
references.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-30 07:12:07 +0100 (Wed, 30 Jan 2008) | 2 lines

- All .h files now have doxygen recognized headers, and the format is slightly 
altered to ease editing of headers.
- Protected all .h files from multiple calls. (Standard format is #ifndef _HEADE
R_H_ #define _HEADER_H_ .... #endif)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 11:18:14 +0100 (Tue, 29 Jan 2008) | 1 line

constants.h, structs.h and utils.h now protected from multiple includes. This is
 sometimes overkill, but good practice overall.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:38:18 +0100 (Tue, 29 Jan 2008) | 1 line

Updated documentation for constants.c and constants.h.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:15:25 +0100 (Tue, 29 Jan 2008) | 3 lines

The standard Doxygen configuration doxyfiles (config files) for tbaMUD. One is 
to be used with the Graphviz DOT (dox_withGraphs), one is designed to be used if
Graphviz is not available.

Now just need a short document describing the usage of doxygen.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:11:36 +0100 (Tue, 29 Jan 2008) | 1 line

Minor document correction in struct dex_app_tpe.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 20:53:51 +0100 (Mon, 28 Jan 2008) | 1 line

*bugfix* do_drink command: When a container is empty, the correct, "It is 
empty." message is now displayed.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 07:58:15 +0100 (Mon, 28 Jan 2008) | 3 lines

Merging changes to trunk for:
* utils.h, utils.c and structs.h doxygen comments
* adding file dox_withGraphs.doxyfile
2008-04-12 01:31:58 +00:00

1222 lines
34 KiB
C

/**************************************************************************
* File: oedit.c Part of tbaMUD *
* Usage: Oasis OLC - Objects. *
* *
* By Levork. Copyright 1996 Harvey Gilpin. 1997-2001 George Greer. *
**************************************************************************/
#include "conf.h"
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "spells.h"
#include "db.h"
#include "boards.h"
#include "constants.h"
#include "shop.h"
#include "genolc.h"
#include "genobj.h"
#include "genzon.h"
#include "oasis.h"
#include "improved-edit.h"
#include "dg_olc.h"
#include "fight.h"
#include "modify.h"
/* local functions */
static void oedit_setup_new(struct descriptor_data *d);
static void oedit_disp_container_flags_menu(struct descriptor_data *d);
static void oedit_disp_extradesc_menu(struct descriptor_data *d);
static void oedit_disp_prompt_apply_menu(struct descriptor_data *d);
static void oedit_liquid_type(struct descriptor_data *d);
static void oedit_disp_apply_menu(struct descriptor_data *d);
static void oedit_disp_weapon_menu(struct descriptor_data *d);
static void oedit_disp_spells_menu(struct descriptor_data *d);
static void oedit_disp_val1_menu(struct descriptor_data *d);
static void oedit_disp_val2_menu(struct descriptor_data *d);
static void oedit_disp_val3_menu(struct descriptor_data *d);
static void oedit_disp_val4_menu(struct descriptor_data *d);
static void oedit_disp_type_menu(struct descriptor_data *d);
static void oedit_disp_extra_menu(struct descriptor_data *d);
static void oedit_disp_wear_menu(struct descriptor_data *d);
static void oedit_disp_menu(struct descriptor_data *d);
static void oedit_disp_perm_menu(struct descriptor_data *d);
static void oedit_save_to_disk(int zone_num);
/* handy macro */
#define S_PRODUCT(s, i) ((s)->producing[(i)])
/* Utility and exported functions */
ACMD(do_oasis_oedit)
{
int number = NOWHERE, save = 0, real_num;
struct descriptor_data *d;
char *buf3;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
/* No building as a mob or while being forced. */
if (IS_NPC(ch) || !ch->desc || STATE(ch->desc) != CON_PLAYING)
return;
/* Parse any arguments. */
buf3 = two_arguments(argument, buf1, buf2);
/* If there aren't any arguments they can't modify anything. */
if (!*buf1) {
send_to_char(ch, "Specify an object VNUM to edit.\r\n");
return;
} else if (!isdigit(*buf1)) {
if (str_cmp("save", buf1) != 0) {
send_to_char(ch, "Yikes! Stop that, someone will get hurt!\r\n");
return;
}
save = TRUE;
if (is_number(buf2))
number = atoi(buf2);
else if (GET_OLC_ZONE(ch) > 0) {
zone_rnum zlok;
if ((zlok = real_zone(GET_OLC_ZONE(ch))) == NOWHERE)
number = NOWHERE;
else
number = genolc_zone_bottom(zlok);
}
if (number == NOWHERE) {
send_to_char(ch, "Save which zone?\r\n");
return;
}
}
/* If a numeric argument was given, get it. */
if (number == NOWHERE)
number = atoi(buf1);
/* Check that whatever it is isn't already being edited. */
for (d = descriptor_list; d; d = d->next) {
if (STATE(d) == CON_OEDIT) {
if (d->olc && OLC_NUM(d) == number) {
send_to_char(ch, "That object is currently being edited by %s.\r\n",
PERS(d->character, ch));
return;
}
}
}
/* Point d to the builder's descriptor (for easier typing later). */
d = ch->desc;
/* Give the descriptor an OLC structure. */
if (d->olc) {
mudlog(BRF, LVL_IMMORT, TRUE,
"SYSERR: do_oasis: Player already had olc structure.");
free(d->olc);
}
CREATE(d->olc, struct oasis_olc_data, 1);
/* Find the zone. */
OLC_ZNUM(d) = save ? real_zone(number) : real_zone_by_thing(number);
if (OLC_ZNUM(d) == NOWHERE) {
send_to_char(ch, "Sorry, there is no zone for that number!\r\n");
/* Free the descriptor's OLC structure. */
free(d->olc);
d->olc = NULL;
return;
}
/* Everyone but IMPLs can only edit zones they have been assigned. */
if (!can_edit_zone(ch, OLC_ZNUM(d))) {
send_cannot_edit(ch, zone_table[OLC_ZNUM(d)].number);
/* Free the OLC structure. */
free(d->olc);
d->olc = NULL;
return;
}
/* If we need to save, save the objects. */
if (save) {
send_to_char(ch, "Saving all objects in zone %d.\r\n",
zone_table[OLC_ZNUM(d)].number);
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(ch)), TRUE,
"OLC: %s saves object info for zone %d.", GET_NAME(ch),
zone_table[OLC_ZNUM(d)].number);
/* Save the objects in this zone. */
save_objects(OLC_ZNUM(d));
/* Free the descriptor's OLC structure. */
free(d->olc);
d->olc = NULL;
return;
}
OLC_NUM(d) = number;
/* If a new object, setup new, otherwise setup the existing object. */
if ((real_num = real_object(number)) != NOTHING)
oedit_setup_existing(d, real_num);
else
oedit_setup_new(d);
oedit_disp_menu(d);
STATE(d) = CON_OEDIT;
/* Send the OLC message to the players in the same room as the builder. */
act("$n starts using OLC.", TRUE, d->character, 0, 0, TO_ROOM);
SET_BIT_AR(PLR_FLAGS(ch), PLR_WRITING);
/* Log the OLC message. */
mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s starts editing zone %d allowed zone %d",
GET_NAME(ch), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(ch));
}
static void oedit_setup_new(struct descriptor_data *d)
{
CREATE(OLC_OBJ(d), struct obj_data, 1);
clear_object(OLC_OBJ(d));
OLC_OBJ(d)->name = strdup("unfinished object");
OLC_OBJ(d)->description = strdup("An unfinished object is lying here.");
OLC_OBJ(d)->short_description = strdup("an unfinished object");
SET_BIT_AR(GET_OBJ_WEAR(OLC_OBJ(d)), ITEM_WEAR_TAKE);
OLC_VAL(d) = 0;
OLC_ITEM_TYPE(d) = OBJ_TRIGGER;
SCRIPT(OLC_OBJ(d)) = NULL;
OLC_OBJ(d)->proto_script = OLC_SCRIPT(d) = NULL;
}
void oedit_setup_existing(struct descriptor_data *d, int real_num)
{
struct obj_data *obj;
/* Allocate object in memory. */
CREATE(obj, struct obj_data, 1);
copy_object(obj, &obj_proto[real_num]);
/* Attach new object to player's descriptor. */
OLC_OBJ(d) = obj;
OLC_VAL(d) = 0;
OLC_ITEM_TYPE(d) = OBJ_TRIGGER;
dg_olc_script_copy(d);
/* The edited obj must not have a script. It will be assigned to the updated
* obj later, after editing. */
SCRIPT(obj) = NULL;
OLC_OBJ(d)->proto_script = NULL;
}
void oedit_save_internally(struct descriptor_data *d)
{
int i;
obj_rnum robj_num;
struct descriptor_data *dsc;
struct obj_data *obj;
i = (real_object(OLC_NUM(d)) == NOTHING);
if ((robj_num = add_object(OLC_OBJ(d), OLC_NUM(d))) == NOTHING) {
log("oedit_save_internally: add_object failed.");
return;
}
/* Update triggers and free old proto list */
if (obj_proto[robj_num].proto_script &&
obj_proto[robj_num].proto_script != OLC_SCRIPT(d))
free_proto_script(&obj_proto[robj_num], OBJ_TRIGGER);
/* this will handle new instances of the object: */
obj_proto[robj_num].proto_script = OLC_SCRIPT(d);
/* this takes care of the objects currently in-game */
for (obj = object_list; obj; obj = obj->next) {
if (obj->item_number != robj_num)
continue;
/* remove any old scripts */
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);
}
/* end trigger update */
if (!i) /* If it's not a new object, don't renumber. */
return;
/* Renumber produce in shops being edited. */
for (dsc = descriptor_list; dsc; dsc = dsc->next)
if (STATE(dsc) == CON_SEDIT)
for (i = 0; S_PRODUCT(OLC_SHOP(dsc), i) != NOTHING; i++)
if (S_PRODUCT(OLC_SHOP(dsc), i) >= robj_num)
S_PRODUCT(OLC_SHOP(dsc), i)++;
/* Update other people in zedit too. From: C.Raehl 4/27/99 */
for (dsc = descriptor_list; dsc; dsc = dsc->next)
if (STATE(dsc) == CON_ZEDIT)
for (i = 0; OLC_ZONE(dsc)->cmd[i].command != 'S'; i++)
switch (OLC_ZONE(dsc)->cmd[i].command) {
case 'P':
OLC_ZONE(dsc)->cmd[i].arg3 += (OLC_ZONE(dsc)->cmd[i].arg3 >= robj_num);
/* Fall through. */
case 'E':
case 'G':
case 'O':
OLC_ZONE(dsc)->cmd[i].arg1 += (OLC_ZONE(dsc)->cmd[i].arg1 >= robj_num);
break;
case 'R':
OLC_ZONE(dsc)->cmd[i].arg2 += (OLC_ZONE(dsc)->cmd[i].arg2 >= robj_num);
break;
default:
break;
}
}
static void oedit_save_to_disk(int zone_num)
{
save_objects(zone_num);
}
/* Menu functions */
/* For container flags. */
static void oedit_disp_container_flags_menu(struct descriptor_data *d)
{
char bits[MAX_STRING_LENGTH];
get_char_colors(d->character);
clear_screen(d);
sprintbit(GET_OBJ_VAL(OLC_OBJ(d), 1), container_bits, bits, sizeof(bits));
write_to_output(d,
"%s1%s) CLOSEABLE\r\n"
"%s2%s) PICKPROOF\r\n"
"%s3%s) CLOSED\r\n"
"%s4%s) LOCKED\r\n"
"Container flags: %s%s%s\r\n"
"Enter flag, 0 to quit : ",
grn, nrm, grn, nrm, grn, nrm, grn, nrm, cyn, bits, nrm);
}
/* For extra descriptions. */
static void oedit_disp_extradesc_menu(struct descriptor_data *d)
{
struct extra_descr_data *extra_desc = OLC_DESC(d);
get_char_colors(d->character);
clear_screen(d);
write_to_output(d,
"Extra desc menu\r\n"
"%s1%s) Keywords: %s%s\r\n"
"%s2%s) Description:\r\n%s%s\r\n"
"%s3%s) Goto next description: %s\r\n"
"%s0%s) Quit\r\n"
"Enter choice : ",
grn, nrm, yel, (extra_desc->keyword && *extra_desc->keyword) ? extra_desc->keyword : "<NONE>",
grn, nrm, yel, (extra_desc->description && *extra_desc->description) ? extra_desc->description : "<NONE>",
grn, nrm, !extra_desc->next ? "Not set." : "Set.", grn, nrm);
OLC_MODE(d) = OEDIT_EXTRADESC_MENU;
}
/* Ask for *which* apply to edit. */
static void oedit_disp_prompt_apply_menu(struct descriptor_data *d)
{
char apply_buf[MAX_STRING_LENGTH];
int counter;
get_char_colors(d->character);
clear_screen(d);
for (counter = 0; counter < MAX_OBJ_AFFECT; counter++) {
if (OLC_OBJ(d)->affected[counter].modifier) {
sprinttype(OLC_OBJ(d)->affected[counter].location, apply_types, apply_buf, sizeof(apply_buf));
write_to_output(d, " %s%d%s) %+d to %s\r\n", grn, counter + 1, nrm,
OLC_OBJ(d)->affected[counter].modifier, apply_buf);
} else {
write_to_output(d, " %s%d%s) None.\r\n", grn, counter + 1, nrm);
}
}
write_to_output(d, "\r\nEnter affection to modify (0 to quit) : ");
OLC_MODE(d) = OEDIT_PROMPT_APPLY;
}
/* Ask for liquid type. */
static void oedit_liquid_type(struct descriptor_data *d)
{
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 0; counter < NUM_LIQ_TYPES; counter++) {
write_to_output(d, " %s%2d%s) %s%-20.20s %s", grn, counter, nrm, yel,
drinks[counter], !(++columns % 2) ? "\r\n" : "");
}
write_to_output(d, "\r\n%sEnter drink type : ", nrm);
OLC_MODE(d) = OEDIT_VALUE_3;
}
/* The actual apply to set. */
static void oedit_disp_apply_menu(struct descriptor_data *d)
{
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 0; counter < NUM_APPLIES; counter++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, counter, nrm,
apply_types[counter], !(++columns % 2) ? "\r\n" : "");
}
write_to_output(d, "\r\nEnter apply type (0 is no apply) : ");
OLC_MODE(d) = OEDIT_APPLY;
}
/* Weapon type. */
static void oedit_disp_weapon_menu(struct descriptor_data *d)
{
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 0; counter < NUM_ATTACK_TYPES; counter++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, counter, nrm,
attack_hit_text[counter].singular,
!(++columns % 2) ? "\r\n" : "");
}
write_to_output(d, "\r\nEnter weapon type : ");
}
/* Spell type. */
static void oedit_disp_spells_menu(struct descriptor_data *d)
{
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 1; counter <= NUM_SPELLS; counter++) {
write_to_output(d, "%s%2d%s) %s%-20.20s %s", grn, counter, nrm, yel,
spell_info[counter].name, !(++columns % 3) ? "\r\n" : "");
}
write_to_output(d, "\r\n%sEnter spell choice (-1 for none) : ", nrm);
}
/* Object value #1 */
static void oedit_disp_val1_menu(struct descriptor_data *d)
{
OLC_MODE(d) = OEDIT_VALUE_1;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_LIGHT:
/* values 0 and 1 are unused.. jump to 2 */
oedit_disp_val3_menu(d);
break;
case ITEM_SCROLL:
case ITEM_WAND:
case ITEM_STAFF:
case ITEM_POTION:
write_to_output(d, "Spell level : ");
break;
case ITEM_WEAPON:
/* This doesn't seem to be used if I remember right. */
write_to_output(d, "Modifier to Hitroll : ");
break;
case ITEM_ARMOR:
write_to_output(d, "Apply to AC : ");
break;
case ITEM_CONTAINER:
write_to_output(d, "Max weight to contain (-1 for unlimited) : ");
break;
case ITEM_DRINKCON:
case ITEM_FOUNTAIN:
write_to_output(d, "Max drink units (-1 for unlimited) : ");
break;
case ITEM_FOOD:
write_to_output(d, "Hours to fill stomach : ");
break;
case ITEM_MONEY:
write_to_output(d, "Number of gold coins : ");
break;
case ITEM_NOTE:
case ITEM_FURNITURE:
write_to_output(d, "Number of people it can hold : ");
break;
default:
oedit_disp_menu(d);
}
}
/* Object value #2 */
static void oedit_disp_val2_menu(struct descriptor_data *d)
{
OLC_MODE(d) = OEDIT_VALUE_2;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_SCROLL:
case ITEM_POTION:
oedit_disp_spells_menu(d);
break;
case ITEM_WAND:
case ITEM_STAFF:
write_to_output(d, "Max number of charges : ");
break;
case ITEM_WEAPON:
write_to_output(d, "Number of damage dice : ");
break;
case ITEM_FOOD:
/* Values 2 and 3 are unused, jump to 4...Odd. */
oedit_disp_val4_menu(d);
break;
case ITEM_CONTAINER:
/* These are flags, needs a bit of special handling. */
oedit_disp_container_flags_menu(d);
break;
case ITEM_DRINKCON:
case ITEM_FOUNTAIN:
write_to_output(d, "Initial drink units : ");
break;
default:
oedit_disp_menu(d);
}
}
/* Object value #3 */
static void oedit_disp_val3_menu(struct descriptor_data *d)
{
OLC_MODE(d) = OEDIT_VALUE_3;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_LIGHT:
write_to_output(d, "Number of hours (0 = burnt, -1 is infinite) : ");
break;
case ITEM_SCROLL:
case ITEM_POTION:
oedit_disp_spells_menu(d);
break;
case ITEM_WAND:
case ITEM_STAFF:
write_to_output(d, "Number of charges remaining : ");
break;
case ITEM_WEAPON:
write_to_output(d, "Size of damage dice : ");
break;
case ITEM_CONTAINER:
write_to_output(d, "Vnum of key to open container (-1 for no key) : ");
break;
case ITEM_DRINKCON:
case ITEM_FOUNTAIN:
oedit_liquid_type(d);
break;
default:
oedit_disp_menu(d);
}
}
/* Object value #4 */
static void oedit_disp_val4_menu(struct descriptor_data *d)
{
OLC_MODE(d) = OEDIT_VALUE_4;
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_SCROLL:
case ITEM_POTION:
case ITEM_WAND:
case ITEM_STAFF:
oedit_disp_spells_menu(d);
break;
case ITEM_WEAPON:
oedit_disp_weapon_menu(d);
break;
case ITEM_DRINKCON:
case ITEM_FOUNTAIN:
case ITEM_FOOD:
write_to_output(d, "Poisoned (0 = not poison) : ");
break;
default:
oedit_disp_menu(d);
}
}
/* Object type. */
static void oedit_disp_type_menu(struct descriptor_data *d)
{
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 0; counter < NUM_ITEM_TYPES; counter++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, counter, nrm,
item_types[counter], !(++columns % 2) ? "\r\n" : "");
}
write_to_output(d, "\r\nEnter object type : ");
}
/* Object extra flags. */
static void oedit_disp_extra_menu(struct descriptor_data *d)
{
char bits[MAX_STRING_LENGTH];
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 0; counter < NUM_ITEM_FLAGS; counter++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, counter + 1, nrm,
extra_bits[counter], !(++columns % 2) ? "\r\n" : "");
}
sprintbitarray(GET_OBJ_EXTRA(OLC_OBJ(d)), extra_bits, EF_ARRAY_MAX, bits);
write_to_output(d, "\r\nObject flags: %s%s%s\r\n"
"Enter object extra flag (0 to quit) : ",
cyn, bits, nrm);
}
/* Object perm flags. */
static void oedit_disp_perm_menu(struct descriptor_data *d)
{
char bits[MAX_STRING_LENGTH];
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 1; counter < NUM_AFF_FLAGS; counter++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, counter, nrm, affected_bits[counter], !(++columns % 2) ? "\r\n" : "");
}
sprintbitarray(GET_OBJ_PERM(OLC_OBJ(d)), affected_bits, EF_ARRAY_MAX, bits);
write_to_output(d, "\r\nObject permanent flags: %s%s%s\r\n"
"Enter object perm flag (0 to quit) : ", cyn, bits, nrm);
}
/* Object wear flags. */
static void oedit_disp_wear_menu(struct descriptor_data *d)
{
char bits[MAX_STRING_LENGTH];
int counter, columns = 0;
get_char_colors(d->character);
clear_screen(d);
for (counter = 0; counter < NUM_ITEM_WEARS; counter++) {
write_to_output(d, "%s%2d%s) %-20.20s %s", grn, counter + 1, nrm,
wear_bits[counter], !(++columns % 2) ? "\r\n" : "");
}
sprintbitarray(GET_OBJ_WEAR(OLC_OBJ(d)), wear_bits, TW_ARRAY_MAX, bits);
write_to_output(d, "\r\nWear flags: %s%s%s\r\n"
"Enter wear flag, 0 to quit : ", cyn, bits, nrm);
}
/* Display main menu. */
static void oedit_disp_menu(struct descriptor_data *d)
{
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
struct obj_data *obj;
obj = OLC_OBJ(d);
get_char_colors(d->character);
clear_screen(d);
/* Build buffers for first part of menu. */
sprinttype(GET_OBJ_TYPE(obj), item_types, buf1, sizeof(buf1));
sprintbitarray(GET_OBJ_EXTRA(obj), extra_bits, EF_ARRAY_MAX, buf2);
/* Build first half of menu. */
write_to_output(d,
"-- Item number : [%s%d%s]\r\n"
"%s1%s) Keywords : %s%s\r\n"
"%s2%s) S-Desc : %s%s\r\n"
"%s3%s) L-Desc :-\r\n%s%s\r\n"
"%s4%s) A-Desc :-\r\n%s%s"
"%s5%s) Type : %s%s\r\n"
"%s6%s) Extra flags : %s%s\r\n",
cyn, OLC_NUM(d), nrm,
grn, nrm, yel, (obj->name && *obj->name) ? obj->name : "undefined",
grn, nrm, yel, (obj->short_description && *obj->short_description) ? obj->short_description : "undefined",
grn, nrm, yel, (obj->description && *obj->description) ? obj->description : "undefined",
grn, nrm, yel, (obj->action_description && *obj->action_description) ? obj->action_description : "Not Set.\r\n",
grn, nrm, cyn, buf1,
grn, nrm, cyn, buf2
);
/* Send first half then build second half of menu. */
sprintbitarray(GET_OBJ_WEAR(OLC_OBJ(d)), wear_bits, EF_ARRAY_MAX, buf1);
sprintbitarray(GET_OBJ_PERM(OLC_OBJ(d)), affected_bits, EF_ARRAY_MAX, buf2);
write_to_output(d,
"%s7%s) Wear flags : %s%s\r\n"
"%s8%s) Weight : %s%d\r\n"
"%s9%s) Cost : %s%d\r\n"
"%sA%s) Cost/Day : %s%d\r\n"
"%sB%s) Timer : %s%d\r\n"
"%sC%s) Values : %s%d %d %d %d\r\n"
"%sD%s) Applies menu\r\n"
"%sE%s) Extra descriptions menu: %s%s%s\r\n"
"%sM%s) Min Level : %s%d\r\n"
"%sP%s) Perm Affects: %s%s\r\n"
"%sS%s) Script : %s%s\r\n"
"%sW%s) Copy object\r\n"
"%sX%s) Delete object\r\n"
"%sQ%s) Quit\r\n"
"Enter choice : ",
grn, nrm, cyn, buf1,
grn, nrm, cyn, GET_OBJ_WEIGHT(obj),
grn, nrm, cyn, GET_OBJ_COST(obj),
grn, nrm, cyn, GET_OBJ_RENT(obj),
grn, nrm, cyn, GET_OBJ_TIMER(obj),
grn, nrm, cyn, GET_OBJ_VAL(obj, 0),
GET_OBJ_VAL(obj, 1),
GET_OBJ_VAL(obj, 2),
GET_OBJ_VAL(obj, 3),
grn, nrm, grn, nrm, cyn, GET_OBJ_EXTRA(obj) ? "Set." : "Not Set.", grn,
grn, nrm, cyn, GET_OBJ_LEVEL(obj),
grn, nrm, cyn, buf2,
grn, nrm, cyn, OLC_SCRIPT(d) ? "Set." : "Not Set.",
grn, nrm,
grn, nrm,
grn, nrm
);
OLC_MODE(d) = OEDIT_MAIN_MENU;
}
/* main loop (of sorts).. basically interpreter throws all input to here. */
void oedit_parse(struct descriptor_data *d, char *arg)
{
int number, max_val, min_val;
char *oldtext = NULL;
switch (OLC_MODE(d)) {
case OEDIT_CONFIRM_SAVESTRING:
switch (*arg) {
case 'y':
case 'Y':
oedit_save_internally(d);
mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE,
"OLC: %s edits obj %d", GET_NAME(d->character), OLC_NUM(d));
if (CONFIG_OLC_SAVE) {
oedit_save_to_disk(real_zone_by_thing(OLC_NUM(d)));
write_to_output(d, "Object saved to disk.\r\n");
} else
write_to_output(d, "Object saved to memory.\r\n");
cleanup_olc(d, CLEANUP_ALL);
return;
case 'n':
case 'N':
/* If not saving, we must free the script_proto list. */
OLC_OBJ(d)->proto_script = OLC_SCRIPT(d);
free_proto_script(OLC_OBJ(d), OBJ_TRIGGER);
cleanup_olc(d, CLEANUP_ALL);
return;
case 'a': /* abort quit */
case 'A':
oedit_disp_menu(d);
return;
default:
write_to_output(d, "Invalid choice!\r\n");
write_to_output(d, "Do you wish to save your changes? : \r\n");
return;
}
case OEDIT_MAIN_MENU:
/* Throw us out to whichever edit mode based on user input. */
switch (*arg) {
case 'q':
case 'Q':
if (OLC_VAL(d)) { /* Something has been modified. */
write_to_output(d, "Do you wish to save your changes? : ");
OLC_MODE(d) = OEDIT_CONFIRM_SAVESTRING;
} else
cleanup_olc(d, CLEANUP_ALL);
return;
case '1':
write_to_output(d, "Enter keywords : ");
OLC_MODE(d) = OEDIT_KEYWORD;
break;
case '2':
write_to_output(d, "Enter short desc : ");
OLC_MODE(d) = OEDIT_SHORTDESC;
break;
case '3':
write_to_output(d, "Enter long desc :-\r\n| ");
OLC_MODE(d) = OEDIT_LONGDESC;
break;
case '4':
OLC_MODE(d) = OEDIT_ACTDESC;
send_editor_help(d);
write_to_output(d, "Enter action description:\r\n\r\n");
if (OLC_OBJ(d)->action_description) {
write_to_output(d, "%s", OLC_OBJ(d)->action_description);
oldtext = strdup(OLC_OBJ(d)->action_description);
}
string_write(d, &OLC_OBJ(d)->action_description, MAX_MESSAGE_LENGTH, 0, oldtext);
OLC_VAL(d) = 1;
break;
case '5':
oedit_disp_type_menu(d);
OLC_MODE(d) = OEDIT_TYPE;
break;
case '6':
oedit_disp_extra_menu(d);
OLC_MODE(d) = OEDIT_EXTRAS;
break;
case '7':
oedit_disp_wear_menu(d);
OLC_MODE(d) = OEDIT_WEAR;
break;
case '8':
write_to_output(d, "Enter weight : ");
OLC_MODE(d) = OEDIT_WEIGHT;
break;
case '9':
write_to_output(d, "Enter cost : ");
OLC_MODE(d) = OEDIT_COST;
break;
case 'a':
case 'A':
write_to_output(d, "Enter cost per day : ");
OLC_MODE(d) = OEDIT_COSTPERDAY;
break;
case 'b':
case 'B':
write_to_output(d, "Enter timer : ");
OLC_MODE(d) = OEDIT_TIMER;
break;
case 'c':
case 'C':
/* Clear any old values */
GET_OBJ_VAL(OLC_OBJ(d), 0) = 0;
GET_OBJ_VAL(OLC_OBJ(d), 1) = 0;
GET_OBJ_VAL(OLC_OBJ(d), 2) = 0;
GET_OBJ_VAL(OLC_OBJ(d), 3) = 0;
OLC_VAL(d) = 1;
oedit_disp_val1_menu(d);
break;
case 'd':
case 'D':
oedit_disp_prompt_apply_menu(d);
break;
case 'e':
case 'E':
/* If extra descriptions don't exist. */
if (OLC_OBJ(d)->ex_description == NULL) {
CREATE(OLC_OBJ(d)->ex_description, struct extra_descr_data, 1);
OLC_OBJ(d)->ex_description->next = NULL;
}
OLC_DESC(d) = OLC_OBJ(d)->ex_description;
oedit_disp_extradesc_menu(d);
break;
case 'm':
case 'M':
write_to_output(d, "Enter new minimum level: ");
OLC_MODE(d) = OEDIT_LEVEL;
break;
case 'p':
case 'P':
oedit_disp_perm_menu(d);
OLC_MODE(d) = OEDIT_PERM;
break;
case 's':
case 'S':
OLC_SCRIPT_EDIT_MODE(d) = SCRIPT_MAIN_MENU;
dg_script_menu(d);
return;
case 'w':
case 'W':
write_to_output(d, "Copy what object? ");
OLC_MODE(d) = OEDIT_COPY;
break;
case 'x':
case 'X':
write_to_output(d, "Are you sure you want to delete this object? ");
OLC_MODE(d) = OEDIT_DELETE;
break;
default:
oedit_disp_menu(d);
break;
}
return; /* end of OEDIT_MAIN_MENU */
case OLC_SCRIPT_EDIT:
if (dg_script_edit_parse(d, arg)) return;
break;
case OEDIT_KEYWORD:
if (!genolc_checkstring(d, arg))
break;
if (OLC_OBJ(d)->name)
free(OLC_OBJ(d)->name);
OLC_OBJ(d)->name = str_udup(arg);
break;
case OEDIT_SHORTDESC:
if (!genolc_checkstring(d, arg))
break;
if (OLC_OBJ(d)->short_description)
free(OLC_OBJ(d)->short_description);
OLC_OBJ(d)->short_description = str_udup(arg);
break;
case OEDIT_LONGDESC:
if (!genolc_checkstring(d, arg))
break;
if (OLC_OBJ(d)->description)
free(OLC_OBJ(d)->description);
OLC_OBJ(d)->description = str_udup(arg);
break;
case OEDIT_TYPE:
number = atoi(arg);
if ((number < 1) || (number >= NUM_ITEM_TYPES)) {
write_to_output(d, "Invalid choice, try again : ");
return;
} else
GET_OBJ_TYPE(OLC_OBJ(d)) = number;
/* what's the boundschecking worth if we don't do this ? -- Welcor */
GET_OBJ_VAL(OLC_OBJ(d), 0) = GET_OBJ_VAL(OLC_OBJ(d), 1) =
GET_OBJ_VAL(OLC_OBJ(d), 2) = GET_OBJ_VAL(OLC_OBJ(d), 3) = 0;
break;
case OEDIT_EXTRAS:
number = atoi(arg);
if ((number < 0) || (number > NUM_ITEM_FLAGS)) {
oedit_disp_extra_menu(d);
return;
} else if (number == 0)
break;
else {
TOGGLE_BIT_AR(GET_OBJ_EXTRA(OLC_OBJ(d)), (number - 1));
oedit_disp_extra_menu(d);
return;
}
case OEDIT_WEAR:
number = atoi(arg);
if ((number < 0) || (number > NUM_ITEM_WEARS)) {
write_to_output(d, "That's not a valid choice!\r\n");
oedit_disp_wear_menu(d);
return;
} else if (number == 0) /* Quit. */
break;
else {
TOGGLE_BIT_AR(GET_OBJ_WEAR(OLC_OBJ(d)), (number - 1));
oedit_disp_wear_menu(d);
return;
}
case OEDIT_WEIGHT:
GET_OBJ_WEIGHT(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_WEIGHT);
break;
case OEDIT_COST:
GET_OBJ_COST(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_COST);
break;
case OEDIT_COSTPERDAY:
GET_OBJ_RENT(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_RENT);
break;
case OEDIT_TIMER:
GET_OBJ_TIMER(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_TIMER);
break;
case OEDIT_LEVEL:
GET_OBJ_LEVEL(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, LVL_IMPL);
break;
case OEDIT_PERM:
if ((number = atoi(arg)) == 0)
break;
if (number > 0 && number <= NUM_AFF_FLAGS) {
/* Setting AFF_CHARM on objects like this is dangerous. */
if (number != AFF_CHARM) {
TOGGLE_BIT_AR(GET_OBJ_PERM(OLC_OBJ(d)), number);
}
}
oedit_disp_perm_menu(d);
return;
case OEDIT_VALUE_1:
number = atoi(arg);
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_FURNITURE:
if (number < 0 || number > MAX_PEOPLE)
oedit_disp_val1_menu(d);
else {
GET_OBJ_VAL(OLC_OBJ(d), 0) = number;
oedit_disp_val2_menu(d);
}
break;
case ITEM_WEAPON:
GET_OBJ_VAL(OLC_OBJ(d), 0) = MIN(MAX(atoi(arg), -50), 50);
break;
case ITEM_CONTAINER:
GET_OBJ_VAL(OLC_OBJ(d), 0) = LIMIT(atoi(arg), -1, MAX_CONTAINER_SIZE);
break;
default:
GET_OBJ_VAL(OLC_OBJ(d), 0) = atoi(arg);
}
/* proceed to menu 2 */
oedit_disp_val2_menu(d);
return;
case OEDIT_VALUE_2:
/* Here, I do need to check for out of range values. */
number = atoi(arg);
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_SCROLL:
case ITEM_POTION:
if (number == 0 || number == -1)
GET_OBJ_VAL(OLC_OBJ(d), 1) = -1;
else
GET_OBJ_VAL(OLC_OBJ(d), 1) = LIMIT(number, 1, NUM_SPELLS);
oedit_disp_val3_menu(d);
break;
case ITEM_CONTAINER:
/* Needs some special handling since we are dealing with flag values here. */
if (number < 0 || number > 4)
oedit_disp_container_flags_menu(d);
else if (number != 0) {
TOGGLE_BIT(GET_OBJ_VAL(OLC_OBJ(d), 1), 1 << (number - 1));
OLC_VAL(d) = 1;
oedit_disp_val2_menu(d);
} else
oedit_disp_val3_menu(d);
break;
case ITEM_WEAPON:
GET_OBJ_VAL(OLC_OBJ(d), 1) = LIMIT(number, 1, MAX_WEAPON_NDICE);
oedit_disp_val3_menu(d);
break;
default:
GET_OBJ_VAL(OLC_OBJ(d), 1) = number;
oedit_disp_val3_menu(d);
}
return;
case OEDIT_VALUE_3:
number = atoi(arg);
/* Quick'n'easy error checking. */
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_SCROLL:
case ITEM_POTION:
if (number == 0 || number == -1) {
GET_OBJ_VAL(OLC_OBJ(d), 2) = -1;
oedit_disp_val4_menu(d);
return;
}
min_val = 1;
max_val = NUM_SPELLS;
break;
case ITEM_WEAPON:
min_val = 1;
max_val = MAX_WEAPON_SDICE;
break;
case ITEM_WAND:
case ITEM_STAFF:
min_val = 0;
max_val = 20;
break;
case ITEM_DRINKCON:
case ITEM_FOUNTAIN:
min_val = 0;
max_val = NUM_LIQ_TYPES - 1;
break;
case ITEM_KEY:
min_val = 0;
max_val = 65099;
break;
default:
min_val = -65000;
max_val = 65000;
}
GET_OBJ_VAL(OLC_OBJ(d), 2) = LIMIT(number, min_val, max_val);
oedit_disp_val4_menu(d);
return;
case OEDIT_VALUE_4:
number = atoi(arg);
switch (GET_OBJ_TYPE(OLC_OBJ(d))) {
case ITEM_SCROLL:
case ITEM_POTION:
if (number == 0 || number == -1) {
GET_OBJ_VAL(OLC_OBJ(d), 3) = -1;
oedit_disp_menu(d);
return;
}
min_val = 1;
max_val = NUM_SPELLS;
break;
case ITEM_WAND:
case ITEM_STAFF:
min_val = 1;
max_val = NUM_SPELLS;
break;
case ITEM_WEAPON:
min_val = 0;
max_val = NUM_ATTACK_TYPES - 1;
break;
default:
min_val = -65000;
max_val = 65000;
break;
}
GET_OBJ_VAL(OLC_OBJ(d), 3) = LIMIT(number, min_val, max_val);
break;
case OEDIT_PROMPT_APPLY:
if ((number = atoi(arg)) == 0)
break;
else if (number < 0 || number > MAX_OBJ_AFFECT) {
oedit_disp_prompt_apply_menu(d);
return;
}
OLC_VAL(d) = number - 1;
OLC_MODE(d) = OEDIT_APPLY;
oedit_disp_apply_menu(d);
return;
case OEDIT_APPLY:
if ((number = atoi(arg)) == 0) {
OLC_OBJ(d)->affected[OLC_VAL(d)].location = 0;
OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = 0;
oedit_disp_prompt_apply_menu(d);
} else if (number < 0 || number >= NUM_APPLIES)
oedit_disp_apply_menu(d);
else {
int counter;
/* add in check here if already applied.. deny builders another */
if (GET_LEVEL(d->character) < LVL_IMPL) {
for (counter = 0; counter < MAX_OBJ_AFFECT; counter++) {
if (OLC_OBJ(d)->affected[counter].location == number) {
write_to_output(d, "Object already has that apply.");
return;
}
}
}
OLC_OBJ(d)->affected[OLC_VAL(d)].location = number;
write_to_output(d, "Modifier : ");
OLC_MODE(d) = OEDIT_APPLYMOD;
}
return;
case OEDIT_APPLYMOD:
OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = atoi(arg);
oedit_disp_prompt_apply_menu(d);
return;
case OEDIT_EXTRADESC_KEY:
if (genolc_checkstring(d, arg)) {
if (OLC_DESC(d)->keyword)
free(OLC_DESC(d)->keyword);
OLC_DESC(d)->keyword = str_udup(arg);
}
oedit_disp_extradesc_menu(d);
return;
case OEDIT_EXTRADESC_MENU:
switch ((number = atoi(arg))) {
case 0:
if (!OLC_DESC(d)->keyword || !OLC_DESC(d)->description) {
struct extra_descr_data *temp;
if (OLC_DESC(d)->keyword)
free(OLC_DESC(d)->keyword);
if (OLC_DESC(d)->description)
free(OLC_DESC(d)->description);
/* Clean up pointers */
REMOVE_FROM_LIST(OLC_DESC(d), OLC_OBJ(d)->ex_description, next);
free(OLC_DESC(d));
OLC_DESC(d) = NULL;
}
break;
case 1:
OLC_MODE(d) = OEDIT_EXTRADESC_KEY;
write_to_output(d, "Enter keywords, separated by spaces :-\r\n| ");
return;
case 2:
OLC_MODE(d) = OEDIT_EXTRADESC_DESCRIPTION;
send_editor_help(d);
write_to_output(d, "Enter the extra description:\r\n\r\n");
if (OLC_DESC(d)->description) {
write_to_output(d, "%s", OLC_DESC(d)->description);
oldtext = strdup(OLC_DESC(d)->description);
}
string_write(d, &OLC_DESC(d)->description, MAX_MESSAGE_LENGTH, 0, oldtext);
OLC_VAL(d) = 1;
return;
case 3:
/* Only go to the next description if this one is finished. */
if (OLC_DESC(d)->keyword && OLC_DESC(d)->description) {
struct extra_descr_data *new_extra;
if (OLC_DESC(d)->next)
OLC_DESC(d) = OLC_DESC(d)->next;
else { /* Make new extra description and attach at end. */
CREATE(new_extra, struct extra_descr_data, 1);
OLC_DESC(d)->next = new_extra;
OLC_DESC(d) = OLC_DESC(d)->next;
}
}
/* No break - drop into default case. */
default:
oedit_disp_extradesc_menu(d);
return;
}
break;
case OEDIT_COPY:
if ((number = real_object(atoi(arg))) != NOTHING) {
oedit_setup_existing(d, number);
} else
write_to_output(d, "That object does not exist.\r\n");
break;
case OEDIT_DELETE:
if (*arg == 'y' || *arg == 'Y') {
if (delete_object(GET_OBJ_RNUM(OLC_OBJ(d))) != NOTHING)
write_to_output(d, "Object deleted.\r\n");
else
write_to_output(d, "Couldn't delete the object!\r\n");
cleanup_olc(d, CLEANUP_ALL);
} else if (*arg == 'n' || *arg == 'N') {
oedit_disp_menu(d);
OLC_MODE(d) = OEDIT_MAIN_MENU;
} else
write_to_output(d, "Please answer 'Y' or 'N': ");
return;
default:
mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: Reached default case in oedit_parse()!");
write_to_output(d, "Oops...\r\n");
break;
}
/* If we get here, we have changed something. */
OLC_VAL(d) = 1;
oedit_disp_menu(d);
}
void oedit_string_cleanup(struct descriptor_data *d, int terminator)
{
switch (OLC_MODE(d)) {
case OEDIT_ACTDESC:
oedit_disp_menu(d);
break;
case OEDIT_EXTRADESC_DESCRIPTION:
oedit_disp_extradesc_menu(d);
break;
}
}