mirror of
https://github.com/tbamud/tbamud.git
synced 2026-02-20 10:31:45 +01:00
GitHub issues 78 79 81 num aff flags off by one (#82)
* Make sure all followers are free'd before freeing the character list Otherwise, the followers structs will point to free'd memory and the stop_follower call will attempt to dereference a free'd characters' followers list. * https://github.com/tbamud/tbamud/issues/79 typo * https://github.com/tbamud/tbamud/issues/81 nullpointer crash on syntax check run * NUM_AFF_FLAGS fix. Now, consistently, the NUM_AFF_FLAGS is used in the same way as other NUM_* variables. Specifically, the the number is consistent with how others are defined - 1 above the highest in the list. I would like to have removed the need to start from 1 instead of 0 as well, but the loading mechanism, and thus potentially a lot of existing object files, use 0 as a marker for "no flags set", and we can't easily fix that. So, the places we loop through the list, we still need to make sure we're stying within the [1;NUM_AFF_FLAGS) interval. Simultaneously, I've checked over the other flags, and it seems like the usage is pretty consistent there. Fixes https://github.com/tbamud/tbamud/issues/78
This commit is contained in:
14
src/medit.c
14
src/medit.c
@@ -396,8 +396,8 @@ static void medit_disp_aff_flags(struct descriptor_data *d)
|
||||
|
||||
get_char_colors(d->character);
|
||||
clear_screen(d);
|
||||
/* +1 since AFF_FLAGS don't start at 0. */
|
||||
column_list(d->character, 0, affected_bits + 1, NUM_AFF_FLAGS, TRUE);
|
||||
/* +1/-1 antics needed because AFF_FLAGS doesn't start at 0. */
|
||||
column_list(d->character, 0, affected_bits + 1, NUM_AFF_FLAGS - 1, TRUE);
|
||||
sprintbitarray(AFF_FLAGS(OLC_MOB(d)), affected_bits, AF_ARRAY_MAX, flags);
|
||||
write_to_output(d, "\r\nCurrent flags : %s%s%s\r\nEnter aff flags (0 to quit) : ",
|
||||
cyn, flags, nrm);
|
||||
@@ -577,8 +577,8 @@ void medit_parse(struct descriptor_data *d, char *arg)
|
||||
case 'q':
|
||||
case 'Q':
|
||||
if (OLC_VAL(d)) { /* Anything been changed? */
|
||||
write_to_output(d, "Do you wish to save your changes? : ");
|
||||
OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING;
|
||||
write_to_output(d, "Do you wish to save your changes? : ");
|
||||
OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING;
|
||||
} else
|
||||
cleanup_olc(d, CLEANUP_ALL);
|
||||
return;
|
||||
@@ -603,8 +603,8 @@ void medit_parse(struct descriptor_data *d, char *arg)
|
||||
send_editor_help(d);
|
||||
write_to_output(d, "Enter mob description:\r\n\r\n");
|
||||
if (OLC_MOB(d)->player.description) {
|
||||
write_to_output(d, "%s", OLC_MOB(d)->player.description);
|
||||
oldtext = strdup(OLC_MOB(d)->player.description);
|
||||
write_to_output(d, "%s", OLC_MOB(d)->player.description);
|
||||
oldtext = strdup(OLC_MOB(d)->player.description);
|
||||
}
|
||||
string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext);
|
||||
OLC_VAL(d) = 1;
|
||||
@@ -898,7 +898,7 @@ void medit_parse(struct descriptor_data *d, char *arg)
|
||||
case MEDIT_AFF_FLAGS:
|
||||
if ((i = atoi(arg)) <= 0)
|
||||
break;
|
||||
else if (i <= NUM_AFF_FLAGS)
|
||||
else if (i < NUM_AFF_FLAGS)
|
||||
TOGGLE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), i);
|
||||
|
||||
/* Remove unwanted bits right away. */
|
||||
|
||||
Reference in New Issue
Block a user