Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Travian P-Alpha 2.03 (All bases support)

Status
Not open for further replies.
akakori
Joined
Apr 3, 2008
Messages
368
Reaction score
98
ares... lol.. for now yes u can do that.. wait till u see the sql dump for wdata with full oasis + full range of different bases + full range of the different image.. =)
 
Banned
Banned
Joined
Sep 1, 2006
Messages
477
Reaction score
15
That poop will take a year to import the one right now took like 10 or 20mins to import parts at a time

Anyways i think some of your code is wrong for res and how much buildings cost
Most buildings you cant build as roman (i know you still doing the coding just saying :p)
The res doesn't update on the page you have to reload it to see it
One of the builds didn't have a building image for lvl 1 not sure what one it was think it was rally point

And most if not all timers don't work right they jump to new/diff times on some reloads/going to new pages and when you build something if there's 2 things at once i think they go to the closest number 1.10/1.20/1.30 etc
 
akakori
Joined
Apr 3, 2008
Messages
368
Reaction score
98
dont really understand at all one bit.. can u give a more concrete thing on which part? like res gathering.. res display.. res calculation.. ?

Building time.. which buidata is wrong? i got it from help.travian
 
Initiate Mage
Joined
Jan 2, 2010
Messages
26
Reaction score
2
Tip: if you are using PHPmyAdmin pack the larger SQL file in a zip file or tgz if you like that. Import it into the db after you have selected the right DB and until it says "success" reupload the same file because phpmyadmin can handle that and asks you to reupload until it is done (since there is a certain time php allows for script execution).

Got the file in on 4 reuploads!
 
Initiate Mage
Joined
Dec 9, 2009
Messages
6
Reaction score
0
can someone host it over mediafire or filefront, i am unable to use rapidshare because they dislike me
 
akakori
Joined
Apr 3, 2008
Messages
368
Reaction score
98
lol.. rejoice everyone.. i finished the install.php.. its still a very rough install.php but it would work.. it will add in the entire database structure + the world data.. if anyone needs it badly let me know i will release it.. else i will work on the nice version of it.. lol
 
Initiate Mage
Joined
Jul 28, 2009
Messages
1
Reaction score
0
Fatal error: Call to undefined method mysqli_result::fetch_all() in C:\xampp\htdocs\travian\s1\include\functions.php on line 63

what's wrong in line 63?

looked all over the topic to know about this problem and all alternatives that have not yet put resouvero the problem on line 63

who can help me?
 
Last edited:
Initiate Mage
Joined
Nov 3, 2009
Messages
38
Reaction score
0
Use this programs this good " WampServer "
 
akakori
Joined
Apr 3, 2008
Messages
368
Reaction score
98
oh yea.. btw.. i released a new installtion system.. just place the entire folder into ur s1.. run it.. and viola..
 
Initiate Mage
Joined
May 5, 2009
Messages
9
Reaction score
0
is complete server? or just a part? how much he is done? 30-40%?
 
Initiate Mage
Joined
Jan 2, 2010
Messages
26
Reaction score
2
There are alot of building data left and the msg system is not there yet. But it looks promising. Allthough a tip is to NOT ask about installation and such. As of now it is only tested on the latest WAMP and won't work (as far as I know) with anything else (if you follow the versions on wamp it might though).
 
akakori
Joined
Apr 3, 2008
Messages
368
Reaction score
98
lol.. anyway... =D i finish partial message system.. =d

---------- Post added at 06:24 PM ---------- Previous post was at 05:27 PM ----------

anyway.. i took some time off to rewrite support for those who want to run them at a webhost but doesnt have php 5.3.x =)

Release a new version v3.2 with a fixed installation script. Partial message system included.
You can choose whether to use mysqli or mysql..

Just change it in the constant.php =)
 
Initiate Mage
Joined
Jul 25, 2008
Messages
23
Reaction score
0
there is no constants file in s1 include??

