function relation_processRelationUpdate($tag, $relationData, $db, $FORCE = 0) { global $relationList; if (!$FORCE) { if (strcasecmp($tag, $relationData['tag']) == 0) { return -7; } if (!($ownTribeInfo = tribe_getTribeByTag($tag, $db))) { return -6; } if (!($targetTribeInfo = tribe_getTribeByTag($relationData['tag'], $db))) { return -6; } if (!$ownTribeInfo['valid']) { return -17; } $relationType = $relationData['relationID']; $relationInfo = $relationList[$relationType]; if (!($relation = relation_getRelation($tag, $relationData['tag'], $db))) { return -3; } $relationTypeActual = $relation['own']['relationType']; if ($relationTypeActual == $relationType) { // change to actual relation? return -14; } if (!$relation['own']['changeable']) { return -4; } // check if switching to same relation as target or relation is possible if ($relation['other']['relationType'] != $relationType && !relation_isPossible($relationType, $relation['own']['relationType'])) { //from return -5; } $relationFrom = $relation['own']['relationType']; $relationTo = $relationType; if (!$FORCE && $relationList[$relationTo]['isWarAlly']) { //generally allowes? if (!$relationList[$relationFrom]['isAlly']) { return -18; } if (!$relationList[$relation['other']['relationType']]['isAlly']) { return -19; } if (!relation_haveSameEnemy($ownTribeInfo['tag'], $targetTribeInfo['tag'], TRUE, FALSE, $db)) { return -20; } } $relationTypeOtherActual = $relation['other']['relationType']; // check minimum size of target tribe if it´s not an ultimatum if (($relationInfo['targetSizeDiffDown'] > 0 || $relationInfo['targetSizeDiffUp'] > 0) && !$relationList[$relationTypeOtherActual]['isUltimatum']) { $from_points = max(0, tribe_getMight($tag, $db)); $target_points = max(0, tribe_getMight($relationData['tag'], $db)); if (!tribe_isTopTribe($db, $relationData['tag'])) { if ($relationInfo['targetSizeDiffDown'] > 0 && $from_points - $relationInfo['targetSizeDiffDown'] > $target_points) { return -12; } } if (!tribe_isTopTribe($db, $relationData['tag'])) { if ($relationInfo['targetSizeDiffUp'] > 0 && $from_points + $relationInfo['targetSizeDiffUp'] < $target_points) { return -13; } } } } // if switching to the same relation of other clan towards us, // use their treaty's end_time! if ($relationType == $relation['other']['relationType'] && $relationType != 0) { $end_time = $relation['other']['duration']; } else { $duration = $relationList[$relationTypeActual]['transitions'][$relationType]['time']; } if ($relationList[$relationFrom]['isPrepareForWar'] && $relationList[$relationTo]['isWar']) { $OurFame = $relation['own']['fame']; $OtherFame = $relation['other']['fame']; } else { $OurFame = 0; $OtherFame = 0; } if (!relation_setRelation($tag, $targetTribeInfo['tag'], $relationType, $duration, $db, $end_time, $relation['own']['tribe_rankingPoints'], $relation['own']['target_rankingPoints'], $OurFame)) { return -3; } // calculate elo if war ended if ($relationList[$relationType]['isWarWon']) { ranking_calculateElo($db, $tag, $relation['own']['tribe_rankingPoints'], $relationData['tag'], $relation['own']['target_rankingPoints']); } else { if ($relationList[$relationType]['isWarLost']) { ranking_calculateElo($db, $relationData['tag'], $relation['own']['target_rankingPoints'], $tag, $relation['own']['tribe_rankingPoints']); } } // insert history message if ($message = $relationList[$relationType]['historyMessage']) { relation_insertIntoHistory($tag, relation_prepareHistoryMessage($tag, $targetTribeInfo['tag'], $message), $db); } $relationName = $relationList[$relationType]['name']; tribe_sendTribeMessage($tag, TRIBE_MESSAGE_RELATION, "Haltung gegenüber {$targetTribeInfo['tag']} " . "geändert", "Ihr Stammesanführer hat die Haltung Ihres " . "Stammes gegenüber dem Stamm " . "{$targetTribeInfo['tag']} auf {$relationName} " . "geändert."); tribe_sendTribeMessage($targetTribeInfo['tag'], TRIBE_MESSAGE_RELATION, "Der Stamm {$tag} ändert seine Haltung", "Der Stammesanführer des Stammes {$tag} " . "hat die Haltung seines " . "Stammes ihnen gegenüber " . "auf {$relationName} " . "geändert."); // switch other side if necessary (and not at this type already) if (!$end_time && ($oST = $relationInfo['otherSideTo']) >= 0) { if (!relation_setRelation($targetTribeInfo['tag'], $tag, $oST, $duration, $db, 0, $relation['other']['tribe_rankingPoints'], $relation['other']['target_rankingPoints'], $OtherFame)) { return -3; } // insert history if ($message = $relationList[$oST]['historyMessage']) { relation_insertIntoHistory($targetTribeInfo['tag'], relation_prepareHistoryMessage($tag, $targetTribeInfo['tag'], $message), $db); } $relationName = $relationList[$oST]['name']; tribe_sendTribeMessage($targetTribeInfo['tag'], TRIBE_MESSAGE_RELATION, "Haltung gegenüber {$tag} " . "geändert", "Die Haltung Ihres " . "Stammes gegenüber dem Stamm " . "{$tag} wurde automatisch auf {$relationName} " . "geändert."); tribe_sendTribeMessage($tag, TRIBE_MESSAGE_RELATION, "Der Stamm {$targetTribeInfo['tag']} ändert " . "seine " . "Haltung", "Der Stamm {$targetTribeInfo['tag']} " . "hat die Haltung ihnen gegenüber " . "automatisch auf {$relationName} " . "geändert."); } tribe_generateMapStylesheet(); return 3; }
<?php /* * mapstyle.php - outputs a tribe-tailored stylesheet for the map that reflects the relations * Copyright (c) 2004 OGP-Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. */ /** Set flag that this is a parent file */ define("_VALID_UA", 1); require_once "config.inc.php"; require_once "include/tribes.inc.php"; require_once "include/params.inc.php"; require_once "include/page.inc.php"; page_start(); $stylesheet = "./images/temp/tribe_" . $params->SESSION->player->tribe . ".css"; if (!file_exists($stylesheet)) { tribe_generateMapStylesheet(); } // output the file; readfile wraps it in HTML, header() is too obvious where files are located $file = @file_get_contents($stylesheet); echo $file;