Skip to content

Commit

Permalink
Version 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed Dec 17, 2023
1 parent fba8488 commit 7187bf6
Show file tree
Hide file tree
Showing 9 changed files with 709 additions and 359 deletions.
2 changes: 1 addition & 1 deletion Art/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Coroner",
"version_number": "1.3.0",
"version_number": "1.3.1",
"website_url": "https://github.com/EliteMasterEric/Coroner",
"description": "Rework the Performance Report with new info, including cause of death.",
"dependencies": [
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# 1.3.1
## Fixed
- Fixed an issue where an exception in one of the cause-of-death patches would cause the player to not die.
- Fixed an issue where not having LC_API installed would cause an exception to occur.

# 1.3.0
## Additions
- Additional death messages for other death types.
Expand Down
2 changes: 1 addition & 1 deletion Coroner/Coroner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Company>EliteMasterEric</Company>
<AssemblyName>Coroner</AssemblyName>
<GUID>com.elitemastereric.coroner</GUID>
<Version>1.3.0</Version>
<Version>1.3.1</Version>

<Title>Coroner</Title>
<Description>Rework the Performance Report with new info, including cause of death.</Description>
Expand Down
23 changes: 4 additions & 19 deletions Coroner/DeathBroadcaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,13 @@ class DeathBroadcaster {
const string SIGNATURE_DEATH = PluginInfo.PLUGIN_GUID + ".death";

public static void Initialize() {
Plugin.Instance.PluginLogger.LogInfo("Initializing DeathBroadcaster...");
if (Plugin.Instance.IsLC_APIPresent) {
Plugin.Instance.PluginLogger.LogInfo("LC_API is present! Registering signature...");
LC_API.ServerAPI.Networking.GetString += OnBroadcastString;
if (Plugin.Instance.IsLCAPIPresent) {
Coroner.LCAPI.DeathBroadcasterLCAPI.Initialize();
} else {
Plugin.Instance.PluginLogger.LogInfo("LC_API is not present! Skipping registration...");
}
}

static void OnBroadcastString(string data, string signature) {
if (signature == SIGNATURE_DEATH) {
Plugin.Instance.PluginLogger.LogInfo("Broadcast has been received from LC_API!");
string[] split = data.Split('|');
int playerId = int.Parse(split[0]);
int causeOfDeathInt = int.Parse(split[1]);
AdvancedCauseOfDeath causeOfDeath = (AdvancedCauseOfDeath) causeOfDeathInt;
Plugin.Instance.PluginLogger.LogInfo("Player " + playerId + " died of " + AdvancedDeathTracker.StringifyCauseOfDeath(causeOfDeath));
AdvancedDeathTracker.SetCauseOfDeath(playerId, causeOfDeath, false);
}
}

public static void BroadcastCauseOfDeath(int playerId, AdvancedCauseOfDeath causeOfDeath) {
AttemptBroadcast(BuildDataCauseOfDeath(playerId, causeOfDeath), SIGNATURE_DEATH);
}
Expand All @@ -33,9 +19,8 @@ static string BuildDataCauseOfDeath(int playerId, AdvancedCauseOfDeath causeOfDe
}

static void AttemptBroadcast(string data, string signature) {
if (Plugin.Instance.IsLC_APIPresent) {
Plugin.Instance.PluginLogger.LogInfo("LC_API is present! Broadcasting...");
LC_API.ServerAPI.Networking.Broadcast(data, signature);
if (Plugin.Instance.IsLCAPIPresent) {
Coroner.LCAPI.DeathBroadcasterLCAPI.AttemptBroadcast(data, signature);
} else {
Plugin.Instance.PluginLogger.LogInfo("LC_API is not present! Skipping broadcast...");
}
Expand Down
38 changes: 38 additions & 0 deletions Coroner/LCAPI/DeathBroadcasterLCAPI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// DO NOT LOAD THIS CLASS UNLESS LC_API IS PRESENT!

namespace Coroner.LCAPI {
class DeathBroadcasterLCAPI {
const string SIGNATURE_DEATH = PluginInfo.PLUGIN_GUID + ".death";

public static void Initialize() {
Plugin.Instance.PluginLogger.LogInfo("Initializing DeathBroadcaster...");
if (Plugin.Instance.IsLCAPIPresent) {
Plugin.Instance.PluginLogger.LogInfo("LC_API is present! Registering signature...");
LC_API.ServerAPI.Networking.GetString += OnBroadcastString;
} else {
Plugin.Instance.PluginLogger.LogError("LC_API is not present! Why did you try to register the DeathBroadcaster?");
}
}

static void OnBroadcastString(string data, string signature) {
if (signature == SIGNATURE_DEATH) {
Plugin.Instance.PluginLogger.LogInfo("Broadcast has been received from LC_API!");
string[] split = data.Split('|');
int playerId = int.Parse(split[0]);
int causeOfDeathInt = int.Parse(split[1]);
AdvancedCauseOfDeath causeOfDeath = (AdvancedCauseOfDeath) causeOfDeathInt;
Plugin.Instance.PluginLogger.LogInfo("Player " + playerId + " died of " + AdvancedDeathTracker.StringifyCauseOfDeath(causeOfDeath));
AdvancedDeathTracker.SetCauseOfDeath(playerId, causeOfDeath, false);
}
}

public static void AttemptBroadcast(string data, string signature) {
if (Plugin.Instance.IsLCAPIPresent) {
Plugin.Instance.PluginLogger.LogInfo("LC_API is present! Broadcasting...");
LC_API.ServerAPI.Networking.Broadcast(data, signature);
} else {
Plugin.Instance.PluginLogger.LogInfo("LC_API is not present! Skipping broadcast...");
}
}
}
}
3 changes: 3 additions & 0 deletions Coroner/LCAPI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Coroner/LCAPI

Do NOT invoke any clases in this namespace unless `LC_API` is detected and present in the current installation.
Loading

0 comments on commit 7187bf6

Please sign in to comment.