From: "Josh B." Subject: Ignore Code... Hiya, I just finished the code I've been working on for ignoring players, and just thought I'd send it to the list if anybody wants to use it. Keep in mind that I haven't done much testing on it. With the testing that I have done, I've noticed one problem. (if you can figure it out, e-mail me so i can change it.) Anyway, it saves fine, but when the person quits, and comes back in, it reads the file fine, but for some reason it reads it twice, and you have to type ignore two times in order to stop ignoring the player. Anyway, that's the only problem I've found. Good Luck: Put the ignore.c file included in this message into your src directory, and add ignore.o to the makefile and put ignore.o: ignore.c structs.h utils.h interpreter.h $(CC) -c $(CFLAGS) ignore.c edit act.comm.c: Towards top put extern int is_ignoring(struct char_data *ch, struct char_data *vict); in the ACMD(do_tell) function, add somewhere with all the others else if (is_ignoring(ch, vict)); act("$E's ignoring you.", FALSE, ch, 0, vict, TO_ROOM | TO_SLEEP); in act.offensive.c: ACMD(do_ignore) { struct char_data *victim; struct ignore *a, *temp; one_argument(argument, arg); if (!*arg) send_to_char("Ignore who?\r\n", ch); else if (!(victim = get_char_vis(ch, arg))) send_to_char(NOPERSON, ch); else if (victim == ch) send_to_char("Ignore yourself? Go seek help!\r\n", ch); else if (IS_NPC(victim)) send_to_char("No ignoring monsters. That isn't nice.\r\n", ch); else if ((a = find_ignore(GET_IGNORELIST(ch), arg)) != NULL) { REMOVE_FROM_LIST(a, GET_IGNORELIST(ch), next); send_to_char("You no longer ignore them.\r\n", ch); free(a->ignore); free(a); } else { CREATE(a, struct ignore, 1); a->ignore = str_dup(arg); a->next = GET_IGNORELIST(ch); GET_IGNORELIST(ch) = a; send_to_char(OK, ch); } } utils.c find all the other declarations of _FILE and add case IGNORE_FILE: prefix="plrignore" suffix="ignore" break; utils.h again, find the #define's of the other _FILE, and add #define IGNORE_FILE 2 also, add somewhere GET_IGNORELIST(ch) ((ch->player_specials->ignorelist) interpreter.h add struct ignore { char *ignore; struct ignore *next } structs.h in struct player_special_data { add struct ignore *ignorelist; I think that about does it. I made this message pretty fast because I have to leave soon, but if you have any problems, just e-mail me. Hope this helps :) Josh /* ************************************************************************ * File: ignore.c * * Usage: Ignoring Players * * * * Written by Josh Brittenham * * * * Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University * * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * ************************************************************************ */ #include #include #include #include #include "conf.h" #include "sysdep.h" #include "structs.h" #include "utils.h" #include "interpreter.h" struct ignore *find_ignore(struct ignore *ignore_list, char *str) { while (ignore_list != NULL) { if (*str == *ignore_list->ignore) if (!strcmp(str, ignore_list->ignore)) return ignore_list; ignore_list = ignore_list->next; } return NULL; } int is_ignoring(struct char_data *ch, struct char_data *vict) { struct ignore *temp; char buf[127]; sprintf(buf, "%s", GET_NAME(ch)); temp = GET_IGNORELIST(vict); while (temp != NULL) { if (!str_cmp(buf, temp->ignore)) return 1; temp = temp->next; } return 0; } void write_ignorelist(struct char_data *ch) { FILE *file; char ignoref[127]; struct ignore *ignoretemp; int ignorelength; get_filename(GET_NAME(ch), ignoref, IGNORE_FILE); unlink(ignoref); if (!GET_IGNORELIST(ch)) return; file = fopen(ignoref, "wt"); ignoretemp = GET_IGNORELIST(ch); while(ignoretemp) { ignorelength = strlen(ignoretemp->ignore); fprintf(file, "%d\n", ignorelength); fprintf(file, "%s\n", ignoretemp->ignore); ignoretemp = ignoretemp->next; } fclose(file); } void read_ignorelist(struct char_data *ch) { FILE *file; char ignoref[127]; struct ignore *ignoretemp2; char buf[127]; int ignorelength; get_filename(GET_NAME(ch), ignoref, IGNORE_FILE); file = fopen(ignoref, "r"); if(!file) return; CREATE(GET_IGNORELIST(ch), struct ignore, 1); ignoretemp2 = GET_IGNORELIST(ch); do { fscanf(file, "%d\n", &ignorelength); fgets(buf, ignorelength + 1, file); ignoretemp2->ignore = strdup(buf); if(!feof(file)) { CREATE(ignoretemp2->next, struct ignore, 1); ignoretemp2 = ignoretemp2->next; } } while(!feof(file)); fclose(file); }