Skip to content

Commit

Permalink
Change rogue's string handling a bit to try and avoid the out-of-boun…
Browse files Browse the repository at this point in the history
…ds errors that crop up after level 3
  • Loading branch information
ctdk committed Jul 10, 2013
1 parent 6c4c16f commit 4f1ed23
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions rogue/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ player_init(void)
obj = alloc_object(); /* initial weapons */
obj->what_is = WEAPON;
obj->which_kind = MACE;
obj->damage = "2d3";
strcpy(obj->damage, "2d3");
obj->hit_enchant = obj->d_enchant = 1;
obj->identified = 1;
add_to_pack(obj, &rogue.pack, 1);
Expand All @@ -156,7 +156,7 @@ player_init(void)
obj = alloc_object();
obj->what_is = WEAPON;
obj->which_kind = BOW;
obj->damage = "1d2";
strcpy(obj->damage, "1d2");
obj->hit_enchant = 1;
obj->d_enchant = 0;
obj->identified = 1;
Expand All @@ -166,7 +166,7 @@ player_init(void)
obj->what_is = WEAPON;
obj->which_kind = ARROW;
obj->quantity = get_rand(25, 35);
obj->damage = "1d2";
strcpy(obj->damage, "1d2");
obj->hit_enchant = 0;
obj->d_enchant = 0;
obj->identified = 1;
Expand Down
16 changes: 8 additions & 8 deletions rogue/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,25 +526,25 @@ gr_weapon(object *obj, int assign_wk)
switch(obj->which_kind) {
case BOW:
case DART:
obj->damage = "1d1";
strcpy(obj->damage, "1d1");
break;
case ARROW:
obj->damage = "1d2";
strcpy(obj->damage, "1d2");
break;
case DAGGER:
obj->damage = "1d3";
strcpy(obj->damage, "1d3");
break;
case SHURIKEN:
obj->damage = "1d4";
strcpy(obj->damage, "1d4");
break;
case MACE:
obj->damage = "2d3";
strcpy(obj->damage, "2d3");
break;
case LONG_SWORD:
obj->damage = "3d4";
strcpy(obj->damage, "3d4");
break;
case TWO_HANDED_SWORD:
obj->damage = "4d5";
strcpy(obj->damage, "4d5");
break;
}
}
Expand Down Expand Up @@ -630,7 +630,7 @@ alloc_object(void)
obj->picked_up = obj->is_cursed = 0;
obj->in_use_flags = NOT_USED;
obj->identified = UNIDENTIFIED;
obj->damage = "1d1";
strcpy(obj->damage, "1d1");
return(obj);
}

Expand Down
2 changes: 1 addition & 1 deletion rogue/rogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ struct id {

struct obj { /* comment is monster meaning */
unsigned long m_flags; /* monster flags */
const char *damage; /* damage it does */
char damage[8]; /* damage it does */
short quantity; /* hit points to kill */
short ichar; /* 'A' is for aquatar */
short kill_exp; /* exp for killing it */
Expand Down

0 comments on commit 4f1ed23

Please sign in to comment.