Major: Backport to rvn 241, with the addition of all previously found bug fixes.

This commit is contained in:
Vatiken 2012-02-06 19:13:03 +00:00
parent e4cdc51eb1
commit 479dbb6cbd
86 changed files with 3771 additions and 7913 deletions

View file

@ -22,13 +22,14 @@
#include "genzon.h" /* for real_zone_by_thing */
#include "act.h"
#include "fight.h"
#include "mail.h"
/* Local file scope functions. */
static void mob_log(char_data *mob, const char *format, ...);
/* attaches mob's name and vnum to msg and sends it to script_log */
void mob_log(char_data *mob, const char *format, ...)
static void mob_log(char_data *mob, const char *format, ...)
{
va_list args;
char output[MAX_STRING_LENGTH];
@ -43,7 +44,7 @@ void mob_log(char_data *mob, const char *format, ...)
/* Macro to determine if a mob is permitted to use these commands. */
#define MOB_OR_IMPL(ch) \
((IS_NPC(ch) && (!(ch)->desc || GET_ADMLEVEL((ch)->desc->original) >= ADMLVL_IMPL)) || (SCRIPT(ch) && TRIGGERS(SCRIPT(ch))))
((IS_NPC(ch) && (!(ch)->desc || GET_LEVEL((ch)->desc->original) >= LVL_IMPL)) || (SCRIPT(ch) && TRIGGERS(SCRIPT(ch))))
#define MOB_OR_PLAYER(ch) (GET_LEVEL(ch) > 0)
/* mob commands */
@ -136,8 +137,8 @@ ACMD(do_mkill)
return;
}
/* Lets the mobile destroy an object in its inventory it can also destroy a
* worn object and it can destroy items using all.xxxxx or just plain all of
/* Lets the mobile destroy an object in its inventory it can also destroy a
* worn object and it can destroy items using all.xxxxx or just plain all of
* them. */
ACMD(do_mjunk)
{
@ -286,7 +287,7 @@ ACMD(do_mzoneecho)
{
int zone;
char room_number[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH], *msg;
if (!MOB_OR_IMPL(ch))
{
send_to_char(ch, "Huh?!?\r\n");
@ -307,7 +308,7 @@ ACMD(do_mzoneecho)
}
}
/* Lets the mobile load an item or mobile. All items are loaded into
/* Lets the mobile load an item or mobile. All items are loaded into
* inventory, unless it is NO-TAKE. */
ACMD(do_mload)
{
@ -328,7 +329,7 @@ ACMD(do_mload)
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && (!IS_ADMIN(ch->desc->original, ADMLVL_IMPL)))
if( ch->desc && GET_LEVEL(ch->desc->original) < LVL_IMPL)
return;
target = two_arguments(argument, arg1, arg2);
@ -412,8 +413,8 @@ ACMD(do_mload)
mob_log(ch, "mload: bad type");
}
/* Lets the mobile purge all objects and other npcs in the room, or purge a
* specified object or mob in the room. It can purge itself, but this will
/* Lets the mobile purge all objects and other npcs in the room, or purge a
* specified object or mob in the room. It can purge itself, but this will
* be the last command it does. */
ACMD(do_mpurge)
{
@ -429,7 +430,7 @@ ACMD(do_mpurge)
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if( ch->desc && !IS_ADMIN(ch->desc->original, ADMLVL_IMPL))
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
return;
one_argument(argument, arg);
@ -554,7 +555,7 @@ ACMD(do_mat)
}
}
/* Lets the mobile transfer people. The all argument transfers everyone in the
/* Lets the mobile transfer people. The all argument transfers everyone in the
* current room to the specified location. */
ACMD(do_mteleport)
{
@ -652,7 +653,7 @@ ACMD(do_mdamage) {
script_damage(vict, dam);
}
/* Lets the mobile force someone to do something. must be mortal level and the
/* Lets the mobile force someone to do something. must be mortal level and the
* all argument only affects those in the room with the mobile. */
ACMD(do_mforce)
{
@ -666,7 +667,7 @@ ACMD(do_mforce)
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && (!IS_ADMIN(ch->desc->original, ADMLVL_IMPL)))
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
return;
argument = one_argument(argument, arg);
@ -727,7 +728,7 @@ ACMD(do_mhunt)
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && (!IS_ADMIN(ch->desc->original, ADMLVL_IMPL)))
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
return;
one_argument(argument, arg);
@ -769,7 +770,7 @@ ACMD(do_mremember)
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && (!IS_ADMIN(ch->desc->original, ADMLVL_IMPL)))
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
return;
argument = one_argument(argument, arg);
@ -820,7 +821,7 @@ ACMD(do_mforget)
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
if (ch->desc && (!IS_ADMIN(ch->desc->original, ADMLVL_IMPL)))
if (ch->desc && (GET_LEVEL(ch->desc->original) < LVL_IMPL))
return;
one_argument(argument, arg);
@ -1135,7 +1136,7 @@ ACMD(do_mfollow)
leader->followers = k;
}
/* Prints the message to everyone in the range of numbers. Thanks to Jamie
/* Prints the message to everyone in the range of numbers. Thanks to Jamie
* Nelson of 4D for this contribution */
ACMD(do_mrecho)
{
@ -1154,101 +1155,3 @@ ACMD(do_mrecho)
else
send_to_range(atoi(start), atoi(finish), "%s\r\n", msg);
}
/* Mailing functions */
ACMD(do_mmail)
{
char arg[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], *arg3;
char buf[MAX_STRING_LENGTH];
char_data *victim;
long recipient = MAIL_TO_NOBODY;
obj_vnum o_num;
struct obj_data *obj;
if (!MOB_OR_IMPL(ch)) {
send_to_char(ch, "Huh?!?\r\n");
return;
}
arg3 = two_arguments(argument, arg, arg2);
if (!*arg) {
mob_log(ch, "mmail called with no argument");
return;
} else if (!strcmp(arg, "recipient")) {
create_mob_mail(ch);
if (*arg2 == UID_CHAR) {
if (!(victim = get_char(arg2))) {
mob_log(ch, "mmail: recipient (%s) not found",arg2);
return;
}
} else if (!(victim = get_char_vis(ch, arg2, NULL, FIND_CHAR_WORLD))) {
/* Check special cases and mail groups */
if ((recipient = get_mail_group_by_name(arg2)) == MAIL_TO_NOBODY) {
mob_log(ch,"mmail: victim (%s) does not exist", arg2);
return;
}
} else if (victim == ch) {
mob_log(ch, "mmail: victim is self");
return;
} else if (IS_NPC(victim)) {
mob_log(ch, "mmail: victim is another mob");
return;
} else {
/* all name checks passed - get the recipient ID */
recipient = GET_ID(victim);
}
if (!add_recipient(MOB_MAIL(ch), recipient)) {
mob_log(ch, "mmail failed to add recipient");
return;
}
} else if (!strcmp(arg, "object")) {
create_mob_mail(ch);
o_num = atoi(arg2);
if (!real_object(o_num)) {
mob_log(ch, "mmail: invalid object vnum");
return;
}
if ((obj = read_object(o_num, VIRTUAL)) == NULL) {
mob_log(ch, "mmail: invalid object to load");
return;
}
obj_to_mail(obj, MOB_MAIL(ch)->mail);
} else if (!strcmp(arg, "subject")) {
create_mob_mail(ch);
sprintf(buf, "%s%s", arg2, arg3);
if ((MOB_MAIL(ch)->mail)->subject)
free((MOB_MAIL(ch)->mail)->subject);
(MOB_MAIL(ch)->mail)->subject = strdup(buf);
} else if (!strcmp(arg, "body")) {
create_mob_mail(ch);
if ((MOB_MAIL(ch)->mail)->body)
free((MOB_MAIL(ch)->mail)->body);
(MOB_MAIL(ch)->mail)->body = strdup(buf);
} else if (!strcmp(arg, "gold")) {
create_mob_mail(ch);
(MOB_MAIL(ch)->mail)->coins = atol(arg2);
} else if (!strcmp(arg, "urgent")) {
create_mob_mail(ch);
TOGGLE_BIT_AR((MOB_MAIL(ch)->mail)->mail_flags, MAIL_URGENT);
} else if (!strcmp(arg, "cod")) {
create_mob_mail(ch);
TOGGLE_BIT_AR((MOB_MAIL(ch)->mail)->mail_flags, MAIL_COD);
} else if (!strcmp(arg, "send")) {
if (mail_from_mobile(ch)== FALSE)
mob_log(ch, "mmail: send failed.");
} else if (!strcmp(arg, "new")) {
create_mob_mail(ch);
clear_mail_data(MOB_MAIL(ch)->mail);
} else if ((!strcmp(arg, "view")) ||
(!strcmp(arg, "show")) ||
(!strcmp(arg, "echo")) ||
(!strcmp(arg, "list")) ) {
create_mob_mail(ch);
send_to_room(IN_ROOM(ch), "%s\r\n", get_mail_text(MOB_MAIL(ch)->mail) );
send_to_room(IN_ROOM(ch), "Recipients: %s\r\n", recipient_list(MOB_MAIL(ch)) );
} else {
mob_log(ch, "mmail: unknown %mail% command (%s).", arg);
}
return;
}