Skip to content

Commit

Permalink
[LotView, VM] Fixes and minor changes
Browse files Browse the repository at this point in the history
- Fix sprites exploding on opengl, at the cost of performance (loading
textures invalidates index buffer state)
- Add person type that behaves more like an object in the UI
- Fix lines appearing in non-square remesh texture mipmaps.
- Add "ensure core objects" routine to server initialization. Spawns
missing objects like the trash can and mailbox.
- Skill meters and other headlines now appear properly in 2D.
  • Loading branch information
riperiperi committed Oct 30, 2019
1 parent cb9e4b4 commit 6ed79ea
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public override Dictionary<int, string> GetNamedProperties(EditorScope scope, VM
case VMSnapSlotScope.Literal:
var slotNs = scope.GetResource<STR>(257, ScopeSource.Private);
var slotRes = scope.GetResource<SLOT>(scope.GetOBJD().SlotID, ScopeSource.Private);
if (slotRes == null) return map;
if (slotRes == null || !slotRes.Slots.ContainsKey(3)) return map;
var slots = slotRes.Slots[3];
for (int i = 0; i < slots.Count; i++)
map.Add(i, (slotNs != null && slotNs.GetString(i) != null)?slotNs.GetString(i):"slot "+i);
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/FSO.IDE/EditorComponent/VarAnimSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void RefreshAnimTable()
{
for (int i = 0; i < AnimTable.Length; i++)
{
MyList.Items.Add((i == 0) ? "Stop Animation" : AnimTable.GetString(i, STRLangCode.EnglishUS));
MyList.Items.Add((i == 0) ? "Stop Animation" : AnimTable.GetString(i, STRLangCode.EnglishUS) ?? "");
}

MyList.SelectedItem = SelectedAnim;
Expand Down
1 change: 1 addition & 0 deletions TSOClient/FSO.Server/Servers/Lot/Domain/LotContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ public void ResetVM()
if (!JobLot) ReturnOOWObjects();

if (isMoved || isNew) VMLotTerrainRestoreTools.RestoreTerrain(Lot);
VMLotTerrainRestoreTools.EnsureCoreObjects(Lot);
if (isNew) VMLotTerrainRestoreTools.PopulateBlankTerrain(Lot);

Lot.ForwardCommand(new VMNetSetTimeCmd()
Expand Down
1 change: 1 addition & 0 deletions TSOClient/FSOFacadeWorker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static void Main(string[] args)
bool useDX = true;

FSOEnvironment.Enable3D = true;
GraphicsModeControl.ChangeMode(FSO.LotView.Model.GlobalGraphicsMode.Full3D);
GameThread.NoGame = true;
GameThread.UpdateExecuting = true;

Expand Down
24 changes: 15 additions & 9 deletions TSOClient/tso.client/UI/Panels/UILotControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,17 @@ public void LiveModeUpdate(UpdateState state, bool scrolled)
{
if (obj is VMAvatar)
{
state.UIState.TooltipProperties.Show = true;
state.UIState.TooltipProperties.Color = Color.Black;
state.UIState.TooltipProperties.Opacity = 1;
state.UIState.TooltipProperties.Position = new Vector2(state.MouseState.X,
state.MouseState.Y);
state.UIState.Tooltip = GetAvatarString(obj as VMAvatar);
state.UIState.TooltipProperties.UpdateDead = false;
ShowTooltip = true;
if (((VMAvatar)obj).GetPersonData(VMPersonDataVariable.PersonType) != 255)
{
state.UIState.TooltipProperties.Show = true;
state.UIState.TooltipProperties.Color = Color.Black;
state.UIState.TooltipProperties.Opacity = 1;
state.UIState.TooltipProperties.Position = new Vector2(state.MouseState.X,
state.MouseState.Y);
state.UIState.Tooltip = GetAvatarString(obj as VMAvatar);
state.UIState.TooltipProperties.UpdateDead = false;
ShowTooltip = true;
}
}
else if (((VMGameObject)obj).Disabled > 0)
{
Expand Down Expand Up @@ -675,7 +678,10 @@ public void LiveModeUpdate(UpdateState state, bool scrolled)
if (InteractionsAvailable)
{
var obj = vm.GetObjectById(ObjectHover);
if (obj is VMAvatar) cursor = CursorType.LivePerson;
if (obj is VMAvatar)
{
cursor = (((VMAvatar)obj).GetPersonData(VMPersonDataVariable.PersonType) != 255) ? CursorType.LivePerson : CursorType.LiveObjectAvail;
}
else
{
var tsoState = obj?.PlatformState as VMTSOObjectState;
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.client/UI/Panels/UIPersonGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void UpdatePeople()

foreach (var sim in vm.Context.ObjectQueries.Avatars)
{
if (!Display.Contains(sim) && sim.PersistID != vm.MyUID)
if (!Display.Contains(sim) && sim.PersistID != vm.MyUID && (sim as VMAvatar)?.GetPersonData(SimAntics.Model.VMPersonDataVariable.PersonType) != 255)
{
Display.Add((VMAvatar)sim);
change = true;
Expand Down
5 changes: 5 additions & 0 deletions TSOClient/tso.client/UI/Screens/SandboxGameScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ public void BlueprintReset(string path)

vm.Load(marshal);
vm.Reset();
var ents = vm.Entities.ToList();
foreach (var ent in ents)
{
ent.ExecuteEntryPoint(2, vm.Context, true);
}
}
}
catch (Exception)
Expand Down
2 changes: 1 addition & 1 deletion TSOClient/tso.common/utils/TextureUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ public static Color[] AvgDecimate(Color[] old, int w, int h)
int find = fyind;
for (int x = 0; x < nw; x++)
{
var xb = x * 2 == h || liney;
var xb = x * 2 == w || liney;
var c1 = old[find];
var c2 = (xb) ? Color.Transparent : old[find + 1];
var c3 = (yb) ? Color.Transparent : old[find + w];
Expand Down
Binary file modified TSOClient/tso.content/Content/Patch/lampceiling2.piff
Binary file not shown.
Binary file modified TSOClient/tso.content/Content/Patch/lampceiling2.spf.piff
Binary file not shown.
24 changes: 21 additions & 3 deletions TSOClient/tso.simantics/Utils/VMLotTerrainRestoreTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ public static void StampTerrainmap(VMArchitecture arch, byte[] tilemap, short x,
}
}

public static void RestoreTerrain(VM vm)
public static void RestoreTerrain(VM vm, bool withHeight = true)
{
//take center of lotstate
RestoreTerrain(vm, vm.TSOState.Terrain.BlendN[1, 1], vm.TSOState.Terrain.Roads[1, 1]);

RestoreHeight(vm, vm.TSOState.Terrain, 1, 1);
if (withHeight) RestoreHeight(vm, vm.TSOState.Terrain, 1, 1);
}

public static int GetBaseLevel(VM vm, VMTSOSurroundingTerrain terrain, int x, int y)
Expand Down Expand Up @@ -721,6 +721,20 @@ public GUIDToPosition(uint guid, short x, short y, int dirOff)
new GUIDToPosition(0xD564C66B, -5, 3, 2), //car portal 2
};

public static void EnsureCoreObjects(VM vm)
{
var fail = MovePositions.Where(x =>
{
//find an object of this type
var ent = EntityByGUID(vm, x.GUID);
return ent == null || ent.Position == LotTilePos.OUT_OF_WORLD;
});
if (fail.Count() > 0)
{
PositionLandmarkObjects(vm);
}
}

/// <summary>
/// Positions the Landmark objects depending on the lot direction. (npc/car portals, bin, mailbox, phone)
/// </summary>
Expand Down Expand Up @@ -772,9 +786,13 @@ public static void PositionLandmarkObjects(VM vm)
{
var rpos = ctr + (pos.X * xperp) + (pos.Y * yperp);
var ent = EntityByGUID(vm, pos.GUID);
if (ent == null)
{
ent = vm.Context.CreateObjectInstance(pos.GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH).BaseObject;
}
if (ent != null)
{
var result = ent.MultitileGroup.BaseObject.SetPosition(LotTilePos.FromBigTile((short)rpos.X, (short)rpos.Y, 1), (Direction)(1 << ((lotDir*2 + pos.DirOff) % 8)), vm.Context);
var result = ent.MultitileGroup.BaseObject.SetPosition(LotTilePos.FromBigTile((short)rpos.X, (short)rpos.Y, 1), (Direction)(1 << ((lotDir*2 + pos.DirOff) % 8)), vm.Context, VMPlaceRequestFlags.AllowIntersection);
if (result.Status != VMPlacementError.Success)
{
// if we can't place the object, put it oow.
Expand Down
1 change: 1 addition & 0 deletions TSOClient/tso.world/components/AvatarComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public override void Draw(GraphicsDevice device, WorldState world)

HeadlineSprite.Room = Room;
HeadlineSprite.PrepareVertices(device);
world._2D.EnsureIndices();
world._2D.DrawImmediate(HeadlineSprite);
}
device.RasterizerState = lastCull;
Expand Down
13 changes: 13 additions & 0 deletions TSOClient/tso.world/utils/_2DWorldBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ public void PrepareImmediate(WorldBatchTechniques technique)
Device.Indices = SpriteIndices;
}

public void EnsureIndices()
{
if (Device.Indices != SpriteIndices)
{
Device.Indices = SpriteIndices;
}
}

public void SetShaderOffsets(Vector2 pxOffset, Vector3 worldOffset)
{
var effect = this.Effect;
Expand All @@ -356,6 +364,11 @@ public void SetShaderOffsets(Vector2 pxOffset, Vector3 worldOffset)
public void DrawImmediate(_2DStandaloneSprite sprite)
{
var effect = this.Effect;
if (!FSOEnvironment.DirectX)
{
Device.Indices = null; //monogame why
Device.Indices = SpriteIndices;
}
PPXDepthEngine.RenderPPXDepth(effect, false, (depth) =>
{
effect.pixelTexture = sprite.Pixel;
Expand Down

0 comments on commit 6ed79ea

Please sign in to comment.