Empire mining settings
* Modified mining settings stored procedures to use text identifiers instead of numeric identifiers * Added DAO for mining settings and controller for resource operations * Added UpdateEmpireMiningSettingsCommand and associated command delegate. The command always returns NullResponse. * Overview page templates split into multiple files for clarity, added priority update form to the empire economy view and associated web server handler
This commit is contained in:
parent
92dd01ffce
commit
d38576a5cf
24 changed files with 1024 additions and 160 deletions
legacyworlds-server-data/db-structure/parts/040-functions
|
@ -29,15 +29,17 @@ BEGIN
|
|||
|
||||
CREATE TEMPORARY TABLE mset_update(
|
||||
empire_id INT ,
|
||||
resource_name_id INT ,
|
||||
resource_name TEXT ,
|
||||
empmset_weight INT
|
||||
) ON COMMIT DROP;
|
||||
|
||||
INSERT INTO mset_update
|
||||
SELECT _mset.empire_id , _mset.resource_name_id , 2
|
||||
SELECT _mset.empire_id , _str.name , 2
|
||||
FROM emp.empires _empire
|
||||
INNER JOIN emp.mining_settings _mset
|
||||
ON _empire.name_id = _mset.empire_id
|
||||
INNER JOIN defs.strings _str
|
||||
ON _str.id = _mset.resource_name_id
|
||||
WHERE _empire.name_id = _empire_id
|
||||
FOR SHARE OF _empire
|
||||
FOR UPDATE OF _mset;
|
||||
|
@ -81,7 +83,7 @@ BEGIN
|
|||
CREATE TEMPORARY TABLE mset_update(
|
||||
empire_id INT ,
|
||||
planet_id INT ,
|
||||
resource_name_id INT ,
|
||||
resource_name TEXT ,
|
||||
empmset_weight INT
|
||||
) ON COMMIT DROP;
|
||||
|
||||
|
@ -106,8 +108,10 @@ BEGIN
|
|||
FOR UPDATE;
|
||||
|
||||
INSERT INTO mset_update
|
||||
SELECT _empire_id , _planet_id , resource_name_id , 2
|
||||
SELECT _empire_id , _planet_id , _str.name , 2
|
||||
FROM verse.resource_providers
|
||||
INNER JOIN defs.strings _str
|
||||
ON _str.id = resource_name_id
|
||||
WHERE planet_id = _planet_id;
|
||||
|
||||
RETURN TRUE;
|
||||
|
@ -131,14 +135,14 @@ GRANT EXECUTE
|
|||
* must be called after emp.mset_update_start() has initialised the table.
|
||||
*
|
||||
* Parameters:
|
||||
* _resource_id The resource's identifier
|
||||
* _resource The resource's text identifier
|
||||
* _weight The setting's new value
|
||||
*
|
||||
* Returns:
|
||||
* ? True if the resource exists, false otherwise.
|
||||
*/
|
||||
DROP FUNCTION IF EXISTS emp.mset_update_set( INT , INT );
|
||||
CREATE FUNCTION emp.mset_update_set( _resource_id INT , _weight INT )
|
||||
DROP FUNCTION IF EXISTS emp.mset_update_set( TEXT , INT );
|
||||
CREATE FUNCTION emp.mset_update_set( _resource TEXT , _weight INT )
|
||||
RETURNS BOOLEAN
|
||||
STRICT VOLATILE
|
||||
SECURITY DEFINER
|
||||
|
@ -147,7 +151,7 @@ BEGIN
|
|||
|
||||
UPDATE mset_update
|
||||
SET empmset_weight = _weight
|
||||
WHERE resource_name_id = _resource_id;
|
||||
WHERE resource_name = _resource;
|
||||
RETURN FOUND;
|
||||
|
||||
END;
|
||||
|
@ -155,10 +159,10 @@ $mset_update_set$ LANGUAGE PLPGSQL;
|
|||
|
||||
|
||||
REVOKE EXECUTE
|
||||
ON FUNCTION emp.mset_update_set( INT , INT )
|
||||
ON FUNCTION emp.mset_update_set( TEXT , INT )
|
||||
FROM PUBLIC;
|
||||
GRANT EXECUTE
|
||||
ON FUNCTION emp.mset_update_set( INT , INT )
|
||||
ON FUNCTION emp.mset_update_set( TEXT , INT )
|
||||
TO :dbuser;
|
||||
|
||||
|
||||
|
@ -201,8 +205,10 @@ BEGIN
|
|||
empire_id , planet_id , resource_name_id ,
|
||||
emppmset_weight
|
||||
) SELECT empire_id , planet_id ,
|
||||
resource_name_id , empmset_weight
|
||||
FROM mset_update;
|
||||
_str.id , empmset_weight
|
||||
FROM mset_update
|
||||
INNER JOIN defs.strings _str
|
||||
ON _str.name = resource_name;
|
||||
|
||||
EXCEPTION
|
||||
|
||||
|
@ -211,8 +217,10 @@ BEGIN
|
|||
UPDATE emp.mining_settings _settings
|
||||
SET empmset_weight = _update.empmset_weight
|
||||
FROM mset_update _update
|
||||
INNER JOIN defs.strings _str
|
||||
ON _str.name = _update.resource_name
|
||||
WHERE _update.empire_id = _settings.empire_id
|
||||
AND _update.resource_name_id = _settings.resource_name_id;
|
||||
AND _str.id = _settings.resource_name_id;
|
||||
END;
|
||||
RETURN TRUE;
|
||||
|
||||
|
|
Reference in a new issue