From 54d24d0333057d88265bf7e15ad00d3cffe2ebf6 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 8 Jun 2019 23:19:29 -0400 Subject: [PATCH] make display effect code reusable and move it to display.c --- include/extern.h | 1 + src/display.c | 22 ++++++++++++++++++++++ src/read.c | 18 +++++------------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/include/extern.h b/include/extern.h index 072fe60ac..a911b6750 100644 --- a/include/extern.h +++ b/include/extern.h @@ -360,6 +360,7 @@ E void FDECL(newsym, (int, int)); E void FDECL(newsym_force, (int, int)); E void FDECL(shieldeff, (XCHAR_P, XCHAR_P)); E void FDECL(tmp_at, (int, int)); +E void FDECL(flash_glyph_at, (int, int, int)); E void FDECL(swallowed, (int)); E void FDECL(under_ground, (int)); E void FDECL(under_water, (int)); diff --git a/src/display.c b/src/display.c index c5b155bd6..1ef7a26d5 100644 --- a/src/display.c +++ b/src/display.c @@ -1067,6 +1067,28 @@ int x, y; } /* end case */ } +/* + * flash_glyph_at(x, y, glyph) + * + * Briefly flash between the passed glyph and the glyph that's + * meant to be at the location. + */ +void +flash_glyph_at(x, y, tg) +int x, y, tg; +{ + int i, glyph[2]; + + glyph[0] = tg; + glyph[1] = glyph_at(x, y); + for (i = 0; i < 15; i++) { + show_glyph(x, y, glyph[i % 2]); + flush_screen(1); + delay_output(); + } + newsym(x, y); +} + /* * swallowed() * diff --git a/src/read.c b/src/read.c index baf82d641..97678dba2 100644 --- a/src/read.c +++ b/src/read.c @@ -2579,21 +2579,13 @@ struct _create_particular_data *d; if (d->sleeping) mtmp->msleeping = 1; if (d->hidden && is_hider(mtmp->data)) { - if (wizard && cansee(mtmp->mx, mtmp->my)) { - int i, glyph[2]; + int saveglyph = glyph_at(mtmp->mx, mtmp->my); - glyph[0] = glyph_at(mtmp->mx, mtmp->my); - mtmp->mundetected = 1; - newsym(mtmp->mx, mtmp->my); - glyph[1] = glyph_at(mtmp->mx, mtmp->my); - if (!canseemon(mtmp) && !sensemon(mtmp)) - for (i = 0; i < 15; i++) { - show_glyph(mtmp->mx, mtmp->my, glyph[i % 2]); - flush_screen(1); - delay_output(); - } - } + mtmp->mundetected = 1; newsym(mtmp->mx, mtmp->my); + if (wizard && cansee(mtmp->mx, mtmp->my)) + if (!canseemon(mtmp) && !sensemon(mtmp)) + flash_glyph_at(mtmp->mx, mtmp->my, saveglyph); } madeany = TRUE; /* in case we got a doppelganger instead of what was asked -- 2.40.0