mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-24 20:17:13 +00:00
fix: cannot send traders to village determined by a village name
This commit is contained in:
@@ -3471,7 +3471,10 @@ class Automation {
|
|||||||
//add unit.
|
//add unit.
|
||||||
$j='1';
|
$j='1';
|
||||||
for($i=$start;$i<=$end;$i++){
|
for($i=$start;$i<=$end;$i++){
|
||||||
$t_units.="u".$i."=u".$i." + ".$data['t'.$j].(($j > 9) ? '' : ', ');$j++;
|
if (!isset($t_units)) {
|
||||||
|
$t_units = '';
|
||||||
|
}
|
||||||
|
$t_units .= "u".$i."=u".$i." + ".$data['t'.$j].(($j > 9) ? '' : ', ');$j++;
|
||||||
}
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."enforcement set $t_units where id =".(int) $check['id'];
|
$q = "UPDATE ".TB_PREFIX."enforcement set $t_units where id =".(int) $check['id'];
|
||||||
$database->query($q);
|
$database->query($q);
|
||||||
|
|||||||
+13
-13
@@ -3,15 +3,15 @@
|
|||||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||||
## --------------------------------------------------------------------------- ##
|
## --------------------------------------------------------------------------- ##
|
||||||
## Project: TravianZ ##
|
## Project: TravianZ ##
|
||||||
## Version: 22.06.2015 ##
|
## Version: 22.06.2015 ##
|
||||||
## Filename db_MYSQL.php ##
|
## Filename db_MYSQL.php ##
|
||||||
## Developed by: Mr.php , Advocaite , brainiacX , yi12345 , Shadow , ronix ##
|
## Developed by: Mr.php , Advocaite , brainiacX , yi12345 , Shadow , ronix ##
|
||||||
## 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-2015. 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 ##
|
||||||
## ##
|
## ##
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
@@ -46,47 +46,47 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
* @var string MySQL server hostname to connect to.
|
* @var string MySQL server hostname to connect to.
|
||||||
*/
|
*/
|
||||||
$hostname = 'localhost',
|
$hostname = 'localhost',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int MySQL server port to connect to.
|
* @var int MySQL server port to connect to.
|
||||||
*/
|
*/
|
||||||
$port = 3306,
|
$port = 3306,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Username to authenticate with to the MySQL connection.
|
* @var string Username to authenticate with to the MySQL connection.
|
||||||
*/
|
*/
|
||||||
$username = 'root',
|
$username = 'root',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Password to authenticate with to the MySQL connection.
|
* @var string Password to authenticate with to the MySQL connection.
|
||||||
*/
|
*/
|
||||||
$password = '',
|
$password = '',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Database to use with TravianZ.
|
* @var string Database to use with TravianZ.
|
||||||
*/
|
*/
|
||||||
$dbname = 'travian',
|
$dbname = 'travian',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Counter of all SELECT queries performed.
|
* @var int Counter of all SELECT queries performed.
|
||||||
*/
|
*/
|
||||||
$selectQueryCount = 0,
|
$selectQueryCount = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Counter of all INSERT queries performed.
|
* @var int Counter of all INSERT queries performed.
|
||||||
*/
|
*/
|
||||||
$insertQueryCount = 0,
|
$insertQueryCount = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Counter of all UPDATE queries performed.
|
* @var int Counter of all UPDATE queries performed.
|
||||||
*/
|
*/
|
||||||
$updateQueryCount = 0,
|
$updateQueryCount = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Counter of all DELETE queries performed.
|
* @var int Counter of all DELETE queries performed.
|
||||||
*/
|
*/
|
||||||
$deleteQueryCount = 0,
|
$deleteQueryCount = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int Counter of all REPLACE queries performed.
|
* @var int Counter of all REPLACE queries performed.
|
||||||
*/
|
*/
|
||||||
@@ -4762,7 +4762,7 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
function getVillageByName($name) {
|
function getVillageByName($name) {
|
||||||
list($name) = $this->escape_input($name);
|
list($name) = $this->escape_input($name);
|
||||||
|
|
||||||
$q = "SELECT wref FROM " . TB_PREFIX . "vdata where name = '$name' limit 1 LIMIT 1";
|
$q = "SELECT wref FROM " . TB_PREFIX . "vdata WHERE `name` = '$name' LIMIT 1";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
$result = mysqli_query($this->dblink,$q);
|
||||||
$dbarray = mysqli_fetch_array($result);
|
$dbarray = mysqli_fetch_array($result);
|
||||||
return $dbarray['wref'];
|
return $dbarray['wref'];
|
||||||
|
|||||||
+310
-310
@@ -1,259 +1,259 @@
|
|||||||
<?php
|
<?php
|
||||||
#################################################################################
|
#################################################################################
|
||||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||||
## --------------------------------------------------------------------------- ##
|
## --------------------------------------------------------------------------- ##
|
||||||
## Filename Market.php ##
|
## Filename Market.php ##
|
||||||
## Developed by: Dzoki ##
|
## Developed by: Dzoki ##
|
||||||
## Some fixes: aggenkeech ##
|
## Some fixes: aggenkeech ##
|
||||||
## License: TravianX Project ##
|
## License: TravianX Project ##
|
||||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||||
## ##
|
## ##
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
class Market
|
class Market
|
||||||
{
|
{
|
||||||
public $onsale,$onmarket,$sending,$recieving,$return = array();
|
public $onsale,$onmarket,$sending,$recieving,$return = array();
|
||||||
public $maxcarry,$merchant,$used;
|
public $maxcarry,$merchant,$used;
|
||||||
|
|
||||||
public function procMarket($post)
|
public function procMarket($post)
|
||||||
{
|
{
|
||||||
$this->loadMarket();
|
$this->loadMarket();
|
||||||
if(isset($_SESSION['loadMarket']))
|
if(isset($_SESSION['loadMarket']))
|
||||||
{
|
{
|
||||||
$this->loadOnsale();
|
$this->loadOnsale();
|
||||||
unset($_SESSION['loadMarket']);
|
unset($_SESSION['loadMarket']);
|
||||||
}
|
}
|
||||||
if(isset($post['ft']))
|
if(isset($post['ft']))
|
||||||
{
|
{
|
||||||
switch($post['ft'])
|
switch($post['ft'])
|
||||||
{
|
{
|
||||||
case "mk1": $this->sendResource($post); break;
|
case "mk1": $this->sendResource($post); break;
|
||||||
case "mk2": $this->addOffer($post); break;
|
case "mk2": $this->addOffer($post); break;
|
||||||
case "mk3": $this->tradeResource($post); break;
|
case "mk3": $this->tradeResource($post); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function procRemove($get)
|
public function procRemove($get)
|
||||||
{
|
{
|
||||||
global $database,$village,$session;
|
global $database,$village,$session;
|
||||||
|
|
||||||
if(isset($get['t']) && $get['t'] == 1)
|
if(isset($get['t']) && $get['t'] == 1)
|
||||||
{
|
{
|
||||||
$this->filterNeed($get);
|
$this->filterNeed($get);
|
||||||
}
|
}
|
||||||
else if(isset($get['t']) && $get['t'] ==2 && isset($get['a']) && $get['a'] == 5 && isset($get['del']))
|
else if(isset($get['t']) && $get['t'] ==2 && isset($get['a']) && $get['a'] == 5 && isset($get['del']))
|
||||||
{
|
{
|
||||||
//GET ALL FIELDS FROM MARKET
|
//GET ALL FIELDS FROM MARKET
|
||||||
$type = $database->getMarketField($village->wid,"gtype");
|
$type = $database->getMarketField($village->wid,"gtype");
|
||||||
$amt = $database->getMarketField($village->wid,"gamt");
|
$amt = $database->getMarketField($village->wid,"gamt");
|
||||||
$vref = $village->wid;
|
$vref = $village->wid;
|
||||||
$database->getResourcesBack($vref,$type,$amt);
|
$database->getResourcesBack($vref,$type,$amt);
|
||||||
$database->addMarket($village->wid,$get['del'],0,0,0,0,0,0,1);
|
$database->addMarket($village->wid,$get['del'],0,0,0,0,0,0,1);
|
||||||
header("Location: build.php?id=".$get['id']."&t=2");
|
header("Location: build.php?id=".$get['id']."&t=2");
|
||||||
exit;
|
exit;
|
||||||
}
|
|
||||||
if(isset($get['t']) && $get['t'] == 1 && isset($get['a']) && $get['a'] == $session->mchecker && !isset($get['del']))
|
|
||||||
{
|
|
||||||
$session->changeChecker();
|
|
||||||
$this->acceptOffer($get);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function merchantAvail()
|
|
||||||
{
|
|
||||||
return $this->merchant - $this->used;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function loadMarket()
|
|
||||||
{
|
|
||||||
global $session,$building,$bid28,$bid17,$database,$village;
|
|
||||||
|
|
||||||
$this->recieving = $database->getMovement(0,$village->wid,1);
|
|
||||||
$this->sending = $database->getMovement(0,$village->wid,0);
|
|
||||||
$this->return = $database->getMovement(2,$village->wid,1);
|
|
||||||
$this->merchant = ($building->getTypeLevel(17) > 0)? $bid17[$building->getTypeLevel(17)]['attri'] : 0;
|
|
||||||
$this->used = $database->totalMerchantUsed($village->wid);
|
|
||||||
$this->onmarket = $database->getMarket($village->wid,0);
|
|
||||||
$this->maxcarry = ($session->tribe == 1)? 500 : (($session->tribe == 2)? 1000 : 750);
|
|
||||||
$this->maxcarry *= TRADER_CAPACITY;
|
|
||||||
if($building->getTypeLevel(28) != 0)
|
|
||||||
{
|
|
||||||
$this->maxcarry *= $bid28[$building->getTypeLevel(28)]['attri'] / 100;
|
|
||||||
}
|
}
|
||||||
}
|
if(isset($get['t']) && $get['t'] == 1 && isset($get['a']) && $get['a'] == $session->mchecker && !isset($get['del']))
|
||||||
|
{
|
||||||
|
$session->changeChecker();
|
||||||
|
$this->acceptOffer($get);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function sendResource($post)
|
public function merchantAvail()
|
||||||
{
|
{
|
||||||
global $database,$village,$session,$generator,$logging,$form;
|
return $this->merchant - $this->used;
|
||||||
|
}
|
||||||
$wtrans = (isset($post['r1']) && $post['r1'] != "")? $post['r1'] : 0;
|
|
||||||
$ctrans = (isset($post['r2']) && $post['r2'] != "")? $post['r2'] : 0;
|
private function loadMarket()
|
||||||
$itrans = (isset($post['r3']) && $post['r3'] != "")? $post['r3'] : 0;
|
{
|
||||||
$crtrans = (isset($post['r4']) && $post['r4'] != "")? $post['r4'] : 0;
|
global $session,$building,$bid28,$bid17,$database,$village;
|
||||||
$wtrans = str_replace("-", "", $wtrans);
|
|
||||||
$ctrans = str_replace("-", "", $ctrans);
|
$this->recieving = $database->getMovement(0,$village->wid,1);
|
||||||
$itrans = str_replace("-", "", $itrans);
|
$this->sending = $database->getMovement(0,$village->wid,0);
|
||||||
|
$this->return = $database->getMovement(2,$village->wid,1);
|
||||||
|
$this->merchant = ($building->getTypeLevel(17) > 0)? $bid17[$building->getTypeLevel(17)]['attri'] : 0;
|
||||||
|
$this->used = $database->totalMerchantUsed($village->wid);
|
||||||
|
$this->onmarket = $database->getMarket($village->wid,0);
|
||||||
|
$this->maxcarry = ($session->tribe == 1)? 500 : (($session->tribe == 2)? 1000 : 750);
|
||||||
|
$this->maxcarry *= TRADER_CAPACITY;
|
||||||
|
if($building->getTypeLevel(28) != 0)
|
||||||
|
{
|
||||||
|
$this->maxcarry *= $bid28[$building->getTypeLevel(28)]['attri'] / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendResource($post)
|
||||||
|
{
|
||||||
|
global $database,$village,$session,$generator,$logging,$form;
|
||||||
|
|
||||||
|
$wtrans = (isset($post['r1']) && $post['r1'] != "")? $post['r1'] : 0;
|
||||||
|
$ctrans = (isset($post['r2']) && $post['r2'] != "")? $post['r2'] : 0;
|
||||||
|
$itrans = (isset($post['r3']) && $post['r3'] != "")? $post['r3'] : 0;
|
||||||
|
$crtrans = (isset($post['r4']) && $post['r4'] != "")? $post['r4'] : 0;
|
||||||
|
$wtrans = str_replace("-", "", $wtrans);
|
||||||
|
$ctrans = str_replace("-", "", $ctrans);
|
||||||
|
$itrans = str_replace("-", "", $itrans);
|
||||||
$crtrans = str_replace("-", "", $crtrans);
|
$crtrans = str_replace("-", "", $crtrans);
|
||||||
// preload all village data, since we're retrieving some of those separately below
|
// preload all village data, since we're retrieving some of those separately below
|
||||||
$database->getVillage($village->wid);
|
$database->getVillage($village->wid);
|
||||||
|
|
||||||
$availableWood = $database->getWoodAvailable($village->wid);
|
$availableWood = $database->getWoodAvailable($village->wid);
|
||||||
$availableClay = $database->getClayAvailable($village->wid);
|
$availableClay = $database->getClayAvailable($village->wid);
|
||||||
$availableIron = $database->getIronAvailable($village->wid);
|
$availableIron = $database->getIronAvailable($village->wid);
|
||||||
$availableCrop = $database->getCropAvailable($village->wid);
|
$availableCrop = $database->getCropAvailable($village->wid);
|
||||||
//check if vacation mode:
|
//check if vacation mode:
|
||||||
if($database->getvacmodexy($id)){
|
if($database->getvacmodexy($id)){
|
||||||
$form->addError("error","User is on vacation mode");
|
$form->addError("error","User is on vacation mode");
|
||||||
}
|
}
|
||||||
if($session->access == BANNED)
|
if($session->access == BANNED)
|
||||||
{
|
{
|
||||||
header("Location: banned.php");
|
header("Location: banned.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else if($availableWood >= $post['r1'] AND $availableClay >= $post['r2'] AND $availableIron >= $post['r3'] AND $availableCrop >= $post['r4'])
|
else if($availableWood >= $post['r1'] AND $availableClay >= $post['r2'] AND $availableIron >= $post['r3'] AND $availableCrop >= $post['r4'])
|
||||||
{
|
{
|
||||||
$resource = array($wtrans,$ctrans,$itrans,$crtrans);
|
$resource = array($wtrans,$ctrans,$itrans,$crtrans);
|
||||||
$reqMerc = ceil((array_sum($resource)-0.1)/$this->maxcarry);
|
$reqMerc = ceil((array_sum($resource)-0.1)/$this->maxcarry);
|
||||||
|
|
||||||
if($this->merchantAvail() != 0 && $reqMerc <= $this->merchantAvail())
|
if($this->merchantAvail() != 0 && $reqMerc <= $this->merchantAvail())
|
||||||
{
|
{
|
||||||
$id = $post['getwref'];
|
$id = $post['getwref'];
|
||||||
$coor = $database->getCoor($id);
|
$coor = $database->getCoor($id);
|
||||||
if($database->getVillageState($id))
|
if($database->getVillageState($id))
|
||||||
{
|
{
|
||||||
$timetaken = $generator->procDistanceTime($coor,$village->coor,$session->tribe,0);
|
$timetaken = $generator->procDistanceTime($coor,$village->coor,$session->tribe,0);
|
||||||
$res = $resource[0]+$resource[1]+$resource[2]+$resource[3];
|
$res = $resource[0]+$resource[1]+$resource[2]+$resource[3];
|
||||||
if($res!=0)
|
if($res!=0)
|
||||||
{
|
{
|
||||||
$reference = $database->sendResource($resource[0],$resource[1],$resource[2],$resource[3],$reqMerc,0);
|
$reference = $database->sendResource($resource[0],$resource[1],$resource[2],$resource[3],$reqMerc,0);
|
||||||
$database->modifyResource($village->wid,$resource[0],$resource[1],$resource[2],$resource[3],0);
|
$database->modifyResource($village->wid,$resource[0],$resource[1],$resource[2],$resource[3],0);
|
||||||
$database->addMovement(0,$village->wid,$id,$reference,time(),time()+$timetaken,$post['send3']);
|
$database->addMovement(0,$village->wid,$id,$reference,time(),time()+$timetaken,$post['send3']);
|
||||||
$logging->addMarketLog($village->wid,1,array($resource[0],$resource[1],$resource[2],$resource[3],$id));
|
$logging->addMarketLog($village->wid,1,array($resource[0],$resource[1],$resource[2],$resource[3],$id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header("Location: build.php?id=".$post['id']);
|
header("Location: build.php?id=".$post['id']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: WTF??? :D
|
// TODO: WTF??? :D
|
||||||
// something
|
// something
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addOffer($post)
|
private function addOffer($post)
|
||||||
{
|
{
|
||||||
global $database,$village,$session;
|
global $database,$village,$session;
|
||||||
|
|
||||||
|
|
||||||
if($post['rid1'] == $post['rid2'])
|
if($post['rid1'] == $post['rid2'])
|
||||||
{
|
{
|
||||||
// Trading res for res of same type (invalid)
|
// Trading res for res of same type (invalid)
|
||||||
header("Location: build.php?id=".$post['id']."&t=2&e2");
|
header("Location: build.php?id=".$post['id']."&t=2&e2");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
elseif($post['m1'] > (2 * $post['m2']))
|
elseif($post['m1'] > (2 * $post['m2']))
|
||||||
{
|
{
|
||||||
// Trade is for more than 2x (invalid)
|
// Trade is for more than 2x (invalid)
|
||||||
header("Location: build.php?id=".$post['id']."&t=2&e2");
|
header("Location: build.php?id=".$post['id']."&t=2&e2");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
elseif($post['m2'] > (2 * $post['m1']))
|
elseif($post['m2'] > (2 * $post['m1']))
|
||||||
{
|
{
|
||||||
// Trade is for less than 0.5x (invalid)
|
// Trade is for less than 0.5x (invalid)
|
||||||
header("Location: build.php?id=".$post['id']."&t=2&e2");
|
header("Location: build.php?id=".$post['id']."&t=2&e2");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$wood = ($post['rid1'] == 1)? $post['m1'] : 0;
|
$wood = ($post['rid1'] == 1)? $post['m1'] : 0;
|
||||||
$clay = ($post['rid1'] == 2)? $post['m1'] : 0;
|
$clay = ($post['rid1'] == 2)? $post['m1'] : 0;
|
||||||
$iron = ($post['rid1'] == 3)? $post['m1'] : 0;
|
$iron = ($post['rid1'] == 3)? $post['m1'] : 0;
|
||||||
$crop = ($post['rid1'] == 4)? $post['m1'] : 0;
|
$crop = ($post['rid1'] == 4)? $post['m1'] : 0;
|
||||||
|
|
||||||
// preload all village data, since we're retrieving some of those separately below
|
// preload all village data, since we're retrieving some of those separately below
|
||||||
$database->getVillage($village->wid);
|
$database->getVillage($village->wid);
|
||||||
|
|
||||||
$availableWood = $database->getWoodAvailable($village->wid);
|
$availableWood = $database->getWoodAvailable($village->wid);
|
||||||
$availableClay = $database->getClayAvailable($village->wid);
|
$availableClay = $database->getClayAvailable($village->wid);
|
||||||
$availableIron = $database->getIronAvailable($village->wid);
|
$availableIron = $database->getIronAvailable($village->wid);
|
||||||
$availableCrop = $database->getCropAvailable($village->wid);
|
$availableCrop = $database->getCropAvailable($village->wid);
|
||||||
|
|
||||||
if($session->access == BANNED)
|
if($session->access == BANNED)
|
||||||
{
|
{
|
||||||
header("Location: banned.php");
|
header("Location: banned.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif($availableWood >= $wood AND $availableClay >= $clay AND $availableIron >= $iron AND $availableCrop >= $crop)
|
elseif($availableWood >= $wood AND $availableClay >= $clay AND $availableIron >= $iron AND $availableCrop >= $crop)
|
||||||
{
|
{
|
||||||
$reqMerc = 1;
|
$reqMerc = 1;
|
||||||
|
|
||||||
if(($wood+$clay+$iron+$crop) > $this->maxcarry)
|
if(($wood+$clay+$iron+$crop) > $this->maxcarry)
|
||||||
{
|
|
||||||
$reqMerc = round(($wood+$clay+$iron+$crop)/$this->maxcarry);
|
|
||||||
|
|
||||||
if(($wood+$clay+$iron+$crop) > $this->maxcarry*$reqMerc)
|
|
||||||
{
|
|
||||||
$reqMerc += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($this->merchantAvail() != 0 && $reqMerc <= $this->merchantAvail())
|
|
||||||
{
|
{
|
||||||
if($database->modifyResource($village->wid,$wood,$clay,$iron,$crop,0))
|
$reqMerc = round(($wood+$clay+$iron+$crop)/$this->maxcarry);
|
||||||
{
|
|
||||||
$time = 0;
|
if(($wood+$clay+$iron+$crop) > $this->maxcarry*$reqMerc)
|
||||||
if(isset($_POST['d1']))
|
{
|
||||||
{
|
$reqMerc += 1;
|
||||||
$time = $_POST['d2'] * 3600;
|
}
|
||||||
}
|
}
|
||||||
$alliance = (isset($post['ally']) && $post['ally'] == 1)? $session->userinfo['alliance'] : 0;
|
if($this->merchantAvail() != 0 && $reqMerc <= $this->merchantAvail())
|
||||||
$database->addMarket($village->wid,$post['rid1'],$post['m1'],$post['rid2'],$post['m2'],$time,$alliance,$reqMerc,0);
|
{
|
||||||
}
|
if($database->modifyResource($village->wid,$wood,$clay,$iron,$crop,0))
|
||||||
// Enough merchants
|
{
|
||||||
|
$time = 0;
|
||||||
|
if(isset($_POST['d1']))
|
||||||
|
{
|
||||||
|
$time = $_POST['d2'] * 3600;
|
||||||
|
}
|
||||||
|
$alliance = (isset($post['ally']) && $post['ally'] == 1)? $session->userinfo['alliance'] : 0;
|
||||||
|
$database->addMarket($village->wid,$post['rid1'],$post['m1'],$post['rid2'],$post['m2'],$time,$alliance,$reqMerc,0);
|
||||||
|
}
|
||||||
|
// Enough merchants
|
||||||
header("Location: build.php?id=".$post['id']."&t=2");
|
header("Location: build.php?id=".$post['id']."&t=2");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Not enough merchants
|
// Not enough merchants
|
||||||
header("Location: build.php?id=".$post['id']."&t=2&e3");
|
header("Location: build.php?id=".$post['id']."&t=2&e3");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// not enough resources
|
// not enough resources
|
||||||
header("Location: build.php?id=".$post['id']."&t=2&e1");
|
header("Location: build.php?id=".$post['id']."&t=2&e1");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function acceptOffer($get)
|
private function acceptOffer($get)
|
||||||
{
|
{
|
||||||
global $database,$village,$session,$logging,$generator;
|
global $database,$village,$session,$logging,$generator;
|
||||||
|
|
||||||
$infoarray = $database->getMarketInfo($get['g']);
|
$infoarray = $database->getMarketInfo($get['g']);
|
||||||
$reqMerc = 1;
|
$reqMerc = 1;
|
||||||
if($infoarray['wamt'] > $this->maxcarry)
|
if($infoarray['wamt'] > $this->maxcarry)
|
||||||
{
|
{
|
||||||
$reqMerc = round($infoarray['wamt']/$this->maxcarry);
|
$reqMerc = round($infoarray['wamt']/$this->maxcarry);
|
||||||
if($infoarray['wamt'] > $this->maxcarry*$reqMerc)
|
if($infoarray['wamt'] > $this->maxcarry*$reqMerc)
|
||||||
{
|
{
|
||||||
$reqMerc += 1;
|
$reqMerc += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$myresource = $hisresource = array(1=>0,0,0,0);
|
$myresource = $hisresource = array(1=>0,0,0,0);
|
||||||
$myresource[$infoarray['wtype']] = $infoarray['wamt'];
|
$myresource[$infoarray['wtype']] = $infoarray['wamt'];
|
||||||
$mysendid = $database->sendResource($myresource[1],$myresource[2],$myresource[3],$myresource[4],$reqMerc,0);
|
$mysendid = $database->sendResource($myresource[1],$myresource[2],$myresource[3],$myresource[4],$reqMerc,0);
|
||||||
$hisresource[$infoarray['gtype']] = $infoarray['gamt'];
|
$hisresource[$infoarray['gtype']] = $infoarray['gamt'];
|
||||||
$hissendid = $database->sendResource($hisresource[1],$hisresource[2],$hisresource[3],$hisresource[4],$infoarray['merchant'],0);
|
$hissendid = $database->sendResource($hisresource[1],$hisresource[2],$hisresource[3],$hisresource[4],$infoarray['merchant'],0);
|
||||||
$hiscoor = $database->getCoor($infoarray['vref']);
|
$hiscoor = $database->getCoor($infoarray['vref']);
|
||||||
$mytime = $generator->procDistanceTime($hiscoor,$village->coor,$session->tribe,0);
|
$mytime = $generator->procDistanceTime($hiscoor,$village->coor,$session->tribe,0);
|
||||||
$targettribe = $database->getUserField($database->getVillageField($infoarray['vref'],"owner"),"tribe",0);
|
$targettribe = $database->getUserField($database->getVillageField($infoarray['vref'],"owner"),"tribe",0);
|
||||||
$histime = $generator->procDistanceTime($village->coor,$hiscoor,$targettribe,0);
|
$histime = $generator->procDistanceTime($village->coor,$hiscoor,$targettribe,0);
|
||||||
$timestamp = time();
|
$timestamp = time();
|
||||||
$database->addMovement(
|
$database->addMovement(
|
||||||
@@ -264,107 +264,107 @@ class Market
|
|||||||
[$timestamp, $timestamp],
|
[$timestamp, $timestamp],
|
||||||
[$mytime + $timestamp, $histime + $timestamp]
|
[$mytime + $timestamp, $histime + $timestamp]
|
||||||
);
|
);
|
||||||
$resource = array(1=>0,0,0,0);
|
$resource = array(1=>0,0,0,0);
|
||||||
$resource[$infoarray['wtype']] = $infoarray['wamt'];
|
$resource[$infoarray['wtype']] = $infoarray['wamt'];
|
||||||
$database->modifyResource($village->wid,$resource[1],$resource[2],$resource[3],$resource[4],0);
|
$database->modifyResource($village->wid,$resource[1],$resource[2],$resource[3],$resource[4],0);
|
||||||
$database->setMarketAcc($get['g']);
|
$database->setMarketAcc($get['g']);
|
||||||
$database->removeAcceptedOffer($get['g']);
|
$database->removeAcceptedOffer($get['g']);
|
||||||
$logging->addMarketLog($village->wid,2,array($infoarray['vref'],$get['g']));
|
$logging->addMarketLog($village->wid,2,array($infoarray['vref'],$get['g']));
|
||||||
header("Location: build.php?id=".$get['id']);
|
header("Location: build.php?id=".$get['id']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadOnsale()
|
private function loadOnsale()
|
||||||
{
|
{
|
||||||
global $database,$village,$session,$multisort,$generator;
|
global $database,$village,$session,$multisort,$generator;
|
||||||
|
|
||||||
$displayarray = $database->getMarket($village->wid,1);
|
$displayarray = $database->getMarket($village->wid,1);
|
||||||
$holderarray = array();
|
$holderarray = array();
|
||||||
foreach($displayarray as $value)
|
foreach($displayarray as $value)
|
||||||
{
|
{
|
||||||
$targetcoor = $database->getCoor($value['vref']);
|
$targetcoor = $database->getCoor($value['vref']);
|
||||||
$duration = $generator->procDistanceTime($targetcoor,$village->coor,$session->tribe,0);
|
$duration = $generator->procDistanceTime($targetcoor,$village->coor,$session->tribe,0);
|
||||||
if($duration <= $value['maxtime'] || $value['maxtime'] == 0)
|
if($duration <= $value['maxtime'] || $value['maxtime'] == 0)
|
||||||
{
|
{
|
||||||
$value['duration'] = $duration;
|
$value['duration'] = $duration;
|
||||||
array_push($holderarray,$value);
|
array_push($holderarray,$value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->onsale = $multisort->sorte($holderarray, "'duration'", true, 2);
|
$this->onsale = $multisort->sorte($holderarray, "'duration'", true, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function filterNeed($get)
|
private function filterNeed($get)
|
||||||
{
|
{
|
||||||
if(isset($get['v']) || isset($get['s']) || isset($get['b']))
|
if(isset($get['v']) || isset($get['s']) || isset($get['b']))
|
||||||
{
|
{
|
||||||
$holder = $holder2 = array();
|
$holder = $holder2 = array();
|
||||||
if(isset($get['v']) && $get['v'] == "1:1")
|
if(isset($get['v']) && $get['v'] == "1:1")
|
||||||
{
|
{
|
||||||
foreach($this->onsale as $equal)
|
foreach($this->onsale as $equal)
|
||||||
{
|
{
|
||||||
if($equal['wamt'] <= $equal['gamt'])
|
if($equal['wamt'] <= $equal['gamt'])
|
||||||
{
|
{
|
||||||
array_push($holder,$equal);
|
array_push($holder,$equal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$holder = $this->onsale;
|
$holder = $this->onsale;
|
||||||
}
|
}
|
||||||
foreach($holder as $sale)
|
foreach($holder as $sale)
|
||||||
{
|
{
|
||||||
if(isset($get['s']) && isset($get['b']))
|
if(isset($get['s']) && isset($get['b']))
|
||||||
{
|
{
|
||||||
if($sale['gtype'] == $get['s'] && $sale['wtype'] == $get['b'])
|
if($sale['gtype'] == $get['s'] && $sale['wtype'] == $get['b'])
|
||||||
{
|
{
|
||||||
array_push($holder2,$sale);
|
array_push($holder2,$sale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(isset($get['s']) && !isset($get['b']))
|
else if(isset($get['s']) && !isset($get['b']))
|
||||||
{
|
{
|
||||||
if($sale['gtype'] == $get['s'])
|
if($sale['gtype'] == $get['s'])
|
||||||
{
|
{
|
||||||
array_push($holder2,$sale);
|
array_push($holder2,$sale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(isset($get['b']) && !isset($get['s']))
|
else if(isset($get['b']) && !isset($get['s']))
|
||||||
{
|
{
|
||||||
if($sale['wtype'] == $get['b'])
|
if($sale['wtype'] == $get['b'])
|
||||||
{
|
{
|
||||||
array_push($holder2,$sale);
|
array_push($holder2,$sale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$holder2 = $holder;
|
$holder2 = $holder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->onsale = $holder2;
|
$this->onsale = $holder2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->loadOnsale();
|
$this->loadOnsale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function tradeResource($post)
|
private function tradeResource($post)
|
||||||
{
|
{
|
||||||
global $session,$database,$village;
|
global $session,$database,$village;
|
||||||
|
|
||||||
$wwvillage = $database->getResourceLevel($village->wid);
|
$wwvillage = $database->getResourceLevel($village->wid);
|
||||||
if($wwvillage['f99t']!=40)
|
if($wwvillage['f99t']!=40)
|
||||||
{
|
{
|
||||||
if($session->userinfo['gold'] >= 3)
|
if($session->userinfo['gold'] >= 3)
|
||||||
{
|
{
|
||||||
//kijken of ze niet meer gs invoeren dan ze hebben
|
//kijken of ze niet meer gs invoeren dan ze hebben
|
||||||
if($session->access == BANNED)
|
if($session->access == BANNED)
|
||||||
{
|
{
|
||||||
header("Location: banned.php");
|
header("Location: banned.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else if (($post['m2'][0]+$post['m2'][1]+$post['m2'][2]+$post['m2'][3])<=(round($village->awood)+round($village->aclay)+round($village->airon)+round($village->acrop)))
|
else if (($post['m2'][0]+$post['m2'][1]+$post['m2'][2]+$post['m2'][3])<=(round($village->awood)+round($village->aclay)+round($village->airon)+round($village->acrop)))
|
||||||
{
|
{
|
||||||
$database->setVillageField(
|
$database->setVillageField(
|
||||||
$village->wid,
|
$village->wid,
|
||||||
["wood", "clay", "iron", "crop"],
|
["wood", "clay", "iron", "crop"],
|
||||||
@@ -373,21 +373,21 @@ class Market
|
|||||||
$database->modifyGold($session->uid,3,0);
|
$database->modifyGold($session->uid,3,0);
|
||||||
header("Location: build.php?id=".$post['id']."&t=3&c");;
|
header("Location: build.php?id=".$post['id']."&t=3&c");;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
header("Location: build.php?id=".$post['id']."&t=3");
|
header("Location: build.php?id=".$post['id']."&t=3");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
header("Location: build.php?id=".$post['id']."&t=3");
|
header("Location: build.php?id=".$post['id']."&t=3");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$market = new Market;
|
$market = new Market;
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user