Skip to content

Commit

Permalink
fix for latest SE
Browse files Browse the repository at this point in the history
only fixed obsolete code where it will be compatible with stable version
  • Loading branch information
Rynchodon committed Jan 27, 2017
1 parent 879bf01 commit 5ec68c8
Show file tree
Hide file tree
Showing 26 changed files with 127 additions and 121 deletions.
5 changes: 3 additions & 2 deletions .build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ def copyWithExtension(l_from, l_to, l_ext, log):
logging.info(command)
os.system('start /D "' + source + '" /WAIT cmd.exe /C ' + command)

SpaceEngineers = SpaceBin + '\SpaceEngineers.exe'
os.system('start /D ' + SpaceBin + ' cmd /c"' + SpaceEngineers)
if not "release" in str.lower(build):
SpaceEngineers = SpaceBin + '\SpaceEngineers.exe'
os.system('start /D ' + SpaceBin + ' cmd /c"' + SpaceEngineers)

# Pack Archive

Expand Down
10 changes: 9 additions & 1 deletion Scripts/ARMS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DefineConstants>UNSTABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug-Unstable|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug-Unstable\</OutputPath>
<DefineConstants>DEBUG;LOG_ENABLED UNSTABLE</DefineConstants>
<PlatformTarget>x64</PlatformTarget>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Sandbox.Common">
<HintPath>..\..\..\..\..\..\..\..\Games\Steam\SteamApps\common\SpaceEngineers\Bin64\Sandbox.Common.dll</HintPath>
Expand Down Expand Up @@ -314,7 +323,6 @@
<Compile Include="Utility\Version.cs" />
<Compile Include="Utility\XML_Amendments.cs" />
<Compile Include="Weapons\Ammo.cs" />
<Compile Include="Weapons\CharacterStateTracker.cs" />
<Compile Include="Weapons\Cluster.cs" />
<Compile Include="Weapons\FixedWeapon.cs" />
<Compile Include="Weapons\Guided\GuidedMissile.cs" />
Expand Down
6 changes: 6 additions & 0 deletions Scripts/ARMS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug-Unstable|x64 = Debug-Unstable|x64
Profile|x64 = Profile|x64
Release|x64 = Release|x64
Release-Unstable|x64 = Release-Unstable|x64
Expand All @@ -18,6 +19,9 @@ Global
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Debug|x64.ActiveCfg = Debug|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Debug|x64.Build.0 = Debug|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Debug|x64.Deploy.0 = Debug|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Debug-Unstable|x64.ActiveCfg = Debug-Unstable|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Debug-Unstable|x64.Build.0 = Debug-Unstable|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Debug-Unstable|x64.Deploy.0 = Debug-Unstable|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Profile|x64.ActiveCfg = Profile|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Profile|x64.Build.0 = Profile|x64
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Release|x64.ActiveCfg = Release|x64
Expand All @@ -26,6 +30,8 @@ Global
{76D2857A-6AAB-4DAD-8BCA-498984875AED}.Release-Unstable|x64.Build.0 = Release-Unstable|x64
{07082A56-DEB8-40F6-92E0-E57B5765FFC7}.Debug|x64.ActiveCfg = Release|x64
{07082A56-DEB8-40F6-92E0-E57B5765FFC7}.Debug|x64.Build.0 = Release|x64
{07082A56-DEB8-40F6-92E0-E57B5765FFC7}.Debug-Unstable|x64.ActiveCfg = Release|x64
{07082A56-DEB8-40F6-92E0-E57B5765FFC7}.Debug-Unstable|x64.Build.0 = Release|x64
{07082A56-DEB8-40F6-92E0-E57B5765FFC7}.Profile|x64.ActiveCfg = Release|x64
{07082A56-DEB8-40F6-92E0-E57B5765FFC7}.Profile|x64.Build.0 = Release|x64
{07082A56-DEB8-40F6-92E0-E57B5765FFC7}.Release|x64.ActiveCfg = Release|x64
Expand Down
4 changes: 2 additions & 2 deletions Scripts/AntennaRelay/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Player()
UpdateManager.Register(30, MissileHudWarning);
UpdateManager.Register(1, MissileAudioWarning);

