stfc2 team mailing list archive
-
stfc2 team
-
Mailing list archive
-
Message #00048
[Branch ~cristiano-delogu/+junk/stfc2] Rev 480: La funzione CanAffordTemplate permetteva la costruzione di user_max_colo + (user_max_colo -1) col...
------------------------------------------------------------
revno: 480
committer: Kail <cristiano.delogu@xxxxxxxx>
branch nick: stfc2.kail
timestamp: Tue 2011-02-08 16:51:09 +0100
message:
La funzione CanAffordTemplate permetteva la costruzione di user_max_colo + (user_max_colo -1) colonizzatrici, bypassando il limite di user_max_colo. Tale comportamento errato è stato corretto, aggiungendo una seconda verifica delle colonizzatrici già possedute.
modified:
game/modules/shipyard.php
--
lp:~cristiano-delogu/+junk/stfc2
https://code.launchpad.net/~cristiano-delogu/+junk/stfc2
Your team STFC2 developers is subscribed to branch lp:~cristiano-delogu/+junk/stfc2.
To unsubscribe from this branch go to https://code.launchpad.net/~cristiano-delogu/+junk/stfc2/+edit-subscription
=== modified file 'game/modules/shipyard.php'
--- game/modules/shipyard.php 2010-06-23 14:55:14 +0000
+++ game/modules/shipyard.php 2011-02-08 15:51:09 +0000
@@ -219,7 +219,7 @@
{
-global $game;
+global $game, $db;
// Calculate how many types of the template could be build:
@@ -244,10 +244,27 @@
if ($template['min_unit_4']!=0) $num[9]=floor($planet['unit_4']/$template['min_unit_4']); else $num[9]=9999;
// You cannot have more than user_max_colo colony ship at same time
-if($template['ship_torso'] == 2 && $template['ship_class'] == 0) {
- if (($game->player['user_max_colo'] != 0) && (min($num) > $game->player['user_max_colo']))
- return (int)$game->player['user_max_colo'];
+if($template['ship_torso'] == 2 && $template['ship_class'] == 0 && $game->player['user_max_colo'] != 0) {
+ // Conteggio delle colonizzatrici già a disposizione del giocatore
+ $sql = 'SELECT COUNT(*) AS conteggio FROM ship_templates, ships WHERE ship_templates.id = ships.template_id
+ AND ship_templates.ship_torso = 2 AND ship_templates.ship_class = 0
+ AND ships.user_id = '.$game->player['user_id'];
+
+ $_temp = $db->queryrow($sql);
+ $conteggio = $_temp['conteggio'];
+
+ $sql = 'SELECT COUNT(*) AS conteggio FROM scheduler_shipbuild, ship_templates, planets WHERE scheduler_shipbuild.ship_type = ship_templates.id
+ AND scheduler_shipbuild.planet_id = planets.planet_id
+ AND ship_templates.ship_torso = 2
+ AND ship_class = 0
+ AND planets.planet_owner = '.$game->player['user_id'];
+
+ $_temp = $db->queryrow($sql);
+ $conteggio += $_temp['conteggio'];
+ $max_colo = $game->player['user_max_colo'] - $conteggio;
+ if (min($num) > $max_colo) return (int)$max_colo;
}
+
return min($num);
}