Skip to content
This repository
Browse code

big update

  • Loading branch information...
commit 8c44bb4e2a58dd3bc1d7ae8826bd78f1cbdcba5c 1 parent a566e25
unknown authored

Showing 46 changed files with 1,465 additions and 993 deletions. Show diff stats Hide diff stats

  1. +3 4 Admin/admin.php
  2. +0 1  GameEngine/Account.php
  3. +32 4 GameEngine/Admin/database.php
  4. +8 1 GameEngine/Alliance.php
  5. +341 80 GameEngine/Automation.php
  6. +755 793 GameEngine/Battle.php
  7. +1 1  GameEngine/Building.php
  8. +15 9 GameEngine/Database/db_MYSQL.php
  9. +1 1  GameEngine/Generator.php
  10. +6 2 GameEngine/Ranking.php
  11. +1 0  GameEngine/Session.php
  12. +7 7 GameEngine/Technology.php
  13. +34 28 Templates/Ajax/quest_core.tpl
  14. +57 0 Templates/Alliance/alliance.tpl
  15. +1 1  Templates/Alliance/overview.tpl
  16. +34 0 Templates/Build/19_train.tpl
  17. +3 1 Templates/Build/20.tpl
  18. +3 3 Templates/Build/21.tpl
  19. +1 1  Templates/Build/25_train.tpl
  20. +1 1  Templates/Build/26_train.tpl
  21. +1 1  Templates/Build/37_hero.tpl
  22. +2 2 Templates/Message/write.tpl
  23. +15 1 Templates/Notice/18.tpl
  24. +15 1 Templates/Notice/18x.tpl
  25. +15 1 Templates/Notice/19.tpl
  26. +15 1 Templates/Notice/19x.tpl
  27. +15 1 Templates/Notice/20.tpl
  28. +15 1 Templates/Notice/20x.tpl
  29. +15 1 Templates/Notice/21.tpl
  30. +15 1 Templates/Notice/21x.tpl
  31. +4 4 Templates/Notice/3x.tpl
  32. +1 1  Templates/Plus/10.tpl
  33. +1 1  Templates/Plus/11.tpl
  34. +1 1  Templates/Plus/12.tpl
  35. +1 1  Templates/Plus/9.tpl
  36. +1 3 Templates/Profile/account.tpl
  37. +1 1  Templates/Ranking/ww.tpl
  38. +0 2  Templates/menu.tpl
  39. +2 2 Templates/quest.tpl
  40. +2 2 anmelden.php
  41. +1 1  create_account.php
  42. +1 1  dorf1.php
  43. BIN  gpack/travian_default/img/q/l4.jpg
  44. BIN  gpack/travian_default/img/q/l4g.jpg
  45. +2 2 login.php
  46. +20 22 medals.php
