Emmanuel BENOîT
56eddcc4f0
* 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
61 lines
No EOL
1.7 KiB
PL/PgSQL
61 lines
No EOL
1.7 KiB
PL/PgSQL
-- LegacyWorlds Beta 6
|
|
-- PostgreSQL database scripts
|
|
--
|
|
-- Game updates - abandon
|
|
--
|
|
-- Copyright(C) 2004-2010, DeepClone Development
|
|
-- --------------------------------------------------------
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION sys.process_planet_abandon_updates( c_tick BIGINT )
|
|
RETURNS VOID
|
|
STRICT VOLATILE
|
|
SECURITY INVOKER
|
|
AS $$
|
|
DECLARE
|
|
p_id INT;
|
|
BEGIN
|
|
-- Lock all records
|
|
PERFORM p.name_id
|
|
FROM sys.updates su
|
|
INNER JOIN verse.planets_updates vu
|
|
USING ( update_id , updtype_id , updtgt_id )
|
|
INNER JOIN verse.planets p
|
|
USING ( name_id )
|
|
INNER JOIN emp.planets ep
|
|
ON ep.planet_id = p.name_id
|
|
INNER JOIN emp.empires e
|
|
ON e.name_id = ep.empire_id
|
|
INNER JOIN emp.abandon a
|
|
ON a.planet_id = p.name_id
|
|
WHERE su.update_last = c_tick AND su.update_state = 'PROCESSING'
|
|
FOR UPDATE;
|
|
|
|
-- Handle planets where time has run out
|
|
FOR p_id IN SELECT p.name_id
|
|
FROM sys.updates su
|
|
INNER JOIN verse.planets_updates vu
|
|
USING ( update_id , updtype_id , updtgt_id )
|
|
INNER JOIN verse.planets p
|
|
USING ( name_id )
|
|
INNER JOIN emp.abandon a ON a.planet_id = p.name_id
|
|
WHERE su.update_last = c_tick AND su.update_state = 'PROCESSING'
|
|
AND a.time_left = 1
|
|
LOOP
|
|
PERFORM emp.leave_planet( p_id );
|
|
END LOOP;
|
|
|
|
-- Update all abandon records
|
|
UPDATE emp.abandon a SET time_left = a.time_left - 1
|
|
FROM sys.updates su
|
|
INNER JOIN verse.planets_updates vu
|
|
USING ( update_id , updtype_id , updtgt_id )
|
|
WHERE su.update_last = c_tick AND su.update_state = 'PROCESSING'
|
|
AND a.planet_id = vu.name_id;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
SELECT sys.register_update_type( 'Planets' , 'PlanetAbandon' ,
|
|
'Planets are being abandoned.' ,
|
|
'process_planet_abandon_updates'
|
|
); |