Game updates improvements

* Added a set of tables which define game updates and their targets.
These definitions replace the old enumerate type. Added a set of
triggers which automatically create specific update tables, insert
missing entries, etc... when game update types are being manipulated.

* Removed manual insertion of game updates from empire creation
function and universe generator.

* Added registration of core update targets (i.e. planets and empires),
updated all existing game update processing functions and added type
registrations

* Created Maven project for game updates control components, moved
existing components from the -simple project, rewritten most of what
they contained, added new components for server-side update batch
processing
This commit is contained in:
Emmanuel BENOîT 2012-02-03 16:25:03 +01:00
parent ba6a1e2b41
commit 56eddcc4f0
93 changed files with 4004 additions and 578 deletions
legacyworlds-server-data/db-structure/tests/utils/common-setup

View file

@ -21,13 +21,13 @@
* - Finally, we need a planet that matches the criterias but isn't
* scheduled for an update at the time.
*
* FIXME: for now, locking is NOT tested. I simply have no idea how to do
* it, at least not without creating an extra database and that
* kind of stuff.
*
* FIXME: cannot test where the happiness column comes from until values
* all use DOUBLE PRECISION.
*/
DELETE FROM sys.update_types
WHERE updtype_name <> 'PlanetMining';
\i utils/strings.sql
\i utils/resources.sql
\i utils/accounts.sql
@ -41,17 +41,7 @@ SELECT _create_emp_names( 4 , 'empire' );
INSERT INTO emp.empires ( name_id , cash )
SELECT id , 0 FROM naming.empire_names;
/* Planet #1 */
INSERT INTO sys.updates( id , gu_type , status , last_tick )
VALUES ( 1 , 'PLANET_MINING' , 'PROCESSING' , 0 );
INSERT INTO verse.updates( update_id , planet_id )
VALUES ( 1 , _get_map_name( 'planet1' ) );
/* Planet #2 */
INSERT INTO sys.updates( id , gu_type , status , last_tick )
VALUES ( 2 , 'PLANET_MINING' , 'PROCESSING' , 0 );
INSERT INTO verse.updates( update_id , planet_id )
VALUES ( 2 , _get_map_name( 'planet2' ) );
INSERT INTO verse.resource_providers (
planet_id , resource_name_id , resprov_quantity_max ,
resprov_quantity , resprov_difficulty , resprov_recovery
@ -64,10 +54,6 @@ INSERT INTO verse.resource_providers (
);
/* Planet #3 */
INSERT INTO sys.updates( id , gu_type , status , last_tick )
VALUES ( 3 , 'PLANET_MINING' , 'PROCESSING' , 0 );
INSERT INTO verse.updates( update_id , planet_id )
VALUES ( 3 , _get_map_name( 'planet3' ) );
INSERT INTO verse.resource_providers (
planet_id , resource_name_id , resprov_quantity_max ,
resprov_quantity , resprov_difficulty , resprov_recovery
@ -90,10 +76,6 @@ INSERT INTO emp.mining_settings( empire_id , resource_name_id , empmset_weight )
);
/* Planet #4 */
INSERT INTO sys.updates( id , gu_type , status , last_tick )
VALUES ( 4 , 'PLANET_MINING' , 'PROCESSING' , 0 );
INSERT INTO verse.updates( update_id , planet_id )
VALUES ( 4 , _get_map_name( 'planet4' ) );
INSERT INTO verse.resource_providers (
planet_id , resource_name_id , resprov_quantity_max ,
resprov_quantity , resprov_difficulty , resprov_recovery
@ -123,10 +105,6 @@ INSERT INTO emp.planet_mining_settings(
);
/* Planet #5 */
INSERT INTO sys.updates( id , gu_type , status , last_tick )
VALUES ( 5 , 'PLANET_MINING' , 'PROCESSING' , 0 );
INSERT INTO verse.updates( update_id , planet_id )
VALUES ( 5 , _get_map_name( 'planet5' ) );
INSERT INTO verse.planet_happiness ( planet_id , current , target )
VALUES ( _get_map_name( 'planet5' ) , 0.5 , 0.5 );
INSERT INTO emp.planets ( empire_id , planet_id )
@ -139,10 +117,6 @@ INSERT INTO emp.mining_settings( empire_id , resource_name_id , empmset_weight )
);
/* Planet #6 */
INSERT INTO sys.updates( id , gu_type , status , last_tick )
VALUES ( 6 , 'PLANET_MINING' , 'PROCESSED' , 0 );
INSERT INTO verse.updates( update_id , planet_id )
VALUES ( 6 , _get_map_name( 'planet6' ) );
INSERT INTO verse.resource_providers (
planet_id , resource_name_id , resprov_quantity_max ,
resprov_quantity , resprov_difficulty , resprov_recovery
@ -168,3 +142,16 @@ INSERT INTO emp.mining_settings( empire_id , resource_name_id , empmset_weight )
INSERT INTO verse.planet_resources ( planet_id , resource_name_id , pres_income , pres_upkeep )
SELECT p.name_id , r.resource_name_id , 42 , 0
FROM verse.planets p CROSS JOIN defs.resources r;
/* Modify update records for the planets. Planet 6 is not to be processed.
*/
UPDATE sys.updates su
SET update_state = 'PROCESSING' , update_last = 0
FROM verse.planets_updates vu
WHERE vu.update_id = su.update_id
AND vu.name_id <> _get_map_name( 'planet6' );
UPDATE sys.updates su
SET update_state = 'PROCESSED' , update_last = 0
FROM verse.planets_updates vu
WHERE vu.update_id = su.update_id
AND vu.name_id = _get_map_name( 'planet6' );