Opened 15 months ago

Closed 3 months ago

#1973 closed bug (fixed (in master))

coding arithmetic errors

Reported by: nckmccnnll Owned by:
Milestone: 4.1 Keywords:


Reported by t4nk074 on IRC:
"so i was reading gen-room.c (4.0.5 release)
the function room_build has this (lines 3002 and 3003)
x = ((bx1 + bx2 + 1) * dun->block_hgt) / 2;
(same for y-coordinate) why does it add 1 to bx1 + bx2? that doesn't look right to me... sorry if i'm missing something
for example, given the block 0, 0 (northwestern-most) and "simple" room (33x11 tiles), it will calculate its center (x-coordinate) as (0 + 3 + 1) * 11 / 2 which is 22... i'd expect the center to be at 16?
and vertical center will be at 11 ((0 + 1 + 1) * 11 / 2) instead of 5... is that correct?"

"line 121 of effects.c calculates effect damage, boosted by skill:
final *= (100 + context->boost) / 100;
context->boost is an int and calculated as follows: (line 546 of cmd-obj.c):
boost = MAX(player->state.skills[SKILL_DEVICE] - level, 0);
judging by ui-player.c (lines 791-792), state.skills[SKILL_DEVICE] is what is displayed on the char screen
a newborn gnome mage has 62 device skill
a wand of magic missile is a level 3 object
how is that possible that a gnome mage has 59% boost (as the game says) when
(100 + 59) / 100 equals 1? (integer arithmetic)
does anyone actually get a boost (that is less than 100%)?"

Change History (2)

comment:1 Changed 3 months ago by nckmccnnll

Second bit was corrected in 160f1a43a

comment:2 Changed 3 months ago by nckmccnnll

  • Resolution set to fixed (in master)
  • Status changed from new to closed

The point of the +1's in the first part is to offset everything half a block away from the edges. So although technically there are 6x18 dungeon blocks, this effectively reduces the usable dungeon space to 5x17 blocks, with a half-block barrier between the actual level edges and anywhere where there might be actual rooms. This is probably unnecessary, but so is changing it - after all, there are plenty of dungeon generation changes already for 4.1.

Note: See TracTickets for help on using tickets.