Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a5a387381 | ||
|
|
33f734da2d |
Binary file not shown.
|
After Width: | Height: | Size: 576 B |
Binary file not shown.
|
After Width: | Height: | Size: 576 B |
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
@@ -0,0 +1,60 @@
|
||||
# Plasma Images
|
||||
|
||||
Hand-made art for the pods' plasma name displays. Anything dropped in here is
|
||||
version-controlled and rolls out with the release: `build-package.bat` copies the
|
||||
folder into `App\`, and `install.bat` puts it beside `TeslaConsole.exe`.
|
||||
|
||||
The folder ships empty on purpose — populate it per site.
|
||||
|
||||
## How it works
|
||||
|
||||
When the console builds a mission egg it renders every participant name into a
|
||||
1-bit-per-pixel bitmap in two sizes and embeds it in the egg. By default those are
|
||||
drawn procedurally: `Microsoft Sans Serif`, white on black, no anti-aliasing, the
|
||||
point size stepped down from 24 until the text fits.
|
||||
|
||||
With **Settings → Enable Custom Bitmaps** ticked, the console looks for a matching
|
||||
file here first and only falls back to the procedural renderer when there isn't
|
||||
one. The toggle is remembered in `console.settings` (see below), so it survives a
|
||||
restart.
|
||||
|
||||
## File naming
|
||||
|
||||
```
|
||||
<text>_<width>x<height>.bmp
|
||||
```
|
||||
|
||||
The `<text>` part is matched **exactly** against the string being rendered — the
|
||||
pilot/player name, the Red Planet football team name, or the literal `Camera` for
|
||||
camera pods. Matching is per-name, not global, so you can override one name and
|
||||
let the rest render normally.
|
||||
|
||||
Two sizes are needed to cover a name completely; supplying only one is fine, the
|
||||
other falls back to the font renderer:
|
||||
|
||||
| Size | Egg section | Example |
|
||||
| -------- | ------------------ | ---------------------- |
|
||||
| 128 × 32 | `BitMap::Large::…` | `Camera_128x32.bmp` |
|
||||
| 64 × 16 | `BitMap::Small::…` | `Camera_64x16.bmp` |
|
||||
|
||||
Rules:
|
||||
|
||||
- **Dimensions must match exactly.** A 130×32 file is ignored, silently, and the
|
||||
name renders procedurally instead.
|
||||
- **Only brightness matters.** Every pixel at or above 50% brightness lights up on
|
||||
the plasma; everything else is dark. Colour art gets thresholded, so design in
|
||||
black and white.
|
||||
- Any name that cannot be a Windows file name (`:`, `\`, `|`, `?`, `*`, …) can't
|
||||
have an override — those names always render procedurally.
|
||||
- Files are read at egg-build time and copied into memory, not locked, so art can
|
||||
be swapped between missions without restarting the console.
|
||||
|
||||
Preview how a name looks before a mission with the console's **Plasma Font Tool**,
|
||||
which renders through the same path — with the option on it shows the override.
|
||||
|
||||
## Where the console looks
|
||||
|
||||
1. `%ProgramData%\Tesla Console\Plasma Images\` — this machine's own art. Takes
|
||||
precedence, and survives a reinstall, so a site can keep local overrides that
|
||||
a release will not overwrite.
|
||||
2. `Plasma Images\` next to `TeslaConsole.exe` — this folder, as shipped.
|
||||
@@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © 2009")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: Guid("581ca4b6-a91c-4d24-b9b5-207f3b5da379")]
|
||||
[assembly: AssemblyFileVersion("4.11.4.4")]
|
||||
[assembly: AssemblyFileVersion("4.11.4.5")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyTitle("Tesla Console")]
|
||||
[assembly: AssemblyDescription("All code and UI property of Virtual World Entertainment.\r\n\r\nDeveloped by Elsewhen Studios, LLC in association with VGCorps, LLC.\r\n\r\nElsewhen Studios and the Elsewhen Wormhole are trademarks of Elsewhen Studios, LLC\r\n\r\nIncludes the WeifenLuo DockingPane library. Copyright © 2007 Weifen Luo (email: weifenluo@yahoo.com). Licensed under the MIT License - details can be found in WeifenLuo.txt included in this installation.")]
|
||||
[assembly: AssemblyVersion("4.11.4.4")]
|
||||
[assembly: AssemblyVersion("4.11.4.5")]
|
||||
|
||||
+9
-2
@@ -103,9 +103,16 @@ dependency DLLs copied alongside it).
|
||||
|
||||
- `RedPlanet\RPConfig.xml`, `RedPlanet\RPStrings.xml` are loaded relative to the
|
||||
exe and are copied to the build output automatically.
|
||||
- `Plasma Images\*.bmp` (under `%ProgramData%`) is an **optional** override set;
|
||||
when absent the console renders plasma-display text procedurally, so it is not
|
||||
- `Plasma Images\*.bmp` is an **optional** override set for the pod plasma name
|
||||
displays, enabled by *Settings → Enable Custom Bitmaps*. The console looks in
|
||||
`%ProgramData%\Tesla Console\Plasma Images` (the machine's own art, wins) and
|
||||
then in `Plasma Images\` next to the exe (the set that ships with the release —
|
||||
see [`Plasma Images/README.md`](Plasma%20Images/README.md) for naming and sizes).
|
||||
When neither has a match the console renders the text procedurally, so no art is
|
||||
required to build or run.
|
||||
- Machine-level Settings-menu toggles persist in
|
||||
`%ProgramData%\Tesla Console\console.settings` (XML, written on change by
|
||||
`ConsoleSettings`). Deleting it just restores the defaults.
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
@@ -184,6 +184,18 @@ internal class BTGame : DockContent
|
||||
|
||||
private readonly bool mDosBoxAddressShift = BTDefaults.DosBoxAddressShift;
|
||||
|
||||
private Panel mSessionStrip;
|
||||
|
||||
private Label mSessionBanner;
|
||||
|
||||
private Button mSessionApply;
|
||||
|
||||
private Button mSessionReset;
|
||||
|
||||
private DateTime mNextRosterPoll = DateTime.MinValue;
|
||||
|
||||
private DateTime mStateChangePendingSince = DateTime.MinValue;
|
||||
|
||||
private string GameStatusText
|
||||
{
|
||||
set
|
||||
@@ -300,10 +312,117 @@ internal class BTGame : DockContent
|
||||
{
|
||||
BuildPodRow(item5.A, item5.B);
|
||||
}
|
||||
BuildSessionStrip();
|
||||
SessionRoster.Poll();
|
||||
UpdateSessionStrip();
|
||||
CheckAllValues();
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The internet-session strip: roster banner, Apply, and the Reset that has
|
||||
/// always existed as a right-click on the (disabled) Go button.
|
||||
///
|
||||
/// Built here and not in InitializeComponent on purpose. That block is the
|
||||
/// decompiled 1995 designer output and the differential tests compare it
|
||||
/// literally, so anything new has to be assembled at runtime instead.
|
||||
/// Docked last, which is docked first, so the strip sits above Mission
|
||||
/// Properties rather than between it and the pilot grid.
|
||||
/// </summary>
|
||||
private void BuildSessionStrip()
|
||||
{
|
||||
mSessionStrip = new Panel();
|
||||
mSessionStrip.Dock = DockStyle.Top;
|
||||
mSessionStrip.Height = 28;
|
||||
mSessionStrip.Visible = false;
|
||||
mSessionBanner = new Label();
|
||||
mSessionBanner.Dock = DockStyle.Fill;
|
||||
mSessionBanner.TextAlign = ContentAlignment.MiddleLeft;
|
||||
mSessionBanner.Padding = new Padding(6, 0, 6, 0);
|
||||
mSessionApply = new Button();
|
||||
mSessionApply.Dock = DockStyle.Left;
|
||||
mSessionApply.Width = 110;
|
||||
mSessionApply.Text = "Apply Session";
|
||||
mSessionApply.Visible = false;
|
||||
mSessionApply.UseVisualStyleBackColor = true;
|
||||
mSessionApply.Click += new EventHandler(mSessionApply_Click);
|
||||
mSessionReset = new Button();
|
||||
mSessionReset.Dock = DockStyle.Right;
|
||||
mSessionReset.Width = 110;
|
||||
mSessionReset.Text = "Reset Pods";
|
||||
mSessionReset.Visible = false;
|
||||
mSessionReset.UseVisualStyleBackColor = true;
|
||||
// The same action as the hidden context-menu item, which no operator has
|
||||
// ever found: it lives on a button that is disabled exactly when the reset
|
||||
// is wanted.
|
||||
mSessionReset.Click += new EventHandler(resetToolStripMenuItem_Click);
|
||||
mSessionStrip.Controls.Add(mSessionBanner);
|
||||
mSessionStrip.Controls.Add(mSessionApply);
|
||||
mSessionStrip.Controls.Add(mSessionReset);
|
||||
base.Controls.Add(mSessionStrip);
|
||||
}
|
||||
|
||||
private void UpdateSessionStrip()
|
||||
{
|
||||
if (mRequestedState == mCurrentState)
|
||||
{
|
||||
mStateChangePendingSince = DateTime.MinValue;
|
||||
mSessionReset.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mStateChangePendingSince == DateTime.MinValue)
|
||||
{
|
||||
mStateChangePendingSince = DateTime.Now;
|
||||
}
|
||||
// Ten seconds, so a healthy Load/Launch never makes the button flicker
|
||||
// past. Past that the pane is not slow, it is stuck: the state barrier
|
||||
// in NetworkScan has no timeout of its own.
|
||||
mSessionReset.Visible = mStateChangePendingSince.AddSeconds(10.0) < DateTime.Now;
|
||||
}
|
||||
string text = SessionBannerText();
|
||||
mSessionBanner.Text = text;
|
||||
mSessionBanner.ForeColor = (SessionRoster.Active ? SystemColors.ControlText : Color.Red);
|
||||
mSessionApply.Visible = SessionRoster.Active;
|
||||
// Nothing claimed, nothing wrong and nothing stuck: no roster file at all
|
||||
// leaves the pane looking exactly as it does today. Museums run this.
|
||||
mSessionStrip.Visible = text.Length > 0 || mSessionReset.Visible;
|
||||
}
|
||||
|
||||
private static string SessionBannerText()
|
||||
{
|
||||
if (!SessionRoster.Active)
|
||||
{
|
||||
// Empty with no file; when a file was refused this is why, and the
|
||||
// operator needs to read it before hand-enabling eight rows.
|
||||
return SessionRoster.LoadError;
|
||||
}
|
||||
string text = SessionRoster.SessionKey;
|
||||
if (text.Length > 8)
|
||||
{
|
||||
text = text.Substring(0, 8);
|
||||
}
|
||||
// Local time: the lobby writes the file on this machine, and the operator
|
||||
// is comparing the stamp against the clock on the wall.
|
||||
return $"SESSION {text} - {SessionRoster.Game} - {SessionRoster.Claims.Count} slots claimed - {SessionRoster.WaitingCount} waiting - written {SessionRoster.WrittenUtc.ToLocalTime():HH:mm:ss}";
|
||||
}
|
||||
|
||||
private void mSessionApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
string text = SessionRoster.Validate("bt", mDosBoxAddressShift, mPilotsDataGrid, mEnabledColumn.Index, mPilotColumn.Index);
|
||||
if (text.Length > 0)
|
||||
{
|
||||
// Named offender, never a silent fix: the pilot name is about to become
|
||||
// an INI section name in the egg, so the operator must see the name that
|
||||
// will be written.
|
||||
MessageBox.Show(text, "Can Not Apply Session Roster");
|
||||
return;
|
||||
}
|
||||
SessionRoster.Apply(mPilotsDataGrid, mEnabledColumn.Index, mPilotColumn.Index, this, mDosBoxAddressShift);
|
||||
CheckAllValues();
|
||||
mPilotsDataGrid.Refresh();
|
||||
}
|
||||
|
||||
private static void SetupKeyValueColumn(DataGridViewComboBoxColumn column, Dictionary<string, string> options, string defaultKey)
|
||||
{
|
||||
int num = 0;
|
||||
@@ -403,6 +522,21 @@ internal class BTGame : DockContent
|
||||
|
||||
private void NetworkScan(object sender, EventArgs e)
|
||||
{
|
||||
// Own deadline rather than a count of ticks: mNetworkTimer's interval is
|
||||
// the designer default and this must stay ~1Hz whatever that becomes. Same
|
||||
// shape as MungaGame.QueryStateIfNeeded (MungaGame.cs:159-167).
|
||||
DateTime now = DateTime.Now;
|
||||
if (mNextRosterPoll < now)
|
||||
{
|
||||
mNextRosterPoll = now.AddSeconds(1.0);
|
||||
if (SessionRoster.Poll() && mCurrentState == BTGameState.Idle && mRequestedState == BTGameState.Idle)
|
||||
{
|
||||
// Guarded like SetPodStatus: CheckAllValues owns mGoButton.Enabled,
|
||||
// and mid-mission that button is Stop Mission.
|
||||
CheckAllValues();
|
||||
}
|
||||
}
|
||||
UpdateSessionStrip();
|
||||
if (mCurrentState == BTGameState.Run && mRequestedState == BTGameState.Run && !mProcessingMissionEndStateChangeReq)
|
||||
{
|
||||
mProcessingMissionEndStateChangeReq = true;
|
||||
@@ -735,6 +869,21 @@ internal class BTGame : DockContent
|
||||
{
|
||||
case BTGameState.Load:
|
||||
{
|
||||
// Re-check at the click, not at the last status tick. Nothing between
|
||||
// here and the egg validates anything -- mGoButton.Enabled is a UI flag
|
||||
// CheckAllValues set at some earlier moment -- so a pod that died in
|
||||
// that gap goes straight into the mission, and the post-Load barrier in
|
||||
// NetworkScan then waits forever for a WaitingForLaunch that will never
|
||||
// arrive (that loop has no timeout). Safe only at the very top of this
|
||||
// case: mMissionLength, mMissionRecorder, mMissionPlayers,
|
||||
// mRequestedState and SwitchControlsMode are all still untouched below,
|
||||
// so returning here leaves the pane exactly as the operator left it.
|
||||
CheckAllValues();
|
||||
if (!mGoButton.Enabled)
|
||||
{
|
||||
MessageBox.Show(mIssuesLabel.Text, "Can Not Load Mission");
|
||||
return;
|
||||
}
|
||||
mMissionLength = ParseMissionLength();
|
||||
string key = ((BTMap)mMap.SelectedItem).Key;
|
||||
string key2 = ((KeyValuePair<string, string>)mTimeOfDay.SelectedItem).Key;
|
||||
@@ -854,6 +1003,9 @@ internal class BTGame : DockContent
|
||||
|
||||
private void SwitchControlsMode(bool editMode)
|
||||
{
|
||||
// Applying a roster rewrites pilot names and enabled rows, so it is an edit
|
||||
// like any other and rides the same gate as the rest of the pane.
|
||||
mSessionApply.Enabled = editMode;
|
||||
mMap.Enabled = editMode;
|
||||
mWeather.Enabled = editMode;
|
||||
mTimeOfDay.Enabled = editMode;
|
||||
@@ -1004,6 +1156,10 @@ internal class BTGame : DockContent
|
||||
{
|
||||
stringBuilder.AppendLine("The mission length must be at least 10 seconds.");
|
||||
}
|
||||
// Enabled implies claimed: an enabled row nobody took in the lobby puts a
|
||||
// dead IP in the egg and every pod then waits on a peer that never boots.
|
||||
// Empty with no session roster, which is what keeps the arcade path intact.
|
||||
stringBuilder.Append(SessionRoster.Issues(mPilotsDataGrid, mEnabledColumn.Index, mDosBoxAddressShift));
|
||||
mGoButton.Enabled = stringBuilder.Length <= 0;
|
||||
mIssuesLabel.Text = stringBuilder.ToString();
|
||||
}
|
||||
|
||||
@@ -178,6 +178,18 @@ public class RPGame : DockContent
|
||||
|
||||
private readonly bool mDosBoxAddressShift = RPDefaults.DosBoxAddressShift;
|
||||
|
||||
private Panel mSessionStrip;
|
||||
|
||||
private Label mSessionBanner;
|
||||
|
||||
private Button mSessionApply;
|
||||
|
||||
private Button mSessionReset;
|
||||
|
||||
private DateTime mNextRosterPoll = DateTime.MinValue;
|
||||
|
||||
private DateTime mStateChangePendingSince = DateTime.MinValue;
|
||||
|
||||
private string GameStatusText
|
||||
{
|
||||
set
|
||||
@@ -335,10 +347,119 @@ public class RPGame : DockContent
|
||||
{
|
||||
BuildPodRow(item6.A, item6.B);
|
||||
}
|
||||
BuildSessionStrip();
|
||||
SessionRoster.Poll();
|
||||
UpdateSessionStrip();
|
||||
CheckAllValues();
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The internet-session strip: roster banner, Apply, and the Reset that has
|
||||
/// always existed as a right-click on the (disabled) Go button.
|
||||
///
|
||||
/// Built here and not in InitializeComponent on purpose. That block is the
|
||||
/// decompiled 1995 designer output and the differential tests compare it
|
||||
/// literally, so anything new has to be assembled at runtime instead.
|
||||
/// Docked last, which is docked first, so the strip sits above Mission
|
||||
/// Properties rather than between it and the pilot grid.
|
||||
/// </summary>
|
||||
private void BuildSessionStrip()
|
||||
{
|
||||
mSessionStrip = new Panel();
|
||||
mSessionStrip.Dock = DockStyle.Top;
|
||||
mSessionStrip.Height = 28;
|
||||
mSessionStrip.Visible = false;
|
||||
mSessionBanner = new Label();
|
||||
mSessionBanner.Dock = DockStyle.Fill;
|
||||
mSessionBanner.TextAlign = ContentAlignment.MiddleLeft;
|
||||
mSessionBanner.Padding = new Padding(6, 0, 6, 0);
|
||||
mSessionApply = new Button();
|
||||
mSessionApply.Dock = DockStyle.Left;
|
||||
mSessionApply.Width = 110;
|
||||
mSessionApply.Text = "Apply Session";
|
||||
mSessionApply.Visible = false;
|
||||
mSessionApply.UseVisualStyleBackColor = true;
|
||||
mSessionApply.Click += new EventHandler(mSessionApply_Click);
|
||||
mSessionReset = new Button();
|
||||
mSessionReset.Dock = DockStyle.Right;
|
||||
mSessionReset.Width = 110;
|
||||
mSessionReset.Text = "Reset Pods";
|
||||
mSessionReset.Visible = false;
|
||||
mSessionReset.UseVisualStyleBackColor = true;
|
||||
// The same action as the hidden context-menu item, which no operator has
|
||||
// ever found: it lives on a button that is disabled exactly when the reset
|
||||
// is wanted.
|
||||
mSessionReset.Click += new EventHandler(resetToolStripMenuItem_Click);
|
||||
mSessionStrip.Controls.Add(mSessionBanner);
|
||||
mSessionStrip.Controls.Add(mSessionApply);
|
||||
mSessionStrip.Controls.Add(mSessionReset);
|
||||
base.Controls.Add(mSessionStrip);
|
||||
}
|
||||
|
||||
private void UpdateSessionStrip()
|
||||
{
|
||||
if (mRequestedState == mCurrentState)
|
||||
{
|
||||
mStateChangePendingSince = DateTime.MinValue;
|
||||
mSessionReset.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mStateChangePendingSince == DateTime.MinValue)
|
||||
{
|
||||
mStateChangePendingSince = DateTime.Now;
|
||||
}
|
||||
// Ten seconds, so a healthy Load/Launch never makes the button flicker
|
||||
// past. Past that the pane is not slow, it is stuck: the state barrier
|
||||
// in NetworkScan has no timeout of its own.
|
||||
mSessionReset.Visible = mStateChangePendingSince.AddSeconds(10.0) < DateTime.Now;
|
||||
}
|
||||
string text = SessionBannerText();
|
||||
mSessionBanner.Text = text;
|
||||
mSessionBanner.ForeColor = (SessionRoster.Active ? SystemColors.ControlText : Color.Red);
|
||||
mSessionApply.Visible = SessionRoster.Active;
|
||||
// Nothing claimed, nothing wrong and nothing stuck: no roster file at all
|
||||
// leaves the pane looking exactly as it does today. Museums run this.
|
||||
mSessionStrip.Visible = text.Length > 0 || mSessionReset.Visible;
|
||||
}
|
||||
|
||||
private static string SessionBannerText()
|
||||
{
|
||||
if (!SessionRoster.Active)
|
||||
{
|
||||
// Empty with no file; when a file was refused this is why, and the
|
||||
// operator needs to read it before hand-enabling eight rows.
|
||||
return SessionRoster.LoadError;
|
||||
}
|
||||
string text = SessionRoster.SessionKey;
|
||||
if (text.Length > 8)
|
||||
{
|
||||
text = text.Substring(0, 8);
|
||||
}
|
||||
// Local time: the lobby writes the file on this machine, and the operator
|
||||
// is comparing the stamp against the clock on the wall.
|
||||
return $"SESSION {text} - {SessionRoster.Game} - {SessionRoster.Claims.Count} slots claimed - {SessionRoster.WaitingCount} waiting - written {SessionRoster.WrittenUtc.ToLocalTime():HH:mm:ss}";
|
||||
}
|
||||
|
||||
private void mSessionApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
// "rp": both Red Planet modes -- Death Race and Martian Football -- are
|
||||
// one game to the lobby, which knows only which title the pods will boot.
|
||||
string text = SessionRoster.Validate("rp", mDosBoxAddressShift, mPilotsDataGrid, mEnabledColumn.Index, mPilotColumn.Index);
|
||||
if (text.Length > 0)
|
||||
{
|
||||
// Named offender, never a silent fix: the pilot name is about to become
|
||||
// an INI section name in the egg, so the operator must see the name that
|
||||
// will be written.
|
||||
MessageBox.Show(text, "Can Not Apply Session Roster");
|
||||
return;
|
||||
}
|
||||
SessionRoster.Apply(mPilotsDataGrid, mEnabledColumn.Index, mPilotColumn.Index, this, mDosBoxAddressShift);
|
||||
CheckAllValues();
|
||||
mPilotsDataGrid.Refresh();
|
||||
}
|
||||
|
||||
private void BuildPodRow(Squad squad, Pod pod)
|
||||
{
|
||||
int index = mPilotsDataGrid.Rows.Add();
|
||||
@@ -430,6 +551,21 @@ public class RPGame : DockContent
|
||||
|
||||
private void NetworkScan(object sender, EventArgs e)
|
||||
{
|
||||
// Own deadline rather than a count of ticks: mNetworkTimer's interval is
|
||||
// the designer default and this must stay ~1Hz whatever that becomes. Same
|
||||
// shape as MungaGame.QueryStateIfNeeded (MungaGame.cs:159-167).
|
||||
DateTime now = DateTime.Now;
|
||||
if (mNextRosterPoll < now)
|
||||
{
|
||||
mNextRosterPoll = now.AddSeconds(1.0);
|
||||
if (SessionRoster.Poll() && mCurrentState == RPGameState.Idle && mRequestedState == RPGameState.Idle)
|
||||
{
|
||||
// Guarded like SetPodStatus: CheckAllValues owns mGoButton.Enabled,
|
||||
// and mid-mission that button is Stop Mission.
|
||||
CheckAllValues();
|
||||
}
|
||||
}
|
||||
UpdateSessionStrip();
|
||||
if (mCurrentState == RPGameState.Run && mRequestedState == RPGameState.Run && !mProcessingMissionEndStateChangeReq)
|
||||
{
|
||||
mProcessingMissionEndStateChangeReq = true;
|
||||
@@ -775,6 +911,21 @@ public class RPGame : DockContent
|
||||
{
|
||||
case RPGameState.Load:
|
||||
{
|
||||
// Re-check at the click, not at the last status tick. Nothing between
|
||||
// here and the egg validates anything -- mGoButton.Enabled is a UI flag
|
||||
// CheckAllValues set at some earlier moment -- so a pod that died in
|
||||
// that gap goes straight into the mission, and the post-Load barrier in
|
||||
// NetworkScan then waits forever for a WaitingForLaunch that will never
|
||||
// arrive (that loop has no timeout). Safe only at the very top of this
|
||||
// case: mMissionLength, mMissionRecorder, mMissionPlayers,
|
||||
// mRequestedState and SwitchControlsMode are all still untouched below,
|
||||
// so returning here leaves the pane exactly as the operator left it.
|
||||
CheckAllValues();
|
||||
if (!mGoButton.Enabled)
|
||||
{
|
||||
MessageBox.Show(mIssuesLabel.Text, "Can Not Load Mission");
|
||||
return;
|
||||
}
|
||||
mMissionLength = ParseMissionLength();
|
||||
string key = ((RPMap)mMap.SelectedItem).Key;
|
||||
string key2 = ((KeyValuePair<string, string>)mTimeOfDay.SelectedItem).Key;
|
||||
@@ -914,6 +1065,9 @@ public class RPGame : DockContent
|
||||
|
||||
private void SwitchControlsMode(bool editMode)
|
||||
{
|
||||
// Applying a roster rewrites pilot names and enabled rows, so it is an edit
|
||||
// like any other and rides the same gate as the rest of the pane.
|
||||
mSessionApply.Enabled = editMode;
|
||||
ComboBox comboBox = mMap;
|
||||
ComboBox comboBox2 = mWeather;
|
||||
ComboBox comboBox3 = mTimeOfDay;
|
||||
@@ -1111,6 +1265,10 @@ public class RPGame : DockContent
|
||||
{
|
||||
stringBuilder.AppendLine("The mission length must be at least 10 seconds.");
|
||||
}
|
||||
// Enabled implies claimed: an enabled row nobody took in the lobby puts a
|
||||
// dead IP in the egg and every pod then waits on a peer that never boots.
|
||||
// Empty with no session roster, which is what keeps the arcade path intact.
|
||||
stringBuilder.Append(SessionRoster.Issues(mPilotsDataGrid, mEnabledColumn.Index, mDosBoxAddressShift));
|
||||
mGoButton.Enabled = stringBuilder.Length <= 0;
|
||||
mIssuesLabel.Text = stringBuilder.ToString();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
<Content Include="RedPlanet\Apps.xml" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="BattleTech\BTConfig.xml" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="BattleTech\BTStrings.xml" CopyToOutputDirectory="PreserveNewest" />
|
||||
<!-- Optional plasma-display art (PlasmaBitmaps.LoadCustomBitmap), shipped with
|
||||
the release. The glob is normally empty; the README goes along so the drop
|
||||
folder exists on the control PC. The machine's own
|
||||
%ProgramData%\Tesla Console\Plasma Images overrides whatever ships here. -->
|
||||
<Content Include="Plasma Images\*.bmp" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="Plasma Images\README.md" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
/// <summary>
|
||||
/// Machine-level console settings that belong to no single game — the Settings
|
||||
/// menu toggles that used to live only in memory and reset on every restart.
|
||||
/// Stored as XML in %ProgramData%\Tesla Console\console.settings, next to
|
||||
/// RPDefaults.rpd / BTDefaults.btd / local.siteconfig.
|
||||
///
|
||||
/// The values themselves stay where they are used (PlasmaBitmaps owns
|
||||
/// EnableCustomBitmaps); this class only moves them to and from disk, so the
|
||||
/// original decompiled classes keep their shape. Load() is called once from
|
||||
/// Program.Main and never from a static initializer: the differential test suite
|
||||
/// drives PlasmaBitmaps directly, and must keep seeing the original defaults
|
||||
/// rather than whatever this operator happens to have saved.
|
||||
/// </summary>
|
||||
internal static class ConsoleSettings
|
||||
{
|
||||
private static readonly string sSettingsFilePath = Path.Combine(Program.GetCommonAppDataDirectory(), "console.settings");
|
||||
|
||||
/// <summary>
|
||||
/// Applies the saved settings. A missing file is the normal first-run case;
|
||||
/// a corrupt one is ignored and rewritten by the next Save(), because losing
|
||||
/// a menu toggle must never stop the console from starting.
|
||||
/// </summary>
|
||||
public static void Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(sSettingsFilePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(sSettingsFilePath);
|
||||
foreach (XmlNode childNode in xmlDocument.DocumentElement.ChildNodes)
|
||||
{
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "EnableCustomBitmaps":
|
||||
{
|
||||
if (bool.TryParse(childNode.InnerText, out var result))
|
||||
{
|
||||
PlasmaBitmaps.EnableCustomBitmaps = result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.AppendChild(xmlDocument.CreateElement("ConsoleSettings"));
|
||||
xmlDocument.DocumentElement.AppendChild(xmlDocument.CreateElement("EnableCustomBitmaps")).InnerText = PlasmaBitmaps.EnableCustomBitmaps.ToString();
|
||||
string directoryName = Path.GetDirectoryName(sSettingsFilePath);
|
||||
if (!Directory.Exists(directoryName))
|
||||
{
|
||||
Directory.CreateDirectory(directoryName);
|
||||
}
|
||||
xmlDocument.Save(sSettingsFilePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("The console settings file could not be saved. This setting will only be remembered until the application is closed.", "Error Saving Console Settings!", MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
@@ -45,21 +46,10 @@ public class PlasmaBitmaps
|
||||
{
|
||||
if (sEnableCustomBitmaps)
|
||||
{
|
||||
string text = Path.Combine(Program.GetCommonAppDataDirectory(), $"Plasma Images\\{str}_{width}x{height}.bmp");
|
||||
if (File.Exists(text))
|
||||
Bitmap bitmap = LoadCustomBitmap(width, height, str);
|
||||
if (bitmap != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Bitmap bitmap = (Bitmap)Image.FromFile(text);
|
||||
if (bitmap.Width == width && bitmap.Height == height)
|
||||
{
|
||||
return bitmap;
|
||||
}
|
||||
bitmap.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
Bitmap bitmap2 = new Bitmap(width, height);
|
||||
@@ -87,6 +77,59 @@ public class PlasmaBitmaps
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The operator-supplied plasma image for this string at this size, or null
|
||||
/// when there is none (the caller then renders the text procedurally).
|
||||
///
|
||||
/// Two folders are searched, in order:
|
||||
/// 1. %ProgramData%\Tesla Console\Plasma Images - this machine's own art,
|
||||
/// which survives reinstalls and wins over anything shipped.
|
||||
/// 2. Plasma Images\ next to TeslaConsole.exe - the set that rolls with
|
||||
/// the release, so art can be version-controlled and deployed.
|
||||
/// The file name is "<text>_<width>x<height>.bmp", e.g. Camera_128x32.bmp.
|
||||
///
|
||||
/// Nothing here may throw: participant names come from operator input, and a
|
||||
/// name containing a character that is illegal in a path used to take out
|
||||
/// egg generation entirely once this option was switched on.
|
||||
/// </summary>
|
||||
private static Bitmap LoadCustomBitmap(int width, int height, string str)
|
||||
{
|
||||
string fileName = $"{str}_{width}x{height}.bmp";
|
||||
if (fileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string[] searchRoots = new string[2]
|
||||
{
|
||||
Program.GetCommonAppDataDirectory(),
|
||||
Path.GetDirectoryName(Application.ExecutablePath)
|
||||
};
|
||||
foreach (string searchRoot in searchRoots)
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = Path.Combine(Path.Combine(searchRoot, "Plasma Images"), fileName);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Copied out of the file rather than Image.FromFile'd: that keeps the
|
||||
// bitmap backed by the file for its whole lifetime, which locks the art
|
||||
// against an operator swapping it while the console is running.
|
||||
using FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
using Image image = Image.FromStream(stream);
|
||||
if (image.Width == width && image.Height == height)
|
||||
{
|
||||
return new Bitmap(image);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void GenerateStrings(out string large, out string small, string str)
|
||||
{
|
||||
GenerateStrings(out large, out small, "Microsoft Sans Serif", str);
|
||||
|
||||
@@ -59,6 +59,8 @@ internal static class Program
|
||||
}
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(defaultValue: false);
|
||||
// Machine-level Settings-menu toggles, before the form reads them to set its check marks.
|
||||
ConsoleSettings.Load();
|
||||
Application.Run(new TeslaConsoleForm());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,857 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
/// <summary>
|
||||
/// Reads the session roster TeslaLobby writes when an internet session
|
||||
/// launches: which of the eight internet slots a human actually claimed, and
|
||||
/// what that human is called. The slot-to-IP map is frozen
|
||||
/// (<c>emulator\steam\SESSION-CONTRACT.md</c> section 1), so the eight internet
|
||||
/// pod rows are furniture the operator builds once in Manage Site; only the
|
||||
/// claims change from session to session.
|
||||
///
|
||||
/// Two properties are load-bearing and everything here is shaped around them:
|
||||
///
|
||||
/// 1. ONLY CLAIMED SLOTS APPEAR IN THE FILE. Absence is the unclaimed signal,
|
||||
/// so a truncated, stale, unreadable or refused file yields FEWER
|
||||
/// participants, never more. Every failure path below therefore degrades to
|
||||
/// "no roster", which is byte-for-byte today's arcade behaviour. Museums run
|
||||
/// this software; a bad JSON file must never be able to stop a mission that
|
||||
/// would otherwise run by hand.
|
||||
/// 2. ENABLED IMPLIES CLAIMED, not the reverse. The operator may always
|
||||
/// subtract from an applied roster (sit a pilot out); the operator may never
|
||||
/// add, because an enabled row nobody claimed puts a dead IP in the mission
|
||||
/// egg and the pods sit waiting on a peer that will never boot.
|
||||
///
|
||||
/// The file is ONE PER LAUNCH GENERATION -- written at the state=launching flip
|
||||
/// and not rewritten as the lobby churns -- because pod peer tables are
|
||||
/// boot-static: a player whose TeslaLobby crashes is still in every pod's peer
|
||||
/// table and still perfectly playable, and a live-tracking roster would evict
|
||||
/// that working pod from the mission. Do not "fix" this into a live view.
|
||||
///
|
||||
/// UI thread only. <see cref="Poll"/> is cheap enough to call at ~1Hz from the
|
||||
/// existing mission timers.
|
||||
/// </summary>
|
||||
internal static class SessionRoster
|
||||
{
|
||||
/// <summary>One claimed slot. Absence of a slot from <see cref="Claims"/> means nobody claimed it.</summary>
|
||||
internal sealed class Claim
|
||||
{
|
||||
internal Claim(int slot, IPAddress address, string pilot, string steamId, bool host)
|
||||
{
|
||||
Slot = slot;
|
||||
Address = address;
|
||||
Pilot = pilot;
|
||||
SteamId = steamId;
|
||||
Host = host;
|
||||
}
|
||||
|
||||
internal int Slot { get; private set; }
|
||||
|
||||
/// <summary>The game IP for the slot: 200.0.0.(111 + slot). Frozen, see SESSION-CONTRACT.md section 1.</summary>
|
||||
internal IPAddress Address { get; private set; }
|
||||
|
||||
internal string Pilot { get; private set; }
|
||||
|
||||
internal string SteamId { get; private set; }
|
||||
|
||||
/// <summary>True for the session host (slot 0). Informational -- the console drives every claim the same way.</summary>
|
||||
internal bool Host { get; private set; }
|
||||
}
|
||||
|
||||
private const int SupportedSchema = 1;
|
||||
|
||||
private const int MaxSlots = 8;
|
||||
|
||||
// Slot 0 -> 200.0.0.111 ... slot 7 -> 200.0.0.118. Frozen in
|
||||
// SESSION-CONTRACT.md section 1 and mirrored by the lobby's SlotPlan.cs;
|
||||
// .119/.120 are reserved for the live-review / camera roles, which is why
|
||||
// the block stops at eight.
|
||||
private const byte SlotNetA = 200;
|
||||
|
||||
private const byte SlotNetB = 0;
|
||||
|
||||
private const byte SlotNetC = 0;
|
||||
|
||||
private const int SlotZeroOctet = 111;
|
||||
|
||||
// Pilot-name rules, decided by the operator 2026-07-25. The name becomes an
|
||||
// INI section name in the egg (BTMission builds [BitMap::Large::<name>]) and
|
||||
// the egg is ASCII, so '[', ']' and '=' would corrupt the egg's structure
|
||||
// silently. The lobby sanitizes; the console only re-validates and refuses,
|
||||
// because a name the operator never saw must not be quietly rewritten on its
|
||||
// way into a mission file.
|
||||
private const int MaxPilotNameLength = 12;
|
||||
|
||||
private const string BarredCharacters = "[]=";
|
||||
|
||||
// A roster older than one evening is a leftover from a previous session.
|
||||
private const double MaxAgeHours = 12.0;
|
||||
|
||||
// Sanity bound. The real file is well under 2 KB; anything larger is not ours.
|
||||
private const long MaxFileBytes = 64L * 1024L;
|
||||
|
||||
private static readonly IList<Claim> sNoClaims = new ReadOnlyCollection<Claim>(new List<Claim>());
|
||||
|
||||
private static bool sSeenExists;
|
||||
|
||||
private static DateTime sSeenStamp = DateTime.MinValue;
|
||||
|
||||
private static long sSeenLength = -1L;
|
||||
|
||||
private static bool sParsed;
|
||||
|
||||
private static bool sActive;
|
||||
|
||||
private static int sSchema;
|
||||
|
||||
private static string sSessionId = "";
|
||||
|
||||
private static string sSessionKey = "";
|
||||
|
||||
private static string sGame = "";
|
||||
|
||||
private static bool sAddressShift;
|
||||
|
||||
private static DateTime sWrittenUtc = DateTime.MinValue;
|
||||
|
||||
private static int sWaiting;
|
||||
|
||||
private static string sLoadError = "";
|
||||
|
||||
private static IList<Claim> sClaims = sNoClaims;
|
||||
|
||||
private static string sLoggedError = "";
|
||||
|
||||
/// <summary>
|
||||
/// A roster file is present, parses, and is fresh. NOT "usable": call
|
||||
/// <see cref="Validate"/> before applying, which is what catches a roster
|
||||
/// for the wrong game, the wrong schema or the wrong addressing mode.
|
||||
/// </summary>
|
||||
internal static bool Active => sActive;
|
||||
|
||||
/// <summary>Matches steam_session.json. A change means a NEW launch generation, so re-apply.</summary>
|
||||
internal static string SessionKey => sSessionKey;
|
||||
|
||||
internal static string SessionId => sSessionId;
|
||||
|
||||
/// <summary>"bt" or "rp", as written. Compare case-insensitively.</summary>
|
||||
internal static string Game => sGame;
|
||||
|
||||
/// <summary>The addressing the session REQUIRES; internet sessions are flat, so this is false.</summary>
|
||||
internal static bool AddressShift => sAddressShift;
|
||||
|
||||
internal static DateTime WrittenUtc => sWrittenUtc;
|
||||
|
||||
/// <summary>Lobby members holding no slot, for the banner. Not a blocker -- spectators are legal.</summary>
|
||||
internal static int WaitingCount => sWaiting;
|
||||
|
||||
/// <summary>Empty when nothing is wrong. Operator-facing; show it in the banner, it is why there is no roster.</summary>
|
||||
internal static string LoadError => sLoadError;
|
||||
|
||||
// IList, not IReadOnlyList: the read-only interfaces are net45+ and the
|
||||
// XP11 console targets net40. The instance is already immutable.
|
||||
internal static IList<Claim> Claims => sClaims;
|
||||
|
||||
internal static string FilePath =>
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
||||
"Tesla Console", "session_roster.json");
|
||||
|
||||
/// <summary>
|
||||
/// Re-reads the roster if the file changed. Returns true when the roster
|
||||
/// state changed and the caller should repaint. Never throws.
|
||||
/// </summary>
|
||||
internal static bool Poll()
|
||||
{
|
||||
string before = StateStamp();
|
||||
try
|
||||
{
|
||||
PollCore();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Belt and braces: PollCore already catches everything it expects to
|
||||
// fail. Anything reaching here is a surprise, and the answer to a
|
||||
// surprise is still "there is no roster".
|
||||
Unsee();
|
||||
Clear("The session roster could not be read: " + ex.Message);
|
||||
}
|
||||
return StateStamp() != before;
|
||||
}
|
||||
|
||||
/// <summary>The claim on an address, or null. The address is the game IP, i.e. what the egg will carry.</summary>
|
||||
internal static Claim Find(IPAddress ip)
|
||||
{
|
||||
if (!sActive || ip == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < sClaims.Count; i++)
|
||||
{
|
||||
if (ip.Equals(sClaims[i].Address))
|
||||
{
|
||||
return sClaims[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gate A. Returns "" when the roster may be applied to this mission
|
||||
/// window, else operator-facing text explaining what to fix.
|
||||
///
|
||||
/// Returns "" when no roster is active: with no roster the console is the
|
||||
/// 1995 console and must not grow a new way to refuse a mission.
|
||||
/// <paramref name="enabledCol"/> and <paramref name="pilotCol"/> are taken
|
||||
/// for call-shape symmetry with <see cref="Apply"/>; the checks here need
|
||||
/// only each row's pod (row.Tag).
|
||||
/// </summary>
|
||||
internal static string Validate(string game, bool paneShift, DataGridView grid, int enabledCol, int pilotCol)
|
||||
{
|
||||
if (!sActive)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
if (sSchema != SupportedSchema)
|
||||
{
|
||||
return $"This session roster is format version {sSchema}; this console reads version {SupportedSchema}. "
|
||||
+ "Install matching TeslaLobby and TeslaConsole builds, then start the session again.";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(game) && !string.Equals(game, sGame, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return $"This session roster is for {GameName(sGame)}. This is a {GameName(game)} mission. "
|
||||
+ $"Start a {GameName(game)} session in TeslaLobby, or close this window and open the {GameName(sGame)} one.";
|
||||
}
|
||||
if (paneShift != sAddressShift)
|
||||
{
|
||||
return AddressShiftMessage(paneShift);
|
||||
}
|
||||
if (sClaims.Count == 0)
|
||||
{
|
||||
return "This session roster has no claimed slots. Nobody took a pod in TeslaLobby, so there is nothing to launch.";
|
||||
}
|
||||
StringBuilder problems = new StringBuilder();
|
||||
for (int i = 0; i < sClaims.Count; i++)
|
||||
{
|
||||
Claim claim = sClaims[i];
|
||||
string problem = PilotNameProblem(claim.Pilot);
|
||||
if (problem != null)
|
||||
{
|
||||
problems.AppendLine(string.IsNullOrEmpty(claim.Pilot)
|
||||
? $"Slot {claim.Slot} has no pilot name. Set one in TeslaLobby and start the session again."
|
||||
: $"Pilot name \"{claim.Pilot}\" (slot {claim.Slot}) {problem}. Fix it in TeslaLobby and start the "
|
||||
+ "session again -- the console will not rewrite a name that is about to be written into the mission egg.");
|
||||
continue;
|
||||
}
|
||||
// Ordinal, matching the panes' own duplicate check in
|
||||
// CheckAllValues (BTGame.cs:965), so the two agree on what a
|
||||
// duplicate is.
|
||||
for (int j = i + 1; j < sClaims.Count; j++)
|
||||
{
|
||||
if (string.Equals(claim.Pilot, sClaims[j].Pilot, StringComparison.Ordinal))
|
||||
{
|
||||
problems.AppendLine($"Pilot name \"{claim.Pilot}\" is claimed by slot {claim.Slot} and slot {sClaims[j].Slot}. "
|
||||
+ "Pilot names must be unique. Rename one in TeslaLobby and start the session again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (grid != null)
|
||||
{
|
||||
for (int i = 0; i < sClaims.Count; i++)
|
||||
{
|
||||
Claim claim = sClaims[i];
|
||||
Pod pod = FindPod(grid, claim.Address, paneShift);
|
||||
if (pod == null)
|
||||
{
|
||||
problems.AppendLine($"No pod is configured at {claim.Address} (slot {claim.Slot}). "
|
||||
+ "Add the Internet squad in Manage Site.");
|
||||
}
|
||||
else if (pod.HostType != HostType.GameMachineHostType)
|
||||
{
|
||||
problems.AppendLine($"The pod at {claim.Address} (slot {claim.Slot}) is not a game machine. "
|
||||
+ "Internet slots must be Game Machine pods in Manage Site.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return problems.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogOnce("SessionRoster.Validate failed: " + ex);
|
||||
// Fail closed: an active roster we cannot check is not a roster the
|
||||
// operator should be allowed to apply.
|
||||
return "The session roster could not be checked. Enable pods by hand, or restart the console.";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills the mission grid in from the roster: every claimed pod row gets its
|
||||
/// pilot name, is enabled and is connected; every other player row is
|
||||
/// cleared, disabled and released.
|
||||
///
|
||||
/// Callers gate on <see cref="Validate"/> first and repaint their own issue
|
||||
/// list afterwards (CheckAllValues) -- this method deliberately knows
|
||||
/// nothing about either pane's UI. Never throws.
|
||||
/// </summary>
|
||||
internal static void Apply(DataGridView grid, int enabledCol, int pilotCol, object requestor, bool paneShift)
|
||||
{
|
||||
if (!sActive || grid == null || requestor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
foreach (DataGridViewRow row in grid.Rows)
|
||||
{
|
||||
Pod pod = row.Tag as Pod;
|
||||
if (pod == null || pod.HostType != HostType.GameMachineHostType)
|
||||
{
|
||||
// Camera and mission-review rows are site furniture, never
|
||||
// lobby slots. Leave them exactly as the operator set them:
|
||||
// the roster describes players, and turning off a recording
|
||||
// host the operator armed would be an edit nobody asked for.
|
||||
continue;
|
||||
}
|
||||
if (enabledCol < 0 || enabledCol >= row.Cells.Count || pilotCol < 0 || pilotCol >= row.Cells.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Claim claim = MatchClaim(pod, paneShift);
|
||||
if (claim != null)
|
||||
{
|
||||
row.Cells[pilotCol].Value = claim.Pilot;
|
||||
row.Cells[enabledCol].Value = true;
|
||||
// Setting cell values connects NOTHING -- programmatic writes
|
||||
// raise no CellEndEdit. The only thing that opens a pod
|
||||
// connection is MungaGame.MakeRequested, so reproduce the
|
||||
// hand-edit sequence exactly, shift first: assigning
|
||||
// DosBoxAddressShift while connected drops the socket
|
||||
// (MungaGame.cs:120-143), so it must be settled before the
|
||||
// request that dials. Modelled on
|
||||
// mPilotsDataGrid_CellEndEdit, BTGame.cs:1085-1089 (and the
|
||||
// identical RPGame.cs:1195-1199).
|
||||
pod.MungaGame.DosBoxAddressShift = paneShift;
|
||||
pod.MungaGame.MakeRequested(requestor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The clear-and-release the Delete/Backspace path uses,
|
||||
// BTGame.cs:1102-1105: "" rather than null, so the pane's
|
||||
// blank-name check sees what a hand-cleared cell leaves.
|
||||
row.Cells[pilotCol].Value = "";
|
||||
row.Cells[enabledCol].Value = false;
|
||||
pod.MungaGame.ReleaseRequest(requestor);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Rows already processed keep their state; a half-applied roster is
|
||||
// still enabled-implies-claimed, and Issues() is the net under it.
|
||||
LogOnce("SessionRoster.Apply failed: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gate B. One line per enabled player row that nobody claimed. Empty when
|
||||
/// there is nothing to say -- and always empty with no active roster, which
|
||||
/// is what keeps the arcade path untouched.
|
||||
/// </summary>
|
||||
internal static string Issues(DataGridView grid, int enabledCol, bool paneShift)
|
||||
{
|
||||
if (!sActive || grid == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
StringBuilder issues = new StringBuilder();
|
||||
foreach (DataGridViewRow row in grid.Rows)
|
||||
{
|
||||
Pod pod = row.Tag as Pod;
|
||||
if (pod == null || pod.HostType != HostType.GameMachineHostType || !IsEnabled(row, enabledCol))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// The pane's shift, matching Apply's signature. It equals
|
||||
// sAddressShift by the time this can matter (Validate refuses a
|
||||
// disagreeing pane before Apply can run), but the join from a row
|
||||
// to a claim is now spelled the same way in both methods -- two
|
||||
// spellings of one rule is how they drift apart later.
|
||||
if (MatchClaim(pod, paneShift) != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
IPAddress address = MissionAddress(pod, paneShift);
|
||||
int slot = SlotForAddress(address);
|
||||
string who = (slot >= 0)
|
||||
? $"Slot {slot} ({address})"
|
||||
: (string.IsNullOrEmpty(pod.Name) ? address.ToString() : $"{pod.Name} ({address})");
|
||||
issues.AppendLine($"{who} is enabled but nobody claimed it in this session.");
|
||||
}
|
||||
return issues.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogOnce("SessionRoster.Issues failed: " + ex);
|
||||
// Fail closed, as in Validate: an active roster we cannot check
|
||||
// against must not be allowed to launch.
|
||||
return "The session roster could not be checked against the enabled pods. Restart the console.";
|
||||
}
|
||||
}
|
||||
|
||||
private static void PollCore()
|
||||
{
|
||||
string path = FilePath;
|
||||
FileInfo info = new FileInfo(path);
|
||||
bool exists = info.Exists;
|
||||
DateTime stamp = exists ? info.LastWriteTimeUtc : DateTime.MinValue;
|
||||
long length = exists ? info.Length : -1L;
|
||||
if (exists == sSeenExists && stamp == sSeenStamp && length == sSeenLength)
|
||||
{
|
||||
// Freshness is time-dependent, not file-dependent: a console left
|
||||
// open overnight must drop a roster that ages out of the window even
|
||||
// though nothing on disk moved.
|
||||
RefreshActive();
|
||||
return;
|
||||
}
|
||||
if (!exists)
|
||||
{
|
||||
See(false, stamp, length);
|
||||
// No file is not an error. This is the arcade path.
|
||||
Clear("");
|
||||
return;
|
||||
}
|
||||
if (length > MaxFileBytes || length <= 0L)
|
||||
{
|
||||
See(true, stamp, length);
|
||||
Clear($"The session roster at {path} is {length} bytes, which is not a roster file. It was ignored.");
|
||||
LogOnce(sLoadError);
|
||||
return;
|
||||
}
|
||||
JObject root;
|
||||
try
|
||||
{
|
||||
root = JObject.Parse(ReadAllTextShared(path));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Leave the stat uncommitted so the next tick retries: the usual
|
||||
// cause is a read that raced the lobby's write, and latching that
|
||||
// failure until something touches the file again would strand a
|
||||
// perfectly good roster.
|
||||
Unsee();
|
||||
Clear("The session roster could not be read: " + ex.Message);
|
||||
LogOnce(sLoadError + " (" + path + ")");
|
||||
return;
|
||||
}
|
||||
See(true, stamp, length);
|
||||
Parse(root, path);
|
||||
}
|
||||
|
||||
private static void Parse(JObject root, string path)
|
||||
{
|
||||
int schema = ReadInt(root["schema"], 0);
|
||||
string sessionId = ReadString(root["sessionId"]);
|
||||
string sessionKey = ReadString(root["sessionKey"]);
|
||||
string game = ReadString(root["game"]).Trim();
|
||||
// Missing means flat addressing: that is what an internet session
|
||||
// requires (SESSION-CONTRACT.md section 1) and it is the safe default,
|
||||
// since a wrong "false" is caught by Validate against the pane's flag.
|
||||
bool addressShift = ReadBool(root["addressShift"], defaultValue: false);
|
||||
int waiting = ReadInt(root["waiting"], 0);
|
||||
|
||||
DateTime writtenUtc;
|
||||
if (!ReadUtc(root["writtenUtc"], out writtenUtc))
|
||||
{
|
||||
Clear("The session roster has no usable writtenUtc timestamp, so its age cannot be checked. It was ignored.");
|
||||
LogOnce(sLoadError + " (" + path + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
JArray slots = root["slots"] as JArray;
|
||||
if (slots == null)
|
||||
{
|
||||
Clear("The session roster has no slots list. It was ignored.");
|
||||
LogOnce(sLoadError + " (" + path + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Claim> claims = new List<Claim>();
|
||||
bool[] seen = new bool[MaxSlots];
|
||||
foreach (JToken token in slots)
|
||||
{
|
||||
JObject entry = token as JObject;
|
||||
if (entry == null)
|
||||
{
|
||||
Refuse("a slot entry is not an object", path);
|
||||
return;
|
||||
}
|
||||
int slot;
|
||||
if (!ReadIntStrict(entry["slot"], out slot) || slot < 0 || slot >= MaxSlots)
|
||||
{
|
||||
Refuse($"a slot entry has an out-of-range or unreadable slot number ({ReadString(entry["slot"])})", path);
|
||||
return;
|
||||
}
|
||||
if (seen[slot])
|
||||
{
|
||||
Refuse($"slot {slot} is claimed twice", path);
|
||||
return;
|
||||
}
|
||||
seen[slot] = true;
|
||||
IPAddress address;
|
||||
if (!IPAddress.TryParse(ReadString(entry["ip"]), out address))
|
||||
{
|
||||
Refuse($"slot {slot} has an unreadable ip", path);
|
||||
return;
|
||||
}
|
||||
// The mapping is frozen. A disagreement here means the lobby and the
|
||||
// console do not share an addressing plan, and every downstream
|
||||
// decision -- which row to enable, which slot to name in an issue --
|
||||
// would be built on a guess. Refuse the file and let the operator
|
||||
// enable pods by hand instead.
|
||||
IPAddress expected = AddressForSlot(slot);
|
||||
if (!expected.Equals(address))
|
||||
{
|
||||
Refuse($"slot {slot} claims {address}, but slot {slot} is {expected}", path);
|
||||
return;
|
||||
}
|
||||
claims.Add(new Claim(slot, address, ReadString(entry["pilot"]), ReadString(entry["steamId"]),
|
||||
ReadBool(entry["host"], defaultValue: false)));
|
||||
}
|
||||
|
||||
sParsed = true;
|
||||
sSchema = schema;
|
||||
sSessionId = sessionId;
|
||||
sSessionKey = sessionKey;
|
||||
sGame = game;
|
||||
sAddressShift = addressShift;
|
||||
sWrittenUtc = writtenUtc;
|
||||
sWaiting = waiting;
|
||||
sClaims = new ReadOnlyCollection<Claim>(claims);
|
||||
sLoadError = "";
|
||||
RefreshActive();
|
||||
}
|
||||
|
||||
/// <summary>Structural refusals: the file contradicts itself, so none of it is trusted.</summary>
|
||||
private static void Refuse(string reason, string path)
|
||||
{
|
||||
Clear($"The session roster was ignored: {reason}. Enable pods by hand for this mission.");
|
||||
LogOnce(sLoadError + " (" + path + ")");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the freshness window to already-parsed data. Split out of
|
||||
/// <see cref="Parse"/> because age changes with the clock, not with the file.
|
||||
/// </summary>
|
||||
private static void RefreshActive()
|
||||
{
|
||||
if (!sParsed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Absolute difference: a timestamp far in the future is clock skew
|
||||
// between the lobby machine and this one, which is no more trustworthy
|
||||
// than one from last night.
|
||||
double hours = Math.Abs((DateTime.UtcNow - sWrittenUtc).TotalHours);
|
||||
if (hours > MaxAgeHours)
|
||||
{
|
||||
string stamp = sWrittenUtc.ToString("u", CultureInfo.InvariantCulture);
|
||||
Clear($"The session roster was written {stamp} and is more than {(int)MaxAgeHours} hours old. "
|
||||
+ "It is left over from an earlier session and was ignored.");
|
||||
return;
|
||||
}
|
||||
sActive = true;
|
||||
sLoadError = "";
|
||||
}
|
||||
|
||||
private static void Clear(string error)
|
||||
{
|
||||
sParsed = false;
|
||||
sActive = false;
|
||||
sSchema = 0;
|
||||
sSessionId = "";
|
||||
sSessionKey = "";
|
||||
sGame = "";
|
||||
sAddressShift = false;
|
||||
sWrittenUtc = DateTime.MinValue;
|
||||
sWaiting = 0;
|
||||
sClaims = sNoClaims;
|
||||
sLoadError = error;
|
||||
}
|
||||
|
||||
private static void See(bool exists, DateTime stamp, long length)
|
||||
{
|
||||
sSeenExists = exists;
|
||||
sSeenStamp = stamp;
|
||||
sSeenLength = length;
|
||||
}
|
||||
|
||||
/// <summary>Forgets the stat so the next Poll re-reads the same file.</summary>
|
||||
private static void Unsee()
|
||||
{
|
||||
sSeenExists = false;
|
||||
sSeenStamp = DateTime.MinValue;
|
||||
sSeenLength = -1L;
|
||||
}
|
||||
|
||||
private static string ReadAllTextShared(string path)
|
||||
{
|
||||
// FileShare.ReadWrite | Delete: the lobby may still hold the file open,
|
||||
// and a sharing violation here would read as "no roster" for a whole
|
||||
// second. UTF-8 without BOM per the contract; BOM detection costs
|
||||
// nothing and forgives a writer that adds one.
|
||||
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string StateStamp()
|
||||
{
|
||||
return string.Concat(sActive ? "1|" : "0|", sSessionKey, "|", sGame, "|",
|
||||
sWrittenUtc.ToString("u", CultureInfo.InvariantCulture), "|",
|
||||
sClaims.Count.ToString(CultureInfo.InvariantCulture), "|",
|
||||
sWaiting.ToString(CultureInfo.InvariantCulture), "|", sLoadError);
|
||||
}
|
||||
|
||||
private static void LogOnce(string message)
|
||||
{
|
||||
// Once per distinct message: Poll runs at 1Hz and a permanently broken
|
||||
// file would otherwise fill ExceptionLog.txt overnight.
|
||||
if (sLoggedError == message)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sLoggedError = message;
|
||||
Program.LogMessage(message);
|
||||
}
|
||||
|
||||
/// <summary>The address this pod will carry into the mission -- MissionAddress() in both game panes.</summary>
|
||||
private static IPAddress MissionAddress(Pod pod, bool shift)
|
||||
{
|
||||
return shift ? DosBox.ShiftAddress(pod.IPAddress) : pod.IPAddress;
|
||||
}
|
||||
|
||||
private static Claim MatchClaim(Pod pod, bool shift)
|
||||
{
|
||||
if (pod == null || pod.IPAddress == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Join on the mission address, not the raw site-config address: the
|
||||
// claim's IP is the game IP, which is what the egg gets. With flat
|
||||
// addressing (every internet session) the two are the same value.
|
||||
return Find(MissionAddress(pod, shift));
|
||||
}
|
||||
|
||||
private static Pod FindPod(DataGridView grid, IPAddress address, bool shift)
|
||||
{
|
||||
foreach (DataGridViewRow row in grid.Rows)
|
||||
{
|
||||
Pod pod = row.Tag as Pod;
|
||||
if (pod != null && pod.IPAddress != null && address.Equals(MissionAddress(pod, shift)))
|
||||
{
|
||||
return pod;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool IsEnabled(DataGridViewRow row, int enabledCol)
|
||||
{
|
||||
if (enabledCol < 0 || enabledCol >= row.Cells.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
object value = row.Cells[enabledCol].Value;
|
||||
return value is bool && (bool)value;
|
||||
}
|
||||
|
||||
private static IPAddress AddressForSlot(int slot)
|
||||
{
|
||||
return new IPAddress(new byte[4] { SlotNetA, SlotNetB, SlotNetC, (byte)(SlotZeroOctet + slot) });
|
||||
}
|
||||
|
||||
/// <summary>The slot an address belongs to, or -1 when it is outside the internet block.</summary>
|
||||
private static int SlotForAddress(IPAddress address)
|
||||
{
|
||||
if (address == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
byte[] octets = address.GetAddressBytes();
|
||||
if (octets.Length != 4 || octets[0] != SlotNetA || octets[1] != SlotNetB || octets[2] != SlotNetC)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int slot = octets[3] - SlotZeroOctet;
|
||||
return (slot >= 0 && slot < MaxSlots) ? slot : -1;
|
||||
}
|
||||
|
||||
private static string GameName(string game)
|
||||
{
|
||||
if (string.Equals(game, "bt", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "BattleTech";
|
||||
}
|
||||
if (string.Equals(game, "rp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "Red Planet";
|
||||
}
|
||||
return string.IsNullOrEmpty(game) ? "an unnamed game" : "\"" + game + "\"";
|
||||
}
|
||||
|
||||
private static string AddressShiftMessage(bool paneShift)
|
||||
{
|
||||
// This mismatch is the silent hang this whole path exists to kill: the
|
||||
// console dials pod+100, nothing answers, and the mission never starts.
|
||||
// The part operators get wrong is that the pane LATCHES the flag when
|
||||
// the mission window opens (BTGame.cs:185 / RPGame.cs:179 read the
|
||||
// default into a readonly field at construction), so changing the
|
||||
// default with the window open does nothing at all. Say so.
|
||||
string state = paneShift ? "ON" : "OFF";
|
||||
string wanted = sAddressShift ? "ON" : "OFF";
|
||||
return $"This session needs the +100 DOSBox address shift {wanted}, but this mission window has it {state}. "
|
||||
+ $"Turn \"Shift all pod IPs +100 (DOSBox-X preservation build)\" {wanted} in the Defaults dialog, "
|
||||
+ "then CLOSE AND REOPEN this mission window -- the shift is latched when the window opens, "
|
||||
+ "so changing the default alone will not take effect.";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Why this pilot name is unusable, or null when it is clean. Mirrors the
|
||||
/// lobby's sanitizer; the console refuses rather than rewrites, so the name
|
||||
/// the player saw in the lobby is the name that reaches the egg.
|
||||
/// </summary>
|
||||
private static string PilotNameProblem(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
return "is blank";
|
||||
}
|
||||
if (name.Length > MaxPilotNameLength)
|
||||
{
|
||||
return $"is longer than {MaxPilotNameLength} characters";
|
||||
}
|
||||
for (int i = 0; i < name.Length; i++)
|
||||
{
|
||||
char c = name[i];
|
||||
if (BarredCharacters.IndexOf(c) >= 0)
|
||||
{
|
||||
return $"contains '{c}', which the mission egg cannot carry -- the pilot name becomes an INI section "
|
||||
+ "name, and '[', ']' and '=' corrupt the egg's structure silently";
|
||||
}
|
||||
if (c < ' ' || c > '~')
|
||||
{
|
||||
return "contains a character that is not printable ASCII";
|
||||
}
|
||||
}
|
||||
if (name != name.Trim())
|
||||
{
|
||||
return "has leading or trailing spaces";
|
||||
}
|
||||
if (name.IndexOf(" ", StringComparison.Ordinal) >= 0)
|
||||
{
|
||||
return "has a doubled space";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string ReadString(JToken token)
|
||||
{
|
||||
if (token == null || token.Type == JTokenType.Null || token.Type == JTokenType.Undefined)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (token.Type == JTokenType.Object || token.Type == JTokenType.Array)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
// SteamID64s are written as strings but survive being written as numbers.
|
||||
return token.ToString();
|
||||
}
|
||||
|
||||
private static int ReadInt(JToken token, int defaultValue)
|
||||
{
|
||||
int value;
|
||||
return ReadIntStrict(token, out value) ? value : defaultValue;
|
||||
}
|
||||
|
||||
private static bool ReadIntStrict(JToken token, out int value)
|
||||
{
|
||||
value = 0;
|
||||
if (token == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (token.Type == JTokenType.Integer)
|
||||
{
|
||||
try
|
||||
{
|
||||
value = token.Value<int>();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return token.Type == JTokenType.String
|
||||
&& int.TryParse(token.Value<string>(), NumberStyles.Integer, CultureInfo.InvariantCulture, out value);
|
||||
}
|
||||
|
||||
private static bool ReadBool(JToken token, bool defaultValue)
|
||||
{
|
||||
if (token == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
if (token.Type == JTokenType.Boolean)
|
||||
{
|
||||
return token.Value<bool>();
|
||||
}
|
||||
if (token.Type == JTokenType.String)
|
||||
{
|
||||
bool value;
|
||||
return bool.TryParse(token.Value<string>(), out value) ? value : defaultValue;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private static bool ReadUtc(JToken token, out DateTime value)
|
||||
{
|
||||
value = DateTime.MinValue;
|
||||
if (token != null && token.Type == JTokenType.Date)
|
||||
{
|
||||
// Newtonsoft already parsed it; normalise the kind rather than trust it.
|
||||
value = token.Value<DateTime>().ToUniversalTime();
|
||||
return true;
|
||||
}
|
||||
string text = ReadString(token);
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
DateTime parsed;
|
||||
if (!DateTime.TryParse(text, CultureInfo.InvariantCulture,
|
||||
DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out parsed))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
value = parsed;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -478,6 +478,7 @@ public class TeslaConsoleForm : Form
|
||||
private void enableCustomBitmapsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
enableCustomBitmapsToolStripMenuItem.Checked = (PlasmaBitmaps.EnableCustomBitmaps = !PlasmaBitmaps.EnableCustomBitmaps);
|
||||
ConsoleSettings.Save();
|
||||
}
|
||||
|
||||
private void mThrowHandledExceptionMenuItem_Click(object sender, EventArgs e)
|
||||
|
||||
+6
-1
@@ -64,8 +64,13 @@ echo Files copied.
|
||||
:: -- STEP 2: Data directory (site config, mission recordings) -----------------
|
||||
echo [2/4] Preparing data directory...
|
||||
if not exist "%DATA_DIR%" mkdir "%DATA_DIR%"
|
||||
:: Per-site plasma-display art. Created empty and never overwritten: what is in
|
||||
:: here wins over the copy shipped in App\Plasma Images, so a release cannot
|
||||
:: clobber a site's own name bitmaps.
|
||||
if not exist "%DATA_DIR%\Plasma Images" mkdir "%DATA_DIR%\Plasma Images"
|
||||
:: Grant the local Users group modify access so a normal operator account can
|
||||
:: write local.siteconfig / RP Missions when the console is not run elevated.
|
||||
:: write local.siteconfig / console.settings / RP Missions when the console is
|
||||
:: not run elevated.
|
||||
icacls "%DATA_DIR%" /grant *S-1-5-32-545:(OI)(CI)M /T >nul 2>&1
|
||||
echo %DATA_DIR% (Users: modify access)
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace TeslaConsole.DiffTests
|
||||
Assert.Contains("TeslaConsole", _fx.Original.AssemblyFullName);
|
||||
Assert.Contains("TeslaConsole", _fx.Recovered.AssemblyFullName);
|
||||
Assert.Contains("4.11.3.37076", _fx.Original.AssemblyFullName);
|
||||
Assert.Contains("4.11.4.4", _fx.Recovered.AssemblyFullName);
|
||||
Assert.Contains("4.11.4.5", _fx.Recovered.AssemblyFullName);
|
||||
}
|
||||
|
||||
// ---- RPStrings.GetTimeString: mm:ss formatting with 0.5s rounding ----
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Version>4.11.4.4</Version>
|
||||
<Version>4.11.4.5</Version>
|
||||
<ApplicationIcon>app.ico</ApplicationIcon>
|
||||
<AssemblyName>TeslaLauncher</AssemblyName>
|
||||
<RootNamespace>Tesla.Launcher</RootNamespace>
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ for %%a in (%*) do (
|
||||
|
||||
echo.
|
||||
echo ============================================================
|
||||
echo Tesla Launcher v4.11.4.4 - Build ^& Package (net40 single binary)
|
||||
echo Tesla Launcher v4.11.4.5 - Build ^& Package (net40 single binary)
|
||||
echo Output : %BUILD_DIR%
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo ============================================================
|
||||
echo Tesla Launcher v4.11.4.4 - Installation (single binary)
|
||||
echo Tesla Launcher v4.11.4.5 - Installation (single binary)
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ console's Install Product (or run directly on any machine).
|
||||
|
||||
Release packages for all three are attached to the
|
||||
[Gitea releases](https://gitea.mysticmachines.com/VWE/TeslaSuite/releases)
|
||||
(latest: **v4.11.4.3**).
|
||||
(latest: **v4.11.4.5**).
|
||||
|
||||
## Layout notes
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ internal sealed class LauncherRpcServer
|
||||
|
||||
private readonly VirtualLauncher mLauncher;
|
||||
private readonly int mPort;
|
||||
private readonly IPAddress mBind; // null = every interface (the default)
|
||||
private byte[] mSessionKey;
|
||||
private TcpListener mListener;
|
||||
private Thread mAcceptThread;
|
||||
@@ -53,10 +54,11 @@ internal sealed class LauncherRpcServer
|
||||
|
||||
public bool IsListening => mRunning;
|
||||
|
||||
public LauncherRpcServer(VirtualLauncher launcher, int port = ManagePort)
|
||||
public LauncherRpcServer(VirtualLauncher launcher, int port = ManagePort, IPAddress bind = null)
|
||||
{
|
||||
mLauncher = launcher;
|
||||
mPort = port;
|
||||
mBind = bind; // null keeps the historical every-interface behaviour
|
||||
}
|
||||
|
||||
/// <summary>Starts listening with the given provisioned session key. Throws if
|
||||
@@ -68,12 +70,14 @@ internal sealed class LauncherRpcServer
|
||||
return;
|
||||
}
|
||||
mSessionKey = sessionKey;
|
||||
mListener = new TcpListener(IPAddress.Any, mPort);
|
||||
mListener = new TcpListener(mBind ?? IPAddress.Any, mPort);
|
||||
mListener.Start();
|
||||
mRunning = true;
|
||||
mAcceptThread = new Thread(AcceptLoop) { IsBackground = true, Name = "vPOD-launcher-accept" };
|
||||
mAcceptThread.Start();
|
||||
Log?.Invoke($"Launcher RPC listening on TCP {mPort}.");
|
||||
Log?.Invoke(mBind == null
|
||||
? $"Launcher RPC listening on TCP {mPort}."
|
||||
: $"Launcher RPC listening on TCP {mPort} ({mBind} only).");
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
|
||||
+13
-2
@@ -28,6 +28,7 @@ internal sealed class MungaPodServer
|
||||
}
|
||||
|
||||
private readonly int mPort;
|
||||
private readonly IPAddress mBind; // null = every interface (the default)
|
||||
private TcpListener mListener;
|
||||
private Thread mAcceptThread;
|
||||
private volatile bool mRunning;
|
||||
@@ -54,8 +55,16 @@ internal sealed class MungaPodServer
|
||||
}
|
||||
|
||||
public MungaPodServer(int port)
|
||||
: this(port, null)
|
||||
{
|
||||
}
|
||||
|
||||
// bind == null keeps the historical every-interface behaviour, so existing
|
||||
// callers and single-pod runs are unchanged.
|
||||
public MungaPodServer(int port, IPAddress bind)
|
||||
{
|
||||
mPort = port;
|
||||
mBind = bind;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
@@ -64,12 +73,14 @@ internal sealed class MungaPodServer
|
||||
{
|
||||
return;
|
||||
}
|
||||
mListener = new TcpListener(IPAddress.Any, mPort);
|
||||
mListener = new TcpListener(mBind ?? IPAddress.Any, mPort);
|
||||
mListener.Start();
|
||||
mRunning = true;
|
||||
mAcceptThread = new Thread(AcceptLoop) { IsBackground = true, Name = "vPOD-accept" };
|
||||
mAcceptThread.Start();
|
||||
Log?.Invoke($"Listening on TCP {mPort} (all interfaces).");
|
||||
Log?.Invoke(mBind == null
|
||||
? $"Listening on TCP {mPort} (all interfaces)."
|
||||
: $"Listening on TCP {mPort} ({mBind} only).");
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using Munga.Net;
|
||||
|
||||
namespace VPod;
|
||||
@@ -18,11 +19,35 @@ namespace VPod;
|
||||
/// vPOD-only (not a real game-client option):
|
||||
/// <c>-nomanage</c> disable the virtual launcher / site-management side
|
||||
/// (no provisioning beacons, no TCP 53290 listener)
|
||||
/// <c>-bind <ip></c> listen on ONE address instead of every interface.
|
||||
/// Both listeners default to IPAddress.Any, which means
|
||||
/// the second vPOD on a machine loses the port and the
|
||||
/// console can only ever see one fake pod. Binding each
|
||||
/// instance to its own address lets a whole roster run
|
||||
/// side by side -- 200.0.0.111..118 are the internet
|
||||
/// session's slot addresses, so an eight-pod session can
|
||||
/// be exercised end to end with no cockpits and nobody
|
||||
/// else in the room. Add the aliases first, e.g.
|
||||
/// netsh interface ipv4 add address "Loopback" 200.0.0.113 255.255.255.0
|
||||
///
|
||||
/// DO NOT leave an unbound vPOD running alongside a bound
|
||||
/// roster. Verified on this box 2026-07-25: Windows lets
|
||||
/// IPAddress.Any bind the SAME port while specific
|
||||
/// addresses already hold it (Linux would refuse). The
|
||||
/// specific listeners still win for their own addresses,
|
||||
/// but the unbound one silently swallows every address no
|
||||
/// one claimed -- so a slot you thought was absent answers
|
||||
/// anyway, which is precisely the stale-pod confusion the
|
||||
/// console's claim gate exists to catch. Bind all of them
|
||||
/// or none of them.
|
||||
/// </summary>
|
||||
internal sealed class PodArguments
|
||||
{
|
||||
public int Port { get; private set; } = MungaSocket.ConsolePort; // 1501
|
||||
|
||||
/// <summary>Address both listeners bind to; null = every interface (default).</summary>
|
||||
public IPAddress Bind { get; private set; }
|
||||
|
||||
public ApplicationID Application { get; private set; } = ApplicationID.RPL4;
|
||||
|
||||
public HostType HostType { get; private set; } = HostType.GameMachineHostType;
|
||||
@@ -46,6 +71,16 @@ internal sealed class PodArguments
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case "-bind":
|
||||
// Unparseable means "every interface" rather than a hard failure:
|
||||
// vPOD is a test tool and a typo here should not stop the run, but
|
||||
// it must be visible -- Program logs the resolved bind at startup.
|
||||
if (i + 1 < args.Length && IPAddress.TryParse(args[i + 1], out IPAddress bind))
|
||||
{
|
||||
result.Bind = bind;
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case "-lc":
|
||||
result.HostType = HostType.MissionReviewHostType;
|
||||
break;
|
||||
|
||||
+2
-2
@@ -72,10 +72,10 @@ internal sealed class VPodForm : Form
|
||||
public VPodForm(PodArguments options)
|
||||
{
|
||||
mOptions = options;
|
||||
mServer = new MungaPodServer(options.Port);
|
||||
mServer = new MungaPodServer(options.Port, options.Bind);
|
||||
mSimulator = new PodSimulator(mServer, options.Application, options.HostId);
|
||||
mLauncher = new VirtualLauncher();
|
||||
mRpcServer = new LauncherRpcServer(mLauncher);
|
||||
mRpcServer = new LauncherRpcServer(mLauncher, LauncherRpcServer.ManagePort, options.Bind);
|
||||
mProvisioning = new PodProvisioning(PodProvisioning.MacForHost(options.HostId));
|
||||
BuildUi();
|
||||
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@
|
||||
<RootNamespace>VPod</RootNamespace>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<!-- Versioned with the suite since v4.11.4.3 (was its own 1.0.0 line). -->
|
||||
<AssemblyVersion>4.11.4.4</AssemblyVersion>
|
||||
<Version>4.11.4.4</Version>
|
||||
<AssemblyVersion>4.11.4.5</AssemblyVersion>
|
||||
<Version>4.11.4.5</Version>
|
||||
<Product>vPOD</Product>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user