This repository has been archived on 2025-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
lwb6/legacyworlds-server-data/db-structure/parts/050-updates/105-planet-resource-regeneration.sql
Emmanuel BENOîT 56eddcc4f0 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
2012-02-03 16:25:03 +01:00

51 lines
No EOL
1.3 KiB
SQL

-- LegacyWorlds Beta 6
-- PostgreSQL database scripts
--
-- Game updates - resource regeneration
--
-- Copyright(C) 2004-2012, DeepClone Development
-- --------------------------------------------------------
/*
* Resource provider regeneration update
*
* This function computes the regeneration of resource providers for the current batch
* of planets.
*
* Parameters:
* _tick The identifier of the game update
*/
CREATE OR REPLACE FUNCTION sys.process_res_regen_updates( _tick BIGINT )
RETURNS VOID
STRICT VOLATILE
SECURITY INVOKER
AS $process_planet_res_regen_updates$
UPDATE verse.resource_providers _provider
SET resprov_quantity = verse.compute_provider_regeneration(
_provider.resprov_quantity ,
_provider.resprov_quantity_max ,
_provider.resprov_recovery
)
FROM sys.updates _upd_sys
INNER JOIN verse.planets_updates _upd_verse
USING ( update_id , updtype_id , updtgt_id )
WHERE _upd_sys.update_last = $1
AND _upd_sys.update_state = 'PROCESSING'
AND _provider.planet_id = _upd_verse.name_id;
$process_planet_res_regen_updates$ LANGUAGE SQL;
REVOKE EXECUTE
ON FUNCTION sys.process_res_regen_updates( BIGINT )
FROM PUBLIC;
SELECT sys.register_update_type( 'Planets' , 'ResourceRegeneration' ,
'Resource providers are being regenerated.' ,
'process_res_regen_updates'
);