Fixes #58 - Game crash with AOE attacks

This commit is contained in:
Linus Probert 2019-05-14 08:33:05 +02:00
parent ef5cd4e244
commit 43ca8f4560
2 changed files with 11 additions and 2 deletions

View File

@ -128,7 +128,12 @@ damage_surroundings(Monster *m, RoomMatrix *rm)
for (Sint32 j = -1; j <= 1; ++j) { for (Sint32 j = -1; j <= 1; ++j) {
if (i == 0 && j == 0) if (i == 0 && j == 0)
continue; 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) { if (r->monster) {
int dmg = stats_fight(&m->stats, &r->monster->stats); int dmg = stats_fight(&m->stats, &r->monster->stats);
monster_hit(r->monster, dmg); monster_hit(r->monster, dmg);

View File

@ -879,7 +879,11 @@ skill_erupt(Skill *skill, SkillData *data)
if (i == 0 && j == 0) if (i == 0 && j == 0)
continue; 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) { if (r->monster) {
player->stats.advantage = true; player->stats.advantage = true;
int dmg = stats_fight(&player->stats, &r->monster->stats); int dmg = stats_fight(&player->stats, &r->monster->stats);