aboutsummaryrefslogtreecommitdiff
path: root/src/containers.hh
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-06-07 01:44:53 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-06-07 01:46:11 -0300
commitbd145c3ebfc082286486a8700b9ce20bfd7383e2 (patch)
tree754b5c8bb1d5fb209e30dc78f698fc835ddf8cdb /src/containers.hh
parent76f6ecb7c809c6e93447efb91bdf50f2a9d50d6b (diff)
downloadgame-bd145c3ebfc082286486a8700b9ce20bfd7383e2.tar.gz
game-bd145c3ebfc082286486a8700b9ce20bfd7383e2.zip
implement TFindCreatures and KillStatistics
Diffstat (limited to 'src/containers.hh')
-rw-r--r--src/containers.hh11
1 files changed, 11 insertions, 0 deletions
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;