mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-28 06:07:14 +00:00
Update database.php
This commit is contained in:
@@ -22,6 +22,7 @@ include_once("../../GameEngine/Data/buidata.php");
|
|||||||
}else{
|
}else{
|
||||||
include_once("../GameEngine/Data/unitdata.php");
|
include_once("../GameEngine/Data/unitdata.php");
|
||||||
include_once("../GameEngine/Technology.php");
|
include_once("../GameEngine/Technology.php");
|
||||||
|
include_once("../GameEngine/Data/buidata.php");
|
||||||
}
|
}
|
||||||
class adm_DB {
|
class adm_DB {
|
||||||
var $connection;
|
var $connection;
|
||||||
@@ -56,58 +57,60 @@ class adm_DB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function recountPop($vid){
|
function recountPop($vid){
|
||||||
global $database;
|
global $database;
|
||||||
$fdata = $database->getResourceLevel($vid);
|
$fdata = $database->getResourceLevel($vid);
|
||||||
$popTot = 0;
|
$popTot = 0;
|
||||||
for ($i = 1; $i <= 40; $i++) {
|
for ($i = 1; $i <= 40; $i++) {
|
||||||
$lvl = $fdata["f".$i];
|
$lvl = $fdata["f".$i];
|
||||||
$building = $fdata["f".$i."t"];
|
$building = $fdata["f".$i."t"];
|
||||||
if($building){
|
if($building>0 && $lvl>0){
|
||||||
$popTot += $this->buildingPOP($building,$lvl);
|
$popTot += $this->buildingPOP($building,$lvl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
|
|
||||||
mysql_query($q, $this->connection);
|
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
|
||||||
|
mysql_query($q, $this->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
function recountCP($vid){
|
function recountCP($vid){
|
||||||
global $database;
|
global $database;
|
||||||
$fdata = $database->getResourceLevel($vid);
|
$fdata = $database->getResourceLevel($vid);
|
||||||
$popTot = 0;
|
$popTot = 0;
|
||||||
for ($i = 1; $i <= 40; $i++) {
|
for ($i = 1; $i <= 40; $i++) {
|
||||||
$lvl = $fdata["f".$i];
|
$lvl = $fdata["f".$i];
|
||||||
$building = $fdata["f".$i."t"];
|
$building = $fdata["f".$i."t"];
|
||||||
if($building){
|
if($building>0 && $lvl>0){
|
||||||
$popTot += $this->buildingCP($building,$lvl);
|
$popTot += $this->buildingCP($building,$lvl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
|
$q = "UPDATE ".TB_PREFIX."vdata set cp = $popTot where wref = $vid";
|
||||||
mysql_query($q, $this->connection);
|
mysql_query($q, $this->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildingPOP($f,$lvl){
|
function buildingPOP($f,$lvl){
|
||||||
$name = "bid".$f;
|
$name = "bid".$f;
|
||||||
global $$name;
|
global $$name;
|
||||||
$popT = 0;
|
$popT = 0;
|
||||||
$dataarray = $$name;
|
$dataarray = $$name;
|
||||||
for ($i = 0; $i <= $lvl; $i++) {
|
|
||||||
$popT += $dataarray[$i]['pop'];
|
for ($i = 1; $i <= $lvl; $i++) {
|
||||||
}
|
$popT += $dataarray[$i]['pop'];
|
||||||
return $popT;
|
}
|
||||||
|
return $popT;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildingCP($f,$lvl){
|
function buildingCP($f,$lvl){
|
||||||
$name = "bid".$f;
|
$name = "bid".$f;
|
||||||
global $$name;
|
global $$name;
|
||||||
$popT = 0;
|
$popT = 0;
|
||||||
$dataarray = $$name;
|
$dataarray = $$name;
|
||||||
|
|
||||||
for ($i = 0; $i <= $lvl; $i++) {
|
for ($i = 1; $i <= $lvl; $i++) {
|
||||||
$popT += $dataarray[$i]['cp'];
|
$popT += $dataarray[$i]['cp'];
|
||||||
}
|
}
|
||||||
return $popT;
|
return $popT;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWref($x,$y) {
|
function getWref($x,$y) {
|
||||||
$q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y";
|
$q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y";
|
||||||
@@ -852,4 +855,4 @@ class adm_DB {
|
|||||||
|
|
||||||
$admin = new adm_DB;
|
$admin = new adm_DB;
|
||||||
include("function.php");
|
include("function.php");
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user