diff options
Diffstat (limited to 'crawl-ref/source/externs.h')
-rw-r--r-- | crawl-ref/source/externs.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 5f4f5e7e40..1c3a962d5d 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -92,6 +92,11 @@ class KillMaster; class ghost_demon; struct glyph; +template <typename Z> inline Z sgn(Z x) +{ + return (x < 0 ? -1 : (x > 0 ? 1 : 0)); +} + struct coord_def { int x; @@ -215,6 +220,11 @@ struct coord_def return (copy *= mul); } + coord_def sgn() const + { + return coord_def(::sgn(x), ::sgn(y)); + } + int abs() const { return (x * x + y * y); |