Fixed netcode issue for stardust core.

This commit is contained in:
2018-08-20 13:53:56 -07:00
parent fe1ecc44b1
commit 5c114285c5
9 changed files with 46 additions and 13 deletions

View File

@ -174,6 +174,7 @@ namespace StardewSymphonyRemastered.Framework
var farm = (Farm)Game1.getLocationFromName("Farm");
foreach(var building in farm.buildings)
{
if (String.IsNullOrEmpty(building.nameOfIndoors)) continue;
if (locations.Contains(building.nameOfIndoors)) continue;
locations.Add(building.nameOfIndoors);
if (StardewSymphony.Config.EnableDebugLog)

View File

@ -118,8 +118,11 @@ namespace StardewSymphonyRemastered.Framework
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);
this.currentSong = new Song(p);
}
@ -131,10 +134,14 @@ namespace StardewSymphonyRemastered.Framework
//StardewSymphony.ModMonitor.Log(count.ToString());
try
{
dynamicSound.SubmitBuffer(byteArray, position, count);
}
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);
}
@ -150,6 +157,7 @@ namespace StardewSymphonyRemastered.Framework
}
else
{
}
}
}

View File

@ -1,7 +1,7 @@
{
"Name": "Stardew Symphony Remastered",
"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!",
"UniqueID": "Omegasis.StardewSymphonyRemastered",
"EntryDll": "StardewSymphonyRemastered.dll",

View File

@ -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()
{
}
}
}

View File

@ -36,6 +36,8 @@ namespace StardustCore
private Type lastMenuType;
public ModConfig config;
public static string ContentDirectory;
public override void Entry(IModHelper helper)
{
@ -70,6 +72,7 @@ namespace StardustCore
TextureManagers.Add(ModManifest.UniqueID, TextureManager);
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
config = ModHelper.ReadConfig<ModConfig>();
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
serverHack = false;
@ -78,7 +81,7 @@ namespace StardustCore
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
{
if (Game1.IsMasterGame == false)
if (Game1.IsMasterGame == false && config.enableMultiplayerHack)
{
if (this.lastMenuType == null)
{
@ -96,7 +99,7 @@ namespace StardustCore
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))
{
@ -147,7 +150,7 @@ namespace StardustCore
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.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!");
multiplayer = (Multiplayer)GetInstanceField(typeof(Game1), Program.gamePtr, "multiplayer");
@ -176,7 +179,7 @@ namespace StardustCore
serverHack = true;
}
if (Game1.client !=null && serverHack == false)
if (Game1.client !=null && serverHack == false && config.enableMultiplayerHack)
{
}

View File

@ -164,7 +164,6 @@ namespace StardustCore.NetCode
ModCore.SerializationManager.cleanUpInventory();
ModCore.SerializationManager.cleanUpWorld();
ModCore.SerializationManager.cleanUpStorageContainers();
ModCore.ModMonitor.Log("HELLO LOVE!!!");
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)),

View File

@ -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.
foreach (Building building in Game1.getFarm().buildings)
{
if (building == null) continue;
if (String.IsNullOrEmpty(building.nameOfIndoors)) continue;
GameLocation loc =Game1.getLocationFromName(building.nameOfIndoors,true);
//ModCore.ModMonitor.Log("Cleaning up farm building: "+loc.uniqueName.Value);
int i = loc.objects.Pairs.Count();

View File

@ -93,6 +93,7 @@
<Compile Include="Interfaces\IToolSerializer.cs" />
<Compile Include="Math\Hex.cs" />
<Compile Include="Math\Hex32.cs" />
<Compile Include="ModConfig.cs" />
<Compile Include="NetCode\Graphics\NetAnimation.cs" />
<Compile Include="NetCode\Graphics\NetAnimationManager.cs" />
<Compile Include="NetCode\ModdedClient.cs" />

View File

@ -1,7 +1,7 @@
{
"Name": "StardustCore",
"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.",
"UniqueID": "Omegasis.StardustCore",
"EntryDll": "StardustCore.dll",