PageRenderTime 28ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/land.php

https://bitbucket.org/obsidian/selador
PHP | 1175 lines | 1037 code | 79 blank | 59 comment | 112 complexity | f149849be93ad7cbc41ce1f312a62a1d MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* land.php - Front-end code for land view
  3. *
  4. * Copyright (C) 2006-2010 Kevin Read, Simone Schaefer
  5. * Copyright (C) 2010 Markus Bender
  6. *
  7. * This file is part of Selador, a browser-based fantasy strategy game
  8. *
  9. * This program is distributed under the terms of the GNU Affero General Public License.
  10. *
  11. *
  12. * Selador is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * any later version.
  16. *
  17. * Selador is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with Selador. If not, see <http://www.gnu.org/licenses/>.
  24. **/
  25. // Works but could be much nicer. The land view itself is cached.
  26. ob_start("ob_gzhandler");
  27. $need_position = true;
  28. require_once("php/base.php");
  29. require_once("php/event.php");
  30. require_once("php/base/config.inc.php");
  31. $_settlecircle_fields = array (74,72,63,62,53,82,83,93);
  32. function highlight_settlecircle ($xy, $can_settle)
  33. {
  34. global $_settlecircle_fields;
  35. if (in_array ($xy, $_settlecircle_fields) && $can_settle)
  36. return true;
  37. else
  38. return false;
  39. }
  40. ?>
  41. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
  42. <html><head><title>Selador - <?php echo WORLDTITLE; ?></title>
  43. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  44. <link type="text/css" href="styles/map.css" rel="stylesheet">
  45. <link type="text/css" href="styles/<?php echo $_SESSION['theme']; ?>.css" rel="stylesheet">
  46. <?php
  47. if ($_SESSION['tt'])
  48. echo '<script type="text/javascript" src="ol/overlibmws.js"></script><script type="text/javascript" src="ol/overlibmws_bubble.js"></script>';
  49. ?>
  50. <script type="text/javascript">
  51. <?php
  52. echo "map_x = ".$x.";\n";
  53. echo "map_y = ".$y.";\n";
  54. echo "mapsy = ".$world->sizey.";\n";
  55. echo "no_reload = false;\n";
  56. $loctime = localtime();
  57. // We need the hour
  58. $this_hour = $loctime[2];
  59. if (($this_hour > 19) || ($this_hour < 8))
  60. echo "daytime = 2;\n";
  61. else
  62. echo "daytime = 1;\n";
  63. /* $eh = new EventHandler ($me, $gui, $user_row, $gamedb);
  64. $eh->run(); */
  65. /*echo "vx = ".(($x + $y) * 64).";";
  66. echo "vy = ".(($world->sizey + -$x + $y) * 32).";"; */
  67. ?>
  68. </script>
  69. <script src="scripts/de.js" type="text/javascript"></script>
  70. </head>
  71. <body class="inhalt" onload="start();">
  72. <?php
  73. // Enhancing a ressource field
  74. if (isset ($_REQUEST['r']) && isset($_REQUEST['l']))
  75. {
  76. if (isset ($gui->building_queue))
  77. $buildings = count($gui->building_queue);
  78. else
  79. $buildings = 0;
  80. // We need to check here if the build queue isn't filled up already
  81. if ($buildings < 2)
  82. {
  83. // Now check if this request was already placed (i.e. this page was reloaded)
  84. $tolevel = $_REQUEST['l'];
  85. // To utilize the build queue, we would also need to know if this ressource tile is already being enhanced.
  86. $query = "select A.level, A.villageid, B.type, C.expansion from tileres A, map B, village C where A.x=".$x." and A.y=".$y." and B.x=".$x." and B.y=".$y." and A.uid=".$me->uid." and C.villageid=A.villageid";
  87. $res = mysql_query ($query);
  88. if ($row = mysql_fetch_array ($res))
  89. {
  90. $type = (int)($row['type']/100);
  91. // Don't enhance this if it is an empty field and we don't have expansion slots
  92. if (($row['level'] > 0) || ($row['expansion'] > 0) || $gui->on_construction)
  93. {
  94. // This is the old check
  95. if (!check_event_village2 ($me->uid, $me->activevillageid, $type+1000, $tolevel, $z))
  96. {
  97. // and this is the new style one
  98. if ($_REQUEST['c'] == $me->reload_counter)
  99. {
  100. $tolevel = $row['level']+1;
  101. if (isset ($gui->on_construction))
  102. $tolevel += $gui->on_construction;
  103. $go_on = false;
  104. // Outposts build sloowly :)
  105. if ($row['villageid'] == $me->activeoutpostid)
  106. {
  107. $buildspeed = BUILD_TIME_BASE;
  108. $outpostid = $row['villageid'];
  109. $go_on = true;
  110. }
  111. if (($row['villageid'] == $me->activevillageid) && !$me->activeoutpostid)
  112. {
  113. $buildspeed = $me->activevillage->speed_build;
  114. $outpostid = 0;
  115. $go_on = true;
  116. }
  117. if ($go_on)
  118. {
  119. if ($me->activevillage->building_enoughcash ($type+1000, $tolevel))
  120. {
  121. // We should also pass this on to the tutorial, if it is still going strong
  122. if (is_object ($tutorial))
  123. {
  124. if ($tutorial->active)
  125. $tutorial->land_upgraded ($z, $type, $tolevel);
  126. }
  127. $costs = building_costs ($type+1000, $tolevel);
  128. $newbuiltdur = (int)(($costs[1] + $costs[2] + $costs[3]) * $buildspeed / WORLD_SPEED / BUILD_SPEED);
  129. $newbuiltdur = max (1, $newbuiltdur) + (int)$gui->building_duration;
  130. $me->activevillage->spend ($costs[1], $costs[2], $costs[3]);
  131. //FIXME: Ist das FIXME noch relevant?
  132. // Insert into event queue FIXME: Type depends on tile type, timestamp depends on finish time of last building in queue
  133. $query = "insert into event (uid1, village1, uid2, village2, type, param, param2, timestamp, score) values (".$me->uid.", ".$me->activevillageid.", 0, ".$z.", ".(1000+$type).", ".$tolevel.", ".$outpostid.", addtime(now(), sec_to_time(".$newbuiltdur.")), ".($costs[1] + $costs[2] + $costs[3]).")";
  134. if (!mysql_query ($query))
  135. {
  136. log_err ("Beim Einfügen von Rohstoffeld-Event: ".$query.", ".mysql_error());
  137. }
  138. else
  139. {
  140. log_info ($eventmap[1000+$type]." (".(1000+$type).") angefangen, wird ".$newbuiltdur." Sekunden dauern. Query: ".$query);
  141. if (count ($gui->building_queue) == 0)
  142. {
  143. $gui->displayedtimers++;
  144. $gui->building_queue[$newbuiltdur] = $eventmap[1000+$type]." ".$tolevel." <span title=\"Fertig am ".date ("d.m. H:i:s", time () + $newbuiltdur)."\" id=\"timer".$gui->displayedtimers."\">";
  145. $gui->building_queue[$newbuiltdur] .= external_calcdur ($newbuiltdur)."</span>";
  146. }
  147. else
  148. $gui->building_queue[$newbuiltdur] = $eventmap[1000+$type]." ".$tolevel." <span title=\"Fertig am ".date ("d.m. H:i:s", time () + $newbuiltdur)."\">".external_calcdur ($newbuiltdur - (int)$gui->building_duration)."</span>";
  149. // $me->activevillage->building_build ($type+1000, $tolevel);
  150. // Increment the reload counter, like with every construction command
  151. $me->reload_counter++;
  152. if (($row['level'] == 0) && !$gui->on_construction)
  153. {
  154. log_debug ("Reducing expansion slots from ".$row['expansion']." to ".($row['expansion']-1));
  155. $query = "update village set expansion=".($row['expansion']-1)." where villageid=".$row['villageid'];
  156. if (!mysql_query ($query))
  157. {
  158. log_err ("Cannot reduce expansion slots when building. Query: ".$query.", ".mysql_error ());
  159. }
  160. $me->activevillage->expansion_slots = ($row['expansion']-1);
  161. }
  162. // We are definitely on a construction site now :)
  163. $gui->on_construction++;
  164. }
  165. }
  166. else
  167. $gui->err_string .= "Nicht gen&uuml;gend Rohstoffe! ";
  168. }
  169. else
  170. $gui->err_string .= "Dieses Feld gehört nicht zur aktiven Stadt. ";
  171. }
  172. }
  173. }
  174. else
  175. $gui->err_string = "Erst Bergfried ausbauen...";
  176. }
  177. else
  178. $gui->err_string = "Dort ist keine Stadt...";
  179. }
  180. else
  181. $gui->err_string .= "Bauliste voll!";
  182. }
  183. // This check is for settling new outposts
  184. if (isset ($_REQUEST['c']))
  185. {
  186. // and this is the new style one
  187. if ($_REQUEST['c'] == $me->reload_counter)
  188. {
  189. if (isset ($_REQUEST['s']))
  190. {
  191. if(!isset($_REQUEST['b']))
  192. {
  193. Formular::setConfirmationPopUp (
  194. 'Willst du hier wirklich einen Au&szlig;enposten gr&uuml;nden?',
  195. '--> Ja, mein Reich soll gr&ouml;&szlig;er werden!!!','land.php?s='.$_REQUEST['s'].'&z='.$_REQUEST['z'].'&c='.$_REQUEST['c'].'&b=1',
  196. '--> Nein, ich habe mich verklickt','land.php?z='.$_REQUEST['z']);
  197. }
  198. else
  199. {
  200. $query = "select out_expansion from village where villageid=".$me->activevillageid;
  201. if (!($res = mysql_query ($query)))
  202. log_err ("Cannot read outpost expansion slots while settling. Query: ".$query.", ".mysql_error());
  203. else
  204. {
  205. if (!($row = mysql_fetch_row ($res)))
  206. log_err ("No rows read while reading expansion slots for setting. Query: ".$query.", ".mysql_error());
  207. else
  208. {
  209. if ($row[0] > 0)
  210. {
  211. if ($world->CheckOutpostRess ($x, $y))
  212. {
  213. $numvillages = count ($me->allvillageids);
  214. $costs = pow ($numvillages, OP_EXP)*OP_FAC;
  215. if ($me->activevillage->can_spend ($costs, $costs, $costs, $costs/OP_GOLD_DIV))
  216. {
  217. //echo "costs: ok";
  218. $me->reload_counter ++;
  219. // FIXME: Start transaction here?
  220. $query = "insert into village (uid, name, x, y, resmax, ress1, ress2, ress3, ress4, stamp, buildspeed, expansion, outpost_of) values (".$me->uid.", \"".$me->user."s Au&szlig;enposten\", ".$x.", ".$y.", ".BASE_STORAGE.", 0, 0, 0, 0, now(), 1.0, 0, ".$me->activevillageid.")";
  221. if (!($res = mysql_query ($query)))
  222. {
  223. $err = true;
  224. log_err ("Village insert query while settling failed: ".$query.": ".mysql_error());
  225. }
  226. else
  227. {
  228. require_once ("php/auxiliary.php");
  229. $villageid = mysql_insert_id ();
  230. $query = "delete from startvillage where x between ".($x-5)." and ".($x+5)." and y between ".($y-5)." and ".($y+5);
  231. // echo $query."<br>";
  232. if (!mysql_query ($query))
  233. {
  234. $err = true;
  235. log_err ("startvillage delete query failed: ".$query.": ".mysql_error());
  236. }
  237. else
  238. {
  239. AllocResTiles ($me->uid, $villageid, $x, $y);
  240. $query = "insert into armies (villageid,uid,flag,location) values (".$villageid.", ".$me->uid.", 0, ".$villageid.")";
  241. if (!mysql_query ($query))
  242. log_err ("Couldn't insert starting army for new user. Query: ".$query.", ".mysql_error ());
  243. else
  244. {
  245. $troopid = mysql_insert_id ();
  246. $query = "insert into troops select ".$troopid.",unitid,0 from units where raceid=".$me->race;
  247. if (!mysql_query ($query))
  248. log_err ("Couldn't insert starting troops for new outpost. Query: ".$query.", ".mysql_error ());
  249. $query = "insert into troops values (".$troopid.", 1000, 0)";
  250. if (!mysql_query ($query))
  251. log_err ("Couldn't insert starting hero troop for new outpost. Query: ".$query.", ".mysql_error ());
  252. }
  253. $query = "update tileres set level=1,time_exhaust=\"2038-01-01 00:00:00\" where (x=".($x-1)." and y=".$y.") or (x=".($x+1)." and y=".$y.") or (x=".$x." and y=".($y-1).") or (x=".$x." and y=".($y+1).")";
  254. if (!mysql_query ($query))
  255. {
  256. log_err ("Cannot update settled village ress tiles. Query: ".$query.", ".mysql_error());
  257. $err = true;
  258. }
  259. else
  260. {
  261. //update field to farm land as villages on mountains look funny
  262. $query = "select type from map where x=".$x." and y=".$y;
  263. if ($res = mysql_query($query))
  264. {
  265. if ($typerow = mysql_fetch_array($res))
  266. {
  267. $type = $typerow['type'];
  268. if ($type > 100)
  269. {
  270. if ($type >= 200 && $type < 300)
  271. $type = 102;
  272. if ($type >= 300 && $type < 400)
  273. $type = 103;
  274. if ($type >= 400 && $type < 500)
  275. $type = 104;
  276. }
  277. $query = "update map set type=".$type." where x=".$x." and y=".$y;
  278. if (!mysql_query($query))
  279. log_err("Could not update map when settling new outpost: ".$query);
  280. }
  281. }
  282. else
  283. {
  284. log_err("could not read ressource field type: ".$query);
  285. }
  286. $me->CalculateVillageProd($villageid);
  287. $world->ClearMapCache ($x, $y);
  288. $world->ClearLandCache ($x, $y);
  289. log_debug ("Reducing outpost expansion slots from ".$row[0]." to ".max(0, $row[0]-1));
  290. $query = "update village set out_expansion=".max (0, $row[0]-1)." where villageid=".$me->activevillageid;
  291. if (!mysql_query ($query))
  292. {
  293. log_err ("Cannot reduce outpost expansion slots when building. Query: ".$query.", ".mysql_error ());
  294. }
  295. $me->activevillage->outpost_expansion = ($row['expansion']-1);
  296. $me->activevillage->spend ($costs, $costs, $costs, $costs/OP_GOLD_DIV);
  297. $me->update_score ($costs*4);
  298. $me->save_score ();
  299. $query = "insert into eventlog (eid, uid1, village1, uid2, village2, fired, happened, type, state) select max(eid)+1, ".$me->uid.", ".$me->activevillageid.", ".$me->uid.", ".$villageid.", now(), now(), 101, 1 from eventlog";
  300. if (!mysql_query ($query))
  301. log_err ("Cannot add evenlog entry for new village. Query: ".$query.", ".mysql_error());
  302. $query = "select * from village where villageid=".$villageid;
  303. if (!($res = mysql_query ($query)))
  304. log_err ("Cannot read new village info after settling. Query: ".$query.", ".mysql_error());
  305. else
  306. {
  307. if (!($row = mysql_fetch_array ($res)))
  308. log_err ("No rows while reading new village info after settling. Query: ".$query.", ".mysql_error());
  309. else
  310. {
  311. $me->activevillage->outposts[$villageid] = new Village ($row, $me);
  312. $me->allvillageids[] = $villageid;
  313. $me->activevillage->ress_prod[1] += (int)($me->activevillage->outposts[$villageid]->ress_prod[1]/2);
  314. $me->activevillage->ress_prod[2] += (int)($me->activevillage->outposts[$villageid]->ress_prod[2]/2);
  315. $me->activevillage->ress_prod[3] += (int)($me->activevillage->outposts[$villageid]->ress_prod[3]/2);
  316. $me->activevillage->ress_prod[4] += (int)($me->activevillage->outposts[$villageid]->ress_prod[4]/2);
  317. $me->activevillage->ress_prod[5] += (int)($me->activevillage->outposts[$villageid]->ress_prod[5]/2);
  318. }
  319. }
  320. }
  321. }
  322. }
  323. }
  324. }
  325. }
  326. }
  327. }
  328. }
  329. }
  330. }
  331. }
  332. require_once ("styles/php/base_design-".$_SESSION['theme'].".php");
  333. //print_r($me->villages);
  334. echo '<div id="mapbox">';
  335. require_once('blocked.php');
  336. $theme = 2;
  337. $precalcpath = TILES_PATH.$z.".php";
  338. // Was an outpost->village upgrade requested?
  339. if (isset ($_REQUEST['u']))
  340. {
  341. // The outpost to be upgraded has to be the active outpost
  342. if ($me->activeoutpostid)
  343. {
  344. if (!isset($_REQUEST['v']))
  345. {
  346. Formular::setConfirmationPopUp('<img src="styles/'.$_SESSION['theme'].'/house.png">
  347. <span style="font-weight:bold">Willst du diesen Au&szlig;enposten wirklich zur Stadt machen?</span>',
  348. '<img src="styles/'.$_SESSION['theme'].'/accept.png"> Ja, er ist doch schon so gro&szlig; geworden', 'land.php?u='.$_REQUEST['u'].'&z='.$_REQUEST['z'].'&v=1',
  349. '<img src="styles/'.$_SESSION['theme'].'/cross.png">Nein, ich habe mich verklickt','land.php');
  350. }
  351. else
  352. {
  353. if (($me->activevillage->ress_prod[5] - $me->activeoutpost->ress_prod[5]) < $me->activevillage->sum_population ($gui))
  354. {
  355. $delerr ="<span id=\"bug\">".$me->activevillage->name." hat nicht genug Nahrung, um diesen AP (aktuelle Produktion: ".$me->activeoutpost->ress_prod[5].") zur Stadt zu machen</span><a href=\"hilfe.php?Page=544\" target=\"_blank\"> [?]</a><br>";;
  356. }
  357. else
  358. {
  359. //FIXME leider aktualisiert das jetzt die auswahlliste oben nicht mehr so schön :(
  360. // First we have to check if there are any active events pending for this outpost
  361. $query = "select * from event where type in (".ATTACK.", ".RAID.", ".SIEGE.") and (village1=".$me->activeoutpostid." or village2=".$me->activeoutpostid.")";
  362. if (!($res = mysql_query ($query)))
  363. {
  364. $me->log_err ("Cannot fetch list of pending events when deleting outpost. Query: ".$query.", ".mysql_error ());
  365. $delerr = "Leider ist ein Datenbank-Fehler aufgetreten. Bitte versuche es später nochmal.";
  366. }
  367. else
  368. {
  369. if (mysql_num_rows ($res))
  370. {
  371. $delerr = "Es bewegen sich gerade Truppen auf diesen AP oder von diesem weg. Er kann deswegen gerade nicht umgewandelt werden. Probiere es doch später noch einmal.";
  372. }
  373. else
  374. {
  375. // Fetch some infos on the outpost
  376. $query = "select expansion, besieged_by from village where villageid=".$me->activeoutpostid;
  377. if (!($res = mysql_query ($query)))
  378. log_err ("Cannot read expansion slots when upgrading outpost. Query: ".$query.", ".mysql_error ());
  379. else
  380. {
  381. if ($row = mysql_fetch_row ($res))
  382. {
  383. // Upgrade is only possible when expansion slots are here and the outpost is not under siege
  384. if (($row[0] > 0) && ($row[1] == 0))
  385. {
  386. $query = "update village set resmax=".BASE_STORAGE.",stamp=now(),ress1=0,ress2=0,ress3=0,ress4=0,expansion=0, outpost_of=0 where villageid=".$me->activeoutpostid;
  387. if (!mysql_query ($query))
  388. {
  389. log_err ("Cannot upgrade outpost to village in land.php. Query: ".$query.", ".mysql_error ());
  390. }
  391. else
  392. {
  393. $me->villages[$me->activeoutpostid] = $me->activeoutpost;
  394. $me->villages[$me->activeoutpostid]->outpost_of = 0;
  395. // print_r ($me->villages);
  396. unset ($me->villages[$me->activevillageid]->outposts[$me->activeoutpostid]);
  397. // print_r ($me->villages);
  398. $me->CalculateVillageProd ($me->activevillageid);
  399. $me->activevillage->update_production();
  400. $me->CalculateVillageProd ($me->activeoutpostid);
  401. // Move all events with the old outpost info to the new villageid
  402. $query = "update event set param2=0,village1=".$me->activeoutpostid." where village1=".$me->activevillageid." and param2=".$me->activeoutpostid;
  403. if (!mysql_query ($query))
  404. $me->log_err ("Cannot shift build queue items to new data after OP->village conversion");
  405. $me->villages[$me->activeoutpostid]->update_production();
  406. if (!isset ($world))
  407. global $world;
  408. $world->ClearMapCache ($me->villages[$me->activeoutpostid]->x, $me->villages[$me->activeoutpostid]->y);
  409. $world->ClearLandCache ($me->villages[$me->activeoutpostid]->x, $me->villages[$me->activeoutpostid]->y);
  410. // Now mark all outposts of this village as not-upgradeable and then recalculate upgradability
  411. foreach ($me->allvillageids as $this_villageid)
  412. {
  413. if (!isset ($querymid))
  414. {
  415. $querymid = $this_villageid;
  416. }
  417. else
  418. {
  419. $querymid .= ", ".$this_villageid;
  420. }
  421. }
  422. $query = "update village set expansion=0 where outpost_of in (".$querymid.") and besieged_by=0";
  423. if (!mysql_query ($query))
  424. $me->log_err ("Cannot mark all outposts non-upgradeable after upgrade. Query: ".$query.", ".mysql_error ());
  425. else
  426. {
  427. $num_vill = count ($me->villages);
  428. $me->log_debug ("Re-Checking upgradeability after oupost->city upgrade for all outposts of vid ".$me->activevillageid);
  429. foreach ($me->villages as $current_village)
  430. {
  431. foreach ($me->villages[$current_village->villageid]->outposts as $current_outpost)
  432. {
  433. $current_village->recalculate_upgrade($current_outpost->villageid, $num_vill);
  434. }
  435. }
  436. }
  437. $me->activevillageid = $me->activeoutpostid;
  438. $me->activeoutpostid = 0;
  439. $me->activeoutpost = NULL;
  440. $me->activevillage = $me->villages[$me->activevillageid];
  441. $me->activevillage->expansion_slots = 0;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. }
  452. // The user can also give up outposts
  453. if (isset ($_REQUEST['d']))
  454. {
  455. if(!isset($_REQUEST['b']))
  456. {
  457. Formular::setConfirmationPopUp (
  458. '<img src="styles/'.$_SESSION['theme'].'/house.png">
  459. <span style="color:red;font-weight:bold">Willst du wirklich diesen Au&szlig;enposten aufgeben?
  460. <br><br>Du kannst diese Aktion nicht r&uuml;ckg&auml;ngig machen.</span>',
  461. '<img src="styles/'.$_SESSION['theme'].'/accept.png">Ja, weg mit ihm!!!', 'land.php?d='.$_REQUEST['d'].'&z='.$_REQUEST['z'].'&b=1',
  462. '<img src="styles/'.$_SESSION['theme'].'/cross.png">Nein, ich hab mich verklickt','land.php?z='.$_REQUEST['z']);
  463. }
  464. else
  465. {
  466. //TODO: move this to the top of file, so land view gets updated immediately
  467. // First we have to check if there are any active events pending for this outpost
  468. $query = "select * from event where type in (".ATTACK.", ".RAID.", ".SIEGE.", ".RETURNING.") and (village1=".$me->activeoutpostid." or village2=".$me->activeoutpostid.")";
  469. if (!($res = mysql_query ($query)))
  470. {
  471. $me->log_err ("Cannot fetch list of pending events when deleting outpost. Query: ".$query.", ".mysql_error ());
  472. $delerr = "Leider ist ein Datenbank-Fehler aufgetreten. Bitte versuche es später nochmal.";
  473. }
  474. else
  475. {
  476. if (mysql_num_rows ($res))
  477. {
  478. $delerr = "Es bewegen sich gerade Truppen auf diesen AP oder von diesem weg. Er kann deswegen gerade nicht aufgegeben werden. Bitte probiere es später noch einmal.";
  479. }
  480. else
  481. {
  482. // Also check if there are any supporting units in the city
  483. $query = "select sum(B.amount) as total from armies A, troops B where A.location=".$me->activeoutpostid." and A.troopid=B.troopid";
  484. if (!($res = mysql_query ($query)))
  485. {
  486. $me->log_err ("Cannot read amount of supporting troops when deleting outpost. Query: ".$query.", ".mysql_error ());
  487. $delerr = "Leider ist ein Datenbank-Fehler aufgetreten. Bitte versuche es später nochmal.";
  488. }
  489. else
  490. {
  491. if ($row = mysql_fetch_array ($res))
  492. {
  493. if ($row['total'] > 0)
  494. {
  495. $delerr = "Du hast noch unterstützende Einheiten in diesem Außenposten. Schicke diese zuerst heim.";
  496. }
  497. }
  498. }
  499. if (!isset ($delerr))
  500. {
  501. $numvillages = count ($me->allvillageids) - 1;
  502. // reduce score for abandoning outpost
  503. $costs = pow ($numvillages, 2)*OP_FAC;
  504. $me->log_debug ("NV:".$numvillages.", costs:".$costs);
  505. $me->update_score ($costs*(-4));
  506. $me->save_score ();
  507. // So we can delete the ole buddy. First delete the village entry, then free up the map space.
  508. $query = "delete from village where villageid=".$me->activeoutpostid;
  509. if (!mysql_query ($query))
  510. {
  511. $me->log_err ("Cannot delete outpost: ".$query.", ".mysql_error ());
  512. $delerr = "Leider ist ein Datenbank-Fehler aufgetreten. Bitte versuche es später nochmal.";
  513. }
  514. else
  515. {
  516. $query = "delete from tileres where villageid=".$me->activeoutpostid;
  517. if (!mysql_query ($query))
  518. {
  519. $me->log_err ("Cannot delete outpost: ".$query.", ".mysql_error ());
  520. $delerr = "Leider ist ein Datenbank-Fehler aufgetreten. Bitte versuche es später nochmal.";
  521. }
  522. else
  523. {
  524. // The next step is to delete events that may still be lying around for this village.
  525. // The only event type that outposts can have apart from attack/spy are ressource level upgrades
  526. $query = "delete from event where type in (1000,1001,1002,1003,1004) and village1=".$me->activeoutpost->outpost_of." and param2=".$me->activeoutpostid;
  527. if (!mysql_query ($query))
  528. {
  529. $me->log_err ("Cannot delete outpost: ".$query.", ".mysql_error ());
  530. $delerr = "Leider ist ein Datenbank-Fehler aufgetreten. Bitte versuche es später nochmal.";
  531. }
  532. else
  533. {
  534. //convert ressourcefield back
  535. $query = "select type from map where x=".$me->activeoutpost->x." and y=".$me->activeoutpost->y;
  536. if ($res = mysql_query($query))
  537. {
  538. if ($typerow = mysql_fetch_array($res))
  539. {
  540. $type = $typerow['type'];
  541. if ($type > 100)
  542. {
  543. if ($type == 102)
  544. $type = 200;
  545. if ($type == 103)
  546. $type = 300;
  547. if ($type == 104)
  548. $type = 400;
  549. $query = "update map set type=".$type." where x=".$me->activeoutpost->x." and y=".$me->activeoutpost->y;
  550. if (!mysql_query($query))
  551. log_err("could not convert ressource field type back: ".$query);
  552. }
  553. }
  554. }
  555. // Then clear up caches as long as we still have the position data
  556. $world->ClearMapCache ($me->activeoutpost->x, $me->activeoutpost->y);
  557. $world->ClearLandCache ($me->activeoutpost->x, $me->activeoutpost->y);
  558. // Hand back the expansion slot to the village that created this outpost
  559. $query = "update village set out_expansion=out_expansion+1 where villageid=".$me->activevillageid;
  560. if (!mysql_query ($query))
  561. {
  562. $me->log_err ("Cannot delete outpost: ".$query.", ".mysql_error ());
  563. $delerr = "Leider ist ein Datenbank-Fehler aufgetreten. Bitte versuche es später nochmal.";
  564. }
  565. $me->activevillage->outpost_expansion++;
  566. // Also remove the villageid from the global vid array
  567. foreach ($me->allvillageids as $idx=>$vid)
  568. {
  569. if ($vid == $me->activeoutpostid)
  570. unset ($me->allvillageids[$idx]);
  571. }
  572. // Finally recalculate production and clean up the village list.
  573. unset ($me->villages[$me->activeoutpostid]);
  574. unset ($me->activevillage->outposts[$me->activeoutpostid]);
  575. $me->CalculateVillageProd ($me->activevillageid);
  576. $me->activevillage->update_production();
  577. $me->activeoutpostid = 0;
  578. $me->activeoutpost = NULL;
  579. }
  580. }
  581. }
  582. }
  583. }
  584. }
  585. }
  586. }
  587. if (isset ($delerr))
  588. Formular::setConfirmationPopUp($delerr, 'Ok, dann nicht', 'land.php?z='.$_REQUEST['z'], '', '' );
  589. // $me->activevillage->update_stamp ();
  590. $todobox = "";
  591. $infobox = "";
  592. $berichtebox = "";
  593. if (!is_object($tutorial) || !$tutorial->active || $tutorial->seeLink("Land")) // tutorial im fullscreen modus?
  594. {
  595. // Instead of precalcing the info box, we do it on-the-fly
  596. // Much better error resilience
  597. //Infobox may display information about the current town
  598. $query = "select *,score/1000 as pop from village where x=".$x." and y=".$y;
  599. $res = mysql_query ($query);
  600. // Check if this is a village
  601. if ($villagerow = mysql_fetch_array ($res))
  602. {
  603. // ghost towns can be handled more efficiently
  604. if (in_array ($villagerow['uid'], $_ghost_uids))
  605. {
  606. // Yes, this is a ghost town
  607. $infobox .= "<span class=\"info\">Dies ist eine verlassene Stadt, die nur noch von den Geistern bev&ouml;lkert wird.</span>";
  608. $is_ghost = true;
  609. }
  610. else
  611. {
  612. $res = mysql_query ("select A.user, B.name as class, C.name as race, A.userflags from user A, classes B, races C where A.uid=".$villagerow['uid']." and B.classid=A.class and C.raceid=A.race");
  613. $userrow = mysql_fetch_array ($res);
  614. $infobox .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\"><tr>\n";
  615. if ($villagerow['outpost_of'] > 0)
  616. $infobox .= "<tr><td class=\"inhalt\">AP :</td><td colspan=\"3\" class=\"inhalt\">".stripslashes ($villagerow['name'])."</td></tr>\n";
  617. else
  618. $infobox .= "<tr><td class=\"inhalt\">Stadt:</td><td colspan=\"3\" class=\"inhalt\">".stripslashes ($villagerow['name'])."</td></tr>\n";
  619. /* echo
  620. "<tr><td class=\"inhalt\">EW &nbsp;<a href=\"hilfe.php?Page=782\" target=\"_blank\"><img src=\"styles/".$_SESSION['theme']."/help.png\"></a>:</td><td colspan=\"3\" class=\"inhalt\">".(int)."</td></tr>"; */
  621. $query = "select A.ranking, round(B.score/1000) as score, B.aid, C.tag, B.inactivity from ranking A join user B on (A.uid=".$villagerow['uid']." and B.uid=".$villagerow['uid'].") left join allies C on (B.aid=C.aid)";
  622. $res = mysql_query ($query);
  623. $row = mysql_fetch_row ($res);
  624. $infobox .= "</td></tr>\n<tr><td class=\"inhalt\">Spieler:</td><td colspan=\"3\" class=\"inhalt\"><a href=\"profile.php?u=".$villagerow['uid']."\">";
  625. $infobox .= style_username ($villagerow['uid'], $userrow['user'], $row[4], $userrow['userflags']);
  626. $infobox .= "</a>&nbsp;(Rang: ".$row[0].")";
  627. $infobox .= "<tr><td class=\"inhalt\">Allianz:</td><td colspan=\"3\" class=\"inhalt\">";
  628. // We should also pass this on to the tutorial, if it is still going strong
  629. if (is_object ($tutorial))
  630. {
  631. if ($tutorial->active)
  632. $tutorial->land_city_position ($villagerow['uid'], $userrow['user'], $row[0]);
  633. }
  634. if ($row[2])
  635. $infobox .= "<a href=\"allianz.php?a=".$row[2]."\">".$row[3]."</a></td></tr>\n";
  636. else
  637. $infobox .= "Keine Allianz</td></tr>\n";
  638. $infobox .= "<tr><td class=\"inhalt\">Punkte:</td><td colspan=\"3\" class=\"inhalt\">".(int)$villagerow['pop']."&nbsp;<a href=\"hilfe.php?Page=782\" target=\"_blank\"><img src=\"styles/".$_SESSION['theme']."/help.png\"></a> von ".$row[1]."</td></tr>\n</table>";
  639. }
  640. if (($row[4] == 1) || ($row[4] == 2))
  641. $todobox .= "<span class=\"info\">Dieser Spieler ist inaktiv<a href=\"hilfe.php?Page=566\" target=\"_blank\">&nbsp;<img src=\"styles/".$_SESSION['theme']."/help.png\"></a></span>";
  642. else
  643. {
  644. if ($row[4] == 3)
  645. $todobox .= "<span class=\"info\">Dieser Spieler ist wegen einem Regelverstoß gesperrt.</span>";
  646. }
  647. if ($villagerow['uid'] != $me->uid)
  648. {
  649. //sind die beiden allianzen im krieg?
  650. //FIXME SchuetzMich
  651. // echo $row[1]." ".round($me->score*4)." ".$row[4]." ".in_array ($row[2], $me->allywars);
  652. if (($row[1] < $me->score*4) || ($row[4] != 0) || $is_ghost || in_array ($row[2], $me->allywars))
  653. {
  654. if (($row[1]*4 > $me->score) || $row[4] || $is_ghost || in_array ($row[2], $me->allywars))
  655. {
  656. // If we are besieging this outpost, we display a different menu
  657. if ($villagerow['besieged_by'] == $me->uid)
  658. {
  659. $todobox .= '<a href="einheiten.php?f=3&sendtroops='; // FIXME
  660. }
  661. if ($me->sat_by)
  662. $todobox .= '<span class="info">Sitter d&uuml;rfen nur innerhalb der eigenen St&auml;dte Truppen verschicken.</span>';
  663. else
  664. {
  665. $todobox .= "<a href=\"einheiten.php?f=3&sendtroops[".ATTACK."]=Angreifen&x=".$x."&y=".$y."\" class=\"dark\">Angreifen</a><a href=\"hilfe.php?Page=545\" target=\"_blank\">&nbsp;<img src=\"styles/".$_SESSION['theme']."/help.png\"></a> &nbsp;";
  666. $todobox .= " <a href=\"einheiten.php?f=3&sendtroops[".RAID."]=Raubzug&x=".$x."&y=".$y."\" class=\"dark\">Raubzug</a><a href=\"hilfe.php?Page=555\" target=\"_blank\">&nbsp;<img src=\"styles/".$_SESSION['theme']."/help.png\"></a>";
  667. if (GROUP_ATTACK_POSSIBLE)
  668. $todobox .= "<a href=\"einheiten.php?f=3&sendtroops[".GROUPATTACK."]=Gruppenangriff&x=".$x."&y=".$y."\" class=\"dark\">Gruppenangriff</a><a href=\"hilfe.php?Page=790\" target=\"_blank\">&nbsp;<img src=\"styles/".$_SESSION['theme']."/help.png\"></a>\n";
  669. if ($villagerow['outpost_of'] && $me->activevillage->outpost_expansion && SIEGE_POSSIBLE)
  670. $todobox .= "<a href=\"einheiten.php?f=3&sendtroops[".SIEGE."]=Erobern&x=".$x."&y=".$y."\" class=\"dark\">Erobern</a><a href=\"hilfe.php?Page=545\" target=\"_blank\">&nbsp;<img src=\"styles/".$_SESSION['theme']."/help.png\"></a>\n";
  671. $todobox .= "<a href=\"einheiten.php?f=3&sendtroops[".SPY."]=Spionieren&x=".$x."&y=".$y."\" class=\"dark\">Spionieren</a><a href=\"hilfe.php?Page=554\" target=\"_blank\">&nbsp;<img src=\"styles/".$_SESSION['theme']."/help.png\"></a>\n";
  672. }
  673. }
  674. else
  675. $todobox .= "<span class=\"info\">Dieser Spieler ist für dich im Noob-Schutz.<a href=\"hilfe.php?Page=540\" target=\"_blank\"><img src=\"styles/".$_SESSION['theme']."/help.png\"></a></span>";
  676. }
  677. else
  678. $todobox .= "<span class=\"info\">Für diesen Spieler bist du im Noob-Schutz.<a href=\"hilfe.php?Page=540\" target=\"_blank\">&nbsp;<img src=\"styles/".$_SESSION['theme']."/help.png\"></a></span>";
  679. }
  680. if (($me->activevillageid != $villagerow['villageid']) && $me->activeoutpostid != $villagerow['villageid'] && !$me->activeoutpostid && !($me->sat_by && $villagerow['uid'] != $me->uid))
  681. {
  682. $todobox .= "<a href=\"einheiten.php?f=3&sendtroops[".SUPPORT."]=Unterstützen&x=".$x."&y=".$y."&r=1\">Unterst&uuml;tzen&nbsp;<a href=\"hilfe.php?Page=553\" target=\"_blank\"><img src=\"styles/".$_SESSION['theme']."/help.png\"></a>";
  683. if ($me->uid == $villagerow['uid'])
  684. $todobox .= "<a href=\"einheiten.php?f=3&sendtroops[".MOVE."]=Stationieren&x=".$x."&y=".$y."&r=1\">Stationieren</a>&nbsp;<a href=\"hilfe.php?Page=783\" target=\"_blank\"><img src=\"styles/".$_SESSION['theme']."/help.png\"></a>\n";
  685. }
  686. if (!$villagerow['outpost_of'] && !$me->activeoutpostid)
  687. {
  688. if (($villagerow['villageid'] != $me->activevillageid) && (!$row[4]))
  689. $todobox .= "<a href=\"handel.php?f=1&x=".$x."&y=".$y."\" class=\"dark\">Beliefern</a><br>\n";
  690. }
  691. else
  692. {
  693. if (($villagerow['villageid'] == $me->activeoutpostid) && ($villagerow['uid'] == $me->uid))
  694. {
  695. if ($villagerow['expansion'])
  696. {
  697. if (($me->activevillage->ress_prod[5] - $me->activeoutpost->ress_prod[5]) < $me->activevillage->sum_population ($gui))
  698. $todobox .= "<span class=\"bug\">".$me->activevillage->name." hat nicht genug Nahrung, um diesen AP (aktuelle Produktion: ".$me->activeoutpost->ress_prod[5].") zur Stadt zu machen</span><a href=\"hilfe.php?Page=544\" target=\"_blank\"> <img src=\"styles/".$_SESSION['theme']."/help.png\"></a><br>";
  699. else
  700. $todobox .= "<img src=\"styles/".$_SESSION['theme']."/accept.png\"><a href=\"land.php?u=1&z=".$z."\">Au&szlig;enposten zur Stadt machen</a><br>";
  701. }
  702. else
  703. {
  704. $todobox .= '<span class="info">Umwandlung zur Stadt erst m&ouml;glich, wenn alle Felder Stufe '.(count ($me->villages) * OP_LEVEL_FAC);
  705. $todobox .= '&nbsp;<a href="hilfe.php?Page=544" target="_blank"><img src="styles/'.$_SESSION['theme']."/help.png\"></a></span>";
  706. }
  707. if (!isset ($delerr))
  708. $todobox .= '<a href="land.php?d=1&z='.$z.'"><img src="styles/'.$_SESSION['theme'].'/cross.png">Au&szlig;enposten aufgeben</a>';
  709. }
  710. }
  711. $berichtebox = "";
  712. //berichte may display the last reports belonging to that town
  713. if (!is_object($tutorial) || !$tutorial->active)
  714. {
  715. if ($me->aid && !$me->sat_by)
  716. {
  717. if (count($me->allymeta) > 0)
  718. {
  719. $query = "select reportid,date_format(stamp, \"%d.%c %H:%i\") as stamp2 from reports where (touid=".$me->uid." or toaid in (".implode (",", $me->allymeta).")) and village2=".$villagerow['villageid']." and type<5 order by stamp desc limit 4";
  720. }
  721. else
  722. {
  723. $query = "select reportid,date_format(stamp, \"%d.%c %H:%i\") as stamp2 from reports where touid=".$me->uid." and village2=".$villagerow['villageid']." and type<5 order by stamp desc limit 4";
  724. }
  725. }
  726. else
  727. {
  728. $query = "select reportid,date_format(stamp, \"%d.%c %H:%i\") as stamp2 from reports where touid=".$me->uid." and village2=".$villagerow['villageid']." and type<5 order by stamp desc limit 4";
  729. }
  730. if (!($res = mysql_query ($query)))
  731. log_err ("Cannot read reports in tileview. Query: ".$query.", ".mysql_error());
  732. if (mysql_num_rows ($res) > 0)
  733. {
  734. while ($row = mysql_fetch_row ($res))
  735. $berichtebox .= "<a href=\"berichte.php?f=6&id=".$row[0]."\" alt=\"Bericht vom ".$row[1]."\">".$row[1]."</a><br>\n";
  736. mysql_free_result ($res);
  737. }
  738. else
  739. $berichtebox .= "Es liegen keine Berichte vor.";
  740. }
  741. }
  742. else
  743. {
  744. // So it might be a tile owned by a village
  745. $query = "select A.villageid, A.level, A.staff, A.resprod1, A.resprod2, A.resprod3, A.resprod4, B.name, B.uid, B.outpost_of, C.user, D.name as class, E.name as race, F.type, F.reserves, time_to_sec(timediff(now(),F.lastchange)) as lastchange2 from tileres A, village B, user C, races D, classes E, map F where A.x=".$x." and A.y=".$y." and A.villageid=B.villageid and B.uid=C.uid and D.raceid=C.race and E.classid=C.class and F.x=".$x." and F.y=".$y;
  746. // echo $query;
  747. if (!($res = mysql_query ($query)))
  748. $me->log_err ("Cannot fetch tile info in land dialogue. Query: ".$query.", ".mysql_error ());
  749. if ($row = mysql_fetch_array ($res))
  750. {
  751. $tolevel = $row['level'] + 1 + $gui->on_construction;
  752. // Yes, it is. We have to differentiate here in the precalc code, though
  753. // Here we could detect a field in the own village radius but not utilized yet
  754. // By checking level, I guess
  755. // We should also pass this on to the tutorial, if it is still going strong
  756. if (is_object ($tutorial))
  757. {
  758. if ($tutorial->active)
  759. $tutorial->land_position ($z, (int)($row['type'] / 100), $tolevel);
  760. }
  761. global $glob_costs;
  762. $eventtype = (int)($row['type'] / 100) + 1000;
  763. $fieldtype = (int)($row['type'] / 100);
  764. if ($row['uid'] == $me->uid)
  765. {
  766. if (($row['villageid'] == $me->activeoutpostid) || (($row['villageid'] == $me->activevillageid) && !$me->activeoutpostid))
  767. {
  768. if (($row['level'] > 0) || $gui->on_construction || ($me->villages[$row['villageid']]->expansion_slots > 0))
  769. {
  770. $villageid = $row['villageid']; // FIXME here: say something intelligent when villageid != activevillageid, but don't display build info
  771. if (isset ($factor))
  772. $this_income = $me->tile_ressource_yield (($eventtype-1000), $row['level']);
  773. else
  774. $this_income = $me->tile_ressource_yield (($eventtype-1000), $row['level']);
  775. $infobox .= "<table cellspacing=\"0\" >";
  776. $this_field_prod = $me->tile_ressource_yield ($fieldtype, $row['level']);
  777. switch ($fieldtype)
  778. {
  779. case 0: // enclave
  780. $pic = "styles/".$_SESSION['theme']."/gold.gif";
  781. $remaining = "unendlich";
  782. break;
  783. case 2: // woods
  784. $pic = "styles/".$_SESSION['theme']."/holz.gif";
  785. $remaining = prettynumber (max (0, (int)($row['reserves'] - ($me->hero->less_exhaust[2] * max (0, ($this_income[1] - (FOREST_REGROWTH * WORLD_SPEED))) * ($row['lastchange2']/3600)))));
  786. break;
  787. case 3:
  788. $pic = "styles/".$_SESSION['theme']."/stein.gif";
  789. $remaining = prettynumber (max (0, (int)($row['reserves'] - ($me->hero->less_exhaust[3] * $row['resprod2'] * ($row['lastchange2']/3600)))));
  790. break;
  791. case 4:
  792. $pic = "styles/".$_SESSION['theme']."/eisen.gif";
  793. $remaining = prettynumber (max (0, (int)($row['reserves'] - ($me->hero->less_exhaust[4] * $row['resprod4'] * ($row['lastchange2']/3600)))));
  794. break;
  795. case 1:
  796. $pic = "styles/".$_SESSION['theme']."/nahrung.gif";
  797. $remaining = "unendlich";
  798. break;
  799. }
  800. if (!is_object($tutorial) || !$tutorial->active || $tutorial->seeLandInfo (60, (int)($row['type'] / 100)))
  801. {
  802. $infobox .= "<tr><td colspan=\"5\"><span class=\"info\"><b>".$eventmap[$eventtype]."</b> Stufe ".$row['level']."</span>";
  803. if (FINITE_RESSOURCES)
  804. {
  805. $infobox .= "<td colspan=\"5\"><table cellspacing=\"0\"><tr><td>Rohstoff-Reserven:</td><td> <img src=\"".$pic."\" width=\"18\"></td><td>".$remaining."</td></tr></table>";
  806. }
  807. $infobox .= "</td></tr><tr><td>";
  808. $infobox .= "Aktuelle Produktion:</td>\n";
  809. if ($this_income[1])
  810. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/holz.gif\" width=\"18\" title=\"Holz\">&nbsp;</td><td>".prettynumber ($this_income[1])."</td> ";
  811. if ($this_income[2])
  812. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/stein.gif\" width=\"18\" title=\"Stein\">&nbsp;</td><td>".prettynumber ($this_income[2])."</td> ";
  813. if ($this_income[3])
  814. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/eisen.gif\" width=\"18\" title=\"Eisen\">&nbsp;</td><td>".prettynumber ($this_income[3])."</td> ";
  815. if ($this_income[4])
  816. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/gold.gif\" width=\"18\" title=\"Gold\">&nbsp;</td><td>".prettynumber ($this_income[4])."</td> ";
  817. if ($this_income[5])
  818. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/nahrung.gif\" width=\"18\" title=\"Nahrung\">&nbsp;</td><td>".prettynumber ($this_income[5]);
  819. $infobox .= "</tr>\n";
  820. if (isset ($factor))
  821. $this_income = $me->tile_ressource_yield (($eventtype-1000), $tolevel, $factor);
  822. else
  823. $this_income = $me->tile_ressource_yield (($eventtype-1000), $tolevel);
  824. $infobox .= "<tr><td>Produktion auf Stufe ".$tolevel.":\n</td>";
  825. if ($this_income[1])
  826. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/holz.gif\" width=\"18px\" title=\"Holz\">&nbsp;</td><td>".prettynumber ($this_income[1])."</td> ";
  827. if ($this_income[2])
  828. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/stein.gif\" width=\"18px\" title=\"Stein\">&nbsp;</td><td>".prettynumber ($this_income[2])."</td> ";
  829. if ($this_income[3])
  830. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/eisen.gif\" width=\"18px\" title=\"Eisen\">&nbsp;</td><td>".prettynumber ($this_income[3])."</td> ";
  831. if ($this_income[4])
  832. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/gold.gif\" width=\"18px\" title=\"Gold\">&nbsp;</td><td>".prettynumber ($this_income[4])."</td> ";
  833. if ($this_income[5])
  834. $infobox .= "<td><img src=\"styles/".$_SESSION['theme']."/nahrung.gif\" width=\"18px\" title=\"Nahrung\">&nbsp;</td><td>".prettynumber ($this_income[5]);
  835. $infobox .= "</td></tr>";
  836. }
  837. $infobox .= "</table>"; // Ende Produktions-Box
  838. if ($row['outpost_of'])
  839. {
  840. $thiscosts = building_costs ($eventtype, $tolevel);
  841. $dur = (int)(($thiscosts[1]+$thiscosts[2]+$thiscosts[3]+$thiscosts[4])*BUILD_TIME_BASE/ WORLD_SPEED / BUILD_SPEED);
  842. }
  843. else
  844. {
  845. $thiscosts = building_costs ($eventtype, $tolevel);
  846. $dur = (int)(($thiscosts[1]+$thiscosts[2]+$thiscosts[3]+$thiscosts[4]) * $me->villages[$row['villageid']]->speed_build/ WORLD_SPEED / BUILD_SPEED);
  847. }
  848. $dur = max (1, $dur);
  849. $tmp_notenough = false;
  850. $coststr = $me->activevillage->display_money ($thiscosts);
  851. $todobox .= '<span class="info">Ausbau von '.$glob_costs[$eventtype][5]." Stufe ".$tolevel.":</span>";
  852. $todobox .= $coststr."<br>\n";
  853. $todobox .= "<img src=\"gfx/hourglass.png\" > ".external_calcdur ($dur)."<br>\n";
  854. if (isset ($gui->building_queue))
  855. if (count ($gui->building_queue) >= 2)
  856. {
  857. $todobox .= "<span class=\"info\">Bauschleife voll</span>";
  858. $no_go = true;
  859. }
  860. if (!isset ($no_go))
  861. {
  862. if (!is_object($tutorial) || !$tutorial->active || $tutorial->seeLandInfo (70, (int)($row['type']/100)))
  863. {
  864. if ($tmp_notenough)
  865. $todobox .= "<span class=\"info\">Nicht genug Rohstoffe f&uuml;r ".$glob_costs[$eventtype][5]." ".$tolevel." </span><br>";
  866. else
  867. {
  868. $todobox .= "<a href=\"land.php?z=".$z."&r=1&l=".$tolevel."&c=".(int)$me->reload_counter."\" class=\"dark\"><img src=\"gfx/hammer.gif\" width=\"16\" height=\"16\">jetzt ausbauen.</a><br>";
  869. }
  870. }
  871. }
  872. }
  873. else
  874. $todobox .= '<span class="info">'.$main_buildings[$me->race]." muss ausgebaut werden, bevor ein freies Feld erschlossen werden kann</span>";
  875. //</div>";
  876. }
  877. else
  878. $todobox .= '<span class="error">Gehört nicht zur aktiven Stadt. Wechsle mit der Auswahlliste oben dorthin.</span>';
  879. }
  880. }
  881. else
  882. {
  883. //if (is_object($tutorial) && $tutorial->active && !$tutorial->seeLandInfo(80))
  884. {
  885. $can_settle = false;
  886. // This field is empty and might be ready for settlers
  887. // Only fields that do not border directly to the border (hah) can be settled on
  888. if (($x < 7) || ($x > $world->sizex - 7) || ($y < 7) || ($y > $world->sizey - 7))
  889. $todobox .= "<span class=\"error\">So nahe am Rand der Welt kann man nicht siedeln.</span>";
  890. else
  891. {
  892. if ($me->activevillage->outpost_expansion > 0)
  893. {
  894. if (($fields = $world->CheckOutpostRess ($x, $y)))
  895. {
  896. $infobox .= "<span class=\"info\">Feldverteilung:</span>";
  897. $infobox .= 'Steppe: '.(int)$fields[0].'<br>Grasland: '.(int)$fields[1].'<br>Wald: '.(int)$fields[2].'<br>H&uuml;gel: '.(int)$fields[3].'<br>Gebirge: '.(int)$fields[4].'';
  898. $numvillages = count ($me->allvillageids);
  899. $costs = pow ($numvillages, 2)*OP_FAC;
  900. $thiscosts = array (1=>$costs, 2=>$costs, 3=>$costs, 4=>$costs/OP_GOLD_DIV);
  901. $tmp_notenough = false;
  902. $coststr = $me->activevillage->display_money ($thiscosts);
  903. require_once("php/base/Tutorial.inc.php");
  904. if (!$me->activeoutpostid)
  905. {
  906. if ($tmp_notenough)
  907. $todobox .= '<span class="info">Nicht genug Rohstoffe, um einen Au&szlig;enposten zu errichten.</span>';
  908. else
  909. {
  910. $can_settle = true;
  911. $todobox .= "<a href=\"land.php?s=1&z=".$z."&c=".$me->reload_counter."\">Au&szlig;enposten gründen</a><br>";
  912. }
  913. $todobox .= $coststr;
  914. }
  915. else
  916. $todobox .= '<span class="error">Au&szlig;enposten k&ouml;nnen keine Aussenposten gr&uuml;nden, das geht nur von St&auml;dten aus.<br></span>';
  917. }
  918. else
  919. $todobox .= "<span class=\"info\">Hier ist nicht genug Platz für einen Au&szlig;enposten.</span>";
  920. }
  921. else
  922. {
  923. $todobox .= '<span class="error">' . $main_buildings[$me->race]." muss ausgebaut werden, bevor du einen Au&szlig;enposten gründen kannst</span>";
  924. }
  925. }
  926. }
  927. }
  928. }
  929. // Define ressource names here
  930. $resnames = array (0=>"deine Enklave. Die Enklave ist eine Gel&auml;ndeart, die nur auf Selador vorkommt. Angeblich gibt es dort viel Gold!", 1=>"dein Farmland. Dort k&ouml;nnen deine Bauern reiche Ernten einfahren.", 2=>"dein Holzf&auml;ller. Die B&auml;ume wachsen hier sehr dicht.", 3=>"dein Steinbruch. Der Stein w&auml;re praktisch f&uuml;r die Stadtausbauten.", 4=>"deine Eisenmine. Sobald du ernsthaft Truppen ausbildest, wirst du viel Eisen brauchen.");
  931. }
  932. //the user ist still in the tutorial and may not see the map
  933. else
  934. {
  935. $tutorial->outputFullscreen();
  936. }
  937. if (!is_object($tutorial) || !$tutorial->active || $tutorial->seeLink("Land")) // tutorial im fullscreen modus?
  938. {
  939. echo '<div id="bottom-land">';
  940. if (!is_object($tutorial) || !$tutorial->active)
  941. {
  942. echo "<div id=\"koords\"><form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">
  943. <table border=\"0\" cellpadding=\"0\" cellspacing=\"3\" height=\"100%\">
  944. <tr valign=\"middle\">
  945. <td class=\"inhalt\">x: <br><input class=\"eingabe\" name=\"x\" type=\"text\" size=\"2\" maxlength=\"4\" value=\"".$x."\"></td>
  946. <td class=\"inhalt\">y: <br><input class=\"eingabe\" name=\"y\" type=\"text\" size=\"2\" maxlength=\"4\" value=\"".$y."\"></td>
  947. </tr>
  948. <tr>
  949. <td align=\"right\"><input class=\"eingabe\" type=\"submit\" name=\"go\" value=\"Go!\"></td>";
  950. echo '<td><a href="welt.php?x='.$x.'&y='.$y.'&h=true"><img src="styles/'.$_SESSION['theme'].'/world.png" title="Auf Weltkarte anzeigen"></a></td>';
  951. echo "</tr></table><br>";
  952. echo "</form></div>";
  953. }
  954. echo "<div id=\"land-infos\"";
  955. if (is_object($tutorial) && $tutorial->active && !$tutorial->seeLandInfo(20))
  956. echo ' style="visibility:hidden"';
  957. if (is_object($tutorial) && $tutorial->active && $tutorial->highlight(51))
  958. echo ' style="border: 3px solid red"';
  959. echo ">\n";
  960. echo $infobox;
  961. echo "</div>";
  962. //todo box may display
  963. // - Links to interact with another player
  964. // - Links to build a ressource field
  965. // - Links to upgrade an outpost
  966. // - Links to build an outpost
  967. echo "<div id=\"options\"";
  968. if (is_object($tutorial) && $tutorial->active && (!$tutorial->seeLandInfo(30) && !($tutorial->seeLandInfo(40, ($row['type']/100)))))
  969. echo ' style="visibility:hidden"';
  970. if (is_object($tutorial) && $tutorial->active && ($tutorial->highlight(20) || $tutorial->highlight(50)))
  971. echo ' style="border: 3px solid red"';
  972. echo ">\n";
  973. echo $todobox;
  974. echo "</div>";
  975. if ($berichtebox)
  976. {
  977. echo "<div id=\"berichte\" ";
  978. if (is_object($tutorial) && $tutorial->active && !($tutorial->seeLandInfo(50)))
  979. echo ' style="visibility:hidden"';
  980. echo tt ("Falls es zu dieser Stadt Berichte von dir oder deinen Allianzkollegen gibt, siehst du diese hier.")."";
  981. echo ">Letzte Berichte:<br>";
  982. echo $berichtebox;
  983. echo "</div>";
  984. }
  985. }
  986. echo '</div>';
  987. if (!file_exists ($precalcpath))
  988. {
  989. require_once ("php/tiles.php");
  990. draw_map ($x, $y, $precalcpath, 3, $me, 2);
  991. }
  992. if (!is_object($tutorial) || !$tutorial->active || $tutorial->seeLink("Land"))
  993. {
  994. echo '<div id="landview">
  995. ';
  996. require_once ($precalcpath);
  997. echo '
  998. </div>';
  999. }
  1000. echo '</div>';
  1001. require_once("footer.php");

Large files files are truncated, but you can click here to view the full file