Skip to content

Commit dfeb6c1

Browse files
committed
ENHANCEMENTS:
- Mission: new commands /airbase info, /airbase atis, /airbase warehouse and /airbase capture - server.yaml: new parameter show_atis. If true, an ATIS display will be sent to people that jump in slots. CHANGES: - Removed Side.SPECTATOR in favor of Side.NEUTRAL - Renamed /mission atis to /airbase atis - Profiler: disables max_hung_minutes now when enabled
1 parent ea48220 commit dfeb6c1

File tree

31 files changed

+1182
-265
lines changed

31 files changed

+1182
-265
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,13 @@ DEFAULT:
459459
4) ...
460460
accept_rules_on_join: true # True, if rules have to be acknowledged (players will be moved to spectators otherwise, default: false)
461461
My Fancy Server: # Your server name, as displayed in the server list and listed in serverSettings.lua
462+
channels:
463+
status: 1122334455667788 # The Discord channel to display the server status embed and players embed into. Right-click on your channel and select "Copy Channel ID". You can disable it with -1
464+
chat: 8877665544332211 # The Discord channel for the in-game chat replication. You can disable it by setting it to -1.
465+
events: 1928374619283746 # Optional: if you want to split game events from chat messages, you can enable an optional events channel.
466+
admin: 1188227733664455 # Optional: The channel where you can fire admin commands to this server. You can decide if you want to have a central admin channel or server-specific ones. See bot.yaml for more.
467+
voice: 1827364518273645 # Optional: The voice channel, where people need to connect to (mandatory if force_voice is true).
468+
audit: 9182736459182736 # Optional: a server-specific audit channel (for those of you who like channels, all others can use the global one)
462469
server_user: Admin # Name of the server user #1 (technical user), default is "Admin".
463470
show_passwords: true # Do you want the password to be displayed in the server status embed? (default: true)
464471
smooth_pause: 5 # Servers that are configured to PAUSE on startup will run for this number of seconds until they are paused again (default 0 = off)
@@ -468,19 +475,13 @@ My Fancy Server: # Your server name, as displayed in the server l
468475
validate_missions: true # Check if your missions can be loaded or not (missing maps, etc.). Default: true.
469476
ignore_dirs: # Optional: ignore directories from mission upload / mission add (already ignored are .dcssb, Scripts and Saves)
470477
- archive
471-
autorole: Fancy Players # Optional: give people this role if they are online on this server (overwrites autorole[online] in bot.yaml!).
478+
autorole: Fancy Players # Optional: give people this role if they are online on this server (overwrites autorole/online in bot.yaml!).
479+
show_atis: true # Optional: show ATIS information on BIRTH
472480
force_voice: false # Optional: enforce the usage of a voice channel (users need to be linked!) - default: false
473481
discord: # Optional: specify discord roles that are allowed to use this server
474482
- '@everyone' # Attention: people cannot self-link on these servers and have to be liked properly already!
475483
managed_by:
476484
- Special Admin # Optional: a list of Discord roles that can manage this server (default: DCS Admin)
477-
channels:
478-
status: 1122334455667788 # The Discord channel to display the server status embed and players embed into. Right-click on your channel and select "Copy Channel ID". You can disable it with -1
479-
chat: 8877665544332211 # The Discord channel for the in-game chat replication. You can disable it by setting it to -1.
480-
events: 1928374619283746 # Optional: if you want to split game events from chat messages, you can enable an optional events channel.
481-
admin: 1188227733664455 # Optional: The channel where you can fire admin commands to this server. You can decide if you want to have a central admin channel or server-specific ones. See bot.yaml for more.
482-
voice: 1827364518273645 # Optional: The voice channel, where people need to connect to (mandatory if force_voice is true).
483-
audit: 9182736459182736 # Optional: a server-specific audit channel (for those of you who like channels, all others can use the global one)
484485
chat_log:
485486
count: 10 # A log file that holds the in-game chat to check for abuse. Tells how many files will be kept, default is 10.
486487
size: 1048576 # Max logfile size, default is 1 MB.

core/data/const.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212

1313
class Side(Enum):
1414
UNKNOWN = -1
15-
SPECTATOR = 0
15+
NEUTRAL = 0
1616
RED = 1
1717
BLUE = 2
18-
NEUTRAL = 3
1918

2019

2120
class Status(Enum):

core/data/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class Server(DataObject, ABC):
5858
last_seen: datetime = field(compare=False, default=datetime.now(timezone.utc))
5959
restart_time: datetime = field(compare=False, default=None)
6060
idle_since: datetime | None = field(compare=False, default=None)
61+
resources: dict = field(repr=False, default_factory=dict)
6162

6263
def __post_init__(self):
6364
super().__post_init__()

core/report/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ async def render(self, *args, **kwargs) -> ReportEnv:
8080
env.params['bot'] = self.bot
8181

