Fixed mysql_* calls
Updated skin Fixed minor bugs in shipyard pages display Fixed various bugs in legacy fleet pages source code. Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
be8c6a6629
commit
cfeb6aca6d
68 changed files with 1561 additions and 1451 deletions
|
|
@ -216,4 +216,20 @@ class Legacies
|
|||
{
|
||||
self::$_response = $response;
|
||||
}
|
||||
|
||||
public static function getUrl($uri, Array $params = array())
|
||||
{
|
||||
// TODO: base path integration
|
||||
$serializedParams = array();
|
||||
foreach ($params as $paramKey => $paramValue) {
|
||||
if ($paramValue) {
|
||||
$serializedParams[] = "{$paramKey}={$paramValue}";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($serializedParams) > 0) {
|
||||
return $uri . '?' . implode('&', $serializedParams);
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ SQL_EOF;
|
|||
{
|
||||
$clone = clone $this;
|
||||
$clone->_fields = array();
|
||||
$clone->column('COUNT(*)');
|
||||
$clone->column('1');
|
||||
|
||||
$sql = $clone->_prepareSql();
|
||||
|
||||
|
|
@ -306,7 +306,10 @@ SQL_EOF;
|
|||
|
||||
$args = func_get_args();
|
||||
$statement->execute(array_shift($args));
|
||||
return $statement->fetch(PDO::FETCH_COLUMN, 0);
|
||||
$count = $statement->rowCount();
|
||||
$statement->closeCursor();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function count()
|
||||
|
|
@ -342,4 +345,22 @@ SQL_EOF;
|
|||
{
|
||||
return current($this->_items) !== false;
|
||||
}
|
||||
|
||||
public function getFirstItem()
|
||||
{
|
||||
if (!$this->_)
|
||||
if (count($this->_items) > 0) {
|
||||
return $this->_items[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getLastItem()
|
||||
{
|
||||
$size = count($this->_items);
|
||||
if ($size > 0) {
|
||||
return $this->_items[$size - 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -112,18 +112,7 @@ class Legacies_Core_View
|
|||
|
||||
public function getUrl($uri, Array $params = array())
|
||||
{
|
||||
// TODO: base path integration
|
||||
$serializedParams = array();
|
||||
foreach ($params as $paramKey => $paramValue) {
|
||||
if ($paramValue) {
|
||||
$serializedParams[] = "{$paramKey}={$paramValue}";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($serializedParams) > 0) {
|
||||
return $uri . '?' . implode('&', $serializedParams);
|
||||
}
|
||||
return $uri;
|
||||
return Legacies::getUrl($uri, $params);
|
||||
}
|
||||
|
||||
public function getSkinUrl($uri)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Legacies_Empire_Block_Planet_Shipyard_Queue
|
|||
{
|
||||
public function getQueue()
|
||||
{
|
||||
return $this->getPlanet()->getShipyard()->getQueue();
|
||||
return $this->getPlanet()->getShipyard()->getBuilder();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
|
|
|
|||
|
|
@ -64,6 +64,56 @@ class Legacies_Empire_Model_Planet
|
|||
return self::$_instances[$id];
|
||||
}
|
||||
|
||||
public static function factoryFromCoords($coords, $type = self::TYPE_PLANET)
|
||||
{
|
||||
if ($coords === null || empty($coords)) {
|
||||
return new self();
|
||||
}
|
||||
|
||||
if (!in_array($type, array(self::TYPE_PLANET, self::TYPE_DEBRIS, self::TYPE_MOON))) {
|
||||
$type = self::TYPE_PLANET;
|
||||
}
|
||||
|
||||
if (!is_array($coords)) {
|
||||
$coords = explode(':', $coords);
|
||||
|
||||
if (count($coords) != 3) {
|
||||
return new self();
|
||||
}
|
||||
|
||||
$coords = array(
|
||||
'galaxy' => $coords[0],
|
||||
'system' => $coords[1],
|
||||
'position' => $coords[2],
|
||||
'type' => $type
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($coords['type'])) {
|
||||
$coords['type'] = $type;
|
||||
}
|
||||
|
||||
$database = Legacies_Database::getSingleton();
|
||||
$collection = new Legacies_Core_Collection('planets');
|
||||
$collection
|
||||
->column('id')
|
||||
->where('galaxy=:galaxy')
|
||||
->where('system=:system')
|
||||
->where('planet=:position')
|
||||
->where('planet_type=:type')
|
||||
->limit(1)
|
||||
->load($coords)
|
||||
;
|
||||
|
||||
$planetData = $collection->getFirstItem();
|
||||
|
||||
if ($planetData === null || !$planetData->getData('id')) {
|
||||
return new self();
|
||||
}
|
||||
|
||||
return self::factory($planetData->getData('id'));
|
||||
}
|
||||
|
||||
public function _init()
|
||||
{
|
||||
$this->_tableName = 'planets';
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class Legacies_Empire_Model_Planet_Builder
|
|||
}
|
||||
|
||||
if (!isset($params['started_at'])) {
|
||||
$startedAt = 0;
|
||||
$startedAt = null;
|
||||
} else {
|
||||
$startedAt = $params['started_at'];
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ class Legacies_Empire_Model_Planet_Builder
|
|||
foreach ($this->getQueue() as $element) {
|
||||
$elementTime = $element->getData('started_at');
|
||||
|
||||
if ($elementTime == 0) {
|
||||
if ($elementTime === null) {
|
||||
$element->setData('started_at', $startingTime);
|
||||
$elementTime = $startingTime;
|
||||
}
|
||||
|
|
@ -199,6 +199,10 @@ class Legacies_Empire_Model_Planet_Builder
|
|||
return $this;
|
||||
}
|
||||
|
||||
if ($this->count() == 0) {
|
||||
$this->_currentPlanet->setData('b_building', $time);
|
||||
}
|
||||
|
||||
$this->enqueue(array(
|
||||
'building_id' => $buildingId,
|
||||
'level' => $level,
|
||||
|
|
|
|||
|
|
@ -233,11 +233,11 @@ class Legacies_Empire_Model_User
|
|||
*/
|
||||
public function updateCurrentPlanet($planet)
|
||||
{
|
||||
if (!$planetId instanceof Legacies_Empire_Model_Planet) {
|
||||
if (!$planet instanceof Legacies_Empire_Model_Planet) {
|
||||
$planetCollection = $this->_preparePlanetCollection()->where('id=:id');
|
||||
|
||||
$planetCollection->load(array(
|
||||
'id' => $planet,
|
||||
'id' => $planet,
|
||||
'user' => $this->getId()
|
||||
));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
<div class="planet-carrousel">
|
||||
<div class="arrow left">⇦</div>
|
||||
<div class="items">
|
||||
<?php foreach ($this->getPlanetCollection() as $planet):?>
|
||||
<div class="planet item">
|
||||
<div class="planet item">
|
||||
<?php if ($planet->getId() != $this->getCurrentPlanet()->getId()):?>
|
||||
<a href="<?php echo $this->getUrl('', array('cp' => $planet->getId()))?>"><?php echo $this->escape($planet->getName())?> [<?php echo $this->escape($planet->getCoords())?>]</a>
|
||||
<a href="<?php echo $this->getUrl('', array('cp' => $planet->getId()))?>"><?php echo $this->escape($planet->getName())?> [<?php echo $this->escape($planet->getCoords())?>]</a>
|
||||
<?php else:?>
|
||||
<?php echo $this->escape($planet->getName())?> [<?php echo $this->escape($planet->getCoords())?>]
|
||||
<?php endif?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach?>
|
||||
</div>
|
||||
<div class="arrow right">⇨</div>
|
||||
</div>
|
||||
<div class="resources-display">
|
||||
<div class="resource metal">
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ define('LEVEL_OPERATOR', 2);
|
|||
define('LEVEL_MODERATOR', 1);
|
||||
define('LEVEL_PLAYER', 0);
|
||||
|
||||
define('ALLOW_SPY_DRONE_ATTACKS', true);
|
||||
|
||||
// Nombre de colones pour les rapports d'espionnage
|
||||
define('SPY_REPORT_ROW', 2);
|
||||
|
||||
|
|
|
|||
|
|
@ -125,33 +125,32 @@ EOF;
|
|||
* @param $title
|
||||
* @return unknown_type
|
||||
*/
|
||||
function error($message, $title)
|
||||
public function error($message, $title)
|
||||
{
|
||||
global $link, $gameConfig;
|
||||
$gameConfig = Legacies_Core_Model_Config::getSingleton();
|
||||
|
||||
if($gameConfig['debug']==1){
|
||||
if ($gameConfig['debug'] == 1) {
|
||||
echo "<h2>$title</h2><br><font color=red>$message</font><br><hr>";
|
||||
echo "<table>".$this->log."</table>";
|
||||
}
|
||||
|
||||
global $user;
|
||||
$user = Legacies_Empire_Model_User::getSingleton();
|
||||
|
||||
$db = Legacies_Database::getSingleton();
|
||||
$config = include ROOT_PATH . 'config.' . PHPEXT;
|
||||
if(!$link) die('La base de donnee n est pas disponible pour le moment, desole pour la gene occasionnee...');
|
||||
$query = "INSERT INTO {{table}} SET
|
||||
`error_sender` = '{$user['id']}' ,
|
||||
`error_time` = '".time()."' ,
|
||||
`error_type` = '{$title}' ,
|
||||
`error_text` = '".mysql_escape_string($message)."';";
|
||||
$sqlquery = mysql_query(str_replace("{{table}}", $dbsettings["prefix"].'errors',$query))
|
||||
or die('error fatal');
|
||||
$query = "explain select * from {{table}}";
|
||||
$q = mysql_fetch_array(mysql_query(str_replace("{{table}}", $dbsettings["prefix"].
|
||||
'errors', $query))) or die('error fatal: ');
|
||||
$query = "INSERT INTO {$db->getTable('errors')} SET
|
||||
`error_sender` = {$user->getId()} ,
|
||||
`error_time` = {$db->quote(time())},
|
||||
`error_type` = {$db->quote($title)},
|
||||
`error_text` = {$db->quote($message)}";
|
||||
|
||||
$db->query($query);
|
||||
$id = $db->lastInsertId($db->getTable('errors'));
|
||||
if (!function_exists('message')) {
|
||||
echo "Erreur, merci de contacter l'admin. Erreur n<>: <b>".$q['rows']."</b>";
|
||||
echo "Erreur, merci de contacter l'admin. Erreur n<>: <b>".$id."</b>";
|
||||
} else {
|
||||
message("Erreur, merci de contacter l'admin. Erreur n<>: <b>".$q['rows']."</b>", "Erreur");
|
||||
message("Erreur, merci de contacter l'admin. Erreur n<>: <b>".$id."</b>", "Erreur");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function BuildFlyingFleetTable () {
|
|||
|
||||
$TableTPL = gettemplate('admin/fleet_rows');
|
||||
$FlyingFleets = doquery ("SELECT * FROM {{table}} ORDER BY `fleet_end_time` ASC;", 'fleets');
|
||||
while ( $CurrentFleet = mysql_fetch_assoc( $FlyingFleets ) ) {
|
||||
while ( $CurrentFleet = $FlyingFleets->fetch(PDO::FETCH_ASSOC) ) {
|
||||
$FleetOwner = doquery("SELECT `username` FROM {{table}} WHERE `id` = '". $CurrentFleet['fleet_owner'] ."';", 'users', true);
|
||||
$TargetOwner = doquery("SELECT `username` FROM {{table}} WHERE `id` = '". $CurrentFleet['fleet_target_owner'] ."';", 'users', true);
|
||||
$Bloc['Id'] = $CurrentFleet['fleet_id'];
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ function DeleteSelectedUser ( $UserID ) {
|
|||
doquery ( "DELETE FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';", 'statpoints' );
|
||||
|
||||
$ThePlanets = doquery ( "SELECT * FROM {{table}} WHERE `id_owner` = '" . $UserID . "';", 'planets' );
|
||||
while ( $OnePlanet = mysql_fetch_assoc ( $ThePlanets ) ) {
|
||||
while ( $OnePlanet = $ThePlanets->fetch(PDO::FETCH_ASSOC) ) {
|
||||
if ( $OnePlanet['planet_type'] == 1 ) {
|
||||
doquery ( "DELETE FROM {{table}} WHERE `galaxy` = '" . $OnePlanet['galaxy'] . "' AND `system` = '" . $OnePlanet['system'] . "' AND `planet` = '" . $OnePlanet['planet'] . "';", 'galaxy' );
|
||||
} elseif ( $OnePlanet['planet_type'] == 3 ) {
|
||||
|
|
|
|||
|
|
@ -36,10 +36,12 @@
|
|||
function MissionCaseColonisation ( $FleetRow ) {
|
||||
global $lang, $resource;
|
||||
|
||||
$iPlanetCount = mysql_result(doquery ("SELECT count(*) FROM {{table}} WHERE `id_owner` = '". $FleetRow['fleet_owner'] ."' AND `planet_type` = '1'", 'planets'), 0);
|
||||
$statement = doquery ("SELECT count(*) FROM {{table}} WHERE `id_owner` = '". $FleetRow['fleet_owner'] ."' AND `planet_type` = '1'", 'planets');
|
||||
$iPlanetCount = $statement->fetch(PDO::FETCH_ASSOC);
|
||||
if ($FleetRow['fleet_mess'] == 0) {
|
||||
// Déjà, sommes nous a l'aller ??
|
||||
$iGalaxyPlace = mysql_result(doquery ("SELECT count(*) FROM {{table}} WHERE `galaxy` = '". $FleetRow['fleet_end_galaxy']."' AND `system` = '". $FleetRow['fleet_end_system']."' AND `planet` = '". $FleetRow['fleet_end_planet']."';", 'galaxy'), 0);
|
||||
$statement2 = doquery ("SELECT count(*) FROM {{table}} WHERE `galaxy` = '". $FleetRow['fleet_end_galaxy']."' AND `system` = '". $FleetRow['fleet_end_system']."' AND `planet` = '". $FleetRow['fleet_end_planet']."';", 'galaxy');
|
||||
$iGalaxyPlace = $statement2->fetch(PDO::FETCH_ASSOC);
|
||||
$TargetAdress = sprintf ($lang['sys_adress_planet'], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']);
|
||||
if ($iGalaxyPlace == 0) {
|
||||
// Y a personne qui s'y est mis avant que je ne debarque !
|
||||
|
|
|
|||
|
|
@ -63,38 +63,51 @@ function GetGameSpeedFactor () {
|
|||
* Calcul de la vitesse de la flotte par rapport aux technos du joueur
|
||||
* Avec prise en compte
|
||||
*/
|
||||
function GetFleetMaxSpeed ($FleetArray, $Fleet, $Player) {
|
||||
function GetFleetMaxSpeed($FleetArray, $Fleet, $Player) {
|
||||
global $reslist, $pricelist;
|
||||
|
||||
if (!is_array($FleetArray)) {
|
||||
$FleetArray = array();
|
||||
}
|
||||
|
||||
if ($Fleet != 0) {
|
||||
$FleetArray[$Fleet] = 1;
|
||||
}
|
||||
|
||||
$speedalls = array();
|
||||
foreach ($FleetArray as $Ship => $Count) {
|
||||
if ($Ship == 202) {
|
||||
if ($Ship == Legacies_Empire::ID_SHIP_SOLAR_SATELLITE) {
|
||||
$speedalls[$Ship] = 0;
|
||||
}
|
||||
if ($Ship == Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT) {
|
||||
if ($Player['impulse_motor_tech'] >= 5) {
|
||||
$speedalls[$Ship] = $pricelist[$Ship]['speed2'] + (($pricelist[$Ship]['speed'] * $Player['impulse_motor_tech']) * 0.2);
|
||||
} else {
|
||||
$speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['combustion_tech']) * 0.1);
|
||||
}
|
||||
}
|
||||
if ($Ship == 203 or $Ship == 204 or $Ship == 209 or $Ship == 210) {
|
||||
if ($Ship == Legacies_Empire::ID_SHIP_LARGE_TRANSPORT || $Ship == Legacies_Empire::ID_SHIP_LIGHT_FIGHTER ||
|
||||
$Ship == Legacies_Empire::ID_SHIP_RECYCLER || $Ship == Legacies_Empire::ID_SHIP_SPY_DRONE) {
|
||||
$speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['combustion_tech']) * 0.1);
|
||||
}
|
||||
if ($Ship == 205 or $Ship == 206 or $Ship == 208) {
|
||||
if ($Ship == Legacies_Empire::ID_SHIP_HEAVY_FIGHTER || $Ship == Legacies_Empire::ID_SHIP_CRUISER ||
|
||||
$Ship == Legacies_Empire::ID_SHIP_COLONY_SHIP) {
|
||||
$speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['impulse_motor_tech']) * 0.2);
|
||||
}
|
||||
if ($Ship == 211) {
|
||||
if ($Ship == Legacies_Empire::ID_SHIP_BOMBER) {
|
||||
if ($Player['hyperspace_motor_tech'] >= 8) {
|
||||
$speedalls[$Ship] = $pricelist[$Ship]['speed2'] + (($pricelist[$Ship]['speed'] * $Player['hyperspace_motor_tech']) * 0.3);
|
||||
} else {
|
||||
$speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['impulse_motor_tech']) * 0.2);
|
||||
}
|
||||
}
|
||||
if ($Ship == 207 or $Ship == 213 or $Ship == 214 or $Ship == 215 or $Ship == 216) {
|
||||
if ($Ship == Legacies_Empire::ID_SHIP_BATTLESHIP || $Ship == Legacies_Empire::ID_SHIP_DESTRUCTOR ||
|
||||
$Ship == Legacies_Empire::ID_SHIP_DEATH_STAR || $Ship == Legacies_Empire::ID_SHIP_BATTLECRUISER ||
|
||||
$Ship == Legacies_Empire::ID_SHIP_SUPERNOVA) {
|
||||
$speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['hyperspace_motor_tech']) * 0.3);
|
||||
}
|
||||
}
|
||||
if ($Fleet != 0) {
|
||||
if ($Fleet != 0 && isset($speedalls[$Ship])) {
|
||||
$ShipSpeed = $speedalls[$Ship];
|
||||
$speedalls = $ShipSpeed;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue