big update

This commit is contained in:
unknown
2012-04-27 12:20:13 +03:00
parent 0b01b8cf2e
commit d0c55c4c3b
27 changed files with 578 additions and 187 deletions
+80 -60
View File
@@ -75,7 +75,7 @@ class Automation {
case 40: $build = "Wonder of the World"; break;
case 41: $build = "Horse Drinking Trough"; break;
case 42: $build = "Great Workshop"; break;
default: $build = "Error"; break;
default: $build = "Nothing had"; break;
}
return $build;
}
@@ -116,7 +116,9 @@ class Automation {
$this->ClearUser();
$this->ClearInactive();
$this->oasisResoucesProduce();
$this->pruneResource();
$this->pruneOResource();
if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time()-filemtime("GameEngine/Prevention/culturepoints.txt")>10) {
$this->culturePoints();
}
@@ -133,7 +135,7 @@ class Automation {
{
$this->buildComplete();
}
$this->updateStore();
$this->updateStore();
if(!file_exists("GameEngine/Prevention/market.txt") or time()-filemtime("GameEngine/Prevention/market.txt")>10) {
$this->marketComplete();
}
@@ -162,8 +164,9 @@ class Automation {
{
$this->demolitionComplete();
}
$this->updateStore();
$this->updateStore();
}
function activeCropDead(){
global $session,$village,$database,$_SESSION, $allcrop;
// var_dump($session);
@@ -384,31 +387,31 @@ private function loyaltyRegeneration() {
foreach($needDelete as $need) {
$needVillage = $database->getVillagesID($need['uid']); //wref
foreach($needVillage as $village) {
$q = "DELETE FROM ".TB_PREFIX."abdata where wref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."abdata where wref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."bdata where wid = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."enforcement where vref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."enforcement where vref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."fdata where vref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."market where vref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."market where vref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$village['wref']." or from = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$village." or from = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."research where vref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."research where vref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."tdata where vref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."tdata where vref = ".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."training where vref =".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."training where vref =".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."units where vref =".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."units where vref =".$village;
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."vdata where wref = ".$village['wref'];
$q = "DELETE FROM ".TB_PREFIX."vdata where owner = ".$village;
$database->query($q);
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$village['wref'];
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$village;
$database->query($q);
}
$q = "DELETE FROM ".TB_PREFIX."mdata where target = ".$need['uid']." or owner = ".$need['uid'];
@@ -492,9 +495,6 @@ private function loyaltyRegeneration() {
}
}
private function culturePoints() {
global $database,$session;
$time = time()-600;
@@ -516,28 +516,6 @@ private function loyaltyRegeneration() {
}
}
# private function culturePoints() {
# global $database;
# $ourFileHandle = @fopen("GameEngine/Prevention/culturepoints.txt", 'w');
# @fclose($ourFileHandle);
# $time = time()-84600;
# $array = array();
# $q = "SELECT id, lastupdate FROM ".TB_PREFIX."users where lastupdate < $time";
# $array = $database->query_return($q);
#
# foreach($array as $indi) {
# if($indi['lastupdate'] < $time){
# $cp = $database->getVSumField($indi['id'], 'cp');
# $newupdate = time();
# $q = "UPDATE ".TB_PREFIX."users set cp = cp + 2000, lastupdate = $newupdate where id = '".$indi['id']."'";
# $database->query($q);
#}
#}
#if(file_exists("GameEngine/Prevention/culturepoints.txt")) {
# @unlink("GameEngine/Prevention/culturepoints.txt");
#}
#}
private function buildComplete() {
global $database,$bid18,$bid10,$bid11,$bid38,$bid39;
$time = time();
@@ -1315,8 +1293,7 @@ ${dead.$i}=$data['t'.$i];
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner']."";
$resulth = mysql_query($qh);
$hero_f=mysql_fetch_array($resulth);
$hero_unit=$hero_f['unit'];
//echo "///".$GLOBALS['u'.$hero_unit]['speed']."///";
$hero_unit=$hero_f['unit'];
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
}
@@ -1354,8 +1331,8 @@ ${dead.$i}=$data['t'.$i];
{
if ($catp!='0')
{
if($toF['pop']<=0)
$villpop=$this->recountPop($data['to']);
if($villpop<=0)
{
$info_cat = ",".$catp_pic.", Village already destroyed.";
}
@@ -1462,7 +1439,7 @@ ${dead.$i}=$data['t'.$i];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."market where vref = ".$data['to'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$data['to']." or from = ".$data['to'];
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$data['to']." or from = ".$data['to'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$data['to'];
$database->query($q);
@@ -1479,7 +1456,6 @@ ${dead.$i}=$data['t'.$i];
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$data['to'];
$database->query($q);
$database->clearExpansionSlot($data['to']);
$logging->VillageDestroyCatalog($data['to']);
}
}
}
@@ -1616,7 +1592,7 @@ ${dead.$i}=$data['t'.$i];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."market where vref = ".$data['to'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$data['to']." or from = ".$data['to'];
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$data['to']." or from = ".$data['to'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$data['to'];
$database->query($q);
@@ -1632,7 +1608,7 @@ ${dead.$i}=$data['t'.$i];
$database->query($q);
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$data['to'];
$database->query($q);
$logging->VillageDestroyCatalog($data['to']);
$database->clearExpansionSlot($data['to']);
}
}
}
@@ -1767,7 +1743,7 @@ ${dead.$i}=$data['t'.$i];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."market where vref = ".$data['to'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$data['to']." or from = ".$data['to'];
$q = "DELETE FROM ".TB_PREFIX."movement where to = ".$data['to']." or from = ".$data['to'];
$database->query($q);
$q = "DELETE FROM ".TB_PREFIX."odata where wref = ".$data['to'];
$database->query($q);
@@ -1783,7 +1759,7 @@ ${dead.$i}=$data['t'.$i];
$database->query($q);
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = ".$data['to'];
$database->query($q);
$logging->VillageDestroyCatalog($data['to']);
$database->clearExpansionSlot($data['to']);
}
}
}
@@ -1875,13 +1851,16 @@ ${dead.$i}=$data['t'.$i];
$pop2 = $database->getVillageField($data['to'],"pop");
if($pop1 > $pop2){
$buildlevel = $database->getResourceLevel($data['to']);
for ($i=0; $i<=99; $i++){
for ($i=1; $i<=39; $i++){
if($buildlevel['f'.$i]!=0){
$buildlevel2 = $buildlevel['f'.$i];
$q = "UPDATE ".TB_PREFIX."fdata SET `".$buildlevel2."`='".$buildlevel2."' - 1 WHERE vref=".$data['to'];
$database->query($q);
$leveldown = $buildlevel['f'.$i]-1;
$database->setVillageLevel($data['to'],"f".$i,$leveldown);
}
}
if($buildlevel['f99']!=0){
$leveldown = $buildlevel['f99']-1;
$database->setVillageLevel($data['to'],"f99",$leveldown);
}
}
//destroy wall
$database->setVillageLevel($data['to'],"f40",0);
@@ -1908,7 +1887,7 @@ ${dead.$i}=$data['t'.$i];
$value = $data['to'];
}
$database->setVillageField($data['from'],$exp,$value);
$chiefing_village = 1;
}
}
@@ -2067,13 +2046,37 @@ $crannyimg = "<img src=\"gpack/travian_default/img/g/g23.gif\" height=\"30\" wid
}
$database->setMovementProc($data['moveid']);
if($chiefing_village != 1){
$database->addMovement(4,$to['wref'],$from['wref'],$data['ref'],time(),$endtime);
}else{
$villreinf = $database->addEnforce($data);
$villtribe = $database->getUserField($from['owner'],"tribe",0);
$unittribe = $villtribe-1;
if($unittribe == 0){
$unittribe = "";
}
$database->modifyEnforce($villreinf,$unittribe.'1',$data['t1']-$dead1,1);
$database->modifyEnforce($villreinf,$unittribe.'2',$data['t2']-$dead2,1);
$database->modifyEnforce($villreinf,$unittribe.'3',$data['t3']-$dead3,1);
$database->modifyEnforce($villreinf,$unittribe.'4',$data['t4']-$dead4,1);
$database->modifyEnforce($villreinf,$unittribe.'5',$data['t5']-$dead5,1);
$database->modifyEnforce($villreinf,$unittribe.'6',$data['t6']-$dead6,1);
$database->modifyEnforce($villreinf,$unittribe.'7',$data['t7']-$dead7,1);
$database->modifyEnforce($villreinf,$unittribe.'8',$data['t8']-$dead8,1);
$database->modifyEnforce($villreinf,$unittribe.'9',$data['t9']-$dead9-1,1);
$database->modifyEnforce($villreinf,$unittribe.'10',$data['t10']-$dead10,1);
$database->modifyEnforce($villreinf,$unittribe.'11',$data['t11']-$dead11,1);
}
// send the bounty on type 6.
if($type !== 1)
{
$reference = $database->sendResource($steal[0],$steal[1],$steal[2],$steal[3],0,0);
$isoasis1 = $database->isVillageOases($to['wref']);
if ($isoasis1 == 0){
$database->modifyResource($to['wref'],$steal[0],$steal[1],$steal[2],$steal[3],0);
}else{
$database->modifyOasisResource($to['wref'],$steal[0],$steal[1],$steal[2],$steal[3],0);
}
$database->addMovement(6,$to['wref'],$from['wref'],$reference,time(),$endtime);
//$database->updateVillage($to['wref']);
$totalstolengain=$steal[0]+$steal[1]+$steal[2]+$steal[3];
@@ -2132,6 +2135,8 @@ $crannyimg = "<img src=\"gpack/travian_default/img/g/g23.gif\" height=\"30\" wid
if($NonHeroPresent == 0 && $this->getTypeLevel(37,$data['to']) > 0) {
//don't reinforce, addunit instead
$database->modifyUnit($data['to'],array("hero"),array(1),array(1));
$heroid = $database->getHero($database->getVillageField($data['from'],"owner"),1);
$database->modifyHero("wref",$data['to'],$heroid,0);
$HeroTransfer = 1;
}
}
@@ -2822,8 +2827,7 @@ private function demolitionComplete() {
}
// by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de >
private function updateStore()
{
private function updateStore() {
global $bid10, $bid38, $bid11, $bid39;
$result = mysql_query('SELECT * FROM `' . TB_PREFIX . 'fdata`');
@@ -2867,7 +2871,23 @@ private function demolitionComplete() {
mysql_query('UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . $ress . ', `maxcrop` = ' . $crop . ' WHERE `wref` = ' . $row['vref']) or die(mysql_error());
}
}
}
private function oasisResoucesProduce() {
global $database;
$time = time();
$q = "SELECT * FROM ".TB_PREFIX."odata WHERE wood < 800 OR clay < 800 OR iron < 800 OR crop < 800";
$array = $database->query_return($q);
foreach($array as $getoasis) {
$oasiswood = (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
$oasisclay = (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
$oasisiron = (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
$oasiscrop = (8*SPEED/3600)*(time()-$getoasis['lastupdated']);
$database->modifyOasisResource($getoasis['wref'],$oasiswood,$oasisclay,$oasisiron,$oasiscrop,1);
$database->updateOasis($getoasis['wref']);
}
}
}
$automation = new Automation;
?>
+19 -5
View File
@@ -102,7 +102,7 @@ class Building {
return 8;
}
else {
if($session->plus) {
if($session->plus or $tid==40) {
if($this->plus == 0) {
return 9;
}
@@ -120,7 +120,7 @@ class Building {
return 8;
}
else {
if($session->plus) {
if($session->plus or $tid==40) {
if($this->plus == 0) {
return 9;
}
@@ -136,7 +136,7 @@ class Building {
}
else {
if($this->basic == 1) {
if($session->plus && $this->plus == 0) {
if(($session->plus or $tid==40) && $this->plus == 0) {
return 9;
}
else {
@@ -329,7 +329,7 @@ class Building {
$time = time() + round($dataarray[$village->resarray['f'.$id]-1]['time'] / 4);
$loop = 0;
if($this->inner == 1 || $this->basic == 1) {
if($session->plus && $this->plus == 0) {
if(($session->plus or $village->resarray['f'.$id.'t']==40)&& $this->plus == 0) {
$loop = 1;
}
}
@@ -619,11 +619,19 @@ class Building {
}
private function finishAll() {
global $database,$session,$logging,$village,$bid18,$bid10,$bid11,$technology;
global $database,$session,$logging,$village,$bid18,$bid10,$bid11,$technology,$_SESSION;
if($session->access!=BANNED){
if($session->gold >= 2){
foreach($this->buildArray as $jobs) {
if($jobs['wid']==$village->wid){
$wwvillage = $database->getResourceLevel($jobs['wid']);
if($wwvillage['f99t']!=40){
$level = $database->getFieldLevel($jobs['wid'],$jobs['field']);
$level = ($level == -1) ? 0 : $level;
if($jobs['type'] != 25 AND $jobs['type'] != 26 AND $jobs['type'] != 40) {
$gold=$database->getUserField($_SESSION['username'],'gold','username');
$gold-=2;
$database->updateUserField($_SESSION['username'],'gold',$gold,0);
$resource = $this->resourceRequired($jobs['field'],$jobs['type']);
$q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = f".$jobs['field']." + 1, f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid'];
if($database->query($q)) {
@@ -670,6 +678,8 @@ class Building {
if(($jobs['field'] >= 19 && ($session->tribe == 1 || ALLOW_ALL_TRIBE)) || (!ALLOW_ALL_TRIBE && $session->tribe != 1)) { $innertimestamp = $jobs['timestamp']; }
}
}
}
}
$technology->finishTech();
$logging->goldFinLog($village->wid);
$database->modifyGold($session->uid,0,0);
@@ -681,6 +691,10 @@ class Building {
}
}
header("Location: ".$session->referrer);
}
}else{
header("Location: banned.php");
}
}
public function resourceRequired($id,$tid,$plus=1) {
-9
View File
@@ -83,15 +83,6 @@ class Logging {
$database->query($q);
}
}
public function VillageDestroyCatalog($wid) {
global $database;
if(LOG_GOLD_FIN) {
$log = "Village destroyed";
$q = "Insert into ".TB_PREFIX."destroy_log values (0,$wid,'$log')";
$database->query($q);
}
}
public function addWarLog() {
global $database;
+4 -1
View File
@@ -243,6 +243,8 @@ class Market {
private function tradeResource($post) {
global $session,$database,$village;
$wwvillage = $database->getResourceLevel($village->wid);
if($wwvillage['f99t']!=40){
if($session->userinfo['gold'] >= 3) {
//kijken of ze niet meer gs invoeren dan ze hebben
if($session->access == BANNED){
@@ -259,7 +261,8 @@ class Market {
}
} else {
header("Location: build.php?id=".$post['id']."&t=3");
}
}
}
}
};
+30 -1
View File
@@ -323,6 +323,21 @@ class Units {
$post['t'.$i.'']='0';
}
}
if(isset($post['t11'])){
if ($post['t11'] > $enforce['hero'])
{
$form->addError("error","You can't send more units than you have");
break;
}
if($post['t11']<0)
{
$form->addError("error","You can't send negative units.");
break;
}
} else {
$post['t11']='0';
}
if($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors();
@@ -340,6 +355,7 @@ class Units {
}
//get cord
$from = $database->getVillage($enforce['from']);
$fromcoor = $database->getCoor($enforce['from']);
$tocoor = $database->getCoor($enforce['vref']);
$fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']);
@@ -361,8 +377,21 @@ class Units {
$post['t'.$i.'']='0';
}
}
if (isset($post['t11'])){
if( $post['t11'] != '' && $post['t11'] > 0){
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner']."";
$resulth = mysql_query($qh);
$hero_f=mysql_fetch_array($resulth);
$hero_unit=$hero_f['unit'];
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
} else {
$post['t11']='0';
}
} else {
$post['t11']='0';
}
$time = $generator->procDistanceTime($fromCor,$toCor,min($speeds),1);
$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'],0,2,0,0,0,0);
$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,$village->wid,$enforce['from'],$reference,time(),($time+time()));
$technology->checkReinf($post['ckey']);