myLogger.debugLog("initialized, player id: " + myPlayer.PlayerID + ", identity id: " + myPlayer.IdentityId, Logger.severity.DEBUG);
myLogger.debugLog("initialized, identity id: " + myPlayer.IdentityId, Logger.severity.DEBUG);
}

private void Update()
Expand Down Expand Up @@ -369,7 +369,7 @@ private bool CanDisplay(LastSeen seen, out UserSettings.ByteSettingName settingN
{
case LastSeen.EntityType.Character:
case LastSeen.EntityType.Grid:
switch (myPlayer.PlayerID.getRelationsTo(seen.Entity))
switch (myPlayer.IdentityId.getRelationsTo(seen.Entity))
{
case ExtensionsRelations.Relations.Enemy:
case ExtensionsRelations.Relations.NoOwner:
Expand Down
18 changes: 11 additions & 7 deletions Scripts/AntennaRelay/RadarEquipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ private float PowerLevel_Radar

#endregion

/// <summary>
/// Create a RadarEquipment for a block, getting the definition from the block.
/// </summary>
public RadarEquipment(IMyCubeBlock block)
{
this.myLogger = new Logger(block);
Expand All @@ -384,9 +387,10 @@ public RadarEquipment(IMyCubeBlock block)
PowerLevel_Current = Math.Min(PowerLevel_Target, myDefinition.MaxPowerLevel);
MyAPIGateway.Utilities.InvokeOnGameThread(UpdatePowerConsumption);

IMyFunctionalBlock func = block as IMyFunctionalBlock;
func.RequestEnable(false);
func.RequestEnable(true);
// maybe this is a bug fix?
MyFunctionalBlock func = (MyFunctionalBlock)block;
func.Enabled = false;
func.Enabled = true;

TermBlock.RefreshCustomInfo();

Expand All @@ -405,6 +409,9 @@ public RadarEquipment(IMyCubeBlock block)
myLogger.debugLog("Radar equipment initialized, power level: " + PowerLevel_Current, Logger.severity.INFO);
}

/// <summary>
/// Create a RadarEquipment for an entity, with the specified definition and an owner block.
/// </summary>
public RadarEquipment(IMyEntity radarEntity, Definition radarDef, IMyCubeBlock relationsBlock)
{
this.myLogger = new Logger(() => RelationsBlock.CubeGrid.DisplayName, () => RelationsBlock.DisplayNameText, () => radarEntity.ToString());
Expand Down Expand Up @@ -534,10 +541,7 @@ private void Update_OnThread()
catch (Exception ex)
{
myLogger.alwaysLog("Exception: " + ex, Logger.severity.ERROR);
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
if (CubeBlock != null)
(CubeBlock as IMyFunctionalBlock).RequestEnable(false);
});
CubeBlock.EnableGameThread(false);
}
finally
{ myLock.ReleaseExclusive(); }
Expand Down
2 changes: 1 addition & 1 deletion Scripts/AntennaRelay/RelayNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public RelayNode(IMyCharacter character)

this.m_loggingName = () => player.DisplayName;
this.m_logger = new Logger(this.m_loggingName);
this.m_ownerId = () => player.PlayerID;
this.m_ownerId = () => player.IdentityId;
this.m_entity = character as IMyEntity;
this.m_player = player;
this.m_comp_radio = ComponentRadio.CreateRadio(character);
Expand Down
3 changes: 2 additions & 1 deletion Scripts/Autopilot/Aerodynamics/FlightControlAssist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Rynchodon.Autopilot.Data;
using Sandbox.Game;
using Sandbox.Game.Entities;
using Sandbox.Game.Entities.Cube;
using Sandbox.Game.Gui;
using Sandbox.Game.World;
using Sandbox.ModAPI;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void SetTarget(float targetAngle)
targetAngle = -targetAngle;

float targetVelocity = (targetAngle - Stator.Angle) * 60f;
float currentVelocity = Stator.Velocity;
float currentVelocity = ((MyMotorStator)Stator).TargetVelocity;
if (((targetVelocity == 0f) != (currentVelocity == 0f)) || Math.Abs(targetVelocity - currentVelocity) > 0.1f)
VelocityProperty.SetValue(Stator, targetVelocity);
Logger.TraceLog("target acceleration: " + targetAngle + ", target angle: " + targetAngle + ", stator angle: " + Stator.Angle + ", target velocity: " + targetVelocity + ", current velocity: " + currentVelocity,
Expand Down
14 changes: 11 additions & 3 deletions Scripts/Autopilot/Instruction/TextPanelMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TextPanelMonitor
public readonly IMyTextPanel TextPanel;
private readonly AutopilotCommands m_autoCommands;
private string m_panelText, m_identifier;
private bool m_private = true;
private bool m_private = false;

private AutopilotActionList m_autopilotActions = new AutopilotActionList();

Expand All @@ -33,7 +33,11 @@ public TextPanelMonitor(IMyTextPanel textPanel, AutopilotCommands autoCommands,

private void CheckCommandsChanged()
{
string currentText = m_private ? TextPanel.GetPrivateText() : TextPanel.GetPublicText();
string currentText = m_private ?
#pragma warning disable CS0618
TextPanel.GetPrivateText() :
#pragma warning restore CS0618
TextPanel.GetPublicText();
if (currentText == m_panelText)
return;

Expand All @@ -57,7 +61,11 @@ private void GetAutopilotActions()
}

m_private = !m_private;
m_panelText = m_private ? TextPanel.GetPrivateText() : TextPanel.GetPublicText();
m_panelText = m_private ?
#pragma warning disable CS0618
TextPanel.GetPrivateText() :
#pragma warning restore CS0618
TextPanel.GetPublicText();
m = Regex.Match(m_panelText, pattern, RegexOptions.Singleline);
if (m.Success)
{
Expand Down
3 changes: 2 additions & 1 deletion Scripts/Autopilot/Navigator/Grinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Rynchodon.Autopilot.Pathfinding;
using Rynchodon.Weapons;
using Sandbox.Common.ObjectBuilders;
using Sandbox.Game.Entities.Cube;
using Sandbox.ModAPI;
using VRage;
using VRage.Game.Entity;
Expand Down Expand Up @@ -416,7 +417,7 @@ private void EnableGrinders(bool enable)
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
foreach (IMyShipGrinder grinder in CubeGridCache.GetFor(m_controlBlock.CubeGrid).BlocksOfType(typeof(MyObjectBuilder_ShipGrinder)))
if (!grinder.Closed)
grinder.RequestEnable(enable);
((MyFunctionalBlock)grinder).Enabled = enable;
});
}

Expand Down
3 changes: 2 additions & 1 deletion Scripts/Autopilot/Navigator/Mining/AMinerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Rynchodon.Autopilot.Pathfinding;
using Sandbox.Common.ObjectBuilders;
using Sandbox.Game.Entities;
using Sandbox.Game.Entities.Cube;
using Sandbox.ModAPI;
using VRageMath;

Expand Down Expand Up @@ -40,7 +41,7 @@ protected void EnableDrills(bool enable)
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
foreach (IMyShipDrill drill in cache.BlocksOfType(typeof(MyObjectBuilder_Drill)))
if (!drill.Closed)
drill.RequestEnable(enable);
((MyFunctionalBlock)drill).Enabled = enable;
});
}

