diff --git a/config/fxdata/creature.cfg b/config/fxdata/creature.cfg index 5b04800cee..a29cebb90d 100644 --- a/config/fxdata/creature.cfg +++ b/config/fxdata/creature.cfg @@ -70,10 +70,8 @@ RangeMax = 0 ; 3,4 will only target other players, 5,6 only own player. ; 7 will target traps. PrimaryTarget = 0 -; Instance used by creature "going postal" while working in a room -; Creature will only use available instances with the highest priority, -; If multiple instances have the same PostalPriority, one is chosen randomly -; 0 disables the instance for beeing used while "going postal". +; Instance used when the creature is 'going postal' in a room. It will use the instance with the highest priority. +; If multiple have the same priority, one is chosen randomly. 0 disables the instance. PostalPriority = 0 ; Instance properties flags: ; REPEAT_TRIGGER allows player to hold down the mouse button to cast. diff --git a/src/thing_creature.c b/src/thing_creature.c index 55ecedce15..2bcd449006 100644 --- a/src/thing_creature.c +++ b/src/thing_creature.c @@ -375,35 +375,45 @@ void draw_swipe_graphic(void) if (thing_is_creature(thing)) { struct CreatureControl* cctrl = creature_control_get_from_thing(thing); - if (instance_draws_possession_swipe(cctrl->instance_id)) + if ((instance_draws_possession_swipe(cctrl->instance_id)) && (cctrl->inst_total_turns > 0)) { lbDisplay.DrawFlags = Lb_SPRITE_TRANSPAR4; long n = (int)cctrl->inst_turn * (5 << 8) / cctrl->inst_total_turns; long allwidth = 0; long i = (abs(n) >> 8) -1; if (i >= SWIPE_SPRITE_FRAMES) + { i = SWIPE_SPRITE_FRAMES-1; - // FIXME: sprites may not be adjacent in the future, causing code below incorrect sprites and possibly crash + } + // FIXME: sprites may not be adjacent in the future, causing code below incorrect sprites and possibly crash. const struct TbSprite* sprlist = get_sprite(swipe_sprites, SWIPE_SPRITES_X * SWIPE_SPRITES_Y * i); const struct TbSprite* startspr = &sprlist[1]; const struct TbSprite* endspr = &sprlist[1]; - for (n=0; n < SWIPE_SPRITES_X; n++) + for (n = 0; n < SWIPE_SPRITES_X; n++) { allwidth += endspr->SWidth; endspr++; } + if (allwidth == 0) + { + return; // No point trying to draw a zero-width sprite. + } int units_per_px = (LbScreenWidth() * 59 / 64) * 16 / allwidth; + if (units_per_px == 0) + { + return; + } int scrpos_y = (MyScreenHeight * 16 / units_per_px - (startspr->SHeight + endspr->SHeight)) / 2; const struct TbSprite *spr; int scrpos_x; if (myplyr->swipe_sprite_drawLR) { int delta_y = sprlist[1].SHeight; - for (i=0; i < SWIPE_SPRITES_X*SWIPE_SPRITES_Y; i+=SWIPE_SPRITES_X) + for (i = 0; i < SWIPE_SPRITES_X*SWIPE_SPRITES_Y; i += SWIPE_SPRITES_X) { spr = &startspr[i]; scrpos_x = (MyScreenWidth * 16 / units_per_px - allwidth) / 2; - for (n=0; n < SWIPE_SPRITES_X; n++) + for (n = 0; n < SWIPE_SPRITES_X; n++) { LbSpriteDrawResized(scrpos_x * units_per_px / 16, scrpos_y * units_per_px / 16, units_per_px, spr); scrpos_x += spr->SWidth; @@ -411,15 +421,16 @@ void draw_swipe_graphic(void) } scrpos_y += delta_y; } - } else + } + else { lbDisplay.DrawFlags = Lb_SPRITE_TRANSPAR4 | Lb_SPRITE_FLIP_HORIZ; - for (i=0; i < SWIPE_SPRITES_X*SWIPE_SPRITES_Y; i+=SWIPE_SPRITES_X) + for (i = 0; i < SWIPE_SPRITES_X*SWIPE_SPRITES_Y; i += SWIPE_SPRITES_X) { spr = &sprlist[SWIPE_SPRITES_X+i]; int delta_y = spr->SHeight; scrpos_x = (MyScreenWidth * 16 / units_per_px - allwidth) / 2; - for (n=0; n < SWIPE_SPRITES_X; n++) + for (n = 0; n < SWIPE_SPRITES_X; n++) { LbSpriteDrawResized(scrpos_x * units_per_px / 16, scrpos_y * units_per_px / 16, units_per_px, spr); scrpos_x += spr->SWidth; @@ -432,7 +443,7 @@ void draw_swipe_graphic(void) return; } } - // we get here many times a second when in possession mode and not attacking: to randomise the swipe direction + // We get here many times a second when in possession mode and not attacking: to randomise the swipe direction. randomise_swipe_graphic_direction(); }