diff --git a/changelog b/changelog index 4a215dc..7532ad9 100644 --- a/changelog +++ b/changelog @@ -35,6 +35,11 @@ export (QQ's a zone into a tarball) Xlist (mlist, olist, rlist, zlist, slist, tlist, qlist) (lots of major bugfixes too) @ +[Nov 04 2010] - Jamdog + Bug-Fix: Converted affect flags in struct affected_type from 32-bit to 128-bit + Bug Fix: Players with too much gold now don't lose eq when renting + Removed conf.h fron the SVN, as this is created by the configure script + Minor IBT system change for accurately finding who logged an IBT [Nov 01 2010] - Rumble Fixed do_scan crash due to exits to NOWHERE. (thanks Rhade) Changed do_score experience tnl to list only mortals since LVL_IMMORT showed negative EXP. diff --git a/src/act.item.c b/src/act.item.c index cd23c7e..3bfd89e 100644 --- a/src/act.item.c +++ b/src/act.item.c @@ -84,7 +84,7 @@ static void perform_put(struct char_data *ch, struct obj_data *obj, struct obj_d 1) put 2) put all. 3) put all - The must be in inventory or on ground. All objects to be put + The must be in inventory or on ground. All objects to be put into container must be in inventory. */ ACMD(do_put) { @@ -473,7 +473,7 @@ static int perform_drop(struct char_data *ch, struct obj_data *obj, return (value); default: log("SYSERR: Incorrect argument %d passed to perform_drop.", mode); - /* SYSERR_DESC: This error comes from perform_drop() and is output when + /* SYSERR_DESC: This error comes from perform_drop() and is output when * perform_drop() is called with an illegal 'mode' argument. */ break; } @@ -619,7 +619,7 @@ static void perform_give(struct char_data *ch, struct char_data *vict, act("You give $p to $N.", FALSE, ch, obj, vict, TO_CHAR); act("$n gives you $p.", FALSE, ch, obj, vict, TO_VICT); act("$n gives $p to $N.", TRUE, ch, obj, vict, TO_NOTVICT); - + autoquest_trigger_check( ch, vict, obj, AQ_OBJ_RETURN); } @@ -748,8 +748,8 @@ void weight_change_object(struct obj_data *obj, int weight) obj_to_obj(obj, tmp_obj); } else { log("SYSERR: Unknown attempt to subtract weight from an object."); - /* SYSERR_DESC: weight_change_object() outputs this error when weight is - * attempted to be removed from an object that is not carried or in + /* SYSERR_DESC: weight_change_object() outputs this error when weight is + * attempted to be removed from an object that is not carried or in * another object. */ } } @@ -766,8 +766,8 @@ void name_from_drinkcon(struct obj_data *obj) liqname = drinknames[GET_OBJ_VAL(obj, 2)]; if (!isname(liqname, obj->name)) { log("SYSERR: Can't remove liquid '%s' from '%s' (%d) item.", liqname, obj->name, obj->item_number); - /* SYSERR_DESC: From name_from_drinkcon(), this error comes about if the - * object noted (by keywords and item vnum) does not contain the liquid + /* SYSERR_DESC: From name_from_drinkcon(), this error comes about if the + * object noted (by keywords and item vnum) does not contain the liquid * string being searched for. */ return; } @@ -907,7 +907,7 @@ ACMD(do_drink) weight = MIN(amount, GET_OBJ_WEIGHT(temp)); weight_change_object(temp, -weight); /* Subtract amount */ } - + gain_condition(ch, DRUNK, drink_aff[GET_OBJ_VAL(temp, 2)][DRUNK] * amount / 4); gain_condition(ch, HUNGER, drink_aff[GET_OBJ_VAL(temp, 2)][HUNGER] * amount / 4); gain_condition(ch, THIRST, drink_aff[GET_OBJ_VAL(temp, 2)][THIRST] * amount / 4); @@ -925,11 +925,10 @@ ACMD(do_drink) send_to_char(ch, "Oops, it tasted rather strange!\r\n"); act("$n chokes and utters some strange sounds.", TRUE, ch, 0, 0, TO_ROOM); + new_affect(&af); af.type = SPELL_POISON; af.duration = amount * 3; - af.modifier = 0; - af.location = APPLY_NONE; - af.bitvector = AFF_POISON; + SET_BIT_AR(af.bitvector, AFF_POISON); affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE); } /* Empty the container (unless unlimited), and no longer poison. */ @@ -1001,11 +1000,10 @@ ACMD(do_eat) send_to_char(ch, "Oops, that tasted rather strange!\r\n"); act("$n coughs and utters some strange sounds.", FALSE, ch, 0, 0, TO_ROOM); + new_affect(&af); af.type = SPELL_POISON; af.duration = amount * 2; - af.modifier = 0; - af.location = APPLY_NONE; - af.bitvector = AFF_POISON; + SET_BIT_AR(af.bitvector, AFF_POISON); affect_join(ch, &af, FALSE, FALSE, FALSE, FALSE); } if (subcmd == SCMD_EAT) @@ -1450,7 +1448,7 @@ static void perform_remove(struct char_data *ch, int pos) log("SYSERR: perform_remove: bad pos %d passed.", pos); /* This error occurs when perform_remove() is passed a bad 'pos' * (location) to remove an object from. */ - else if (OBJ_FLAGGED(obj, ITEM_NODROP) && !PRF_FLAGGED(ch, PRF_NOHASSLE)) + else if (OBJ_FLAGGED(obj, ITEM_NODROP) && !PRF_FLAGGED(ch, PRF_NOHASSLE)) act("You can't remove $p, it must be CURSED!", FALSE, ch, obj, 0, TO_CHAR); else if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch)&& !PRF_FLAGGED(ch, PRF_NOHASSLE)) act("$p: you can't carry that many items!", FALSE, ch, obj, 0, TO_CHAR); diff --git a/src/act.other.c b/src/act.other.c index adaf41d..a3dadfd 100644 --- a/src/act.other.c +++ b/src/act.other.c @@ -117,11 +117,10 @@ ACMD(do_sneak) if (percent > GET_SKILL(ch, SKILL_SNEAK) + dex_app_skill[GET_DEX(ch)].sneak) return; + new_affect(&af); af.type = SKILL_SNEAK; af.duration = GET_LEVEL(ch); - af.modifier = 0; - af.location = APPLY_NONE; - af.bitvector = AFF_SNEAK; + SET_BIT_AR(af.bitvector, AFF_SNEAK); affect_to_char(ch, &af); } diff --git a/src/act.wizard.c b/src/act.wizard.c index 7d1cf25..a079c78 100644 --- a/src/act.wizard.c +++ b/src/act.wizard.c @@ -887,11 +887,14 @@ static void do_stat_character(struct char_data *ch, struct char_data *k) if (aff->modifier) send_to_char(ch, "%+d to %s", aff->modifier, apply_types[(int) aff->location]); - if (aff->bitvector) { - if (aff->modifier) - send_to_char(ch, ", "); - - send_to_char(ch, "sets %s", affected_bits[aff->bitvector]); + if (aff->bitvector[0] || aff->bitvector[1] || aff->bitvector[2] || aff->bitvector[3]) { + if (aff->modifier) + send_to_char(ch, ", "); + for (i=0; ibitvector, i)) { + send_to_char(ch, "sets %s, ", affected_bits[i]); + } + } } send_to_char(ch, "\r\n"); } diff --git a/src/conf.h b/src/conf.h deleted file mode 100644 index 10000b0..0000000 --- a/src/conf.h +++ /dev/null @@ -1,338 +0,0 @@ -/* src/conf.h. Generated automatically by configure. */ -/* src/conf.h.in. Generated automatically from configure.in by autoheader. */ - -#ifndef _CONF_H_ -#define _CONF_H_ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define if you don't have vprintf but do have _doprnt. */ -/* #undef HAVE_DOPRNT */ - -/* Define if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if you have the vprintf function. */ -#define HAVE_VPRINTF 1 - -/* Define to `int' if doesn't define. */ -/* #undef pid_t */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* Define to `unsigned' if doesn't define. */ -/* #undef size_t */ - -/* Define if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define if we're compiling CircleMUD under any type of UNIX system. */ -#define CIRCLE_UNIX 1 - -/* Define if the system is capable of using crypt() to encrypt. */ -#define CIRCLE_CRYPT 1 - -/* Define if we don't have proper support for the system's crypt(). */ -/* #undef HAVE_UNSAFE_CRYPT */ - -/* Define is the system has struct in_addr. */ -#define HAVE_STRUCT_IN_ADDR 1 - -/* Define to `int' if doesn't define. */ -/* #undef socklen_t */ - -/* Define to `int' if doesn't define. */ -/* #undef ssize_t */ - -/* Define if you have the gettimeofday function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define if you have the inet_addr function. */ -#define HAVE_INET_ADDR 1 - -/* Define if you have the inet_aton function. */ -#define HAVE_INET_ATON 1 - -/* Define if you have the select function. */ -#define HAVE_SELECT 1 - -/* Define if you have the snprintf function. */ -#define HAVE_SNPRINTF 1 - -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - -/* Define if you have the strdup function. */ -#define HAVE_STRDUP 1 - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the stricmp function. */ -/* #undef HAVE_STRICMP */ - -/* Define if you have the strlcpy function. */ -/* #undef HAVE_STRLCPY */ - -/* Define if you have the strncasecmp function. */ -#define HAVE_STRNCASECMP 1 - -/* Define if you have the strnicmp function. */ -/* #undef HAVE_STRNICMP */ - -/* Define if you have the strstr function. */ -#define HAVE_STRSTR 1 - -/* Define if you have the vsnprintf function. */ -#define HAVE_VSNPRINTF 1 - -/* Define if you have the header file. */ -#define HAVE_ARPA_INET_H 1 - -/* Define if you have the header file. */ -#define HAVE_ARPA_TELNET_H 1 - -/* Define if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define if you have the header file. */ -#define HAVE_CRYPT_H 1 - -/* Define if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the header file. */ -#define HAVE_MCHECK_H 1 - -/* Define if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define if you have the header file. */ -/* #undef HAVE_NET_ERRNO_H */ - -/* Define if you have the header file. */ -#define HAVE_NETDB_H 1 - -/* Define if you have the header file. */ -#define HAVE_NETINET_IN_H 1 - -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_FCNTL_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_SOCKET_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if you have the header file. */ -#define HAVE_SYS_UIO_H 1 - -/* Define if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the malloc library (-lmalloc). */ -/* #undef HAVE_LIBMALLOC */ - -/* Check for a prototype to accept. */ -/* #undef NEED_ACCEPT_PROTO */ - -/* Check for a prototype to atoi. */ -/* #undef NEED_ATOI_PROTO */ - -/* Check for a prototype to atol. */ -/* #undef NEED_ATOL_PROTO */ - -/* Check for a prototype to bind. */ -/* #undef NEED_BIND_PROTO */ - -/* Check for a prototype to bzero. */ -/* #undef NEED_BZERO_PROTO */ - -/* Check for a prototype to chdir. */ -/* #undef NEED_CHDIR_PROTO */ - -/* Check for a prototype to close. */ -/* #undef NEED_CLOSE_PROTO */ - -/* Check for a prototype to crypt. */ -/* #undef NEED_CRYPT_PROTO */ - -/* Check for a prototype to fclose. */ -/* #undef NEED_FCLOSE_PROTO */ - -/* Check for a prototype to fcntl. */ -/* #undef NEED_FCNTL_PROTO */ - -/* Check for a prototype to fflush. */ -/* #undef NEED_FFLUSH_PROTO */ - -/* Check for a prototype to fprintf. */ -/* #undef NEED_FPRINTF_PROTO */ - -/* Check for a prototype to fputc. */ -/* #undef NEED_FPUTC_PROTO */ - -/* Check for a prototype to fputs. */ -/* #undef NEED_FPUTS_PROTO */ - -/* Check for a prototype to fread. */ -/* #undef NEED_FREAD_PROTO */ - -/* Check for a prototype to fscanf. */ -/* #undef NEED_FSCANF_PROTO */ - -/* Check for a prototype to fseek. */ -/* #undef NEED_FSEEK_PROTO */ - -/* Check for a prototype to fwrite. */ -/* #undef NEED_FWRITE_PROTO */ - -/* Check for a prototype to getpeername. */ -/* #undef NEED_GETPEERNAME_PROTO */ - -/* Check for a prototype to getpid. */ -/* #undef NEED_GETPID_PROTO */ - -/* Check for a prototype to getrlimit. */ -/* #undef NEED_GETRLIMIT_PROTO */ - -/* Check for a prototype to getsockname. */ -/* #undef NEED_GETSOCKNAME_PROTO */ - -/* Check for a prototype to gettimeofday. */ -/* #undef NEED_GETTIMEOFDAY_PROTO */ - -/* Check for a prototype to htonl. */ -/* #undef NEED_HTONL_PROTO */ - -/* Check for a prototype to htons. */ -/* #undef NEED_HTONS_PROTO */ - -/* Check for a prototype to inet_addr. */ -/* #undef NEED_INET_ADDR_PROTO */ - -/* Check for a prototype to inet_aton. */ -/* #undef NEED_INET_ATON_PROTO */ - -/* Check for a prototype to inet_ntoa. */ -/* #undef NEED_INET_NTOA_PROTO */ - -/* Check for a prototype to listen. */ -/* #undef NEED_LISTEN_PROTO */ - -/* Check for a prototype to ntohl. */ -/* #undef NEED_NTOHL_PROTO */ - -/* Check for a prototype to perror. */ -/* #undef NEED_PERROR_PROTO */ - -/* Check for a prototype to printf. */ -/* #undef NEED_PRINTF_PROTO */ - -/* Check for a prototype to qsort. */ -/* #undef NEED_QSORT_PROTO */ - -/* Check for a prototype to read. */ -/* #undef NEED_READ_PROTO */ - -/* Check for a prototype to remove. */ -/* #undef NEED_REMOVE_PROTO */ - -/* Check for a prototype to rewind. */ -/* #undef NEED_REWIND_PROTO */ - -/* Check for a prototype to select. */ -/* #undef NEED_SELECT_PROTO */ - -/* Check for a prototype to setitimer. */ -/* #undef NEED_SETITIMER_PROTO */ - -/* Check for a prototype to setrlimit. */ -/* #undef NEED_SETRLIMIT_PROTO */ - -/* Check for a prototype to setsockopt. */ -/* #undef NEED_SETSOCKOPT_PROTO */ - -/* Check for a prototype to snprintf. */ -/* #undef NEED_SNPRINTF_PROTO */ - -/* Check for a prototype to socket. */ -/* #undef NEED_SOCKET_PROTO */ - -/* Check for a prototype to sprintf. */ -/* #undef NEED_SPRINTF_PROTO */ - -/* Check for a prototype to sscanf. */ -/* #undef NEED_SSCANF_PROTO */ - -/* Check for a prototype to strcasecmp. */ -/* #undef NEED_STRCASECMP_PROTO */ - -/* Check for a prototype to strdup. */ -/* #undef NEED_STRDUP_PROTO */ - -/* Check for a prototype to strerror. */ -/* #undef NEED_STRERROR_PROTO */ - -/* Check for a prototype to stricmp. */ -#define NEED_STRICMP_PROTO - -/* Check for a prototype to strlcpy. */ -#define NEED_STRLCPY_PROTO - -/* Check for a prototype to strncasecmp. */ -/* #undef NEED_STRNCASECMP_PROTO */ - -/* Check for a prototype to strnicmp. */ -#define NEED_STRNICMP_PROTO - -/* Check for a prototype to system. */ -/* #undef NEED_SYSTEM_PROTO */ - -/* Check for a prototype to time. */ -/* #undef NEED_TIME_PROTO */ - -/* Check for a prototype to unlink. */ -/* #undef NEED_UNLINK_PROTO */ - -/* Check for a prototype to vsnprintf. */ -/* #undef NEED_VSNPRINTF_PROTO */ - -/* Check for a prototype to write. */ -/* #undef NEED_WRITE_PROTO */ - - -#endif /* _CONF_H_ */ diff --git a/src/dg_misc.c b/src/dg_misc.c index 13aa4c2..c1524ec 100644 --- a/src/dg_misc.c +++ b/src/dg_misc.c @@ -227,16 +227,15 @@ void do_dg_affect(void *go, struct script_data *sc, trig_data *trig, } /* add the affect */ + new_affect(&af); af.type = SPELL_DG_AFFECT; af.duration = duration -1; af.modifier = value; if (type == APPLY_TYPE) { af.location = i; - af.bitvector = 0; } else { - af.location = 0; - af.bitvector = i; + SET_BIT_AR(af.bitvector, i); } affect_to_char(ch, &af); diff --git a/src/handler.c b/src/handler.c index 2498556..b380554 100644 --- a/src/handler.c +++ b/src/handler.c @@ -29,8 +29,7 @@ static int extractions_pending = 0; /* local file scope functions */ static int apply_ac(struct char_data *ch, int eq_pos); static void update_object(struct obj_data *obj, int use); -static void affect_modify(struct char_data *ch, byte loc, sbyte mod, long bitv, bool add); - +static void affect_modify_ar(struct char_data * ch, byte loc, sbyte mod, int bitv[], bool add); char *fname(const char *namelist) { @@ -203,19 +202,7 @@ void aff_apply_modify(struct char_data *ch, byte loc, sbyte mod, char *msg) } /* switch */ } -static void affect_modify(struct char_data * ch, byte loc, sbyte mod, long bitv, bool add) -{ - if (add) { - SET_BIT_AR(AFF_FLAGS(ch), bitv); - } else { - REMOVE_BIT_AR(AFF_FLAGS(ch), bitv); - mod = -mod; - } - - aff_apply_modify(ch, loc, mod, "affect_modify"); -} - -void affect_modify_ar(struct char_data * ch, byte loc, sbyte mod, int bitv[], bool add) +static void affect_modify_ar(struct char_data * ch, byte loc, sbyte mod, int bitv[], bool add) { int i , j; @@ -251,7 +238,7 @@ void affect_total(struct char_data *ch) } for (af = ch->affected; af; af = af->next) - affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE); + affect_modify_ar(ch, af->location, af->modifier, af->bitvector, FALSE); ch->aff_abils = ch->real_abils; @@ -264,7 +251,7 @@ void affect_total(struct char_data *ch) } for (af = ch->affected; af; af = af->next) - affect_modify(ch, af->location, af->modifier, af->bitvector, TRUE); + affect_modify_ar(ch, af->location, af->modifier, af->bitvector, TRUE); /* Make certain values are between 0..25, not < 0 and not > 25! */ i = (IS_NPC(ch) || GET_LEVEL(ch) >= LVL_GRGOD) ? 25 : 18; @@ -299,7 +286,7 @@ void affect_to_char(struct char_data *ch, struct affected_type *af) affected_alloc->next = ch->affected; ch->affected = affected_alloc; - affect_modify(ch, af->location, af->modifier, af->bitvector, TRUE); + affect_modify_ar(ch, af->location, af->modifier, af->bitvector, TRUE); affect_total(ch); } @@ -315,7 +302,7 @@ void affect_remove(struct char_data *ch, struct affected_type *af) return; } - affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE); + affect_modify_ar(ch, af->location, af->modifier, af->bitvector, FALSE); REMOVE_FROM_LIST(af, ch->affected, next); free(af); affect_total(ch); diff --git a/src/ibt.c b/src/ibt.c index 6c68555..342b794 100755 --- a/src/ibt.c +++ b/src/ibt.c @@ -56,6 +56,7 @@ static void free_ibt_list(IBT_DATA *first_ibt, IBT_DATA *last_ibt); static IBT_DATA *read_ibt(char *filename, FILE *fp); static IBT_DATA *get_first_ibt(int mode); static IBT_DATA *get_last_ibt(int mode); +static bool is_ibt_logger(IBT_DATA *ibtData, struct char_data *ch); /* Internal (static) OLC functions */ static void ibtedit_setup(struct descriptor_data *d); static void ibtedit_save(struct descriptor_data *d); @@ -419,6 +420,22 @@ bool free_ibt(int mode, IBT_DATA *ibtData) return TRUE; } +/* Return TRUE if 'ch' is the person who logged the IBT */ +static bool is_ibt_logger(IBT_DATA *ibtData, struct char_data *ch) +{ + if ( ch && !IS_NPC(ch) && ibtData ) { + + /* Check the ID number first (in case of name change) */ + if ((ibtData->id_num != NOBODY) && (ibtData->id_num == GET_IDNUM(ch))) + return TRUE; + + /* Check the name next (in case of deletion/recreation) */ + if (strcmp(ibtData->name, GET_NAME(ch)) == 0) + return TRUE; + } + return FALSE; +} + ACMD(do_ibt) { char arg[MAX_STRING_LENGTH], arg2[MAX_STRING_LENGTH]; @@ -482,7 +499,7 @@ ACMD(do_ibt) send_to_char(ch, "That %s doesn't exist.\r\n", CMD_NAME); return; } else { - if ((GET_LEVEL(ch) < LVL_IMMORT) && (GET_IDNUM(ch) != ibtData->id_num)) { + if ((GET_LEVEL(ch) < LVL_IMMORT) && (!is_ibt_logger(ibtData, ch))) { send_to_char(ch, "Sorry but you may only view %ss you have posted yourself.\n\r", ibt_types[subcmd]); } else { @@ -522,7 +539,7 @@ ACMD(do_ibt) i++; /* For mortals, skip IBT's that they didn't log */ - if ((GET_LEVEL(ch) < LVL_IMMORT) && (ibtData->id_num != GET_IDNUM(ch))) + if ((GET_LEVEL(ch) < LVL_IMMORT) && !is_ibt_logger(ibtData,ch)) continue; /* Set up the 'important' flag */ diff --git a/src/magic.c b/src/magic.c index 9c39bfb..7034284 100644 --- a/src/magic.c +++ b/src/magic.c @@ -28,9 +28,9 @@ static int mag_materials(struct char_data *ch, IDXTYPE item0, IDXTYPE item1, IDX static void perform_mag_groups(int level, struct char_data *ch, struct char_data *tch, int spellnum, int savetype); -/* Negative apply_saving_throw[] values make saving throws better! So do - * negative modifiers. Though people may be used to the reverse of that. - * It's due to the code modifying the target saving throw instead of the +/* Negative apply_saving_throw[] values make saving throws better! So do + * negative modifiers. Though people may be used to the reverse of that. + * It's due to the code modifying the target saving throw instead of the * random number of the character as in some other systems. */ int mag_savingthrow(struct char_data *ch, int type, int modifier) { @@ -91,7 +91,7 @@ void affect_update(void) * FALSE to send no in game messages from this function. * @retval int TRUE if ch has all materials to cast the spell, FALSE if not. */ -static int mag_materials(struct char_data *ch, IDXTYPE item0, +static int mag_materials(struct char_data *ch, IDXTYPE item0, IDXTYPE item1, IDXTYPE item2, int extract, int verbose) { /* Begin Local variable definitions. */ @@ -106,33 +106,33 @@ static int mag_materials(struct char_data *ch, IDXTYPE item0, /* Begin success checks. Checks must pass to signal a success. */ /*------------------------------------------------------------------------*/ /* Check for the objects in the players inventory. */ - for (tobj = ch->carrying; tobj; tobj = tobj->next_content) + for (tobj = ch->carrying; tobj; tobj = tobj->next_content) { - if ((item0 != NOTHING) && (GET_OBJ_VNUM(tobj) == item0)) + if ((item0 != NOTHING) && (GET_OBJ_VNUM(tobj) == item0)) { obj0 = tobj; item0 = NOTHING; - } - else if ((item1 != NOTHING) && (GET_OBJ_VNUM(tobj) == item1)) + } + else if ((item1 != NOTHING) && (GET_OBJ_VNUM(tobj) == item1)) { obj1 = tobj; item1 = NOTHING; - } - else if ((item2 != NOTHING) && (GET_OBJ_VNUM(tobj) == item2)) + } + else if ((item2 != NOTHING) && (GET_OBJ_VNUM(tobj) == item2)) { obj2 = tobj; item2 = NOTHING; } } - - /* If we needed items, but didn't find all of them, then the spell is a + + /* If we needed items, but didn't find all of them, then the spell is a * failure. */ - if ((item0 != NOTHING) || (item1 != NOTHING) || (item2 != NOTHING)) + if ((item0 != NOTHING) || (item1 != NOTHING) || (item2 != NOTHING)) { /* Generic spell failure messages. */ - if (verbose) + if (verbose) { - switch (rand_number(0, 2)) + switch (rand_number(0, 2)) { case 0: send_to_char(ch, "A wart sprouts on your nose.\r\n"); @@ -150,14 +150,14 @@ static int mag_materials(struct char_data *ch, IDXTYPE item0, } /*------------------------------------------------------------------------*/ /* End success checks. */ - + /* From here on, ch has all required materials in their inventory and the * material check will return a success. */ - + /* Begin Material Processing. */ /*------------------------------------------------------------------------*/ /* Extract (destroy) the materials, if so called for. */ - if (extract) + if (extract) { if (obj0 != NULL) extract_obj(obj0); @@ -166,22 +166,22 @@ static int mag_materials(struct char_data *ch, IDXTYPE item0, if (obj2 != NULL) extract_obj(obj2); /* Generic success messages that signals extracted objects. */ - if (verbose) + if (verbose) { send_to_char(ch, "A puff of smoke rises from your pack.\r\n"); act("A puff of smoke rises from $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM); } } - + /* Don't extract the objects, but signal materials successfully found. */ if(!extract && verbose) { send_to_char(ch, "Your pack rumbles.\r\n"); - act("Something rumbles in $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM); + act("Something rumbles in $n's pack.", TRUE, ch, NULL, NULL, TO_ROOM); } /*------------------------------------------------------------------------*/ /* End Material Processing. */ - + /* Signal to calling function that the materials were successfully found * and processed. */ return (TRUE); @@ -189,7 +189,7 @@ static int mag_materials(struct char_data *ch, IDXTYPE item0, /* Every spell that does damage comes through here. This calculates the amount - * of damage, adds in any modifiers, determines what the saves are, tests for + * of damage, adds in any modifiers, determines what the saves are, tests for * save and calls damage(). -1 = dead, otherwise the amount of damage done. */ int mag_damage(int level, struct char_data *ch, struct char_data *victim, int spellnum, int savetype) @@ -294,7 +294,7 @@ int mag_damage(int level, struct char_data *ch, struct char_data *victim, } -/* Every spell that does an affect comes through here. This determines the +/* Every spell that does an affect comes through here. This determines the * effect, whether it is added or replacement, whether it is legal or not, etc. * affect_join(vict, aff, add_dur, avg_dur, add_mod, avg_mod) */ #define MAX_SPELL_AFFECTS 5 /* change if more needed */ @@ -305,17 +305,15 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, struct affected_type af[MAX_SPELL_AFFECTS]; bool accum_affect = FALSE, accum_duration = FALSE; const char *to_vict = NULL, *to_room = NULL; - int i; + int i, j; if (victim == NULL || ch == NULL) return; for (i = 0; i < MAX_SPELL_AFFECTS; i++) { + new_affect(&(af[i])); af[i].type = spellnum; - af[i].bitvector = 0; - af[i].modifier = 0; - af[i].location = APPLY_NONE; } switch (spellnum) { @@ -361,12 +359,12 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, af[0].location = APPLY_HITROLL; af[0].modifier = -4; af[0].duration = 2; - af[0].bitvector = AFF_BLIND; + SET_BIT_AR(af[0].bitvector, AFF_BLIND); af[1].location = APPLY_AC; af[1].modifier = 40; af[1].duration = 2; - af[1].bitvector = AFF_BLIND; + SET_BIT_AR(af[1].bitvector, AFF_BLIND); to_room = "$n seems to be blinded!"; to_vict = "You have been blinded!"; @@ -381,12 +379,12 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, af[0].location = APPLY_HITROLL; af[0].duration = 1 + (GET_LEVEL(ch) / 2); af[0].modifier = -1; - af[0].bitvector = AFF_CURSE; + SET_BIT_AR(af[0].bitvector, AFF_CURSE); af[1].location = APPLY_DAMROLL; af[1].duration = 1 + (GET_LEVEL(ch) / 2); af[1].modifier = -1; - af[1].bitvector = AFF_CURSE; + SET_BIT_AR(af[1].bitvector, AFF_CURSE); accum_duration = TRUE; accum_affect = TRUE; @@ -396,28 +394,28 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, case SPELL_DETECT_ALIGN: af[0].duration = 12 + level; - af[0].bitvector = AFF_DETECT_ALIGN; + SET_BIT_AR(af[0].bitvector, AFF_DETECT_ALIGN); accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_DETECT_INVIS: af[0].duration = 12 + level; - af[0].bitvector = AFF_DETECT_INVIS; + SET_BIT_AR(af[0].bitvector, AFF_DETECT_INVIS); accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_DETECT_MAGIC: af[0].duration = 12 + level; - af[0].bitvector = AFF_DETECT_MAGIC; + SET_BIT_AR(af[0].bitvector, AFF_DETECT_MAGIC); accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_INFRAVISION: af[0].duration = 12 + level; - af[0].bitvector = AFF_INFRAVISION; + SET_BIT_AR(af[0].bitvector, AFF_INFRAVISION); accum_duration = TRUE; to_vict = "Your eyes glow red."; to_room = "$n's eyes glow red."; @@ -430,7 +428,7 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, af[0].duration = 12 + (GET_LEVEL(ch) / 4); af[0].modifier = -40; af[0].location = APPLY_AC; - af[0].bitvector = AFF_INVISIBLE; + SET_BIT_AR(af[0].bitvector, AFF_INVISIBLE); accum_duration = TRUE; to_vict = "You vanish."; to_room = "$n slowly fades out of existence."; @@ -445,21 +443,21 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, af[0].location = APPLY_STR; af[0].duration = GET_LEVEL(ch); af[0].modifier = -2; - af[0].bitvector = AFF_POISON; + SET_BIT_AR(af[0].bitvector, AFF_POISON); to_vict = "You feel very sick."; to_room = "$n gets violently ill!"; break; case SPELL_PROT_FROM_EVIL: af[0].duration = 24; - af[0].bitvector = AFF_PROTECT_EVIL; + SET_BIT_AR(af[0].bitvector, AFF_PROTECT_EVIL); accum_duration = TRUE; to_vict = "You feel invulnerable!"; break; case SPELL_SANCTUARY: af[0].duration = 4; - af[0].bitvector = AFF_SANCTUARY; + SET_BIT_AR(af[0].bitvector, AFF_SANCTUARY); accum_duration = TRUE; to_vict = "A white aura momentarily surrounds you."; @@ -475,7 +473,7 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, return; af[0].duration = 4 + (GET_LEVEL(ch) / 4); - af[0].bitvector = AFF_SLEEP; + SET_BIT_AR(af[0].bitvector, AFF_SLEEP); if (GET_POS(victim) > POS_SLEEPING) { send_to_char(victim, "You feel very sleepy... Zzzz......\r\n"); @@ -499,29 +497,33 @@ void mag_affects(int level, struct char_data *ch, struct char_data *victim, case SPELL_SENSE_LIFE: to_vict = "Your feel your awareness improve."; af[0].duration = GET_LEVEL(ch); - af[0].bitvector = AFF_SENSE_LIFE; + SET_BIT_AR(af[0].bitvector, AFF_SENSE_LIFE); accum_duration = TRUE; break; case SPELL_WATERWALK: af[0].duration = 24; - af[0].bitvector = AFF_WATERWALK; + SET_BIT_AR(af[0].bitvector, AFF_WATERWALK); accum_duration = TRUE; to_vict = "You feel webbing between your toes."; break; } - /* If this is a mob that has this affect set in its mob file, do not perform - * the affect. This prevents people from un-sancting mobs by sancting them + /* If this is a mob that has this affect set in its mob file, do not perform + * the affect. This prevents people from un-sancting mobs by sancting them * and waiting for it to fade, for example. */ - if (IS_NPC(victim) && !affected_by_spell(victim, spellnum)) - for (i = 0; i < MAX_SPELL_AFFECTS; i++) - if (AFF_FLAGGED(victim, af[i].bitvector) && (af[i].bitvector > 0)) { - send_to_char(ch, "%s", CONFIG_NOEFFECT); - return; + if (IS_NPC(victim) && !affected_by_spell(victim, spellnum)) { + for (i = 0; i < MAX_SPELL_AFFECTS; i++) { + for (j=0; jfield || !obj2->field || \ @@ -115,7 +115,7 @@ int objsave_save_obj_record(struct obj_data *obj, FILE *fp, int locate) fprintf(fp, "Cost: %d\n", GET_OBJ_COST(obj)); if (TEST_OBJN(cost_per_day)) fprintf(fp, "Rent: %d\n", GET_OBJ_RENT(obj)); - if (TEST_OBJN(bitvector)) + if (TEST_OBJN(bitvector)) fprintf(fp, "Perm: %d %d %d %d\n", GET_OBJ_PERM(obj)[0], GET_OBJ_PERM(obj)[1], GET_OBJ_PERM(obj)[2], GET_OBJ_PERM(obj)[3]); if (TEST_OBJN(wear_flags)) fprintf(fp, "Wear: %d %d %d %d\n", GET_OBJ_WEAR(obj)[0], GET_OBJ_WEAR(obj)[1], GET_OBJ_WEAR(obj)[2], GET_OBJ_WEAR(obj)[3]); @@ -241,7 +241,7 @@ static void auto_equip(struct char_data *ch, struct obj_data *obj, int location) if (location > 0) { /* Wearable. */ if (!GET_EQ(ch,j)) { - /* Check the characters's alignment to prevent them from being zapped + /* Check the characters's alignment to prevent them from being zapped * through the auto-equipping. */ if (invalid_align(ch, obj) || invalid_class(ch, obj)) location = LOC_INVENTORY; @@ -482,7 +482,7 @@ static void Crash_restore_weight(struct obj_data *obj) } } -/* Get !RENT items from equipment to inventory and extract !RENT out of worn +/* Get !RENT items from equipment to inventory and extract !RENT out of worn * containers. */ static void Crash_extract_norent_eq(struct char_data *ch) { @@ -975,7 +975,7 @@ void Crash_save_all(void) } /* Parses the object records stored in fl, and returns the first object in a - * linked list, which also handles location if worn. This list can then be + * linked list, which also handles location if worn. This list can then be * handled by house code, listrent code, autoeq code, etc. */ obj_save_data *objsave_parse_objects(FILE *fl) { @@ -1169,7 +1169,8 @@ static int Crash_load_objs(struct char_data *ch) { char line[READ_SIZE]; char buf[MAX_STRING_LENGTH]; char str[64]; - int i, num_of_days, orig_rent_code, cost, num_objs=0; + int i, num_of_days, orig_rent_code, num_objs=0; + unsigned long cost; struct obj_data *cont_row[MAX_BAG_ROWS]; int rentcode,timed,netcost,gold,account,nitems; obj_save_data *loaded, *current; @@ -1198,8 +1199,8 @@ static int Crash_load_objs(struct char_data *ch) { if (rentcode == RENT_RENTED || rentcode == RENT_TIMEDOUT) { sprintf(str, "%d", SECS_PER_REAL_DAY); num_of_days = (int)((float) (time(0) - timed) / (float)atoi(str)); - cost = (int) (netcost * num_of_days); - if (cost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) { + cost = (unsigned int) (netcost * num_of_days); + if (cost > (unsigned int)GET_GOLD(ch) + (unsigned int)GET_BANK_GOLD(ch)) { fclose(fl); mudlog(BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE, "%s entering game, rented equipment lost (no $).", GET_NAME(ch)); @@ -1271,15 +1272,15 @@ static int handle_obj(struct obj_data *temp, struct char_data *ch, int locate, s auto_equip(ch, temp, locate); /* What to do with a new loaded item: - * If there's a list with less than 1 below this: (equipped items - * are assumed to have ==0 here) then its container has disappeared - * from the file *gasp* -> put all the list back to ch's inventory if - * there's a list of contents with 1 below this: check if it's a - * container - if so: get it from ch, fill it, and give it back to ch (this - * way the container has its correct weight before modifying ch) - if not: - * the container is missing -> put all the list to ch's inventory. For items - * with negative : If there's already a list of contents with the - * same put obj to it if not, start a new list. Since for + * If there's a list with less than 1 below this: (equipped items + * are assumed to have ==0 here) then its container has disappeared + * from the file *gasp* -> put all the list back to ch's inventory if + * there's a list of contents with 1 below this: check if it's a + * container - if so: get it from ch, fill it, and give it back to ch (this + * way the container has its correct weight before modifying ch) - if not: + * the container is missing -> put all the list to ch's inventory. For items + * with negative : If there's already a list of contents with the + * same put obj to it if not, start a new list. Since for * contents is < 0 the list indices are switched to non-negative. */ if (locate > 0) { /* item equipped */ diff --git a/src/players.c b/src/players.c index 10152ef..246a6e0 100644 --- a/src/players.c +++ b/src/players.c @@ -504,7 +504,7 @@ void save_char(struct char_data * ch) { FILE *fl; char filename[40], buf[MAX_STRING_LENGTH], bits[127], bits2[127], bits3[127], bits4[127]; - int i, id, save_index = FALSE; + int i, j, id, save_index = FALSE; struct affected_type *aff, tmp_aff[MAX_AFFECT]; struct obj_data *char_eq[NUM_WEARS]; trig_data *t; @@ -552,14 +552,12 @@ void save_char(struct char_data * ch) for (aff = ch->affected, i = 0; i < MAX_AFFECT; i++) { if (aff) { tmp_aff[i] = *aff; + for (j=0; jbitvector[j]; tmp_aff[i].next = 0; aff = aff->next; } else { - tmp_aff[i].type = 0; /* Zero signifies not used */ - tmp_aff[i].duration = 0; - tmp_aff[i].modifier = 0; - tmp_aff[i].location = 0; - tmp_aff[i].bitvector = 0; + new_affect(&(tmp_aff[i])); tmp_aff[i].next = 0; } } @@ -695,10 +693,10 @@ void save_char(struct char_data * ch) for (i = 0; i < MAX_AFFECT; i++) { aff = &tmp_aff[i]; if (aff->type) - fprintf(fl, "%d %d %d %d %d\n", aff->type, aff->duration, - aff->modifier, aff->location, (int)aff->bitvector); + fprintf(fl, "%d %d %d %d %d %d %d %d\n", aff->type, aff->duration, + aff->modifier, aff->location, aff->bitvector[0], aff->bitvector[1], aff->bitvector[2], aff->bitvector[3]); } - fprintf(fl, "0 0 0 0 0\n"); + fprintf(fl, "0 0 0 0 0 0 0 0\n"); } write_aliases_ascii(fl, ch); @@ -835,22 +833,35 @@ void clean_pfiles(void) * entries of the players that were just deleted. */ } +/* load_affects function now handles both 32-bit and + 128-bit affect bitvectors for backward compatibility */ static void load_affects(FILE *fl, struct char_data *ch) { - int num = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, i; + int num = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, num6 = 0, num7 = 0, num8 = 0, i, n_vars; char line[MAX_INPUT_LENGTH + 1]; struct affected_type af; i = 0; do { + new_affect(&af); get_line(fl, line); - sscanf(line, "%d %d %d %d %d", &num, &num2, &num3, &num4, &num5); + n_vars = sscanf(line, "%d %d %d %d %d %d %d %d", &num, &num2, &num3, &num4, &num5, &num6, &num7, &num8); if (num > 0) { af.type = num; af.duration = num2; af.modifier = num3; af.location = num4; - af.bitvector = num5; + if (n_vars == 8) { /* New 128-bit version */ + af.bitvector[0] = num5; + af.bitvector[1] = num6; + af.bitvector[2] = num7; + af.bitvector[3] = num8; + } else if (n_vars == 5) { /* Old 32-bit conversion version */ + if (num5 > 0 && num5 <= NUM_AFF_FLAGS) /* Ignore invalid values */ + SET_BIT_AR(af.bitvector, num5); + } else { + log("SYSERR: Invalid affects in pfile (%s), expecting 5 or 8 values", GET_NAME(ch)); + } affect_to_char(ch, &af); i++; } diff --git a/src/spells.c b/src/spells.c index 87e6c82..2d2b5bd 100644 --- a/src/spells.c +++ b/src/spells.c @@ -277,15 +277,14 @@ ASPELL(spell_charm) add_follower(victim, ch); + new_affect(&af); af.type = SPELL_CHARM; af.duration = 24 * 2; if (GET_CHA(ch)) af.duration *= GET_CHA(ch); if (GET_INT(victim)) af.duration /= GET_INT(victim); - af.modifier = 0; - af.location = 0; - af.bitvector = AFF_CHARM; + SET_BIT_AR(af.bitvector, AFF_CHARM); affect_to_char(victim, &af); act("Isn't $n just such a nice fellow?", FALSE, ch, 0, victim, TO_VICT); diff --git a/src/structs.h b/src/structs.h index ab1d182..ea58ac9 100644 --- a/src/structs.h +++ b/src/structs.h @@ -219,7 +219,7 @@ #define MOB_NOKILL 18 /**< Mob can't be attacked */ #define MOB_NOTDEADYET 19 /**< (R) Mob being extracted */ -#define NUM_MOB_FLAGS 19 +#define NUM_MOB_FLAGS 19 /* Preference flags: used by char_data.player_specials.pref */ #define PRF_BRIEF 0 /**< Room descs won't normally be shown */ @@ -576,7 +576,6 @@ /** Controls when to save the current ingame MUD time to disk. * This should be set >= SECS_PER_MUD_HOUR */ #define PULSE_TIMESAVE (30 * 60 RL_SEC) - /* Variables for the output buffering system */ #define MAX_SOCK_BUF (24 * 1024) /**< Size of kernel's sock buf */ #define MAX_PROMPT_LENGTH 96 /**< Max length of prompt */ @@ -973,7 +972,7 @@ struct affected_type sh_int duration; /**< For how long its effects will last */ sbyte modifier; /**< Added/subtracted to/from apropriate ability */ byte location; /**< Tells which ability to change(APPLY_XXX). */ - long /*bitvector_t*/bitvector; /**< Tells which bits to set (AFF_XXX). */ + int bitvector[AF_ARRAY_MAX]; /**< Tells which bits to set (AFF_XXX). */ struct affected_type *next; /**< The next affect in the list of affects. */ }; diff --git a/src/utils.c b/src/utils.c index 5b138e4..9e449fe 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1459,3 +1459,15 @@ char *strpaste(char *str1, char *str2, char *joiner) *rp = '\0'; return ret; } + +/* Create a blank affect struct */ +void new_affect(struct affected_type *af) +{ + int i; + af->type = 0; + af->duration = 0; + af->modifier = 0; + af->location = APPLY_NONE; + for (i=0; ibitvector[i]=0; +} + diff --git a/src/utils.h b/src/utils.h index 7393372..564003c 100644 --- a/src/utils.h +++ b/src/utils.h @@ -66,6 +66,7 @@ int file_numlines( FILE *file ); IDXTYPE atoidx( const char *str_to_conv ); char *strfrmt(char *str, int w, int h, int justify, int hpad, int vpad); char *strpaste(char *str1, char *str2, char *joiner); +void new_affect(struct affected_type *af); /* Public functions made available form weather.c */ void weather_and_time(int mode);