diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-06-07 01:44:53 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-06-07 01:46:11 -0300 |
| commit | bd145c3ebfc082286486a8700b9ce20bfd7383e2 (patch) | |
| tree | 754b5c8bb1d5fb209e30dc78f698fc835ddf8cdb /src/containers.hh | |
| parent | 76f6ecb7c809c6e93447efb91bdf50f2a9d50d6b (diff) | |
| download | game-bd145c3ebfc082286486a8700b9ce20bfd7383e2.tar.gz game-bd145c3ebfc082286486a8700b9ce20bfd7383e2.zip | |
implement TFindCreatures and KillStatistics
Diffstat (limited to 'src/containers.hh')
| -rw-r--r-- | src/containers.hh | 11 |
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; |
