Skip to content

Commit

Permalink
Merge pull request #29 from drskinner/COV-0068
Browse files Browse the repository at this point in the history
COV-0068: Social commands accept objects as targets
  • Loading branch information
Myles Skinner committed Nov 19, 2017
2 parents 5c34cf0 + d56a848 commit ff3342b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 44 deletions.
77 changes: 40 additions & 37 deletions src/act_wiz.c
Original file line number Diff line number Diff line change
Expand Up @@ -7731,21 +7731,12 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
argument = one_argument(argument, arg1);
argument = one_argument(argument, arg2);

if (arg1[0] == '\0')
{
send_to_char("Syntax: sedit <social> [field]\r\n", ch);
send_to_char("Syntax: sedit <social> create\r\n", ch);
if (get_trust(ch) > LEVEL_GOD)
send_to_char("Syntax: sedit <social> delete\r\n", ch);
if (get_trust(ch) > LEVEL_LESSER)
send_to_char("Syntax: sedit <save>\r\n", ch);
send_to_char("\r\nField being one of:\r\n", ch);
send_to_char(" cnoarg onoarg cfound ofound vfound cauto oauto\r\n", ch);
if (arg1[0] == '\0' || !str_cmp(arg1, "?") || !str_cmp(arg1, "help")) {
do_help(ch, "_sedit");
return;
}

if (get_trust(ch) > LEVEL_LESSER && !str_cmp(arg1, "save"))
{
if (get_trust(ch) > LEVEL_LESSER && !str_cmp(arg1, "save")) {
save_socials();
send_to_char("Saved.\r\n", ch);
return;
Expand All @@ -7768,8 +7759,7 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!social)
{
if (!social) {
send_to_char("Social not found.\r\n", ch);
return;
}
Expand All @@ -7778,26 +7768,27 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
{
ch_printf(ch, "Social: %s\r\n\r\nCNoArg: %s\r\n", social->name, social->char_no_arg);
ch_printf(ch, "ONoArg: %s\r\nCFound: %s\r\nOFound: %s\r\n",
social->others_no_arg ? social->others_no_arg : "(not set)",
social->char_found ? social->char_found : "(not set)",
social->others_found ? social->others_found : "(not set)");
ch_printf(ch, "VFound: %s\r\nCAuto : %s\r\nOAuto : %s\r\n",
social->vict_found ? social->vict_found : "(not set)",
social->char_auto ? social->char_auto : "(not set)",
social->others_auto ? social->others_auto : "(not set)");
social->others_no_arg ? social->others_no_arg : "(not set)",
social->char_found ? social->char_found : "(not set)",
social->others_found ? social->others_found : "(not set)");
ch_printf(ch, "VFound: %s\r\nCAuto: %s\r\nOAuto: %s\r\n",
social->vict_found ? social->vict_found : "(not set)",
social->char_auto ? social->char_auto : "(not set)",
social->others_auto ? social->others_auto : "(not set)");
ch_printf(ch, "CObject: %s\r\nOObject: %s\r\n",
social->char_obj ? social->char_obj : "(not set)",
social->others_obj ? social->others_obj : "(not set)");
return;
}

if (get_trust(ch) > LEVEL_GOD && !str_cmp(arg2, "delete"))
{
if (get_trust(ch) > LEVEL_GOD && !str_cmp(arg2, "delete")) {
unlink_social(social);
free_social(social);
send_to_char("Deleted.\r\n", ch);
return;
}

if (!str_cmp(arg2, "cnoarg"))
{
if (!str_cmp(arg2, "cnoarg")) {
if (argument[0] == '\0' || !str_cmp(argument, "clear"))
{
send_to_char("You cannot clear this field. It must have a message.\r\n", ch);
Expand All @@ -7810,8 +7801,7 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!str_cmp(arg2, "onoarg"))
{
if (!str_cmp(arg2, "onoarg")) {
if (social->others_no_arg)
DISPOSE(social->others_no_arg);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
Expand All @@ -7820,8 +7810,7 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!str_cmp(arg2, "cfound"))
{
if (!str_cmp(arg2, "cfound")) {
if (social->char_found)
DISPOSE(social->char_found);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
Expand All @@ -7830,8 +7819,7 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!str_cmp(arg2, "ofound"))
{
if (!str_cmp(arg2, "ofound")) {
if (social->others_found)
DISPOSE(social->others_found);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
Expand All @@ -7840,8 +7828,7 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!str_cmp(arg2, "vfound"))
{
if (!str_cmp(arg2, "vfound")) {
if (social->vict_found)
DISPOSE(social->vict_found);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
Expand All @@ -7850,8 +7837,7 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!str_cmp(arg2, "cauto"))
{
if (!str_cmp(arg2, "cauto")) {
if (social->char_auto)
DISPOSE(social->char_auto);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
Expand All @@ -7860,8 +7846,7 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!str_cmp(arg2, "oauto"))
{
if (!str_cmp(arg2, "oauto")) {
if (social->others_auto)
DISPOSE(social->others_auto);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
Expand All @@ -7870,6 +7855,24 @@ void do_sedit(CHAR_DATA* ch, const char* argument)
return;
}

if (!str_cmp(arg2, "cobject")) {
if (social->char_obj)
DISPOSE(social->char_obj);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
social->char_obj = str_dup(argument);
send_to_char("Done.\r\n", ch);
return;
}

if (!str_cmp(arg2, "oobject")) {
if (social->others_obj)
DISPOSE(social->others_obj);
if (argument[0] != '\0' && str_cmp(argument, "clear"))
social->others_obj = str_dup(argument);
send_to_char("Done.\r\n", ch);
return;
}

if (get_trust(ch) > LEVEL_GREATER && !str_cmp(arg2, "name"))
{
bool relocate;
Expand Down
2 changes: 1 addition & 1 deletion src/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ DECLARE_DO_FUN(do_color);
#define AT_LOG AT_GREY
#define AT_ROOM_NAME AT_WHITE
#define AT_ROOM_DESC AT_PLAIN
#define AT_SOCIAL AT_PLAIN
#define AT_SAY 35
#define AT_GOSSIP 36
#define AT_YELL 37
Expand All @@ -168,7 +169,6 @@ DECLARE_DO_FUN(do_color);
#define AT_CONSIDER 46
#define AT_REPORT 47
#define AT_POISON 48
#define AT_SOCIAL 49
#define AT_DYING 50
#define AT_DEAD 51
#define AT_SKILL 52
Expand Down
16 changes: 10 additions & 6 deletions src/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ bool check_social(CHAR_DATA * ch, const char *command, const char *argument)
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim, *victim_next;
OBJ_DATA *victobj;
SOCIALTYPE *social;
CHAR_DATA *removed[128]; /* What are the chances of more than 128? */
ROOM_INDEX_DATA *room;
Expand Down Expand Up @@ -681,12 +682,14 @@ bool check_social(CHAR_DATA * ch, const char *command, const char *argument)
act(AT_SOCIAL, social->others_no_arg, ch, NULL, victim, TO_ROOM);
act(AT_SOCIAL, social->char_no_arg, ch, NULL, victim, TO_CHAR);
}
else if ((victim = get_char_room(ch, arg)) == NULL)
{
/*
* If they aren't in the room, they may be in the list of
* people ignoring...
*/
else if ((victim = get_char_room(ch, arg)) == NULL) {
if ((victobj = get_obj_here(ch, arg)) != NULL) {
act(AT_SOCIAL, social->others_obj, ch, NULL, victobj, TO_ROOM);
act(AT_SOCIAL, social->char_obj, ch, NULL, victobj, TO_CHAR);
}
else {
/* If they aren't in the room, they may be in the list of
* people ignoring... */
if (i != 0)
{
for (k = 0, victim = removed[0]; k < i; k++, victim = removed[k])
Expand All @@ -702,6 +705,7 @@ bool check_social(CHAR_DATA * ch, const char *command, const char *argument)

if (!victim)
send_to_char("They aren't here.\r\n", ch);
}
}
else if (victim == ch)
{
Expand Down
2 changes: 2 additions & 0 deletions src/mud.h
Original file line number Diff line number Diff line change
Expand Up @@ -3518,6 +3518,8 @@ struct social_type
const char *name;
const char *char_no_arg;
const char *others_no_arg;
const char *char_obj;
const char *others_obj;
const char *char_found;
const char *others_found;
const char *vict_found;
Expand Down
6 changes: 6 additions & 0 deletions src/tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,10 @@ void save_socials()
bug("Save_socials: NULL char_no_arg in hash bucket %d", x);
if (social->others_no_arg)
fprintf(fpout, "OthersNoArg %s~\n", social->others_no_arg);
if (social->char_obj)
fprintf(fpout, "CharObject %s~\n", social->char_obj);
if (social->others_obj)
fprintf(fpout, "OthersObject %s~\n", social->others_obj);
if (social->char_found)
fprintf(fpout, "CharFound %s~\n", social->char_found);
if (social->others_found)
Expand Down Expand Up @@ -1452,6 +1456,7 @@ void fread_social(FILE * fp)

case 'C':
KEY("CharNoArg", social->char_no_arg, fread_string_nohash(fp));
KEY("CharObject", social->char_obj, fread_string_nohash(fp));
KEY("CharFound", social->char_found, fread_string_nohash(fp));
KEY("CharAuto", social->char_auto, fread_string_nohash(fp));
break;
Expand Down Expand Up @@ -1482,6 +1487,7 @@ void fread_social(FILE * fp)

case 'O':
KEY("OthersNoArg", social->others_no_arg, fread_string_nohash(fp));
KEY("OthersObject", social->others_obj, fread_string_nohash(fp));
KEY("OthersFound", social->others_found, fread_string_nohash(fp));
KEY("OthersAuto", social->others_auto, fread_string_nohash(fp));
break;
Expand Down

0 comments on commit ff3342b

Please sign in to comment.