big update

This commit is contained in:
unknown
2012-09-01 13:00:40 +03:00
parent a566e25759
commit 8c44bb4e2a
46 changed files with 1480 additions and 1008 deletions
-1
View File
@@ -114,7 +114,6 @@ class Account {
if($uid) {
setcookie("COOKUSR",$_POST['name'],time()+COOKIE_EXPIRE,COOKIE_PATH);
setcookie("COOKEMAIL",$_POST['email'],time()+COOKIE_EXPIRE,COOKIE_PATH);
$database->updateUserField($uid,"act","",1);
$database->updateUserField($uid,"invited",$_POST['invited'],1);
$this->generateBase($_POST['kid'],$uid,$_POST['name']);
+32 -4
View File
@@ -52,6 +52,7 @@ class adm_DB {
for ($i = 0; $i <= count($villages)-1; $i++) {
$vid = $villages[$i]['wref'];
$this->recountPop($vid);
$this->recountCP($vid);
}
}
@@ -60,15 +61,30 @@ class adm_DB {
$fdata = $database->getResourceLevel($vid);
$popTot = 0;
for ($i = 1; $i <= 40; $i++) {
$lvl = $fdata["f".$i];
$building = $fdata["f".$i."t"];
if($building){
$lvl = $fdata["f".$i];
$building = $fdata["f".$i."t"];
if($building){
$popTot += $this->buildingPOP($building,$lvl);
}
}
}
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
mysql_query($q, $this->connection);
}
function recountCP($vid){
global $database;
$fdata = $database->getResourceLevel($vid);
$popTot = 0;
for ($i = 1; $i <= 40; $i++) {
$lvl = $fdata["f".$i];
$building = $fdata["f".$i."t"];
if($building){
$popTot += $this->buildingCP($building,$lvl);
}
}
$q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
mysql_query($q, $this->connection);
}
function buildingPOP($f,$lvl){
$name = "bid".$f;
@@ -80,6 +96,18 @@ class adm_DB {
}
return $popT;
}
function buildingCP($f,$lvl){
$name = "bid".$f;
global $$name;
$popT = 0;
$dataarray = $$name;
for ($i = 0; $i <= $lvl; $i++) {
$popT += $dataarray[$i]['cp'];
}
return $popT;
}
function getWref($x,$y) {
$q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y";
+8 -1
View File
@@ -108,7 +108,7 @@
public function sendInvite($post) {
global $form, $database, $session;
if($session->access != BANNED){
if(isset($post['a_name']) && $post['a_uid'] != ""){
if(isset($post['a_name']) or $post['a_uid'] == ""){
$UserData = $database->getUserArray($post['a_name'], 0);
if($this->userPermArray['opt4'] == 0) {
$form->addError("perm", NO_PERMISSION);
@@ -393,6 +393,13 @@
} elseif(md5($post['pw']) !== $session->userinfo['password']) {
$form->addError("pw2", PW_ERR);
} else {
if($database->isAllianceOwner($sessiom->uid)){
$newowner = $database->getAllMember2($session->alliance);
$newleader = $newowner['id'];
$q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$session->alliance."";
$database->query($q);
$database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1);
}
$database->updateUserField($session->uid, 'alliance', 0, 1);
$database->deleteAlliPermissions($session->uid);
// log the notice
+341 -80
View File
@@ -1,7 +1,9 @@
<?php
if (!isset($_SESSION)) {
session_start();
}
# Developed By : Mr.php
# you have no rights to change this !!
# Fixed : Doubling Troops , Hero not dieing etc ..
# Email : mr.php-majed@hotmail.com
# Skype : mr.majed1005
class Automation {
@@ -101,6 +103,7 @@ class Automation {
global $database;
$fdata = $database->getResourceLevel($vid);
$popTot = 0;
for ($i = 1; $i <= 40; $i++) {
$lvl = $fdata["f".$i];
$building = $fdata["f".$i."t"];
@@ -109,7 +112,7 @@ class Automation {
}
}
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
$q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
mysql_query($q);
return $popTot;
@@ -141,39 +144,77 @@ class Automation {
}
public function Automation() {
$this->procClimbers();
$this->ClearUser();
$this->ClearInactive();
$this->oasisResoucesProduce();
$this->pruneResource();
$this->pruneOResource();
$this->checkWWAttacks();
$this->culturePoints();
$this->updateHero();
$this->clearDeleting();
$this->buildComplete();
if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time()-filemtime("GameEngine/Prevention/culturepoints.txt")>10) {
$this->culturePoints();
}
if(!file_exists("GameEngine/Prevention/updatehero.txt") or time()-filemtime("GameEngine/Prevention/updatehero.txt")>50) {
$this->updateHero();
}
if(!file_exists("GameEngine/Prevention/cleardeleting.txt") or time()-filemtime("GameEngine/Prevention/cleardeleting.txt")>10) {
$this->clearDeleting();
}
if (! file_exists("GameEngine/Prevention/build.txt") or time() - filemtime("GameEngine/Prevention/build.txt") > 10)
{
$this->buildComplete();
}
$this->MasterBuilder();
$this->demolitionComplete();
if (! file_exists("GameEngine/Prevention/demolition.txt") or time() - filemtime("GameEngine/Prevention/demolition.txt") > 10)
{
$this->demolitionComplete();
}
$this->updateStore();
$this->delTradeRoute();
$this->TradeRoute();
$this->marketComplete();
$this->researchComplete();
$this->trainingComplete();
$this->starvation();
$this->celebrationComplete();
$this->sendunitsComplete();
$this->loyaltyRegeneration();
$this->sendreinfunitsComplete();
$this->returnunitsComplete();
$this->sendSettlersComplete();
if(!file_exists("GameEngine/Prevention/market.txt") or time()-filemtime("GameEngine/Prevention/market.txt")>10) {
$this->marketComplete();
}
if(!file_exists("GameEngine/Prevention/research.txt") or time()-filemtime("GameEngine/Prevention/research.txt")>10) {
$this->researchComplete();
}
if(!file_exists("GameEngine/Prevention/training.txt") or time()-filemtime("GameEngine/Prevention/training.txt")>10) {
$this->trainingComplete();
}
if(!file_exists("GameEngine/Prevention/starvation.txt") or time()-filemtime("GameEngine/Prevention/starvation.txt")>10) {
$this->starvation();
}
if(!file_exists("GameEngine/Prevention/celebration.txt") or time()-filemtime("GameEngine/Prevention/celebration.txt")>10) {
$this->celebrationComplete();
}
if(!file_exists("GameEngine/Prevention/sendunits.txt") or time()-filemtime("GameEngine/Prevention/sendunits.txt")>10) {
$this->sendunitsComplete();
}
if(!file_exists("GameEngine/Prevention/loyalty.txt") or time()-filemtime("GameEngine/Prevention/loyalty.txt")>50) {
$this->loyaltyRegeneration();
}
if(!file_exists("GameEngine/Prevention/sendreinfunits.txt") or time()-filemtime("GameEngine/Prevention/sendreinfunits.txt")>10) {
$this->sendreinfunitsComplete();
}
if(!file_exists("GameEngine/Prevention/returnunits.txt") or time()-filemtime("GameEngine/Prevention/returnunits.txt")>51) {
$this->returnunitsComplete();
}
if(!file_exists("GameEngine/Prevention/settlers.txt") or time()-filemtime("GameEngine/Prevention/settlers.txt")>10) {
$this->sendSettlersComplete();
}
$this->updateGeneralAttack();
$this->checkInvitedPlayes();
$this->updateStore();
$this->CheckBan();
$this->regenerateOasisTroops();
$this->artefactOfTheFool();
}
private function loyaltyRegeneration() {
if(file_exists("GameEngine/Prevention/loyalty.txt")) {
unlink("GameEngine/Prevention/loyalty.txt");
}
global $database;
$array = array();
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE loyalty<>100";
@@ -209,6 +250,9 @@ class Automation {
$database->query($q);
}
}
if(file_exists("GameEngine/Prevention/loyalty.txt")) {
unlink("GameEngine/Prevention/loyalty.txt");
}
}
private function getfieldDistance($coorx1, $coory1, $coorx2, $coory2) {
@@ -271,7 +315,12 @@ class Automation {
}
private function clearDeleting() {
if(file_exists("GameEngine/Prevention/cleardeleting.txt")) {
unlink("GameEngine/Prevention/cleardeleting.txt");
}
global $database;
$ourFileHandle = fopen("GameEngine/Prevention/cleardeleting.txt", 'w');
fclose($ourFileHandle);
$needDelete = $database->getNeedDelete();
if(count($needDelete) > 0) {
foreach($needDelete as $need) {
@@ -281,14 +330,12 @@ class Automation {
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."enforcement where vref = ".$village;
$q = "DELETE FROM ".TB_PREFIX."enforcement where from = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."market where vref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$village." or from = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."research where vref = ".$village;
@@ -299,11 +346,56 @@ class Automation {
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."units where vref =".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."vdata where vref = ".$village;
$q = "DELETE FROM ".TB_PREFIX."vdata where wref = ".$village;
$database->query($q);
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$village;
$database->query($q);
$getmovement = $database->getMovement(3,$village,1);
foreach($getmovement as $movedata) {
$time = time();
$time2 = $time - $movedata['starttime'];
$database->addMovement(4,$movedata['to'],$movedata['from'],$movedata['ref'],$time,$time+$time2);
$database->setMovementProc($movedata['moveid']);
}
$q = "DELETE FROM ".TB_PREFIX."movement where from = ".$village;
$database->query($q);
$getprisoners = $database->getPrisoners($village);
foreach($getprisoners as $pris) {
$troops = 0;
for($i=1;$i<12;$i++){
$troops += $pris['t'.$i];
}
$database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
$database->deletePrisoners($pris['id']);
}
$getprisoners = $database->getPrisoners3($village);
foreach($getprisoners as $pris) {
$troops = 0;
for($i=1;$i<12;$i++){
$troops += $pris['t'.$i];
}
$database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
$database->deletePrisoners($pris['id']);
}
$enforcement = $database->getEnforceVillage($village,0);
foreach($enforcement as $enforce) {
$time = time();
$fromcoor = $database->getCoor($enforce['vref']);
$tocoor = $database->getCoor($enforce['from']);
$targettribe = $database->getUserField($database->getVillageField($enforce['from'],"owner"),"tribe",0);
$time2 = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0);
$start = 10*($targettribe-1);
for($i=1;$i<11;$i++){
$unit = $start + $i;
$post['t'.$i] = $enforce['u'.$unit];
}
$post['t11'] = $enforce['hero'];
$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);
$database->addMovement(4,$enforce['vref'],$enforce['from'],$reference,$time,$time+$time2);
}
}
$q = "DELETE FROM ".TB_PREFIX."hero where uid = ".$need['uid'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."mdata where target = ".$need['uid']." or owner = ".$need['uid'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."ndata where uid = ".$need['uid'];
@@ -312,8 +404,20 @@ class Automation {
$database->query($q);
}
}
if(file_exists("GameEngine/Prevention/cleardeleting.txt")) {
unlink("GameEngine/Prevention/cleardeleting.txt");
}
}
private function ClearUser() {
global $database;
if(AUTO_DEL_INACTIVE) {
$time = time()+UN_ACT_TIME;
$q = "DELETE from ".TB_PREFIX."users where timestamp >= $time and act != ''";
$database->query($q);
}
}
private function ClearInactive() {
global $database;
if(TRACK_USR) {
@@ -470,6 +574,9 @@ class Automation {
}
private function culturePoints() {
if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
unlink("GameEngine/Prevention/culturepoints.txt");
}
global $database,$session;
$time = time()-600; // 10minutes
$array = array();
@@ -485,9 +592,15 @@ class Automation {
$database->query($q);
}
}
}
if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
unlink("GameEngine/Prevention/culturepoints.txt");
}
}
private function buildComplete() {
if(file_exists("GameEngine/Prevention/build.txt")) {
unlink("GameEngine/Prevention/build.txt");
}
global $database,$bid18,$bid10,$bid11,$bid38,$bid39;
$time = time();
$array = array();
@@ -584,6 +697,9 @@ class Automation {
$database->setVillageField($indi['wid'], 'starvupdate', $time);
}
}
if(file_exists("GameEngine/Prevention/build.txt")) {
unlink("GameEngine/Prevention/build.txt");
}
}
// by SlimShady95 aka Manuel Mannhardt < manuel_mannhardt@web.de >
@@ -782,7 +898,12 @@ class Automation {
}
private function marketComplete() {
if(file_exists("GameEngine/Prevention/market.txt")) {
unlink("GameEngine/Prevention/market.txt");
}
global $database;
$ourFileHandle = fopen("GameEngine/Prevention/market.txt", 'w');
fclose($ourFileHandle);
$time = time();
$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";
$dataarray = $database->query_return($q);
@@ -817,6 +938,9 @@ class Automation {
$this->sendResource2($data1['wood'],$data1['clay'],$data1['iron'],$data1['crop'],$data1['to'],$data1['from'],$targettribe1,$send);
}
}
if(file_exists("GameEngine/Prevention/market.txt")) {
unlink("GameEngine/Prevention/market.txt");
}
}
private function sendResource2($wtrans,$ctrans,$itrans,$crtrans,$from,$to,$tribe,$send) {
@@ -854,7 +978,12 @@ class Automation {
}
private function sendunitsComplete() {
if(file_exists("GameEngine/Prevention/sendunits.txt")) {
unlink("GameEngine/Prevention/sendunits.txt");
}
global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator;
$ourFileHandle = fopen("GameEngine/Prevention/sendunits.txt", 'w');
fclose($ourFileHandle);
$time = time();
$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";
$dataarray = $database->query_return($q);
@@ -956,9 +1085,9 @@ class Automation {
$end = ($owntribe*10);
$u = (($owntribe-1)*10);
$catp = 0;
$catapult = array(8,18,28,38,48);
$ram = array(7,17,27,37,47);
$chief = array(9,19,29,39,49);
$catapult = array(8,18,28,48);
$ram = array(7,17,27,47);
$chief = array(9,19,29,49);
$spys = array(4,14,23,44);
for($i=$start;$i<=$end;$i++) {
$y = $i-$u;
@@ -1112,8 +1241,6 @@ class Automation {
$end = ($owntribe*10);
$u = (($owntribe-1)*10);
$catp = 0;
$rams = 0;
$chiefs = 0;
$catapult = array(8,18,28,38,48);
$ram = array(7,17,27,37,47);
$chief = array(9,19,29,39,49);
@@ -1703,7 +1830,7 @@ class Automation {
for ($i=1;$i<=41;$i++)
{
if ($i==41) $i=99;
if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0)
if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
{
$j++;
$_rand[$j]=$bdo['f'.$i];
@@ -1732,7 +1859,7 @@ class Automation {
for ($i=1;$i<=41;$i++)
{
if ($i==41) $i=99;
if ($bdo['f'.$i] > 0)
if ($bdo['f'.$i] > 0 && $rand != 31 && $rand != 32 && $rand != 33)
{
$list[$j]=$i;
$j++;
@@ -1773,7 +1900,8 @@ class Automation {
$database->query($q);
}
$pop=$this->recountPop($data['to']);
if($pop=='0')
$capital = $database->getVillage($data['to']);
if($pop=='0' && $capital['capital']=='0')
{
$village_destroyed = 1;
}
@@ -1827,7 +1955,7 @@ class Automation {
for ($i=1;$i<=41;$i++)
{
if ($i==41) $i=99;
if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0)
if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
{
$j++;
$_rand[$j]=$bdo['f'.$i];
@@ -1856,7 +1984,7 @@ class Automation {
for ($i=1;$i<=41;$i++)
{
if ($i==41) $i=99;
if ($bdo['f'.$i] > 0)
if ($bdo['f'.$i] > 0 && $rand != 31 && $rand != 32 && $rand != 33)
{
$j++;
$list[$j]=$i;
@@ -1951,7 +2079,7 @@ class Automation {
for ($i=1;$i<=41;$i++)
{
if ($i==41) $i=99;
if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0)
if ($bdo['f'.$i.'t']==$rand && $bdo['f'.$i]>0 && $rand != 31 && $rand != 32 && $rand != 33)
{
$j++;
$_rand[$j]=$bdo['f'.$i];
@@ -2380,7 +2508,7 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$database->modifyAttack2($data['ref'],10,$prisoner['t10']);
$database->modifyAttack2($data['ref'],11,$prisoner['t11']);
$mytroops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
$newtraps = (round($mytroops/3))*2;
$newtraps = round($mytroops/3);
$database->modifyUnit($data['to'],array("99"),array($newtraps),array(0));
$database->modifyUnit($data['to'],array("99o"),array($mytroops),array(0));
}else{
@@ -2464,7 +2592,7 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
}
}
$data2 = $data2.','.$info_trap.',,';
$data2 = $data2.','.addslashes($info_trap).',,';
if($totalsend_alldef == 0){
$database->addNotice($to['owner'],$to['wref'],$targetally,7,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime);
}else if($totaldead_alldef == 0){
@@ -2582,6 +2710,40 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
$q = "DELETE FROM ".TB_PREFIX."movement where from = ".$data['to'];
$database->query($q);
$getprisoners = $database->getPrisoners($data['to']);
foreach($getprisoners as $pris) {
$troops = 0;
for($i=1;$i<12;$i++){
$troops += $pris['t'.$i];
}
$database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
$database->deletePrisoners($pris['id']);
}
$getprisoners = $database->getPrisoners3($data['to']);
foreach($getprisoners as $pris) {
$troops = 0;
for($i=1;$i<12;$i++){
$troops += $pris['t'.$i];
}
$database->modifyUnit($pris['wref'],array("99o"),array($troops),array(0));
$database->deletePrisoners($pris['id']);
}
$enforcement = $database->getEnforceVillage($data['to'],0);
foreach($enforcement as $enforce) {
$time = time();
$fromcoor = $database->getCoor($enforce['vref']);
$tocoor = $database->getCoor($enforce['from']);
$targettribe = $database->getUserField($database->getVillageField($enforce['from'],"owner"),"tribe",0);
$time2 = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0);
$start = 10*($targettribe-1);
for($i=1;$i<11;$i++){
$unit = $start + $i;
$post['t'.$i] = $enforce['u'.$unit];
}
$post['t11'] = $enforce['hero'];
$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);
$database->addMovement(4,$enforce['vref'],$enforce['from'],$reference,$time,$time+$time2);
}
}
}
}else{
@@ -2716,6 +2878,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
#################################################
}
if(file_exists("GameEngine/Prevention/sendunits.txt")) {
unlink("GameEngine/Prevention/sendunits.txt");
}
}
private function sendTroopsBack($post) {
@@ -2846,8 +3011,13 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
private function sendreinfunitsComplete() {
if(file_exists("GameEngine/Prevention/sendreinfunits.txt")) {
unlink("GameEngine/Prevention/sendreinfunits.txt");
}
global $bid23,$database,$battle;
$time = time();
$ourFileHandle = fopen("GameEngine/Prevention/sendreinfunits.txt", 'w');
fclose($ourFileHandle);
$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";
$dataarray = $database->query_return($q);
foreach($dataarray as $data) {
@@ -2909,10 +3079,18 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$database->setMovementProc($data['moveid']);
}
}
if(file_exists("GameEngine/Prevention/sendreinfunits.txt")) {
unlink("GameEngine/Prevention/sendreinfunits.txt");
}
}
private function returnunitsComplete() {
if(file_exists("GameEngine/Prevention/returnunits.txt")) {
unlink("GameEngine/Prevention/returnunits.txt");
}
global $database;
$ourFileHandle = fopen("GameEngine/Prevention/returnunits.txt", 'w');
fclose($ourFileHandle);
$time = time();
$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";
$dataarray = $database->query_return($q);
@@ -2961,10 +3139,19 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$database->modifyUnit($data['to'],array($tribe."0"),array(3),array(1));
$database->setMovementProc($data['moveid']);
}
if(file_exists("GameEngine/Prevention/returnunits.txt")) {
unlink("GameEngine/Prevention/returnunits.txt");
}
}
private function sendSettlersComplete() {
if(file_exists("GameEngine/Prevention/settlers.txt")) {
unlink("GameEngine/Prevention/settlers.txt");
}
global $database, $building;
$ourFileHandle = fopen("GameEngine/Prevention/settlers.txt", 'w');
fclose($ourFileHandle);
$time = time();
$q = "SELECT * FROM ".TB_PREFIX."movement where proc = 0 and sort_type = 5 and endtime < $time";
$dataarray = $database->query_return($q);
@@ -3005,10 +3192,18 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$database->setMovementProc($data['moveid']);
}
}
}
if(file_exists("GameEngine/Prevention/settlers.txt")) {
unlink("GameEngine/Prevention/settlers.txt");
}
}
private function researchComplete() {
if(file_exists("GameEngine/Prevention/research.txt")) {
unlink("GameEngine/Prevention/research.txt");
}
global $database;
$ourFileHandle = fopen("GameEngine/Prevention/research.txt", 'w');
fclose($ourFileHandle);
$time = time();
$q = "SELECT * FROM ".TB_PREFIX."research where timestamp < $time";
$dataarray = $database->query_return($q);
@@ -3027,6 +3222,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$q = "DELETE FROM ".TB_PREFIX."research where id = ".$data['id'];
$database->query($q);
}
if(file_exists("GameEngine/Prevention/research.txt")) {
unlink("GameEngine/Prevention/research.txt");
}
}
private function updateRes($bountywid,$uid) {
@@ -3137,8 +3335,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
global $database,$session,$village;
if ($vid == 0) { $vid = $_SESSION['wid']; }
$buildarray = $database->getResourceLevel($vid);
if($vid==0) { $vid=$village->wid; }
$buildarray = array();
if($vid!=0){ $buildarray = $database->getResourceLevel($vid); }
$upkeep = 0;
switch($type) {
case 0:
@@ -3209,9 +3408,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}else{
$upkeep += $array['t11'] * 6;
}
$artefact = count($database->getOwnUniqueArtefactInfo2($_SESSION['id_user'],4,3,0));
$artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,4,3,0));
$artefact1 = count($database->getOwnUniqueArtefactInfo2($vid,4,1,1));
$artefact2 = count($database->getOwnUniqueArtefactInfo2($_SESSION['id_user'],4,2,0));
$artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,4,2,0));
if($artefact > 0){
$upkeep /= 2;
$upkeep = round($upkeep);
@@ -3223,7 +3422,7 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$upkeep = round($upkeep);
$upkeep *= 3;
}
$foolartefact = $database->getFoolArtefactInfo(4,$vid,$_SESSION['id_user']);
$foolartefact = $database->getFoolArtefactInfo(4,$vid,$session->uid);
if(count($foolartefact) > 0){
foreach($foolartefact as $arte){
if($arte['bad_effect'] == 1){
@@ -3414,8 +3613,13 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
private function trainingComplete() {
if(file_exists("GameEngine/Prevention/training.txt")) {
unlink("GameEngine/Prevention/training.txt");
}
global $database;
$time = time();
$ourFileHandle = fopen("GameEngine/Prevention/training.txt", 'w');
fclose($ourFileHandle);
$trainlist = $database->getTrainingList();
if(count($trainlist) > 0){
foreach($trainlist as $train){
@@ -3452,6 +3656,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
}
}
if(file_exists("GameEngine/Prevention/training.txt")) {
unlink("GameEngine/Prevention/training.txt");
}
}
public function procDistanceTime($coor,$thiscoor,$ref,$mode) {
@@ -3546,7 +3753,13 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
private function celebrationComplete() {
if(file_exists("GameEngine/Prevention/celebration.txt")) {
unlink("GameEngine/Prevention/celebration.txt");
}
global $database;
$ourFileHandle = fopen("GameEngine/Prevention/celebration.txt", 'w');
fclose($ourFileHandle);
$varray = $database->getCel();
foreach($varray as $vil){
$id = $vil['wref'];
@@ -3556,10 +3769,19 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$database->clearCel($id);
$database->setCelCp($user,$cp);
}
if(file_exists("GameEngine/Prevention/celebration.txt")) {
unlink("GameEngine/Prevention/celebration.txt");
}
}
private function demolitionComplete() {
if(file_exists("GameEngine/Prevention/demolition.txt")) {
unlink("GameEngine/Prevention/demolition.txt");
}
global $building,$database;
$ourFileHandle = fopen("GameEngine/Prevention/demolition.txt", 'w');
fclose($ourFileHandle);
$varray = $database->getDemolition();
foreach($varray as $vil) {
if ($vil['timetofinish'] <= time()) {
@@ -3586,16 +3808,22 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$database->delDemolition($vil['vref']);
}
}
if(file_exists("GameEngine/Prevention/demolition.txt")) {
unlink("GameEngine/Prevention/demolition.txt");
}
}
private function updateHero() {
if(file_exists("GameEngine/Prevention/updatehero.txt")) {
unlink("GameEngine/Prevention/updatehero.txt");
}
global $database,$hero_levels;
$harray = $database->getHero();
if(!empty($harray)){
foreach($harray as $hdata){
if((time()-$hdata['lastupdate'])>=1){
if($hdata['health']<100 and $hdata['health']>0){
$reg = $hdata['health']+$hdata['regeneration']*5*SPEED/86400*(time()-$hdata['lastupdate']);
$reg = $hdata['health']+$hdata['regeneration']*5*ceil(SPEED/10)/86400*(time()-$hdata['lastupdate']);
if($reg <= 100){
$database->modifyHero("health",$reg,$hdata['heroid']);
}else{
@@ -3619,45 +3847,58 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
}
}
}
if(file_exists("GameEngine/Prevention/updatehero.txt")) {
unlink("GameEngine/Prevention/updatehero.txt");
}
}
// by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com >
private function updateStore() {
global $bid10, $bid38, $bid11, $bid39;
$result = mysql_query("SELECT * FROM `".TB_PREFIX."fdata` WHERE vref = '".$_SESSION['wid']."' LIMIT 1");
$row = mysql_fetch_assoc($result);
if ($row == null) { return; }
$ress = $crop = 0;
for ($i = 19; $i < 40; ++$i) {
switch ($row['f' . $i . 't']) {
case 10:
$result = mysql_query('SELECT * FROM `' . TB_PREFIX . 'fdata`');
while ($row = mysql_fetch_assoc($result))
{
$ress = $crop = 0;
for ($i = 19; $i < 40; ++$i)
{
if ($row['f' . $i . 't'] == 10)
{
$ress += $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
break;
case 11:
$crop += $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
break;
case 38:
}
if ($row['f' . $i . 't'] == 38)
{
$ress += $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
break;
case 39:
}
if ($row['f' . $i . 't'] == 11)
{
$crop += $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
}
if ($row['f' . $i . 't'] == 39)
{
$crop += $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
break;
}
}
if ($ress == 0)
{
$ress = 800 * STORAGE_MULTIPLIER;
}
if ($crop == 0)
{
$crop = 800 * STORAGE_MULTIPLIER;
}
mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . $ress . ', `maxcrop` = ' . $crop . ' WHERE `wref` = ' . $row['vref']) or die(mysql_error());
}
if ($ress == 0) {
$ress = 800 * STORAGE_MULTIPLIER;
}
if ($crop == 0) {
$crop = 800 * STORAGE_MULTIPLIER;
}
mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . $ress . ', `maxcrop` = ' . $crop . ' WHERE `wref` = ' . $row['vref']) or die(mysql_error());
}
private function oasisResoucesProduce() {
@@ -3682,8 +3923,6 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
foreach($array as $user) {
$numusers = mysql_query("SELECT * FROM ".TB_PREFIX."users WHERE id = ".$user['invited']);
if(mysql_num_rows($numusers) > 0){
$database->updateUserField($user['id'],"invited",0,1);
}else{
$varray = count($database->getProfileVillages($user['id']));
if($varray > 1){
$usergold = $database->getUserField($user['invited'],"gold",0);
@@ -3764,7 +4003,12 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
private function starvation() {
if(file_exists("GameEngine/Prevention/starvation.txt")) {
unlink("GameEngine/Prevention/starvation.txt");
}
global $database;
$ourFileHandle = fopen("GameEngine/Prevention/starvation.txt", 'w');
fclose($ourFileHandle);
$starvupkeep = array(
'1'=>1,
@@ -3918,9 +4162,16 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
unset ($starv,$unitarrays,$enforcearray,$enforce,$starvarray);
}
if(file_exists("GameEngine/Prevention/starvation.txt")) {
unlink("GameEngine/Prevention/starvation.txt");
}
}
private function procClimbers() {
if(file_exists("GameEngine/Prevention/climbers.txt")) {
unlink("GameEngine/Prevention/climbers.txt");
}
global $database, $ranking;
$users = "SELECT * FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8") . "";
$array = $database->query_return($users);
@@ -3936,6 +4187,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
foreach($array as $session){
$oldrank = $ranking->getUserRank($session['id']);
if($session['oldrank'] == 0){
$database->updateoldrank($session['id'], $oldrank);
}else{
if($week > 1){
if($session['oldrank'] > $oldrank) {
$totalpoints = $session['oldrank'] - $oldrank;
@@ -3954,6 +4208,7 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
}
}
}
$alliance = $database->getARanking();
$ranking->procARankArray();
if(count($ranking->getRank()) > 0){
@@ -3962,6 +4217,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
$oldrank = 0;
foreach($memberlist as $member) {
$oldrank += $database->getVSumField($member['id'],"pop");
}
if($ally['oldrank'] == 0){
$database->updateoldrankAlly($ally['id'], $oldrank);
}
if($ally['oldrank'] < $oldrank) {
$totalpoints = $oldrank - $ally['oldrank'];
@@ -3975,6 +4233,9 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
}
}
}
if(file_exists("GameEngine/Prevention/climbers.txt")) {
unlink("GameEngine/Prevention/climbers.txt");
}
}
private function checkBan() {
+770 -808
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -698,7 +698,7 @@ class Building {
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
}
}
if($database->query($q) && ($enought_res = 1 or $jobs['master'])) {
if($database->query($q) && ($enought_res == 1 or $jobs['master'] == 0)) {
$database->modifyPop($jobs['wid'],$resource['pop'],0);
$database->addCP($jobs['wid'],$resource['cp']);
$q = "DELETE FROM ".TB_PREFIX."bdata where id = ".$jobs['id'];
+15 -9
View File
@@ -160,7 +160,7 @@ class MYSQL_DB {
}
function getStarvation(){
$q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0";
$q = "SELECT * FROM " . TB_PREFIX . "vdata where starv != 0 and owner != 3";
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
@@ -221,7 +221,7 @@ class MYSQL_DB {
}
function setDeleting($uid, $mode) {
$time = time() + 72 * 3600;
$time = time() + 5 * 3600;
if(!$mode) {
$q = "INSERT into " . TB_PREFIX . "deleting values ($uid,$time)";
} else {
@@ -2208,6 +2208,12 @@ class MYSQL_DB {
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
function getAllMember2($aid) {
$q = "SELECT * FROM " . TB_PREFIX . "users where alliance = $aid order by (SELECT sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = " . TB_PREFIX . "users.id) desc, " . TB_PREFIX . "users.id desc LIMIT 1";
$result = mysql_query($q, $this->connection);
return mysql_fetch_array($result);
}
function addUnits($vid) {
$q = "INSERT into " . TB_PREFIX . "units (vref) values ($vid)";
@@ -2355,13 +2361,13 @@ class MYSQL_DB {
global $village, $building, $session, $technology;
if(!$mode) {
$barracks = array(1, 2, 3, 11, 12, 13, 14, 21, 22, 31, 32, 33, 34, 41, 42, 43, 44);
$stables = array(4, 5, 6, 15, 16, 23, 24, 25, 26, 35, 36, 45, 46);
$workshop = array(7, 8, 17, 18, 27, 28, 37, 38, 47, 48);
$residence = array(9, 10, 19, 20, 29, 30, 39, 40, 49, 50);
$greatstables = array(64,65,66,75,76,83,84,85,86,95,96,105,106,);
$greatbarracks = array(61,62,63,71,72,73,84,81,82,91,92,93,94,101,102,103,104,111,112,113,114);
$greatworkshop = array(67,68,77,78,87,88,97,98,107,108);
$barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44);
$greatbarracks = array(61,62,63,71,72,73,84,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104);
$stables = array(4,5,6,15,16,23,24,25,26,45,46);
$greatstables = array(64,65,66,75,76,83,84,85,86,105,106);
$workshop = array(7,8,17,18,27,28,47,48);
$greatworkshop = array(67,68,77,78,87,88,107,108);
$residence = array(9,10,19,20,29,30,49,50);
$trapper = array(99);
if(in_array($unit, $barracks)) {
+1 -1
View File
@@ -106,7 +106,7 @@ public function procMtime($time, $pref = 3) {
break;
}
*/
- $time += 3600*0; //Edit this yourself
- $time += 3600*1; //Edit this yourself
+ $time += 0; //Edit this yourself
$today = date('d',time())-1;
+6 -2
View File
@@ -24,7 +24,7 @@
$users2 = mysql_num_rows(mysql_query($users));
$users3 = $users2+1;
if(count($ranking) > 0) {
for($i=1;$i<($users3);$i++) {
for($i=0;$i<($users3);$i++) {
if($ranking[$i]['userid'] == $id && $ranking[$i] != "pad") {
$myrank = $i;
}
@@ -42,15 +42,19 @@
break;
case 8:
$this->procHeroRankArray();
$this->getStart($this->searchRank($session->uid, "owner"));
break;
case 11:
$this->procRankRaceArray(1);
$this->getStart($this->searchRank($session->uid, "userid"));
break;
case 12:
$this->procRankRaceArray(2);
$this->getStart($this->searchRank($session->uid, "userid"));
break;
case 13:
$this->procRankRaceArray(3);
$this->getStart($this->searchRank($session->uid, "userid"));
break;
case 31:
$this->procAttRankArray();
@@ -160,7 +164,7 @@
public function searchRank($name, $field) {
while(1) {
$key = key($this->rankarray)+1;
$key = key($this->rankarray);
if($this->rankarray[$key][$field] == $name) {
return $key;
break;
+1
View File
@@ -168,6 +168,7 @@ class Session {
if($this->userarray['b4'] > $this->time) {
$this->bonus4 = 1;
}
$this->money = $this->userarray['money'];
}
private function SurfControl(){
+7 -7
View File
@@ -90,13 +90,13 @@ class Technology {
global $database,$village;
$trainingarray = $database->getTraining($village->wid);
$listarray = array();
$barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,41,42,43,44);
$greatbarracks = array(61,62,63,71,72,73,84,81,82,91,92,93,94,101,102,103,104);
$stables = array(4,5,6,15,16,23,24,25,26,35,36,45,46);
$greatstables = array(64,65,66,75,76,83,84,85,86,95,96,105,106);
$workshop = array(7,8,17,18,27,28,37,38,47,48);
$greatworkshop = array(67,68,77,78,87,88,97,98,107,108);
$residence = array(9,10,19,20,29,30,39,40,49,50);
$barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44);
$greatbarracks = array(61,62,63,71,72,73,84,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104);
$stables = array(4,5,6,15,16,23,24,25,26,45,46);
$greatstables = array(64,65,66,75,76,83,84,85,86,105,106);
$workshop = array(7,8,17,18,27,28,47,48);
$greatworkshop = array(67,68,77,78,87,88,107,108);
$residence = array(9,10,19,20,29,30,49,50);
$trapper = array(99);
if(count($trainingarray) > 0) {
foreach($trainingarray as $train) {