8282
# Create an embed with optional color
83-
embed_color = getattr(discord.Color, report_def.get('color', 'blue'), discord.Color.blue)()
83+
embed_color = getattr(discord.Color, utils.format_string(report_def.get('color', 'blue'), **env.params),
84+
discord.Color.blue)()
8485
env.embed = discord.Embed(color=embed_color)
8586

8687
# Predefine keys that need formatting and apply transformations

core/utils/dcs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"dms_to_dd",
2929
"dd_to_mgrs",
3030
"mgrs_to_dd",
31+
"rad_to_heading",
3132
"get_active_runways",
3233
"create_writable_mission",
3334
"get_orig_file",
@@ -310,7 +311,12 @@ def mgrs_to_dd(value: str) -> tuple[float, float]:
310311
return ll_coords['lat'], ll_coords['lon']
311312

312313

313-
def get_active_runways(runways, wind):
314+
def rad_to_heading(rad: float) -> float:
315+
"""Return a heading in [0, 360) degrees for a radian value."""
316+
return (360.0 - (rad * 180.0 / math.pi)) % 360.0
317+
318+
319+
def get_active_runways(runways: list, wind: dict):
314320
retval = []
315321
for runway in runways:
316322
heading = int(runway[:2]) * 10

plugins/cloud/listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def onPlayerChangeSlot(self, server: Server, data: dict) -> None:
5555
player: Player = server.get_player(ucid=data['ucid'])
5656
if not player:
5757
return
58-
if player.side == Side.SPECTATOR:
58+
if player.side == Side.NEUTRAL:
5959
return
6060
asyncio.create_task(self.update_cloud_data(server, player))
6161

plugins/competitive/db/tables.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ CREATE OR REPLACE FUNCTION trueskill_hist_change()
1616
RETURNS trigger
1717
AS $$
1818
BEGIN
19-
INSERT INTO trueskill_hist(player_ucid, skill_mu, skill_sigma, time)
20-
SELECT OLD.player_ucid, OLD.skill_mu, OLD.skill_sigma, old.time;
19+
INSERT INTO trueskill_hist (player_ucid, skill_mu, skill_sigma, time)
20+
VALUES (OLD.player_ucid, OLD.skill_mu, OLD.skill_sigma, OLD.time)
21+
ON CONFLICT (player_ucid, time) DO UPDATE
22+
SET skill_mu = EXCLUDED.skill_mu,
23+
skill_sigma = EXCLUDED.skill_sigma;
24+
2125
RETURN NEW;
2226
END;
2327
$$ LANGUAGE 'plpgsql';

plugins/competitive/db/update_v3.1.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ CREATE OR REPLACE FUNCTION trueskill_hist_change()
44
RETURNS trigger
55
AS $$
66
BEGIN
7-
INSERT INTO trueskill_hist(player_ucid, skill_mu, skill_sigma, time)
8-
SELECT OLD.player_ucid, OLD.skill_mu, OLD.skill_sigma, old.time;
7+
INSERT INTO trueskill_hist (player_ucid, skill_mu, skill_sigma, time)
8+
VALUES (OLD.player_ucid, OLD.skill_mu, OLD.skill_sigma, OLD.time)
9+
ON CONFLICT (player_ucid, time) DO UPDATE
10+
SET skill_mu = EXCLUDED.skill_mu,
11+
skill_sigma = EXCLUDED.skill_sigma;
12+
913
RETURN NEW;
1014
END;
1115
$$ LANGUAGE 'plpgsql';

plugins/creditsystem/squadron.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ def points(self) -> int:
4747
return row[0]
4848
else:
4949
with conn.transaction():
50-
cursor = conn.execute("""
50+
conn.execute("""
5151
INSERT INTO squadron_credits (campaign_id, squadron_id, points)
5252
VALUES (%s, %s, %s)
5353
ON CONFLICT DO NOTHING
54-
RETURNING points;
5554
""", (self.campaign_id, self.squadron_id, self.config.get('initial_points', 0)))
55+
cursor = conn.execute("""
56+
SELECT points FROM squadron_credits WHERE campaign_id = %s AND squadron_id = %s
57+
""", (self.campaign_id, self.squadron_id))
5658
row = cursor.fetchone()
5759
return row[0]
5860

plugins/gamemaster/listener.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ async def onChatMessage(self, server: Server, data: dict) -> None:
7777
Side.RED: 31,
7878
Side.BLUE: 34,
7979
Side.NEUTRAL: 37,
80-
Side.SPECTATOR: 37,
8180
Side.UNKNOWN: 37
8281
}
8382
if data['to'] == -2:
8483
color = colors[player.side]
8584
else:
86-
color = colors[Side.SPECTATOR]
85+
color = colors[Side.NEUTRAL]
8786
asyncio.create_task(chat_channel.send(
8887
f"```ansi\n\u001b[1;{color}mPlayer {player.name} said: {data['message']}```"
8988
))

0 commit comments

Comments
 (0)