Skip to content

Commit

Permalink
fixed #112, v1.16.0.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeG621 committed Nov 21, 2024
1 parent 7559477 commit d706906
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 27 deletions.
73 changes: 54 additions & 19 deletions BriefingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Copyright (C) 2007-2024 Michael Gaisser ([email protected])
* Licensed under the MPL v2.0 or later
*
* VERSION: 1.16.0.2
* VERSION: 1.16.0.5
*
* CHANGELOG
* v1.16.0.5, 241120
* [FIX #112] Exception adding events to blank briefing, and silently overwriting existing events.
* v1.16.0.2, 241017
* [FIX] Exception during XwaSetIcon and XwaMoveIcon event modifications
* v1.16, 241013
Expand Down Expand Up @@ -2013,19 +2015,25 @@ void cmdOk_Click(object sender, EventArgs e)
if (i < 10000) { break; } // no further action, existing found

i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
break;
case BaseBriefing.EventType.PageBreak:
i = findExisting(_eventType);
if (i < 10000) { break; }

i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
if (_platform == Settings.Platform.TIE) lblTitle.Text = "";
lblCaption.Text = "";
break;
case BaseBriefing.EventType.TitleText:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
_events[i].Variables[0] = (short)cboText.SelectedIndex; // TODO: possible exception if nothing selected?
if (i >= 10000)
{
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)((cboText.SelectedIndex >= 0) ? cboText.SelectedIndex : 0);
if (_strings[_events[i].Variables[0]].StartsWith(">"))
{
lblTitle.TextAlign = ContentAlignment.TopCenter;
Expand All @@ -2041,7 +2049,11 @@ void cmdOk_Click(object sender, EventArgs e)
break;
case BaseBriefing.EventType.CaptionText:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)cboText.SelectedIndex;
if (_strings[_events[i].Variables[0]].StartsWith(">"))
{
Expand All @@ -2058,14 +2070,22 @@ void cmdOk_Click(object sender, EventArgs e)
break;
case BaseBriefing.EventType.MoveMap:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = _mapX;
_events[i].Variables[1] = _mapY;
// don't need to repaint, done while adjusting values
break;
case BaseBriefing.EventType.ZoomMap:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = _zoomX;
_events[i].Variables[1] = _zoomY;
// don't need to repaint, done while adjusting values
Expand All @@ -2075,6 +2095,7 @@ void cmdOk_Click(object sender, EventArgs e)
if (i < 10000) break;

i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
for (int n = 0; n < 8; n++)
{
_fgTags[n].Slot = -1;
Expand All @@ -2084,7 +2105,11 @@ void cmdOk_Click(object sender, EventArgs e)
case BaseBriefing.EventType.FGTag1:
_eventType = (BaseBriefing.EventType)((int)_eventType + numFG.Value - 1);
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)cboFGTag.SelectedIndex;
_fgTags[(int)_eventType - (int)BaseBriefing.EventType.FGTag1].Slot = _events[i].Variables[0];
_fgTags[(int)_eventType - (int)BaseBriefing.EventType.FGTag1].StartTime = _events[i].Time;
Expand All @@ -2095,6 +2120,7 @@ void cmdOk_Click(object sender, EventArgs e)
if (i < 10000) break;

i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
for (int n = 0; n < 8; n++)
{
_textTags[n].StringIndex = -1;
Expand All @@ -2113,6 +2139,7 @@ void cmdOk_Click(object sender, EventArgs e)
break;
}
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
else
{
Expand All @@ -2137,25 +2164,29 @@ void cmdOk_Click(object sender, EventArgs e)
break;
}

i = findNext();
i = _events.Insert(i, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
i = _events.Insert(findNext(), new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
_events[i].Variables[0] = _icon;
_events[i].Variables[1] = (short)cboNCraft.SelectedIndex;
_events[i].Variables[2] = (short)cboIconIff.SelectedIndex;
updateList(i);
// add initial MoveIcon
if (cboNCraft.SelectedIndex != 0)
{
i = findNext();
i = _events.Insert(i, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
i = _events.Insert(findNext(), new BaseBriefing.Event(BaseBriefing.EventType.XwaMoveIcon) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
_events[i].Variables[0] = _icon;
_events[i].Variables[1] = _tempX;
_events[i].Variables[2] = _tempY;
}
break;
case BaseBriefing.EventType.XwaShipInfo:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)(optInfoOn.Checked ? 1 : 0);
_events[i].Variables[1] = (short)cboInfoCraft.SelectedIndex;
break;
Expand All @@ -2169,8 +2200,8 @@ void cmdOk_Click(object sender, EventArgs e)

if (numMoveTime.Value == 0)
{
i = findNext();
i = _events.Insert(i, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
i = _events.Insert(findNext(), new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
_events[i].Variables[0] = _icon;
_events[i].Variables[1] = _briefData[_icon].Waypoint[0];
_events[i].Variables[2] = _briefData[_icon].Waypoint[1];
Expand All @@ -2188,8 +2219,8 @@ void cmdOk_Click(object sender, EventArgs e)
int t0 = hsbTimer.Value, x = _briefData[_icon].Waypoint[0], y = _briefData[_icon].Waypoint[1];
for (int j = 0; j <= total; j++)
{
i = findNext(j + t0);
i = _events.Insert(i, new BaseBriefing.Event(_eventType) { Time = (short)(j + t0) });
i = _events.Insert(findNext(j + t0), new BaseBriefing.Event(_eventType) { Time = (short)(j + t0) });
lstEvents.Items.Insert(i, "");
_events[i].Variables[0] = _icon;
_events[i].Variables[1] = (short)((x - _tempX) * j / total + _tempX);
_events[i].Variables[2] = (short)((y - _tempY) * j / total + _tempY);
Expand All @@ -2198,14 +2229,18 @@ void cmdOk_Click(object sender, EventArgs e)
}
break;
case BaseBriefing.EventType.XwaRotateIcon:
i = findNext();
i = _events.Insert(i, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
i = _events.Insert(findNext(), new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
_events[i].Variables[0] = _icon;
_events[i].Variables[1] = (short)cboRotateAmount.SelectedIndex;
break;
case BaseBriefing.EventType.XwaChangeRegion:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new BaseBriefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)(numNewRegion.Value - 1);
break;
default: // this shouldn't be possible
Expand Down
38 changes: 32 additions & 6 deletions BriefingFormXwing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* This file authored by "JB" (Random Starfighter) ([email protected])
* Licensed under the MPL v2.0 or later
*
* VERSION: 1.16
* VERSION: 1.16.0.5
*
* CHANGELOG
* v1.16.0.5, 241120
* [FIX #112] Exception adding events to blank briefing, and silently overwriting existing events.
* v1.16, 241013
* [UPD] Updates per Platform
* [NEW] TextTag and ShipTag structs (def'd in BriefingForm.cs) to replace int[,] for _textTags and _fgTags
Expand Down Expand Up @@ -944,7 +946,11 @@ void cmdOk_Click(object sender, EventArgs e)

case Briefing.EventType.TitleText:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)((cboText.SelectedIndex >= 0) ? cboText.SelectedIndex : 0); //[JB] Fix exception if no string is selected in the dropdown box.
if (_strings[_events[i].Variables[0]].StartsWith(">"))
{
Expand All @@ -961,7 +967,11 @@ void cmdOk_Click(object sender, EventArgs e)
break;
case Briefing.EventType.CaptionText:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)cboText.SelectedIndex;
if (_strings[_events[i].Variables[0]].StartsWith(">"))
{
Expand All @@ -978,14 +988,22 @@ void cmdOk_Click(object sender, EventArgs e)
break;
case Briefing.EventType.MoveMap:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = _mapX;
_events[i].Variables[1] = _mapY;
// don't need to repaint, done while adjusting values
break;
case Briefing.EventType.ZoomMap:
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = _zoomX;
_events[i].Variables[1] = _zoomY;
// don't need to repaint, done while adjusting values
Expand All @@ -995,6 +1013,7 @@ void cmdOk_Click(object sender, EventArgs e)
if (i < 10000) break; // no further action, existing break found

i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
for (int n = 0; n < 8; n++)
{
_fgTags[n].Slot = -1;
Expand All @@ -1004,7 +1023,11 @@ void cmdOk_Click(object sender, EventArgs e)
case Briefing.EventType.FGTag1:
_eventType = (Briefing.EventType)((int)_eventType + numFG.Value - 1);
i = findExisting(_eventType);
if (i >= 10000) i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
if (i >= 10000)
{
i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
_events[i].Variables[0] = (short)cboFGTag.SelectedIndex;
_fgTags[(int)_eventType - (int)Briefing.EventType.FGTag1].Slot = _events[i].Variables[0];
_fgTags[(int)_eventType - (int)Briefing.EventType.FGTag1].StartTime = _events[i].Time;
Expand All @@ -1015,6 +1038,7 @@ void cmdOk_Click(object sender, EventArgs e)
if (i < 10000) break; // no further action, existing break found

i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
for (int n = 0; n < 4; n++)
{
_textTags[n].StringIndex = -1;
Expand All @@ -1033,6 +1057,7 @@ void cmdOk_Click(object sender, EventArgs e)
break;
}
i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
}
else
{
Expand All @@ -1052,6 +1077,7 @@ void cmdOk_Click(object sender, EventArgs e)
if (i < 10000) break;

i = _events.Insert(i - 10000, new Briefing.Event(_eventType) { Time = (short)hsbTimer.Value });
lstEvents.Items.Insert(i, "");
break;
}

Expand Down
7 changes: 5 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ To remove YOGEME, simply delete the directory where you placed it.
This will leave behind a single config file in AppData with your user settings.

## Latest Release
#### 1.16.0.5, 20 Nov 2024
- (All) Fixed an exception when adding events to blank briefings, which would also silently overwrite non-related events in populated briefings. [Issue [#112](https://github.com/MikeG621/YOGEME/issues/112)]

#### 1.16.0.4, 3 Nov 2024
- (XWA) Fixed an exception when enabling a FG Goal. [Issue #111]
-
- (XWA) Fixed an exception when enabling a FG Goal. [Issue [#111](https://github.com/MikeG621/YOGEME/issues/111)]

#### 1.16.0.3, 27 Oct 2024
- (All) Fixed an exception when attemping to add a craft to the mission from the Library. [Issue [#110](https://github.com/MikeG621/YOGEME/issues/110)]

Expand Down

0 comments on commit d706906

Please sign in to comment.