Mining computations update
* Added a few that can be used to retrieve mining settings for resource providers from empire-owned planets from either the empire-wide or planet-specific settings
This commit is contained in:
parent
c18bdc2d1f
commit
038bba896a
3 changed files with 158 additions and 0 deletions
legacyworlds-server-data/db-structure/parts/040-functions
|
@ -59,3 +59,43 @@ REVOKE EXECUTE
|
|||
DOUBLE PRECISION , DOUBLE PRECISION ,
|
||||
DOUBLE PRECISION )
|
||||
FROM PUBLIC;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Mining settings view
|
||||
* ---------------------
|
||||
*
|
||||
* This view lists mining settings being used on planets owned by empires
|
||||
* for each resource providers. The settings are taken from planet-specific
|
||||
* settings if they are available, or from empire-wide settings.
|
||||
*
|
||||
* Columns:
|
||||
*
|
||||
* planet_id The planet's identifier
|
||||
* resource_name_id The type of resources
|
||||
* mset_weight The setting to use for mining priorities
|
||||
* mset_specific True if the settings are specific for this planet,
|
||||
* false if empire-wise settings are in use.
|
||||
*/
|
||||
DROP VIEW IF EXISTS emp.mining_settings_view CASCADE;
|
||||
CREATE VIEW emp.mining_settings_view
|
||||
AS SELECT planet_id , resource_name_id ,
|
||||
( CASE
|
||||
WHEN _pl_settings.planet_id IS NULL THEN
|
||||
_emp_settings.empmset_weight
|
||||
ELSE
|
||||
_pl_settings.emppmset_weight
|
||||
END ) AS mset_weight ,
|
||||
( _pl_settings.planet_id IS NOT NULL ) AS mset_specific
|
||||
FROM verse.resource_providers
|
||||
INNER JOIN emp.planets
|
||||
USING ( planet_id )
|
||||
INNER JOIN emp.mining_settings _emp_settings
|
||||
USING ( empire_id , resource_name_id )
|
||||
LEFT OUTER JOIN emp.planet_mining_settings _pl_settings
|
||||
USING ( planet_id , empire_id , resource_name_id );
|
||||
|
||||
GRANT SELECT
|
||||
ON emp.mining_settings_view
|
||||
TO :dbuser;
|
Reference in a new issue