<commit_before>#include "fov_algorithm.h"
#include "entity.h"
#include "collider_component.h"
#include "description_component.h"
#include <iostream>

void FovAlgorithm::calculateFov ()
{
    EntityId player = m_engine->getEntities()->getPlayer();
    Location playerLoc = m_engine->getEntities()->getLocation (player);

    if (player == 0) return;

    m_engine->getMap()->getTile (playerLoc).lastVisited = m_engine->getTurn();

    int x = 0;
    int y = 0;
    unsigned int sightMax = 10;
    for (unsigned int oct = 0; oct < 8; oct++) {
        ShadowLine line;
        bool fullShadow = false;
        for (unsigned int row = 1; row < sightMax; row++) {
            for (unsigned int col = 0; col <= row; col++) {
                bool visible = false;
                Shadow projection (0,0);
                if (!fullShadow) {
                    projection = projectTile (row, col);
                    visible = !line.isInShadow (projection);
                }
                transformOctant (row, col, oct, y, x);
                y += playerLoc.y;
                x += playerLoc.x;
                if (m_engine->getMap()->isValidTile (x, y, playerLoc.z) && visible) {
                    m_engine->getMap()->getTile (x, y, playerLoc.z).lastVisited = m_engine->getTurn();
                    for (EntityId entity : m_engine->getMap()->getTile (x, y, m_engine->getLevel()).entities) {
                        if (m_engine->getComponents()->get<ColliderComponent>(entity)) {
                            line.addShadow (projection);
                            fullShadow = line.isInFullShadow();
                            break;
                        }
                    }
                }
            }
        }
    }



}

void FovAlgorithm::transformOctant (unsigned int row, unsigned int col, unsigned int octant, int& outY, int& outX)
{
    if (octant == 0) {
        outX = col;
        outY = -row;
    }
    if (octant == 1) {
        outX = row;
        outY = -col;
    }
    if (octant == 2) {
        outX = row;
        outY = col;
    }
    if (octant == 3) {<commit_msg>Fixed FOV error<commit_after>#include "fov_algorithm.h"
#include "entity.h"
#include "collider_component.h"
#include "description_component.h"
#include <iostream>

void FovAlgorithm::calculateFov ()
{
    EntityId player = m_engine->getEntities()->getPlayer();
    Location playerLoc = m_engine->getEntities()->getLocation (player);

    if (player == 0) return;

    m_engine->getMap()->getTile (playerLoc).lastVisited = m_engine->getTurn();

    int x = 0;
    int y = 0;
    unsigned int sightMax = 10;
    for (unsigned int oct = 0; oct < 8; oct++) {
        ShadowLine line;
        bool fullShadow = false;
        for (unsigned int row = 1; row < sightMax; row++) {
            for (unsigned int col = 0; col <= row; col++) {
                bool visible = false;
                Shadow projection (0,0);
                if (!fullShadow) {
                    projection = projectTile (row, col);
                    visible = !line.isInShadow (projection);
                }
                transformOctant (row, col, oct, y, x);
                y += playerLoc.y;
                x += playerLoc.x;
                if (m_engine->getMap()->isValidTile (x, y, playerLoc.z) && visible) {
                    m_engine->getMap()->getTile (x, y, playerLoc.z).lastVisited = m_engine->getTurn();
                    for (EntityId entity : m_engine->getMap()->getTile (x, y, playerLoc.z).entities) {
                        if (m_engine->getComponents()->get<ColliderComponent>(entity)) {
                            line.addShadow (projection);
                            fullShadow = line.isInFullShadow();
                            break;
                        }
                    }
                }
            }
        }
    }



}

void FovAlgorithm::transformOctant (unsigned int row, unsigned int col, unsigned int octant, int& outY, int& outX)
{
    if (octant == 0) {
        outX = col;
        outY = -row;
    }
    if (octant == 1) {
        outX = row;
        outY = -col;
    }
    if (octant == 2) {
        outX = row;
        outY = col;
    }
    if (octant == 3) {
{'fraction_non_alphanumeric': 0.1290245647507751, 'fraction_numerical': 0.007154781779155735, 'mean_word_length': 1.6294670846394985, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3268346', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1217, 'n_words': 310}