Expand Down
35 changes: 15 additions & 20 deletions Scripts/Autopilot/Navigator/UnLander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using Rynchodon.Autopilot.Data;
using Rynchodon.Autopilot.Pathfinding;
using Sandbox.Common.ObjectBuilders;
using Sandbox.Game.Entities.Cube;
using Sandbox.ModAPI;
using SpaceEngineers.Game.Entities.Blocks;
using SpaceEngineers.Game.ModAPI;
using VRage.Game.ModAPI;
using VRageMath;
Expand Down Expand Up @@ -63,21 +65,15 @@ public UnLander(Pathfinder pathfinder, PseudoBlock unlandBlock = null)
else
{
m_logger.debugLog("Cannot unland block: " + m_unlandBlock.Block.DisplayNameText, Logger.severity.INFO);
IMyFunctionalBlock func = m_unlandBlock.Block as IMyFunctionalBlock;
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
if (func != null)
func.RequestEnable(false);
});
return;
m_unlandBlock.Block.EnableGameThread(false);
}
}

IMyCubeBlock block = this.m_unlandBlock.Block;
if (block is IMyLandingGear)
MyLandingGear landingGear = this.m_unlandBlock.Block as MyLandingGear;
if (landingGear != null)
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
(block as IMyFunctionalBlock).RequestEnable(true);
if ((block.GetObjectBuilderCubeBlock() as MyObjectBuilder_LandingGear).AutoLock)
asGear.ApplyAction("Autolock");
landingGear.Enabled = true;
landingGear.AutoLock = true;
});

