コード例 #1
0
ファイル: wonder.html.php プロジェクト: agatho/uaenhanced
function wonder_getWonderContent($playerID, $caveID, &$details)
{
    global $buildingTypeList, $resourceTypeList, $wonderTypeList, $unitTypeList, $config, $params, $db;
    // messages
    $messageText = array(-4 => "Die Zielsiedlung steht unter Schutz. Der Zauber kann nicht erwirkt werden.", -3 => "Die angegebene Zielsiedlung wurde nicht gefunden.", -2 => "Der Zauber kann nicht auf die angegbene Zielsiedlung erwirkt " . "werden.", -1 => "Es ist ein Fehler bei der Verarbeitung Ihrer Anfrage aufgetreten. " . "Bitte wenden Sie sich an die Administratoren.", 0 => "Der Zauber kann nicht erwirkt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 1 => "Das Erwirken des Zaubers scheint Erfolg zu haben.", 2 => "Die Götter haben Ihr Flehen nicht erhört! Die " . "eingesetzten Opfergaben sind natürlich dennoch verloren. " . "Mehr Glück beim nächsten Mal!");
    // ADDED by chris--- for cavebook -----------------------
    if ($params->POST->targetCaveID != -1) {
        $targetCave = getCaveByID($params->POST->targetCaveID);
        $x = $targetCave[xCoord];
        $y = $targetCave[yCoord];
    } else {
        $x = $params->POST->xCoord;
        $y = $params->POST->yCoord;
    }
    // ------------------------------------------------------
    // and changed $params->POST->xCoord to $x etc
    if (isset($params->POST->wonderID)) {
        $messageID = wonder_processOrder($playerID, $params->POST->wonderID, $caveID, $x, $y, $details, $db);
        $reload = 1;
    }
    if ($reload) {
        // this isn't that elegant...
        $r = getCaveSecure($caveID, $params->SESSION->user['playerID']);
        if ($r->isEmpty()) {
            page_dberror();
        }
        $details = $r->nextRow();
    }
    $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/wonder.ihtml");
    // Show a special message
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
    }
    // ADDED by chris--- for cavebook ---------------------------------
    // Getting entries
    $cavelist = cavebook_getEntries($params->SESSION->user['playerID']);
    // Show the cave table
    $cavebook = array();
    for ($ix = 0; $ix < sizeof($cavelist[id]); $ix++) {
        $cavebook[$ix][cavebook_entry] = $cavelist[name][$ix];
        $cavebook[$ix][cavebook_id] = $cavelist[id][$ix];
        $cavebook[$ix][cavebook_x] = $cavelist[x][$ix];
        $cavebook[$ix][cavebook_y] = $cavelist[y][$ix];
    }
    // --------------------------------------------------------------
    // Show the wonder table
    for ($i = 0; $i < sizeof($wonderTypeList); $i++) {
        $wonder = $wonderTypeList[$i];
        // the current building
        $result = rules_checkDependencies($wonder, $details);
        if ($result === TRUE) {
            tmpl_iterate($template, 'WONDER');
            tmpl_set($template, "WONDER/alternate", $count++ % 2 ? "alternate" : "");
            tmpl_set($template, 'WONDER', array('name' => $wonder->name, 'wonderID' => $i, 'modus' => WONDER_DETAIL, 'caveID' => $caveID));
            // iterate ressourcecosts
            foreach ($wonder->resourceProductionCost as $resourceID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "WONDER/RESSOURCECOST");
                    if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "WONDER/RESSOURCECOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "WONDER/RESSOURCECOST/LESS/value", $cost);
                    }
                    tmpl_set($template, "WONDER/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
                    tmpl_set($template, "WONDER/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
                }
            }
            // iterate unitcosts
            foreach ($wonder->unitProductionCost as $unitID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "WONDER/UNITCOST");
                    if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "WONDER/UNITCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "WONDER/UNITCOST/LESS/value", $cost);
                    }
                    tmpl_set($template, "WONDER/UNITCOST/name", $unitTypeList[$unitID]->name);
                }
            }
            // show the wonder link
            tmpl_set($template, 'WONDER/BUILD_LINK', array('action' => WONDER, 'wonderID' => $wonder->wonderID, 'cave_book_link' => CAVE_BOOK, 'BOOKENTRY' => $cavebook, 'caveID' => $caveID));
        } else {
            if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$wonder->nodocumentation) {
                tmpl_iterate($template, '/UNQUALIFIEDWONDERS/WONDER');
                tmpl_set($template, '/UNQUALIFIEDWONDERS/WONDER', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => WONDER_DETAIL, 'wonderID' => $i, 'caveID' => $caveID, 'name' => $wonder->name, 'dependencies' => $result));
            }
        }
    }
    return tmpl_parse($template);
}
コード例 #2
0
ファイル: map.html.php プロジェクト: agatho/uaenhanced
function getCaveMapContent($caves, $caveID, $playerID)
{
    global $params, $config, $terrainList;
    $caveData = $caves[$caveID];
    $message = '';
    // template öffnen
    $template = @tmpl_open('./templates/' . $config->template_paths[$params->SESSION->user['template']] . '/map.ihtml');
    // Grundparameter setzen
    tmpl_set($template, 'modus', MAP);
    tmpl_set($template, 'cave_book_link', CAVE_BOOK);
    // ADDED by chris--- for cavebook
    // default Werte: Koordinaten dieser Höhle
    $xCoord = $caveData['xCoord'];
    $yCoord = $caveData['yCoord'];
    // Größe der Karte wird benötigt
    $mapSize = getMapSize();
    // wenn in die Minimap geklickt wurde, zoome hinein
    if (!empty($params->POST->minimap_x) && !empty($params->POST->minimap_y) && $params->POST->scaling != 0) {
        $xCoord = Floor($params->POST->minimap_x * 100 / $params->POST->scaling) + $mapSize['minX'];
        $yCoord = Floor($params->POST->minimap_y * 100 / $params->POST->scaling) + $mapSize['minY'];
    } else {
        if (!empty($params->POST->caveName)) {
            $coords = getCaveByName($params->POST->caveName);
            if (sizeof($coords) == 0) {
                $message = 'Die Siedlung mit dem Namen: "' . $params->POST->caveName . '" konnte nicht gefunden werden!';
            } else {
                $xCoord = $coords['xCoord'];
                $yCoord = $coords['yCoord'];
                $message = 'Die Siedlung mit dem Namen: "' . $params->POST->caveName . '" befindet sich in (' . $xCoord . ' | ' . $yCoord . ').';
            }
        } else {
            if (!empty($params->POST->targetCaveID)) {
                $coords = getCaveByID($params->POST->targetCaveID);
                if ($coords === null) {
                    $message = 'Die Siedlung mit der ID: "' . $params->POST->targetCaveID . '" konnte nicht gefunden werden!';
                } else {
                    $xCoord = $coords['xCoord'];
                    $yCoord = $coords['yCoord'];
                    $message = 'Die Siedlung mit der ID: "' . $params->POST->targetCaveID . '" befindet sich in (' . $xCoord . ' | ' . $yCoord . ').';
                }
            } else {
                if (!empty($params->POST->xCoord) && !empty($params->POST->yCoord)) {
                    $xCoord = $params->POST->xCoord;
                    $yCoord = $params->POST->yCoord;
                }
            }
        }
    }
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $message);
    }
    // Koordinaten begrenzen
    if ($xCoord < $mapSize['minX']) {
        $xCoord = $mapSize['minX'];
    }
    if ($yCoord < $mapSize['minY']) {
        $yCoord = $mapSize['minY'];
    }
    if ($xCoord > $mapSize['maxX']) {
        $xCoord = $mapSize['maxX'];
    }
    if ($yCoord > $mapSize['maxY']) {
        $yCoord = $mapSize['maxY'];
    }
    // width und height anpassen
    $MAP_WIDTH = min(MAP_WIDTH, $mapSize['maxX'] - $mapSize['minX'] + 1);
    $MAP_HEIGHT = min(MAP_HEIGHT, $mapSize['maxY'] - $mapSize['minY'] + 1);
    // Nun befinden sich in $xCoord und $yCoord die gesuchten Koordinaten.
    // ermittele nun die linke obere Ecke des Bildausschnittes
    $minX = min(max($xCoord - intval($MAP_WIDTH / 2), $mapSize['minX']), $mapSize['maxX'] - $MAP_WIDTH + 1);
    $minY = min(max($yCoord - intval($MAP_HEIGHT / 2), $mapSize['minY']), $mapSize['maxY'] - $MAP_HEIGHT + 1);
    // ermittele nun die rechte untere Ecke des Bildausschnittes
    $maxX = $minX + $MAP_WIDTH - 1;
    $maxY = $minY + $MAP_HEIGHT - 1;
    // get the map details
    $caveDetails = getCaveDetailsByCoords($minX, $minY, $maxX, $maxY);
    $map = array();
    foreach ($caveDetails as $cave) {
        // ADDED by chris--- for Quests --------------------------------------------------------------------------------
        global $db;
        if ($cave['quest_cave'] && !isCaveInvisibleToPlayer($cave['caveID'], $playerID, $db) && $cave['invisible_name'] != "") {
            $cave['cavename'] = $cave['invisible_name'];
        }
        // -------------------------------------------------------------------------------------------------------
        $cell = array('terrain' => strtolower($terrainList[$cave['terrain']]['name']), 'alt' => "{$cave['cavename']} - ({$cave['xCoord']}|{$cave['yCoord']})", 'link' => "modus=" . MAP_DETAIL . "&targetCaveID={$cave['caveID']}");
        // unbewohnte Höhle
        // ADDED by chris--- for Quests
        // ----------------------------------------------------------
        // checking if this cave is a quest cave and if its visible to the player (than he knows the quest)
        // if he does not know the quest the cave is invisible
        if ($cave['quest_cave'] && isCaveInvisibleToPlayer($cave['caveID'], $playerID, $db)) {
            $cave['playerID'] = 0;
        }
        // ----------------------------------------------------------
        if ($cave['playerID'] == 0) {
            // als Frei! zeigen, wenn man missionieren kann
            if (sizeof($caves) < $params->SESSION->user['takeover_max_caves'] && $cave['takeoverable'] == 1) {
                $text = "Frei!";
                $file = "icon_cave_empty";
                // als Einöde zeigen, wenn man nicht mehr missionieren kann
            } else {
                $text = "Ein&ouml;de";
                $file = "icon_waste";
            }
            // oder Dunkelheit zeigen?
            if ($cave['terrain'] == 4 && $text != "Frei!") {
                $text = "verdorrtes Land";
                $file = "icon_waste";
            }
            // bewohnte Höhle
        } else {
            // eigene Höhle
            if ($cave['playerID'] == $params->SESSION->user['playerID']) {
                $file = "icon_cave_own";
            } else {
                $file = "icon_cave_other";
                if ($cave['quest_cave']) {
                    $file = "icon_cave_quest";
                }
            }
            // mit Artefakt
            if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->user['tribe'] == GOD_ALLY)) {
                $file .= "_artefact";
            }
            // link zum Tribe einfügen
            $cell['link_tribe'] = "modus=" . TRIBE_DETAIL . "&tribe=" . urlencode(unhtmlentities($cave['tribe']));
            // Clan abkürzen
            $decodedTribe = unhtmlentities($cave['tribe']);
            if (strlen($decodedTribe) > 10) {
                $cell['text_tribe'] = htmlentities(substr($decodedTribe, 0, 8)) . "..";
            } else {
                $cell['text_tribe'] = $cave['tribe'];
            }
            // Besitzer
            $decodedOwner = unhtmlentities($cave['name']);
            if (strlen($decodedOwner) > 10) {
                $text = htmlentities(substr($decodedOwner, 0, 8)) . "..";
            } else {
                $text = $cave['name'];
            }
            // übernehmbare Höhlen können gekennzeichnet werden
            if ($cave['secureCave'] != 1) {
                $cell['unsecure'] = array('dummy' => '');
            }
        }
        $cell['file'] = $file;
        $cell['text'] = $text;
        // Wenn die Höhle ein Artefakt enthält und man berechtigt ist -> anzeigen
        if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->user['tribe'] == GOD_ALLY)) {
            $cell['artefacts'] = $cave['artefacts'];
            $cell['artefacts_text'] = "Artefakte: {$cave['artefacts']}";
        }
        $map[$cave['xCoord']][$cave['yCoord']] = $cell;
    }
    // Karte mit Beschriftungen ausgeben
    // über alle Zeilen
    for ($j = $minY - 1; $j <= $maxY + 1; ++$j) {
        tmpl_iterate($template, '/ROWS');
        // über alle Spalten
        for ($i = $minX - 1; $i <= $maxX + 1; ++$i) {
            tmpl_iterate($template, '/ROWS/CELLS');
            // leere Zellen
            if (($j == $minY - 1 || $j == $maxY + 1) && ($i == $minX - 1 || $i == $maxX + 1)) {
                tmpl_set($template, "/ROWS/CELLS", getEmptyCell());
                // x-Beschriftung
            } else {
                if ($j == $minY - 1 || $j == $maxY + 1) {
                    tmpl_set($template, "/ROWS/CELLS", getLegendCell('x', $i));
                    // y-Beschriftung
                } else {
                    if ($i == $minX - 1 || $i == $maxX + 1) {
                        tmpl_set($template, "/ROWS/CELLS", getLegendCell('y', $j));
                        // Kartenzelle
                    } else {
                        tmpl_set($template, "/ROWS/CELLS", getMapCell($map, $i, $j));
                    }
                }
            }
        }
    }
    // ADDED by chris--- for cavebook:
    // Getting entries
    $cavelist = cavebook_getEntries($params->SESSION->user['playerID']);
    // Show the cave table
    for ($i = 0; $i < sizeof($cavelist[id]); $i++) {
        $cavename = $cavelist[name][$i];
        // the current cavename
        $cavebookID = $cavelist[id][$i];
        $cave_x = $cavelist[x][$i];
        $cave_y = $cavelist[y][$i];
        tmpl_iterate($template, '/BOOKENTRY');
        tmpl_set($template, 'BOOKENTRY/book_entry', $cavename);
        tmpl_set($template, 'BOOKENTRY/book_id', $cavebookID);
        tmpl_set($template, 'BOOKENTRY/book_x', $cave_x);
        tmpl_set($template, 'BOOKENTRY/book_y', $cave_y);
    }
    // Minimap
    $width = $mapSize['maxX'] - $mapSize['minX'] + 1;
    $height = $mapSize['maxY'] - $mapSize['minY'] + 1;
    // compute mapcenter coords
    $mcX = $minX + intval($MAP_WIDTH / 2);
    $mcY = $minY + intval($MAP_HEIGHT / 2);
    tmpl_set($template, "/MINIMAP", array('file' => "images/minimap.png.php?x=" . $xCoord . "&y=" . $yCoord, 'modus' => MAP, 'width' => intval($width * MINIMAP_SCALING / 100), 'height' => intval($height * MINIMAP_SCALING / 100), 'scaling' => MINIMAP_SCALING));
    tmpl_set($template, '/O', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/SO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/S', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/SW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/W', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/NW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/N', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/NO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    return tmpl_parse($template);
}
コード例 #3
0
ファイル: cave_book.html.php プロジェクト: agatho/uaenhanced
function show_cavebook($playerID, $deleteID)
{
    global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db;
    // messages
    $messageText = array(0 => "Siedlung wurde eingetragen.", 1 => "Diese Siedlung gibt es nicht.", 2 => "Diese Siedlung ist schon in der Liste.", 3 => "Siedlung aus der Liste gel&ouml;scht.", 4 => "Siedlung konnte nicht aus der Liste entfernt werden.", 5 => "Verarsch mich nicht!", 6 => "Datenbank Fehler.");
    // enter something new
    if (isset($params->POST->newEntryName) && $params->POST->newEntryName != "") {
        $messageID = cavebook_newEntry($playerID, $params->POST->newEntryName);
    } else {
        if (isset($params->POST->x) && isset($params->POST->y) && $params->POST->y > 0 && $params->POST->x > 0) {
            $messageID = cavebook_newEntry_coords($playerID, $params->POST->x, $params->POST->y);
        } else {
            if (isset($params->POST->id)) {
                $messageID = cavebook_newEntry_id($playerID, $params->POST->id);
            } else {
                if (isset($params->GET->id)) {
                    $messageID = cavebook_newEntry_id($playerID, $params->GET->id);
                } else {
                    if ($deleteID > 0) {
                        $messageID = cavebook_deleteEntry($playerID, $deleteID);
                    }
                }
            }
        }
    }
    $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/cave_book.ihtml");
    // Show a special message
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
    }
    // Getting entries
    // call our function
    $cavelist = cavebook_getEntries($playerID);
    // Show the cave table
    for ($i = 0; $i < sizeof($cavelist[id]); $i++) {
        $cavename = $cavelist[name][$i];
        // the current cavename
        $caveX = $cavelist[x][$i];
        $caveY = $cavelist[y][$i];
        $caveID = $cavelist[id][$i];
        $playerName = $cavelist[playerName][$i];
        $playerID = $cavelist[playerID][$i];
        $tribe = $cavelist[tribe][$i];
        // the current tribe
        $tribelink = "<a href=\"main.php?modus=" . TRIBE_DETAIL . "&tribe=" . urlencode(unhtmlentities($tribe)) . "\" target=\"_blank\">";
        if ($tribe != "") {
            $tribe = "(" . $tribe . ")";
        }
        $playerName = "&nbsp;&nbsp;-&nbsp;&nbsp;<a href=\"main.php?modus=" . PLAYER_DETAIL . "&amp;detailID=" . $playerID . "\" target=\"_blank\">" . $playerName . "</a>";
        if ($playerID == 0) {
            $playerName = "";
        }
        $cavename = "<a href=\"main.php?modus=" . MAP_DETAIL . "&amp;targetCaveID=" . $caveID . "\" target=\"_blank\">" . $cavename . "</a>";
        $movementLink = "?modus=" . MOVEMENT . "&targetXCoord=" . $caveX . "&targetYCoord=" . $caveY . "&targetCaveName=" . unhtmlentities($cavelist[name][$i]);
        tmpl_iterate($template, '/CAVES');
        tmpl_set($template, "CAVES/alternate", $count++ % 2 ? "alternate" : "");
        tmpl_set($template, 'CAVES', array('cavename' => $cavename, 'tribe' => $tribe, 'playerName' => $playerName, 'tribelink' => $tribelink, 'movementLink' => $movementLink, 'caveID' => $caveID, 'caveX' => $caveX, 'caveY' => $caveY, 'modus_delete' => CAVE_BOOK_DELETE));
    }
    if (sizeof($cavelist) < 1) {
        tmpl_set($template, "NOCAVES/dummy", "");
    }
    return tmpl_parse($template);
}
コード例 #4
0
ファイル: unitaction.html.php プロジェクト: agatho/uaenhanced
function unitAction($caveID, &$meineHoehlen)
{
    global $config, $db, $MAX_RESOURCE, $MOVEMENTCOSTCONSTANT, $MOVEMENTSPEEDCONSTANT, $params, $ua_movements, $resourceTypeList, $unitTypeList, $effectTypeList, $FUELRESOURCEID;
    $details = $meineHoehlen[$caveID];
    /***************************************************************************/
    /**                                                                       **/
    /** CHECK ARTEFACTS                                                       **/
    /**                                                                       **/
    /***************************************************************************/
    // artefact moving: get ID if any
    //
    // $params->POST->myartefacts will be
    //   NULL, if it is not set at all
    //   -1 when choosing no artefact to move
    //   0 if there was a real choice
    // default: Move No Artefact (this var holds the artefactID to move)
    $moveArtefact = 0;
    // this array shall contain the artefacts if any
    $myartefacts = array();
    // does the cave contain an artefact at least?
    if ($details['artefacts'] > 0) {
        // get artefacts
        $myartefacts = artefact_getArtefactsReadyForMovement($caveID);
        // was an artefact chosen?
        if ((int) $params->POST->myartefacts > 0) {
            $tempID = (int) $params->POST->myartefacts;
            // now check, whether this artefactID belongs to this cave
            foreach ($myartefacts as $key => $value) {
                // if found, set it
                if ($tempID == $value['artefactID']) {
                    $moveArtefact = $tempID;
                    break;
                }
            }
        }
    }
    // now $moveArtefact should contain 0 for 'move no artefact'
    // or the artefactID of the artefact to be moved
    /***************************************************************************/
    /***************************************************************************/
    /***************************************************************************/
    // get Map Size
    $size = getMapSize();
    $dim_x = ($size['maxX'] - $size['minX'] + 1) / 2;
    $dim_y = ($size['maxY'] - $size['minY'] + 1) / 2;
    $foodPerCave = eval('return ' . formula_parseToPHP($MOVEMENTCOSTCONSTANT . ';', '$details'));
    $minutesPerCave = eval('return ' . formula_parseToPHP($MOVEMENTSPEEDCONSTANT . ';', '$details'));
    if (isset($params->POST->moveit)) {
        $targetXCoord = $params->POST->targetXCoord;
        $targetYCoord = $params->POST->targetYCoord;
        $targetCaveName = $params->POST->targetCaveName;
        $movementID = $params->POST->movementID;
        // check for scripters
        check_timestamp($params->POST->tstamp);
        // HöhlenName >>> Koordinate
        $validCaveName = FALSE;
        if (empty($targetXCoord) || empty($targetYCoord) and !empty($targetCaveName)) {
            $result = getCaveByName($targetCaveName);
            if (sizeof($result) != 0) {
                $targetXCoord = $result['xCoord'];
                $targetYCoord = $result['yCoord'];
                $validCaveName = TRUE;
            }
        }
        // Array von Nullwerten befreien
        $unit = array_filter($params->POST->unit, "filterZeros");
        $unit = array_map("checkFormValues", $unit);
        $resource = array_map("checkFormValues", $params->POST->rohstoff);
        // Test, ob Einheitentragekapazität ausgelastet
        foreach ($resource as $resKey => $aRes) {
            $capacity = 0;
            foreach ($unit as $unitKey => $aUnit) {
                $capacity += $aUnit * $unitTypeList[$unitKey]->encumbranceList[$resKey];
            }
            if ($capacity < $aRes) {
                $overloaded = 1;
                break;
            }
        }
        // ADDED by chris--- for farmschutz
        if (FARMSCHUTZ_ACTIVE == 1) {
            if ($params->POST->movementID == 3 || $params->POST->movementID == 6) {
                $farmschutz = farmschutz($targetXCoord, $targetYCoord, $params->SESSION->user['playerID'], $db);
            }
        }
        // ------------------------------------
        if ($params->POST->movementID == 0) {
            $msg = "*#\$@*#\$%: Bitte Bewegungsart ausw&auml;hlen!";
        } else {
            if (!sizeof($unit)) {
                $msg = "*#\$@*#\$%: Es sind keine Einheiten ausgew&auml;hlt!";
            } else {
                if (empty($targetXCoord) || empty($targetYCoord) and empty($targetCaveName)) {
                    $msg = "*#\$@*#\$%: Es fehlt eine Zielkoordinate oder ein Zielsiedlungsname!";
                } else {
                    if (empty($targetXCoord) || empty($targetYCoord) and !empty($targetCaveName) and $validCaveName === FALSE) {
                        $msg = "*#\$@*#\$%: Es gibt keine Siedlung mit dem Namen '" . $targetCaveName . "'!";
                    } else {
                        if ($overloaded) {
                            $msg = "*#\$@*#\$%: Deine Krieger k&ouml;nnen die Menge an Ressourcen nicht tragen!!";
                        } else {
                            if (beginner_isCaveProtectedByCoord($targetXCoord, $targetYCoord, $db)) {
                                $msg = "*#\$@*#\$%: Die Zielsiedlung steht unter Anf&auml;ngerschutz. ";
                            } else {
                                if (beginner_isCaveProtectedByID($caveID, $db)) {
                                    $msg = "*#\$@*#\$%: Ihre Siedlung steht unter Anf&auml;ngerschutz. " . "Sie k&ouml;nnen den Schutz sofort unter dem Punkt Bericht: Alle " . "meine Siedlungen beenden";
                                } else {
                                    if ($params->POST->movementID == 6 && cave_isCaveSecureByCoord($targetXCoord, $targetYCoord, $db)) {
                                        $msg = "*#\$@*#\$%: Sie k&ouml;nnen diese Siedlung nicht &uuml;bernehmen. " . "Sie ist gegen &Uuml;bernahmen gesch&uuml;tzt.";
                                    } else {
                                        if (FARMSCHUTZ_ACTIVE == 1 && ($params->POST->movementID == 3 || $params->POST->movementID == 6) && $farmschutz == 1) {
                                            $msg = "*#\$@*#\$%: Der Spieler steht unter Farmschutz. Sie k&ouml;nnen ihn nicht angreifen.";
                                        } else {
                                            if (FARMSCHUTZ_ACTIVE == 1 && ($params->POST->movementID == 3 || $params->POST->movementID == 6) && $farmschutz == 2) {
                                                $msg = "*#\$@*#\$%: Sie stehen unter Farmschutz. Dieser Spieler ist zu gro&szlig; zum angreifen.";
                                            } else {
                                                // Entfernung x Dauer pro Höhle x größter Geschwindigkeitsfaktor x Bewegungsfaktor
                                                $duration = ceil(getDistanceByCoords($details['xCoord'], $details['yCoord'], $targetXCoord, $targetYCoord) * $minutesPerCave * getMaxSpeedFactor($unit) * $ua_movements[$movementID]->speedfactor * (1 + $details[$effectTypeList[25]->dbFieldName]));
                                                // Dauer x Rationen x Größe einer Ration x Bewegungsfaktor
                                                $reqFood = ceil($duration * calcRequiredFood($unit) * $foodPerCave * $ua_movements[$movementID]->foodfactor);
                                                if ($details[$resourceTypeList[$FUELRESOURCEID]->dbFieldName] < $reqFood) {
                                                    $msg = "*#\$@*#\$%: Nicht genug Nahrung zum Ern&auml;hren der Krieger auf ihrem langen Marsch vorhanden!!";
                                                } else {
                                                    $msgID = setMovementEvent($caveID, $details, $targetXCoord, $targetYCoord, $unit, $resource, $movementID, $reqFood, $duration, $moveArtefact, $minutesPerCave * $ua_movements[$movementID]->speedfactor);
                                                    switch ($msgID) {
                                                        case 0:
                                                            $msg = "Die Krieger wurden losgeschickt und haben {$reqFood} Nahrung mitgenommen!";
                                                            break;
                                                        case 1:
                                                            $msg = "*#\$@*#\$%: In diesen Koordinaten liegt keine Siedlung!";
                                                            break;
                                                        case 2:
                                                            $msg = "*#\$@*#\$%: F&uuml;r diese Bewegung sind nicht gen&uuml;gend Einheiten/Rohstoffe verf&uuml;gbar!";
                                                            break;
                                                        case 3:
                                                            $msg = "Schwerer *#\$@*#\$%: Bitte Admin kontaktieren!";
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        if (!empty($params->POST->eventID)) {
            $msgID = reverseMovementEvent($caveID, $params->POST->eventID);
            switch ($msgID) {
                case 0:
                    $msg = "Die Einheiten kehren zurück!";
                    break;
                case 1:
                    $msg = "*#\$@*#\$%: Fehler bei der Rückkehr!";
                    break;
            }
        }
    }
    // refresh this cave
    $temp = getCaveSecure($caveID, $params->SESSION->user['playerID']);
    $meineHoehlen[$caveID] = $details = $temp->nextRow(MYSQL_ASSOC);
    // make sure that bagged artefacts are not shown again
    if ($moveArtefact != 0) {
        $myartefacts = artefact_getArtefactsReadyForMovement($caveID);
    }
    // //////////////////////////////////////////////////////////////
    // Create the page
    // //////////////////////////////////////////////////////////////
    $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/unitaction.ihtml");
    // messages
    if (isset($msg)) {
        tmpl_set($template, '/MESSAGE/msg', $msg);
    }
    // javascript support
    tmpl_set($template, 'currentX', $details['xCoord']);
    tmpl_set($template, 'currentY', $details['yCoord']);
    tmpl_set($template, 'dim_x', $dim_x);
    tmpl_set($template, 'dim_y', $dim_y);
    tmpl_set($template, 'speed', $minutesPerCave);
    tmpl_set($template, 'movementcostconstant', $foodPerCave);
    tmpl_set($template, "resourceTypes", $MAX_RESOURCE);
    tmpl_set($template, "movement_speed_factor", $details[$effectTypeList[25]->dbFieldName]);
    // ADDED by chris--- for movement_speed_factor
    // ADDED by chris--- for cavebook:
    tmpl_set($template, 'show_book_modus', CAVE_BOOK);
    // Getting entries
    $cavelist = cavebook_getEntries($params->SESSION->user['playerID']);
    // Show the cave table
    for ($i = 0; $i < sizeof($cavelist[id]); $i++) {
        $cavename = $cavelist[name][$i];
        // the current cavename
        $cavebookID = $cavelist[id][$i];
        $cave_x = $cavelist[x][$i];
        $cave_y = $cavelist[y][$i];
        tmpl_iterate($template, '/BOOKENTRY');
        tmpl_set($template, 'BOOKENTRY/book_entry', $cavename);
        tmpl_set($template, 'BOOKENTRY/book_id', $cavebookID);
        tmpl_set($template, 'BOOKENTRY/book_x', $cave_x);
        tmpl_set($template, 'BOOKENTRY/book_y', $cave_y);
        tmpl_iterate($template, '/BOOKENTRYJS');
        tmpl_set($template, 'BOOKENTRYJS/book_entry', unhtmlentities($cavename));
        tmpl_set($template, 'BOOKENTRYJS/book_id', $cavebookID);
        tmpl_set($template, 'BOOKENTRYJS/book_x', $cave_x);
        tmpl_set($template, 'BOOKENTRYJS/book_y', $cave_y);
    }
    // movements
    $selectable_movements = array();
    foreach ($ua_movements as $value) {
        if ($value->playerMayChoose) {
            $selectable_movements[] = get_object_vars($value);
        }
    }
    tmpl_set($template, 'SELECTACTION', $selectable_movements);
    // resources
    $resources = array();
    for ($res = 0; $res < sizeof($resourceTypeList); $res++) {
        $resources[] = array('resourceID' => $resourceTypeList[$res]->resourceID, 'name' => $resourceTypeList[$res]->name, 'currentAmount' => "0" + $details[$resourceTypeList[$res]->dbFieldName], 'dbFieldName' => $resourceTypeList[$res]->dbFieldName);
    }
    tmpl_set($template, 'RESOURCE', $resources);
    tmpl_set($template, 'TOTAL', $resources);
    tmpl_set($template, 'RESOURCE_LUGGAGE', $resources);
    // units table
    $unitprops = array();
    $units = array();
    $unitsAll = array();
    // ADDED by chris---
    for ($i = 0; $i < sizeof($unitTypeList); $i++) {
        // if no units of this type, next type
        if (!$details[$unitTypeList[$i]->dbFieldName]) {
            continue;
        }
        $temp = array();
        $encumbrance = array();
        for ($j = 0; $j < count($resourceTypeList); $j++) {
            $encumbrance[$j] = array('resourceID' => $j, 'load' => "0" + $unitTypeList[$i]->encumbranceList[$j]);
            $temp[] = "0" + $unitTypeList[$i]->encumbranceList[$j];
        }
        $unitprops[] = array('unitID' => $unitTypeList[$i]->unitID, 'foodCost' => $unitTypeList[$i]->foodCost, 'speedFactor' => $unitTypeList[$i]->wayCost, 'resourceLoad' => implode(",", $temp));
        $units[] = array('name' => $unitTypeList[$i]->name, 'modus' => UNIT_PROPERTIES, 'unitID' => $unitTypeList[$i]->unitID, 'foodCost' => $unitTypeList[$i]->foodCost, 'speedFactor' => $unitTypeList[$i]->wayCost, 'maxWarriorAnzahl' => $details[$unitTypeList[$i]->dbFieldName], 'warriorID' => $i, 'ENCUMBRANCE' => $encumbrance);
        $unitAnzahl = sizeof($units);
    }
    tmpl_set($template, 'UNITPROPS', $unitprops);
    tmpl_set($template, 'SELECTWARRIOR', $units);
    tmpl_set($template, '/unitAnzahl', $unitAnzahl);
    // weitergereichte Koordinateny
    if (empty($params->POST->movementID)) {
        tmpl_set($template, 'targetXCoord', $params->POST->targetXCoord);
        tmpl_set($template, 'targetYCoord', $params->POST->targetYCoord);
        tmpl_set($template, 'targetCaveName', $params->POST->targetCaveName);
    }
    // weitere Paramter
    $hidden = array(array('name' => 'modus', 'value' => MOVEMENT), array('name' => 'moveit', 'value' => 'true'), array('name' => 'trigger', 'value' => 'self'), array('name' => 'tstamp', 'value' => "" . time()));
    tmpl_set($template, 'PARAMS', $hidden);
    $movements = digest_getMovements(array($caveID => $details), array(), true);
    //$movements = digest_getMovements($meineHoehlen, array(), true);
    foreach ($movements as $move) {
        if ($move['isOwnMovement']) {
            if (isCaveInvisibleToPlayer($move['target_caveID'], $params->SESSION->user['playerID'], $db)) {
                $move['target_player_tribe'] = "";
                $move['target_player_name'] = "";
            }
            tmpl_iterate($template, 'MOVEMENT/MOVE');
            tmpl_set($template, 'MOVEMENT/MOVE', $move);
        } else {
            tmpl_iterate($template, 'OPPMOVEMENT/MOVE');
            tmpl_set($template, 'OPPMOVEMENT/MOVE', $move);
        }
    }
    // artefakte
    if (sizeof($myartefacts) != 0) {
        tmpl_set($template, '/ARTEFACTS/ARTEFACT', $myartefacts);
    }
    return tmpl_parse($template);
}