Skip to content

Commit

Permalink
[Bugfix] Fix bugs and improve performance
Browse files Browse the repository at this point in the history
- Fix issue doing like anything with objects in db
- Fix booting on osx (run `mono update.exe` if you're in trouble)
- Add "force update" by holding shift and pressing F10 at login
- Enable culling for objects in 3D/Hybrid 2D
- Allow clicking thru floor levels similar to newer updates of old
lotview
- Fix crash when changing surrounding lot settings
- Draw "headlines" after other elements
- Fix server crash when creating new or job lot.
  • Loading branch information
riperiperi committed Oct 23, 2019
1 parent a8df715 commit 71cd382
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion TSOClient/FSO.Server.Database/DA/Objects/SqlObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public bool UpdatePersistState(uint id, DbObject obj)
+ "value = @value, "
+ "dyn_flags_1 = @dyn_flags_1, "
+ "dyn_flags_2 = @dyn_flags_2, "
+ "upgrade_level = @upgrade_level "
+ "upgrade_level = @upgrade_level, "
+ "has_db_attributes = @has_db_attributes "
+ "WHERE object_id = @object_id AND (@lot_id IS NULL OR lot_id = @lot_id);", obj) > 0;
}
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.client/FSOProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public bool InitWithArguments(string[] args)
Directory.SetCurrentDirectory(baseDir);
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
AppDomain.CurrentDomain.SetDynamicBase(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content/JITCache/"));
//AppDomain.CurrentDomain.SetDynamicBase(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content/JITCache/"));

OperatingSystem os = Environment.OSVersion;
PlatformID pid = os.Platform;
Expand Down
5 changes: 5 additions & 0 deletions TSOClient/tso.client/UI/Screens/LoginScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public override void Update(UpdateState state)
base.Update(state);
if (state.NewKeys.Contains(Microsoft.Xna.Framework.Input.Keys.F1))
FSOFacade.Controller.ToggleDebugMenu();
if (state.ShiftDown && state.NewKeys.Contains(Microsoft.Xna.Framework.Input.Keys.F10))
{
GlobalSettings.Default.ClientVersion = "bad/version-23";
UIAlert.Alert("Update Force", "Holding shift and pressing F10 will force the next login to re-update. Useful for fixing weird issues! Try log in now.", true);
}
}

public override void GameResized()
Expand Down
1 change: 1 addition & 0 deletions TSOClient/tso.common/utils/PPXDepthEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static void InitScreenTargets()
{
if (GD == null) return;
if (BackbufferDepth != null) BackbufferDepth.Dispose();
BackbufferDepth = null;
if (Backbuffer != null) Backbuffer.Dispose();
var scale = 1;//FSOEnvironment.DPIScaleFactor;
if (!FSOEnvironment.Enable3D)
Expand Down
3 changes: 2 additions & 1 deletion TSOClient/tso.world/Platform/WorldPlatform2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public short GetObjectIDAtScreenPos(int x, int y, GraphicsDevice gd, WorldState
foreach (var obj in bp.Objects)
{
var tilePosition = obj.Position;
if (obj.Level != state.Level || !obj.DoDraw(state)) continue;
if (obj.Level > state.Level || !obj.DoDraw(state)) continue;
obj.Draw(gd, state);
}
_2d.EndImmediate();
Expand All @@ -153,6 +153,7 @@ public short GetObjectIDAtScreenPos(int x, int y, GraphicsDevice gd, WorldState

foreach (var avatar in bp.Avatars)
{
if (avatar.Level > state.Level) continue;
_2d.OffsetPixel(state.WorldSpace.GetScreenFromTile(avatar.Position));
_2d.OffsetTile(avatar.Position);
avatar.Draw(gd, state);
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/Platform/WorldPlatform3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public short GetObjectIDAtScreenPos(int x, int y, GraphicsDevice gd, WorldState
float bestDistance = float.MaxValue;
foreach (var obj in bp.Objects)
{
if (obj.Level != state.Level || !obj.Visible || obj.CutawayHidden) continue;
if (obj.Level > state.Level || !obj.Visible || obj.CutawayHidden) continue;
var intr = obj.IntersectsBounds(ray);
if (obj.Container != null && intr != null) intr = intr.Value - 1.5f;
if (intr != null && intr.Value < bestDistance)
Expand Down
3 changes: 2 additions & 1 deletion TSOClient/tso.world/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ protected virtual void InternalDraw(GraphicsDevice device)
State.PrepareCamera();
Entities.DrawAvatars(device, State);
Entities.Draw(device, State);
Entities.DrawAvatarTransparency(device, State);

State._2D.OutputDepth = false;
}
Expand Down Expand Up @@ -1077,7 +1078,7 @@ public override void Dispose()
Light?.Dispose();
Platform?.Dispose();
State.Rooms.Dispose();
if (State._2D != null) State._2D.Dispose();
if (State._2D != null && !(this is SubWorldComponent)) State._2D.Dispose();
if (Blueprint != null)
{
foreach (var world in Blueprint.SubWorlds)
Expand Down
15 changes: 13 additions & 2 deletions TSOClient/tso.world/WorldEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void DrawAvatars(GraphicsDevice gd, WorldState state)
gd.DepthStencilState = DepthStencilState.Default;
gd.BlendState = BlendState.AlphaBlend;
gd.RasterizerState = RasterizerState.CullCounterClockwise;

var advDir = (WorldConfig.Current.Directional && WorldConfig.Current.AdvancedLighting);
var pass = advDir ? 5 : WorldConfig.Current.PassOffset * 2;

Expand All @@ -95,10 +95,21 @@ public void DrawAvatars(GraphicsDevice gd, WorldState state)
{
if (avatar.Level <= state.Level) avatar.Draw(gd, state);
}

gd.RasterizerState = RasterizerState.CullNone;
}

public void DrawAvatarTransparency(GraphicsDevice gd, WorldState state)
{
if (!state.Cameras.Safe2D)
{
foreach (var avatar in Blueprint.Avatars)
{
if (avatar.Level <= state.Level) avatar.DrawHeadline3D(gd, state);
}
}
}

public void Draw(GraphicsDevice gd, WorldState state)
{
var changes = Blueprint.Changes;
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/WorldState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public int WorldSize
}
set {
_WorldSize = value;
Camera2D.WorldSize = value;
if (Camera2D != null) Camera2D.WorldSize = value;
InvalidateWorldSize();
}
}
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/components/AvatarComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public override void Draw(GraphicsDevice device, WorldState world)
var headOff = (transhead-Position) + new Vector3(0,0,0.66f);
if (!world.Cameras.Safe2D)
{
DrawHeadline3D(device, world);
//DrawHeadline3D(device, world);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.world/components/ObjectComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public bool DoDraw(WorldState world)
{
result |= world.Frustum.Intersects(GetBounds());
}
return result || true;
return result;
}

public void ValidateSprite(WorldState world)
Expand Down

0 comments on commit 71cd382

Please sign in to comment.