diff --git a/src/monster.c b/src/monster.c index 6cc416f..90cab32 100644 --- a/src/monster.c +++ b/src/monster.c @@ -128,7 +128,12 @@ damage_surroundings(Monster *m, RoomMatrix *rm) for (Sint32 j = -1; j <= 1; ++j) { if (i == 0 && j == 0) continue; - RoomSpace *r = &rm->spaces[roomPos.x + i][roomPos.y + j]; + + Position matrixPos = POS(roomPos.x + i, roomPos.y + j); + if (!position_in_roommatrix(&matrixPos)) + continue; + + RoomSpace *r = &rm->spaces[matrixPos.x][matrixPos.y]; if (r->monster) { int dmg = stats_fight(&m->stats, &r->monster->stats); monster_hit(r->monster, dmg); diff --git a/src/skill.c b/src/skill.c index e1d012e..6923b0e 100644 --- a/src/skill.c +++ b/src/skill.c @@ -879,7 +879,11 @@ skill_erupt(Skill *skill, SkillData *data) if (i == 0 && j == 0) continue; - RoomSpace *r = &rm->spaces[playerMPos.x + i][playerMPos.y + j]; + Position matrixPos = POS(playerMPos.x + i, playerMPos.y + j); + if (!position_in_roommatrix(&matrixPos)) + continue; + + RoomSpace *r = &rm->spaces[matrixPos.x][matrixPos.y]; if (r->monster) { player->stats.advantage = true; int dmg = stats_fight(&player->stats, &r->monster->stats);