From bd145c3ebfc082286486a8700b9ce20bfd7383e2 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sat, 7 Jun 2025 01:44:53 -0300 Subject: implement TFindCreatures and KillStatistics --- src/containers.hh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/containers.hh') diff --git a/src/containers.hh b/src/containers.hh index fafe5b7..ba7e3cd 100644 --- a/src/containers.hh +++ b/src/containers.hh @@ -239,6 +239,17 @@ struct matrix{ delete[] this->entry; } + // NOTE(fusion): Same as `at` but returns NULL on out of bounds coordinates. + T *boundedAt(int x, int y){ + int xoffset = x - this->xmin; + int yoffset = y - this->ymin; + if(xoffset < 0 || xoffset >= this->dx || yoffset < 0 || yoffset >= this->dy){ + return NULL; + }else{ + return &this->entry[yoffset * this->dx + xoffset]; + } + } + T *at(int x, int y){ int xoffset = x - this->xmin; int yoffset = y - this->ymin; -- cgit v1.2.3