---------- Post added at 11:01 AM ---------- Previous post was at 10:58 AM ----------

im sorry u need to use install

---------- Post added at 11:09 AM ---------- Previous post was at 11:01 AM ----------

now i cant login

it doesnt activate
 
akakori
Joined
Apr 3, 2008
Messages
368
Reaction score
98
sorry... i found the mistake.. lol.. here's the fix..

replace functions with this
Code:
<?php
class Functions {
	
	function check_email_address($email) {
	  $regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
	  if ( !preg_match($regexp, $email) ) {
		   return false;
	  }
	  return true;
	}
   
   function getActivate($name,$pw,$start) {
	   return substr(md5($name.$pw), $start, ($start+10));
   }
   
   function getTimeFormat($time) {
	   if ($time%10 < 5) {
			$time = $time-($time%10);
		}
		else {
			$time = $time + (10 - $time%10);
		}
	   $min = 0;
	   $hr = 0;
	   while($time >= 60) :
		   $time -= 60;
		   $min += 1;
	   endwhile;
	   while ($min > 60) :
		   $min -= 60;
		   $hr += 1;
	   endwhile;
	   if ($min < 10) {
		   $min = "0".$min;
	   }
	   if($time < 10) {
		   $time = "0".$time;
	   }
		return $hr.":".$min.":".$time;
   }
   
   	function generateBase($sector) {
		global $database;
		switch($sector) {
			case 0:
			$q = "Select * from ".TB_PREFIX."WDATA where fieldtype = 3 and occupied = 0 LIMIT 200";
			break;
			case 1:
			$q = "Select * from ".TB_PREFIX."WDATA where fieldtype = 3 and x < 0 and y > 0 and occupied = 0 LIMIT 200";
			break;
			case 2:
			$q = "Select * from ".TB_PREFIX."WDATA where fieldtype = 3 and x > 0 and y > 0 and occupied = 0 LIMIT 200";
			break;
			case 3:
			$q = "Select * from ".TB_PREFIX."WDATA where fieldtype = 3 and x < 0 and y < 0 and occupied = 0 LIMIT 200";
			break;
			case 4:
			$q = "Select * from ".TB_PREFIX."WDATA where fieldtype = 3 and x > 0 and y < 0 and occupied = 0 LIMIT 200";
			break;
		}
		if(CONNECT_TYPE) {
		$result = $database->query($q);
		$num_rows = mysqli_num_rows($result);
		$row = $result->fetch_all(MYSQLI_ASSOC);
		$base = rand(0, ($num_rows-1));
		return $row[$base]['id'];
		}
		else {
			$result = $database->query($q);
			$num_rows = mysql_num_rows($result);
			$result = $database->mysql_fetch_all($result);
			$base = rand(0, ($num_rows-1));
			return $result[$base]['id'];
		}
	}
	
	function processLogin($user,$pw) {
		global $database,$session;
		if(file_exists("Install/install.php")) {
			header("Location: login.php?e=1");
		}
		else {
		if($user == "") {
			$_SESSION['ferror'] = 5;
		}
		else if($pw == "") {
			$_SESSION['tempu'] = $user;
			$_SESSION['ferror'] = 4;
		}
	else {
		if($session->login($user, $pw)) {
			$this->updateResLevel($session->baseinfo['wref']);
			$this->getUpgrading($session->baseinfo['wref']);
			header("Location: dorf1.php");
		}
		else {
			if($database->checkExist($user)){
				$_SESSION['tempu'] = $user;
				$_SESSION['ferror'] = 3;
			}
			else {
				$_SESSION['ferror'] = 2;
				$_SESSION['tempu'] = $user;
				$_SESSION['tempp'] = $pw;
				}
			}
		}
		header("Location: login.php");
		}
	}
	
