forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Mon Dec 18, 2017 8:28 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jun 30, 2008 12:21 pm 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
There needs to be a check in processOrderUnitPlacing::create() so that the maximum number of unit creation orders is limited by the number of available supply centers which can be built in.

This is the function which creates the unit creation orders:
http://www.phpdiplomacy.net/doc/phpDoc/ ... p.html#a62


Top
 Profile  
 
PostPosted: Tue Jul 01, 2008 4:43 pm 
Offline

Joined: Tue Jul 01, 2008 2:42 pm
Posts: 11
Location: chicago
Think I've solved this, but I don't have the time to set up a phpDip instance for this yet. I can't seem to attach the patch as all the extensions I've tried thus far are "not allowed", so here it is inline:

Code:
diff -Naur phpdiplomacy/gamemaster/orders/unitplacing.php phpdiplomacy.limit_builds/gamemaster/orders/unitplacing.php
--- phpdiplomacy/gamemaster/orders/unitplacing.php      2008-06-28 06:06:17.000000000 -0500
+++ phpdiplomacy.limit_builds/gamemaster/orders/unitplacing.php 2008-07-01 11:32:21.000000000 -0500
@@ -76,6 +76,22 @@
                        {
                                $difference = $Member->supplyCenterNo - $Member->unitNo;
                                $type = 'Build Army';
+
+                               list($row) = $DB->sql_row("SELECT COUNT(*)
+                                       FROM pD_TerrStatus ts
+                                       INNER JOIN pD_Territories t
+                                               ON ( t.terr = ts.terr )
+                                       WHERE ts.gameID = ".$Game->id."
+                                               AND ts.country = '".$Member->country."'
+                                               AND t.country = '".$Member->country."'
+                                               AND ts.occupyingUnitID IS NULL
+                                               AND t.supply = 'Yes'");
+
+                               $max_builds = $row[0];
+                               if ( $difference > $max_builds )
+                               {
+                                       $difference = $max_builds;
+                               }
                        }
 
                        for( $i=0; $i < $difference; ++$i )


The original version (with proper tab characters) can be found here: http://relocated.ath.cx/patchcontrol/limit_builds.patch.

The patch is against the 0.8 code currently on Sourceforge. I did my best to follow the coding conventions I saw used, let me know if there's anything I got wrong.


Top
 Profile  
 
PostPosted: Tue Jul 01, 2008 7:58 pm 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
Thanks for this, it definitely fits into the conventions. Only problem was

Code:
list($row) = $DB->sql_row([...]

$max_builds = $row[0];


Which should just be

Code:
list($max_builds) = $DB->sql_row([...]


But other than that it looks fine


I also realize that CVS is probably inconvenient, and releases don't contain the latest code, so I updated my cvs script to create a tarball of the latest code and upload it.
I added this link to the developers page: http://phpdiplomacy.net/phpdiplomacy-latest.tgz

Regards,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group