Fixed netcode issue for stardust core.
This commit is contained in:
parent
fe1ecc44b1
commit
5c114285c5
|
@ -174,6 +174,7 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
var farm = (Farm)Game1.getLocationFromName("Farm");
|
var farm = (Farm)Game1.getLocationFromName("Farm");
|
||||||
foreach(var building in farm.buildings)
|
foreach(var building in farm.buildings)
|
||||||
{
|
{
|
||||||
|
if (String.IsNullOrEmpty(building.nameOfIndoors)) continue;
|
||||||
if (locations.Contains(building.nameOfIndoors)) continue;
|
if (locations.Contains(building.nameOfIndoors)) continue;
|
||||||
locations.Add(building.nameOfIndoors);
|
locations.Add(building.nameOfIndoors);
|
||||||
if (StardewSymphony.Config.EnableDebugLog)
|
if (StardewSymphony.Config.EnableDebugLog)
|
||||||
|
|
|
@ -118,8 +118,11 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
|
|
||||||
|
|
||||||
dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels);
|
dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels);
|
||||||
count = byteArray.Length;//dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(10000));
|
count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(10000));
|
||||||
|
if (count > byteArray.Length)
|
||||||
|
{
|
||||||
|
count = byteArray.Length;
|
||||||
|
}
|
||||||
dynamicSound.BufferNeeded += new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
|
dynamicSound.BufferNeeded += new EventHandler<EventArgs>(DynamicSound_BufferNeeded);
|
||||||
this.currentSong = new Song(p);
|
this.currentSong = new Song(p);
|
||||||
}
|
}
|
||||||
|
@ -131,10 +134,14 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
//StardewSymphony.ModMonitor.Log(count.ToString());
|
//StardewSymphony.ModMonitor.Log(count.ToString());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
dynamicSound.SubmitBuffer(byteArray, position, count);
|
dynamicSound.SubmitBuffer(byteArray, position, count);
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch(Exception err)
|
||||||
{
|
{
|
||||||
|
StardewSymphony.ModMonitor.Log(byteArray.Length.ToString());
|
||||||
|
StardewSymphony.ModMonitor.Log(position.ToString());
|
||||||
|
StardewSymphony.ModMonitor.Log(count.ToString());
|
||||||
StardewSymphony.ModMonitor.Log(err.ToString(), StardewModdingAPI.LogLevel.Error);
|
StardewSymphony.ModMonitor.Log(err.ToString(), StardewModdingAPI.LogLevel.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,6 +157,7 @@ namespace StardewSymphonyRemastered.Framework
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Name": "Stardew Symphony Remastered",
|
"Name": "Stardew Symphony Remastered",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "2.1.1",
|
"Version": "2.1.2",
|
||||||
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
"Description": "Adding more music to the game one beep at a time. Now with streaming!",
|
||||||
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
"UniqueID": "Omegasis.StardewSymphonyRemastered",
|
||||||
"EntryDll": "StardewSymphonyRemastered.dll",
|
"EntryDll": "StardewSymphonyRemastered.dll",
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StardustCore
|
||||||
|
{
|
||||||
|
public class ModConfig
|
||||||
|
{
|
||||||
|
public bool enableMultiplayerHack { get; set; } = false;
|
||||||
|
|
||||||
|
public ModConfig()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,6 +36,8 @@ namespace StardustCore
|
||||||
|
|
||||||
private Type lastMenuType;
|
private Type lastMenuType;
|
||||||
|
|
||||||
|
public ModConfig config;
|
||||||
|
|
||||||
public static string ContentDirectory;
|
public static string ContentDirectory;
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
|
@ -70,6 +72,7 @@ namespace StardustCore
|
||||||
TextureManagers.Add(ModManifest.UniqueID, TextureManager);
|
TextureManagers.Add(ModManifest.UniqueID, TextureManager);
|
||||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
||||||
|
|
||||||
|
config = ModHelper.ReadConfig<ModConfig>();
|
||||||
|
|
||||||
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
|
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
|
||||||
serverHack = false;
|
serverHack = false;
|
||||||
|
@ -78,7 +81,7 @@ namespace StardustCore
|
||||||
|
|
||||||
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
|
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
|
||||||
{
|
{
|
||||||
if (Game1.IsMasterGame == false)
|
if (Game1.IsMasterGame == false && config.enableMultiplayerHack)
|
||||||
{
|
{
|
||||||
if (this.lastMenuType == null)
|
if (this.lastMenuType == null)
|
||||||
{
|
{
|
||||||
|
@ -96,7 +99,7 @@ namespace StardustCore
|
||||||
|
|
||||||
private void MenuEvents_MenuChanged(object sender, StardewModdingAPI.Events.EventArgsClickableMenuChanged e)
|
private void MenuEvents_MenuChanged(object sender, StardewModdingAPI.Events.EventArgsClickableMenuChanged e)
|
||||||
{
|
{
|
||||||
if (Game1.IsMasterGame == false)
|
if (Game1.IsMasterGame == false && config.enableMultiplayerHack)
|
||||||
{
|
{
|
||||||
if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.ReadyCheckDialog))
|
if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.ReadyCheckDialog))
|
||||||
{
|
{
|
||||||
|
@ -147,7 +150,7 @@ namespace StardustCore
|
||||||
|
|
||||||
if (Game1.activeClickableMenu != null)
|
if (Game1.activeClickableMenu != null)
|
||||||
{
|
{
|
||||||
if(Game1.activeClickableMenu is StardewValley.Menus.TitleMenu)
|
if(Game1.activeClickableMenu is StardewValley.Menus.TitleMenu && config.enableMultiplayerHack)
|
||||||
{
|
{
|
||||||
if (TitleMenu.subMenu == null) return;
|
if (TitleMenu.subMenu == null) return;
|
||||||
if (TitleMenu.subMenu.GetType() == typeof(FarmhandMenu))
|
if (TitleMenu.subMenu.GetType() == typeof(FarmhandMenu))
|
||||||
|
@ -164,7 +167,7 @@ namespace StardustCore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Game1.server!=null&& serverHack==false)
|
if (Game1.server!=null&& serverHack==false && config.enableMultiplayerHack)
|
||||||
{
|
{
|
||||||
ModCore.ModMonitor.Log("OK!");
|
ModCore.ModMonitor.Log("OK!");
|
||||||
multiplayer = (Multiplayer)GetInstanceField(typeof(Game1), Program.gamePtr, "multiplayer");
|
multiplayer = (Multiplayer)GetInstanceField(typeof(Game1), Program.gamePtr, "multiplayer");
|
||||||
|
@ -176,7 +179,7 @@ namespace StardustCore
|
||||||
|
|
||||||
serverHack = true;
|
serverHack = true;
|
||||||
}
|
}
|
||||||
if (Game1.client !=null && serverHack == false)
|
if (Game1.client !=null && serverHack == false && config.enableMultiplayerHack)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,6 @@ namespace StardustCore.NetCode
|
||||||
ModCore.SerializationManager.cleanUpInventory();
|
ModCore.SerializationManager.cleanUpInventory();
|
||||||
ModCore.SerializationManager.cleanUpWorld();
|
ModCore.SerializationManager.cleanUpWorld();
|
||||||
ModCore.SerializationManager.cleanUpStorageContainers();
|
ModCore.SerializationManager.cleanUpStorageContainers();
|
||||||
ModCore.ModMonitor.Log("HELLO LOVE!!!");
|
|
||||||
this.sendMessage(peer, new OutgoingMessage((byte)1, Game1.serverHost.Value, new object[3]
|
this.sendMessage(peer, new OutgoingMessage((byte)1, Game1.serverHost.Value, new object[3]
|
||||||
{
|
{
|
||||||
(object)ModCore.multiplayer.writeObjectFullBytes<Farmer>((NetRoot<Farmer>)Game1.serverHost, new long?(peer)),
|
(object)ModCore.multiplayer.writeObjectFullBytes<Farmer>((NetRoot<Farmer>)Game1.serverHost, new long?(peer)),
|
||||||
|
|
|
@ -239,11 +239,13 @@ namespace StardustCore.Serialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Game1.getFarm() == null) return;
|
||||||
|
if (Game1.getFarm().buildings == null) return;
|
||||||
//Look through all farm buildings for custom items.
|
//Look through all farm buildings for custom items.
|
||||||
foreach (Building building in Game1.getFarm().buildings)
|
foreach (Building building in Game1.getFarm().buildings)
|
||||||
{
|
{
|
||||||
|
if (building == null) continue;
|
||||||
|
if (String.IsNullOrEmpty(building.nameOfIndoors)) continue;
|
||||||
GameLocation loc =Game1.getLocationFromName(building.nameOfIndoors,true);
|
GameLocation loc =Game1.getLocationFromName(building.nameOfIndoors,true);
|
||||||
//ModCore.ModMonitor.Log("Cleaning up farm building: "+loc.uniqueName.Value);
|
//ModCore.ModMonitor.Log("Cleaning up farm building: "+loc.uniqueName.Value);
|
||||||
int i = loc.objects.Pairs.Count();
|
int i = loc.objects.Pairs.Count();
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
<Compile Include="Interfaces\IToolSerializer.cs" />
|
<Compile Include="Interfaces\IToolSerializer.cs" />
|
||||||
<Compile Include="Math\Hex.cs" />
|
<Compile Include="Math\Hex.cs" />
|
||||||
<Compile Include="Math\Hex32.cs" />
|
<Compile Include="Math\Hex32.cs" />
|
||||||
|
<Compile Include="ModConfig.cs" />
|
||||||
<Compile Include="NetCode\Graphics\NetAnimation.cs" />
|
<Compile Include="NetCode\Graphics\NetAnimation.cs" />
|
||||||
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
|
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
|
||||||
<Compile Include="NetCode\ModdedClient.cs" />
|
<Compile Include="NetCode\ModdedClient.cs" />
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Name": "StardustCore",
|
"Name": "StardustCore",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "2.0.2",
|
"Version": "2.0.3",
|
||||||
"Description": "A core mod that allows for other mods of mine to be run.",
|
"Description": "A core mod that allows for other mods of mine to be run.",
|
||||||
"UniqueID": "Omegasis.StardustCore",
|
"UniqueID": "Omegasis.StardustCore",
|
||||||
"EntryDll": "StardustCore.dll",
|
"EntryDll": "StardustCore.dll",
|
||||||
|
|
Loading…
Reference in New Issue