	function getUpgrading($vid) {
		global $database, $session;
		$database->getRunningResource($vid,0);
			if(isset($_SESSION['runres'])) {
				$type = ($_SESSION['runres'] >= 19)? $_SESSION['runtype'] : $this->procResType($_SESSION['runres'],$session->basetype,0);
				$this->getUstats($type,$_SESSION['runres'],1);
				$like = '%f'.$_SESSION['runres'].'%level '.($session->resarray['f'.$_SESSION['runres']]+1).'%';
				$_SESSION['logid'] = $database->getRlog($vid,$like);
			}
			if(isset($_SESSION['runres2'])) {
				$type2 = ($_SESSION['runres2'] >= 19)? $_SESSION['runtype2'] : $this->procResType($_SESSION['runres2'],$session->basetype,0);
				$this->getUstats($type2,$_SESSION['runres2'],2);
				$like2 = '%f'.$_SESSION['runres2'].'%level '.($session->resarray[$_SESSION['runres2']]+1).'%';
				$_SESSION['logid'] = $database->getRlog($vid,$like2);
			}
	}
	
	function getResLevel($vid) {
		global $database, $session;
		$levelarray = $database->getResourceLevel($vid);
		for ($i=1;$i<=18;$i++) {
				$oreslevel[$i] = $levelarray['f'.$i];
			}
		return $oreslevel;
	}
	
