@@ -136,6 +136,11 @@ void movemon(void) {
136136 if (mtmp -> mspeed == MFAST && dochugw (mtmp ))
137137 continue ;
138138 }
139+ /* IMPORTANT NOTE: when enabling the modern code below (bounds check) it
140+ allows a warning message to appear without a ring of warning indicating a
141+ possible default mechanic that has been silienced since v1.0 and carried
142+ over. I will continue
143+ to investigate and decide on the approptiate course of action.*/
139144 /* IMPORTANT NOTE: when enabling the modern code below (bounds check) it
140145 allows a warning message to appear without a ring of warning indicating a
141146 possible default mechanic that has been silienced since v1.0 and carried
@@ -152,6 +157,11 @@ void movemon(void) {
152157 // int display_level = (warnlevel < 0) ? 0 : warnlevel;
153158 // if (warnlevel < 0) /* MODERN: prevent negative array index */
154159 // warnlevel = 0;
160+ /* MODERN: Defensive bounds check for array access while preserving game
161+ * logic */
162+ // int display_level = (warnlevel < 0) ? 0 : warnlevel;
163+ // if (warnlevel < 0) /* MODERN: prevent negative array index */
164+ // warnlevel = 0;
155165 switch (Warning & (LEFT_RING | RIGHT_RING )) {
156166 case LEFT_RING :
157167 rr = "Your left ring glows" ;
@@ -363,7 +373,8 @@ int m_move(struct monst *mtmp, int after) {
363373 goto postmov ;
364374 }
365375
366- /* spit fire ('D') or use a wand ('1') when appropriate */
376+ /* spit fire ('D') or use a wand ('1') when appropriate
377+ */
367378 if (index ("D1" , msym ))
368379 inrange (mtmp );
369380
@@ -533,7 +544,8 @@ void mpickgold(struct monst *mtmp) {
533544 mtmp -> mgold += gold -> amount ;
534545 freegold (gold );
535546 if (levl [(int )mtmp -> mx ][(int )mtmp -> my ].scrsym == '$' )
536- newsym (mtmp -> mx , mtmp -> my );
547+ if (levl [(int )mtmp -> mx ][(int )mtmp -> my ].scrsym == '$' )
548+ newsym (mtmp -> mx , mtmp -> my );
537549 }
538550}
539551
@@ -546,8 +558,9 @@ void mpickgems(struct monst *mtmp) {
546558 freeobj (otmp );
547559 mpickobj (mtmp , otmp );
548560 if (levl [(int )mtmp -> mx ][(int )mtmp -> my ].scrsym == GEM_SYM )
549- newsym (mtmp -> mx , mtmp -> my ); /* %% */
550- return ; /* pick only one object */
561+ if (levl [(int )mtmp -> mx ][(int )mtmp -> my ].scrsym == GEM_SYM )
562+ newsym (mtmp -> mx , mtmp -> my ); /* %% */
563+ return ; /* pick only one object */
551564 }
552565}
553566
0 commit comments