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,25 @@
|
||||
-- change_player_faction(in_player_id bigint, in_faction_id smallint, neutral_faction_id smallint, in_utc_time_faction_change timestamp without time zone) -> void
|
||||
-- oid: 58157 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.change_player_faction(in_player_id bigint, in_faction_id smallint, neutral_faction_id smallint, in_utc_time_faction_change timestamp without time zone)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
found_role_id SMALLINT;
|
||||
BEGIN
|
||||
|
||||
if in_faction_id = neutral_faction_id THEN
|
||||
DELETE FROM player_faction WHERE actor_id = in_player_id;
|
||||
|
||||
PERFORM pg_notify('faction_notify_channel', format('remove_player#{"PlayerId" : %s}', in_player_id));
|
||||
ELSE
|
||||
INSERT INTO player_faction(actor_id, faction_id, utc_time_faction_change) VALUES(in_player_id, in_faction_id, in_utc_time_faction_change)
|
||||
ON CONFLICT (actor_id) DO UPDATE SET faction_id = in_faction_id, utc_time_faction_change = in_utc_time_faction_change;
|
||||
|
||||
PERFORM pg_notify('faction_notify_channel', format('add_player#{"PlayerId" : %s, "FactionId" : %s}', in_player_id, in_faction_id));
|
||||
END IF;
|
||||
|
||||
PERFORM handle_player_faction_guild_effects(in_player_id, in_faction_id, neutral_faction_id);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,23 @@
|
||||
-- clean_guild_invites_with_incompatible_faction(in_player_id bigint, in_faction_id smallint, neutral_faction_id smallint) -> void
|
||||
-- oid: 58166 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.clean_guild_invites_with_incompatible_faction(in_player_id bigint, in_faction_id smallint, neutral_faction_id smallint)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
row_record record; -- Variable to hold individual rows
|
||||
out_guild_faction_id SMALLINT;
|
||||
BEGIN
|
||||
PERFORM guilds_get_exclusive_operation_lock();
|
||||
|
||||
FOR row_record IN
|
||||
SELECT invite_id, guild_invites.guild_id, guilds.guild_faction FROM get_player_guild_invites(in_player_id) as guild_invites
|
||||
JOIN guilds ON guilds.guild_id = guild_invites.guild_id
|
||||
LOOP
|
||||
IF row_record.guild_faction != neutral_faction_id AND in_faction_id != neutral_faction_id AND row_record.guild_faction != in_faction_id THEN
|
||||
PERFORM reject_guild_invite(row_record.invite_id);
|
||||
END IF;
|
||||
END LOOP;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_all_faction_members() -> TABLE(player_id bigint, fls_id text, faction_id smallint)
|
||||
-- oid: 58274 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_faction_members()
|
||||
RETURNS TABLE(player_id bigint, fls_id text, faction_id smallint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT ps.player_controller_id as player_id, acc.user as fls_id, f.faction_id
|
||||
FROM accounts acc
|
||||
LEFT JOIN player_state ps ON acc.id = ps.account_id
|
||||
RIGHT JOIN player_faction f ON ps.player_controller_id = f.actor_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,19 @@
|
||||
-- get_player_current_faction_reputation(in_actor_id bigint, OUT out_faction_id smallint, OUT out_reputation_amount integer) -> record
|
||||
-- oid: 58332 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_current_faction_reputation(in_actor_id bigint, OUT out_faction_id smallint, OUT out_reputation_amount integer)
|
||||
RETURNS record
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
SELECT
|
||||
pf.faction_id,
|
||||
COALESCE(pfr.reputation_amount, 0)
|
||||
INTO out_faction_id, out_reputation_amount
|
||||
FROM player_faction pf
|
||||
LEFT JOIN player_faction_reputation pfr
|
||||
ON pfr.actor_id = pf.actor_id AND pfr.faction_id = pf.faction_id
|
||||
WHERE pf.actor_id = in_actor_id
|
||||
limit 1;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,21 @@
|
||||
-- get_player_faction(in_player_id bigint, in_neutral_faction_id smallint) -> smallint
|
||||
-- oid: 58333 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_faction(in_player_id bigint, in_neutral_faction_id smallint)
|
||||
RETURNS smallint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
player_faction_id SMALLINT;
|
||||
BEGIN
|
||||
SELECT player_faction.faction_id INTO player_faction_id
|
||||
FROM player_faction
|
||||
WHERE actor_id = in_player_id;
|
||||
|
||||
IF player_faction_id IS NULL THEN
|
||||
player_faction_id := in_neutral_faction_id;
|
||||
END IF;
|
||||
|
||||
RETURN player_faction_id;
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_player_faction_name(in_actor_id bigint, OUT player_faction_name text, OUT utc_time_faction_change timestamp without time zone) -> record
|
||||
-- oid: 58334 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_faction_name(in_actor_id bigint, OUT player_faction_name text, OUT utc_time_faction_change timestamp without time zone)
|
||||
RETURNS record
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
SELECT factions.name, player_faction.utc_time_faction_change AT TIME ZONE 'UTC' INTO player_faction_name, utc_time_faction_change
|
||||
FROM factions INNER JOIN player_faction ON factions.id = player_faction.faction_id
|
||||
WHERE player_faction.actor_id = in_actor_id
|
||||
limit 1;
|
||||
END; $function$
|
||||
@@ -0,0 +1,32 @@
|
||||
-- handle_player_faction_guild_effects(in_player_id bigint, in_faction_id smallint, neutral_faction_id smallint) -> void
|
||||
-- oid: 58368 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.handle_player_faction_guild_effects(in_player_id bigint, in_faction_id smallint, neutral_faction_id smallint)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
guild_member_record record;
|
||||
BEGIN
|
||||
PERFORM guilds_get_exclusive_operation_lock();
|
||||
|
||||
SELECT * INTO guild_member_record
|
||||
FROM guild_members
|
||||
JOIN guilds ON guilds.guild_id = guild_members.guild_id
|
||||
WHERE player_id = in_player_id;
|
||||
|
||||
IF guild_member_record IS NOT NULL THEN
|
||||
PERFORM pg_notify('guild_notify_channel', format('player_guild_data_changed#{"GuildId" : %s , "PlayerId" : %s, "FactionId" : %s}', guild_member_record.guild_id, in_player_id, in_faction_id));
|
||||
IF guild_member_record.guild_faction != neutral_faction_id THEN
|
||||
-- If guild leader changes faction and guild already has a non neutral faction, break the guild allegiance
|
||||
IF is_player_guild_admin(in_player_id, guild_member_record.guild_id) THEN
|
||||
PERFORM break_guild_allegiance(guild_member_record.guild_id, neutral_faction_id);
|
||||
-- Neutral player changing to Faction A while Guild is Faction B must be kicked
|
||||
ELSEIF guild_member_record.guild_faction != in_faction_id AND in_faction_id != neutral_faction_id THEN
|
||||
PERFORM remove_guild_members(ARRAY[in_player_id], guild_member_record.guild_id, 2::smallint);
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
PERFORM clean_guild_invites_with_incompatible_faction(in_player_id, in_faction_id, neutral_faction_id);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,19 @@
|
||||
-- register_new_factions(factions text[]) -> TABLE(faction_id smallint, faction_name text)
|
||||
-- oid: 58508 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.register_new_factions(factions text[])
|
||||
RETURNS TABLE(faction_id smallint, faction_name text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
found_role_id SMALLINT;
|
||||
BEGIN
|
||||
-- Lock the factions table to prevent concurrent modifications. This is only done once on server start up.
|
||||
LOCK TABLE factions IN SHARE ROW EXCLUSIVE MODE;
|
||||
WITH new_factions AS (
|
||||
SELECT f FROM UNNEST(factions) f LEFT JOIN factions ON f = factions.name WHERE id IS NULL
|
||||
)
|
||||
INSERT INTO factions (name) SELECT * FROM new_factions ON CONFLICT DO NOTHING;
|
||||
RETURN QUERY SELECT * from factions;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- set_player_faction_reputation(in_actor_id bigint, in_faction_id smallint, in_reputation_amount integer) -> void
|
||||
-- oid: 58594 kind: FUNCTION category: faction
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.set_player_faction_reputation(in_actor_id bigint, in_faction_id smallint, in_reputation_amount integer)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
INSERT INTO player_faction_reputation (actor_id, faction_id, reputation_amount)
|
||||
VALUES (in_actor_id, in_faction_id, in_reputation_amount)
|
||||
ON CONFLICT (actor_id, faction_id)
|
||||
DO UPDATE
|
||||
SET reputation_amount = EXCLUDED.reputation_amount;
|
||||
END
|
||||
$function$
|
||||
Reference in New Issue
Block a user