mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-25 14:06:12 +00:00
fix some training and hero bugs + fix GameEngine/Admin/database.php (now should to work fine)
This commit is contained in:
@@ -16,19 +16,22 @@
|
||||
## Source code: http://www.github.com/ZZJHONS/ZravianX ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
if($gameinstall == 1){
|
||||
include("../../GameEngine/config.php");
|
||||
include("../../GameEngine/Data/buidata.php");
|
||||
|
||||
}else{
|
||||
include("../GameEngine/config.php");
|
||||
include("../GameEngine/Data/buidata.php");
|
||||
}
|
||||
class adm_DB {
|
||||
var $connection;
|
||||
|
||||
|
||||
function adm_DB(){
|
||||
global $database;
|
||||
$this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error());
|
||||
mysql_select_db(SQL_DB, $this->connection) or die(mysql_error());
|
||||
}
|
||||
|
||||
|
||||
function Login($username,$password){
|
||||
$q = "SELECT password FROM ".TB_PREFIX."users where username = '$username' and access >= ".MULTIHUNTER;
|
||||
$result = mysql_query($q, $this->connection);
|
||||
@@ -42,7 +45,7 @@ class adm_DB {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function recountPopUser($uid){
|
||||
global $database;
|
||||
$villages = $database->getProfileVillages($uid);
|
||||
@@ -51,7 +54,7 @@ class adm_DB {
|
||||
$this->recountPop($vid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function recountPop($vid){
|
||||
global $database;
|
||||
$fdata = $database->getResourceLevel($vid);
|
||||
@@ -77,14 +80,14 @@ class adm_DB {
|
||||
}
|
||||
return $popT;
|
||||
}
|
||||
|
||||
|
||||
function getWref($x,$y) {
|
||||
$q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$r = mysql_fetch_array($result);
|
||||
return $r['id'];
|
||||
}
|
||||
|
||||
|
||||
function AddVillage($post){
|
||||
global $database;
|
||||
$wid = $this->getWref($post['x'],$post['y']);
|
||||
@@ -101,7 +104,7 @@ class adm_DB {
|
||||
$database->addABTech($wid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Punish($post){
|
||||
global $database;
|
||||
$villages = $database->getProfileVillages($post['uid']);
|
||||
@@ -115,7 +118,7 @@ class adm_DB {
|
||||
$pop = floor(($popOld/100)*($proc));
|
||||
if($pop <= 1 ){$pop = 2;}
|
||||
$this->PunishBuilding($vid,$proc,$pop);
|
||||
|
||||
|
||||
}
|
||||
if($post['del_troop']){
|
||||
if($user['tribe'] == 1) {
|
||||
@@ -161,7 +164,7 @@ class adm_DB {
|
||||
$q = "UPDATE ".TB_PREFIX."units SET `u$unit` = '0' WHERE `vref` = $vid;";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
|
||||
function DelPlayer($uid,$pass){
|
||||
global $database;
|
||||
$ID = $_SESSION['id'];//$database->getUserField($_SESSION['username'],'id',1);
|
||||
@@ -194,7 +197,7 @@ class adm_DB {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function DelVillage($wref){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref and capital = 0";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
@@ -218,7 +221,7 @@ class adm_DB {
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function DelBan($uid,$id){
|
||||
global $database;
|
||||
$name = $database->getUserField($uid,"username",0);
|
||||
@@ -295,12 +298,12 @@ class adm_DB {
|
||||
return $all;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function query_return($q) {
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
|
||||
/***************************
|
||||
Function to do free query
|
||||
References: Query
|
||||
@@ -308,8 +311,8 @@ class adm_DB {
|
||||
function query($query) {
|
||||
return mysql_query($query, $this->connection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
$admin = new adm_DB;
|
||||
|
||||
@@ -2592,8 +2592,8 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
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);
|
||||
$heroid = $database->getHero($database->getVillageField($data['from'],"owner"),1);
|
||||
$HeroTransfer = 1;
|
||||
}
|
||||
}
|
||||
@@ -3243,12 +3243,12 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
private function updateHero() {
|
||||
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) {
|
||||
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']);
|
||||
if($reg <= 100) {
|
||||
if($reg <= 100){
|
||||
$database->modifyHero("health",$reg,$hdata['heroid']);
|
||||
}else{
|
||||
$database->modifyHero("health",100,$hdata['heroid']);
|
||||
@@ -3256,10 +3256,18 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
}
|
||||
$database->modifyHero("lastupdate",time(),$hdata['heroid']);
|
||||
}
|
||||
if ($hdata['experience'] > $hero_levels[$hdata['level']+1] && $hdata['level'] < 100) {
|
||||
if($hdata['experience'] > $hero_levels[$hdata['level']+1] && $hdata['level'] < 100){
|
||||
mysql_query("UPDATE " . TB_PREFIX ."hero SET level = level + 1 WHERE heroid = '".$hdata['heroid']."'");
|
||||
mysql_query("UPDATE " . TB_PREFIX ."hero SET points = points + 5 WHERE heroid = '".$hdata['heroid']."'");
|
||||
}
|
||||
$villunits = $database->getUnit($hdata['wref']);
|
||||
if($hero_info['dead'] == 1 or $villunits['hero'] == 1){
|
||||
mysql_query("UPDATE " . TB_PREFIX . "hero SET nothome = 0 WHERE heroid = ".$hdata['heroid']."");
|
||||
}
|
||||
if($villunits['hero'] == 0 && $hero_info['trainingtime'] < time() && $hero_info['nothome'] == 0){
|
||||
mysql_query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".$hdata['wref']."");
|
||||
mysql_query("UPDATE ".TB_PREFIX."hero SET `dead` = '0', `health` = '100' WHERE `uid` = '".$hdata['uid']."'");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(file_exists("GameEngine/Prevention/updatehero.txt")) {
|
||||
|
||||
@@ -332,6 +332,10 @@ class Units {
|
||||
$checkoexist = $database->checkOasisExist($data['to_vid']);
|
||||
if($checkexist or $checkoexist){
|
||||
$database->addMovement(3,$village->wid,$data['to_vid'],$reference,time(),($time+time()));
|
||||
if($data['u11'] > 0){
|
||||
$heroid = $database->getHero($session->uid);
|
||||
mysql_query("UPDATE " . TB_PREFIX . "hero SET nothome = 1 WHERE heroid = ".$heroid."");
|
||||
}
|
||||
}
|
||||
|
||||
if($form->returnErrors() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user