fix issue #337 - crash on start with armhf arch

Fix "objects[0] class #1 not in order!" panic.  The new check to
make sure that the elements of objects[] were in ascending order
by object class uses a plain 'char' index so -1 to indicate 'no
previous value' didn't work on a system using unsigned chars.

Verfied by temporarily adding '-funsigned-char' to CFLAGS before
and after the revision.  Before: panic, after: no panic.

Fixes #337
This commit is contained in:
PatR
2020-04-23 11:47:29 -07:00
parent 33cb2142e6
commit 3468129f5a
2 changed files with 5 additions and 4 deletions

View File

@@ -108,8 +108,8 @@ boolean domaterial;
void
init_objects()
{
int i, first, last, sum;
char oclass, prevoclass;
int i, first, last, sum, prevoclass;
char oclass;
#ifdef TEXTCOLOR
#define COPY_OBJ_DESCR(o_dst, o_src) \
o_dst.oc_descr_idx = o_src.oc_descr_idx, o_dst.oc_color = o_src.oc_color
@@ -138,7 +138,7 @@ init_objects()
* earlier class would involve switching back to a lower class
* number after having moved on to one or more other classes.
*/
if (oclass < prevoclass)
if ((int) oclass < prevoclass)
panic("objects[%d] class #%d not in order!", first, oclass);
last = first + 1;
@@ -181,7 +181,7 @@ init_objects()
if (sum != 1000)
error("init-prob error for class %d (%d%%)", oclass, sum);
first = last;
prevoclass = oclass;
prevoclass = (int) oclass;
}
/* extra entry allows deriving the range of a class via
bases[class] through bases[class+1]-1 for all classes */