m_detachOffset = m_unlandBlock.Block.GetPosition() - m_destination.Entity.GetPosition();
Expand All @@ -104,17 +100,15 @@ public override void Move()
return;
}
else if (m_unlandBlock.Block.IsWorking)
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => ((IMyFunctionalBlock)m_unlandBlock.Block).RequestEnable(false));
m_unlandBlock.Block.EnableGameThread(false);

double distSqMoved = Vector3D.DistanceSquared(m_destination.Entity.GetPosition() + m_detachOffset, m_unlandBlock.WorldPosition);
//m_navSet.Settings_Task_NavMove.Distance = (float)distanceMoved;
if (distSqMoved > 100f)
{
//if (m_detachLength >= Math.Min(m_controlBlock.CubeGrid.GetLongestDim(), m_navSet.Settings_Task_NavEngage.DestinationRadius))
//{
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
(m_unlandBlock.Block as IMyFunctionalBlock).RequestEnable(false);
});
m_unlandBlock.Block.EnableGameThread(false);
m_logger.debugLog("Moved away. distSqMoved: " + distSqMoved + ", dest radius: " + m_navSet.Settings_Task_NavEngage.DestinationRadius, Logger.severity.INFO);
m_navSet.OnTaskComplete_NavMove();
m_mover.MoveAndRotateStop(false);
Expand Down Expand Up @@ -148,17 +142,18 @@ private void Disconnect()
}
else
{
IMyShipConnector asConn = m_unlandBlock.Block as IMyShipConnector;
MyShipConnector asConn = (MyShipConnector)m_unlandBlock.Block;
if (asConn != null)
{
m_attached = asConn.IsConnected;
m_attached = asConn.Connected;
if (m_attached)
{
ReserveTarget(asConn.OtherConnector.EntityId);
MyShipConnector otherConnector = (MyShipConnector)((IMyShipConnector)asConn).OtherConnector;
ReserveTarget(otherConnector.EntityId);
m_logger.debugLog("Unlocking connector", Logger.severity.DEBUG);
MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
asConn.RequestEnable(true);
asConn.OtherConnector.RequestEnable(true);
asConn.Enabled = true;
otherConnector.Enabled = true;
asConn.ApplyAction("Unlock");
});
}
Expand Down
5 changes: 3 additions & 2 deletions Scripts/Autopilot/Navigator/WeldBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Sandbox.Common.ObjectBuilders; // from MedievalEngineers.ObjectBuilders.dll and SpaceEngineers.ObjectBuilders.dll
using Sandbox.Game.Entities;
using Sandbox.ModAPI; // from Sandbox.Common.dll
using SpaceEngineers.Game.Entities.Blocks;
using VRage.Game.ModAPI; // from VRage.Math.dll
using VRageMath;

