Production adjustment fix
* The production adjustment function was completely off (and always has been). It has been fixed. * The problem with the adjustment function not being reported means that no-one ever encountered it. As a consequence, happiness strike threshold has been increased to 50% /!\ Full database reset required (or at least much easier than other options).
This commit is contained in:
parent
c94958a058
commit
afa1224391
4 changed files with 95 additions and 8 deletions
legacyworlds-server-data/db-structure/parts/040-functions
|
@ -301,21 +301,45 @@ $$ LANGUAGE plpgsql;
|
|||
|
||||
|
||||
|
||||
--
|
||||
-- Production adjustment
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION verse.adjust_production( prod REAL , happiness REAL )
|
||||
/*
|
||||
* Production adjustment
|
||||
* ----------------------
|
||||
*
|
||||
* Adjust productions depending on a planet's happiness ratio. When the
|
||||
* happiness ratio is greater than the game.happiness.strike constant, the
|
||||
* production is not affected. However, under that threshold, the production
|
||||
* decreases proportionally, until it reaches 0.
|
||||
*
|
||||
* Parameters:
|
||||
* _prod The production's valule
|
||||
* _h_ratio The happiness ratio
|
||||
*
|
||||
* Returns:
|
||||
* ? The adjusted production value
|
||||
*/
|
||||
DROP FUNCTION IF EXISTS verse.adjust_production( REAL , REAL ) CASCADE;
|
||||
CREATE OR REPLACE FUNCTION verse.adjust_production( _prod REAL , _h_ratio REAL )
|
||||
RETURNS REAL
|
||||
LANGUAGE SQL
|
||||
STRICT IMMUTABLE
|
||||
SECURITY INVOKER
|
||||
AS $$
|
||||
AS $adjust_production$
|
||||
|
||||
SELECT ( CASE
|
||||
WHEN $2 < sys.get_constant( 'game.happiness.strike' ) THEN
|
||||
( $1 * ( 1 - ( $2 / sys.get_constant( 'game.happiness.strike' ) ) ) )::REAL
|
||||
( $1 * $2 / sys.get_constant( 'game.happiness.strike' ) )::REAL
|
||||
ELSE
|
||||
$1
|
||||
END );
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
$adjust_production$;
|
||||
|
||||
REVOKE EXECUTE
|
||||
ON FUNCTION verse.adjust_production( REAL , REAL )
|
||||
FROM PUBLIC;
|
||||
GRANT EXECUTE
|
||||
ON FUNCTION verse.adjust_production( REAL , REAL )
|
||||
TO :dbuser;
|
||||
|
||||
|
||||
--
|
||||
|
|
Reference in a new issue