<commit_before>﻿using RemoteFortressReader;
using System.Collections.Generic;
using UnityEngine;
using UnityExtension;
using DFHack;

public class WorldMapMaker : MonoBehaviour
{
    public float scale = 0.01f;
    public int width;
    public int height;
    public string worldName;
    public string worldNameEnglish;
    int[,] elevation;
    int[,] rainfall;
    int[,] vegetation;
    int[,] temperature;
    int[,] evilness;
    int[,] drainage;
    int[,] volcanism;
    int[,] savagery;
    int[,] salinity;
    bool[,] cumulusMedium;
    bool[,] cumulusMulti;
    bool[,] cumulusNimbus;
    bool[,] stratusAlto;
    bool[,] stratusProper;
    bool[,] stratusNimbus;
    bool[,] cirrus;
    bool[,] fogMist;
    bool[,] fogNormal;
    bool[,] fogThick;

    public Vector3 offset;

    RemoteFortressReader.RegionMaps regionMaps;
    RemoteFortressReader.WorldMap worldMap;

    public CloudMaker cloudPrafab;

    CloudMaker cumulusMediumClouds;
    CloudMaker cumulusMultiClouds;
    Dictionary<int, CloudMaker> cumulusNimbusClouds;
    CloudMaker stratusAltoClouds;
    CloudMaker stratusProperClouds;
    Dictionary<int, CloudMaker> stratusNimbusClouds;
    CloudMaker cirrusClouds;

    Dictionary<DFCoord2d, RegionMaker> DetailRegions = new Dictionary<DFCoord2d, RegionMaker>();
    public RegionMaker regionPrefab;

    public MeshFilter terrainPrefab;
    List<MeshFilter> terrainChunks = new List<MeshFilter>();

    public MeshFilter waterPrefab;
    List<MeshFilter> waterChunks = new List<MeshFilter>();

    public Material terrainMat;

    int CoordToIndex(int x, int y)
    {
        return x + y * width;
    }

    TimeHolder timeHolder;

    void Awake()
    {
        timeHolder = FindObjectOfType<TimeHolder>();
    }

