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 @@
|
||||
-- admin_get_character_details(in_account_id bigint) -> TABLE(account_id bigint, player_id text, character_name text, online_status text, last_avatar_activity timestamp with time zone, class text, map text, transform dune.transform, server_id text, partition_id bigint, partition_label text, dimension_index integer, gas_attributes jsonb, properties jsonb, slot_name text, fgl_data text)
|
||||
-- oid: 58130 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_get_character_details(in_account_id bigint)
|
||||
RETURNS TABLE(account_id bigint, player_id text, character_name text, online_status text, last_avatar_activity timestamp with time zone, class text, map text, transform dune.transform, server_id text, partition_id bigint, partition_label text, dimension_index integer, gas_attributes jsonb, properties jsonb, slot_name text, fgl_data text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
return query SELECT player_state.account_id, accounts.user As player_id, player_state.character_name, CASE WHEN is_player_offline(accounts.user) THEN 'Offline' ELSE 'Online' END AS online_status, player_state.last_avatar_activity,
|
||||
actors.class, actors.map, actors.transform, player_state.server_id, actors.partition_id, world_partition.label, actors.dimension_index,
|
||||
actors.gas_attributes, actors.properties, actor_fgl_entities.slot_name,
|
||||
string_agg(cast(to_json((select d from (select fgl_entities.components) d)) as varchar), ', ') as fgl_data
|
||||
from fgl_entities
|
||||
left join actor_fgl_entities on fgl_entities.entity_id = actor_fgl_entities.entity_id
|
||||
left join actors on actor_fgl_entities.actor_id = actors.id
|
||||
left join player_state on player_state.player_pawn_id = actors.id
|
||||
left join accounts on accounts.id = player_state.account_id
|
||||
left join world_partition on world_partition.partition_id = actors.partition_id
|
||||
where player_state.account_id = in_account_id
|
||||
and actor_fgl_entities.slot_name = 'DuneCharacter'
|
||||
group by player_state.account_id, player_state.character_name, player_state.last_avatar_activity, accounts.user,
|
||||
actors.class, actors.map, actors.transform, player_state.server_id, actors.partition_id, world_partition.label, actors.dimension_index,
|
||||
actors.gas_attributes, actors.properties, actor_fgl_entities.slot_name;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- admin_get_character_ids(in_search_term text) -> TABLE(id bigint, "user" text, character_name text)
|
||||
-- oid: 58131 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_get_character_ids(in_search_term text)
|
||||
RETURNS TABLE(id bigint, "user" text, character_name text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
return query
|
||||
select accounts.id, accounts.user, player_state.character_name
|
||||
from accounts
|
||||
left join player_state on player_state.account_id = accounts.id
|
||||
where lower(accounts.user) like in_search_term or lower(player_state.character_name) like in_search_term;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,20 @@
|
||||
-- admin_get_inventory_details(in_account_id bigint) -> TABLE(inventory_id bigint, item_id bigint, stack_size integer, template_id text, acquisition_time bigint)
|
||||
-- oid: 58132 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_get_inventory_details(in_account_id bigint)
|
||||
RETURNS TABLE(inventory_id bigint, item_id bigint, stack_size integer, template_id text, acquisition_time bigint)
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select
|
||||
inventories.id as inventory_id, items.id as item_id, items.stack_size, items.template_id, items.acquisition_time
|
||||
from
|
||||
items
|
||||
left join
|
||||
inventories on inventories.id = items.inventory_id
|
||||
left join
|
||||
player_state on inventories.actor_id = player_state.player_pawn_id
|
||||
where
|
||||
player_state.account_id = in_account_id
|
||||
order by
|
||||
template_id;
|
||||
$function$
|
||||
@@ -0,0 +1,16 @@
|
||||
-- admin_get_journey_details(in_player_id text, in_story_node_id text) -> TABLE(out_story_node_id text, out_override_reward_block boolean, out_has_pending_reward boolean, out_complete_condition_state jsonb, out_reveal_condition_state jsonb, out_fail_condition_state jsonb, out_metadata_state jsonb, out_reset_group dune.journeystoryresetgroup)
|
||||
-- oid: 58133 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_get_journey_details(in_player_id text, in_story_node_id text DEFAULT '%%'::text)
|
||||
RETURNS TABLE(out_story_node_id text, out_override_reward_block boolean, out_has_pending_reward boolean, out_complete_condition_state jsonb, out_reveal_condition_state jsonb, out_fail_condition_state jsonb, out_metadata_state jsonb, out_reset_group dune.journeystoryresetgroup)
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select story_node_id, override_reward_block, has_pending_reward, complete_condition_state, reveal_condition_state, fail_condition_state, metadata_state, reset_group
|
||||
from journey_story_node
|
||||
where story_node_id like in_story_node_id
|
||||
and account_id in (
|
||||
select id
|
||||
from accounts a
|
||||
where a.user = in_player_id
|
||||
);
|
||||
$function$
|
||||
@@ -0,0 +1,9 @@
|
||||
-- admin_get_partitions() -> 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: 58135 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_get_partitions()
|
||||
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 sql
|
||||
AS $function$
|
||||
select * from load_partition_definition_map();
|
||||
$function$
|
||||
@@ -0,0 +1,26 @@
|
||||
-- admin_move_offline_player(in_fls_id text, in_target_partition_name text, in_target_location dune.vector) -> void
|
||||
-- oid: 58136 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_move_offline_player(in_fls_id text, in_target_partition_name text, in_target_location dune.vector)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
if not (select is_player_offline(in_fls_id)) then
|
||||
raise exception 'Player must be Offline';
|
||||
end if;
|
||||
|
||||
if not exists(select 1 from world_partition where label = in_target_partition_name) then
|
||||
raise exception 'Partition with name % not found', in_target_partition_name;
|
||||
end if;
|
||||
|
||||
perform (with target_partition as (
|
||||
select partition_id, map, dimension_index
|
||||
from world_partition
|
||||
where label = in_target_partition_name
|
||||
limit 1
|
||||
)
|
||||
select admin_move_offline_player_to_partition(in_fls_id, target_partition.partition_id, in_target_location)
|
||||
from target_partition);
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,48 @@
|
||||
-- admin_move_offline_player_to_partition(in_fls_id text, in_target_partition_id bigint, in_target_location dune.vector) -> void
|
||||
-- oid: 58137 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_move_offline_player_to_partition(in_fls_id text, in_target_partition_id bigint, in_target_location dune.vector)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
if not (select is_player_offline(in_fls_id)) then
|
||||
-- CAVEAT: DirectorDbApi.TryMoveOfflinePlayerToPartition depends on this string.
|
||||
raise exception 'Player must be Offline';
|
||||
end if;
|
||||
|
||||
if not exists(select 1 from world_partition where partition_id = in_target_partition_id) then
|
||||
raise exception 'Partition with ID % not found', in_target_partition_id;
|
||||
end if;
|
||||
|
||||
raise notice 'Moving player % to partition % location x=%, y=%, z=%', in_fls_id, in_target_partition_id, in_target_location.x, in_target_location.y, in_target_location.z;
|
||||
|
||||
with target_partition as (
|
||||
select partition_id, map, dimension_index
|
||||
from world_partition
|
||||
where partition_id = in_target_partition_id
|
||||
limit 1
|
||||
), target_pawn_id as (
|
||||
select player_state.player_pawn_id as id
|
||||
from accounts, player_state
|
||||
where accounts.user = in_fls_id and accounts.id = player_state.account_id
|
||||
limit 1
|
||||
), update_overmap_player_location as (
|
||||
select
|
||||
case
|
||||
when target_partition.map = 'Overmap' then overmap_save_player_survival_data(target_pawn_id.id, null, false, in_target_location)
|
||||
else null
|
||||
end
|
||||
from target_pawn_id, target_partition
|
||||
)
|
||||
update actors
|
||||
set
|
||||
transform = (in_target_location, (transform).rotation),
|
||||
map = upgrade_map_name(target_partition.map),
|
||||
dimension_index = target_partition.dimension_index,
|
||||
partition_id = target_partition.partition_id
|
||||
from
|
||||
target_pawn_id, target_partition, update_overmap_player_location
|
||||
where actors.id = target_pawn_id.id;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- admin_read_player_tags(in_account_id bigint) -> TABLE(tags text)
|
||||
-- oid: 58138 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.admin_read_player_tags(in_account_id bigint)
|
||||
RETURNS TABLE(tags text)
|
||||
LANGUAGE sql
|
||||
AS $function$
|
||||
select
|
||||
pt.tag
|
||||
from
|
||||
player_tags as pt
|
||||
where
|
||||
pt.account_id = in_account_id
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- dune_get_account_id_by_user(in_user text) -> bigint
|
||||
-- oid: 58257 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.dune_get_account_id_by_user(in_user text)
|
||||
RETURNS bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
account_id BIGINT;
|
||||
BEGIN
|
||||
SELECT INTO account_id id FROM accounts WHERE "user"=in_user;
|
||||
RETURN account_id;
|
||||
END $function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- fetch_resourcefield_state(in_map text, in_dimension_index integer, in_field_kind_id smallint) -> TABLE(field_id bigint, spawn_time double precision, value_remaining bigint)
|
||||
-- oid: 58260 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.fetch_resourcefield_state(in_map text, in_dimension_index integer, in_field_kind_id smallint)
|
||||
RETURNS TABLE(field_id bigint, spawn_time double precision, value_remaining bigint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT resourcefield_state.field_id, resourcefield_state.spawn_time, resourcefield_state.value_remaining
|
||||
FROM resourcefield_state
|
||||
WHERE map = in_map AND dimension_index = in_dimension_index AND field_kind_id = in_field_kind_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- fetch_server_spice_field_manifest(in_server_id text) -> TABLE(spicefield_type_id integer, inactive_fields_of_type integer, requested_spawned_of_type integer)
|
||||
-- oid: 58261 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.fetch_server_spice_field_manifest(in_server_id text)
|
||||
RETURNS TABLE(spicefield_type_id integer, inactive_fields_of_type integer, requested_spawned_of_type integer)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT t.spicefield_type_id, t.inactive_fields_of_type, t.requested_spawned_of_type
|
||||
FROM spicefield_server_availability as t
|
||||
WHERE t.server_id = in_server_id;
|
||||
END; $function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- fetch_spicefie_id_types_with_global_info(in_map_name text, in_dimension_index integer) -> TABLE(spicefield_type_id integer, max_globally_active integer, max_globally_primed integer, current_globally_active integer, current_globally_primed integer, is_spawning_active boolean, field_type text)
|
||||
-- oid: 58262 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.fetch_spicefie_id_types_with_global_info(in_map_name text, in_dimension_index integer)
|
||||
RETURNS TABLE(spicefield_type_id integer, max_globally_active integer, max_globally_primed integer, current_globally_active integer, current_globally_primed integer, is_spawning_active boolean, field_type text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT t.spicefield_type_id, t.max_globally_active, t.max_globally_primed, t.current_globally_active, t.current_globally_primed, t.is_spawning_active, t.field_type
|
||||
FROM spicefield_types as t
|
||||
WHERE t.map_name = in_map_name AND t.dimension_index = in_dimension_index;
|
||||
END; $function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_all_demo_players() -> TABLE(fls_ids text)
|
||||
-- oid: 58273 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_demo_players()
|
||||
RETURNS TABLE(fls_ids text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT fls_id
|
||||
FROM demo_users
|
||||
WHERE demo_playtime_seconds IS NOT NULL;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_all_guild_members() -> TABLE(player_id bigint, fls_id text, guild_id bigint)
|
||||
-- oid: 58275 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_guild_members()
|
||||
RETURNS TABLE(player_id bigint, fls_id text, guild_id bigint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT gm.player_id, acc.user, gm.guild_id
|
||||
FROM accounts acc
|
||||
LEFT JOIN player_state ps ON acc.id = ps.account_id
|
||||
RIGHT JOIN guild_members gm ON ps.player_controller_id = gm.player_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_all_online_or_recently_disconnected_player_online_state() -> SETOF dune.playeronlinestateentry
|
||||
-- oid: 58276 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_online_or_recently_disconnected_player_online_state()
|
||||
RETURNS SETOF dune.playeronlinestateentry
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT actors.id, player_state.character_name, (actors.map, actors.partition_id, actors.dimension_index)::ServerInfo, (player_state.last_avatar_activity AT TIME ZONE 'UTC')::TIMESTAMP, player_state.online_status
|
||||
FROM actors
|
||||
JOIN player_state ON player_state.player_controller_id = actors.id
|
||||
WHERE (player_state.online_status = 'Online'
|
||||
or player_state.last_avatar_activity > NOW() - INTERVAL '1 minutes' );
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,23 @@
|
||||
-- get_all_parties() -> TABLE(party_id bigint, player_id bigint, player_name text, party_leader_id bigint, platform_session_id text, platform_name text, platform_players_count integer)
|
||||
-- oid: 58277 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_parties()
|
||||
RETURNS TABLE(party_id bigint, player_id bigint, player_name text, party_leader_id bigint, platform_session_id text, platform_name text, platform_players_count integer)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT
|
||||
parties.party_id,
|
||||
party_members.player_id,
|
||||
player_state.character_name,
|
||||
parties.party_leader_id,
|
||||
platform_parties_mapping.platform_session_id,
|
||||
platform_parties_mapping.platform_name,
|
||||
platform_parties_mapping.num_of_players
|
||||
FROM party_members
|
||||
JOIN parties ON party_members.party_id = parties.party_id
|
||||
JOIN player_state ON player_state.player_controller_id = party_members.player_id
|
||||
LEFT JOIN platform_parties_mapping ON platform_parties_mapping.dune_party_id = parties.party_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- get_all_party_invites() -> TABLE(invite_id bigint, party_id bigint, sender_player_id bigint, sender_name text, player_id bigint, player_name text, invite_sent_timespan bigint)
|
||||
-- oid: 58278 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_party_invites()
|
||||
RETURNS TABLE(invite_id bigint, party_id bigint, sender_player_id bigint, sender_name text, player_id bigint, player_name text, invite_sent_timespan bigint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT party_invites.invite_id, party_invites.party_id, party_invites.sender_player_id, sender_player_state.character_name, party_invites.player_id, player_state.character_name, party_invites.invite_sent_timespan
|
||||
FROM party_invites
|
||||
JOIN player_state ON player_state.player_controller_id = party_invites.player_id
|
||||
JOIN player_state AS sender_player_state ON sender_player_state.player_controller_id = party_invites.sender_player_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_all_party_members() -> TABLE(player_id bigint, fls_id text, party_id bigint)
|
||||
-- oid: 58279 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_party_members()
|
||||
RETURNS TABLE(player_id bigint, fls_id text, party_id bigint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT pm.player_id, acc.user, pm.party_id
|
||||
FROM party_members pm
|
||||
LEFT JOIN player_state ps ON ps.player_controller_id = pm.player_id
|
||||
LEFT JOIN accounts acc ON acc.id = ps.account_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_all_player_character_home_dimensions() -> TABLE(fls_id text, home_dimension integer)
|
||||
-- oid: 58280 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_player_character_home_dimensions()
|
||||
RETURNS TABLE(fls_id text, home_dimension integer)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT accounts.user as fls_id, player_state.home_dimension_index as home_dimension
|
||||
FROM accounts
|
||||
LEFT JOIN player_state on player_state.account_id = accounts.id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_all_player_in_guild_online_state(in_guild_id bigint) -> SETOF dune.playeronlinestateentry
|
||||
-- oid: 58281 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_player_in_guild_online_state(in_guild_id bigint)
|
||||
RETURNS SETOF dune.playeronlinestateentry
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT actors.id, player_state.character_name, (actors.map, actors.partition_id, actors.dimension_index)::ServerInfo, (player_state.last_avatar_activity AT TIME ZONE 'UTC')::TIMESTAMP, player_state.online_status
|
||||
FROM actors
|
||||
JOIN player_state ON player_state.player_controller_id = actors.id
|
||||
JOIN guild_members ON guild_members.player_id = actors.id
|
||||
WHERE guild_members.guild_id = in_guild_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,12 @@
|
||||
-- get_all_player_travel_states() -> TABLE(fls_id text, login_target_dimension_index integer)
|
||||
-- oid: 58282 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_player_travel_states()
|
||||
RETURNS TABLE(fls_id text, login_target_dimension_index integer)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
BEGIN
|
||||
RETURN query SELECT pts.fls_id, pts.login_target_dimension_index FROM player_travel_state AS pts;
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,12 @@
|
||||
-- get_all_unresolved_character_imports() -> TABLE(flsid text, importstate dune.transferimportstate, lastupdatetime timestamp with time zone)
|
||||
-- oid: 58284 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_all_unresolved_character_imports()
|
||||
RETURNS TABLE(flsid text, importstate dune.transferimportstate, lastupdatetime timestamp with time zone)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT ti.fls_id, ti.transfer_state, ti.last_update
|
||||
FROM character_transfer_imports ti;
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,21 @@
|
||||
-- get_best_dungeon_completion(in_dungeon_id text) -> TABLE(out_difficulty integer, out_duration_ms integer, out_players_names text[])
|
||||
-- oid: 58287 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_best_dungeon_completion(in_dungeon_id text)
|
||||
RETURNS TABLE(out_difficulty integer, out_duration_ms integer, out_players_names text[])
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
RETURN QUERY SELECT
|
||||
d.difficulty,
|
||||
d.duration_ms,
|
||||
COALESCE((SELECT array_agg(COALESCE(ps.character_name, ''))
|
||||
FROM player_state as ps
|
||||
FULL JOIN dungeon_completion_players as dcp ON dcp.player_id = ps.player_controller_id
|
||||
WHERE dcp.completion_id = d.completion_id), ARRAY[]::TEXT[])
|
||||
FROM dungeon_completion as d
|
||||
WHERE d.dungeon_id = in_dungeon_id
|
||||
ORDER BY d.difficulty DESC, d.players_num ASC, d.duration_ms ASC, d.completion_id ASC
|
||||
LIMIT 1;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_best_dungeons_completions_for_player(in_player_id bigint) -> TABLE(out_dungeon_id text, out_difficulty integer, out_duration_ms integer, out_players_num smallint)
|
||||
-- oid: 58288 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_best_dungeons_completions_for_player(in_player_id bigint)
|
||||
RETURNS TABLE(out_dungeon_id text, out_difficulty integer, out_duration_ms integer, out_players_num smallint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
RETURN QUERY SELECT DISTINCT ON (d.dungeon_id) d.dungeon_id, d.difficulty, d.duration_ms, d.players_num
|
||||
FROM dungeon_completion as d
|
||||
INNER JOIN dungeon_completion_players as p ON p.completion_id = d.completion_id
|
||||
WHERE p.player_id = in_player_id
|
||||
ORDER BY d.dungeon_id, d.difficulty DESC, d.players_num ASC, d.duration_ms ASC, d.completion_id ASC;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- get_character_import_state(in_fls_id text) -> dune.transferimportstate
|
||||
-- oid: 58292 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_character_import_state(in_fls_id text)
|
||||
RETURNS dune.transferimportstate
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
v_state TransferImportState;
|
||||
BEGIN
|
||||
SELECT transfer_state INTO v_state FROM character_transfer_imports WHERE fls_id = in_fls_id;
|
||||
RETURN v_state;
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,11 @@
|
||||
-- get_learned_building_sets(in_account_id bigint) -> SETOF text
|
||||
-- oid: 58316 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_learned_building_sets(in_account_id bigint)
|
||||
RETURNS SETOF text
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT UNNEST(learned_building_sets) FROM building_progression WHERE account_id = in_account_id;
|
||||
END; $function$
|
||||
@@ -0,0 +1,11 @@
|
||||
-- get_learned_new_buildable_pieces(in_account_id bigint) -> SETOF text
|
||||
-- oid: 58317 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_learned_new_buildable_pieces(in_account_id bigint)
|
||||
RETURNS SETOF text
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT UNNEST(new_buildable_pieces) FROM building_progression WHERE account_id = in_account_id;
|
||||
END; $function$
|
||||
@@ -0,0 +1,30 @@
|
||||
-- get_login_journey_nodes(in_account_id bigint) -> dune.journeynodeinfo[]
|
||||
-- oid: 58318 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_login_journey_nodes(in_account_id bigint)
|
||||
RETURNS dune.journeynodeinfo[]
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
result JourneyNodeInfo[];
|
||||
BEGIN
|
||||
SELECT
|
||||
array_agg(
|
||||
(
|
||||
res.story_node_id,
|
||||
res.override_reward_block,
|
||||
res.has_pending_reward,
|
||||
res.complete_condition_state,
|
||||
res.reveal_condition_state,
|
||||
res.fail_condition_state,
|
||||
res.metadata_state,
|
||||
res.reset_group
|
||||
)::JourneyNodeInfo
|
||||
)
|
||||
INTO result
|
||||
FROM journey_story_node res
|
||||
WHERE res.account_id = in_account_id;
|
||||
|
||||
RETURN result;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,24 @@
|
||||
-- get_login_journey_nodes_cooldown(in_account_id bigint) -> dune.journeynodecooldowninfo[]
|
||||
-- oid: 58319 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_login_journey_nodes_cooldown(in_account_id bigint)
|
||||
RETURNS dune.journeynodecooldowninfo[]
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
result JourneyNodeCooldownInfo[];
|
||||
BEGIN
|
||||
SELECT
|
||||
array_agg(
|
||||
(
|
||||
res.story_node_id,
|
||||
res.time_to_expire
|
||||
)::JourneyNodeCooldownInfo
|
||||
)
|
||||
INTO result
|
||||
FROM journey_story_node_cooldown res
|
||||
WHERE res.account_id = in_account_id;
|
||||
|
||||
RETURN result;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- get_online_player_controller_ids(in_map text) -> SETOF bigint
|
||||
-- oid: 58321 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_online_player_controller_ids(in_map text)
|
||||
RETURNS SETOF bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
return query SELECT DISTINCT ps.player_controller_id
|
||||
FROM player_state ps
|
||||
JOIN actors a ON (a.id = ps.player_controller_id)
|
||||
WHERE ps.online_status = 'Online' AND a.map = in_map;
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- get_online_player_controller_ids_on_farm() -> SETOF bigint
|
||||
-- oid: 58322 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_online_player_controller_ids_on_farm()
|
||||
RETURNS SETOF bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
return query SELECT DISTINCT ps.player_controller_id
|
||||
FROM player_state ps
|
||||
JOIN actors a ON (a.id = ps.player_controller_id)
|
||||
WHERE ps.online_status = 'Online';
|
||||
END;
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_player_access_codes(in_account_id bigint) -> TABLE(access_code integer, access_code_type integer)
|
||||
-- oid: 58331 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_access_codes(in_account_id bigint)
|
||||
RETURNS TABLE(access_code integer, access_code_type integer)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT p.access_code, p.access_code_type
|
||||
FROM player_access_codes AS p
|
||||
WHERE p.account_id = in_account_id;
|
||||
END; $function$
|
||||
@@ -0,0 +1,16 @@
|
||||
-- get_player_guild_invites(in_player_id bigint) -> TABLE(invite_id bigint, guild_id bigint, guild_name text, guild_description text, sender_player_id bigint, invite_sent_timespan bigint, character_name text, sender_character_name text)
|
||||
-- oid: 58335 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_guild_invites(in_player_id bigint)
|
||||
RETURNS TABLE(invite_id bigint, guild_id bigint, guild_name text, guild_description text, sender_player_id bigint, invite_sent_timespan bigint, character_name text, sender_character_name text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT guild_invites.invite_id, guilds.guild_id, guilds.guild_name, guilds.guild_description, guild_invites.sender_player_id, guild_invites.invite_sent_timespan, player_state.character_name, sender_player_state.character_name AS sender_character_name
|
||||
FROM guild_invites
|
||||
JOIN guilds ON guilds.guild_id = guild_invites.guild_id
|
||||
JOIN player_state ON player_state.player_controller_id = guild_invites.player_id
|
||||
JOIN player_state AS sender_player_state ON sender_player_state.player_controller_id = guild_invites.sender_player_id
|
||||
WHERE player_id = in_player_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,14 @@
|
||||
-- get_player_ids_online_state(in_player_ids bigint[]) -> SETOF dune.playeronlinestateentry
|
||||
-- oid: 58336 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_ids_online_state(in_player_ids bigint[])
|
||||
RETURNS SETOF dune.playeronlinestateentry
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT actors.id, player_state.character_name, (actors.map, actors.partition_id, actors.dimension_index)::ServerInfo, (player_state.last_avatar_activity AT TIME ZONE 'UTC')::TIMESTAMP, player_state.online_status
|
||||
FROM actors
|
||||
JOIN player_state ON player_state.player_controller_id = actors.id
|
||||
WHERE actors.id = ANY(in_player_ids);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_player_infos_for_actor_ids(in_actor_ids bigint[]) -> TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
-- oid: 58337 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_infos_for_actor_ids(in_actor_ids bigint[])
|
||||
RETURNS TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT ps.player_controller_id, ps.character_name, acc.user, acc.funcom_id, acc.platform_id, acc.platform_name
|
||||
FROM accounts acc LEFT JOIN player_state ps ON acc.id=ps.account_id
|
||||
WHERE ps.player_controller_id = ANY(in_actor_ids);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_player_infos_for_character_names(in_character_names text[]) -> TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
-- oid: 58338 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_infos_for_character_names(in_character_names text[])
|
||||
RETURNS TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT ps.player_controller_id, ps.character_name, acc.user, acc.funcom_id, acc.platform_id, acc.platform_name
|
||||
FROM accounts acc LEFT JOIN player_state ps ON acc.id=ps.account_id
|
||||
WHERE ps.character_name = ANY(in_character_names);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_player_infos_for_fls_ids(in_fls_ids text[]) -> TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
-- oid: 58339 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_infos_for_fls_ids(in_fls_ids text[])
|
||||
RETURNS TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT ps.player_controller_id, ps.character_name, acc.user, acc.funcom_id, acc.platform_id, acc.platform_name
|
||||
FROM accounts acc LEFT JOIN player_state ps ON acc.id=ps.account_id
|
||||
WHERE acc.user = ANY(in_fls_ids);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,13 @@
|
||||
-- get_player_infos_for_funcom_ids(in_funcom_ids text[]) -> TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
-- oid: 58340 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_infos_for_funcom_ids(in_funcom_ids text[])
|
||||
RETURNS TABLE(player_id bigint, character_name text, fls_id text, funcom_id text, platform_id text, platform_name text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT ps.player_controller_id, ps.character_name, acc.user, acc.funcom_id, acc.platform_id, acc.platform_name
|
||||
FROM accounts acc LEFT JOIN player_state ps ON acc.id=ps.account_id
|
||||
WHERE acc.funcom_id = ANY(in_funcom_ids);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_player_online_state_within_grace_period_for_each_server() -> TABLE(fls_id text, previous_partition_id bigint, current_server_id text, online_status dune.playerconnectionstatus, within_grace_period boolean, last_disconnect timestamp without time zone, demo_playtime_seconds integer, logoff_persistence_end_time timestamp without time zone, party_id bigint)
|
||||
-- oid: 58341 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_online_state_within_grace_period_for_each_server()
|
||||
RETURNS TABLE(fls_id text, previous_partition_id bigint, current_server_id text, online_status dune.playerconnectionstatus, within_grace_period boolean, last_disconnect timestamp without time zone, demo_playtime_seconds integer, logoff_persistence_end_time timestamp without time zone, party_id bigint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT accounts.user as fls_id, player_state.previous_server_partition_id as previous_partition_id, player_state.server_id as current_server_id, player_state.online_status as online_status, player_state.reconnect_grace_period_end > (now() AT TIME ZONE 'UTC')::TIMESTAMP as within_grace_period, (player_state.last_avatar_activity AT TIME ZONE 'UTC')::TIMESTAMP as last_disconnect, demo_users.demo_playtime_seconds, (player_state.logoff_persistence_end_time)::TIMESTAMP as logoff_persistence_end_time, party_members.party_id
|
||||
FROM player_state
|
||||
LEFT JOIN accounts ON accounts.id = player_state.account_id
|
||||
LEFT JOIN demo_users ON accounts.user = demo_users.fls_id
|
||||
LEFT JOIN party_members ON player_state.player_controller_id = party_members.player_id;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,18 @@
|
||||
-- get_player_partition_id(in_fls_id text) -> bigint
|
||||
-- oid: 58343 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_partition_id(in_fls_id text)
|
||||
RETURNS bigint
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
-- Only the player pawn actually travels and gets it's partition id updated
|
||||
return (
|
||||
select actors.partition_id
|
||||
from accounts as acc
|
||||
join player_state as ps on ps.account_id = acc.id
|
||||
join actors on actors.id = ps.player_pawn_id
|
||||
where acc.user = in_fls_id
|
||||
);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_player_pawn(in_account_id bigint) -> TABLE(description dune.actordescription, server_info dune.serverinfo, player_tags text[])
|
||||
-- oid: 58344 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_player_pawn(in_account_id bigint)
|
||||
RETURNS TABLE(description dune.actordescription, server_info dune.serverinfo, player_tags text[])
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
return query
|
||||
with id as (select player_pawn_id as id from player_state where account_id = in_account_id limit 1),
|
||||
tags as (select array_agg(tag) from player_tags where account_id = in_account_id)
|
||||
select load_full_actors(array[id]) as description, get_actor_server_info(id) as server_info, (select * from tags) as player_tags
|
||||
from id limit 1;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,15 @@
|
||||
-- get_players_demo_data(in_controller_ids bigint[]) -> SETOF dune.playerdemostatedescription
|
||||
-- oid: 58346 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_players_demo_data(in_controller_ids bigint[])
|
||||
RETURNS SETOF dune.playerdemostatedescription
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT ps.player_controller_id, (ps.last_avatar_activity AT TIME ZONE 'UTC')::TIMESTAMP, demo_playtime_seconds, demo_state
|
||||
FROM encrypted_accounts acc
|
||||
JOIN player_state ps ON ps.account_id = acc.id
|
||||
JOIN demo_users du ON acc.user = du.fls_id
|
||||
WHERE ps.player_controller_id = ANY (in_controller_ids);
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,16 @@
|
||||
-- get_traveling_actor_id_and_types(in_actor_id bigint) -> TABLE(id bigint, is_instigator boolean, is_player boolean, level integer)
|
||||
-- oid: 58357 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_traveling_actor_id_and_types(in_actor_id bigint)
|
||||
RETURNS TABLE(id bigint, is_instigator boolean, is_player boolean, level integer)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
return query
|
||||
select t.id, t.is_instigator, (ps.player_pawn_id is not null) as is_player, t.level
|
||||
from get_traveling_actor_ids(in_actor_id) as t
|
||||
left join player_state as ps
|
||||
on t.id = ps.player_pawn_id
|
||||
order by t.level, t.id;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,35 @@
|
||||
-- get_traveling_actor_ids(in_actor_id bigint, in_max_recursion_level integer) -> TABLE(id bigint, is_instigator boolean, level integer)
|
||||
-- oid: 58358 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_traveling_actor_ids(in_actor_id bigint, in_max_recursion_level integer DEFAULT 5)
|
||||
RETURNS TABLE(id bigint, is_instigator boolean, level integer)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
return query
|
||||
with recursive
|
||||
-- go down the dependency tree and gather all the parents
|
||||
p(id, lvl) AS (
|
||||
select a.id, 0
|
||||
from actors as a
|
||||
where (in_actor_id = a.id)
|
||||
union all
|
||||
select ap.parent_id, (p.lvl - 1)
|
||||
from p, travel_actor_parent as ap
|
||||
where (p.id = ap.id) and (p.lvl > -in_max_recursion_level)
|
||||
),
|
||||
-- find the most distant parent (root)
|
||||
r as (
|
||||
select * from p order by p.lvl limit 1
|
||||
),
|
||||
-- go up the tree from the root and gather all the children
|
||||
t(id, ins, lvl) as (
|
||||
select r.id, true, 0 from r
|
||||
union all
|
||||
select ap.id, ap.is_instigator, (t.lvl + 1)
|
||||
from t, travel_actor_parent as ap
|
||||
where (t.id = ap.parent_id) and (t.lvl < 2 * in_max_recursion_level)
|
||||
)
|
||||
select * from t order by t.lvl, id;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,17 @@
|
||||
-- get_traveling_actors_fls_ids(in_actor_id bigint) -> TABLE(out_id text)
|
||||
-- oid: 58359 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_traveling_actors_fls_ids(in_actor_id bigint)
|
||||
RETURNS TABLE(out_id text)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
return query
|
||||
select a.user
|
||||
from get_traveling_actor_ids(in_actor_id) as t
|
||||
inner join player_state as ps
|
||||
on t.id = ps.player_pawn_id
|
||||
inner join accounts as a
|
||||
on a.id = ps.account_id;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,21 @@
|
||||
-- get_traveling_non_player_actor_ids(in_actor_id bigint) -> TABLE(id bigint)
|
||||
-- oid: 58360 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.get_traveling_non_player_actor_ids(in_actor_id bigint)
|
||||
RETURNS TABLE(id bigint)
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
begin
|
||||
return query
|
||||
select t.id
|
||||
from get_traveling_actor_ids(in_actor_id) as t
|
||||
left join player_state as ps
|
||||
on t.id = ps.player_pawn_id
|
||||
left join travel_actor_parent as ap
|
||||
on ap.id = in_actor_id
|
||||
where
|
||||
ps.player_pawn_id is null
|
||||
and ap.is_instigator is true
|
||||
order by t.level, t.id;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,17 @@
|
||||
-- is_player_guild_admin(in_player_id bigint, in_guild_id bigint) -> boolean
|
||||
-- oid: 58393 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.is_player_guild_admin(in_player_id bigint, in_guild_id bigint)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
found_role_id SMALLINT;
|
||||
BEGIN
|
||||
SELECT role_id FROM guild_members WHERE player_id = in_player_id AND guild_id = in_guild_id INTO found_role_id;
|
||||
IF NOT FOUND THEN
|
||||
RETURN FALSE;
|
||||
END IF;
|
||||
RETURN found_role_id = 100;
|
||||
END
|
||||
$function$
|
||||
@@ -0,0 +1,37 @@
|
||||
-- is_player_offline(in_fls_id text) -> boolean
|
||||
-- oid: 58394 kind: FUNCTION category: lookup
|
||||
-- comment: Return true if player is marked as offline, taking into account server crashing before players online state was updated in DB.
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.is_player_offline(in_fls_id text)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
declare
|
||||
has_state int;
|
||||
is_offline boolean;
|
||||
begin
|
||||
-- If there's no player_state row for this account, treat the player as offline
|
||||
select count(*) into has_state
|
||||
from player_state ps
|
||||
join accounts a on a.id = ps.account_id
|
||||
where a.user = in_fls_id;
|
||||
|
||||
if has_state = 0 then
|
||||
return true;
|
||||
end if;
|
||||
|
||||
select exists(
|
||||
select 1
|
||||
from player_state ps
|
||||
join accounts a on a.id = ps.account_id
|
||||
where a.user = in_fls_id
|
||||
and (
|
||||
ps.online_status = 'Offline'
|
||||
-- Player is treated as offline if last played server is offline/unavailable, or not set at all
|
||||
or (ps.server_id is null or ps.server_id not in (select * from active_server_ids))
|
||||
)
|
||||
) into is_offline;
|
||||
|
||||
return is_offline;
|
||||
end
|
||||
$function$
|
||||
@@ -0,0 +1,17 @@
|
||||
-- is_player_party_leader(in_player_id bigint, in_party_id bigint) -> boolean
|
||||
-- oid: 58395 kind: FUNCTION category: lookup
|
||||
|
||||
CREATE OR REPLACE FUNCTION dune.is_player_party_leader(in_player_id bigint, in_party_id bigint)
|
||||
RETURNS boolean
|
||||
LANGUAGE plpgsql
|
||||
AS $function$
|
||||
DECLARE
|
||||
found_leader_id SMALLINT;
|
||||
BEGIN
|
||||
SELECT party_leader_id FROM parties WHERE party_id = in_party_id INTO found_leader_id;
|
||||
IF NOT FOUND THEN
|
||||
RETURN FALSE;
|
||||
END IF;
|
||||
RETURN found_leader_id = in_player_id;
|
||||
END
|
||||
$function$
|
||||
Reference in New Issue
Block a user