docs(reference): import Dune: Awakening server-manager references
Phase 2 references for the host-agent Dune adapter, moved out of volatile /tmp
into docs/reference-repos/ (per Commander). Three upstream projects, .git +
node_modules + compiled binaries stripped (16MB source). Nested AI-instruction
files (.claude/, CLAUDE.md) removed so they don't pollute Corrosion sessions.
- icehunter/ dune-admin (Go+React) — 4 control planes; SETUP_DOCKER.md is the
closest analog to our agent's Dune docker control plane (compose
lifecycle, docker logs, RabbitMQ-via-exec, dune Postgres schema)
- adainrivers/ Rust/Tauri desktop — SSH+k8s BattleGroup control, maintenance
daemon, in-game admin console (Rust idiom reference)
- the4rchangel/ Node web UI replacing battlegroup.bat — matches the Commander's
Hyper-V self-host path + game-config schema
See docs/reference-repos/README.md for the full index + how we use each.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- add_partition_unique(in_map text, in_definition jsonb, in_dimension bigint, in_label text) -> bigint
|
||||
-- oid: 58127 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.add_partition_unique(in_map text, in_definition jsonb, in_dimension bigint, in_label text DEFAULT NULL::text)
|
||||
RETURNS bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
v_partition_id bigint;
|
||||
BEGIN
|
||||
-- Don't use a constraint right now, this is only a dev-only helper function.
|
||||
-- We could add a constraint, but would need to check the performance of constraint on the jsonb field.
|
||||
insert into world_partition (map, partition_definition, dimension_index, label)
|
||||
select in_map, in_definition, in_dimension, in_label
|
||||
where not exists (
|
||||
select 1 from world_partition where map = in_map and partition_definition = in_definition and dimension_index = in_dimension
|
||||
) returning partition_id into v_partition_id;
|
||||
return v_partition_id;
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,162 @@
|
||||
-- determine_partition_label(in_map text, in_dimension_index integer, in_label text, in_allow_overwrite boolean, in_partition_id bigint) -> text
|
||||
-- oid: 58234 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.determine_partition_label(in_map text, in_dimension_index integer, in_label text DEFAULT NULL::text, in_allow_overwrite boolean DEFAULT true, in_partition_id bigint DEFAULT NULL::bigint)
|
||||
RETURNS text
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
result_label TEXT := in_label;
|
||||
tmp_count INTEGER;
|
||||
tmp_box_max_x TEXT;
|
||||
tmp_box_max_y TEXT;
|
||||
tmp_box_min_x TEXT;
|
||||
tmp_box_min_y TEXT;
|
||||
BEGIN
|
||||
-- If label is provided and we don't want to overwrite, return it
|
||||
IF result_label IS NOT NULL AND in_allow_overwrite = FALSE THEN
|
||||
RETURN result_label;
|
||||
END IF;
|
||||
|
||||
CASE in_map
|
||||
WHEN 'SH_HarkoVillage' THEN return 'HarkoVillage' || '_' || in_dimension_index;
|
||||
WHEN 'SH_Arrakeen' THEN return 'Arrakeen' || '_' || in_dimension_index;
|
||||
WHEN 'SH_FallenLight' THEN return 'FallenLight' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Story_Hephaestus' THEN return 'WreckOfHephaestus' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Story_Ecolab_Carthag' THEN return 'BeneathCarthag' || '_' || in_dimension_index;
|
||||
WHEN 'CB_SurvivalChallenge_Station_15' THEN return 'Station15' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Story_WaterFatManor' THEN return 'WaterFat' || '_' || in_dimension_index;
|
||||
WHEN 'Story_ProcesVerbal' THEN return 'ProcesVerbal' || '_' || in_dimension_index;
|
||||
WHEN 'DLC_Story_LostHarvest' THEN return 'LostHarvest' || '_' || in_dimension_index;
|
||||
WHEN 'DLC_Story_LostHarvest_EcolabA' THEN return 'LostHarvest_EcolabA' || '_' || in_dimension_index;
|
||||
WHEN 'DLC_Story_LostHarvest_EcolabB' THEN return 'LostHarvest_EcolabB' || '_' || in_dimension_index;
|
||||
WHEN 'DLC_Story_LostHarvest_ForgottenLab' THEN return 'LostHarvest_ForgottenLab' || '_' || in_dimension_index;
|
||||
WHEN 'Story_ArtOfKanly' THEN return 'ArtOfKanly' || '_' || in_dimension_index;
|
||||
WHEN 'Story_HeighlinerDungeon' THEN return 'HeighlinerDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Dungeon_Hephaestus' THEN return 'WreckOfHephaestusDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Dungeon_OldCarthag' THEN return 'OldCarthagDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Story_BanditFortress01' THEN return 'SandfliesFortress' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Overland_S_05' THEN return 'ClosedOffTestingStationIsland' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Overland_S_06' THEN return 'GroundVehicleTimeTrialIsland' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Overland_S_04' THEN return 'ErythriteCaveIsland' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Overland_M_01' THEN return 'RadioactiveShipwreck' || '_' || in_dimension_index;
|
||||
WHEN 'Story_Faction_Outpost_Hark' THEN return 'Story_Faction_Outpost_Hark' || '_' || in_dimension_index;
|
||||
WHEN 'Story_Faction_Outpost_Atre' THEN return 'Story_Faction_Outpost_Atre' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Ecolab_Bronze_Green_089' THEN return 'RadiationDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Ecolab_Bronze_Green_152' THEN return 'ElectricityDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Ecolab_Bronze_Green_195' THEN return 'PoisonDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Ecolab_Bronze_Green_024' THEN return 'DarknessDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Ecolab_Bronze_Green_136' THEN return 'FireDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Overland_S_07' THEN return 'TheRuinsOfTsimpo' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Story_DestroyedZanovar' THEN return 'DestroyedZanovar' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Story_OrbitalMonitor' THEN return 'OrbitalMonitor' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Dungeon_TheFacility' THEN return 'FacilityDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'CB_Dungeon_ThePit' THEN return 'PitDungeon' || '_' || in_dimension_index;
|
||||
WHEN 'Overmap' THEN
|
||||
IF in_dimension_index = 0 THEN
|
||||
return 'Overland';
|
||||
END IF;
|
||||
WHEN 'Survival_1' THEN
|
||||
CASE in_dimension_index
|
||||
WHEN 0 THEN return 'Abbir';
|
||||
WHEN 1 THEN return 'Alraab';
|
||||
WHEN 2 THEN return 'Barkan';
|
||||
WHEN 3 THEN return 'Coanua';
|
||||
WHEN 4 THEN return 'Fajr Kulon';
|
||||
WHEN 5 THEN return 'Gara';
|
||||
WHEN 6 THEN return 'Hajar';
|
||||
WHEN 7 THEN return 'Jacurutu';
|
||||
WHEN 8 THEN return 'Kathib';
|
||||
WHEN 9 THEN return 'Legg';
|
||||
WHEN 10 THEN return 'Makab';
|
||||
WHEN 11 THEN return 'Nadir';
|
||||
WHEN 12 THEN return 'Ramal';
|
||||
WHEN 13 THEN return 'Rifana';
|
||||
WHEN 14 THEN return 'Sandrat';
|
||||
WHEN 15 THEN return 'Saajid';
|
||||
WHEN 16 THEN return 'Tabr Sink';
|
||||
WHEN 17 THEN return 'Tharwa';
|
||||
WHEN 18 THEN return 'Umbu';
|
||||
WHEN 19 THEN return 'Yaracuwan';
|
||||
WHEN 20 THEN return 'al-Mut';
|
||||
WHEN 21 THEN return 'Altuyur';
|
||||
WHEN 22 THEN return 'Ammit';
|
||||
WHEN 23 THEN return 'Ashia';
|
||||
WHEN 24 THEN return 'Eaqrab';
|
||||
WHEN 25 THEN return 'Hagga';
|
||||
WHEN 26 THEN return 'Hua';
|
||||
WHEN 27 THEN return 'Katal';
|
||||
WHEN 28 THEN return 'Khafash';
|
||||
WHEN 29 THEN return 'Matar';
|
||||
WHEN 30 THEN return 'Rabie';
|
||||
WHEN 31 THEN return 'Rajifiri';
|
||||
WHEN 32 THEN return 'Remmel';
|
||||
WHEN 33 THEN return 'Sahr';
|
||||
WHEN 34 THEN return 'Saqer';
|
||||
WHEN 35 THEN return 'Ta''lab';
|
||||
WHEN 36 THEN return 'Tarl';
|
||||
WHEN 37 THEN return 'Tasmin Sink';
|
||||
WHEN 38 THEN return 'Thueban';
|
||||
WHEN 39 THEN return 'Tuono';
|
||||
ELSE
|
||||
return 'Survival' || '_' || in_dimension_index;
|
||||
END CASE;
|
||||
ELSE
|
||||
-- Do nothing
|
||||
END CASE;
|
||||
|
||||
-- DeepDesert per-partition handling: if all 9 partitions exist, assign based on ordering
|
||||
IF in_map = 'DeepDesert_1' THEN
|
||||
SELECT count(*) INTO tmp_count FROM world_partition WHERE map = 'DeepDesert_1' AND dimension_index = in_dimension_index;
|
||||
IF tmp_count = 9 AND in_partition_id IS NOT NULL THEN
|
||||
RETURN (
|
||||
WITH chess_notation AS (
|
||||
SELECT label, ROW_NUMBER() OVER (ORDER BY null) AS row_num
|
||||
FROM (select * from UNNEST(ARRAY['A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3']) as label) as label_list
|
||||
),
|
||||
partitions AS (
|
||||
SELECT partition_id, ROW_NUMBER() OVER (
|
||||
order by
|
||||
coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'max_x',
|
||||
coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'max_y',
|
||||
coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'min_x',
|
||||
coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'min_y'
|
||||
) AS row_num
|
||||
FROM world_partition
|
||||
where map = 'DeepDesert_1' AND dimension_index = in_dimension_index
|
||||
)
|
||||
SELECT 'DeepDesert_' || cn.label
|
||||
FROM chess_notation cn
|
||||
JOIN partitions p ON cn.row_num = p.row_num
|
||||
WHERE p.partition_id = in_partition_id
|
||||
LIMIT 1
|
||||
);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF in_partition_id IS NOT NULL THEN
|
||||
SELECT coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'max_x', coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'max_y', coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'min_x', coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'min_y'
|
||||
INTO tmp_box_max_x, tmp_box_max_y, tmp_box_min_x, tmp_box_min_y
|
||||
FROM world_partition
|
||||
WHERE partition_id = in_partition_id
|
||||
LIMIT 1;
|
||||
|
||||
IF tmp_box_max_x IS NOT NULL AND tmp_box_max_x IN ('1.0','1') AND tmp_box_max_y IN ('1.0','1') AND tmp_box_min_x IN ('0.0','0') AND tmp_box_min_y IN ('0.0','0') THEN
|
||||
RETURN upgrade_map_name(in_map) || '_' || in_dimension_index;
|
||||
END IF;
|
||||
ELSE
|
||||
-- If we don't have a partition id, try to read any partition for that map/dimension
|
||||
SELECT coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'max_x', coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'max_y', coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'min_x', coalesce(partition_definition->'box', partition_definition->'boxes'->0)->>'min_y'
|
||||
INTO tmp_box_max_x, tmp_box_max_y, tmp_box_min_x, tmp_box_min_y
|
||||
FROM world_partition
|
||||
WHERE map = in_map AND dimension_index = in_dimension_index
|
||||
LIMIT 1;
|
||||
|
||||
IF tmp_box_max_x IS NOT NULL AND tmp_box_max_x IN ('1.0','1') AND tmp_box_max_y IN ('1.0','1') AND tmp_box_min_x IN ('0.0','0') AND tmp_box_min_y IN ('0.0','0') THEN
|
||||
RETURN upgrade_map_name(in_map) || '_' || in_dimension_index;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
RETURN NULL;
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,17 @@
|
||||
-- determine_partition_label_trigger() -> trigger
|
||||
-- oid: 58236 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.determine_partition_label_trigger()
|
||||
RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
IF NEW.label IS NULL THEN
|
||||
UPDATE world_partition
|
||||
SET label = determine_partition_label(NEW.map, NEW.dimension_index, NULL, false)
|
||||
WHERE partition_id = NEW.partition_id;
|
||||
END IF;
|
||||
|
||||
RETURN NULL; -- AFTER ROW trigger does not need to return a row
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,12 @@
|
||||
-- get_partition_presets() -> SETOF text
|
||||
-- oid: 58323 kind: FUNCTION category: partition
|
||||
-- comment: Adds a partition only if its unique. Not using constraints, as this is only a helper function.
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_partition_presets()
|
||||
RETURNS SETOF text
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
return query SELECT routine_name::text as preset_function FROM information_schema.routines WHERE routine_type = 'FUNCTION' and routine_name ilike 'initialize_partitions_%';
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,11 @@
|
||||
-- get_partitions(in_map text) -> SETOF bigint
|
||||
-- oid: 58324 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_partitions(in_map text)
|
||||
RETURNS SETOF bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
SELECT partition_id FROM world_partition where map = in_map order by partition_id ASC;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,9 @@
|
||||
-- igwo_delete_world_partitions(in_partition_ids bigint[]) -> void
|
||||
-- oid: 58369 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_delete_world_partitions(in_partition_ids bigint[])
|
||||
RETURNS void
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
delete from world_partition where partition_id = any(in_partition_ids);
|
||||
$function$
|
||||
@@ -0,0 +1,9 @@
|
||||
-- igwo_get_partition_id_seq_last_value() -> bigint
|
||||
-- oid: 58370 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_get_partition_id_seq_last_value()
|
||||
RETURNS bigint
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select last_value from world_partition_partition_id_seq;
|
||||
$function$
|
||||
@@ -0,0 +1,9 @@
|
||||
-- igwo_get_partition_ids() -> SETOF bigint
|
||||
-- oid: 58371 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_get_partition_ids()
|
||||
RETURNS SETOF bigint
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select partition_id from world_partition order by partition_id asc;
|
||||
$function$
|
||||
@@ -0,0 +1,19 @@
|
||||
-- igwo_get_partitions() -> TABLE(partition_id bigint, map text, dimension_index integer, label text, min_x double precision, min_y double precision, max_x double precision, max_y double precision)
|
||||
-- oid: 58372 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_get_partitions()
|
||||
RETURNS TABLE(partition_id bigint, map text, dimension_index integer, label text, min_x double precision, min_y double precision, max_x double precision, max_y double precision)
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
SELECT
|
||||
partition_id,
|
||||
map,
|
||||
dimension_index,
|
||||
label,
|
||||
(partition_definition->'box'->>'min_x')::float8,
|
||||
(partition_definition->'box'->>'min_y')::float8,
|
||||
(partition_definition->'box'->>'max_x')::float8,
|
||||
(partition_definition->'box'->>'max_y')::float8
|
||||
FROM world_partition
|
||||
ORDER BY partition_id ASC;
|
||||
$function$
|
||||
@@ -0,0 +1,16 @@
|
||||
-- igwo_insert_world_partition(in_partition_id bigint, in_map text, in_partition_definition jsonb, in_dimension_index integer, in_partition_label text) -> bigint
|
||||
-- oid: 58374 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_insert_world_partition(in_partition_id bigint, in_map text, in_partition_definition jsonb, in_dimension_index integer DEFAULT 0, in_partition_label text DEFAULT NULL::text)
|
||||
RETURNS bigint
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
insert into world_partition(partition_id, map, partition_definition, dimension_index, label)
|
||||
values (
|
||||
in_partition_id,
|
||||
in_map,
|
||||
in_partition_definition,
|
||||
in_dimension_index,
|
||||
coalesce(in_partition_label, determine_partition_label(in_map, in_dimension_index, null, false, in_partition_id)))
|
||||
returning partition_id;
|
||||
$function$
|
||||
@@ -0,0 +1,9 @@
|
||||
-- igwo_next_partition_id_seq() -> bigint
|
||||
-- oid: 58375 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_next_partition_id_seq()
|
||||
RETURNS bigint
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select nextval('world_partition_partition_id_seq');
|
||||
$function$
|
||||
@@ -0,0 +1,9 @@
|
||||
-- igwo_notify_world_partition_update() -> void
|
||||
-- oid: 58376 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_notify_world_partition_update()
|
||||
RETURNS void
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
notify world_partition_update;
|
||||
$function$
|
||||
@@ -0,0 +1,12 @@
|
||||
-- igwo_restart_partition_id_seq(in_restart_with bigint) -> void
|
||||
-- oid: 58377 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_restart_partition_id_seq(in_restart_with bigint)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
-- Use execute to substitute the numeric parameter into the alter sequence command
|
||||
execute format('alter sequence world_partition_partition_id_seq restart with %s', in_restart_with);
|
||||
end;
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- igwo_update_world_partition(in_map text, in_partition_definition jsonb, in_partition_id bigint, in_dimension_index integer, in_label text) -> void
|
||||
-- oid: 58378 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.igwo_update_world_partition(in_map text, in_partition_definition jsonb, in_partition_id bigint, in_dimension_index integer, in_label text DEFAULT NULL::text)
|
||||
RETURNS void
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
update world_partition
|
||||
set map = in_map,
|
||||
partition_definition = in_partition_definition,
|
||||
dimension_index = in_dimension_index,
|
||||
label = coalesce(in_label, label)
|
||||
where partition_id = in_partition_id;
|
||||
$function$
|
||||
@@ -0,0 +1,21 @@
|
||||
-- initialize_partitions_basic_battlegroup() -> void
|
||||
-- oid: 58380 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_basic_battlegroup()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('SH_HarkoVillage', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('SH_HarkoVillage', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('SH_Arrakeen', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('SH_Arrakeen', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('DeepDesert_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('DeepDesert_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('DeepDesert_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 2);
|
||||
perform add_partition_unique('Overmap', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform update_partition_labels();
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- initialize_partitions_basic_survival_1() -> void
|
||||
-- oid: 58381 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_basic_survival_1()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 2);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 3);
|
||||
perform update_partition_labels();
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,22 @@
|
||||
-- initialize_partitions_development_battlegroup() -> void
|
||||
-- oid: 58382 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_development_battlegroup()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
-- Current battlegroup maps
|
||||
perform initialize_partitions_full_battlegroup();
|
||||
|
||||
-- Core development maps
|
||||
perform initialize_partitions_editor_default_1x1();
|
||||
perform initialize_partitions_igw_test_small_2x2();
|
||||
perform initialize_partitions_igw_training();
|
||||
|
||||
-- Additional Gyms
|
||||
perform add_partition_unique('CombatGym_01', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0, 'CombatGym_01');
|
||||
perform add_partition_unique('Audio_Gym', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0, 'Audio_Gym');
|
||||
perform add_partition_unique('CombatGym_Camps', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0, 'CombatGym_Camps');
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,11 @@
|
||||
-- initialize_partitions_editor_default_1x1() -> void
|
||||
-- oid: 58383 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_editor_default_1x1()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
perform add_partition_unique('Editor_Default', '{"type": "box2d_array", "boxes": [{"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}]}', 0, 'Editor_Default');
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,73 @@
|
||||
-- initialize_partitions_full_battlegroup() -> void
|
||||
-- oid: 58384 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_full_battlegroup()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 2);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 3);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 4);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 5);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 6);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 7);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 8);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 9);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 10);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 11);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 12);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 13);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 14);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 15);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 16);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 17);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 18);
|
||||
perform add_partition_unique('Survival_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 19);
|
||||
perform add_partition_unique('SH_HarkoVillage', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('SH_HarkoVillage', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('SH_Arrakeen', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('SH_Arrakeen', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('SH_FallenLight', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('SH_FallenLight', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('CB_Story_Hephaestus', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Story_Ecolab_Carthag', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Story_WaterFatManor', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('DeepDesert_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('DeepDesert_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('DeepDesert_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 2);
|
||||
perform add_partition_unique('Overmap', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Story_ProcesVerbal', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('DLC_Story_LostHarvest', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('DLC_Story_LostHarvest_EcolabA', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('DLC_Story_LostHarvest_EcolabB', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('DLC_Story_LostHarvest_ForgottenLab', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Story_ArtOfKanly', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Story_HeighlinerDungeon', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Dungeon_Hephaestus', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Dungeon_OldCarthag', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Story_BanditFortress01', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Overland_S_05', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Overland_S_06', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Overland_S_04', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Overland_M_01', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Overland_S_07', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Story_Faction_Outpost_Hark', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('Story_Faction_Outpost_Atre', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Ecolab_Bronze_Green_089', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Ecolab_Bronze_Green_152', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Ecolab_Bronze_Green_195', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Ecolab_Bronze_Green_024', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Ecolab_Bronze_Green_136', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('PolarCap_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('PolarCap_1', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 1);
|
||||
perform add_partition_unique('CB_Story_DestroyedZanovar', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Story_OrbitalMonitor', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Dungeon_TheFacility', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Dungeon_ThePit', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform add_partition_unique('CB_Overland_S_08', '{"box": {"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0}, "type": "box2d_array"}', 0);
|
||||
perform update_partition_labels();
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,12 @@
|
||||
-- initialize_partitions_igw_test_small_2x1() -> void
|
||||
-- oid: 58385 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_igw_test_small_2x1()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
perform add_partition_unique('IGW_Test_Small', '{"type": "box2d_array", "boxes": [{"max_x": 0.5, "max_y": 1, "min_x": 0, "min_y": 0}]}', 0, 'IGW_Test_Small_A1');
|
||||
perform add_partition_unique('IGW_Test_Small', '{"type": "box2d_array", "boxes": [{"max_x": 1, "max_y": 1, "min_x": 0.5, "min_y": 0}]}', 0, 'IGW_Test_Small_A2');
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- initialize_partitions_igw_test_small_2x2() -> void
|
||||
-- oid: 58386 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_igw_test_small_2x2()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
perform add_partition_unique('IGW_Test_Small', '{"type": "box2d_array", "boxes": [{"max_x": 0.5, "max_y": 0.5, "min_x": 0, "min_y": 0}]}', 0, 'IGW_Test_Small_A1');
|
||||
perform add_partition_unique('IGW_Test_Small', '{"type": "box2d_array", "boxes": [{"max_x": 0.5, "max_y": 1, "min_x": 0, "min_y": 0.5}]}', 0, 'IGW_Test_Small_A2');
|
||||
perform add_partition_unique('IGW_Test_Small', '{"type": "box2d_array", "boxes": [{"max_x": 1, "max_y": 0.5, "min_x": 0.5, "min_y": 0}]}', 0, 'IGW_Test_Small_B1');
|
||||
perform add_partition_unique('IGW_Test_Small', '{"type": "box2d_array", "boxes": [{"max_x": 1, "max_y": 1, "min_x": 0.5, "min_y": 0.5}]}', 0, 'IGW_Test_Small_B2');
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- initialize_partitions_igw_training() -> void
|
||||
-- oid: 58387 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_partitions_igw_training()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
perform add_partition_unique('IGW_Training', '{"type": "box2d_array", "boxes": [{"max_x": 1, "max_y": 0.33333, "min_x": 0, "min_y": 0}]}', 0, 'IGW_Training_A1');
|
||||
perform add_partition_unique('IGW_Training', '{"type": "box2d_array", "boxes": [{"max_x": 1, "max_y": 0.66667, "min_x": 0, "min_y": 0.33333}]}', 0, 'IGW_Training_A2');
|
||||
perform add_partition_unique('IGW_Training', '{"type": "box2d_array", "boxes": [{"max_x": 1, "max_y": 1, "min_x": 0, "min_y": 0.66667}]}', 0, 'IGW_Training_A3');
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,19 @@
|
||||
-- initialize_world_partition(in_map_name text, in_num_servers integer, in_dimension_index integer) -> SETOF bigint
|
||||
-- oid: 58389 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.initialize_world_partition(in_map_name text, in_num_servers integer, in_dimension_index integer DEFAULT 0)
|
||||
RETURNS SETOF bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
BEGIN
|
||||
return query
|
||||
with _cleanup as (
|
||||
DELETE FROM world_partition WHERE map = in_map_name and dimension_index = in_dimension_index
|
||||
)
|
||||
INSERT INTO world_partition (map, partition_definition, dimension_index, label)
|
||||
select in_map_name, format('{"type": "cell_index", "index": %s}', generate_series)::JSONB, in_dimension_index, in_map_name || '_' || in_dimension_index || '_' || generate_series
|
||||
from generate_series(0, in_num_servers - 1)
|
||||
returning partition_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- load_partition_definition_map() -> TABLE(out_partition_id bigint, out_server_id text, out_partition_definition jsonb, out_dimension_index integer, out_blocked boolean, out_label text, out_map text)
|
||||
-- oid: 58459 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.load_partition_definition_map()
|
||||
RETURNS TABLE(out_partition_id bigint, out_server_id text, out_partition_definition jsonb, out_dimension_index integer, out_blocked boolean, out_label text, out_map text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT wp.partition_id, active_server_ids.server_id AS server_id, wp.partition_definition,
|
||||
wp.dimension_index, wp.blocked, wp.label, wp.map
|
||||
FROM world_partition as wp
|
||||
LEFT JOIN active_server_ids
|
||||
ON active_server_ids.server_id = wp.server_id;
|
||||
END; $function$
|
||||
@@ -0,0 +1,39 @@
|
||||
-- load_world_partition(in_map_name text, in_server_id text, in_desired_dimension_index bigint, in_desired_partition_id bigint) -> TABLE(partition_id bigint, partition_definition jsonb, dimension_index integer, blocked boolean, label text)
|
||||
-- oid: 58468 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.load_world_partition(in_map_name text, in_server_id text, in_desired_dimension_index bigint DEFAULT 0, in_desired_partition_id bigint DEFAULT NULL::bigint)
|
||||
RETURNS TABLE(partition_id bigint, partition_definition jsonb, dimension_index integer, blocked boolean, label text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
tmp_partition RECORD;
|
||||
BEGIN
|
||||
-- First check if the server already have a partition assigned
|
||||
SELECT INTO tmp_partition wp.partition_id, wp.partition_definition, wp.dimension_index, wp.blocked, wp.label
|
||||
FROM world_partition wp
|
||||
WHERE server_id = in_server_id AND wp.map = in_map_name AND wp.dimension_index = in_desired_dimension_index;
|
||||
IF tmp_partition.partition_id IS NOT NULL THEN
|
||||
RETURN QUERY SELECT tmp_partition.partition_id, tmp_partition.partition_definition, tmp_partition.dimension_index, tmp_partition.blocked, tmp_partition.label;
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
-- No partition assigned, so try to find an unassigned partition for this server
|
||||
SELECT INTO tmp_partition wp.partition_id, wp.partition_definition, wp.dimension_index, wp.blocked, wp.label
|
||||
FROM world_partition wp
|
||||
WHERE (server_id IS NULL OR server_id NOT IN (SELECT * FROM active_server_ids)) AND wp.map = in_map_name AND wp.dimension_index = in_desired_dimension_index
|
||||
ORDER BY (wp.partition_id = in_desired_partition_id) DESC, wp.partition_definition->'type', wp.partition_definition->'index', wp.partition_definition->'box'->'min_x', wp.partition_definition->'box'->'min_y'
|
||||
LIMIT 1
|
||||
FOR UPDATE SKIP LOCKED;
|
||||
IF tmp_partition.partition_id IS NULL THEN
|
||||
RETURN;
|
||||
ELSE
|
||||
-- Fake a server
|
||||
INSERT INTO farm_state(server_id, farm_id, outgoing_s2s_connections, incoming_s2s_connections, connected_players, igw_addr, igw_port, game_addr, game_port, map, revision)
|
||||
VALUES (in_server_id, '0', 0, 0, 0, '0.0.0.0', 0, '0.0.0.0', 0, '', 0) ON CONFLICT DO NOTHING;
|
||||
UPDATE world_partition SET server_id = in_server_id WHERE world_partition.partition_id = tmp_partition.partition_id;
|
||||
NOTIFY world_partition_update;
|
||||
RETURN QUERY SELECT tmp_partition.partition_id, tmp_partition.partition_definition, tmp_partition.dimension_index, tmp_partition.blocked, tmp_partition.label;
|
||||
RETURN;
|
||||
END IF;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,17 @@
|
||||
-- save_world_partition(in_map_name text, in_server_id text, in_dimension_index bigint, in_partition_definition jsonb, in_blocked boolean, in_label text) -> bigint
|
||||
-- oid: 58575 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.save_world_partition(in_map_name text, in_server_id text, in_dimension_index bigint, in_partition_definition jsonb, in_blocked boolean DEFAULT false, in_label text DEFAULT NULL::text)
|
||||
RETURNS bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
partition_id BIGINT;
|
||||
BEGIN
|
||||
LOCK TABLE world_partition; -- only one at a time, please
|
||||
INSERT INTO world_partition(partition_id, server_id, map, partition_definition, dimension_index, blocked, label) VALUES(DEFAULT, in_server_id, in_map_name, in_partition_definition, in_dimension_index, in_blocked, in_label)
|
||||
ON CONFLICT ("server_id", "map") DO UPDATE set partition_definition = in_partition_definition, blocked = in_blocked, label = in_label WHERE world_partition.server_id = in_server_id
|
||||
RETURNING world_partition.partition_id INTO partition_id;
|
||||
RETURN partition_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,20 @@
|
||||
-- unassign_partition(in_server_id text) -> boolean
|
||||
-- oid: 58614 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.unassign_partition(in_server_id text)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
v_affected_rows BigInt;
|
||||
BEGIN
|
||||
UPDATE world_partition SET server_id = null WHERE server_id = in_server_id;
|
||||
get diagnostics v_affected_rows = ROW_COUNT;
|
||||
|
||||
-- If we didn't actually unassign anything, we have no need to trigger the notification (as nothing changed)
|
||||
if v_affected_rows > 0 then
|
||||
NOTIFY world_partition_update;
|
||||
return true;
|
||||
end if;
|
||||
return false;
|
||||
END $function$
|
||||
@@ -0,0 +1,36 @@
|
||||
-- update_partition_labels(in_allow_overwrite boolean) -> void
|
||||
-- oid: 58627 kind: FUNCTION category: partition
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.update_partition_labels(in_allow_overwrite boolean DEFAULT true)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
-- Compute candidate labels per-partition using the helper and apply them where appropriate
|
||||
UPDATE world_partition wp
|
||||
SET label = sub.new_label
|
||||
FROM (
|
||||
SELECT partition_id, determine_partition_label(map, dimension_index, label, in_allow_overwrite, partition_id) AS new_label
|
||||
FROM world_partition
|
||||
) AS sub
|
||||
WHERE wp.partition_id = sub.partition_id
|
||||
AND (wp.label IS NULL OR in_allow_overwrite = true)
|
||||
AND sub.new_label IS NOT NULL;
|
||||
|
||||
-- The default is `MAP_DIMENSION`
|
||||
-- Only set it for map, dimension combos that have a single partition (label must be unique), and for labels not already touched
|
||||
UPDATE world_partition SET label = map || '_' || dimension_index
|
||||
from (
|
||||
select grouping.partition_ids[1] as partition_id
|
||||
from (
|
||||
select count(*) as count, array_agg(partition_id) as partition_ids
|
||||
from world_partition
|
||||
group by map, dimension_index
|
||||
) as grouping
|
||||
where grouping.count = 1
|
||||
) as partition
|
||||
where
|
||||
world_partition.partition_id = partition.partition_id
|
||||
and label is null;
|
||||
END;
|
||||
$function$
|
||||
Reference in New Issue
Block a user