    void CopyFromRemote(WorldMap remoteMap)
    {
        if (remoteMap == null)
        {
            Debug.Log("Didn't get world map!");
            return;
        }
        timeHolder.realTime = new DFTime(remoteMap.cur_year, remoteMap.cur_year_tick);
        if (!GameSettings.Instance.rendering.drawDistantTerrain)
            return;
        width = remoteMap.world_width;
        height = remoteMap.world_height;
        if(width * height > 65535)
        {
            width = Mathf.Clamp(width, 0, 255);
            height = Mathf.Clamp(height, 0, 255);
        }
        worldName = remoteMap.name;
        worldNameEnglish = remoteMap.name_english;
        offset = new Vector3(
        -remoteMap.center_x * 48 * GameMap.tileWidth,
        0,
        remoteMap.center_y * 48 * GameMap.tileWidth);
        terrainMat.SetFloat("_Scale", scale);
        terrainMat.SetFloat("_SeaLevel", (99 * GameMap.tileHeight) + offset.y);
        InitArrays();
        for (int x = 0; x < width; x++)
            for (int y = 0; y < height; y++)
            {
                int index = y * remoteMap.world_width + x;
                elevation[x, y] = remoteMap.elevation[index];
                rainfall[x, y] = remoteMap.rainfall[index];
                vegetation[x, y] = remoteMap.vegetation[index];
                temperature[x, y] = remoteMap.temperature[index];
                evilness[x, y] = remoteMap.evilness[index];
                drainage[x, y] = remoteMap.drainage[index];
                volcanism[x, y] = remoteMap.volcanism[index];
                savagery[x, y] = remoteMap.savagery[index];
                salinity[x, y] = remoteMap.salinity[index];
                if (GameSettings.Instance.rendering.drawClouds)
                {
                    cumulusMedium[x, y] = remoteMap.clouds[index].cumulus == CumulusType.CUMULUS_MEDIUM;
                    cumulusMulti[x, y] = remoteMap.clouds[index].cumulus == CumulusType.CUMULUS_MULTI;
                    cumulusNimbus[x, y] = remoteMap.clouds[index].cumulus == CumulusType.CUMULUS_NIMBUS;
                    stratusAlto[x, y] = remoteMap.clouds[index].stratus == StratusType.STRATUS_ALTO;
                    stratusProper[x, y] = remoteMap.clouds[index].stratus == StratusType.STRATUS_PROPER;<commit_msg>fixed half-tile offset in the world map<commit_after>﻿using RemoteFortressReader;
using System.Collections.Generic;
using UnityEngine;
using UnityExtension;
using DFHack;

public class WorldMapMaker : MonoBehaviour
{
    public float scale = 0.01f;
    public int width;
    public int height;
    public string worldName;
    public string worldNameEnglish;
    int[,] elevation;
    int[,] rainfall;
    int[,] vegetation;
    int[,] temperature;
    int[,] evilness;
    int[,] drainage;
    int[,] volcanism;
    int[,] savagery;
    int[,] salinity;
    bool[,] cumulusMedium;
    bool[,] cumulusMulti;
    bool[,] cumulusNimbus;
    bool[,] stratusAlto;
    bool[,] stratusProper;
    bool[,] stratusNimbus;
    bool[,] cirrus;
    bool[,] fogMist;
    bool[,] fogNormal;
    bool[,] fogThick;

    public Vector3 offset;

    RemoteFortressReader.RegionMaps regionMaps;
    RemoteFortressReader.WorldMap worldMap;

    public CloudMaker cloudPrafab;

    CloudMaker cumulusMediumClouds;
    CloudMaker cumulusMultiClouds;
    Dictionary<int, CloudMaker> cumulusNimbusClouds;
    CloudMaker stratusAltoClouds;
    CloudMaker stratusProperClouds;
    Dictionary<int, CloudMaker> stratusNimbusClouds;
    CloudMaker cirrusClouds;

    Dictionary<DFCoord2d, RegionMaker> DetailRegions = new Dictionary<DFCoord2d, RegionMaker>();
    public RegionMaker regionPrefab;

    public MeshFilter terrainPrefab;
    List<MeshFilter> terrainChunks = new List<MeshFilter>();

    public MeshFilter waterPrefab;
    List<MeshFilter> waterChunks = new List<MeshFilter>();

    public Material terrainMat;

    int CoordToIndex(int x, int y)
    {
        return x + y * width;
    }

    TimeHolder timeHolder;

    void Awake()
    {
        timeHolder = FindObjectOfType<TimeHolder>();
    }

    void CopyFromRemote(WorldMap remoteMap)
    {
        if (remoteMap == null)
        {
            Debug.Log("Didn't get world map!");
            return;
        }
        timeHolder.realTime = new DFTime(remoteMap.cur_year, remoteMap.cur_year_tick);
        if (!GameSettings.Instance.rendering.drawDistantTerrain)
            return;
        width = remoteMap.world_width;
        height = remoteMap.world_height;
        if(width * height > 65535)
        {
            width = Mathf.Clamp(width, 0, 255);
            height = Mathf.Clamp(height, 0, 255);
        }
        worldName = remoteMap.name;
        worldNameEnglish = remoteMap.name_english;
        offset = new Vector3(
        ((-remoteMap.center_x * 48) - 0.5f) * GameMap.tileWidth,
        0,
        ((remoteMap.center_y * 48) + 0.5f) * GameMap.tileWidth);

        terrainMat.SetFloat("_Scale", scale);
        terrainMat.SetFloat("_SeaLevel", (99 * GameMap.tileHeight) + offset.y);

        InitArrays();
        for (int x = 0; x < width; x++)
            for (int y = 0; y < height; y++)
            {
                int index = y * remoteMap.world_width + x;
                elevation[x, y] = remoteMap.elevation[index];
                rainfall[x, y] = remoteMap.rainfall[index];
                vegetation[x, y] = remoteMap.vegetation[index];
                temperature[x, y] = remoteMap.temperature[index];
                evilness[x, y] = remoteMap.evilness[index];
                drainage[x, y] = remoteMap.drainage[index];
                volcanism[x, y] = remoteMap.volcanism[index];
                savagery[x, y] = remoteMap.savagery[index];
                salinity[x, y] = remoteMap.salinity[index];
                if (GameSettings.Instance.rendering.drawClouds)
                {
                    cumulusMedium[x, y] = remoteMap.clouds[index].cumulus == CumulusType.CUMULUS_MEDIUM;
                    cumulusMulti[x, y] = remoteMap.clouds[index].cumulus == CumulusType.CUMULUS_MULTI;
                    cumulusNimbus[x, y] = remoteMap.clouds[index].cumulus == CumulusType.CUMULUS_NIMBUS;
                    stratusAlto[x, y] = remoteMap.clouds[index].stratus == StratusType.STRATUS_ALTO;
                    stratusProper[x, y] = remoteMap.clouds[index].stratus == StratusType.STRATUS_PROPER;
{'fraction_non_alphanumeric': 0.10690505548705302, 'fraction_numerical': 0.0076448828606658446, 'mean_word_length': 2.5219279201042117, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, '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': '2225855', 'n_tokens_mistral': 2711, 'n_tokens_neox': 2517, 'n_words': 521}