Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes and crash log #41

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions resources/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## 1.0 - Feature complete (2024-02-25)

### 1.0.2

- Fixed crash with 6 people in your group - or rather prevent that
- Fixed crash when starting without AI players
- Fixed crash log
- Corrected "Inventar" in German translation

### 1.0.1

- Fixed New Village water source for older saves
Expand Down
2 changes: 1 addition & 1 deletion resources/game/classic_de/lang/de/BURN.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ ENTLASSEN}
ZUM LAGER}
ZUM TRUPP}
EIGENER}
INVENTORY}
INVENTAR}
ABBRECHEN}
HEILEN}
BESTENLISTE}
Expand Down
32 changes: 12 additions & 20 deletions source/Burntime.MonoGame/CustomExceptionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
using System;
//using System.Windows.Forms;
using System.IO;
using System.Threading;

namespace Burntime
{
//public class CustomExceptionHandler
//{
// public void OnThreadException(object sender, UnhandledExceptionEventArgs args)
// {
// Exception e = args.ExceptionObject as Exception;
// if (e == null)
// {
// MessageBox.Show("Error: Unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
// }
// else
// {
// ErrorMsg.LogException(e);
public class CustomExceptionHandler
{
public static void OnThreadException(object sender, UnhandledExceptionEventArgs args)
{
var e = args.ExceptionObject as Exception;
if (e is not null)
ErrorMsg.LogException(e);

// MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
// }
//MessageBox.Show("Error: " + e?.Message ?? "Unknown", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);

// // close
// Environment.Exit(1);
// }
//};
// close
Environment.Exit(1);
}
};

static class ErrorMsg
{
Expand Down
19 changes: 4 additions & 15 deletions source/Burntime.MonoGame/Program.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@

using Burntime;
using System;

#if (DEBUG)
#if !(DEBUG)
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CustomExceptionHandler.OnThreadException);
#endif

using var game = new Burntime.MonoGame.BurntimeGame();
game.Run();

#else

try
{
using var game = new Burntime.MonoGame.BurntimeGame();
game.Run();
}
catch (System.Exception exception)
{
ErrorMsg.LogException(exception);
}

#endif
12 changes: 7 additions & 5 deletions source/Burntime.Remaster/GUI/InventoryWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public Character ActiveCharacter
public InventoryWindow(Module App, InventorySide Side)
: base(App)
{
const int MAX_PEOPLE = 5;

side = (Side == InventorySide.Right);

back = side ? "inv.raw?2" : "gfx/inventory_left.png";
Expand All @@ -88,7 +86,7 @@ public InventoryWindow(Module App, InventorySide Side)

pageName = "";

for (int i = 0; i < MAX_PEOPLE; i++)
for (int i = 0; i < Logic.Group.MAX_PEOPLE; i++)
{
pageButtons[i] = new Button(App);
pageButtons[i].Image = "munt.raw?" + (5 + i);
Expand All @@ -99,7 +97,7 @@ public InventoryWindow(Module App, InventorySide Side)
pageButtons[i].Hide();
pageButtons[i].Command += new CommandHandler(OnPage, i);
pageIndices[i] = i;
pageButtons[i].Layer = Layer + MAX_PEOPLE + 1;
pageButtons[i].Layer = Layer + Logic.Group.MAX_PEOPLE + 1;
Windows += pageButtons[i];
}

Expand All @@ -109,7 +107,7 @@ public InventoryWindow(Module App, InventorySide Side)
Position = new Vector2(side ? 9 : 19, side ? 72 : 83) + basePos,
Spacing = new Vector2(4, side ? 16 : 5),
Grid = new Vector2(3, 2),
Layer = Layer + MAX_PEOPLE + 1
Layer = Layer + Logic.Group.MAX_PEOPLE + 1
};
grid.LeftClickItemEvent += OnLeftClickItem;
grid.RightClickItemEvent += OnRightClickItem;
Expand Down Expand Up @@ -163,6 +161,10 @@ void Refresh()

for (int i = 0; i < group.Count; i++)
{
// should not happen but well
if (count >= pageButtons.Length)
continue;

// show only if in range
if (group.IsInRange(leader, group[i]))
{
Expand Down
9 changes: 6 additions & 3 deletions source/Burntime.Remaster/Logic/Character/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,12 @@ public void Dismiss()
public virtual void Die()
{
// drop items
Location.Items.DropPosition = Position;
Items.MoveTo(Location.Items);

if (Location is not null)
{
Location.Items.DropPosition = Position;
Items.MoveTo(Location.Items);
}

// remove from player empire
if (Player != null && Player.Character != this)
Dismiss();
Expand Down
2 changes: 2 additions & 0 deletions source/Burntime.Remaster/Logic/Character/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Burntime.Remaster.Logic
[Serializable]
public class Group : StateObject, ICharacterCollection
{
public const int MAX_PEOPLE = 5;

StateLinkList<Character> characterList;
float rangeFilterValue;

Expand Down
3 changes: 2 additions & 1 deletion source/Burntime.Remaster/Logic/Interaction/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ Conversation GetGreetingConversation(Character boss)
conv.Choices[1].Action = new ConversationAction(ConversationActionType.Talk);
conv.Choices[1].Text = ResourceManager.GetString("burn?492");
}
else if (Parent.Class != CharClass.Mutant && Parent.Class != CharClass.Dog && boss.IsPlayerCharacter && file != 510 && boss.Player.Group.Count < 5)
else if (Parent.Class != CharClass.Mutant && Parent.Class != CharClass.Dog && boss.IsPlayerCharacter && file != 510
&& boss.Player.Group.Count < Logic.Group.MAX_PEOPLE)
{
conv.Choices[0].Action = new ConversationAction(ConversationActionType.Talk);
conv.Choices[0].Text = ResourceManager.GetString("burn?492");
Expand Down
2 changes: 1 addition & 1 deletion source/Burntime.Remaster/Scenes/LocationScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void ShowMenu(Vector2 position)
{
menu.AddLine("@burn?364", (CommandHandler)OnMenuMakeCamp);
}
else
else if (view.Player.Group.Count < Logic.Group.MAX_PEOPLE)
{
menu.AddLine("@burn?365", (CommandHandler)OnMenuLeaveCamp);
}
Expand Down
Loading