Esempio n. 1
0
        // update map
        $javascript = 'map_session_refresh();' . $javascript;
        js_eval($javascript, $refresh_id);
    } else {
        $layer = $_GET['layer'];
        $event_pos = $event_pos[1];
        if ($layer == 1 && isset($events['i' . $event_pos]) && ($event_pos == $user->map_left . '-' . ($user->map_top + 1) || $event_pos == $user->map_left - 1 . '-' . $user->map_top || $event_pos == $user->map_left . '-' . ($user->map_top - 1) || $event_pos == $user->map_left + 1 . '-' . $user->map_top) || $layer == 0 && isset($events['i' . $event_pos]) && $event_pos == $user->map_left . '-' . $user->map_top) {
            $event_script = new event_script($event_script_data['i' . $event_pos]);
            $script = array();
            while ($data = $event_script->script(true, false)) {
                // javascript instruction
                $script[] = '\'' . quotes($data) . '\'';
            }
            $javascript .= 'script_eval(0, new Array(' . implode(', ', $script) . '));';
        }
        js_eval($javascript, $refresh_id);
    }
} else {
    if ($user->in_battle) {
        header('Location: ' . $config->path . $config->index . '?mod=battle');
        exit;
    }
    if ($user->refresh == 1) {
        $user->set('refresh', 0);
    }
    if ($user->teleport == 1) {
        $user->set('teleport', 0);
    }
    // get map data
    $result = $db->sql_query('SELECT m.id, m.name, m.blocs, m.music, m.optimized, t.tiles FROM ' . MAPS_TABLE . ' m, ' . TILESETS_TABLE . ' t WHERE m.id = ' . $user->map_id . ' AND m.tileset = t.id');
    if (!($map = $db->sql_fetchobject($result))) {
Esempio n. 2
0
            }
            $y++;
        }
        if (is_file($config->path . $config->cache_dir . 'map_' . $map_id . '_1.png')) {
            unlink($config->path . $config->cache_dir . 'map_' . $map_id . '_1.png');
        }
        imagepng($picture, $config->path . $config->cache_dir . 'map_' . $map_id . '_1.png');
        imagedestroy($picture);
    }
    $db->sql_query('UPDATE ' . MAPS_TABLE . ' SET name = \'' . $map_name . '\', tileset = \'' . $tileset_id . '\', blocs = \'' . quotes(serialize($map)) . '\', music = \'' . $map_music . '\', optimized = ' . $config->optimize_maps . ' WHERE id = ' . $map_id);
    $db->sql_query('UPDATE ' . USERS_TABLE . ' SET refresh = 1 WHERE id > 1 AND map_id = ' . $map_id);
    $lang->load_keys('map_editor');
    if ($tileset_id != intval($_POST['old_tileset_id'])) {
        js_eval('alert(\'' . quotes($lang->map_saved) . '\');document.location.href=\'' . $config->index . '?mod=admin.map&mode=map_editor&map_id=' . $map_id . '\';', $refresh_id, 1);
    } else {
        js_eval('alert(\'' . quotes($lang->map_saved) . '\');saved=true;', $refresh_id, 1);
    }
} elseif ($mode == 'GET.map_editor') {
    if (empty($_GET['map_id'])) {
        header('Location: ' . $config->path . $config->index . '?mod=admin.map&mode=select_map_to_edit');
        exit;
    }
    $map_id = intval($_GET['map_id']);
    $result = $db->sql_query('SELECT m.*, t.tiles, t.cols FROM ' . MAPS_TABLE . ' m, ' . TILESETS_TABLE . ' t WHERE m.id = ' . $map_id . ' AND t.id = m.tileset');
    if (!($row = $db->sql_fetchrow($result))) {
        message_die('Error', 'Could not get map data');
    }
    $lang->load_keys('map_editor');
    $tileset_id = isset($_GET['tileset_id']) ? intval($_GET['tileset_id']) : 0;
    $refresh_id = 1;
    $row['tiles'] = unserialize($row['tiles']);