Fixed a crash bug in oset related to editing unique objects.

This commit is contained in:
Vatiken 2012-03-03 03:36:21 +00:00
parent 2939a3d507
commit 0fd579d3d4
2 changed files with 25 additions and 17 deletions

View file

@ -5037,13 +5037,21 @@ ACMD(do_oset)
{
char arg[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
const char usage[] = "Usage: \r\n"
"Options: alias, apply, longdesc, shortdesc\r\n"
"> oset <object> <option> <value>\r\n";
struct obj_data *obj;
bool success = TRUE;
if (IS_NPC(ch) || ch->desc == NULL) {
send_to_char(ch, "oset is only usable by connected players.\r\n");
return;
}
argument = one_argument(argument, arg);
if (!*arg)
send_to_char(ch, "oset what?\r\n");
send_to_char(ch, usage);
else if (!(obj = get_obj_in_list_vis(ch, arg, NULL, ch->carrying)) &&
!(obj = get_obj_in_list_vis(ch, arg, NULL, world[IN_ROOM(ch)].contents)))
send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg), arg);
@ -5051,23 +5059,23 @@ ACMD(do_oset)
argument = one_argument(argument, arg2);
if (!*arg2)
send_to_char(ch, "What?\r\n");
send_to_char(ch, usage);
else {
if (is_abbrev(arg2, "alias") && (success = oset_alias(obj, argument)))
send_to_char(ch, "Object alias set to %s.\r\n", argument);
send_to_char(ch, "Object alias set.\r\n");
else if (is_abbrev(arg2, "longdesc") && (success = oset_long_description(obj, argument)))
send_to_char(ch, "Object long description set to %s.\r\n", argument);
send_to_char(ch, "Object long description set.\r\n");
else if (is_abbrev(arg2, "shortdesc") && (success = oset_short_description(obj, argument)))
send_to_char(ch, "Object short description set to %s.\r\n", argument);
send_to_char(ch, "Object short description set.\r\n");
else if (is_abbrev(arg2, "apply") && (success = oset_apply(obj, argument)))
send_to_char(ch, "Object apply set to %s.\r\n", argument);
else {
if (!success)
send_to_char(ch, "%s was unsuccessful.\r\n", arg2);
else
send_to_char(ch, "Unknown argument: %s.\r\n", arg2);
return;
}
}
send_to_char(ch, "Object apply set.\r\n");
else {
if (!success)
send_to_char(ch, "%s was unsuccessful.\r\n", arg2);
else
send_to_char(ch, usage);
return;
}
}
}
}

View file

@ -488,7 +488,7 @@ bool oset_alias(struct obj_data *obj, char * argument)
if (strlen(argument) > max_len)
return FALSE;
if (obj->name && obj->name != obj_proto[i].name)
if (i != NOWHERE && obj->name && obj->name != obj_proto[i].name)
free(obj->name);
obj->name = strdup(argument);
@ -559,7 +559,7 @@ bool oset_short_description(struct obj_data *obj, char * argument)
if (strlen(argument) > max_len)
return FALSE;
if (obj->short_description && obj->short_description != obj_proto[i].short_description)
if (i != NOWHERE && obj->short_description && obj->short_description != obj_proto[i].short_description)
free(obj->short_description);
obj->short_description = strdup(argument);
@ -577,7 +577,7 @@ bool oset_long_description(struct obj_data *obj, char * argument)
if (strlen(argument) > max_len)
return FALSE;
if (obj->description && obj->description != obj_proto[i].description)
if (i != NOWHERE && obj->description && obj->description != obj_proto[i].description)
free(obj->description);
obj->description = strdup(argument);