7 Admin/admin.php
@@ -93,7 +93,6 @@ function hideStuff(id) {
93 93 <a href="<?php echo HOMEPAGE; ?>">Server Homepage</a>
94 94 <a href="admin.php">Control Panel Home</a>
95 95 <a href="<?php echo SERVER; ?>dorf1.php">Return to the server</a>
96   - <a href="?p=update"><font color="Red"><b>Server Update</font></b></a>
97 96 <br />
98 97 <a href="?action=logout">Logout</a>
99 98 <br />
@@ -103,8 +102,8 @@ function hideStuff(id) {
103 102 <a href="?p=notregistered">Players Not Activated</a>
104 103 <br />
105 104 <a href="#"><b>Search</b></a>
106   - <a href="?p=search">General Search</a>
107   - <a href="?p=message">Search IGMs/Reports</a>
  105 + <a href="?p=search">Search Players/Alliances/Villages/E-mails/IPs/Deleted Players</a>
  106 + <a href="?p=message">Search Messages/Battle Reports</a>
108 107 <br />
109 108 <a href="#"><b>Ban</b></a>
110 109 <a href="?p=ban">Ban/Unban Players</a>
@@ -130,7 +129,7 @@ function hideStuff(id) {
130 129 <br />
131 130 <a href="#"><b>Natars</b></a>
132 131 <a href="?p=natarend">Add WW Villages</a>
133   - <a href="?p=natarbuildingplan">Add WW Building Plan Villages</a>
  132 + <a href="?p=natarbuildingplan">Add WW Buildingplan Villages</a>
134 133 <br />
135 134 <a href="#"><b>Admin:</b></a>
136 135 <a href="?p=admin_log"><font color="Red"><b>Admin Log</font></b></a>
1  GameEngine/Account.php
@@ -114,7 +114,6 @@ private function Signup() {
114 114 if($uid) {
115 115 setcookie("COOKUSR",$_POST['name'],time()+COOKIE_EXPIRE,COOKIE_PATH);
116 116 setcookie("COOKEMAIL",$_POST['email'],time()+COOKIE_EXPIRE,COOKIE_PATH);
117   -
118 117 $database->updateUserField($uid,"act","",1);
119 118 $database->updateUserField($uid,"invited",$_POST['invited'],1);
120 119 $this->generateBase($_POST['kid'],$uid,$_POST['name']);
36 GameEngine/Admin/database.php
@@ -52,6 +52,7 @@ function recountPopUser($uid){
52 52 for ($i = 0; $i <= count($villages)-1; $i++) {
53 53 $vid = $villages[$i]['wref'];
54 54 $this->recountPop($vid);
  55 + $this->recountCP($vid);
55 56 }
56 57 }
57 58
@@ -60,15 +61,30 @@ function recountPop($vid){
60 61 $fdata = $database->getResourceLevel($vid);
61 62 $popTot = 0;
62 63 for ($i = 1; $i <= 40; $i++) {
63   - $lvl = $fdata["f".$i];
64   - $building = $fdata["f".$i."t"];
65   - if($building){
  64 + $lvl = $fdata["f".$i];
  65 + $building = $fdata["f".$i."t"];
  66 + if($building){
66 67 $popTot += $this->buildingPOP($building,$lvl);
67   - }
  68 + }
68 69 }
69 70 $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
70 71 mysql_query($q, $this->connection);
71 72 }
  73 +
  74 + function recountCP($vid){
  75 + global $database;
  76 + $fdata = $database->getResourceLevel($vid);
  77 + $popTot = 0;
  78 + for ($i = 1; $i <= 40; $i++) {
  79 + $lvl = $fdata["f".$i];
  80 + $building = $fdata["f".$i."t"];
  81 + if($building){
  82 + $popTot += $this->buildingCP($building,$lvl);
  83 + }
  84 + }
  85 + $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
  86 + mysql_query($q, $this->connection);
  87 + }
72 88
73 89 function buildingPOP($f,$lvl){
74 90 $name = "bid".$f;
@@ -80,6 +96,18 @@ function buildingPOP($f,$lvl){
80 96 }
81 97 return $popT;
82 98 }
  99 +
  100 + function buildingCP($f,$lvl){
  101 + $name = "bid".$f;
  102 + global $$name;
  103 + $popT = 0;
  104 + $dataarray = $$name;
  105 +
  106 + for ($i = 0; $i <= $lvl; $i++) {
  107 + $popT += $dataarray[$i]['cp'];
  108 + }
  109 + return $popT;
  110 + }
83 111
84 112 function getWref($x,$y) {
85 113 $q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y";
9 GameEngine/Alliance.php
@@ -108,7 +108,7 @@ public function procAlliForm($post) {
108 108 public function sendInvite($post) {
109 109 global $form, $database, $session;
110 110 if($session->access != BANNED){
111   - if(isset($post['a_name']) && $post['a_uid'] != ""){
  111 + if(isset($post['a_name']) or $post['a_uid'] == ""){
112 112 $UserData = $database->getUserArray($post['a_name'], 0);
113 113 if($this->userPermArray['opt4'] == 0) {
114 114 $form->addError("perm", NO_PERMISSION);
@@ -393,6 +393,13 @@ private function quitally($post) {
393 393 } elseif(md5($post['pw']) !== $session->userinfo['password']) {
394 394 $form->addError("pw2", PW_ERR);
395 395 } else {
  396 + if($database->isAllianceOwner($sessiom->uid)){
  397 + $newowner = $database->getAllMember2($session->alliance);
  398 + $newleader = $newowner['id'];
  399 + $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$session->alliance."";
  400 + $database->query($q);
  401 + $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1);
  402 + }
396 403 $database->updateUserField($session->uid, 'alliance', 0, 1);
397 404 $database->deleteAlliPermissions($session->uid);
398 405 // log the notice
421 GameEngine/Automation.php
... ... @@ -1,7 +1,9 @@
1 1 <?php
2   -if (!isset($_SESSION)) {
3   - session_start();
4   -}
  2 +# Developed By : Mr.php
  3 +# you have no rights to change this !!
  4 +# Fixed : Doubling Troops , Hero not dieing etc ..
  5 +# Email : mr.php-majed@hotmail.com
  6 +# Skype : mr.majed1005
5 7
6 8 class Automation {
7 9
@@ -101,6 +103,7 @@ function recountCP($vid){
101 103 global $database;
102 104 $fdata = $database->getResourceLevel($vid);
103 105 $popTot = 0;
  106 +
104 107 for ($i = 1; $i <= 40; $i++) {
105 108 $lvl = $fdata["f".$i];
106 109 $building = $fdata["f".$i."t"];
@@ -109,7 +112,7 @@ function recountCP($vid){
109 112 }
110 113 }
111 114
112   - $q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
  115 + $q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
113 116 mysql_query($q);
114 117
115 118 return $popTot;
@@ -141,39 +144,77 @@ function buildingCP($f,$lvl){
141 144 }
142 145
143 146 public function Automation() {
  147 +
144 148 $this->procClimbers();
  149 + $this->ClearUser();
145 150 $this->ClearInactive();
146 151 $this->oasisResoucesProduce();
147 152 $this->pruneResource();
148 153 $this->pruneOResource();
149 154 $this->checkWWAttacks();
150   - $this->culturePoints();
151   - $this->updateHero();
152   - $this->clearDeleting();
153   - $this->buildComplete();
  155 + if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time()-filemtime("GameEngine/Prevention/culturepoints.txt")>10) {
  156 + $this->culturePoints();
  157 + }
  158 + if(!file_exists("GameEngine/Prevention/updatehero.txt") or time()-filemtime("GameEngine/Prevention/updatehero.txt")>50) {
  159 + $this->updateHero();
  160 + }
  161 + if(!file_exists("GameEngine/Prevention/cleardeleting.txt") or time()-filemtime("GameEngine/Prevention/cleardeleting.txt")>10) {
  162 + $this->clearDeleting();
  163 + }
  164 + if (! file_exists("GameEngine/Prevention/build.txt") or time() - filemtime("GameEngine/Prevention/build.txt") > 10)
  165 + {
  166 + $this->buildComplete();
  167 + }
154 168 $this->MasterBuilder();
155   - $this->demolitionComplete();
  169 + if (! file_exists("GameEngine/Prevention/demolition.txt") or time() - filemtime("GameEngine/Prevention/demolition.txt") > 10)
  170 + {
  171 + $this->demolitionComplete();
  172 + }
156 173 $this->updateStore();
157 174 $this->delTradeRoute();
158 175 $this->TradeRoute();
159   - $this->marketComplete();
160   - $this->researchComplete();
161   - $this->trainingComplete();
162   - $this->starvation();
163   - $this->celebrationComplete();
164   - $this->sendunitsComplete();
165   - $this->loyaltyRegeneration();
166   - $this->sendreinfunitsComplete();
167   - $this->returnunitsComplete();
168   - $this->sendSettlersComplete();
  176 + if(!file_exists("GameEngine/Prevention/market.txt") or time()-filemtime("GameEngine/Prevention/market.txt")>10) {
  177 + $this->marketComplete();
  178 + }
  179 + if(!file_exists("GameEngine/Prevention/research.txt") or time()-filemtime("GameEngine/Prevention/research.txt")>10) {
  180 + $this->researchComplete();
  181 + }
  182 + if(!file_exists("GameEngine/Prevention/training.txt") or time()-filemtime("GameEngine/Prevention/training.txt")>10) {
  183 + $this->trainingComplete();
  184 + }
  185 + if(!file_exists("GameEngine/Prevention/starvation.txt") or time()-filemtime("GameEngine/Prevention/starvation.txt")>10) {
  186 + $this->starvation();
  187 + }
  188 + if(!file_exists("GameEngine/Prevention/celebration.txt") or time()-filemtime("GameEngine/Prevention/celebration.txt")>10) {
  189 + $this->celebrationComplete();
  190 + }
  191 + if(!file_exists("GameEngine/Prevention/sendunits.txt") or time()-filemtime("GameEngine/Prevention/sendunits.txt")>10) {
  192 + $this->sendunitsComplete();
  193 + }
  194 + if(!file_exists("GameEngine/Prevention/loyalty.txt") or time()-filemtime("GameEngine/Prevention/loyalty.txt")>50) {
  195 + $this->loyaltyRegeneration();
  196 + }
  197 + if(!file_exists("GameEngine/Prevention/sendreinfunits.txt") or time()-filemtime("GameEngine/Prevention/sendreinfunits.txt")>10) {
  198 + $this->sendreinfunitsComplete();
  199 + }
  200 + if(!file_exists("GameEngine/Prevention/returnunits.txt") or time()-filemtime("GameEngine/Prevention/returnunits.txt")>51) {
  201 + $this->returnunitsComplete();
  202 + }
  203 + if(!file_exists("GameEngine/Prevention/settlers.txt") or time()-filemtime("GameEngine/Prevention/settlers.txt")>10) {
  204 + $this->sendSettlersComplete();
  205 + }
169 206 $this->updateGeneralAttack();
170 207 $this->checkInvitedPlayes();
  208 + $this->updateStore();
171 209 $this->CheckBan();
172 210 $this->regenerateOasisTroops();
173 211 $this->artefactOfTheFool();
174 212 }
175 213
176 214 private function loyaltyRegeneration() {
  215 + if(file_exists("GameEngine/Prevention/loyalty.txt")) {
  216 + unlink("GameEngine/Prevention/loyalty.txt");
  217 + }
177 218 global $database;
178 219 $array = array();
179 220 $q = "SELECT * FROM ".TB_PREFIX."vdata WHERE loyalty<>100";
@@ -209,6 +250,9 @@ private function loyaltyRegeneration() {
209 250 $database->query($q);
210 251 }
211 252 }
  253 + if(file_exists("GameEngine/Prevention/loyalty.txt")) {
  254 + unlink("GameEngine/Prevention/loyalty.txt");
  255 + }
212 256 }
213 257
214 258 private function getfieldDistance($coorx1, $coory1, $coorx2, $coory2) {
@@ -271,7 +315,12 @@ public function getTypeLevel($tid,$vid) {
271 315 }
272 316
273 317 private function clearDeleting() {
  318 + if(file_exists("GameEngine/Prevention/cleardeleting.txt")) {
  319 + unlink("GameEngine/Prevention/cleardeleting.txt");
  320 + }
274 321 global $database;
  322 + $ourFileHandle = fopen("GameEngine/Prevention/cleardeleting.txt", 'w');
  323 + fclose($ourFileHandle);
275 324 $needDelete = $database->getNeedDelete();
276 325 if(count($needDelete) > 0) {
277 326 foreach($needDelete as $need) {
@@ -281,14 +330,12 @@ private function clearDeleting() {
281 330 $database->query($q);
282 331 $q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$village;
283 332 $database->query($q);
284   - $q = "DELETE FROM ".TB_PREFIX."enforcement where vref = ".$village;
  333 + $q = "DELETE FROM ".TB_PREFIX."enforcement where from = ".$village;
285 334 $database->query($q);
286 335 $q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$village;
287 336 $database->query($q);
288 337 $q = "DELETE FROM ".TB_PREFIX."market where vref = ".$village;
289 338 $database->query($q);
290   - $q = "DELETE FROM ".TB_PREFIX."movement where to = ".$village." or from = ".$village;
291   - $database->query($q);
292 339 $q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$village;
293 340 $database->query($q);
294 341 $q = "DELETE FROM ".TB_PREFIX."research where vref = ".$village;
@@ -299,11 +346,56 @@ private function clearDeleting() {
299 346 $database->query($q);
300 347 $q = "DELETE FROM ".TB_PREFIX."units where vref =".$village;
301 348 $database->query($q);
302   - $q = "DELETE FROM ".TB_PREFIX."vdata where vref = ".$village;
  349 + $q = "DELETE FROM ".TB_PREFIX."vdata where wref = ".$village;
303 350 $database->query($q);
304 351 $q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$village;
305 352 $database->query($q);
  353 + $getmovement = $database->getMovement(3,$village,1);
  354 + foreach($getmovement as $movedata) {
  355 + $time = time();
  356 + $time2 = $time - $movedata['starttime'];
  357 + $database->addMovement(4,$movedata['to'],$movedata['from'],$movedata['ref'],$time,$time+$time2);
  358 + $database->setMovementProc($movedata['moveid']);
  359 + }
  360 + $q = "DELETE FROM ".TB_PREFIX."movement where from = ".$village;
  361 + $database->query($q);
  362 + $getprisoners = $database->getPrisoners($village);
  363 + foreach($getprisoners as $pris) {
  364 + $troops = 0;
  365 + for($i=1;$i<12;$i++){
  366 + $troops += $pris['t'.$i];
  367 + }
  368 + $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
  369 + $database->deletePrisoners($pris['id']);
  370 + }
  371 + $getprisoners = $database->getPrisoners3($village);
  372 + foreach($getprisoners as $pris) {
  373 + $troops = 0;
  374 + for($i=1;$i<12;$i++){
  375 + $troops += $pris['t'.$i];
  376 + }
  377 + $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
  378 + $database->deletePrisoners($pris['id']);
  379 + }
  380 + $enforcement = $database->getEnforceVillage($village,0);
  381 + foreach($enforcement as $enforce) {
  382 + $time = time();
  383 + $fromcoor = $database->getCoor($enforce['vref']);
  384 + $tocoor = $database->getCoor($enforce['from']);
  385 + $targettribe = $database->getUserField($database->getVillageField($enforce['from'],"owner"),"tribe",0);
  386 + $time2 = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0);
  387 + $start = 10*($targettribe-1);
  388 + for($i=1;$i<11;$i++){
  389 + $unit = $start + $i;
  390 + $post['t'.$i] = $enforce['u'.$unit];
  391 + }
  392 + $post['t11'] = $enforce['hero'];
  393 + $reference = $database->addAttack($enforce['from'],$post['t1'],$post['t2'],$post['t3'],$post['t4'],$post['t5'],$post['t6'],$post['t7'],$post['t8'],$post['t9'],$post['t10'],$post['t11'],2,0,0,0,0);
  394 + $database->addMovement(4,$enforce['vref'],$enforce['from'],$reference,$time,$time+$time2);
  395 + }
306 396 }
  397 + $q = "DELETE FROM ".TB_PREFIX."hero where uid = ".$need['uid'];
  398 + $database->query($q);
307 399 $q = "DELETE FROM ".TB_PREFIX."mdata where target = ".$need['uid']." or owner = ".$need['uid'];
308 400 $database->query($q);
309 401 $q = "DELETE FROM ".TB_PREFIX."ndata where uid = ".$need['uid'];
@@ -312,8 +404,20 @@ private function clearDeleting() {
312 404 $database->query($q);
313 405 }
314 406 }
  407 + if(file_exists("GameEngine/Prevention/cleardeleting.txt")) {
  408 + unlink("GameEngine/Prevention/cleardeleting.txt");
  409 + }
315 410 }
316   -
  411 +
  412 + private function ClearUser() {
  413 + global $database;
  414 + if(AUTO_DEL_INACTIVE) {
  415 + $time = time()+UN_ACT_TIME;
  416 + $q = "DELETE from ".TB_PREFIX."users where timestamp >= $time and act != ''";
  417 + $database->query($q);
  418 + }
  419 + }
  420 +
317 421 private function ClearInactive() {
318 422 global $database;
319 423 if(TRACK_USR) {
@@ -470,6 +574,9 @@ private function pruneResource() {
470 574 }
471 575
472 576 private function culturePoints() {
  577 + if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
  578 + unlink("GameEngine/Prevention/culturepoints.txt");
  579 + }
473 580 global $database,$session;
474 581 $time = time()-600; // 10minutes
475 582 $array = array();
@@ -485,9 +592,15 @@ private function culturePoints() {
485 592 $database->query($q);
486 593 }
487 594 }
488   - }
  595 + if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
  596 + unlink("GameEngine/Prevention/culturepoints.txt");
  597 + }
  598 +}
489 599
490 600 private function buildComplete() {
  601 + if(file_exists("GameEngine/Prevention/build.txt")) {
  602 + unlink("GameEngine/Prevention/build.txt");
  603 + }
491 604 global $database,$bid18,$bid10,$bid11,$bid38,$bid39;
492 605 $time = time();
493 606 $array = array();
@@ -584,6 +697,9 @@ private function buildComplete() {
584 697 $database->setVillageField($indi['wid'], 'starvupdate', $time);
585 698 }
586 699 }
  700 + if(file_exists("GameEngine/Prevention/build.txt")) {
  701 + unlink("GameEngine/Prevention/build.txt");
  702 + }
587 703 }
588 704
589 705 // by SlimShady95 aka Manuel Mannhardt < manuel_mannhardt@web.de >
@@ -782,7 +898,12 @@ private function TradeRoute() {
782 898 }
783 899
784 900 private function marketComplete() {
  901 + if(file_exists("GameEngine/Prevention/market.txt")) {
  902 + unlink("GameEngine/Prevention/market.txt");
  903 + }
785 904 global $database;
  905 + $ourFileHandle = fopen("GameEngine/Prevention/market.txt", 'w');
  906 + fclose($ourFileHandle);
786 907 $time = time();
787 908 $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."send where ".TB_PREFIX."movement.ref = ".TB_PREFIX."send.id and ".TB_PREFIX."movement.proc = 0 and sort_type = 0 and endtime < $time";
788 909 $dataarray = $database->query_return($q);
@@ -817,6 +938,9 @@ private function marketComplete() {
817 938 $this->sendResource2($data1['wood'],$data1['clay'],$data1['iron'],$data1['crop'],$data1['to'],$data1['from'],$targettribe1,$send);
818 939 }
819 940 }
  941 + if(file_exists("GameEngine/Prevention/market.txt")) {
  942 + unlink("GameEngine/Prevention/market.txt");
  943 + }
820 944 }
821 945
822 946 private function sendResource2($wtrans,$ctrans,$itrans,$crtrans,$from,$to,$tribe,$send) {
@@ -854,7 +978,12 @@ private function sendResource2($wtrans,$ctrans,$itrans,$crtrans,$from,$to,$tribe
854 978 }
855 979
856 980 private function sendunitsComplete() {
  981 + if(file_exists("GameEngine/Prevention/sendunits.txt")) {
  982 + unlink("GameEngine/Prevention/sendunits.txt");
  983 + }
857 984 global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator;
  985 + $ourFileHandle = fopen("GameEngine/Prevention/sendunits.txt", 'w');
  986 + fclose($ourFileHandle);
858 987 $time = time();
859 988 $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '3' and ".TB_PREFIX."attacks.attack_type != '2' and endtime < $time ORDER BY endtime ASC";
860 989 $dataarray = $database->query_return($q);
@@ -956,9 +1085,9 @@ private function sendunitsComplete() {
956 1085 $end = ($owntribe*10);
957 1086 $u = (($owntribe-1)*10);
958 1087 $catp = 0;
959   - $catapult = array(8,18,28,38,48);
960   - $ram = array(7,17,27,37,47);
961   - $chief = array(9,19,29,39,49);
  1088 + $catapult = array(8,18,28,48);
  1089 + $ram = array(7,17,27,47);
  1090 + $chief = array(9,19,29,49);
962 1091 $spys = array(4,14,23,44);
963 1092 for($i=$start;$i<=$end;$i++) {
964 1093 $y = $i-$u;
@@ -1112,8 +1241,6 @@ private function sendunitsComplete() {
1112 1241 $end = ($owntribe*10);
1113 1242 $u = (($owntribe-1)*10);
1114 1243 $catp = 0;
1115   - $rams = 0;
1116   - $chiefs = 0;
1117 1244 $catapult = array(8,18,28,38,48);
1118 1245 $ram = array(7,17,27,37,47);
1119 1246 $chief = array(9,19,29,39,49);
@@ -1703,7 +1830,7 @@ private function sendunitsComplete() {
1703 1830 for ($i=1;$i<=41;$i++)
1704 1831 {
1705 1832 if ($i==41) $i=99;
1706   - if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0)
  1833 + if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
1707 1834 {
1708 1835 $j++;
1709 1836 $_rand[$j]=$bdo['f'.$i];
@@ -1732,7 +1859,7 @@ private function sendunitsComplete() {
1732 1859 for ($i=1;$i<=41;$i++)
1733 1860 {
1734 1861 if ($i==41) $i=99;
1735   - if ($bdo['f'.$i] > 0)
  1862 + if ($bdo['f'.$i] > 0 && $rand != 31 && $rand != 32 && $rand != 33)
1736 1863 {
1737 1864 $list[$j]=$i;
1738 1865 $j++;
@@ -1773,7 +1900,8 @@ private function sendunitsComplete() {
1773 1900 $database->query($q);
1774 1901 }
1775 1902 $pop=$this->recountPop($data['to']);
1776   - if($pop=='0')
  1903 + $capital = $database->getVillage($data['to']);
  1904 + if($pop=='0' && $capital['capital']=='0')
1777 1905 {
1778 1906 $village_destroyed = 1;
1779 1907 }
@@ -1827,7 +1955,7 @@ private function sendunitsComplete() {
1827 1955 for ($i=1;$i<=41;$i++)
1828 1956 {
1829 1957 if ($i==41) $i=99;
1830   - if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0)
  1958 + if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
1831 1959 {
1832 1960 $j++;
1833 1961 $_rand[$j]=$bdo['f'.$i];
@@ -1856,7 +1984,7 @@ private function sendunitsComplete() {
1856 1984 for ($i=1;$i<=41;$i++)
1857 1985 {
1858 1986 if ($i==41) $i=99;
1859   - if ($bdo['f'.$i] > 0)
  1987 + if ($bdo['f'.$i] > 0 && $rand != 31 && $rand != 32 && $rand != 33)
1860 1988 {
1861 1989 $j++;
1862 1990 $list[$j]=$i;
@@ -1951,7 +2079,7 @@ private function sendunitsComplete() {
1951 2079 for ($i=1;$i<=41;$i++)
1952 2080 {
1953 2081 if ($i==41) $i=99;
1954   - if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0)
  2082 + if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
1955 2083 {
1956 2084 $j++;
1957 2085 $_rand[$j]=$bdo['f'.$i];
@@ -2380,7 +2508,7 @@ private function sendunitsComplete() {
2380 2508 $database->modifyAttack2($data['ref'],10,$prisoner['t10']);
2381 2509 $database->modifyAttack2($data['ref'],11,$prisoner['t11']);
2382 2510 $mytroops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
2383   - $newtraps = (round($mytroops/3))*2;
  2511 + $newtraps = round($mytroops/3);
2384 2512 $database->modifyUnit($data['to'],array("99"),array($newtraps),array(0));
2385 2513 $database->modifyUnit($data['to'],array("99o"),array($mytroops),array(0));
2386 2514 }else{
@@ -2464,7 +2592,7 @@ private function sendunitsComplete() {
2464 2592 }
2465 2593 }
2466 2594 }
2467   - $data2 = $data2.','.$info_trap.',,';
  2595 + $data2 = $data2.','.addslashes($info_trap).',,';
2468 2596 if($totalsend_alldef == 0){
2469 2597 $database->addNotice($to['owner'],$to['wref'],$targetally,7,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
2470 2598 }else if($totaldead_alldef == 0){
@@ -2582,6 +2710,40 @@ private function sendunitsComplete() {
2582 2710 }
2583 2711 $q = "DELETE FROM ".TB_PREFIX."movement where from = ".$data['to'];
2584 2712 $database->query($q);
  2713 + $getprisoners = $database->getPrisoners($data['to']);
  2714 + foreach($getprisoners as $pris) {
  2715 + $troops = 0;
  2716 + for($i=1;$i<12;$i++){
  2717 + $troops += $pris['t'.$i];
  2718 + }
  2719 + $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
  2720 + $database->deletePrisoners($pris['id']);
  2721 + }
  2722 + $getprisoners = $database->getPrisoners3($data['to']);
  2723 + foreach($getprisoners as $pris) {
  2724 + $troops = 0;
  2725 + for($i=1;$i<12;$i++){
  2726 + $troops += $pris['t'.$i];
  2727 + }
  2728 + $database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
  2729 + $database->deletePrisoners($pris['id']);
  2730 + }
  2731 + $enforcement = $database->getEnforceVillage($data['to'],0);
  2732 + foreach($enforcement as $enforce) {
  2733 + $time = time();
  2734 + $fromcoor = $database->getCoor($enforce['vref']);
  2735 + $tocoor = $database->getCoor($enforce['from']);
  2736 + $targettribe = $database->getUserField($database->getVillageField($enforce['from'],"owner"),"tribe",0);
  2737 + $time2 = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0);
  2738 + $start = 10*($targettribe-1);
  2739 + for($i=1;$i<11;$i++){
  2740 + $unit = $start + $i;
  2741 + $post['t'.$i] = $enforce['u'.$unit];
  2742 + }
  2743 + $post['t11'] = $enforce['hero'];
  2744 + $reference = $database->addAttack($enforce['from'],$post['t1'],$post['t2'],$post['t3'],$post['t4'],$post['t5'],$post['t6'],$post['t7'],$post['t8'],$post['t9'],$post['t10'],$post['t11'],2,0,0,0,0);
  2745 + $database->addMovement(4,$enforce['vref'],$enforce['from'],$reference,$time,$time+$time2);
  2746 + }
2585 2747 }
2586 2748 }
2587 2749 }else{
@@ -2716,6 +2878,9 @@ private function sendunitsComplete() {
2716 2878 #################################################
2717 2879
2718 2880 }
  2881 + if(file_exists("GameEngine/Prevention/sendunits.txt")) {
  2882 + unlink("GameEngine/Prevention/sendunits.txt");
  2883 + }
2719 2884 }
2720 2885
2721 2886 private function sendTroopsBack($post) {
@@ -2846,8 +3011,13 @@ private function sendTroopsBack($post) {
2846 3011 }
2847 3012
2848 3013 private function sendreinfunitsComplete() {
  3014 + if(file_exists("GameEngine/Prevention/sendreinfunits.txt")) {
  3015 + unlink("GameEngine/Prevention/sendreinfunits.txt");
  3016 + }
2849 3017 global $bid23,$database,$battle;
2850 3018 $time = time();
  3019 + $ourFileHandle = fopen("GameEngine/Prevention/sendreinfunits.txt", 'w');
  3020 + fclose($ourFileHandle);
2851 3021 $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '3' and ".TB_PREFIX."attacks.attack_type = '2' and endtime < $time";
2852 3022 $dataarray = $database->query_return($q);
2853 3023 foreach($dataarray as $data) {
@@ -2909,10 +3079,18 @@ private function sendreinfunitsComplete() {
2909 3079 $database->setMovementProc($data['moveid']);
2910 3080 }
2911 3081 }
  3082 + if(file_exists("GameEngine/Prevention/sendreinfunits.txt")) {
  3083 + unlink("GameEngine/Prevention/sendreinfunits.txt");
  3084 + }
2912 3085 }
2913 3086
2914 3087 private function returnunitsComplete() {
  3088 + if(file_exists("GameEngine/Prevention/returnunits.txt")) {
  3089 + unlink("GameEngine/Prevention/returnunits.txt");
  3090 + }
2915 3091 global $database;
  3092 + $ourFileHandle = fopen("GameEngine/Prevention/returnunits.txt", 'w');
  3093 + fclose($ourFileHandle);
2916 3094 $time = time();
2917 3095 $q = "SELECT * FROM ".TB_PREFIX."movement, ".TB_PREFIX."attacks where ".TB_PREFIX."movement.ref = ".TB_PREFIX."attacks.id and ".TB_PREFIX."movement.proc = '0' and ".TB_PREFIX."movement.sort_type = '4' and endtime < $time";
2918 3096 $dataarray = $database->query_return($q);
@@ -2961,10 +3139,19 @@ private function returnunitsComplete() {
2961 3139 $database->modifyUnit($data['to'],array($tribe."0"),array(3),array(1));
2962 3140 $database->setMovementProc($data['moveid']);
2963 3141 }
  3142 +
  3143 + if(file_exists("GameEngine/Prevention/returnunits.txt")) {
  3144 + unlink("GameEngine/Prevention/returnunits.txt");
  3145 + }
2964 3146 }
2965 3147
2966 3148 private function sendSettlersComplete() {
  3149 + if(file_exists("GameEngine/Prevention/settlers.txt")) {
  3150 + unlink("GameEngine/Prevention/settlers.txt");
  3151 + }
2967 3152 global $database, $building;
  3153 + $ourFileHandle = fopen("GameEngine/Prevention/settlers.txt", 'w');
  3154 + fclose($ourFileHandle);
2968 3155 $time = time();
2969 3156 $q = "SELECT * FROM ".TB_PREFIX."movement where proc = 0 and sort_type = 5 and endtime < $time";
2970 3157 $dataarray = $database->query_return($q);
@@ -3005,10 +3192,18 @@ private function sendSettlersComplete() {
3005 3192 $database->setMovementProc($data['moveid']);
3006 3193 }
3007 3194 }
3008   - }
  3195 + if(file_exists("GameEngine/Prevention/settlers.txt")) {
  3196 + unlink("GameEngine/Prevention/settlers.txt");
  3197 + }
  3198 + }
3009 3199
3010 3200 private function researchComplete() {
  3201 + if(file_exists("GameEngine/Prevention/research.txt")) {
  3202 + unlink("GameEngine/Prevention/research.txt");
  3203 + }
3011 3204 global $database;
  3205 + $ourFileHandle = fopen("GameEngine/Prevention/research.txt", 'w');
  3206 + fclose($ourFileHandle);
3012 3207 $time = time();
3013 3208 $q = "SELECT * FROM ".TB_PREFIX."research where timestamp < $time";
3014 3209 $dataarray = $database->query_return($q);
@@ -3027,6 +3222,9 @@ private function researchComplete() {
3027 3222 $q = "DELETE FROM ".TB_PREFIX."research where id = ".$data['id'];
3028 3223 $database->query($q);
3029 3224 }
  3225 + if(file_exists("GameEngine/Prevention/research.txt")) {
  3226 + unlink("GameEngine/Prevention/research.txt");
  3227 + }
3030 3228 }
3031 3229
3032 3230 private function updateRes($bountywid,$uid) {
@@ -3137,8 +3335,9 @@ function getAllUnits($base) {
3137 3335
3138 3336 public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
3139 3337 global $database,$session,$village;
3140   - if ($vid == 0) { $vid = $_SESSION['wid']; }
3141   - $buildarray = $database->getResourceLevel($vid);
  3338 + if($vid==0) { $vid=$village->wid; }
  3339 + $buildarray = array();
  3340 + if($vid!=0){ $buildarray = $database->getResourceLevel($vid); }
3142 3341 $upkeep = 0;
3143 3342 switch($type) {
3144 3343 case 0:
@@ -3209,9 +3408,9 @@ public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
3209 3408 }else{
3210 3409 $upkeep += $array['t11'] * 6;
3211 3410 }
3212   - $artefact = count($database->getOwnUniqueArtefactInfo2($_SESSION['id_user'],4,3,0));
  3411 + $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,4,3,0));
3213 3412 $artefact1 = count($database->getOwnUniqueArtefactInfo2($vid,4,1,1));
3214   - $artefact2 = count($database->getOwnUniqueArtefactInfo2($_SESSION['id_user'],4,2,0));
  3413 + $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,4,2,0));
3215 3414 if($artefact > 0){
3216 3415 $upkeep /= 2;
3217 3416 $upkeep = round($upkeep);
@@ -3223,7 +3422,7 @@ public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
3223 3422 $upkeep = round($upkeep);
3224 3423 $upkeep *= 3;
3225 3424 }
3226   - $foolartefact = $database->getFoolArtefactInfo(4,$vid,$_SESSION['id_user']);
  3425 + $foolartefact = $database->getFoolArtefactInfo(4,$vid,$session->uid);
3227 3426 if(count($foolartefact) > 0){
3228 3427 foreach($foolartefact as $arte){
3229 3428 if($arte['bad_effect'] == 1){
@@ -3414,8 +3613,13 @@ private function bountyGetCropProd() {
3414 3613 }
3415 3614
3416 3615 private function trainingComplete() {
  3616 + if(file_exists("GameEngine/Prevention/training.txt")) {
  3617 + unlink("GameEngine/Prevention/training.txt");
  3618 + }
3417 3619 global $database;
3418 3620 $time = time();
  3621 + $ourFileHandle = fopen("GameEngine/Prevention/training.txt", 'w');
  3622 + fclose($ourFileHandle);
3419 3623 $trainlist = $database->getTrainingList();
3420 3624 if(count($trainlist) > 0){
3421 3625 foreach($trainlist as $train){
@@ -3452,6 +3656,9 @@ private function trainingComplete() {
3452 3656 }
3453 3657 }
3454 3658 }
  3659 + if(file_exists("GameEngine/Prevention/training.txt")) {
  3660 + unlink("GameEngine/Prevention/training.txt");
  3661 + }
3455 3662 }
3456 3663
3457 3664 public function procDistanceTime($coor,$thiscoor,$ref,$mode) {
@@ -3546,7 +3753,13 @@ private function getsort_typeLevel($tid,$resarray) {
3546 3753 }
3547 3754
3548 3755 private function celebrationComplete() {
  3756 + if(file_exists("GameEngine/Prevention/celebration.txt")) {
  3757 + unlink("GameEngine/Prevention/celebration.txt");
  3758 + }
3549 3759 global $database;
  3760 + $ourFileHandle = fopen("GameEngine/Prevention/celebration.txt", 'w');
  3761 + fclose($ourFileHandle);
  3762 +
3550 3763 $varray = $database->getCel();
3551 3764 foreach($varray as $vil){
3552 3765 $id = $vil['wref'];
@@ -3556,10 +3769,19 @@ private function celebrationComplete() {
3556 3769 $database->clearCel($id);
3557 3770 $database->setCelCp($user,$cp);
3558 3771 }
  3772 + if(file_exists("GameEngine/Prevention/celebration.txt")) {
  3773 + unlink("GameEngine/Prevention/celebration.txt");
  3774 + }
3559 3775 }
3560 3776
3561 3777 private function demolitionComplete() {
  3778 + if(file_exists("GameEngine/Prevention/demolition.txt")) {
  3779 + unlink("GameEngine/Prevention/demolition.txt");
  3780 + }
3562 3781 global $building,$database;
  3782 + $ourFileHandle = fopen("GameEngine/Prevention/demolition.txt", 'w');
  3783 + fclose($ourFileHandle);
  3784 +
3563 3785 $varray = $database->getDemolition();
3564 3786 foreach($varray as $vil) {
3565 3787 if ($vil['timetofinish'] <= time()) {
@@ -3586,16 +3808,22 @@ private function demolitionComplete() {
3586 3808 $database->delDemolition($vil['vref']);
3587 3809 }
3588 3810 }
  3811 + if(file_exists("GameEngine/Prevention/demolition.txt")) {
  3812 + unlink("GameEngine/Prevention/demolition.txt");
  3813 + }
3589 3814 }
3590 3815
3591 3816 private function updateHero() {
  3817 + if(file_exists("GameEngine/Prevention/updatehero.txt")) {
  3818 + unlink("GameEngine/Prevention/updatehero.txt");
  3819 + }
3592 3820 global $database,$hero_levels;
3593 3821 $harray = $database->getHero();
3594 3822 if(!empty($harray)){
3595 3823 foreach($harray as $hdata){
3596 3824 if((time()-$hdata['lastupdate'])>=1){
3597 3825 if($hdata['health']<100 and $hdata['health']>0){
3598   - $reg = $hdata['health']+$hdata['regeneration']*5*SPEED/86400*(time()-$hdata['lastupdate']);
  3826 + $reg = $hdata['health']+$hdata['regeneration']*5*ceil(SPEED/10)/86400*(time()-$hdata['lastupdate']);
3599 3827 if($reg <= 100){
3600 3828 $database->modifyHero("health",$reg,$hdata['heroid']);
3601 3829 }else{
@@ -3619,45 +3847,58 @@ private function updateHero() {
3619 3847 }
3620 3848 }
3621 3849 }
3622   - }
3623   -
  3850 + if(file_exists("GameEngine/Prevention/updatehero.txt")) {
  3851 + unlink("GameEngine/Prevention/updatehero.txt");
  3852 + }
  3853 +
  3854 +
  3855 +}
  3856 +
  3857 + // by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com >
3624 3858 private function updateStore() {
3625 3859 global $bid10, $bid38, $bid11, $bid39;
3626   -
3627   - $result = mysql_query("SELECT * FROM `".TB_PREFIX."fdata` WHERE vref = '".$_SESSION['wid']."' LIMIT 1");
3628   - $row = mysql_fetch_assoc($result);
3629   - if ($row == null) { return; }
3630   -
3631   - $ress = $crop = 0;
3632   -
3633   - for ($i = 19; $i < 40; ++$i) {
3634   - switch ($row['f' . $i . 't']) {
3635   - case 10:
  3860 +
  3861 + $result = mysql_query('SELECT * FROM `' . TB_PREFIX . 'fdata`');
  3862 + while ($row = mysql_fetch_assoc($result))
  3863 + {
  3864 + $ress = $crop = 0;
  3865 + for ($i = 19; $i < 40; ++$i)
  3866 + {
  3867 + if ($row['f' . $i . 't'] == 10)
  3868 + {
3636 3869 $ress += $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
3637   - break;
3638   -
3639   - case 11:
3640   - $crop += $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
3641   - break;
3642   -
3643   - case 38:
  3870 + }
  3871 +
  3872 + if ($row['f' . $i . 't'] == 38)
  3873 + {
3644 3874 $ress += $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
3645   - break;
3646   -
3647   - case 39:
  3875 + }
  3876 +
  3877 +
  3878 +
  3879 + if ($row['f' . $i . 't'] == 11)
  3880 + {
  3881 + $crop += $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
  3882 + }
  3883 +
  3884 + if ($row['f' . $i . 't'] == 39)
  3885 + {
3648 3886 $crop += $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
3649   - break;
  3887 + }
3650 3888 }
  3889 +
  3890 + if ($ress == 0)
  3891 + {
  3892 + $ress = 800 * STORAGE_MULTIPLIER;
  3893 + }
  3894 +
  3895 + if ($crop == 0)
  3896 + {
  3897 + $crop = 800 * STORAGE_MULTIPLIER;
  3898 + }
  3899 +
  3900 + mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . $ress . ', `maxcrop` = ' . $crop . ' WHERE `wref` = ' . $row['vref']) or die(mysql_error());
3651 3901 }
3652   -
3653   - if ($ress == 0) {
3654   - $ress = 800 * STORAGE_MULTIPLIER;
3655   - }
3656   - if ($crop == 0) {
3657   - $crop = 800 * STORAGE_MULTIPLIER;
3658   - }
3659   -
3660   - mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . $ress . ', `maxcrop` = ' . $crop . ' WHERE `wref` = ' . $row['vref']) or die(mysql_error());
3661 3902 }
3662 3903
3663 3904 private function oasisResoucesProduce() {
@@ -3682,8 +3923,6 @@ private function checkInvitedPlayes() {
3682 3923 foreach($array as $user) {
3683 3924 $numusers = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$user['invited']);
3684 3925 if(mysql_num_rows($numusers) > 0){
3685   - $database->updateUserField($user['id'],"invited",0,1);
3686   - }else{
3687 3926 $varray = count($database->getProfileVillages($user['id']));
3688 3927 if($varray > 1){
3689 3928 $usergold = $database->getUserField($user['invited'],"gold",0);
@@ -3764,7 +4003,12 @@ private function MasterBuilder() {
3764 4003 }
3765 4004
3766 4005 private function starvation() {
  4006 + if(file_exists("GameEngine/Prevention/starvation.txt")) {
  4007 + unlink("GameEngine/Prevention/starvation.txt");
  4008 + }
3767 4009 global $database;
  4010 + $ourFileHandle = fopen("GameEngine/Prevention/starvation.txt", 'w');
  4011 + fclose($ourFileHandle);
3768 4012 $starvupkeep = array(
3769 4013
3770 4014 '1'=>1,
@@ -3918,9 +4162,16 @@ private function starvation() {
3918 4162
3919 4163 unset ($starv,$unitarrays,$enforcearray,$enforce,$starvarray);
3920 4164 }
  4165 +
  4166 + if(file_exists("GameEngine/Prevention/starvation.txt")) {
  4167 + unlink("GameEngine/Prevention/starvation.txt");
  4168 + }
3921 4169 }
3922   -
  4170 +
3923 4171 private function procClimbers() {
  4172 + if(file_exists("GameEngine/Prevention/climbers.txt")) {
  4173 + unlink("GameEngine/Prevention/climbers.txt");
  4174 + }
3924 4175 global $database, $ranking;
3925 4176 $users = "SELECT * FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8") . "";
3926 4177 $array = $database->query_return($users);
@@ -3936,6 +4187,9 @@ private function procClimbers() {
3936 4187 }
3937 4188 foreach($array as $session){
3938 4189 $oldrank = $ranking->getUserRank($session['id']);
  4190 + if($session['oldrank'] == 0){
  4191 + $database->updateoldrank($session['id'], $oldrank);
  4192 + }else{
3939 4193 if($week > 1){
3940 4194 if($session['oldrank'] > $oldrank) {
3941 4195 $totalpoints = $session['oldrank'] - $oldrank;
@@ -3954,6 +4208,7 @@ private function procClimbers() {
3954 4208 }
3955 4209 }
3956 4210 }
  4211 + }
3957 4212 $alliance = $database->getARanking();
3958 4213 $ranking->procARankArray();
3959 4214 if(count($ranking->getRank()) > 0){
@@ -3963,6 +4218,9 @@ private function procClimbers() {
3963 4218 foreach($memberlist as $member) {
3964 4219 $oldrank += $database->getVSumField($member['id'],"pop");
3965 4220 }
  4221 + if($ally['oldrank'] == 0){
  4222 + $database->updateoldrankAlly($ally['id'], $oldrank);
  4223 + }
3966 4224 if($ally['oldrank'] < $oldrank) {
3967 4225 $totalpoints = $oldrank - $ally['oldrank'];
3968 4226 $database->addclimberrankpopAlly($ally['id'], $totalpoints);
@@ -3975,6 +4233,9 @@ private function procClimbers() {
3975 4233 }
3976 4234 }
3977 4235 }
  4236 + if(file_exists("GameEngine/Prevention/climbers.txt")) {
  4237 + unlink("GameEngine/Prevention/climbers.txt");
  4238 + }
3978 4239 }
3979 4240
3980 4241 private function checkBan() {
1,548 GameEngine/Battle.php
@@ -13,60 +13,58 @@
13 13
14 14 class Battle {
15 15
16   - public function procSim($post) {
17   - global $form;
18   - // Recivimos el formulario y procesamos
19   - if(isset($post['a1_v']) && (isset($post['a2_v1']) || isset($post['a2_v2']) || isset($post['a2_v3']) || isset($post['a2_v4']))) {
20   - $_POST['mytribe'] = $post['a1_v'];
21   - $target = array();
22   - if(isset($post['a2_v1'])) {
23   - array_push($target,1);
24   - }
25   - if(isset($post['a2_v2'])) {
26   - array_push($target,2);
27   - }
28   - if(isset($post['a2_v3'])) {
29   - array_push($target,3);
30   - }
31   - if(isset($post['a2_v4'])) {
32   - array_push($target,4);
33   - }
34   - if(isset($post['a2_v5'])) {
35   - array_push($target,5);
36   - }
37   - $_POST['target'] = $target;
38   - if(isset($post['a1_1'])) {
39   - $sum = $sum2 = 0;
40   - for($i=1;$i<=10;$i++) {
41   - $sum += $post['a1_'.$i];
  16 + public function procSim($post) {
  17 + global $form;
  18 + // Recivimos el formulario y procesamos
  19 + if(isset($post['a1_v']) && (isset($post['a2_v1']) || isset($post['a2_v2']) || isset($post['a2_v3']) || isset($post['a2_v4']))) {
  20 + $_POST['mytribe'] = $post['a1_v'];
  21 + $target = array();
  22 + if(isset($post['a2_v1'])) {
  23 + array_push($target,1);
  24 + }
  25 + if(isset($post['a2_v2'])) {
  26 + array_push($target,2);
  27 + }
  28 + if(isset($post['a2_v3'])) {
  29 + array_push($target,3);
  30 + }
  31 + if(isset($post['a2_v4'])) {
  32 + array_push($target,4);
  33 + }
  34 + if(isset($post['a2_v5'])) {
  35 + array_push($target,5);
42 36 }
43   - if($sum > 0) {
44   - if($post['palast'] == "") {
45   - $post['palast'] = 0;
46   - }
47   - if(isset($post['wall1']) && $post['wall1'] == "") {
48   - $post['wall1'] = 0;
49   - }
50   - if(isset($post['wall2']) && $post['wall2'] == "") {
51   - $post['wall2'] = 0;
52   - }
53   - if(isset($post['wall3']) && $post['wall3'] == "") {
54   - $post['wall3'] = 0;
55   - }
56   - if(isset($post['wall4']) && $post['wall4'] == "") {
57   - $post['wall4'] = 0;
58   - }
59   - if(isset($post['wall5']) && $post['wall5'] == "") {
60   - $post['wall5'] = 0;
61   - }
62   - $post['tribe'] = $target[0];
63   - $_POST['result'] = $this->simulate($post);
64   - $form->valuearray = $post;
  37 + $_POST['target'] = $target;
  38 + if(isset($post['a1_1'])) {
  39 + $sum = $sum2 = 0;
  40 + for($i=1;$i<=10;$i++) {
  41 + $sum += $post['a1_'.$i];
  42 + }
  43 + if($sum > 0) {
  44 + if($post['palast'] == "") {
  45 + $post['palast'] = 0;
  46 + }
  47 + if(isset($post['wall1']) && $post['wall1'] == "") {
  48 + $post['wall1'] = 0;
  49 + }
  50 + if(isset($post['wall2']) && $post['wall2'] == "") {
  51 + $post['wall2'] = 0;
  52 + }
  53 + if(isset($post['wall3']) && $post['wall3'] == "") {
  54 + $post['wall3'] = 0;
  55 + }if(isset($post['wall4']) && $post['wall4'] == "") {
  56 + $post['wall4'] = 0;
  57 + }if(isset($post['wall5']) && $post['wall5'] == "") {
  58 + $post['wall5'] = 0;
  59 + }
  60 + $post['tribe'] = $target[0];
  61 + $_POST['result'] = $this->simulate($post);
  62 + $form->valuearray = $post;
  63 + }
  64 + }
65 65 }
66   - }
67 66 }
68   - }
69   - private function getBattleHero($uid) {
  67 + private function getBattleHero($uid) {
70 68 global $database;
71 69 $heroarray = $database->getHero($uid);
72 70 $herodata = $GLOBALS["h".$heroarray[0]['unit']];
@@ -78,104 +76,103 @@ private function getBattleHero($uid) {
78 76 $h_db = 1 + 0.002 * $heroarray[0]['defencebonus'];
79 77
80 78 return array('heroid'=>$heroarray[0]['heroid'],'unit'=>$heroarray[0]['unit'],'atk'=>$h_atk,'di'=>$h_di,'dc'=>$h_dc,'ob'=>$h_ob,'db'=>$h_db,'health'=>$heroarray['health']);
81   - }
82   -
83   - private function simulate($post) {
84   - // Establecemos los arrays con las unidades del atacante y defensor
85   - $attacker = array('u1'=>0,'u2'=>0,'u3'=>0,'u4'=>0,'u5'=>0,'u6'=>0,'u7'=>0,'u8'=>0,'u9'=>0,'u10'=>0,'u11'=>0,'u12'=>0,'u13'=>0,'u14'=>0,'u15'=>0,'u16'=>0,'u17'=>0,'u18'=>0,'u19'=>0,'u20'=>0,'u21'=>0,'u22'=>0,'u23'=>0,'u24'=>0,'u25'=>0,'u26'=>0,'u27'=>0,'u28'=>0,'u29'=>0,'u30'=>0,'u31'=>0,'u32'=>0,'u33'=>0,'u34'=>0,'u35'=>0,'u36'=>0,'u37'=>0,'u38'=>0,'u39'=>0,'u40'=>0,'u41'=>0,'u42'=>0,'u43'=>0,'u44'=>0,'u45'=>0,'u46'=>0,'u47'=>0,'u48'=>0,'u49'=>0,'u50'=>0);
86   - $start = ($post['a1_v']-1)*10+1;
87   - $index = 1;
88   - for($i=$start;$i<=($start+9);$i++) {
89   - $attacker['u'.$i] = $post['a1_'.$index];
90   - if($index <=8) {
91   - ${att_ab.$index} = $post['f1_'.$index];
92   - }
93   - $index += 1;
94   - }
95   - $defender = array();
96   - for($i=1;$i<=50;$i++) {
97   - if(isset($post['a2_'.$i]) && $post['a2_'.$i] != "") {
98   - $defender['u'.$i] = $post['a2_'.$i];
99   - }
100   - else {
101   - $defender['u'.$i] = 0;
102   - }
103 79 }
104   - $deftribe = $post['tribe'];
105   - $wall = 0;
106   - switch($deftribe) {
107   - case 1:
108   - for($i=1;$i<=8;$i++) {
109   - ${def_ab.$i} = $post['f2_'.$i];
110   - }
111   - break;
112   - case 2:
113   - for($i=11;$i<=18;$i++) {
114   - ${def_ab.$i-10} = $post['f2_'.$i];
  80 +
  81 + private function simulate($post) {
  82 + // Establecemos los arrays con las unidades del atacante y defensor
  83 + $attacker = array('u1'=>0,'u2'=>0,'u3'=>0,'u4'=>0,'u5'=>0,'u6'=>0,'u7'=>0,'u8'=>0,'u9'=>0,'u10'=>0,'u11'=>0,'u12'=>0,'u13'=>0,'u14'=>0,'u15'=>0,'u16'=>0,'u17'=>0,'u18'=>0,'u19'=>0,'u20'=>0,'u21'=>0,'u22'=>0,'u23'=>0,'u24'=>0,'u25'=>0,'u26'=>0,'u27'=>0,'u28'=>0,'u29'=>0,'u30'=>0,'u31'=>0,'u32'=>0,'u33'=>0,'u34'=>0,'u35'=>0,'u36'=>0,'u37'=>0,'u38'=>0,'u39'=>0,'u40'=>0,'u41'=>0,'u42'=>0,'u43'=>0,'u44'=>0,'u45'=>0,'u46'=>0,'u47'=>0,'u48'=>0,'u49'=>0,'u50'=>0);
  84 + $start = ($post['a1_v']-1)*10+1;
  85 + $index = 1;
  86 + for($i=$start;$i<=($start+9);$i++) {
  87 + $attacker['u'.$i] = $post['a1_'.$index];
  88 + if($index <=8) {
  89 + ${att_ab.$index} = $post['f1_'.$index];
  90 + }
  91 + $index += 1;
115 92 }
116   - break;
117   - case 3:
118   - for($i=21;$i<=28;$i++) {
119   - ${def_ab.$i-20} = $post['f2_'.$i];
  93 + $defender = array();
  94 + for($i=1;$i<=50;$i++) {
  95 + if(isset($post['a2_'.$i]) && $post['a2_'.$i] != "") {
  96 + $defender['u'.$i] = $post['a2_'.$i];
  97 + }
  98 + else {
  99 + $defender['u'.$i] = 0;
  100 + }
120 101 }
121   - break;
  102 + $deftribe = $post['tribe'];
  103 + $wall = 0;
  104 + switch($deftribe) {
  105 + case 1:
  106 + for($i=1;$i<=8;$i++) {
  107 + ${def_ab.$i} = $post['f2_'.$i];
  108 + }
  109 + break;
  110 + case 2:
  111 + for($i=11;$i<=18;$i++) {
  112 + ${def_ab.$i-10} = $post['f2_'.$i];