Skip to content

Commit

Permalink
Merge pull request #61 from jcsnider/hotfixes
Browse files Browse the repository at this point in the history
Hotfixes

Former-commit-id: 8cc724bde3462264875a5d6f01c6b171ee4672de
  • Loading branch information
lodicolo committed Nov 16, 2017
2 parents bf8c373 + 054976f commit 8081170
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
13 changes: 13 additions & 0 deletions Intersect Client/Classes/Core/GameGraphics.cs
Expand Up @@ -141,6 +141,19 @@ public static void DrawInGame()
GridSwitched = false;
}


lock (AnimationLock)
{
var animations = LiveAnimations.ToArray();
foreach (AnimationInstance animInstance in animations)
{
if (animInstance.ParentGone())
{
animInstance.Dispose();
}
}
}

ClearDarknessTexture();
TryPreRendering();
FixAutotiles();
Expand Down
13 changes: 12 additions & 1 deletion Intersect Client/Classes/Entities/AnimationInstance.cs
Expand Up @@ -27,10 +27,12 @@ public class AnimationInstance
private int upperLoop;
private long upperTimer;
private int ZDimension = -1;
private Entity _parent;

public AnimationInstance(AnimationBase animBase, bool loopForever, bool autoRotate = false, int zDimension = -1)
public AnimationInstance(AnimationBase animBase, bool loopForever, bool autoRotate = false, int zDimension = -1, Entity parent = null)
{
MyBase = animBase;
_parent = parent;
if (MyBase != null)
{
lowerLoop = animBase.LowerAnimLoopCount;
Expand Down Expand Up @@ -179,6 +181,15 @@ public void Show()
Hidden = false;
}

public bool ParentGone()
{
if (_parent != null && _parent.IsDisposed())
{
return true;
}
return false;
}

public void Dispose()
{
lock (GameGraphics.AnimationLock)
Expand Down
2 changes: 1 addition & 1 deletion Intersect Client/Classes/Entities/Entity.cs
Expand Up @@ -277,7 +277,7 @@ public void AddAnimations(List<AnimationBase> anims)
{
foreach (var anim in anims)
{
Animations.Add(new AnimationInstance(anim,true));
Animations.Add(new AnimationInstance(anim,true,false,-1,this));
}
}

Expand Down
6 changes: 3 additions & 3 deletions Intersect Client/Classes/Entities/Projectile.cs
Expand Up @@ -117,7 +117,7 @@ private void AddProjectileSpawns()
ProjectileSpawns s = new ProjectileSpawns(FindProjectileRotationDir(Dir, d),
CurrentX + FindProjectileRotationX(Dir, x - 2, y - 2),
CurrentY + FindProjectileRotationY(Dir, x - 2, y - 2), CurrentZ, CurrentMap, animBase,
_myBase.Animations[Spawn].AutoRotate, _myBase);
_myBase.Animations[Spawn].AutoRotate, _myBase,this);
Spawns[_spawnedAmount] = s;
if (Collided(_spawnedAmount))
{
Expand Down Expand Up @@ -546,7 +546,7 @@ public class ProjectileSpawns
public int Z;

public ProjectileSpawns(int dir, int x, int y, int z, int map, AnimationBase animBase, bool autoRotate,
ProjectileBase projectileBase)
ProjectileBase projectileBase, Entity parent)
{
X = x;
Y = y;
Expand All @@ -556,7 +556,7 @@ public class ProjectileSpawns
Map = map;
SpawnMap = Map;
Dir = dir;
Anim = new AnimationInstance(animBase, true, autoRotate, Z);
Anim = new AnimationInstance(animBase, true, autoRotate, Z,parent);
AutoRotate = autoRotate;
ProjectileBase = projectileBase;
TransmittionTimer = Globals.System.GetTimeMS() +
Expand Down
4 changes: 2 additions & 2 deletions Intersect Client/Classes/Networking/PacketHandler.cs
Expand Up @@ -1201,7 +1201,7 @@ private static void HandlePlayAnimation(byte[] packet)
if (animBase != null)
{
AnimationInstance animInstance = new AnimationInstance(animBase, false,
dir == -1 ? false : true);
dir == -1 ? false : true,-1,Globals.Entities[entityIndex]);
if (dir > -1) animInstance.SetDir(dir);
Globals.Entities[entityIndex].Animations.Add(animInstance);
}
Expand All @@ -1225,7 +1225,7 @@ private static void HandlePlayAnimation(byte[] packet)
if (animBase != null)
{
AnimationInstance animInstance = new AnimationInstance(animBase, false,
dir == -1 ? true : false);
dir == -1 ? true : false,-1,map.LocalEntities[entityIndex]);
if (dir > -1) animInstance.SetDir(dir);
map.LocalEntities[entityIndex].Animations.Add(animInstance);
}
Expand Down
1 change: 1 addition & 0 deletions Intersect Client/Classes/UI/Game/QuestsWindow.cs
Expand Up @@ -291,6 +291,7 @@ private void UpdateSelectedQuest()
_questStatus.SetTextColor(Color.Red, Label.ControlState.Normal);
_questDescLabel.AddText(_selectedQuest.BeforeDesc, Color.White, Alignments.Left,
_questDescTemplateLabel.Font);
_quitButton?.Hide();
}
}
}
Expand Down

0 comments on commit 8081170

Please sign in to comment.