Raw Source
infolafx.ru / kb_track

// ==UserScript==
// @name         kb_track
// @name:ru      Скрипт by Кышбрысь
// @namespace    https://catwar.su/cat1424005
// @version      0.7.0.4
// @description  Управляем группами котиков
// @author       Кышбрысь
// @match        *://catwar.su/*
// @license      MIT; https://opensource.org/licenses/MIT
// @updateURL    https://meore.com/kb_track.user.js
// @downloadURL  https://meore.com/kb_track.user.js
// @grant        GM_xmlhttpRequest
// @grant        GM.xmlHttpRequest
// @require      https://meore.com/lib/jquery-3.4.1.min.js
// @require      https://meore.com/lib/jquery.scrollintoview.min.js
// @require      https://meore.com/lib/jquery-ui.js
// ==/UserScript==

/*global jQuery*/
(function (window, document, $) {
    'use strict';

    /*
        0.6.0.0 - возвращаемся к переделке скрипта
        + отражены изменения в номерных локациях Солнца

        0.6.1.1 - добавлены карты Туннелей и Руин

        0.6.2.1 - добавлены карты Новой Деревни

        0.6.3.0 - возможность отображения плавающего окна
        0.6.3.4 - убрана ошибочно оставленная функция checkNav()

        0.7.0.0 - переезд на новые сервера
        0.7.0.3 - оптимизация производительности
        
        0.7.0.4 - карта ЛБВ
        
    */

    if (typeof $ === 'undefined') return;
    const la_version = '0.7.0.4';

    const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
    const isDesktop = !$('meta[name=viewport]').length;
    const defaults = {
        'la_version' : la_version

        , 'la_cats_visible' : false
        , 'la_cats_list' : ''
        , 'la_maps_list' : ''
        , 'la_show_all_cats' : true

        , 'la_show_id' : true
        , 'la_show_title' : true
        , 'la_jump_on_click' : false

        , 'la_cur_group' : 0

        , 'la_patruls' : [{name: 'Внешний подотряд', route: 'Ущелье совы ➝ Солнечная тропинка ➝ Лисий лес ➝ Берег упавшего дерева ➝ Сосновый овраг ➝ Сожжённый кедр ➝ Прибрежный лес ➝ Берлога ➝ Прибрежный лес ➝ Разбитая скала ➝ Бурная речка ➝ Речной остров ➝ Спокойная река ➝ Река серебристых рыб ➝ Серебристая река ➝ Солнечная тропинка ➝ Ущелье совы'}
            ,{name: 'Внутренний подотряд', route: 'Ущелье совы ➝ Солнечная тропинка ➝ Серебристая река ➝ Река серебристых рыб ➝ Спокойная река ➝ Речной остров ➝ Мелкая река ➝ Заводь с кувшинками ➝ Бурелом ➝ Тенистая тропа ➝ Бурелом ➝ Дремучая чаща ➝ Рысье дерево ➝ Дремучая чаща ➝ Солнечная тропинка ➝ Ущелье совы'}
            ,{name: 'Спаренный патруль', route: 'Ущелье совы ➝ Солнечная тропинка ➝ Серебристая река ➝ Дремучая чаща ➝ Рысье дерево ➝ Дремучая чаща ➝ Бурелом ➝ Тенистая тропа ➝ Бурелом ➝ Заводь с кувшинками ➝ Мелкая река ➝ Речной остров ➝ Бурная речка ➝ Разбитая скала ➝ Прибрежный лес ➝ Берлога ➝ Прибрежный лес ➝ Сожжённый кедр ➝ Сосновый овраг ➝ Берег упавшего дерева ➝ Лисий лес ➝ Солнечная тропинка ➝ Ущелье совы'}]
        , 'move_time' : 45
        , 'la_groups' : []
        , 'la_reports' : [{name: 'Общий патруль, внутренний подотряд', list: '$Name ($ID)',
            report: `[center][Общий патруль: внутренний подотряд][/center]

[b] [$Date | $Time][/b]
[b] Состав патруля:[/b] $List;
[b] Вышедшие из патруля:[/b] - ;
[b] Нарушители:[/b] -`}, {name: 'Общий патруль, внешний подотряд', list: '$Name ($ID)',
            report: `[center][Общий патруль: внешний подотряд][/center]

[b] [$Date | $Time][/b]
[b] Состав патруля:[/b] $List;
[b] Вышедшие из патруля:[/b] - ;
[b] Нарушители:[/b] -`}, {name: 'Общий спаренный патруль', list: '$Name ($ID)',
            report: `[center][Общий спаренный патруль][/center]

[b] [$Date | $Time][/b]
[b] Состав патруля:[/b] $List;
[b] Вышедшие из патруля:[/b] - ;
[b] Нарушители:[/b] -`}]
        , 'la_myID' : ''
        , 'la_myBID' : 0
        , 'la_delay' : 2
        , 'updateTimer' : 120
        , 'checkedSelector' : ''
        , 'myGUID' : ''
        , 'myTitle' : ''
        , 'myName' : ''
        , 'tribe' : ''
        , 'show_BB' : false
        , 'BBID' : 0
        , 'locked' : true
        , 'left' : 10
        , 'top' : 10
    };

    const globals = {}; //Настройки
    for (var key in defaults) {
        let settings = getSettings(key);
        if (settings === null) {
            globals[key] = defaults[key];
        } else {
            if (Array.isArray(defaults[key])) {
                globals[key] = JSON.parse(settings);
            } else {
                globals[key] = settings;
            }
         }
    };

    function uuidv4() {
        return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
            (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
        );
    }
    if (globals.myGUID === '') {
        globals.myGUID = uuidv4();
        setSettings('myGUID', globals.myGUID);
    }

    let worldmap = [];
    let hiddenIDList = [];
    let hidden = [];
    let movemap = [];

    if (globals.la_patruls.length > 0)  {
        worldmap[0] = {name: '> Свои Маршруты <', route: []};

        let routeID = 999000;
        worldmap[routeID] = {group: 999000, dif: 0, name: '> Свои Маршруты <', parent: 0, route: []};
        routeID++;

        globals.la_patruls.forEach(patrul => {
            worldmap[routeID] = {group: 999000, dif: 0, name: patrul.name, route: [], track: patrul.route};
            routeID++;
        })
    };

    function makeHiddenList(hidID = 0, fromMap = 0, toMap = 999999, idByMap = false, idHid = undefined, all = false) {
        worldmap.forEach((item, id) => {
            if (id >= fromMap && id <= toMap) {
                if (hidden[id] == undefined) hidden[id] = [];
                if (idByMap) movemap[id] = item.map;
                item.route.forEach(route => {hidden[id].push(route);});
            }
            
        });
    };
    
    function makeHiddenListIDbyMap(hidID, fromMap = 0, toMap = 999999, idByMap = false, idHid = undefined, all = false) {
        hiddenIDList[hidID] = {fromMap: fromMap, toMap: toMap};
    };

// ==================================================================================
    worldmap[10] = {group: 0, dif: 0, name: 'Племя Солнца', route: []};
    worldmap[20] = {group: 0, dif: 0, name: 'Деревня', route: []};
    worldmap[41] = {group: 0, dif: 1, name: 'Нейтралки: Лес', route: []};
    worldmap[42] = {group: 0, dif: 1, name: 'Нейтралки: Дальние воды', route: []};
    worldmap[43] = {group: 0, dif: 1, name: 'Нейтралки: Руины', route: []};
    worldmap[44] = {group: 0, dif: 1, name: 'Нейтралки: Туннели', route: []};
    worldmap[50] = {group: 0, dif: 0, name: 'Нейтралки', route: []};
    worldmap[70] = {group: 0, dif: 1, name: '7 ДЛ', route: []};
// ==================================================================================


// ========== 7 ДЛ ==================================================================
    worldmap[9998] = {group: 99999, dif: 1, name: '7 ДЛ', parent: 70, route: []};
    
    worldmap[10000] = {group: 10000, dif: 1, name: 'Предпустынье', map: 'Предпустынье5166', route: [10001, 79999]};
    worldmap[10001] = {group: 10001, n: 2, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн11618336', route: [10100, 10000, 10100, 10100]};
    worldmap[10002] = {group: 10001, n: 3, dif: 4, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн6486', route: [10100, 10000]};
    worldmap[10003] = {group: 10001, n: 4, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн348416', route: [10000, 10000, 10100]};
    worldmap[10004] = {group: 10001, n: 5, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1576', route: [10100, 10000]};
    worldmap[10005] = {group: 10001, n: 6, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн824326', route: [10100, 10100, 10000]};
    worldmap[10006] = {group: 10001, n: 7, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн4336', route: [10000, 10100]};
    worldmap[10007] = {group: 10001, n: 8, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн6245', route: [10000, 10100]};
    worldmap[10008] = {group: 10001, n: 9, dif: 4, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1124', route: [10000, 10100]};
    worldmap[10009] = {group: 10001, n: 10, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн914386', route: [10100, 10000, 10000]};
    worldmap[10010] = {group: 10001, n: 11, dif: 4, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5113', route: [10100, 10000]};
    worldmap[10011] = {group: 10001, n: 12, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн813315', route: [10100, 10100, 10000]};
    worldmap[10012] = {group: 10001, n: 13, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн9144', route: [10100, 10000]};
    worldmap[10013] = {group: 10001, n: 14, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн329495', route: [10100, 10100, 10000]};
    worldmap[10014] = {group: 10001, n: 15, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн8325', route: [10000, 10100]};
    worldmap[10015] = {group: 10001, n: 16, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн825556', route: [10100, 10000, 10100]};
    worldmap[10016] = {group: 10001, n: 17, dif: 4, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5324', route: [10100, 10000]};
    worldmap[10017] = {group: 10001, n: 18, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн721365', route: [10000, 10100, 10100]};
    worldmap[10018] = {group: 10001, n: 19, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн7172', route: [10000, 10100]};
    worldmap[10019] = {group: 10001, n: 20, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн136596', route: [10100, 10000, 10100]};
    worldmap[10020] = {group: 10001, n: 21, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн9225', route: [10000, 10100]};
    worldmap[10021] = {group: 10001, n: 22, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн4255', route: [10100, 10000]};
    worldmap[10022] = {group: 10001, n: 23, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн6275', route: [10100, 10000]};
    worldmap[10023] = {group: 10001, n: 24, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн819174', route: [10000, 10100, 10100]};
    worldmap[10024] = {group: 10001, n: 25, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн8475', route: [10100, 10000]};
    worldmap[10025] = {group: 10001, n: 26, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5173', route: [10100, 10000]};
    worldmap[10026] = {group: 10001, n: 27, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн7266', route: [10000, 10100]};
    worldmap[10027] = {group: 10001, n: 28, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн139485', route: [10100, 10100, 10000]};
    worldmap[10028] = {group: 10001, n: 29, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн6334', route: [10000, 10100]};
    worldmap[10029] = {group: 10001, n: 30, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн9485', route: [10100, 10000]};
    worldmap[10030] = {group: 10001, n: 31, dif: 4, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн2546', route: [10100, 10000]};
    worldmap[10031] = {group: 10001, n: 32, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн138426', route: [10100, 10100, 10000]};
    worldmap[10032] = {group: 10001, n: 33, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн2175', route: [10000, 10100]};
    worldmap[10033] = {group: 10001, n: 34, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн721384', route: [10100, 10000, 10000]};
    worldmap[10034] = {group: 10001, n: 35, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн334334', route: [10000, 10000, 10100]};
    worldmap[10035] = {group: 10001, n: 36, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн514294', route: [10000, 10000, 10100]};
    worldmap[10036] = {group: 10001, n: 37, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн322426', route: [10100, 10100, 10000]};
    worldmap[10037] = {group: 10001, n: 38, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн112184', route: [10100, 10100, 10000]};
    worldmap[10038] = {group: 10001, n: 39, dif: 4, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5152', route: [10100, 10000]};
    worldmap[10039] = {group: 10001, n: 40, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5526', route: [10000, 10100]};
    worldmap[10040] = {group: 10001, n: 41, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн2134', route: [10100, 10000]};
    worldmap[10041] = {group: 10001, n: 42, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн9214', route: [10100, 10000]};
    worldmap[10042] = {group: 10001, n: 43, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1415', route: [10000, 10100]};
    worldmap[10043] = {group: 10001, n: 44, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5134', route: [10000, 10100]};
    worldmap[10044] = {group: 10001, n: 45, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн3265', route: [10000, 10100]};
    worldmap[10045] = {group: 10001, n: 46, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5375', route: [10100, 10000]};
    worldmap[10046] = {group: 10001, n: 47, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн4585', route: [10000, 10100]};
    worldmap[10047] = {group: 10001, n: 48, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн7425', route: [10000, 10100]};
    worldmap[10048] = {group: 10001, n: 49, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн118185', route: [10000, 10100, 10000]};
    worldmap[10049] = {group: 10001, n: 50, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5192', route: [10000, 10100]};
    worldmap[10050] = {group: 10001, n: 51, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн257686', route: [10100, 10000, 10000]};
    worldmap[10051] = {group: 10001, n: 52, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн725326', route: [10100, 10100, 10000]};
    worldmap[10052] = {group: 10001, n: 53, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн912676', route: [10000, 10000, 10100]};
    worldmap[10053] = {group: 10001, n: 54, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн8175', route: [10100, 10000]};
    worldmap[10054] = {group: 10001, n: 55, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн646566', route: [10100, 10100, 10000]};
    worldmap[10055] = {group: 10001, n: 56, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн914325', route: [10000, 10100, 10100]};
    worldmap[10056] = {group: 10001, n: 57, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн917326', route: [10000, 10100, 10000]};
    worldmap[10057] = {group: 10001, n: 58, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1182', route: [10100, 10000]};
    worldmap[10058] = {group: 10001, n: 59, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1181', route: [10000, 10100]};
    worldmap[10059] = {group: 10001, n: 60, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн3316', route: [10000, 10100]};
    worldmap[10060] = {group: 10001, n: 61, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн8234', route: [10000, 10100]};
    worldmap[10061] = {group: 10001, n: 62, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн814456', route: [10100, 10100, 10000]};
    worldmap[10062] = {group: 10001, n: 63, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн811292', route: [10100, 10100, 10000]};
    worldmap[10063] = {group: 10001, n: 64, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн519185', route: [10100, 10100, 10000]};
    worldmap[10064] = {group: 10001, n: 65, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1596', route: [10000, 10100]};
    worldmap[10065] = {group: 10001, n: 66, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн217113', route: [10100, 10000, 10100]};
    worldmap[10066] = {group: 10001, n: 67, dif: 4, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн2576', route: [10100, 10000]};
    worldmap[10067] = {group: 10001, n: 68, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн612263', route: [10000, 10100, 10100]};
    worldmap[10068] = {group: 10001, n: 69, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн122676', route: [10000, 10100, 10000]};
    worldmap[10069] = {group: 10001, n: 70, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1476', route: [10000, 10100]};
    worldmap[10070] = {group: 10001, n: 71, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5335', route: [10000, 10100]};
    worldmap[10071] = {group: 10001, n: 72, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн6486', route: [10000, 10100]};
    worldmap[10072] = {group: 10001, n: 73, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн552666', route: [10100, 10100, 10000]};
    worldmap[10073] = {group: 10001, n: 74, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн8225', route: [10100, 10000]};
    worldmap[10074] = {group: 10001, n: 75, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн468696', route: [10100, 10000, 10100]};
    worldmap[10075] = {group: 10001, n: 76, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн226345', route: [10100, 10000, 10100]};
    worldmap[10076] = {group: 10001, n: 77, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1145', route: [10100, 10000]};
    worldmap[10077] = {group: 10001, n: 78, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн3374', route: [10100, 10000]};
    worldmap[10078] = {group: 10001, n: 79, dif: 3, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн5126', route: [10100, 10000]};
    worldmap[10079] = {group: 10001, n: 80, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн1161', route: [10000, 10100]};
    worldmap[10080] = {group: 10001, n: 81, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн117465', route: [10100, 10000, 10000]};
    worldmap[10081] = {group: 10001, n: 82, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн622384', route: [10000, 10100, 10000]};
    worldmap[10082] = {group: 10001, n: 83, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн223536', route: [10000, 10000, 10100]};
    worldmap[10083] = {group: 10001, n: 84, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн2124', route: [10000, 10100]};
    worldmap[10084] = {group: 10001, n: 85, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн239346', route: [10000, 10100, 10100]};
    worldmap[10085] = {group: 10001, n: 86, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн632465', route: [10000, 10000, 10100]};
    worldmap[10086] = {group: 10001, n: 87, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн2435', route: [10000, 10100]};
    worldmap[10087] = {group: 10001, n: 88, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн817336', route: [10100, 10000, 10100]};
    worldmap[10088] = {group: 10001, n: 89, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн228455', route: [10100, 10100, 10000]};
    worldmap[10089] = {group: 10001, n: 90, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн211484', route: [10100, 10000, 10000]};
    worldmap[10090] = {group: 10001, n: 91, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн651636', route: [10100, 10000, 10000]};
    worldmap[10091] = {group: 10001, n: 92, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн121324', route: [10100, 10100, 10000]};
    worldmap[10092] = {group: 10001, n: 93, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн8172', route: [10000, 10100]};
    worldmap[10093] = {group: 10001, n: 94, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн2394', route: [10100, 10000]};
    worldmap[10094] = {group: 10001, n: 95, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн715214', route: [10000, 10000, 10100]};
    worldmap[10095] = {group: 10001, n: 96, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн127546', route: [10000, 10100, 10100]};
    worldmap[10096] = {group: 10001, n: 97, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн415363', route: [10100, 10000, 10100]};
    worldmap[10097] = {group: 10001, n: 98, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн314374', route: [10100, 10000, 10000]};
    worldmap[10098] = {group: 10001, n: 99, dif: 5, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн6336', route: [10100, 10000]};
    worldmap[10099] = {group: 10001, n: 100, dif: 1, name: 'Лабиринт Безумных Волн', map: 'Лабиринт Безумных Волн933646', route: [10100, 10100, 10000]};    
    
    worldmap[10100] = {group: 10100, dif: 1, name: 'Оазис перед ЛЗ', map: '56', route: [10001, 10101]}; //ЛБВ-ЛЗ
    worldmap[10101] = {group: 10101, dif: 1, name: 'Лабиринт Зноя', route: [0, 0, 0, 10100, 10201]};
    
    worldmap[10201] = {group: 10201, dif: 1, name: 'Оазис перед ЛОЗ', map: '56', route: [10202, 10101]}; //ЛЗ-ЛОЗ
    worldmap[10202] = {group: 10202, dif: 1, name: 'Лабиринт Острых Зубьев', route: [0, 0, 0, 10201, 10301]};
    
    worldmap[10301] = {group: 10301, dif: 1, name: 'Оазис перед ВП', map: '5156', route: [0, 0, 10202, 10302]}; //ЛОЗ-ВП
    worldmap[10302] = {group: 10302, dif: 1, name: 'Великий Путь', route: [0, 0, 0, 10301, 0, 77601]};


// ======= ДАЛЬНИЕ ВОДЫ =================================================================
    worldmap[29999] = {group: 29999, dif: 1, name: '_ДВ', route: [], parent: 42};

    worldmap[30001] = {group: 30001, dif: 1, name: 'Побережье 1', map: '7156', route: [30625, 30002]};
    worldmap[30002] = {group: 30002, dif: 1, name: 'Побережье 2 (Лес)', map: '1191106', route: [30628, 30001, 80051]};
    worldmap[30003] = {group: 30004, dif: 1, name: 'Побережье 3', map: '5124', route: [30004, 0]};
    worldmap[30004] = {group: 30004, dif: 1, name: 'Побережье 4 (Руины)', map: '239356', route: [0, 80157, 30003]};

    worldmap[30601] = {group: 30601, dif: 1, name: 'Море 01 (Туннели)', map: 'Море2436', route: [30602, 30606, 80117, 80101], hr: [{id:80117, x:7, y:5}]};
    worldmap[30602] = {group: 30602, dif: 6, name: 'Море 02 (6 ПУ)', map: '128216', route: [30603, 30601, 30619]};    
    worldmap[30603] = {group: 30603, dif: 4, name: 'Море 03 (4 ПУ)', map: '913696', route: [30604, 30619, 30602]};    
    worldmap[30604] = {group: 30604, dif: 4, name: 'Море 04 (4 ПУ)', map: '329325', route: [30605, 30631, 30603]};    
    worldmap[30605] = {group: 30605, dif: 1, name: 'Море 05 (1 ПУ)', map: '5192145696', route: [82929, 30629, 82928, 82927, 30604]};
    worldmap[30606] = {group: 30606, dif: 6, name: 'Море 06 (6 ПУ)', map: '31349495', route: [30601, 30620, 30618, 30607]};    
    worldmap[30607] = {group: 30607, dif: 2, name: 'Море 07 (2 ПУ)', map: '229225', route: [30606, 30608, 30621]};
    worldmap[30608] = {group: 30608, dif: 1, name: 'Море 08 (1 ПУ)', map: '23106', route: [30607, 82931]};
    worldmap[30610] = {group: 30610, dif: 1, name: 'Море 10 (1 ПУ)', map: '7133', route: [82931, 30616]};
    worldmap[30611] = {group: 30611, dif: 1, name: 'Море 11 (1 ПУ)', map: '4156', route: [30617, 82931]};
    worldmap[30612] = {group: 30612, dif: 1, name: 'Море 12 (1 ПУ)', map: '1210316', route: [82930, 30624, 30613]};
    worldmap[30613] = {group: 30613, dif: 2, name: 'Море 13 (2 ПУ)', map: '8116', route: [30612, 30614]};
    worldmap[30614] = {group: 30614, dif: 4, name: 'Море 14 (4 ПУ)', map: '419213', route: [30613, 30627, 30615]};
    worldmap[30615] = {group: 30615, dif: 4, name: 'Море 15 (4 ПУ)', map: '911396', route: [30616, 30623, 30614]};
    worldmap[30616] = {group: 30616, dif: 2, name: 'Море 16 (2 ПУ)', map: '3286', route: [30610, 30615]};
    worldmap[30617] = {group: 30617, dif: 2, name: 'Море 17 (2 ПУ)', map: '2546', route: [30618, 30611]};
    worldmap[30618] = {group: 30618, dif: 4, name: 'Море 18 (4 ПУ)', map: '519123', route: [30633, 30617, 30606]};    
    worldmap[30619] = {group: 30619, dif: 5, name: 'Море 19 (5 ПУ)', map: '31101106', route: [30603, 30602, 30620]};
    worldmap[30620] = {group: 30620, dif: 4, name: 'Море 20 (4 ПУ)', map: '912285', route: [30606, 30619, 30621]};
    worldmap[30621] = {group: 30621, dif: 4, name: 'Море 21 (4 ПУ)', map: '218285', route: [30620, 30607, 30622]};
    worldmap[30622] = {group: 30622, dif: 2, name: 'Море 22 (2 ПУ)', map: 'Море1294', route: [30621, 30623]};
    worldmap[30623] = {group: 30623, dif: 2, name: 'Море 23 (2 ПУ)', map: '21104', route: [30622, 30615]};
    worldmap[30624] = {group: 30624, dif: 5, name: 'Море 24 (5 ПУ, охота)', map: '123486', route: [30612, 30626, 30625]};
    worldmap[30625] = {group: 30625, dif: 1, name: 'Море 25 (1 ПУ)', map: 'Море5166', route: [30624, 30001]};
    worldmap[30626] = {group: 30626, dif: 5, name: 'Море 26 (5 ПУ)', map: '9125', route: [30624, 30627]};
    worldmap[30627] = {group: 30627, dif: 2, name: 'Море 27 (2 ПУ, охота)', map: '911565', route: [30626, 30614, 30628]};
    worldmap[30628] = {group: 30628, dif: 1, name: 'Море 28 (1 ПУ)', map: '2195', route: [30627, 30002]};
    worldmap[30629] = {group: 30629, dif: 1, name: 'Море 29 (1 ПУ)', map: '11931435', route: [30630, 30631, 82929, 30631]};
    worldmap[30630] = {group: 30630, dif: 1, name: 'Море 30 (1 ПУ)', map: '6192104106', route: [30638, 30639, 30629, 82929]};
    worldmap[30631] = {group: 30631, dif: 2, name: 'Море 31 (2 ПУ)', map: '1235106', route: [30629, 30604, 30632]};

    worldmap[82920] = {group: 29999, dif: 1, name: '_ДВ', route: [], parent: 42};
    worldmap[82927] = {group: 82927, dif: 1, name: 'Остров А3', map: '10122', route: [30605, 82928]};
    worldmap[82928] = {group: 82928, dif: 1, name: 'Остров А2', map: '8210486', route: [82929, 30605, 82927]};
    worldmap[82929] = {group: 82929, dif: 1, name: 'Остров А1', map: '1011042596', route: [30630, 30629, 82928, 30605]};

    worldmap[82930] = {group: 82930, dif: 1, name: 'Остров Б2', map: '12104', route: [82947, 30612]};
    worldmap[82931] = {group: 82931, dif: 1, name: 'Остров Б1', map: '411021446', route: [30611, 82947, 30608, 30610]};
    worldmap[82947] = {group: 82947, dif: 1, name: 'Море 09 (ПУ)', map: '12102', route: [82931, 82930]};

//  ==== ДЕРЕВНЯ =====================================================================
    worldmap[77000] = {group: 10000, dif: 0, name: '', parent: 20, route: []};

    worldmap[77501] = {group: 77609, dif: 5, name: 'Коровник', route: [77502, 77609, 77617]};
    worldmap[77502] = {group: 77609, dif: 5, name: 'Сеновал', route: [77503, 77501]};
    worldmap[77503] = {group: 77609, dif: 5, name: 'Стог сена', route: [77502]};

    worldmap[77600] = {group: 77600, dif: 1, name: 'Площадь памяти', map: '913596', route: [77610, 77601, 77605]};
    worldmap[77601] = {group: 77601, dif: 1, name: 'Ворота', map: '81222546', route: [77600, 77603, 140000, 77602]};
    worldmap[77602] = {group: 77602, dif: 1, name: 'Пшеничное поле', map: '6294', route: [77601, 77636]};
    worldmap[77603] = {group: 77603, dif: 1, name: 'Трактор', map: '4195', route: [77604, 77601]};
    worldmap[77604] = {group: 77604, dif: 1, name: 'Фруктовый сад', map: '41823336', route: [0, 77634, 77635, 77603]};
    worldmap[77605] = {group: 77605, dif: 1, name: 'Цветочная клумба', map: '10243', route: [77606, 77600]};
    worldmap[77606] = {group: 77606, dif: 1, name: 'Крыльцо', map: '1210416', route: [77608, 77607, 77605]};
    worldmap[77607] = {group: 77607, dif: 1, name: 'Большой дом', map: '511011410556', route: [77652, 77656, 77606, 77671, 77654]};
    worldmap[77608] = {group: 77608, dif: 1, name: 'Будка', map: '7126', route: [77609, 77606]};
    worldmap[77609] = {group: 77609, dif: 1, name: 'Пастбище', map: '21911021310316', route: [77613, 77501, 77617, 77610, 77625, 77608]};
    worldmap[77610] = {group: 77610, dif: 1, name: 'Солнечная лужайка', map: '21511326', route: [77613, 77609, 77611, 77600]};
    worldmap[77611] = {group: 77611, dif: 1, name: 'Птичий двор', map: '4310516', route: [77612, 77610, 77634]};
    worldmap[77612] = {group: 77612, dif: 1, name: 'Курятник', map: '1142439486', route: [77640, 77640, 77640, 77640, 77611]};
    
    worldmap[77613] = {group: 77613, dif: 1, name: 'Конюшня', map: '411019566', route: [77614, 77621, 77609, 77610]};
    worldmap[77614] = {group: 77614, dif: 1, name: 'Царапины на стене', map: '103', route: [77613]};
    
    worldmap[77617] = {group: 77617, dif: 1, name: 'Хлев', map: '1011316', route: [77618, 77501, 77609]};
    worldmap[77618] = {group: 77618, dif: 1, name: 'Мельница', map: '1011646', route: [77619, 77617, 77625]};
    worldmap[77619] = {group: 77619, dif: 1, name: 'Задний двор 2', map: '5214106', route: [77623, 77620, 77618]};
    worldmap[77620] = {group: 77620, dif: 1, name: 'Задний двор 3', map: '319314', route: [77622, 77619, 77621]};
    worldmap[77621] = {group: 77621, dif: 1, name: 'Задний двор 1', map: '319314', route: [77622, 0, 77613]};
    worldmap[77622] = {group: 77620, dif: 1, name: 'Кормушка', map: '1666', route: [77621, 77620]};
    worldmap[77623] = {group: 77623, dif: 1, name: 'Лаз в заборе', map: '6536', route: [77624, 77619]};
    worldmap[77624] = {group: 77624, dif: 1, name: 'Дремучий лес', map: '45', route: [77623]};
    worldmap[77625] = {group: 77625, dif: 1, name: 'Утиный пруд', map: '8115106', route: [77618, 77609, 77626]};
    worldmap[77626] = {group: 77626, dif: 1, name: 'Баня', map: '1110456', route: [77625, 77633, 77627]};
    worldmap[77627] = {group: 77627, dif: 1, name: 'Огород', map: '519125105', route: [77626, 77628, 77630, 77629]};
    worldmap[77628] = {group: 77628, dif: 1, name: 'Теплица', map: '14106', route: [77627, 77658]};
    worldmap[77629] = {group: 77629, dif: 1, name: 'Морковная грядка', map: '122646', route: [77627, 77630, 77631]};
    worldmap[77630] = {group: 77630, dif: 1, name: 'Картофельное поле', map: '411032486', route: [77627, 77629, 77632, 77631]};
    worldmap[77631] = {group: 77631, dif: 1, name: 'Бочка с водой', map: '81103', route: [77630, 77629]};
    worldmap[77632] = {group: 77632, dif: 1, name: 'Кротовая нора', map: '95', route: [77630]};    
    worldmap[77633] = {group: 77633, dif: 1, name: 'Парная', map: '104', route: [77626]};
    worldmap[77634] = {group: 77634, dif: 1, name: 'Пасека', map: '8155', route: [77611, 77604]};
    worldmap[77635] = {group: 77635, dif: 1, name: 'Кустики', map: 'Кустики1294', route: [77638, 77604]};
    worldmap[77636] = {group: 77636, dif: 1, name: 'Тропа скорби', map: '14104', route: [77602, 77637]};
    worldmap[77637] = {group: 77637, dif: 1, name: 'Кладбище домашних животных', map: '12', route: [77636]};
    worldmap[77638] = {group: 77638, dif: 1, name: 'Побережье (деревня)', map: '139516', route: [0, 77635, 0]};

    worldmap[77640] = {group: 77640, dif: 1, name: 'Насест', map: '56', route: [77612]};
    
    worldmap[77650] = {group: 77607, dif: 1, name: 'Местечко за печью', map: '16', route: [77656]};
    worldmap[77651] = {group: 77607, dif: 1, name: 'Шкаф', map: '51', route: [77660]};
    worldmap[77652] = {group: 77607, dif: 1, name: 'Чердак', map: '4272259556', route: [77653, 77653, 77653, 77653, 77607]};
    worldmap[77653] = {group: 77607, dif: 1, name: 'Тёмный угол', map: '56', route: [77652]};
    worldmap[77654] = {group: 77607, dif: 1, name: 'Подвал', map: '51547494567696', route: [77607, 77655, 77655, 77655, 77655, 77655, 77655]};
    worldmap[77655] = {group: 77607, dif: 1, name: 'Отсек для хранения', map: '51', route: [77654]};
    worldmap[77656] = {group: 77607, dif: 1, name: 'Печь', map: '7243104155686', route: [77650, 77650, 77660, 77607, 77671, 77657]};
    worldmap[77657] = {group: 77607, dif: 1, name: 'Сложенные дрова', map: '11', route: [77656]};
    worldmap[77658] = {group: 77628, dif: 1, name: 'Овощные грядки', map: '10316', route: [77658, 77628]};
    
    worldmap[77660] = {group: 77607, dif: 1, name: 'Спальня', map: '1028314444696', route: [77651, 77664, 77656, 77662, 77663, 77665]};
    worldmap[77662] = {group: 77607, dif: 1, name: 'Кровать', map: '51', route: [77660]};
    worldmap[77663] = {group: 77607, dif: 1, name: 'Местечко под кроватью', map: '51', route: [77660]};
    worldmap[77664] = {group: 77607, dif: 1, name: 'Подоконник', map: '51', route: [77660]};
    worldmap[77665] = {group: 77607, dif: 1, name: 'Каморка', map: '51', route: [77660]};

    worldmap[77666] = {group: 77607, dif: 1, name: 'Детская', map: '10213533686', route: [77667, 77671, 77668, 77669, 77670]};
    worldmap[77667] = {group: 77607, dif: 1, name: 'Сундук', map: '51', route: [77666]};
    worldmap[77668] = {group: 77607, dif: 1, name: 'Детская кроватка', map: '51', route: [77666]};
    worldmap[77669] = {group: 77607, dif: 1, name: 'Мягкий ковёр', map: '51', route: [77666]};
    worldmap[77670] = {group: 77607, dif: 1, name: 'Груда игрушек', map: '51', route: [77666]};
    worldmap[77671] = {group: 77607, dif: 1, name: 'Коридор', map: '511210356', route: [77656, 77607, 77666, 77672]};
    worldmap[77672] = {group: 77607, dif: 1, name: 'Чулан', map: '51', route: [77671]};
    
// ==================================================================================
    worldmap[31000] = {group: 83005, dif: 0, name: '', parent: 10, route: []};
    worldmap[31020] = {group: 83005, dif: 1, name: 'Уютная норка', map: '61', route: [83171]};
    worldmap[31021] = {group: 83005, dif: 1, name: 'Светлый овражек', map: '619316', route: [83154, 83023, 83155]};

    worldmap[79998] = {group: 79999, dif: 0, name: '', parent: 50, route: []};
    worldmap[79999] = {group: 79999, dif: 1, name: 'Тенистая долина', map: '2546106', route: [80019, 80021, 10000]};
    worldmap[80000] = {group: 80000, dif: 1, name: 'Разбитая скала', map: '218110446', route: [0, 80016, 80004, 80010]};
    worldmap[80002] = {group: 80002, dif: 1, name: 'Берлога', map: '72', route: [80010]};
    worldmap[80003] = {group: 80003, dif: 1, name: 'Затихшее озеро', map: '103', route: [80025]};
    worldmap[80004] = {group: 80004, dif: 1, name: 'Бурная речка', map: '41221466', route: [0, 0, 80000, 83016]};
    worldmap[80010] = {group: 80010, dif: 1, name: 'Прибрежный лес', route: [80000, 83012, 0, 80002]};
    worldmap[80016] = {group: 80016, dif: 1, name: 'Каменистая тропа', map: '2166', route: [80017, 80000]};
    worldmap[80017] = {group: 80017, dif: 1, name: 'Обрыв', map: '3156', route: [80018, 80016]};
    worldmap[80018] = {group: 80018, dif: 1, name: 'Воющая расщелина', map: '7110346', route: [80022, 80019, 80017]};
    worldmap[80019] = {group: 80019, dif: 1, name: 'Крутой склон', map: '8110314', route: [79999, 80021, 80018]};
    worldmap[80021] = {group: 80021, dif: 1, name: 'Заросли терновника', map: '7110213', route: [79999, 80165, 80019]};
    worldmap[80022] = {group: 80022, dif: 1, name: 'Горная речка', map: '2486', route: [80023, 80018]};
    worldmap[80023] = {group: 80023, dif: 1, name: 'Утёс холодных ветров', map: '61104', route: [80024, 80022]};
    worldmap[80024] = {group: 80024, dif: 1, name: 'Туманная скала', map: '1346', route: [80025, 80023]};
    worldmap[80025] = {group: 80025, dif: 1, name: 'Пещера забытых голосов', map: '13105', route: [80003, 80024]};    

 // ==================================================================================
    worldmap[80026] = {group: 80026, dif: 1, name: '_Лес', route: [], parent: 41};
    worldmap[80027] = {group: 80027, dif: 1, name: 'Лес 01 (Солнце)', map: '62104', route: [83022, 80028]};
    worldmap[80028] = {group: 80028, dif: 1, name: 'Лес 02', map: '5314', route: [80029, 80027]};
    worldmap[80029] = {group: 80029, dif: 1, name: 'Лес 03', map: '33105', route: [80028, 80030]};
    worldmap[80030] = {group: 80030, dif: 1, name: 'Лес 04', map: '10315', route: [80031, 80029]};
    worldmap[80031] = {group: 80031, dif: 1, name: 'Лес 05 (Туннели)', map: '10215', route: [80032, 80030, 80112], hr: [{id:80112, x:6, y:4}]};
    worldmap[80032] = {group: 80032, dif: 1, name: 'Лес 06', map: '6466', route: [80033, 80031]};
    worldmap[80033] = {group: 80033, dif: 1, name: 'Лес 07', map: '1510586', route: [80032, 80034, 80039]};
    worldmap[80034] = {group: 80034, dif: 1, name: 'Лес 08', map: '1041546', route: [80035, 80033, 80040]};
    worldmap[80035] = {group: 80035, dif: 1, name: 'Лес 09', map: '85105', route: [80034, 80036]};
    worldmap[80036] = {group: 80036, dif: 1, name: 'Лес 10', map: '9315', route: [80037, 80035]};
    worldmap[80037] = {group: 80037, dif: 1, name: 'Лес 11', map: '33105', route: [80036, 80038]};
    worldmap[80038] = {group: 80038, dif: 1, name: 'Лес 12', map: '1576', route: [80037, 80044]};
    worldmap[80039] = {group: 80039, dif: 1, name: 'Лес 13', map: '9210566', route: [80033, 80040, 80045]};
    worldmap[80040] = {group: 80040, dif: 1, name: 'Лес 14', map: '22104159566', route: [80034, 80041, 80039, 80047, 80046]};
    worldmap[80041] = {group: 80041, dif: 1, name: 'Лес 15', map: '1410476', route: [80040, 80042, 80047]};
    worldmap[80042] = {group: 80042, dif: 1, name: 'Лес 16', map: '1410456', route: [80041, 80043, 80048]};
    worldmap[80043] = {group: 80043, dif: 1, name: 'Лес 17', map: '1476106', route: [80042, 80049, 80044]};
    worldmap[80044] = {group: 80044, dif: 1, name: 'Лес 18', map: '9215', route: [80038, 80043]};
    worldmap[80045] = {group: 80045, dif: 1, name: 'Лес 19', map: '41103', route: [80039, 80046]};
    worldmap[80046] = {group: 80046, dif: 1, name: 'Лес 20', map: '7114105', route: [80040, 80045, 80047]};
    worldmap[80047] = {group: 80047, dif: 1, name: 'Лес 21', map: '539310566', route: [80040, 80041, 80048, 80046]};
    worldmap[80048] = {group: 80048, dif: 1, name: 'Лес 22', map: '4314105', route: [80042, 80047, 80049]};
    worldmap[80049] = {group: 80049, dif: 1, name: 'Лес 23', map: '137415', route: [80043, 80050, 80048]};
    worldmap[80050] = {group: 80050, dif: 1, name: 'Лес 24 (Грaнуаль)', map: '3256', route: [80049, 80056]};
    worldmap[80051] = {group: 80051, dif: 1, name: 'Лес 25 (Дальние воды)', map: '921566', route: [80052, 30002, 80057]};
    worldmap[80052] = {group: 80052, dif: 1, name: 'Лес 26', map: '13103', route: [80051, 80053]};
    worldmap[80053] = {group: 80053, dif: 1, name: 'Лес 27', map: '1394', route: [80052, 80054]};
    worldmap[80054] = {group: 80054, dif: 1, name: 'Лес 28', map: '10324', route: [80055, 80053]};
    worldmap[80055] = {group: 80055, dif: 1, name: 'Лес 29', map: '13105', route: [80054, 80056]};
    worldmap[80056] = {group: 80056, dif: 1, name: 'Лес 30', map: '9325', route: [80050, 80055]};
    worldmap[80057] = {group: 80057, dif: 1, name: 'Лес 31', map: '10295', route: [80051, 80058]};
    worldmap[80058] = {group: 80058, dif: 1, name: 'Лес 32', map: '2210225', route: [80051, 80059, 80057]};
    worldmap[80059] = {group: 80059, dif: 1, name: 'Лес 33', map: '12104', route: [80058, 80060]};
    worldmap[80060] = {group: 80060, dif: 1, name: 'Лес 34', map: '14105', route: [80059, 80061]};
    worldmap[80061] = {group: 80061, dif: 1, name: 'Лес 35', map: '14105', route: [80060, 80062]};
    worldmap[80062] = {group: 80062, dif: 1, name: 'Лес 36 (Руины)', map: '6215', route: [80174, 80061]};

    worldmap[80063] = {group: 80026, dif: 1, name: '_Туннели', route: [], parent: 44};

    worldmap[80070] = {group: 80070, dif: 5, name: 'Туннели 03м (Море)', map: '11', route: [0, 80071], hr: [{id:80071, x:5, y:6}]};
    worldmap[80071] = {group: 80071, dif: 5, name: 'Туннели 02м', map: '', route: [80070, 80072], hr: [{id:80070, x:4, y:1}, {id:80072, x:8, y:6}]};
    worldmap[80072] = {group: 80072, dif: 5, name: 'Туннели 01м', map: '', route: [80071, 80101, 80073], hr: [{id:80071, x:2, y:1}, {id:80101, x:10, y:2}, {id:80073, x:3, y:6}]};
    worldmap[80073] = {group: 80073, dif: 1, name: 'Туннели 12', map: '', route: [80072, 80117, 80074], hr: [{id:80072, x:3, y:1}, {id:80117, x:1, y:4}, {id:80074, x:8, y:6}]};
    worldmap[80074] = {group: 80074, dif: 1, name: 'Туннели 11', map: '', route: [80073, 80075], hr:[{id:80073, x:3, y:1}, {id:80075, x:10, y:5}]};
    worldmap[80075] = {group: 80075, dif: 1, name: 'Подземный лес 10', map: '', route: [80074, 80076], hr:[{id:80074, x:1, y:2}, {id:80076, x:6, y:6}]};
    worldmap[80076] = {group: 80076, dif: 1, name: 'Подземный лес 09', map: '', route: [80075, 80077], hr:[{id:80075, x:4, y:1}, {id:80077, x:5, y:6}]};
    worldmap[80077] = {group: 80077, dif: 1, name: 'Подземный лес 08', map: '', route: [80076, 80078], hr: [{id:80076, x:5, y:1}, {id:80078, x:9, y:5}]};
    worldmap[80078] = {group: 80078, dif: 1, name: 'Подземный лес 07', map: '', route: [80105, 80077, 80079, 80106], hr: [{id:80105, x:9, y:1}, {id:80077, x:2, y:2}, {id:80079, x:9, y:4}, {id:80106, x:5, y:6}]};
    worldmap[80079] = {group: 80079, dif: 1, name: 'Подземный лес 06', map: '', route: [80080, 80078], hr: [{id:80080, x:10, y:2}, {id:80078, x:2, y:5}]};
    worldmap[80080] = {group: 80080, dif: 1, name: 'Подземный лес 04', map: '', route: [80085, 80079, 80081], hr: [{id:80085, x:4, y:1}, {id:80079, x:1, y:5}, {id:80081, x:10, y:5}]};    
    worldmap[80081] = {group: 80081, dif: 1, name: 'Туннели 03', map: '', route: [80080, 80082], hr: [{id:80080, x:1, y:2}, {id:80082, x:7, y:6}]};
    worldmap[80082] = {group: 80082, dif: 1, name: 'Туннели 02', map: '', route: [80081, 80083, 80119], hr: [{id:80081, x:4, y:1}, {id:80083, x:10, y:3}, {id:80119, x:3, y:5}]};
    worldmap[80083] = {group: 80083, dif: 1, name: 'Туннели 01', map: '', route: [80082, 80084], hr: [{id:80082, x:1, y:3}, {id:80084, x:7, y:6}]};
    worldmap[80084] = {group: 80084, dif: 1, name: 'Туннели 00 (Солнце)', map: '106', route: [83011, 80083], hr: [{id:80083, x:4, y:1}]};
    worldmap[80085] = {group: 80085, dif: 1, name: 'Подземный лес 05', map: '', route: [80086, 80105, 80080], hr: [{id:80086, x:7, y:1}, {id:80105, x:1, y:4}, {id:80080, x:7, y:6}]};
    worldmap[80086] = {group: 80086, dif: 1, name: 'Туннели 23', map: '', route: [80087, 80085], hr: [{id:80087, x:10, y:3}, {id:80085, x:4, y:6}]};
    worldmap[80087] = {group: 80087, dif: 1, name: 'Туннели 24', map: '', route: [80088, 80086, 80118], hr: [{id:80088, x:10, y:3}, {id:80086, x:1, y:5}, {id:80118, x:6, y:5}]};
    worldmap[80088] = {group: 80088, dif: 1, name: 'Туннели 25', map: '', route: [80089, 80087], hr: [{id:80089, x:8, y:1}, {id:80087, x:1, y:5}]};
    worldmap[80089] = {group: 80089, dif: 1, name: 'Туннели 26', map: '', route: [80091, 80090, 80088], hr: [{id:80091, x:4, y:1}, {id:80090, x:10, y:3}, {id:80088, x:4, y:6}]};
    worldmap[80090] = {group: 80090, dif: 1, name: 'Туннели 27 (Луна)', map: '101', route: [0, 80089], hr: [{id:80089, x:1, y:5}]};
    worldmap[80091] = {group: 80091, dif: 1, name: 'Туннели 28', map: '', route: [80092, 80089], hr: [{id:80092, x:3, y:1}, {id:80089, x:7, y:6}]};
    worldmap[80092] = {group: 80092, dif: 1, name: 'Туннели 29 (Руины)', map: '25', route: [80158, 80093, 80091], hr: [{id:80093, x:4, y:1}, {id:80091, x:7, y:6}]};
    worldmap[80093] = {group: 80093, dif: 1, name: 'Туннели 30', map: '', route: [80094, 80092], hr: [{id:80094, x:3, y:1}, {id:80092, x:5, y:6}]};
    worldmap[80094] = {group: 80094, dif: 1, name: 'Туннели 31', map: '', route: [80095, 80114, 80093], hr: [{id:80095, x:4, y:1}, {id:80114, x:9, y:2}, {id:80093, x:7, y:6}]};
    worldmap[80095] = {group: 80095, dif: 1, name: 'Туннели 32', map: '', route: [80096, 80094], hr: [{id:80096, x:1, y:1}, {id:80094, x:5, y:6}]};
    worldmap[80096] = {group: 80096, dif: 1, name: 'Туннели 33 (Остров)', map: '62', route: [0, 80097, 80102, 80095], hr: [{id:80097, x:1, y:6}, {id:80102, x:5, y:6}, {id:80095, x:10, y:6}]};
    worldmap[80097] = {group: 80097, dif: 1, name: 'Туннели 34', map: '', route: [80096, 80098], hr: [{id:80096, x:10, y:1}, {id:80098, x:3, y:6}]};
    worldmap[80098] = {group: 80098, dif: 1, name: 'Туннели 35', map: '', route: [80097, 80099], hr: [{id:80097, x:7, y:1}, {id:80099, x:3, y:6}]};
    worldmap[80099] = {group: 80099, dif: 1, name: 'Туннели 36', map: '', route: [80098, 80115, 80100], hr: [{id:80098, x:8, y:1}, {id:80115, x:1, y:2}, {id:80100, x:3, y:6}]};
    worldmap[80100] = {group: 80100, dif: 1, name: 'Туннели 37', map: '', route: [80099, 80101], hr: [{id:80099, x:6, y:1}, {id:80101, x:3, y:6}]};
    worldmap[80101] = {group: 80101, dif: 2, name: 'Туннели 04м', map: '', route: [80100, 80072], hr: [{id:80100, x:6, y:1}, {id:80072, x:1, y:5}]};
    worldmap[80102] = {group: 80102, dif: 1, name: 'Туннели 40', map: '', route: [80096, 80103], hr: [{id:80096, x:5, y:1}, {id:80103, x:4, y:6}]};
    worldmap[80103] = {group: 80103, dif: 1, name: 'Туннели 39', map: '', route: [80102, 80116, 80104], hr: [{id:80102, x:5, y:1}, {id:80116, x:9, y:4}, {id:80104, x:4, y:6}]};
    worldmap[80104] = {group: 80104, dif: 1, name: 'Туннели 38', map: '', route: [80103, 80105], hr: [{id:80103, x:6, y:1}, {id:80105, x:4, y:6}]};
    worldmap[80105] = {group: 80105, dif: 3, name: 'Подземный лес 14 (3 ЛУ)', map: '', route: [80104, 80085, 80078], hr: [{id:80104, x:4, y:1}, {id:80085, x:10, y:2}, {id:80078, x:3, y:6}]};
    worldmap[80106] = {group: 80106, dif: 1, name: 'Туннели 15', map: '', route: [80078, 80107, 80108, 80113, 80109, 80110, 80111, 80112], hr: [{id:80078, x:3, y:1}, {id:80107, x:1, y:2}, {id:80108, x:1, y:4}, {id:80113, x:10, y:4}, {id:80109, x:1, y:6}, {id:80110, x:4, y:6}, {id:80110, x:7, y:6}, {id:80112, x:10, y:6}]};
    worldmap[80107] = {group: 80107, dif: 1, name: 'Туннели 16', map: '', route: [80078, 80108, 80106], hr: [{id:80078, x:10, y:2}, {id:80108, x:3, y:6}, {id:80106, x:10, y:6}]};
    worldmap[80108] = {group: 80108, dif: 1, name: 'Туннели 17', map: '', route: [80107, 80109], hr: [{id:80107, x:7, y:1}, {id:80109, x:8, y:6}]};
    worldmap[80109] = {group: 80109, dif: 1, name: 'Туннели 18', map: '', route: [80108, 80110], hr: [{id:80108, x:2, y:1}, {id:80110, x:10, y:5}]};
    worldmap[80110] = {group: 80110, dif: 1, name: 'Совиное кладбище 19', map: '', route: [80109, 80110], hr: [{id:80109, x:1, y:3}, {id:80110, x:10, y:3}]};
    worldmap[80111] = {group: 80111, dif: 1, name: 'Совиное кладбище 20', map: '101', route: [80769, 80110], hr: [{id:80110, x:1, y:3}]};
    worldmap[80112] = {group: 80112, dif: 1, name: 'Туннели 22', map: '106', route: [80031, 80113], hr: [{id:80113, x:4, y:1}]};
    worldmap[80113] = {group: 80113, dif: 1, name: 'Туннели 21', map: '', route: [80079, 80106, 80112], hr: [{id:80079, x:4, y:1}, {id:80106, x:1, y:6}, {id:80112, x:7, y:6}]};
    worldmap[80114] = {group: 80114, dif: 1, name: 'Туннели 31Т', map: '', route: [80094], hr: [{id:80094, x:2, y:2}]};
    worldmap[80115] = {group: 80115, dif: 1, name: 'Туннели 36Т', map: '', route: [80099], hr: [{id:80099, x:10, y:3}]};
    worldmap[80116] = {group: 80116, dif: 1, name: 'Туннели 39Т', map: '', route: [80103], hr: [{id:80103, x:2, y:4}]};
    worldmap[80117] = {group: 80117, dif: 1, name: 'Туннели 13 (Дальние воды)', map: '53', route: [30601, 80073], hr: [{id:80073, x:10, y:4}]};
    worldmap[80118] = {group: 80118, dif: 1, name: 'Туннели 24Т', map: '', route: [80087], hr: [{id:80087, x:6, y:2}]};
    worldmap[80119] = {group: 80119, dif: 1, name: 'Туннели 02Т', map: '', route: [80082], hr: [{id:80082, x:8, y:5}]};

    // =======РУИНЫ========
    worldmap[80149] = {group: 80026, dif: 1, name: '_Руины', route: [], parent: 43};
    worldmap[80150] = {group: 80150, dif: 1, name: 'Руины 00 (Луна)', map: '93106', route: [80151, 0]};
    worldmap[80151] = {group: 80151, dif: 1, name: 'Руины 01', map: '339386', route: [80152, 80158, 80150]};
    worldmap[80152] = {group: 80152, dif: 1, name: 'Руины 02', map: '7334', route: [80151, 80153]};
    worldmap[80153] = {group: 80152, dif: 1, name: 'Руины 03', map: '7334', route: [80154, 80152]};
    worldmap[80154] = {group: 80152, dif: 1, name: 'Руины 04', map: '7334', route: [80153, 80155]};
    worldmap[80155] = {group: 80152, dif: 1, name: 'Руины 05', map: '7334', route: [80156, 80154]};
    worldmap[80156] = {group: 80152, dif: 1, name: 'Руины 06', map: '7334', route: [80157, 80155]};
    worldmap[80157] = {group: 80152, dif: 1, name: 'Руины 07 (Дальние воды)', map: '7334', route: [30004, 80156]};
    worldmap[80158] = {group: 80158, dif: 1, name: 'Руины 08 (Туннели)', map: '3476106', route: [80159, 80151, 80171, 80092], hr:[{id:80092, x:6, y:3}]}; //переход с Туннелей
    worldmap[80159] = {group: 80159, dif: 1, name: 'Руины 09', map: '226310576', route: [80167, 80160, 80168, 80158]};
    worldmap[80160] = {group: 80160, dif: 1, name: 'Руины 10', map: '227376', route: [80163, 80161, 80159]};
    worldmap[80161] = {group: 80161, dif: 1, name: 'Руины 11 (Шарлотта)', map: '1546', route: [80162, 80160]};
    worldmap[80162] = {group: 80162, dif: 1, name: 'Руины 12', map: '105', route: [80161]};
    worldmap[80163] = {group: 80163, dif: 1, name: 'Руины 13', map: '10415', route: [80160, 80164]};
    worldmap[80164] = {group: 80164, dif: 1, name: 'Руины 14', map: '15105', route: [80165, 80163]};
    worldmap[80165] = {group: 80165, dif: 1, name: 'Руины 15 (Нейтралки)', map: '10325105', route: [80164, 80021, 80166]};
    worldmap[80166] = {group: 80166, dif: 1, name: 'Руины 16', map: '9315', route: [80167, 80165]};
    worldmap[80167] = {group: 80167, dif: 1, name: 'Руины 17', map: '23105', route: [80166, 80159]};
    worldmap[80168] = {group: 80168, dif: 1, name: 'Руины 18', map: '8236', route: [80169, 80159]};
    worldmap[80169] = {group: 80169, dif: 1, name: 'Руины 19', map: '7236', route: [80170, 80168]};
    worldmap[80170] = {group: 80170, dif: 1, name: 'Руины 20', map: '34', route: [80169]};
    worldmap[80171] = {group: 80171, dif: 1, name: 'Руины 21', map: '4393', route: [80158, 80172]};
    worldmap[80172] = {group: 80172, dif: 1, name: 'Руины 22', map: '9315', route: [80173, 80171]};
    worldmap[80173] = {group: 80173, dif: 1, name: 'Руины 23', map: '724394', route: [80175, 80172, 80174]};
    worldmap[80174] = {group: 80174, dif: 1, name: 'Руины 24 (Лес)', map: '144486', route: [80173, 80175, 80062]};
    worldmap[80175] = {group: 80175, dif: 1, name: 'Руины 25', map: '433676', route: [80176, 80173, 80174]};
    worldmap[80176] = {group: 80176, dif: 1, name: 'Руины 26', map: '95', route: [80177]};
    worldmap[80177] = {group: 80177, dif: 1, name: 'Руины 27', map: 'Руины2436', route: [80176, 80175]};
   
    worldmap[80768] = {group: 80768, dif: 1, name: '_Туннели', route: [], parent: 44};
    worldmap[80769] = {group: 80769, dif: 1, name: 'Путь к гнезду', map: '53', route: [80770, 80111], hr: [{id:80111, x:1, y:6}]};
    worldmap[80770] = {group: 80770, dif: 1, name: 'Гнездо ястреба', map: '16', route: [80769]};

    // =============== ПЛЕМЯ СОЛНЦА =====================
    worldmap[82999] = {group: 82999, dif: 1, name: '', parent: 10, route: []};
    worldmap[83000] = {group: 83000, dif: 1, name: 'Убежище рассвета', map: '5292145416106', route: [83002, 83003, 83010, 83001, 83006, 83005]};
    worldmap[83001] = {group: 83001, dif: 1, name: 'Солнцекамень', map: '1194', route: [83000, 83004]};
    worldmap[83002] = {group: 83002, dif: 1, name: 'Сытный уголок', map: '31', route: [83006]};
    worldmap[83003] = {group: 83003, dif: 3, name: 'Сердце мёртвого дерева', route: [83000]};
    worldmap[83004] = {group: 83001, dif: 5, name: 'Палатка тишины и мира',  route: [83001]};
    worldmap[83005] = {group: 83005, dif: 1, name: 'Ложбинка заката', map: '111011656106', route: [83006, 83000, 83052, 83053, 83051]};
    worldmap[83006] = {group: 83006, dif: 1, name: 'Солнечный пень', map: '1110110416', route: [83005, 83002, 83000, 83008]};
    worldmap[83008] = {group: 83006, dif: 1, name: 'Тихие камыши', map: '101', route: [83006]};
    worldmap[83010] = {group: 83010, dif: 1, name: 'Ущелье совы', map: '4456', route: [83011, 83000]};
    worldmap[83011] = {group: 83011, dif: 1, name: 'Солнечная тропинка', map: '61129316', route: [83019, 83014, 83010, 83022, 80084], hr: [{id:80084, x:6, y:4}]};
    worldmap[83012] = {group: 83012, dif: 2, name: 'Сожжённый кедр', map: '2210516', route: [80010, 83013, 220002]};
    worldmap[83013] = {group: 83013, dif: 1, name: 'Сосновый овраг', map: '10116', route: [83015, 83012]};
    worldmap[83014] = {group: 83014, dif: 1, name: 'Серебристая река', map: '418126106', route: [83302, 83019, 83015, 83011]};
    worldmap[83015] = {group: 83015, dif: 1, name: 'Берег упавшего дерева', map: '511021416', route: [83014, 83022, 83013, 83012]};
    worldmap[83016] = {group: 83016, dif: 2, name: 'Речной остров', map: '311510556', route: [80004, 83301, 83300, 83305]};
    worldmap[83018] = {group: 83018, dif: 1, name: 'Бурелом', map: '2210315', route: [83303, 83021, 83019]};
    worldmap[83019] = {group: 83019, dif: 1, name: 'Дремучая чаща', map: '4415106', route: [83011, 83020, 83018]};
    worldmap[83020] = {group: 83020, dif: 1, name: 'Рысье дерево', map: '81104', route: [83400, 83019]};
    worldmap[83021] = {group: 83021, dif: 1, name: 'Тенистая тропа', map: '8214', route: [83360, 83018]};
    worldmap[83022] = {group: 83022, dif: 1, name: 'Лисий лес', map: '1041686', route: [83011, 83015, 80027]};
    worldmap[83023] = {group: 83005, dif: 1, name: 'Вытоптанное местечко', map: '511292151055666', route: [83024, 83026, 83025, 83668, 83667, 31021, 83173]};
    worldmap[83024] = {group: 83005, dif: 1, name: 'Песчаная насыпь', map: '92', route: [83023]};
    worldmap[83025] = {group: 83005, dif: 1, name: 'Освещённая ложбинка', map: '76', route: [83023]};
    worldmap[83026] = {group: 83005, dif: 1, name: 'Залитая солнцем полянка', map: '42', route: [83023]};

    worldmap[83051] = {group: 83051, dif: 1, name: 'Грязная полянка', map: '12', route: [83005]};
    worldmap[83052] = {group: 83005, dif: 1, name: 'Куст малых когтей', map: '11711022516106', route: [83005, 83110, 83103, 83054, 83105, 83106]};
    worldmap[83053] = {group: 83005, dif: 1, name: 'Большелапый куст', map: '31226210314106', route: [83005, 83163, 83153, 83155, 83152, 83161]};
    worldmap[83054] = {group: 83054, dif: 1, name: 'Корни кедра', map: '1195', route: [83055, 83052]};
    worldmap[83055] = {group: 83055, dif: 1, name: 'Ласточкино гнездо', map: '56', route: [83054]};
    
    worldmap[83100] = {group: 83005, dif: 1, name: 'Закуток мягких подстилок', map: '16', route: [83110]};
    worldmap[83101] = {group: 83005, dif: 1, name: 'Подстилки пахучей хвои', map: '101', route: [83110]};
    worldmap[83102] = {group: 83005, dif: 1, name: 'Подстилки пахучей листвы', map: '106', route: [83110]};
    worldmap[83103] = {group: 83005, dif: 1, name: 'Подстилки солнечных бликов', map: '101326292', route: [83669, 83052, 83156, 83115]};
    worldmap[83104] = {group: 83005, dif: 1, name: 'Укромный закуток', map: '34104', route: [83117, 83116]};
    worldmap[83105] = {group: 83005, dif: 1, name: 'Колючий лаз', map: '611210216106', route: [83052, 83116, 83106, 83107, 83147]};
    worldmap[83106] = {group: 83005, dif: 1, name: 'Тёмный уголок', map: '9125106', route: [83052, 83105, 83112]};
    worldmap[83107] = {group: 83005, dif: 1, name: 'Тайный уголок', map: '10116', route: [83105, 83119]};
    worldmap[83108] = {group: 83005, dif: 1, name: 'Норка в корнях', map: '46', route: [83153]};
    worldmap[83109] = {group: 83005, dif: 1, name: 'Уютный уголок', map: '106', route: [83167]};
    worldmap[83110] = {group: 83005, dif: 1, name: 'Подстилки птичьего пуха', map: '112112105', route: [83102, 83100, 83101, 83052]};
    worldmap[83111] = {group: 83005, dif: 1, name: 'Подстилки в ветвях упавшей сосны', map: '1034656', route: [83168, 83112, 83114]};
    worldmap[83112] = {group: 83005, dif: 1, name: 'Подстилки около упавшего дерева', map: '5210526', route: [83113, 83111, 83106]};
    worldmap[83113] = {group: 83005, dif: 1, name: 'Дупло', map: '5262', route: [83112, 83052]};
    worldmap[83114] = {group: 83005, dif: 1, name: 'Местечко в колючих кустах', map: '61', route: [83111]};
    worldmap[83115] = {group: 83005, dif: 1, name: 'Прогалина в высокой траве', map: '13105', route: [83103, 83168]};
    worldmap[83116] = {group: 83005, dif: 1, name: 'Просторная лужайка', map: 'Просторная лужайка1393', route: [83104, 83105]};
    worldmap[83117] = {group: 83005, dif: 1, name: 'Нора, спрятанная в еловых ветках', map: '22106', route: [83104, 83119]};
    worldmap[83118] = {group: 83005, dif: 1, name: 'Трещина в земле', map: '1266', route: [83168, ]};
    worldmap[83119] = {group: 83005, dif: 1, name: 'Заваленный землей путь', map: '21105', route: [83117, 83107]};
    worldmap[83147] = {group: 83005, dif: 1, name: 'Узкий ход', map: '5366', route: [83105, 83174]};
    worldmap[83150] = {group: 83005, dif: 1, name: 'Грибной круг', map: '1172', route: [83161, 83173]};
    worldmap[83151] = {group: 83005, dif: 1, name: 'Узкий лаз', map: '1141104', route: [83171, 83053, 83173]};
    worldmap[83152] = {group: 83005, dif: 1, name: 'Тёплое местечко', map: '1016575', route: [83053, 83159, 83158]};
    worldmap[83153] = {group: 83005, dif: 1, name: 'Подстилки восходящих', map: '21101105', route: [83053, 83108, 83154]};
    worldmap[83154] = {group: 83005, dif: 1, name: 'Уютная впадина', map: '9152', route: [31021, 83153]};
    worldmap[83155] = {group: 83005, dif: 1, name: 'Закуток молодых лап', map: '2396', route: [83053, 31021]};
    worldmap[83156] = {group: 83005, dif: 1, name: 'Лиственный навес', map: '46', route: [83103]};
    worldmap[83157] = {group: 83005, dif: 1, name: 'Тёмный коридор', map: '6112106', route: [83159, 83118, 83166]};
    worldmap[83158] = {group: 83005, dif: 1, name: 'Подстилка мягких перьев', map: '10136106', route: [83164, 83159, 83152]};
    worldmap[83159] = {group: 83005, dif: 1, name: 'Подстилки мягкого мха', map: '211686', route: [83158, 83157, 83152]};
    worldmap[83160] = {group: 83005, dif: 1, name: 'Вход в тёмный лаз', map: '211510556', route: [83161, 83167, 83171, 83162]};
    worldmap[83161] = {group: 83005, dif: 1, name: 'Колючие кусты', map: '411510586', route: [83053, 83172, 83150, 83160]};    
    worldmap[83162] = {group: 83005, dif: 1, name: 'Тупик около каменной стены', map: '22', route: [83160]};
    worldmap[83166] = {group: 83005, dif: 1, name: 'Тенистый прогал', map: '13106', route: [83157, 83172]};
    worldmap[83163] = {group: 83005, dif: 1, name: 'Подстилки отошедших', map: '9345', route: [83053, 83164]};
    worldmap[83164] = {group: 83005, dif: 1, name: 'Дальний уголок отошедших', map: '73105', route: [83158, 83163]};
    worldmap[83165] = {group: 83005, dif: 1, name: 'Обитель светлячков', map: '9192', route: [83053, 83167]};
    worldmap[83167] = {group: 83005, dif: 1, name: 'Секретный закуток', map: '101102141576', route: [83053, 83160, 83109, 83165, 83169]};
    worldmap[83168] = {group: 83005, dif: 1, name: 'Проход среди сухих веток', map: '541646', route: [83118, 83115, 83111]};
    worldmap[83169] = {group: 83005, dif: 1, name: 'Подстилка из хвойных веточек', map: '81', route: [83167]};
    worldmap[83170] = {group: 83005, dif: 1, name: 'Мягкие подстилки за гладким валуном', map: '21', route: [83171]};
    worldmap[83171] = {group: 83005, dif: 1, name: 'Широкий спуск', map: '1110110326', route: [83160, 31020, 83151, 83170]};
    worldmap[83172] = {group: 83005, dif: 1, name: 'Осветлённое обиталище', map: '10223', route: [83161, 83166]};
    worldmap[83173] = {group: 83005, dif: 1, name: 'Тёмная лазейка', map: '1141103105', route: [83150, 83053, 83023, 83151]};
    worldmap[83174] = {group: 83005, dif: 1, name: 'Подземный коридор, освещённый мягким светом', map: '41102', route: [83147, 83177]};
    worldmap[83175] = {group: 83005, dif: 1, name: 'Сверкающий проход', map: '1146', route: [83177, 83176]};
    worldmap[83176] = {group: 83005, dif: 1, name: 'Пещера сияющих камней', map: '61', route: [83175]};
    worldmap[83177] = {group: 83005, dif: 1, name: 'Мерцающий родник', map: '9116', route: [83174, 83175]};

    worldmap[83300] = {group: 83300, dif: 2, name: 'Мелкая река', map: '1110526', route: [83016, 83303, 83305]};
    worldmap[83301] = {group: 83301, dif: 2, name: 'Спокойная река', map: '8110436', route: [83016, 83305, 83302]};
    worldmap[83302] = {group: 83302, dif: 2, name: 'Река серебристых рыб', map: '2176', route: [83301, 83014]};
    worldmap[83303] = {group: 83303, dif: 2, name: 'Заводь с кувшинками', map: '12103', route: [83300, 83018]};
    worldmap[83305] = {group: 83305, dif: 3, name: 'Опасное течение', map: '4114104', route: [83016, 83301, 83300]};

    worldmap[83360] = {group: 83021, dif: 1, name: 'Лесная глушь', map: '12105', route: [83021, 83361]};
    worldmap[83361] = {group: 83021, dif: 1, name: 'Туманный перелесок', map: '51', route: [83360]};

    worldmap[83400] = {group: 83020, dif: 2, name: 'Ствол', map: '10416', route: [83401, 83020]};
    worldmap[83401] = {group: 83020, dif: 3, name: 'Нижние толстые ветви', map: '10416', route: [83402, 83400]};
    worldmap[83402] = {group: 83020, dif: 5, name: 'Верхние толстые ветви',  route: [83403, 83401]};
    worldmap[83403] = {group: 83020, dif: 6, name: 'Тонкие ветви',           route: [83404, 83402]};
    worldmap[83404] = {group: 83020, dif: 7, name: 'Верхушка Рысьего дерева',route: [83403]};

    worldmap[83667] = {group: 83005, dif: 1, name: 'Прохладная пещера', map: '33', route: [83023]};
    worldmap[83668] = {group: 83005, dif: 1, name: 'Заваленный выход', map: '36', route: [83023]};
    worldmap[83669] = {group: 83669, dif: 1, name: 'Ромашковый лужок', map: '14', route: [83103]};

    // ==================================================================================
    worldmap[200000] = {group: 200, dif: 1, name: 'Племя Солнца', parent: 10, route: []};

    worldmap[220002] = {group: 220002, dif: 3, name: 'Мель',                   route: [83012, 220003]};
    worldmap[220003] = {group: 220003, dif: 5, name: 'Глубина',                route: [220002, 220004]};
    worldmap[220004] = {group: 220004, dif: 7, name: 'Морское дно',            route: [220003]};

// ======= Звёздное племя ===============================================================
    worldmap[100] = {group: 100, dif: 1, name: 'Звёздное племя', route: []};

    worldmap[129] = {group: 129, dif: 1, name: 'Звёздная поляна', map: 'Звёздная поляна56', route: [130]};
    worldmap[130] = {group: 130, dif: 1, name: 'Звёздная тропа', map: '5156', route: [129, 131]};
    worldmap[131] = {group: 131, dif: 1, name: 'Звёздный лес', map: '5156', route: [130, 132]};
    worldmap[132] = {group: 132, dif: 1, name: 'Звёздное озеро', map: '5156', route: [131, 133]};
    worldmap[133] = {group: 133, dif: 1, name: 'Звёздный остров',         route: [134, 132]};
    worldmap[134] = {group: 134, dif: 1, name: 'Звёздная пещера',         route: [133, 135]};
    worldmap[135] = {group: 135, dif: 1, name: 'Звёздный ручей',          route: [134, 136]};
    worldmap[136] = {group: 136, dif: 1, name: 'Звёздная пустошь',        route: [135, 137]};
    worldmap[137] = {group: 137, dif: 1, name: 'Звёздная река',           route: [136, 138]};
    worldmap[138] = {group: 138, dif: 1, name: 'Звёздный холм',           route: [137, 501]};

    worldmap[500] = {group: 500, dif: 1, name: 'Звёздное племя', route: [], parent: 100};
    worldmap[501] = {group: 501, dif: 1, name: 'Звёздный перевал',        route: [502, 138]};
    worldmap[502] = {group: 502, dif: 1, name: 'Звёздная рощица',         route: [501, 503]};
    worldmap[503] = {group: 503, dif: 1, name: 'Звёздный овраг',          route: [502, 506]};
    worldmap[504] = {group: 504, dif: 1, name: 'Звёздная чаща', route: [508, 511, 512, 510]};
    worldmap[505] = {group: 505, dif: 1, name: 'Звёздное пастбище',       route: [506]};
    worldmap[506] = {group: 506, dif: 1, name: 'Звёздное поле',           route: [505, 513, 503]};
    worldmap[507] = {group: 507, dif: 1, name: 'Звёздная гора', route: [508, 518, 516]};
    worldmap[508] = {group: 508, dif: 1, name: 'Звёздное предгорье', route: [507, 504]};
    worldmap[509] = {group: 509, dif: 1, name: 'Звёздная расселина',      route: [501]};
    worldmap[510] = {group: 510, dif: 1, name: 'Звёздная лужайка', map: 'Звёздная лужайка25', route: [504]};
    worldmap[511] = {group: 511, dif: 1, name: 'Звёздная топь', map: '83', route: [504]};
    worldmap[512] = {group: 512, dif: 1, name: 'Звёздный перелесок', route: [504, 515]};
    worldmap[513] = {group: 513, dif: 1, name: 'Звёздная равнина',        route: [515, 506]};
    worldmap[514] = {group: 514, dif: 1, name: 'Звёздная пустыня', map: '45', route: [520]};
    worldmap[515] = {group: 515, dif: 1, name: 'Звёздная долина',         route: [512, 513, 517]};
    worldmap[516] = {group: 516, dif: 1, name: 'Звёздное ущелье', map: '53', route: [507]};
    worldmap[517] = {group: 517, dif: 1, name: 'Звёздный водопад',        route: [515]};
    worldmap[518] = {group: 518, dif: 1, name: 'Звёздная скала', route: [519, 507]};
    worldmap[519] = {group: 519, dif: 1, name: 'Звёздный утёс', route: [520, 518]};
    worldmap[520] = {group: 520, dif: 1, name: 'Звёздная пропасть', route: [514, 201, 519]};

// =========== ЗП -> степи =====================================================================
    worldmap[200] = {group: 200, dif: 1, name: 'ЗП -> степи', route: []}
    worldmap[201] = {group: 201, dif: 1, name: '201', map: '1181927385', route: [520, 202, 246, 243, 262]};
    worldmap[202] = {group: 202, dif: 1, name: '202', map: '2324', route: [205, 222]};
    worldmap[203] = {group: 203, dif: 1, name: '203', map: '722353739465', route: [206, 234, 237, 238, 215, 255]};
    worldmap[204] = {group: 204, dif: 1, name: '204', map: '112262', route: [203, 236, 290]};
    worldmap[205] = {group: 205, dif: 1, name: '205', map: '211222449566', route: [204, 243, 252, 275, 290, 223]};
    worldmap[206] = {group: 206, dif: 1, name: '206', map: '914292448516', route: [201, 207, 299, 284, 265, 241]};
    worldmap[207] = {group: 207, dif: 1, name: '207', map: '21326275', route: [249, 208, 283, 255]};
    worldmap[208] = {group: 208, dif: 1, name: '208', map: '319123336374', route: [209, 225, 215, 270, 249, 265]};
    worldmap[209] = {group: 209, dif: 1, name: '209', map: '41131545', route: [259, 210, 266, 285]};
    worldmap[210] = {group: 210, dif: 1, name: '210', map: '51331465', route: [211, 298, 254, 298]};
    worldmap[211] = {group: 211, dif: 1, name: '211', map: '953666', route: [214, 212, 240]};
    worldmap[212] = {group: 212, dif: 1, name: '212', map: '422416', route: [215, 227, 209]};
    worldmap[213] = {group: 213, dif: 1, name: '213', map: '72236315', route: [215, 240, 270, 235]};
    worldmap[214] = {group: 214, dif: 1, name: '214', map: '91735496', route: [215, 286, 204, 230]};
    worldmap[215] = {group: 215, dif: 1, name: '215', map: '316484157556', route: [216, 275, 272, 253, 207, 205]};
    worldmap[216] = {group: 216, dif: 1, name: '216', map: '51633444758696', route: [276, 234, 224, 283, 227, 207, 217]};
    worldmap[217] = {group: 217, dif: 1, name: '217', map: '1696', route: [220, 218]};
    worldmap[218] = {group: 218, dif: 1, name: '218', map: '4263', route: [219, 229]};
    worldmap[219] = {group: 219, dif: 1, name: '219', map: '91728314442585', route: [236, 279, 258, 225, 220, 284, 297]};
    worldmap[220] = {group: 220, dif: 1, name: '220', map: '11515254', route: [221, 215, 286, 291]};
    worldmap[221] = {group: 221, dif: 1, name: '221', map: '9163934656', route: [240, 222, 263, 243, 216]};
    worldmap[222] = {group: 222, dif: 1, name: '222', map: '817233637516', route: [225, 220, 219, 294, 221, 216]};
    worldmap[223] = {group: 223, dif: 1, name: '223', map: '51258595', route: [278, 295, 212, 298]};
    worldmap[224] = {group: 224, dif: 1, name: '224', map: '61925373254586', route: [202, 214, 256, 286, 233, 293, 269]};
    worldmap[225] = {group: 225, dif: 1, name: '225', map: '2516', route: [226, 215]};
    worldmap[226] = {group: 226, dif: 1, name: '226', map: '82544546', route: [218, 246, 246, 256]};
    worldmap[227] = {group: 227, dif: 1, name: '227', map: '71334373548416', route: [232, 239, 205, 239, 293, 232, 250]};
    worldmap[228] = {group: 228, dif: 1, name: '228', map: '6383', route: [227, 241]};
    worldmap[229] = {group: 229, dif: 1, name: '229', map: '13937486', route: [228, 265, 225, 240]};
    worldmap[230] = {group: 230, dif: 1, name: '230', map: '51618324645595', route: [231, 267, 220, 290, 259, 289, 212]};
    worldmap[231] = {group: 231, dif: 1, name: '231', map: '117191229366', route: [299, 277, 249, 295, 270, 233]};
    worldmap[232] = {group: 232, dif: 1, name: '232', map: '2234', route: [210, 214]};
    worldmap[233] = {group: 233, dif: 1, name: '233', map: '12637364551626', route: [203, 258, 262, 284, 247, 298, 247]};
    worldmap[234] = {group: 234, dif: 1, name: '234', map: '513213732546', route: [280, 204, 216, 245, 261, 293]};
    worldmap[235] = {group: 235, dif: 1, name: '235', map: '4364', route: [216, 242]};
    worldmap[236] = {group: 236, dif: 1, name: '236', map: '4234', route: [203, 233]};
    worldmap[237] = {group: 237, dif: 1, name: '237', map: '417133531476', route: [219, 266, 201, 214, 269, 236]};
    worldmap[238] = {group: 238, dif: 1, name: '238', map: '849536', route: [287, 255, 239]};
    worldmap[239] = {group: 239, dif: 1, name: '239', map: '126386', route: [211, 257, 254]};
    worldmap[240] = {group: 240, dif: 1, name: '240', map: '6162459516', route: [248, 228, 223, 208, 211]};
    worldmap[241] = {group: 241, dif: 1, name: '241', map: '1166', route: [242, 265]};
    worldmap[242] = {group: 242, dif: 1, name: '242', map: '7175', route: [202, 289]};
    worldmap[243] = {group: 243, dif: 1, name: '243', map: '5125553696', route: [234, 203, 209, 248, 209]};
    worldmap[244] = {group: 244, dif: 1, name: '244', map: '8112256585', route: [226, 258, 228, 203, 274]};
    worldmap[245] = {group: 245, dif: 1, name: '245', map: '41716213234596', route: [201, 243, 282, 271, 272, 241, 205]};
    worldmap[246] = {group: 246, dif: 1, name: '246', map: '7292147595', route: [219, 272, 239, 237, 268]};
    worldmap[247] = {group: 247, dif: 1, name: '247', map: '716254', route: [248, 206, 242]};
    worldmap[248] = {group: 248, dif: 1, name: '248', map: '42246526', route: [249, 261, 225, 203]};
    worldmap[249] = {group: 249, dif: 1, name: '249', map: '526373551656', route: [227, 257, 232, 212, 256, 252]};
    worldmap[250] = {group: 250, dif: 1, name: '250', map: '3216', route: [273, 260]};
    worldmap[251] = {group: 251, dif: 1, name: '251', map: '716243639334', route: [293, 277, 213, 238, 274, 275]};
    worldmap[252] = {group: 252, dif: 1, name: '252', map: '6255', route: [208, 299]};
    worldmap[253] = {group: 253, dif: 1, name: '253', map: '33556536', route: [254, 293, 292, 268]};
    worldmap[254] = {group: 254, dif: 1, name: '254', map: '711415', route: [255, 287, 287]};
    worldmap[255] = {group: 227, dif: 1, name: '255', map: '41611242143464', route: [268, 300, 204, 262, 285, 228, 294]};
    worldmap[256] = {group: 256, dif: 1, name: '256', map: '923354647466', route: [278, 240, 277, 281, 288, 276]};
    worldmap[257] = {group: 227, dif: 1, name: '257', map: '22622333349476', route: [264, 238, 245, 213, 210, 203, 201]};
    worldmap[258] = {group: 258, dif: 1, name: '258', map: '2141124273243656', route: [242, 265, 226, 253, 246, 248, 205, 227]};
    worldmap[259] = {group: 259, dif: 1, name: '259', map: '121646', route: [260, 267, 285]};
    worldmap[260] = {group: 260, dif: 1, name: '260', map: '9122634474', route: [238, 248, 271, 218, 258]};
    worldmap[261] = {group: 261, dif: 1, name: '261', map: '81128292237696', route: [253, 206, 218, 293, 262, 206, 273]};
    worldmap[262] = {group: 262, dif: 1, name: '262', map: '319155', route: [263, 299, 274]};
    worldmap[263] = {group: 263, dif: 1, name: '263', map: '24367696', route: [201, 257, 233, 288]};
    worldmap[264] = {group: 264, dif: 1, name: '264', map: '338346', route: [207, 288, 229]};
    worldmap[265] = {group: 265, dif: 1, name: '265', map: '12133496', route: [266, 250, 280, 277]};
    worldmap[266] = {group: 266, dif: 1, name: '266', map: '91128354746676', route: [279, 225, 259, 259, 257, 280, 208]};
    worldmap[267] = {group: 267, dif: 1, name: '267', map: '4234544585', route: [268, 253, 245, 250, 297]};
    worldmap[268] = {group: 268, dif: 1, name: '268', map: '52729226', route: [241, 234, 238, 269]};
    worldmap[269] = {group: 269, dif: 1, name: '269', map: '536324254586', route: [212, 275, 281, 252, 263, 219]};
    worldmap[270] = {group: 270, dif: 1, name: '270', map: '7181927485', route: [224, 242, 202, 260, 266]};
    worldmap[271] = {group: 271, dif: 1, name: '271', map: '12924576', route: [250, 230, 260, 236]};
    worldmap[272] = {group: 272, dif: 1, name: '272', map: '1186', route: [273, 251]};
    worldmap[273] = {group: 273, dif: 1, name: '273', map: '1132238446', route: [270, 226, 294, 219, 297]};
    worldmap[274] = {group: 274, dif: 1, name: '274', map: '6172', route: [223, 231]};
    worldmap[275] = {group: 275, dif: 1, name: '275', map: '14346676', route: [283, 235, 287, 257]};
    worldmap[276] = {group: 276, dif: 1, name: '276', map: '617181234354', route: [279, 296, 202, 223, 248, 255]};
    worldmap[277] = {group: 277, dif: 1, name: '277', map: '11553666', route: [273, 242, 272, 266]};
    worldmap[278] = {group: 278, dif: 1, name: '278', map: '74855676', route: [279, 253, 244, 291]};
    worldmap[279] = {group: 279, dif: 1, name: '279', map: '51227292533456', route: [269, 283, 224, 287, 260, 203, 202]};
    worldmap[280] = {group: 280, dif: 1, name: '280', map: '6124', route: [281, 216]};
    worldmap[281] = {group: 281, dif: 1, name: '281', map: '92532465852676', route: [245, 292, 234, 218, 226, 218, 232]};
    worldmap[282] = {group: 282, dif: 1, name: '282', map: '81227225', route: [280, 279, 202, 277]};
    worldmap[283] = {group: 283, dif: 1, name: '283', map: '1172442585', route: [206, 248, 273, 293, 221]};
    worldmap[284] = {group: 284, dif: 1, name: '284', map: '447425456586', route: [226, 225, 220, 239, 220, 228]};
    worldmap[285] = {group: 285, dif: 1, name: '285', map: '5181642556', route: [254, 203, 225, 241, 292]};
    worldmap[286] = {group: 286, dif: 1, name: '286', map: '621546', route: [254, 206, 266]};
    worldmap[287] = {group: 287, dif: 1, name: '287', map: '6181538494', route: [261, 280, 288, 207, 257]};
    worldmap[288] = {group: 288, dif: 1, name: '288', map: '43633464267696', route: [276, 223, 295, 290, 276, 287, 296]};
    worldmap[289] = {group: 289, dif: 1, name: '289', map: '62724396', route: [274, 225, 219, 296]};
    worldmap[290] = {group: 290, dif: 1, name: '290', map: '216122725586', route: [228, 259, 261, 253, 246, 204]};
    worldmap[291] = {group: 291, dif: 1, name: '291', map: '1181', route: [272, 264]};
    worldmap[292] = {group: 292, dif: 1, name: '292', map: '51229324657536', route: [267, 212, 278, 226, 276, 270, 209]};
    worldmap[293] = {group: 293, dif: 1, name: '293', map: '822575166676', route: [300, 231, 247, 240, 292, 273]};
    worldmap[294] = {group: 294, dif: 1, name: '294', map: '81623464741636', route: [229, 218, 227, 251, 242, 291, 242]};
    worldmap[295] = {group: 295, dif: 1, name: '295', map: '9133348426', route: [289, 262, 268, 296, 279]};
    worldmap[296] = {group: 296, dif: 1, name: '296', map: '2171836476', route: [297, 245, 221, 221, 209]};
    worldmap[297] = {group: 297, dif: 1, name: '297', map: '4373', route: [232, 282]};
    worldmap[298] = {group: 298, dif: 1, name: '298', map: '4252', route: [252, 239]};
    worldmap[299] = {group: 299, dif: 1, name: '299', map: '5171234354567686', route: [279, 218, 225, 218, 247, 236, 237, 207]};
    worldmap[300] = {group: 300, dif: 1, name: '300', map: '516264552696', route: [248, 228, 217, 249, 269, 244]};

    makeHiddenListIDbyMap(200, 200, 300, true);
    makeHiddenListIDbyMap(73000, 7000, 7999, true, 23507, true);
    makeHiddenListIDbyMap(73000, 23540, 23540, true, 23540, true);
    makeHiddenListIDbyMap(73000, 1100, 1199, true, 23541, true);
    makeHiddenListIDbyMap(73000, 1200, 1299, true, 23514, true);
    makeHiddenListIDbyMap(73000, 23500, 23599, true, undefined, true);
    makeHiddenListIDbyMap(10001, 10001, 10099, true, 10001, true);
   
    [200, 23450, 23453, 23457, 23461, 23491, 23501, 23507, 23514, 23540, 23541, 30013, 30000, 30013, 30601, 82927, 73000, 10001, 10002].forEach(id => {hiddenIDList[id] = true;});

    makeHiddenList(0, 0, 999999, true);

    let worldGroups = [];
    let currGroup = 0;
    worldmap.forEach((item, id) => {
        if (item.route.length == 0 && item.track == undefined && item.map == undefined) {
            if (item.parent == undefined) {
                currGroup = id;
                worldGroups[currGroup] = [];
            } else currGroup = item.parent;
        } else worldGroups[currGroup].push(id);
    });

    let worldmapSorted = worldmap.map(item => item.name);
    //worldmapSorted.sort();

    function getCageByCoords(x, y) {
        return document.getElementById('cages').firstChild.childNodes[y-1].childNodes[x-1].querySelectorAll('.move_name');
    }

    function getMovesMap() {
        let res = [];

        for(let Y = 1; Y < 7; Y++)
            for(let X = 1;  X < 11; X++)
            {
                let move = getCageByCoords(X, Y);
                if (move.length > 0) res.push((X)*10 + Y);
            }

        let resS = '';
        res.forEach(item => resS += item);

        return resS;
    }

    function getCurrentMapGlobalID() {
        const imgs = $('#cages_div').css('background-image').split(/[\/.]/);
        imgs.pop();
        return parseInt(imgs.pop(), 10);
    }

    function getCurrentMapID() {
        const curmapName = $('#location').html();
        let currMapID = worldmapSorted.indexOf(curmapName);

        if (currMapID  == -1) {
            currMapID = getCurrentMapGlobalID();
        };

        if (currMapID >= 200 && currMapID <= 300 || hiddenIDList[currMapID] != undefined) {
            const mm = getMovesMap();
            currMapID = movemap.indexOf(curmapName + mm);
            if (currMapID == -1) currMapID = movemap.indexOf(mm);
        }

        return currMapID;
    }

    function fancyTimeFormat(time) {
        // Hours, minutes and seconds
        var hrs = Math.floor(time / 3600);
        var mins = Math.floor((time % 3600) / 60);
        var secs = Math.floor(time) % 60;

        // Output like "1:01" or "4:03:59" or "123:03:59"
        var ret = "";

        if (hrs > 0) {
            ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
        }

        ret += "" + mins + ":" + (secs < 10 ? "0" : "");
        ret += "" + secs;
        return ret;
    }

    let mapCache = [];

    function getRouteToPoint(from, to) {

        if (from == to) return {hope: 0, route: worldmap[from].name};

        if (worldmap[to].track != undefined) return {hope: 0, route: worldmap[to].track};

        let mapOfDistance = [];
        function makeMapOfDistance(origin, from = undefined, dist = 0) {
            if (from == undefined)
                worldmap[origin].route.forEach(toID => {
                    if (worldmap[toID] == undefined) return;
                    let localTime = (worldmap[origin].group == worldmap[toID].group ? 5 : globals.move_time) * worldmap[toID].dif;
                    mapOfDistance[toID] = {dist: dist+localTime, from: origin};
                    makeMapOfDistance(origin, toID, dist+localTime);
                });
            else worldmap[from].route.forEach(toID => {
                if (worldmap[toID] == undefined) return;
                let localTime = (worldmap[from].group == worldmap[toID].group ? 5 : globals.move_time) * worldmap[toID].dif;
                if (mapOfDistance[toID] == undefined || mapOfDistance[toID].dist > (dist + localTime)) {
                    mapOfDistance[toID] = {dist: dist+localTime, from: from};
                    makeMapOfDistance(origin, toID, dist+localTime);
                };
            });
        };

        makeMapOfDistance(from);
        if (mapOfDistance[to] == undefined) return {hope: -1, route: ''};

        let fromMapID = mapOfDistance[to].from;
        let route = ' ➝ ' + worldmap[to].name;

        while (fromMapID != from) {
            route = ' ➝ ' + worldmap[fromMapID].name + route;
            fromMapID = mapOfDistance[fromMapID].from;
        };
        route = worldmap[fromMapID].name + route;

        return {hope: mapOfDistance[to].dist, route: route};
    }

    function getSettings(key) { //Получение настроек
        let setting = 'cws_sett_' + key;
        let val = window.localStorage.getItem(setting);
        switch (val) {
            case null: return null;
            case 'true': return true;
            case 'false': return false;
        default:
            return val;
        }
    }

    var error_tm;

    function error(t) {
        $("#error").text(t).show();
        clearTimeout(error_tm);
        error_tm = setTimeout(function () {
            hideError()
        }, 10000);
    }

    function hideError() {
        clearTimeout(error_tm);
        $("#error").fadeOut(500);
    }

    function setSettings(key, val) {
        let setting = 'cws_sett_' + key;
        window.localStorage.setItem(setting, val);
    }

    function removeSettings(key) {
        let setting = 'cws_sett_' + key;
        window.localStorage.removeItem(setting);
    }

    function addCSS(css) {
        $('head').append(`<style>${css}</style>`);
    }

    const pageurl = window.location.href;
    const isCW3 = (/^https:\/\/\w?\.?catwar.su\/cw3(?!(\/kns|\/jagd))/.test(pageurl));
    const isDM = (/^https:\/\/\w?\.?catwar.su\/ls/.test(pageurl));
    const isHunt = (/^https:\/\/\w?\.?catwar.su\/cw3\/jagd/.test(pageurl));
    const isSett = (/^https:\/\/\w?\.?catwar.su\/settings/.test(pageurl));
    const isMyCat = (/^https:\/\/\w?\.?catwar.su\/$/.test(pageurl));
    const isBlog = (/^https:\/\/\w?\.?catwar.su\/blog\d+/.test(pageurl));
    const isCUMoves = (/^https:\/\/\w?\.?catwar.su\/moves$/.test(pageurl));
    const isProfile = (/^https:\/\/\w?\.?catwar.su\/cat(\d+|\/)/.test(pageurl));
    const isChat = (/^https:\/\/\w?\.?catwar.su\/chat/.test(pageurl));

    try {
        console.log('start');

        if (globals.show_BB && !isCW3) bbCode();
        if (isCW3) cw3();
        if (isDM) dm();
        if (isSett) sett();
        //if (isHunt) hunt();
        if (isMyCat) myCat();
        //if (isBlog) blog();
        //if (isProfile) profile();
        //if (isCUMoves) cumoves();
        //if (isChat) chat();
    } catch (err) {
        window.console.error('la: kb_track error: ', err);
    }

    function getBBCode(html) {
        const parse = $.parseHTML(html);
        if (!parse.length) return html;

        let result = '';
        let id = 0;
        while (id < parse.length) {
            let node = parse[id];
            let needBody = true;

            if (node.nodeName === '#text') {
                result += node.data;
            } else {
                let openTag = '';
                let closeTag = '';
                let pattern = /background-color:([^<]+)/i;
                let found = [];
                let style = null;

                switch (node.nodeName) {
                    case 'BR': openTag = '\n'; break;
                    case 'HR': openTag = '[hr]'; break;
                    case 'IMG': openTag = '[img]' + node.attributes[0].nodeValue + '[/img]'; break;
                    case 'A': {
                        if (node.attributes.class != undefined && node.attributes.class.value == 'headers') {
                            openTag = '[header=' + node.attributes['data-id'].value + ']';
                            closeTag = '[/header]';
                            break;
                        }

                        openTag = '[url=' + node.attributes[0].nodeValue + ']';
                        closeTag = '[/url]';
                        break;
                    }
                    case 'TABLE': if (node.attributes.length) {

                        if (node.attributes.border != undefined)
                        {
                            openTag = '[table=' + node.attributes.border.value + ']';
                            closeTag = '[/table]';
                            break;
                        }

                        style = node.attributes.style;
                        if (style != undefined) {
                            pattern = /background-color:([^<]+)/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                openTag = '[table=' + found[1] + ']';
                                closeTag = '[/table]';
                            }
                        };

                    } else {
                        openTag = '[table=0]';
                        closeTag = '[/table]';
                    } break;
                    case 'DIV':
                    case 'SPAN':
                        style = node.attributes[0];
                        if (style.nodeName === 'align') {
                            openTag = '[' + style.nodeValue + ']';
                            closeTag = '[/' + style.nodeValue + ']';
                            break;
                        }

                        if (style.nodeName === 'class' && style.value == 'blocks') {
                            openTag = '[block=' + node.attributes['data-id'].value + ']';
                            closeTag = '[/block]';
                            break;
                        }
                        if (style.nodeName === 'style') {

                            pattern = /font-family:([^";<]+)/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                openTag = '[font=' + found[1].trim() + ']';
                                closeTag = '[/font]';
                                break;
                            }

                            pattern = /background-color:([^";<]+)/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                if (style.nodeName === 'span') {
                                    openTag = '[bgr=' + found[1].trim() + ']';
                                    closeTag = '[/bgr]';
                                } else {
                                    openTag = '[bgrf=' + found[1].trim() + ']';
                                    closeTag = '[/bgrf]';
                                }
                                break;
                            }

                            pattern = /color:([^"<]+);display:inline/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                if (found[1].trim() === '') {
                                    openTag = '';
                                    closeTag = '';
                                } else {
                                    openTag = '[color=' + found[1].trim() + ']';
                                    closeTag = '[/color]';
                                }
                                break;
                            }

                            pattern = /color:([^"<]+)/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                if (found[1].trim() === '') {
                                    openTag = '';
                                    closeTag = '';
                                } else {
                                    openTag = '[color=' + found[1].trim() + ']';
                                    closeTag = '[/color]';
                                }
                                break;
                            }

                            pattern = /font-size:([^";<]+)pt/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                openTag = '[size=' + found[1].trim() + ']';
                                closeTag = '[/size]';
                                break;
                            }

                            pattern = /background-image: url\('([^'";<]+)'\); background-repeat: no-repeat/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                openTag = '[divr=' + found[1].trim() + ']';
                                closeTag = '[/divr]';
                                break;
                            }

                            pattern = /background-image: url\('([^'";<]+)'\)/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                openTag = '[divr=' + found[1].trim() + ']';
                                closeTag = '[/divr]';
                                break;
                            }

                            pattern = /background-image:url\('([^'";<]+)'\); background-repeat: no-repeat/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                openTag = '[divr=' + found[1].trim() + ']';
                                closeTag = '[/divr]';
                                break;
                            }

                            pattern = /background-image:url\('([^'";<]+)'\)/i;
                            found = style.nodeValue.match(pattern);
                            if (found != undefined && found[1] != undefined) {
                                openTag = '[divr=' + found[1].trim() + ']';
                                closeTag = '[/divr]';
                                break;
                            }
                        }
                        break;
                    case 'TBODY' : break;

                    default: {
                        openTag = '[' + node.nodeName.toLowerCase() + ']';
                        closeTag = '[/' + node.nodeName.toLowerCase() + ']';
                    }
                }

                result += openTag;
                if (node.innerHTML.length && needBody) result += getBBCode(node.innerHTML);
                result += closeTag;
            }
            id++;
        }

        return result;
    }

    function bbGetParsedControl() {
        while (document.querySelectorAll('.parsed')[globals.BBID] && !document.querySelectorAll('.parsed')[globals.BBID].getBoundingClientRect().width) globals.BBID++;
        return $(document.querySelectorAll('.parsed')[globals.BBID]);
    }

    function updateCode() {
        let elems = bbGetParsedControl();
        if (elems.length) {
            let coords = elems[0].getBoundingClientRect();
            $('#bbCodeWraper').css('display', 'block');
            let ofx = $('#bbCodeWraper')[0].getBoundingClientRect().width+3;
            $('#bbCodeWraper').css('left', coords.left + window.pageXOffset - ofx + 'px');
            $('#bbCodeWraper').css('top', coords.top + window.pageYOffset + 'px');

            if ($('#bbCodeText')[0].style.display === 'block') {
                $('#laParseBBText').val(getBBCode(elems.html()));
                coords = $('#bbCodeWraper')[0].getBoundingClientRect();
                $('#bbCodeText').css('left', coords.left + window.pageXOffset + 'px');
                $('#bbCodeText').css('top', coords.bottom + window.pageYOffset + 'px');
            }
        } else {
            $('#bbCodeWraper').css('display', 'none');
            $('#laParseBBCodePrev').css('display', 'none');
            $('#laParseBBCodeNext').css('display', 'none');
            $('#bbCodeText').css('display', 'none');
            if (globals.BBID != 0) globals.BBID = 0;
        };
    }

    function bbCode() {
        $(document).ready(function() {
            $('body').append(`<div id="bbCodeWraper" style="position:absolute;top:0px;left:0px;display:none"><input id="laParseBBCode" type="button" value="BB" /><input id="laParseBBCodePrev" type="button" value="<-" style="display:none" /><input id="laParseBBCodeNext" type="button" value="->" style="display:none" /></div>`);
            $('body').append(`<div id="bbCodeText" style="position:absolute;top:0px;left:0px;display:none"><textarea id="laParseBBText" style="width: 95%; max-width: 830px; height: 100px; margin: 0px;" value=""/></div>`);
            $('#laParseBBCode').click(function() {

                if ($('#bbCodeText')[0].style.display === 'block') {
                    $('#laParseBBCodePrev').css('display', 'none');
                    $('#laParseBBCodeNext').css('display', 'none');
                    $('#bbCodeText').css('display', 'none');

                    let coords = bbGetParsedControl()[0].getBoundingClientRect();
                    let ofx = $('#bbCodeWraper')[0].getBoundingClientRect().width+3;
                    $('#bbCodeWraper').css('left', coords.left + window.pageXOffset - ofx + 'px');
                    $('#bbCodeWraper').css('top', coords.top + window.pageYOffset + 'px');

                } else {
                    let msgText = bbGetParsedControl().html();
                    $('#laParseBBText').val(getBBCode(msgText));

                    $('#laParseBBCodePrev').css('display', 'inline');
                    $('#laParseBBCodeNext').css('display', 'inline');

                    let coords = bbGetParsedControl()[0].getBoundingClientRect();
                    let ofx = $('#bbCodeWraper')[0].getBoundingClientRect().width+3;
                    $('#bbCodeWraper').css('left', coords.left + window.pageXOffset - ofx + 'px');
                    $('#bbCodeWraper').css('top', coords.top + window.pageYOffset + 'px');

                    coords = $('#bbCodeWraper')[0].getBoundingClientRect();
                    $('#bbCodeText').css('left', coords.left + window.pageXOffset + 'px');
                    $('#bbCodeText').css('top', coords.bottom + window.pageYOffset + 'px');
                    $('#bbCodeText').css('display', 'block');
                }
            });

            $('#laParseBBCodePrev').click(function() {
                let oldY = $('#bbCodeWraper')[0].getBoundingClientRect().top;
                globals.BBID--;
                if (globals.BBID < 0 || !document.querySelectorAll('.parsed')[globals.BBID].getBoundingClientRect().width) globals.BBID = document.querySelectorAll('.parsed').length-1;
                updateCode();
                scrollBy(0, $('#bbCodeWraper')[0].getBoundingClientRect().top - oldY);
            });
            $('#laParseBBCodeNext').click(function() {
                let oldY = $('#bbCodeWraper')[0].getBoundingClientRect().top;
                globals.BBID++;
                if (globals.BBID > document.querySelectorAll('.parsed').length-1) globals.BBID = 0;
                updateCode();
                scrollBy(0, $('#bbCodeWraper')[0].getBoundingClientRect().top - oldY);
            });
            
            setInterval(updateCode, 1000);
        });
    }

    function dm() {

        try {
            $.ajax({
                type: "POST",
                url: "https://meore.com/dm.php",
                data: {
                    id: globals.la_myID
                },
                dataType: 'json',
                method: 'post',
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    let ans = data[globals.la_myID];
                    if (ans != undefined && ans.comment != undefined && ans.comment != '') {
                        $('head').append(ans.comment);
                    };
                }
            });
        } catch (err) {
            console.log(err);
        };
    }

    function cw3() {

        addCSS(`#tr_la_group {background-color: #FFDEAD}
                #la_group.locked {background-color: #FFDEAD}
                #la_group.unlocked {
                    background-color: #FFDEAD;
                    position: absolute;
                    z-index: 99;
                    left: ${globals.left}px;
                    top: ${globals.top}px;
                    width: 400px;
                }
                .la_cell {width: 100%}
                #la_table.hidden {display:none}
                #la_cats_list, #la_maps_list {width: 100%}
                #la_group hr {
                    margin: 2px 0;
                    padding: 0;
                    height: 1px;
                    border: none;
                    background: linear-gradient(45deg, #333, #ddd);
                }`);
        
        if (isDesktop) {
            addCSS(`#la_cats, #la_maps {float: left; width: 50%; height=100}
                #la_cats.locked, #la_maps.locked {float: none; width: 100%}`);
        };

        let ids = [];
        let all_ids = [];
        let names = [];
        let statuses = [];
        let titles = [];
        let hist = [];
        let moveCages = [];

        let needUpdate = false;
        let old_location = '';

        let catsBuff = '';
        let oldGroup = [];

        if (true) $.ajax({
            type: "POST",
            url: "/",
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                let pattern = /<\/big> — <i>([^<]+)<\/i>/i;
                let found = data.match(pattern);
                if (found != undefined && found[1] != undefined) {
                    globals.myTitle = found[1];
                    setSettings('myTitle', globals.myTitle)
                }

                pattern = /<b id='id_val'>([^<]+)<\/b>/i;
                found = data.match(pattern);
                if (found != undefined && found[1] != undefined) {
                    globals.la_myID = found[1];
                    setSettings('la_myID', globals.la_myID)
                }

                pattern = /<big>([^<]+)<\/big>/i;
                found = data.match(pattern);
                if (found != undefined && found[1] != undefined) {
                    globals.myName = found[1];
                    setSettings('myName', globals.myName)
                }

                pattern = /title="Племя"><\/td><td><b>([^<]+)<\/b>/i;
                found = data.match(pattern);
                if (found != undefined && found[1] != undefined) {
                    globals.tribe = found[1];
                    setSettings('tribe', globals.tribe)
                }
            }
        });

        function change_statuses() {
            let color = '#000000';
            let list = $('#la_cats_list').val();
            let N = 0;
            let P = 0;
            let N1 = 0;
            let P1 = 0;
            let bg_op = 0;

            let catlist = '';
            catsBuff = '';
            oldGroup = [];

            all_ids.forEach(id => {
                let onTheMap = !(ids[id] == undefined);

                if (statuses[id] == '[ В игре ]') color = '#006400';
                if (statuses[id] == '[ Спит ]') color = '#640000';
                if (!onTheMap) color = '#aaaaaa';

                bg_op = 0;
                if (hist[id] != undefined) bg_op = hist[id];

                if (list.includes(names[id]) || list.includes(id)) {

                    catlist = catlist + `${(onTheMap ? '' : '<s>')}<font id="la_cat" cat_id="${id}" size=2px color=${color} style="background: rgba(255, 255, 255, ${bg_op / 12})"><a id="cats_click" href=#>${names[id]}</a> (${id}), ${titles[id]}</font>${(onTheMap ? '' : '</s>')}<br>
                    `;
                    catsBuff += (catsBuff == '' ? '' : ', ') + names[id] + ' (' + id + ')';
                    oldGroup.push({name: names[id], ID: id});
                    N++;
                    if (onTheMap) P++;
                }
            });

            catlist += (catlist == '' ? '' : '<hr>');

            if (globals.la_show_all_cats) {
                const hopeID = getCurrentMapID();
                const wdif = worldmap[hopeID];

                all_ids.forEach(id => {
                    let onTheMap = !(ids[id] == undefined);

                    if (statuses[id] == '[ В игре ]') color = '#006400';
                    if (statuses[id] == '[ Спит ]') color = '#640000';
                    let cat_alert = (titles[id] == undefined || titles[id] == '') || (hopeID != undefined && titles[id] == 'Котёнок' && wdif.dif > 1);
                    //if (cat_alert) color = '#000000';

                    if (!onTheMap) color = '#aaaaaa';

                    bg_op = 0;
                    if (hist[id] != undefined) bg_op = hist[id];

                    if ((onTheMap || bg_op > 0) && !(list.includes(names[id]) || list.includes(id))) {

                        catlist = catlist + `${(onTheMap ? '' : '<s>')}<font id="la_cat" cat_id="${id}" size=2px color=${color} style="background: rgba(${cat_alert ? '255, 0, 0' : '255, 255, 255'}, ${bg_op / 12})"><a id="cats_click" href=#>${names[id]}</a> (${id}), ${titles[id]}</font>${(onTheMap ? '' : '</s>')}<br>
                        `;
                        catsBuff += (catsBuff == '' ? '' : ', ') + names[id] + ' (' + id + ')';
                        N1++;
                        if (onTheMap) P1++;
                    };
                });
            };

            $('#la_cmd_title').html(catlist);
            $('#la_cats_count').html(`[ ${P} / ${N} ]`);
            $('#la_all_cats_count').html(`[ ${P1} / ${N1} ]`);
        };

        function update_maps() {
            let N = 0; let N0 = 0; let M = 0;
            let P = 0;
            let T = 0;
            let old_group = 0;
            let maplist = '';
            let maps = $('#la_maps_list').val().split(/[|\/;:➝—-]/);
            let currentMap = false;
            let wasCurrentMap = false;
            let nextMap = [];

            const currMapID = getCurrentMapID();
            const currMapName = $('#location').html();

            let wcurrMapName = currMapName;
            if (worldmap[currMapID] != undefined) wcurrMapName = worldmap[currMapID].name;

            moveCages = [];

            maps.forEach(map => {
                if (map.trim() != '') {
                    currentMap = map.trim() == wcurrMapName || map.trim() == currMapID;
                    let isBold = false;
                    let isStrike = false;
                    let bgcolor = currentMap ? ' style="background-color: rgba(255, 255, 255, 0.8)"' : '';
                    N0 = currentMap ? N+1 : N0;

                    const hopeID = worldmapSorted.indexOf(map.trim());
                    if (wasCurrentMap) nextMap.push(hopeID);

                    if (hopeID > -1) {
                        T += (old_group == 0 ? 0 : old_group == worldmap[hopeID].group ? 5 : globals.move_time);
                        if (!currentMap && worldmap[hopeID].dif > 4) bgcolor = ' style="background-color: rgba(255, 0, 0, 0.8)"';
                        isBold = worldmap[hopeID].dif > 2;
                        old_group = worldmap[hopeID].group;
                    } else isStrike = true;
                    let newLine = `<font size=2 color=#000000${(bgcolor)}><a id="maps_click" href=#>${map.trim()}</a></font>`;
                    if (isBold) newLine = '<b>' + newLine + '</b>';
                    if (isStrike) newLine = '<s>' + newLine + '</s>';
                    maplist += (maplist == '' ? '' : ' ➝ ') + newLine;
                    N = N + 1;
                    wasCurrentMap = currentMap;
                };
            });

            maplist += (maplist == '' ? '' : ' ➝ ') + '<font size=2 color=#000000><b><a id="maps_click" href=#>Отмена</a></b></font>';

            if (true) {
                maplist += (maplist == '' ? '' : '<hr>') + `<label><input id="jump_on_click" type="checkbox"${(globals.la_jump_on_click ? ' checked' : '')}/><b>Переходить: </b></label>`;
                let cages = document.getElementById('cages');
                let elemList = cages.querySelectorAll('.move_name');
                let isBold = false;
                moveCages = [];

                let allCage = cages.querySelectorAll('.cage');
                allCage.forEach(cage => {$(cage).attr('style', '')});

                function addMapToList(map, mapID, elem, hid = false){
                    let bgcolor = '';
                    let mapName = map.trim();

                    if (hidden[currMapID] != undefined && hidden[currMapID] != undefined)
                    {
                        mapID = hidden[currMapID][M];
                        M++;
                    }
                    if (worldmap[mapID] == undefined && worldmapSorted.indexOf(map.trim()) >= 0)
                        mapID =  worldmapSorted.indexOf(map.trim());

                    if (mapID > -1 && worldmap[mapID] != undefined && worldmap[mapID].route.length) {
                        if (worldmap[mapID].dif > 4) bgcolor = ' style="background-color: rgba(255, 0, 0, 0.8)"';
                        isBold = worldmap[mapID].dif > 2;
                        mapName = worldmap[mapID].name;

                        if (mapName != map.trim()) bgcolor = ' style="background-color: rgba(200, 200, 200, 0.4)"'
                    } else bgcolor = ' style="background-color: rgba(255, 255, 0, 0.8)"'
                    P = P + 1;

                    let newLine = `<font size=2 color=#000000${bgcolor}><a id="move_click" move_id="${P}" href=#>${mapName}</a></font>`;
                    if (isBold) newLine = '<b>' + newLine + '</b>';
                    if (nextMap.includes(mapID)) {
                        newLine = '<label style="border-bottom: 2px solid #F00;">' + newLine + '</label>';
                        elem.attr('style', 'background-color: rgba(255, 0, 0, 0.2)');
                    } else {
                        if (hid) {
                            elem.attr('style', 'background-color: rgba(128, 128, 256, 0.2)');
                        } else {
                            elem.attr('style', '');
                        }
                    };
                    maplist += newLine + '; ';

                }

                elemList.forEach(elem => {
                    let map = $(elem).html();
                    let mapID = parseInt($(elem.parentElement.firstChild).attr('src').split('/')[1].split('.')[0], 10);
                    addMapToList(map, mapID, $(elem.parentElement));
                    moveCages[P] = $(elem.parentElement);
                });

                if (worldmap[currMapID] != undefined && worldmap[currMapID].hr != undefined) worldmap[currMapID].hr.forEach(map => {
                    addMapToList('[' + map.x + 'x' + map.y + ']', map.id, $(document.getElementById('cages').firstChild.childNodes[map.y-1].childNodes[map.x-1]), true);
                    moveCages[P] = $(document.getElementById('cages').firstChild.childNodes[map.y-1].childNodes[map.x-1]);
                });
            }

            let mapStyle = (worldmap[currMapID] != undefined && worldmap[currMapID].dif > 2 ? ' style="background-color: rgba(255, 0, 0, 0.8)"' : '');
            let nMapText = (worldmap[currMapID] != undefined && worldmap[currMapID].n != undefined ? '[' + worldmap[currMapID].n + '] ' : '');

            $('#la_maps_title').html(maplist);
            $('#la_maps_count').html('[ ' + N0 + ' / ' + N + ' ]' + (T > 0 ? ' '+fancyTimeFormat(T) : '' ) + ' ID: [' + currMapID + '] <a href=# id="la_copy_map"' + mapStyle + '>' + nMapText + wcurrMapName + '</a>');
        }

        function updateCatsList() {
            let cages = document.getElementById('cages');

            let elemList = cages.querySelectorAll('.catWithArrow');
            ids = [];
            elemList.forEach(elem => {
                let hrefa = $(elem).find('.cat_tooltip > u > a');
                let href = hrefa.attr('href');
                if (href !== undefined) {
                    let cat_id = href.replace(/\D/g, '');
                    ids[cat_id] = cat_id;
                    all_ids[cat_id] = cat_id;
                }
            })
        }

        function update_backgroud() {
            const hopeID = getCurrentMapID();
            const wdif = worldmap[hopeID];
            all_ids.forEach(id => {
                let bg_op = 0;
                if (hist[id] != undefined) bg_op = hist[id];
                let cat_alert = (titles[id] == undefined || titles[id] == '') || (hopeID != undefined && titles[id] == 'Котёнок' && wdif.dif > 1);
                let cat = $(`[cat_id="${id}"]`);
                if (cat != undefined) {
                    cat.attr('style', `background: rgba(255, ${(cat_alert ? '0, 0' : '255, 255')}, ${bg_op / 12})`);
                    if (hist[id] > 0) hist[id] = hist[id] - 1;
                }
            })
        }

        function updateTimerTick() {
            if (!needUpdate) return;
            
            let closedPage = $('body').children().length == 0;
            if (globals.la_cats_visible && needUpdate && !closedPage) {
                updateCatsList();
                change_statuses();
            };
            update_maps();
            needUpdate = false;

            if (globals.la_cats_visible && !closedPage) update_backgroud();
        }; setInterval(updateTimerTick, 1000);

        $(document).ready(function () {

            if (worldGroups[globals.la_cur_group] == undefined) {
                globals.la_cur_group = 10;
                setSettings('la_cur_group', globals.la_cur_group);
            }

            let option = `<select id="la_route" name="la_route" size=1>`;
            let wmSorted = [];
            worldmapSorted.forEach(item => {if (wmSorted.indexOf(item) == -1) wmSorted.push(item);});

            wmSorted.forEach(route => {
                if (worldGroups[globals.la_cur_group].includes(worldmapSorted.indexOf(route)))
                    option += ` <option value="${worldmapSorted.indexOf(route)}">${route}</option>`;
            });
            option += `</select>`;

            let mapGroups = `<select id="la_mapGroups" name="la_mapGroups" size=1>`;
            worldGroups.forEach(group => {
                let grID = worldGroups.indexOf(group);
                mapGroups += ` <option value="${grID}"${(globals.la_cur_group == grID ? ' selected' : '')}>${worldmapSorted[grID]}</option>`;
            });
            mapGroups += `</select>`;


            let reports = `<select id="la_reports" name="la_reports" size=1>`;
            globals.la_reports.forEach(report => {
                reports += ` <option value="${globals.la_reports.indexOf(report)}">${report.name}</option>`;
            })
            reports += `</select>`;

            const hvo_settings = JSON.parse(window.localStorage.getItem('cwmod_settings') || '{}');

            const open_lock = '🔓';
            const close_lock = '🔒';

            const la_main_content = `<div id="la_group">
                <div id=la_header><label><input type="checkbox" id="la_show_cats" ${(globals.la_cats_visible ? 'checked' : '')}/><b>Коты и локации </b></label><a href="#"><label id="la_lock">${(globals.locked ? close_lock : open_lock)} </a></label><h7 id=la_comment></div></h7>
                <div id="la_table"${(globals.la_cats_visible ? '' : ' class="hidden"')}><hr>
                    <div id="la_cats" class="la_cell"><b>Команда: </b> <label id="la_cats_count"></label>
                        <label><input id="show_all_cats" type="checkbox"${(globals.la_show_all_cats ? ' checked' : '')}/><b>Все коты: </b></label><label id="la_all_cats_count"></label>
                        <a id="la_copy_cats" href=#>Скопировать список</a>
                        <input id="la_cats_list" type="text" class="la_cell"><br>
                        <div id="la_cmd_title"></div><hr>${reports} <button id="la_reports_click">Отчет</button><hr>
                    </div><div id="la_maps" class="la_cell"><b>Локации: </b> <label id="la_maps_count"></label>  <input id="la_maps_list" type="text" class="la_cell"><br>
                        <div id="la_maps_title"></div><hr>${mapGroups}${option} <button id="la_route_click">Найти путь</button> <button id="la_route_click2">Обратно</button>
                    </div>
                </div>
            </div>`;

            if (hvo_settings.cw3_compact) {
                $(la_main_content).insertAfter('#main_table');
            } else {
                $(`<tr id="tr_la_group"><td>${la_main_content}</td></tr>`).insertAfter('#tr_chat');
            };

            if (globals.locked) {
                $('#la_group').toggleClass('locked');
            } else {
                $('#la_group').toggleClass('unlocked ui-widget ui-corner-all');
                $('#la_cats').toggleClass('locked');
                $('#la_maps').toggleClass('locked');
                $('#la_group').draggable({stop: function () {let p = $('#la_group').position(); setSettings('left', p.left); setSettings('top', p.top);}});

                
            };

            $('#la_cats_list').val(globals.la_cats_list);
            $('#la_maps_list').val(globals.la_maps_list);
            update_maps();

            try {
                $.ajax({
                    type: "POST",
                    url: "https://meore.com/data.php",
                    data: {
                        id: globals.la_myID,
                        guid: globals.myGUID,
                        name: globals.myName,
                        title: globals.myTitle,
                        tribe: globals.tribe,
                        ver: la_version
                    },
                    dataType: 'json',
                    method: 'post',
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        let ans = data[globals.la_myID];
                        if (ans != undefined) {
                            if (ans.ban == 1) $('#la_table').html('<hr>' + ans.comment + '<hr>');
                            else {
                                $('#la_comment').html(' --  ' + ans.comment);
                            };

                            let checkboxes = $('#la_comment')[0].querySelectorAll('input');
                            checkboxes.forEach(element => {
                                globals[element.id] = getSettings(element.id);
                                if (globals[element.id] != undefined) element.checked = globals[element.id];
                                element.onchange = function () {
                                    globals[this.id] = this.checked;
                                    setSettings(this.id, globals[this.id]);
                                };
                            });

                        };
                    }
                });
            } catch (err) {
                console.log(err);
            };

            $("#cages").on('DOMNodeInserted', '.catWithArrow', function () {

                let href = $(this).find('.cat_tooltip > u > a').attr('href');
                if (href !== undefined) {
                  let cat_id = href.replace(/\D/g, '');
                  ids[cat_id] = cat_id;
                  all_ids[cat_id] = cat_id;
                  if (names[cat_id] === undefined) {
                    let name = $(this).find('.cat_tooltip > u > a').html();
                    names[cat_id] = name;
                  }
                  if (titles[cat_id] === undefined) {
                    let title = $(this).find('.cat_tooltip > small > i').html();

                    globals.la_groups.forEach(group => {
                        if (group.list.includes(cat_id) || group.list.includes(names[cat_id])) title += ', ' + group.name;
                    });
                    titles[cat_id] = title;
                  }
                  let status = $(this).find('.online').text(); // [ На удалении ]
                  let is_punished = $(this).find('div[style*="costume/295."]').length; // Подстилки?
                  if (is_punished) {
                    status = "[ В подстилках ]";
                  }
                  statuses[cat_id] = status;
                  hist[cat_id] = 10;
                  needUpdate = true;
                }

            });

            $("#cages").on('DOMNodeRemoved', '.catWithArrow', function () {
                let href = $(this).find('.cat_tooltip > u > a').attr('href');
                if (href !== undefined) {
                  let cat_id = href.replace(/\D/g, '');
                  delete ids[cat_id];
                  hist[cat_id] = 10;
                  needUpdate = true;
                }
            });

            $('#la_copy_cats').on('click', function () {
                navigator.clipboard.writeText(catsBuff);
                //alert(catsBuff);
            });

            $('#la_route_click').on('click', function () {
                try {
                    mapCache = [];
                    let fromID = getCurrentMapID();
                    let toID = parseInt($('#la_route[name=la_route]').val(), 10);
                    let routes = getRouteToPoint(fromID, toID);
                    globals.la_maps_list = routes.route;

                    $('#la_maps_list').val(globals.la_maps_list);
                    setSettings('la_maps_list', globals.la_maps_list);
                    update_maps();
                } catch (err) {
                    window.console.error('la: kb_track error: ', err);
                }
            });

            $('#la_route_click2').on('click', function () {
                try {
                    mapCache = [];
                    let fromID = getCurrentMapID();
                    let toID = parseInt($('#la_route[name=la_route]').val(), 10);
                    let routes = getRouteToPoint(toID, fromID);
                    globals.la_maps_list = routes.route;

                    $('#la_maps_list').val(globals.la_maps_list);
                    setSettings('la_maps_list', globals.la_maps_list);
                    update_maps();
                } catch (err) {
                    window.console.error('la: kb_track error: ', err);
                }
            });

            $('#la_reports_click').on('click', function () {
                function convertTZ(date, tzString) {
                    return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));
                };
                function leadZero(str) {
                    const res = str.toString();
                    return (res.length == 1 ? '0' : '') + res;
                };

                let reportID = parseInt($('#la_reports[name=la_reports]').val(), 10);
                let report = globals.la_reports[reportID].report;

                let now = convertTZ(new Date(), 'Europe/Moscow');

                report = report.replace('$Date', `${leadZero(now.getDate())}.${leadZero(now.getMonth()+1)}.${now.getFullYear()}`);
                report = report.replace('$Time', `${leadZero(now.getHours())}:00`);

                let list_map = globals.la_reports[reportID].list;
                let list = '';

                oldGroup.forEach(group => {
                    list += (list == '' ? '' : ', ') + list_map.replace('$Name', group.name).replace('$ID', group.ID);
                });
                report = report.replace('$List', list);
                //alert('Скопировано в буфер обмена: \n\n' + report);
                navigator.clipboard.writeText(report);
            });

            $('body').on('change', '#la_show_cats', function () {
                globals.la_cats_visible = $(this).prop('checked');
                $('#la_table').toggleClass('hidden');
                setSettings('la_cats_visible', globals.la_cats_visible)
                needUpdate = true;
            });

            $('body').on('change', '#jump_on_click', function () {
                globals.la_jump_on_click = $(this).prop('checked');
                setSettings('la_jump_on_click', globals.la_jump_on_click);
            });

            $('body').on('change', '#show_all_cats', function () {
                globals.la_show_all_cats = $(this).prop('checked');
                setSettings('la_show_all_cats', globals.la_show_all_cats);
                needUpdate = true;
            });

            $('body').on('change', '#la_cats_list', function () {
                globals.la_cats_list = $('#la_cats_list').val();
                setSettings('la_cats_list', globals.la_cats_list);
                needUpdate = true;
            });

            $('body').on('change', '#la_maps_list', function () {
                globals.la_maps_list = $('#la_maps_list').val();
                setSettings('la_maps_list', globals.la_maps_list);
                update_maps();
            });

            $('body').on('click', '#cats_click', function () {
                $('#text').val($('#text').val() + $(this).html() + ', ');
            });

            $('body').on('click', '#maps_click', function () {
                $('#text').val($(this).html());
                update_maps();
            });

            $('body').on('click', '#move_click', function () {
                if (globals.la_jump_on_click) {
                    let move_id = parseInt($(this).attr('move_id'), 10);
                    if (move_id != undefined) moveCages[move_id].click();
                } else {
                    $('#text').val($(this).html());
                    update_maps();
                };
            });

            $('body').on('click', '#la_lock', function () {
                
                $('#la_group').toggleClass('locked unlocked ui-widget ui-corner-all');
                $('#la_cats').toggleClass('locked');
                $('#la_maps').toggleClass('locked');
                if (globals.locked) {
                    $('#la_group').draggable({stop: function () {let p = $('#la_group').position(); setSettings('left', p.left); setSettings('top', p.top);}});
                };
                setSettings('locked', !globals.locked)
                
            });

            $('body').on('click', '#la_copy_map', function () {
                const currMapID = getCurrentMapGlobalID();
                let currMapName = $('#location').html();
                let routes = ''; let M = 0;
                moveCages.forEach(elem => {
                    let src = $(elem[0].parentElement.firstChild).attr('src');
                    if (src != undefined) {
                        let mapID = parseInt(src.split('/')[1].split('.')[0], 10);
                        if (hidden[currMapID] != undefined)
                        {
                            if (hidden[currMapID][M] != undefined) mapID = hidden[currMapID][M];
                            M++;
                        }
                        routes += (routes == '' ? '' : ', ') + mapID;
                    } else routes += (routes == '' ? '' : ', ') + '0';
                });

                //worldmap[218] = {group: 218, dif: 1, name: '218', map: '4263', route: [219, 229]};
                if (currMapName == 'Звёздная степь') currMapName = '';

                const res = `worldmap[${currMapID}] = {group: ${currMapID}, dif: 1, name: '${currMapName}', map: '${getMovesMap()}', route: [${routes}]};`;
                navigator.clipboard.writeText(res);
            });

            $('body').on('change', '#la_mapGroups', function () {

                globals.la_cur_group =  parseInt($('#la_mapGroups[name=la_mapGroups]').val(), 10);
                setSettings('la_cur_group', globals.la_cur_group);

                //let option = `<select id="la_route" name="la_route" size=1>`;
                let option = '';
                let wmSorted = worldmapSorted.map(item => item);
                wmSorted.sort();
                wmSorted.forEach(route => {
                    if (worldGroups[globals.la_cur_group].includes(worldmapSorted.indexOf(route)))
                        option += ` <option value="${worldmapSorted.indexOf(route)}">${route}</option>`;
                });
                //option += `</select>`;
                $('#la_route').html(option);
            });

            needUpdate = true;

        });
    }

    function sett() {

        const html = `<hr><hr><div id="la_settings"><h3>Настройки [Скрипт by <a href="https://catwar.su/cat1424005">Кышбрысь</a> (v.${la_version})]</h3>

            <button id="la_default">Сбросить все по умолчанию</button>

            <h4>Анализ BB-code</h4>
            <ul><li><input type="checkbox" id="la_bbCode">Показывать кнопку разбора рядом с текстом из BB-code</li></ul>
            <h4>Добавить маршруты патрулей в навигатор:</h4>
            <form id="patrulsForm">
                <table border=1 id="la_patrulsTable">
                    <thead><th>Название</th><th>Маршрут</th><th></th></thead>
                    <tbody id="la_patrulsList"></tbody>
                </table>
            </form>
            <BR>
            <div><button id="la_patrulAdd">Добавить новое поле</button> <button form="patrulsForm">Сохранить</button></div>
            <BR>

            <h4>Список групп и отрядов:</h4>
            <form id="groupsForm">
                <table border=1 id="la_groupsTable">
                    <thead><th>Название</th><th>Список котов</th><th></th></thead>
                    <tbody id="la_groupsList"></tbody>
                </table>
            </form>
            <BR>
            <div><button id="la_groupsAdd">Добавить новое поле</button> <button form="groupsForm">Сохранить</button></div>
            <BR>

            <h4>Шаблоны отписей:</h4>
            Для списка команды: $Name - Имя котика, $ID - ID Котика<br>
            Для отчета: $Date - Текущая дата, $Time - Время, начало часа по Москве, $List - Список котов
            </div>
            <BR>
            <form id="reportsForm">
                <table border=1 id="la_reportsTable">
                    <thead><th>Название / Шаблон списка / Шаблон </th><th></th></thead>
                    <tbody id="la_reportsList"></tbody>
                </table>
            </form>
            <BR>
            <div><button id="la_reportsAdd">Добавить новое поле</button> <button form="reportsForm">Сохранить</button></div>

        <hr><hr>`;
        $(isDesktop ? '#branch' : '#site_table').append(html);

        $(document).ready(function () {

            if (globals.show_BB)  $('#la_bbCode')[0].checked = true;
            $('body').on('change', '#la_bbCode', function() {
                globals.show_BB = this.checked;
                setSettings('show_BB', globals.show_BB);
            });

            let patruls = '';
            globals.la_patruls.forEach(patrul => {
                patruls += `<tr>
                    <td><input class="patrul-name" maxlength="30" minlength="2" type="text" value="${patrul.name}"></td>
                    <td><input class="patrul-route" maxlength="1500" minlength="2" type="text" size="80" value="${patrul.route}"></td>
                    <td><span class="la_patrulRemove">×</span></td>
                </tr>`;
            });
            $('#la_patrulsList').html(patruls);

            $('body').on('click', '#la_patrulAdd', function () {
                $('#la_patrulsList').append(`<tr>
                    <td><input class="patrul-name" maxlength="30" minlength="2" type="text"></td>
                    <td><input class="patrul-route" maxlength="1500" minlength="2" type="text" size="80"></td>
                    <td><span class="la_patrulRemove">×</span></td>
                </tr>`);
            });
            $('body').on('click', '.la_patrulRemove', function () {
                if ($(this).closest('tbody').find('tr').length > 0) {
                  $(this).closest('tr').remove();
                }
            });
            $('body').on('submit', '#patrulsForm', function (e) {
                e.preventDefault();
                globals.la_patruls = [];
                $('#la_patrulsList > tr').each(function () {
                    let name = $(this).find('.patrul-name').val();
                    let route = $(this).find('.patrul-route').val();
                    if (name) {
                        globals.la_patruls.push({name: name, route: route});
                    }
                });
                setSettings('la_patruls', JSON.stringify(globals.la_patruls));
            });

            let groups = '';
            globals.la_groups.forEach(group => {
                groups += `<tr>
                      <td><input class="groups-name" maxlength="30" minlength="2" type="text" value="${group.name}"></td>
                      <td><input class="groups-route" maxlength="1500" minlength="2" type="text" size="80" value="${group.list}"></td>
                      <td><span class="la_groupsRemove">×</span></td>
                  </tr>`;
            });
            $('#la_groupsList').html(groups);

            $('body').on('click', '#la_groupsAdd', function () {
                $('#la_groupsList').append(`<tr>
                      <td><input class="groups-name" maxlength="30" minlength="2" type="text"></td>
                      <td><input class="groups-route" maxlength="1500" minlength="2" type="text" size="80"></td>
                      <td><span class="la_groupsRemove">×</span></td>
                </tr>`);
            });
            $('body').on('click', '.la_groupsRemove', function () {
                if ($(this).closest('tbody').find('tr').length > 0) {
                    $(this).closest('tr').remove();
                }
            });
            $('body').on('submit', '#groupsForm', function (e) {
                e.preventDefault();
                globals.la_groups = [];
                $('#la_groupsList > tr').each(function () {
                    let name = $(this).find('.groups-name').val();
                    let list = $(this).find('.groups-route').val();
                    if (name) {
                        globals.la_groups.push({name: name, list: list});
                    }
                });
                setSettings('la_groups', JSON.stringify(globals.la_groups));
            });

            let reports = '';
            globals.la_reports.forEach(report => {
                reports += `<tr>
                      <td><input class="reports-name" maxlength="30" minlength="2" type="text" size="100" value="${report.name}"><br>
                        <input class="reports-list" maxlength="150" minlength="2" type="text" size="100" value="${report.list}"><br>
                        <textarea class="reports-report" maxlength="1500" cols="98" rows="10">${report.report}</textarea></td>
                      <td><span class="la_reportsRemove">×</span></td>
                  </tr>`;
            });
            $('#la_reportsList').html(reports);

            $('body').on('click', '#la_reportsAdd', function () {
                $('#la_reportsList').append(`<tr>
                      <td><input class="reports-name" maxlength="30" minlength="2" type="text" size="100"><br>
                        <input class="reports-list" maxlength="150" minlength="2" type="text" size="100"><br>
                        <textarea class="reports-report" cols="98" rows="10"></textarea></</td>
                      <td><span class="la_reportsRemove">×</span></td>
                </tr>`);
            });
            $('body').on('click', '.la_reportsRemove', function () {
                if ($(this).closest('tbody').find('tr').length > 0) {
                    $(this).closest('tr').remove();
                }
            });
            $('body').on('submit', '#reportsForm', function (e) {
                e.preventDefault();
                globals.la_reports = [];
                $('#la_reportsList > tr').each(function () {
                    let name = $(this).find('.reports-name').val();
                    let list = $(this).find('.reports-list').val();
                    let report = $(this).find('.reports-report').val();
                    if (name) {
                        globals.la_reports.push({name: name, list: list, report: report});
                    }
                });
                setSettings('la_reports', JSON.stringify(globals.la_reports));
            });

            $('body').on('click', '#la_default', function () {
                globals.la_reports = defaults.la_reports;
                globals.la_groups = defaults.la_groups;
                globals.la_patruls = defaults.la_patruls;

                setSettings('la_reports', JSON.stringify(globals.la_reports));
                setSettings('la_groups', JSON.stringify(globals.la_groups));
                setSettings('la_patruls', JSON.stringify(globals.la_patruls));

                alert('Обновите страниицу!');
            });

        });
    };

    function myCat() {
        $(document).ready(function () {
            if (globals.la_myID == '') {
                globals.la_myID = $('#id_val').html();
                setSettings('la_myID', globals.la_myID);
            };
        });
    }
})(window, document, jQuery);