Fixed a bug in oasis

+Oasis now produce resources correctly
This commit is contained in:
iopietro
2018-04-21 19:41:44 +02:00
parent e9def19bd9
commit daa7f0fdf4
2 changed files with 42 additions and 55 deletions
+18 -21
View File
@@ -10,7 +10,7 @@
## Fixed by: Shadow - STARVATION , HERO FIXED COMPL. ## ## Fixed by: Shadow - STARVATION , HERO FIXED COMPL. ##
## Fixed by: InCube - double troops ## ## Fixed by: InCube - double troops ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2015. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2018. All rights reserved. ##
## URLs: http://travian.shadowss.ro ## ## URLs: http://travian.shadowss.ro ##
## Source code: https://github.com/Shadowss/TravianZ ## ## Source code: https://github.com/Shadowss/TravianZ ##
## ## ## ##
@@ -34,7 +34,7 @@ class Automation {
$this->procNewClimbers(); $this->procNewClimbers();
$this->ClearUser(); $this->ClearUser();
$this->ClearInactive(); $this->ClearInactive();
$this->oasisResourcesProduce(); //$this->oasisResourcesProduce();
$this->pruneResource(); $this->pruneResource();
$this->pruneOResource(); $this->pruneOResource();
$this->checkWWAttacks(); $this->checkWWAttacks();
@@ -2102,7 +2102,7 @@ class Automation {
}else{ }else{
$cranny_eff = 0; $cranny_eff = 0;
if ($conqureby >0) { //10% from owner proc village owner - fix by ronix if ($conqureby > 0) { //10% from owner proc village owner - fix by ronix
$this->updateRes($conqureby,$to['owner']); $this->updateRes($conqureby,$to['owner']);
$this->pruneResource(); $this->pruneResource();
@@ -2116,7 +2116,7 @@ class Automation {
$this->updateORes($data['to']); $this->updateORes($data['to']);
$this->pruneOResource(); $this->pruneOResource();
$oasisData = $database->getOasisFields($data['to'],'clay, iron, wood, crop'); $oasisData = $database->getOasisFields($data['to'], false);
$totclay = $oasisData['clay']; $totclay = $oasisData['clay'];
$totiron = $oasisData['iron']; $totiron = $oasisData['iron'];
$totwood = $oasisData['wood']; $totwood = $oasisData['wood'];
@@ -2974,16 +2974,15 @@ class Automation {
// send the bounty on type 6. // send the bounty on type 6.
if($type !== 1){ if($type !== 1){
$reference = $database->sendResource($steal[0],$steal[1],$steal[2],$steal[3],0,0); $reference = $database->sendResource($steal[0], $steal[1], $steal[2], $steal[3], 0, 0);
if ($isoasis == 0){ if ($isoasis == 0){
$database->modifyResource($DefenderWref,$steal[0],$steal[1],$steal[2],$steal[3],0); $database->modifyResource($DefenderWref, $steal[0], $steal[1], $steal[2], $steal[3], 0);
}else{ }else{
if($conqureby > 0) //if it's an oasis but it's conquered by someone, resources must be modified in the owner village if($conqureby > 0) //if it's an oasis but it's conquered by someone, resources must be modified in the owner village
{ {
$database->modifyResource($conqureby,$steal[0],$steal[1],$steal[2],$steal[3],0); $database->modifyResource($conqureby, $steal[0], $steal[1], $steal[2], $steal[3], 0);
}else{
$database->modifyOasisResource($DefenderWref,$steal[0],$steal[1],$steal[2],$steal[3],0);
} }
else $database->modifyOasisResource($DefenderWref, $steal[0], $steal[1], $steal[2], $steal[3], 0);
} }
$database->addMovement(6,$DefenderWref,$AttackerWref,$reference,$AttackArrivalTime,$endtime,1,0,0,0,0,$data['ref']); $database->addMovement(6,$DefenderWref,$AttackerWref,$reference,$AttackArrivalTime,$endtime,1,0,0,0,0,$data['ref']);
$totalstolengain=$steal[0]+$steal[1]+$steal[2]+$steal[3]; $totalstolengain=$steal[0]+$steal[1]+$steal[2]+$steal[3];
@@ -3783,10 +3782,9 @@ class Automation {
private function bountyLoadOTown($bountywid) { private function bountyLoadOTown($bountywid) {
global $database; global $database;
$this->bountyinfoarray = $database->getOasisV($bountywid); $this->bountyinfoarray = $database->getOasisV($bountywid);
$this->bountyresarray = $database->getResourceLevel($bountywid);
$this->bountypop = 2; $this->bountypop = 2;
} }
private function bountyLoadTown($bountywid) { private function bountyLoadTown($bountywid) {
global $database; global $database;
$this->bountyinfoarray = $database->getVillage($bountywid); $this->bountyinfoarray = $database->getVillage($bountywid);
@@ -3794,7 +3792,6 @@ class Automation {
$this->bountyoasisowned = $database->getOasis($bountywid); $this->bountyoasisowned = $database->getOasis($bountywid);
$this->bountyocounter = $this->bountysortOasis(); $this->bountyocounter = $this->bountysortOasis();
$this->bountypop = $this->bountyinfoarray['pop']; $this->bountypop = $this->bountyinfoarray['pop'];
} }
private function bountysortOasis() { private function bountysortOasis() {
@@ -4029,12 +4026,12 @@ class Automation {
} }
private function bountycalculateOProduction($bountywid) { private function bountycalculateOProduction($bountywid) {
global $technology,$database;
$this->bountyOproduction['wood'] = $this->bountyGetOWoodProd(); $this->bountyOproduction['wood'] = $this->bountyGetOWoodProd();
$this->bountyOproduction['clay'] = $this->bountyGetOClayProd(); $this->bountyOproduction['clay'] = $this->bountyGetOClayProd();
$this->bountyOproduction['iron'] = $this->bountyGetOIronProd(); $this->bountyOproduction['iron'] = $this->bountyGetOIronProd();
$this->bountyOproduction['crop'] = $this->bountyGetOCropProd(); $this->bountyOproduction['crop'] = $this->bountyGetOCropProd();
} }
private function bountycalculateProduction($bountywid,$uid) { private function bountycalculateProduction($bountywid,$uid) {
global $technology,$database; global $technology,$database;
$normalA = $database->getOwnArtefactInfoByType($bountywid,4); $normalA = $database->getOwnArtefactInfoByType($bountywid,4);
@@ -4065,17 +4062,17 @@ class Automation {
$nclay = ($this->bountyproduction['clay'] / 3600) * $timepast; $nclay = ($this->bountyproduction['clay'] / 3600) * $timepast;
$niron = ($this->bountyproduction['iron'] / 3600) * $timepast; $niron = ($this->bountyproduction['iron'] / 3600) * $timepast;
$ncrop = ($this->bountyproduction['crop'] / 3600) * $timepast; $ncrop = ($this->bountyproduction['crop'] / 3600) * $timepast;
$database->modifyResource($bountywid,$nwood,$nclay,$niron,$ncrop,1); $database->modifyResource($bountywid, $nwood, $nclay, $niron, $ncrop, 1);
$database->updateVillage($bountywid); $database->updateVillage($bountywid);
} }
private function bountyprocessOProduction($bountywid) { private function bountyprocessOProduction($bountywid) {
global $database; global $database;
$timepast = time() - $this->bountyinfoarray['lastupdated']; $timepast = time() - $this->bountyinfoarray['lastupdated'];
$nwood = ($this->bountyproduction['wood'] / 3600) * $timepast; $nwood = ($this->bountyOproduction['wood'] / 3600) * $timepast;
$nclay = ($this->bountyproduction['clay'] / 3600) * $timepast; $nclay = ($this->bountyOproduction['clay'] / 3600) * $timepast;
$niron = ($this->bountyproduction['iron'] / 3600) * $timepast; $niron = ($this->bountyOproduction['iron'] / 3600) * $timepast;
$ncrop = ($this->bountyproduction['crop'] / 3600) * $timepast; $ncrop = ($this->bountyOproduction['crop'] / 3600) * $timepast;
$database->modifyOasisResource($bountywid,$nwood,$nclay,$niron,$ncrop,1); $database->modifyOasisResource($bountywid, $nwood, $nclay, $niron, $ncrop, 1);
$database->updateOasis($bountywid); $database->updateOasis($bountywid);
} }
@@ -4662,7 +4659,7 @@ class Automation {
mysqli_commit($database->dblink); mysqli_commit($database->dblink);
} }
private function oasisResourcesProduce() { /*private function oasisResourcesProduce() {
global $database; global $database;
$speedMultiplier = (8 * (SPEED/3600)); $speedMultiplier = (8 * (SPEED/3600));
@@ -4679,7 +4676,7 @@ class Automation {
clay < 800 OR clay < 800 OR
iron < 800 OR iron < 800 OR
crop < 800"); crop < 800");
} }*/
private function checkInvitedPlayes() { private function checkInvitedPlayes() {
global $database; global $database;
+23 -33
View File
@@ -2064,16 +2064,9 @@ class MYSQLi_DB implements IDbConnection {
// return all data, don't waste time by selecting fields one by one // return all data, don't waste time by selecting fields one by one
$oasisArray = $this->getOasisV($ref, $use_cache); $oasisArray = $this->getOasisV($ref, $use_cache);
return (isset($oasisArray[$field]) ? $oasisArray[$field] : null); return (isset($oasisArray[$field]) ? $oasisArray[$field] : null);
/*list($ref, $field) = $this->escape_input((int) $ref, $field);
$q = "SELECT $field FROM " . TB_PREFIX . "odata where wref = $ref";
$result = mysqli_query($this->dblink,$q);
$dbarray = mysqli_fetch_array($result);
return $dbarray[$field];*/
} }
function getOasisFields($ref, $fields, $use_cache = true) { function getOasisFields($ref, $use_cache = true) {
// return all data, don't waste time by selecting fields one by one // return all data, don't waste time by selecting fields one by one
return $this->getOasisV($ref, $use_cache); return $this->getOasisV($ref, $use_cache);
@@ -3341,37 +3334,34 @@ class MYSQLi_DB implements IDbConnection {
$negativeResources = false; $negativeResources = false;
$checkres = $this->getOasisV($vid); $checkres = $this->getOasisV($vid);
if ( ! $mode ) { if (!$mode) {
$nwood = $checkres[0]['wood'] - $wood; $nwood = $checkres['wood'] - $wood;
$nclay = $checkres[0]['clay'] - $clay; $nclay = $checkres['clay'] - $clay;
$niron = $checkres[0]['iron'] - $iron; $niron = $checkres['iron'] - $iron;
$ncrop = $checkres[0]['crop'] - $crop; $ncrop = $checkres['crop'] - $crop;
if ( $nwood < 0 or $nclay < 0 or $niron < 0 or $ncrop < 0 ) { $negativeResources = $nwood < 0 || $nclay < 0 || $niron < 0 || $ncrop < 0;
$negativeResources = true;
}
$dwood = ( $nwood < 0 ) ? 0 : $nwood; $dwood = ($nwood < 0) ? 0 : $nwood;
$dclay = ( $nclay < 0 ) ? 0 : $nclay; $dclay = ($nclay < 0) ? 0 : $nclay;
$diron = ( $niron < 0 ) ? 0 : $niron; $diron = ($niron < 0) ? 0 : $niron;
$dcrop = ( $ncrop < 0 ) ? 0 : $ncrop; $dcrop = ($ncrop < 0) ? 0 : $ncrop;
} else { } else {
$nwood = $checkres[0]['wood'] + $wood; $nwood = $checkres['wood'] + $wood;
$nclay = $checkres[0]['clay'] + $clay; $nclay = $checkres['clay'] + $clay;
$niron = $checkres[0]['iron'] + $iron; $niron = $checkres['iron'] + $iron;
$ncrop = $checkres[0]['crop'] + $crop; $ncrop = $checkres['crop'] + $crop;
$dwood = ( $nwood > $checkres[0]['maxstore'] ) ? $checkres[0]['maxstore'] : $nwood; $dwood = ($nwood > $checkres['maxstore']) ? $checkres['maxstore'] : $nwood;
$dclay = ( $nclay > $checkres[0]['maxstore'] ) ? $checkres[0]['maxstore'] : $nclay; $dclay = ($nclay > $checkres['maxstore']) ? $checkres['maxstore'] : $nclay;
$diron = ( $niron > $checkres[0]['maxstore'] ) ? $checkres[0]['maxstore'] : $niron; $diron = ($niron > $checkres['maxstore']) ? $checkres['maxstore'] : $niron;
$dcrop = ( $ncrop > $checkres[0]['maxcrop'] ) ? $checkres[0]['maxcrop'] : $ncrop; $dcrop = ($ncrop > $checkres['maxcrop']) ? $checkres['maxcrop'] : $ncrop;
} }
if ( ! $negativeResources ) { if (!$negativeResources) {
$q = "UPDATE " . TB_PREFIX . "odata set wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop where wref = " . $vid; $q = "UPDATE " . TB_PREFIX . "odata SET wood = $dwood, clay = $dclay, iron = $diron, crop = $dcrop WHERE wref = ".$vid;
return mysqli_query( $this->dblink, $q ); return mysqli_query($this->dblink, $q);
} else {
return false;
} }
else return false;
} }
function getFieldLevelInVillage($vid, $fieldType, $use_cache = true) { function getFieldLevelInVillage($vid, $fieldType, $use_cache = true) {