Some fixes from the ports.

This commit is contained in:
hondacrx
2021-09-26 16:14:57 -04:00
parent a43f839669
commit 35710258b9
7 changed files with 56 additions and 40 deletions
@@ -180,6 +180,12 @@ namespace System.Collections.Generic
{
Array.Clear(array, 0, array.Length);
}
public static void EnsureWritableListIndex<T>(this List<T> list, uint index, T defaultValue)
{
while (list.Count <= index)
list.Add(defaultValue);
}
}
public interface ICheck<in T>
+2 -2
View File
@@ -282,7 +282,7 @@ namespace Game.Collision
public GameObjectModel GetHitModel() { return _hitModel; }
PhaseShift _phaseShift;
LocationInfo _locationInfo;
GameObjectModel _hitModel;
LocationInfo _locationInfo = new();
GameObjectModel _hitModel = new();
}
}
@@ -286,7 +286,7 @@ namespace Game.DataStorage
uint oldMSTime = Time.GetMSTime();
// Load area trigger positions (to put them on the server)
// 0 1 2 3 4 5 6 7 8 9 10
SQLResult templates = DB.World.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup " +
SQLResult templates = DB.World.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, " +
//11 12 13 14 15 16 17
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5 FROM `areatrigger`");
if (!templates.IsEmpty())
@@ -311,7 +311,7 @@ namespace Game.Entities
public AreaTriggerScaleInfo OverrideScale = new();
public AreaTriggerScaleInfo ExtraScale = new();
public AreaTriggerShapeInfo Shape;
public AreaTriggerShapeInfo Shape = new();
public List<Vector2> PolygonVertices = new();
public List<Vector2> PolygonVerticesTarget = new();
public List<Vector3> SplinePoints = new();
@@ -327,7 +327,7 @@ namespace Game.Entities
public uint PhaseGroup;
public byte PhaseUseFlags;
public AreaTriggerShapeInfo Shape;
public AreaTriggerShapeInfo Shape = new();
}
public struct AreaTriggerAction
+15 -5
View File
@@ -41,7 +41,8 @@ namespace Game.Spells
if (spellEffect == null)
continue;
_effects.Add(new SpellEffectInfo(this, spellEffect));
_effects.EnsureWritableListIndex(spellEffect.EffectIndex, new SpellEffectInfo(this));
_effects[(int)spellEffect.EffectIndex] = new SpellEffectInfo(this, spellEffect);
}
SpellName = spellName.Name;
@@ -252,7 +253,10 @@ namespace Game.Spells
SpellName = spellName.Name;
foreach (SpellEffectRecord spellEffect in effects)
_effects.Add(new SpellEffectInfo(this, spellEffect));
{
_effects.EnsureWritableListIndex(spellEffect.EffectIndex, new SpellEffectInfo(this));
_effects[(int)spellEffect.EffectIndex] = new SpellEffectInfo(this, spellEffect);
}
}
public bool HasEffect(SpellEffectName effect)
@@ -307,6 +311,9 @@ namespace Game.Spells
public bool IsExplicitDiscovery()
{
if (GetEffects().Count < 2)
return false;
return ((GetEffect(0).Effect == SpellEffectName.CreateRandomItem
|| GetEffect(0).Effect == SpellEffectName.CreateLoot)
&& GetEffect(1).Effect == SpellEffectName.ScriptEffect)
@@ -3917,9 +3924,11 @@ namespace Game.Spells
public class SpellEffectInfo
{
public SpellEffectInfo(SpellInfo spellInfo, SpellEffectRecord effect)
public SpellEffectInfo(SpellInfo spellInfo, SpellEffectRecord effect = null)
{
_spellInfo = spellInfo;
if (effect != null)
{
EffectIndex = effect.EffectIndex;
Effect = (SpellEffectName)effect.Effect;
ApplyAuraName = (AuraType)effect.EffectAura;
@@ -3948,6 +3957,7 @@ namespace Game.Spells
Scaling.Variance = effect.Variance;
Scaling.ResourceCoefficient = effect.ResourceCoefficient;
EffectAttributes = effect.EffectAttributes;
}
ImplicitTargetConditions = null;
@@ -4669,8 +4679,8 @@ namespace Game.Spells
public int MiscValueB;
public Mechanics Mechanic;
public float PositionFacing;
public SpellImplicitTargetInfo TargetA;
public SpellImplicitTargetInfo TargetB;
public SpellImplicitTargetInfo TargetA = new();
public SpellImplicitTargetInfo TargetB = new();
public SpellRadiusRecord RadiusEntry;
public SpellRadiusRecord MaxRadiusEntry;
public int ChainTargets;
+1 -1
View File
@@ -2462,7 +2462,7 @@ namespace Game.Entities
Log.outError(LogFilter.Sql, $"Serverside spell {spellId} difficulty {difficulty} has invalid max radius id {effect.EffectRadiusIndex[1]} at index {effect.EffectIndex}, set to 0");
}
spellEffects[(spellId, difficulty)].Add(effect);
spellEffects.Add((spellId, difficulty), effect);
} while (effectsResult.NextRow());
}