Expand Down Expand Up @@ -325,9 +326,9 @@ private void EnableWelders(bool enable)
}

MyAPIGateway.Utilities.TryInvokeOnGameThread(() => {
foreach (IMyShipWelder welder in cache.BlocksOfType(typeof(MyObjectBuilder_ShipWelder)))
foreach (MyShipWelder welder in cache.BlocksOfType(typeof(MyObjectBuilder_ShipWelder)))
if (!welder.Closed)
welder.RequestEnable(enable);
welder.Enabled = enable;
});
}

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
//
// Major, Minor, and Build should be set in VersionInfo.cs not VersionInfo - User.cs
// Revision is set by pre-build.py
[assembly: AssemblyVersion("1.79.4.0")]
[assembly: AssemblyVersion("1.79.5.0")]
1 change: 0 additions & 1 deletion Scripts/Update/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ private void RegisterScripts_ClientAndServer()
RelayNode node = new RelayNode(character);
RegisterForUpdates(100, node.Update100, (IMyEntity)character);
}
new CharacterStateTracker(character);
});

RegisterForBlock(typeof(MyObjectBuilder_MyProgrammableBlock), block => {
Expand Down
15 changes: 10 additions & 5 deletions Scripts/Utility/Attached/LandingGear.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using System;
using SpaceEngineers.Game.ModAPI;
using Sandbox.Common.ObjectBuilders;
using SpaceEngineers.Game.Entities.Blocks;
using VRage.Game.ModAPI;
using VRage.ModAPI;

namespace Rynchodon.Attached
{
public class LandingGear : AttachableBlockBase
{
private IMyLandingGear myGear { get { return myBlock as IMyLandingGear; } }
private MyLandingGear myGear { get { return (MyLandingGear)myBlock; } }

public LandingGear(IMyCubeBlock block)
: base (block, AttachedGrid.AttachmentKind.LandingGear)
{
this.myGear.StateChanged += myGear_StateChanged;
this.myGear.LockModeChanged += MyGear_LockModeChanged;

IMyCubeGrid attached = myGear.GetAttachedEntity() as IMyCubeGrid;
if (attached != null)
Expand All @@ -23,10 +24,14 @@ public LandingGear(IMyCubeBlock block)

private void myGear_OnClosing(IMyEntity obj)
{
myGear.StateChanged -= myGear_StateChanged;
this.myGear.LockModeChanged -= MyGear_LockModeChanged;
}

private void myGear_StateChanged(bool obj)
#if UNSTABLE
private void MyGear_LockModeChanged(Sandbox.Game.Entities.Interfaces.IMyLandingGear gear, SpaceEngineers.Game.ModAPI.Ingame.LandingGearMode oldMode)
#else
private void MyGear_LockModeChanged(Sandbox.Game.Entities.Interfaces.IMyLandingGear gear, LandingGearMode oldMode)
#endif
{
try
{
Expand Down
6 changes: 6 additions & 0 deletions Scripts/Utility/Extensions/IMyCubeBlockExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using Sandbox.Definitions;
using Sandbox.Game.Entities;
using Sandbox.Game.Entities.Cube;
using Sandbox.ModAPI;
using VRage.Game;
using VRage.Game.ModAPI;
Expand Down Expand Up @@ -178,5 +179,10 @@ public static bool IsOnSide(this IMyCubeBlock block, Vector3 side)
return blockPosInDirect > centreInDirect;
}

public static void EnableGameThread(this IMyCubeBlock block, bool enable)
{
MyAPIGateway.Utilities.InvokeOnGameThread(() => ((MyFunctionalBlock)block).Enabled = enable);
}

}
}
Loading

0 comments on commit 5ec68c8

Please sign in to comment.