	function getProduction($type,$resarray) { 
		global $session;
		include("resdata.php");
		switch($type) {
			case 1:
			$wood = $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f5']]['prod'] + $Cropland[$resarray['f4']]['prod'] + $Cropland[$resarray['f1']]['prod'] + $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 2:
			$wood = $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f5']]['prod'] + $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f1']]['prod'] + $Ironmine[$resarray['f4']]['prod'] + $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 3:
			$wood = $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f5']]['prod'] + $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f4']]['prod'] + $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 4:
			$wood = $Woodcutter[$resarray['f1']]['prod'] + $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f4']]['prod'] + $Claypit[$resarray['f5']]['prod'] + $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 5:
			$wood = $Woodcutter[$resarray['f1']]['prod'] + $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f5']]['prod'] +  $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f4']]['prod'] + $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 6:
			$wood = $Woodcutter[$resarray['f3']]['prod'];
			$clay = $Claypit[$resarray['f16']]['prod'];
			$crop = $Cropland[$resarray['f5']]['prod'] + $Cropland[$resarray['f6']]['prod'] + $Cropland[$resarray['f3']]['prod'] + $Cropland[$resarray['f14']]['prod'] + $Cropland[$resarray['f17']]['prod'] + $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'] + $Cropland[$resarray['f18']]['prod'] + $Cropland[$resarray['f7']]['prod'] + $Cropland[$resarray['f10']]['prod'] + $Cropland[$resarray['f11']]['prod'];
			$iron = $Ironmine[$resarray['f4']]['prod'];
			break;
			case 7:
			$wood = $Woodcutter[$resarray['f4']]['prod'] + $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f5']]['prod'] + $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f3']]['prod'] + $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 8:
			$wood = $Woodcutter[$resarray['f4']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f5']]['prod'] + $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f3']]['prod'] + $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f1']]['prod'] + $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 9:
			$wood = $Woodcutter[$resarray['f5']]['prod'] + $Woodcutter[$resarray['f4']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f3']]['prod'] + $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f1']]['prod'] + $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 10:
			$wood = $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f4']]['prod'] + $Claypit[$resarray['f5']]['prod'] + $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f1']]['prod'] + $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
			case 11:
			$wood = $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f2']]['prod'] + $Woodcutter[$resarray['f5']]['prod'] + $Woodcutter[$resarray['f13']]['prod'];
			$clay = $Claypit[$resarray['f10']]['prod'] + $Claypit[$resarray['f11']]['prod'] + $Claypit[$resarray['f16']]['prod'];
			$crop = $Cropland[$resarray['f6']]['prod'] + $Cropland[$resarray['f7']]['prod'] + $Cropland[$resarray['f14']]['prod'] + $Cropland[$resarray['f15']]['prod'] + $Cropland[$resarray['f17']]['prod'] + $Cropland[$resarray['f18']]['prod'];
			$iron = $Ironmine[$resarray['f1']]['prod'] + $Ironmine[$resarray['f4']]['prod'] + $Ironmine[$resarray['f8']]['prod'] + $Ironmine[$resarray['f9']]['prod'] + $Ironmine[$resarray['f12']]['prod'];
			break;
			case 12:
			$wood = $Woodcutter[$resarray['f4']]['prod'] + $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f3']]['prod'] + $Woodcutter[$resarray['f14']]['prod'] + $Woodcutter[$resarray['f17']]['prod'];
			$clay = $Claypit[$resarray['f5']]['prod'] + $Claypit[$resarray['f6']]['prod'] + $Claypit[$resarray['f16']]['prod'] + $Claypit[$resarray['f18']]['prod'];
			$crop = $Cropland[$resarray['f2']]['prod'] + $Cropland[$resarray['f8']]['prod'] + $Cropland[$resarray['f9']]['prod'] + $Cropland[$resarray['f12']]['prod'] + $Cropland[$resarray['f13']]['prod'] + $Cropland[$resarray['f15']]['prod'];
			$iron = $Ironmine[$resarray['f7']]['prod'] + $Ironmine[$resarray['f10']]['prod'] + $Ironmine[$resarray['f11']]['prod'];
			break;
		}
		$_SESSION['prod'] = array('wood' => $wood, 'clay'=> $clay, 'crop'=> $crop, 'iron'=> $iron);
		return $_SESSION['prod'];
	}	
	
	function procResType($field,$vtype,$switch) {
		global $session;
		      switch($field) {
			   case 1:
			   switch($vtype) {
				   case 1:
				   case 6:
				   return "Cropland";
				   break;
				   case 2:
				   case 8:
				   case 9:
				   case 10:
				   case 11:
                   return "Iron Mine";
				   break;
				   case 3:
				   case 4:
				   case 5:
				   case 7:
				   case 12:
				    return "Woodcutter";
				   break;
			   }
			   break;
			   case 2:
			   case 13:
			   return ($vtype == 11)? "Woodcutter" : "Cropland";
			   break;
			   case 3:
				  return "Woodcutter";
			   break;
			   case 4:
			   switch($vtype) {
				   case 1:
                   return "Cropland";
				   break;
				   case 2:
				   case 3:
				   case 5:
				   case 6:
				   case 11:
				    return "Iron Mine";
				   break;
				   case 4:
				   case 10:
                   return "Clay Pit";
				   break;
				   case 7:
				   case 8:
				   case 9:
				   case 12:
				   return "Woodcutter";
				   break;
			   }
			   break;
			   case 5:
			   switch($vtype) {
				   case 1:
				   case 6:
                   return "Cropland";
				   break;
				   case 2:
				   case 3:
				   case 4:
				   case 7:
				   case 8:
				   case 10:
				   case 12:
				    return "Clay Pit";
				   break;
				   case 5:
				   case 9:
				   case 11:
				   return "Woodcutter";
				   break;
			   }
			   break;
			   case 6:
			   case 18:
			   return ($vtype == 11 || $vtype == 6)? "Cropland" : "Clay Pit";
			   break;
			   case 7:
			   return ($vtype == 11 || $vtype == 6)? "Cropland" : "Iron Mine";
			   break;
			   case 8:
			   case 9:
			   case 12:
			   return ($vtype == 11)? "Iron Mine" : "Cropland";
			   break;
			   case 10:
			   case 11:
			   switch($vtype) {
				   case 6:
				   return "Cropland";
				   break;
				   case 11:
				   return "Clay Pit";
				   break;
				   default:
				   return "Iron Mine";
				   break;
			   }
			   break;
			   case 14:
			   case 17:
			   return ($vtype == 11 || $vtype == 6)? "Cropland" : "Woodcutter";
			   break;
			   case 15:
			   return "Cropland";
			   break;
			   case 16:
			   return "Clay Pit";
			   break;
               default:
			   switch($switch) {
				   case 1:
				   $buildingtype = isset($_SESSION['runtype']) ? $_SESSION['runtype'] : $session->resarray['f'.$field.'t'];
				   break;
				   case 2:
				   $buildingtype = isset($_SESSION['runtype2']) ? $_SESSION['runtype2'] : $session->resarray['f'.$field.'t'];
				   break;
				   default:
				   $buildingtype = $session->resarray['f'.$field.'t'];
				   break;
			   }
               switch($buildingtype) {
				  case 10:
				   return "Warehouse";
				   break;
				case 11:
				return "Granary";
				break;
               case 15:
               		return "Main Building";
                break;
			   case 18:
			   		return "Embassy";
				break;
               case 23:
              	    return "Cranny";
               break;
			   case 31:
			   return "City Wall";
			   break;
			   case 33:
               		return "Rally Point";
               break;
               }
               break;
		   }
	}
	
	function gainResource($prod,$baseinfo) {
		global $database;
		$timepast = time() - $baseinfo['lastupdate'];
		$awood = ($prod['wood'] / (3600/SPEED)) * $timepast;
		$aclay = ($prod['clay'] / (3600/SPEED)) * $timepast;
		$airon = ($prod['iron'] / (3600/SPEED)) * $timepast;
		$acrop = ($prod['crop'] / (3600/SPEED)) * $timepast;
		return $database->addResource($baseinfo['wref'],$awood,$aclay,$airon,$acrop);
	}
	
	function Upkeep($baseinfo) {
		global $database;
		$timepast = time() - $baseinfo['lastupdate'];
		$upkeep = ($baseinfo['pop'] / (3600/SPEED)) * $timepast;
		return $database->villageUpkeep($baseinfo['wref'],$upkeep);
	}
	
	function pruneResource($baseinfo) {
		global $session, $database;
		if($baseinfo['wood'] > $baseinfo['maxstore']) {
			$database->pruneResource($baseinfo['wref'],"wood");
		}
		if($baseinfo['clay'] > $baseinfo['maxstore']) {
			$database->pruneResource($baseinfo['wref'],"clay");
		}
		if($baseinfo['iron'] > $baseinfo['maxstore']) {
			$database->pruneResource($baseinfo['wref'],"iron");
		}
		if($baseinfo['crop'] > $baseinfo['maxcrop']) {
			$database->pruneCrop($baseinfo['wref']);
		}
	}
	
	function startUpgrading($field,$switch) {
		global $database,$session;
		$type = ($field >= 19)? $session->resarray['f'.$field.'t'] : $this->procResType($field,$session->basetype,0);
		$uprequire = $this->getUstats($type,$field,$switch);
		$this->getUstats($type,$field,0);
		switch($switch) {
			case 1:
			$ustats = $_SESSION['ustats'];
			break;
			case 2:
			$ustats = $_SESSION['ustats2'];
			break;
		}
		$database->startResourceUpgrade($session->baseinfo['wref'], $field, $ustats['time'],0);
		$database->removeResource($session->baseinfo['wref'],$ustats['wood'],$ustats['clay'],$ustats['iron'],$ustats['crop']);
		$comment = "Started upgrade of f".$field." to level ";
		$comment .= $session->resarray['f'.$field]+1;
		if ($field >= 19) {
		$comment .= " type ".$session->resarray['f'.$field.'t'];
		}
		$database->addRlog($session->baseinfo['wref'], $comment);
		$session->refreshVillage($session->baseinfo['wref'],$session->uid);
		$session->checker = $session->getChecker();
	}
	
	function startNewBuilding($field,$type,$switch) {
		global $database,$session;
		if($type == 16) {
			$field = 39;
		}
		else if($type == 31) {
			$field = 40;
		}
			$this->getUstats($type,$field,0);
		switch($switch) {
			case 1:
			$ustats = $_SESSION['ustats'];
			$_SESSION['runtype'] = $type;
			break;
			case 2:
			$ustats = $_SESSION['ustats2'];
			$_SESSION['runtype2'] = $type;
			break;
		}
		$database->startResourceUpgrade($session->baseinfo['wref'], $field, $ustats['time'],$type);
		$database->removeResource($session->baseinfo['wref'],$ustats['wood'],$ustats['clay'],$ustats['iron'],$ustats['crop']);
		$comment = "Started building of f".$field." to level ";
		$comment .= $session->resarray['f'.$field]+1;
		$comment .= " type ".$type;
		$database->addRlog($session->baseinfo['wref'], $comment);
		$session->refreshVillage($session->baseinfo['wref'],$session->uid);
		$session->checker = $session->getChecker();
	}
	
	function finishBuilding() {
		global $database,$session;
		if($database->getRunningResource($session->baseinfo['wref'],1) <= 0) {
			$database->updateResourceFields($_SESSION['runres'], $session->baseinfo['wref'],1);
			if(isset($_SESSION['runtype'])) {
				$database->updateType($session->baseinfo['wref'], $_SESSION['runres'], $_SESSION['runtype']);
			}
			if($_SESSION['runres'] >= 19) {
				$attritype = isset($_SESSION['runtype'])? $_SESSION['runtype'] : $session->resarray['f'.$_SESSION['runres'].'t'];
				switch($attritype) {
					case 10:
					$database->putVillageStats("maxstore",$_SESSION['ustats']['attri'],$session->baseinfo['wref']);
					break;
					case 11:
					$database->putVillageStats("maxcrop",$_SESSION['ustats']['attri'],$session->baseinfo['wref']);
					break;
				}
			}
			unset($_SESSION['runres']);
			unset($_SESSION['runtype']);
			$session->resarray = $_SESSION['resarray'] = $database->getResourceLevel($session->baseinfo['wref']);
			$session->prod = $this->getProduction($session->basetype, $session->resarray);
			$database->addPop($session->baseinfo['wref'],$_SESSION['ustats']['pop']);
			$database->addUserCP($session->uid, $_SESSION['ustats']['cp']);
			$database->addBaseCP($session->baseinfo['wref'], $_SESSION['ustats']['cp']);
			unset($_SESSION['ustats']);
			$session->refreshVillage($session->baseinfo['wref'],$session->uid);
			if(isset($_SESSION['runres2'])) {
			$_SESSION['runres'] = $_SESSION['runres2'];
			$_SESSION['ustats'] = $_SESSION['ustats2'];
			$_SESSION['logid'] = $_SESSION['logid2'];
			if(isset($_SESSION['runtype2'])) {
			$_SESSION['runtype'] = $_SESSION['runtype2'];
			}
			$database->shiftUpgrading($session->baseinfo['wref']);
			unset($_SESSION['runres2']);
			unset($_SESSION['ustats2']);
			unset($_SESSION['logid2']);
			unset($_SESSION['runtype2']);
			}
		}
		if($database->getRunningResource($session->baseinfo['wref'],2) <= 0 && isset($_SESSION['runres2'])) {
			$database->updateResourceFields($_SESSION['runres2'], $session->baseinfo['wref'],2);
			if(isset($_SESSION['runtype2'])) {
				$database->updateType($session->baseinfo['wref'], $_SESSION['runres2'], $_SESSION['runtype2']);
			}
			if($_SESSION['runres2'] >= 19) {
				$attritype = isset($_SESSION['runtype2'])? $_SESSION['runtype2'] : $session->resarray['f'.$_SESSION['runres2'].'t'];
				switch($attritype) {
					case 10:
					$database->putVillageStats("maxstore",$_SESSION['ustats2']['attri'],$session->baseinfo['wref']);
					break;
					case 11:
					$database->putVillageStats("maxcrop",$_SESSION['ustats2']['attri'],$session->baseinfo['wref']);
					break;
				}
			}
			unset($_SESSION['runres2']);
			unset($_SESSION['runtype2']);
			$session->resarray = $_SESSION['resarray'] = $database->getResourceLevel($session->baseinfo['wref']);
			$session->prod = $this->getProduction($session->basetype, $session->resarray);
			$database->addPop($session->baseinfo['wref'],$_SESSION['ustats2']['pop']);
			$database->addUserCP($session->uid, $_SESSION['ustats2']['cp']);
			$database->addBaseCP($session->baseinfo['wref'], $_SESSION['ustats2']['cp']);
			unset($_SESSION['ustats2']);
			$session->refreshVillage($session->baseinfo['wref'],$session->uid);
		}
	}
	
	function cancelBuilding($logid) {
		global $database,$session;
		if($logid == $_SESSION['logid']) {
		unset($_SESSION['runres']);
		$database->cancelResourceUpgrade($session->baseinfo['wref'],1);
		$database->addResource($session->baseinfo['wref'],$_SESSION['ustats']['wood'],$_SESSION['ustats']['clay'],$_SESSION['ustats']['iron'],$_SESSION['ustats']['crop']);
		unset($_SESSION['ustats']);
		unset($_SESSION['logid']);
		unset($_SESSION['runtype']);
		if(isset($_SESSION['runres2'])) {
			$_SESSION['runres'] = $_SESSION['runres2'];
			$_SESSION['ustats'] = $_SESSION['ustats2'];
			$_SESSION['logid'] = $_SESSION['logid2'];
			if(isset($_SESSION['runtype2'])) {
			$_SESSION['runtype'] = $_SESSION['runtype2'];
			}
			$database->shiftUpgrading($session->baseinfo['wref']);
			unset($_SESSION['runres2']);
			unset($_SESSION['ustats2']);
			unset($_SESSION['logid2']);
			unset($_SESSION['runtype2']);
		}
		}
		else if ($logid == $_SESSION['logid2']) {
			unset($_SESSION['runres2']);
			$database->cancelResourceUpgrade($session->baseinfo['wref'],2);
			$database->addResource($session->baseinfo['wref'],$_SESSION['ustats2']['wood'],$_SESSION['ustats2']['clay'],$_SESSION['ustats2']['iron'],$_SESSION['ustats2']['crop']);
			unset($_SESSION['ustats2']);
			unset($_SESSION['logid2']);
			unset($_SESSION['runtype2']);
		}
		$database->removeRlog($logid);
		$session->refreshVillage($session->baseinfo['wref'],$session->uid);
		$session->checker = $session->getChecker();
	}
	
	function getUstats($type,$id,$switch) {
		global $session;
		include("resdata.php");
		include("buidata.php");
		$building = 1;
		$main = 0;
		switch($type) {
			case "Woodcutter":
			$dataarray = $Woodcutter;
			$building = 0;
			break;
			case "Cropland":
			$dataarray = $Cropland;
			$building = 0;
			break;
			case "Clay Pit":
			$dataarray = $Claypit;
			$building = 0;
			break;
			case "Iron Mine":
			$dataarray = $Ironmine;
			$building = 0;
			break;
			case 10:
			$dataarray = $Warehouse;
			break;
			case 11:
			$dataarray = $Granary;
			break;
			case 15:
			$dataarray = $Mainbuilding;
			$main = 1;
			break;
			case 18:
			$dataarray = $Embassy;
			break;
			case 23:
			$dataarray = $Cranny;
			break;
			case 31:
			$dataarray = $Citywall;
			break;
			case 33:
			$dataarray = $Rallypoint;
			break;
		}
			$wood = $dataarray[$session->resarray['f'.$id]+1]['wood'];
			$clay = $dataarray[$session->resarray['f'.$id]+1]['clay'];
			$crop = $dataarray[$session->resarray['f'.$id]+1]['crop'];
			if ($main == 1) {
				$time = round($dataarray[$session->resarray['f'.$id]+1]['time'] / SPEED);
			}
			else {
				$time = round(round($dataarray[$session->resarray['f'.$id]+1]['time'] * $Mainbuilding[$session->resarray['f26']]['attri'] / 100) / SPEED);
			}
			$iron = $dataarray[$session->resarray['f'.$id]+1]['iron'];
			$pop = $dataarray[$session->resarray['f'.$id]+1]['pop'];
			$cp = $dataarray[$session->resarray['f'.$id]+1]['cp'];
		if($building == 1) {
			$attri = $dataarray[$session->resarray['f'.$id]+1]['attri'];
		}
		else {
			$attri = 0;
		}
		switch($switch) {
			case 1:
			$time += time();
			$_SESSION['ustats'] = array('time'=>$time,'wood'=>$wood,'clay'=>$clay,'iron'=>$iron,'crop'=>$crop,'pop'=>$pop,'cp'=>$cp,'attri'=>$attri);
			break;
			case 2:
			$time += time();
			$_SESSION['ustats2'] = array('time'=>$time,'wood'=>$wood,'clay'=>$clay,'iron'=>$iron,'crop'=>$crop,'pop'=>$pop,'cp'=>$cp,'attri'=>$attri);
			break;
			case 3:
			return array('time'=>$time,'wood'=>$wood,'clay'=>$clay,'iron'=>$iron,'crop'=>$crop,'pop'=>$pop,'cp'=>$cp,'attri'=>$attri);
			break;
			default:
		if(!isset($_SESSION['ustats'])) {
			$time += time();
			$_SESSION['ustats'] = array('time'=>$time,'wood'=>$wood,'clay'=>$clay,'iron'=>$iron,'crop'=>$crop,'pop'=>$pop,'cp' =>$cp,'attri'=>$attri);
		}
		else {
			$time += time();
			$_SESSION['ustats2'] = array('time'=>$time,'wood'=>$wood,'clay'=>$clay,'iron'=>$iron,'crop'=>$crop,'pop'=>$pop,'cp' =>$cp,'attri'=>$attri);
		}
		break;
		}
	}
	
	function getTypeLevel($tid) {
		global $session;
		$key = array_search($tid, $session->resarray);
		$number = preg_replace("/[^0-9]/", '', $key);
		if($number >= 19) {
			return $session->resarray['f'.$number];
		}
		else {
			return false;
		}
	}
	
	function getMapCheck($wref) {
		return substr(md5($wref),5,2);
	}
	
	function getBaseID($x,$y) {
	return	((WORLD_MAX-$y) * (WORLD_MAX*2+1)) + (WORLD_MAX +$x + 1);
	}
	
	function procMtime($time) {
		if ((time()-$time) < 24*60*60) {
			$day = "today";
		}
		else {
			$day = date("j.m.y",$time);
		}
		$time = date("H:i",$time);
		return array($day,$time);
	}
	
	function pageLoadTimeStart() {
		$starttime = microtime();
		$startarray = explode(" ", $starttime);
		$starttime = $startarray[1] + $startarray[0];
		return $starttime;
	}
	
	function pageLoadTimeEnd() {
		$endtime = microtime();
		$endarray = explode(" ", $endtime);
		$endtime = $endarray[1] + $endarray[0];
		return $endtime;
	}
	
};
$functions = new Functions;
?>

This is for people who downloaded 3.2..

I am uploading 3.2.1 with the functions fixed.. =d
 
Last edited:
akakori
Joined
Apr 3, 2008
Messages
368
Reaction score
98
buildings.. buildings.. more buildings.. den its units and war system.. after that.. would be the wonder of the world system... den well.. i suppose i am done? =d
 
Status
Not open for further replies.
Back
Top