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); 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> public interface ICheck<in T>
+2 -2
View File
@@ -282,7 +282,7 @@ namespace Game.Collision
public GameObjectModel GetHitModel() { return _hitModel; } public GameObjectModel GetHitModel() { return _hitModel; }
PhaseShift _phaseShift; PhaseShift _phaseShift;
LocationInfo _locationInfo; LocationInfo _locationInfo = new();
GameObjectModel _hitModel; GameObjectModel _hitModel = new();
} }
} }
@@ -286,7 +286,7 @@ namespace Game.DataStorage
uint oldMSTime = Time.GetMSTime(); uint oldMSTime = Time.GetMSTime();
// Load area trigger positions (to put them on the server) // Load area trigger positions (to put them on the server)
// 0 1 2 3 4 5 6 7 8 9 10 // 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 //11 12 13 14 15 16 17
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5 FROM `areatrigger`"); "Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5 FROM `areatrigger`");
if (!templates.IsEmpty()) if (!templates.IsEmpty())
@@ -311,7 +311,7 @@ namespace Game.Entities
public AreaTriggerScaleInfo OverrideScale = new(); public AreaTriggerScaleInfo OverrideScale = new();
public AreaTriggerScaleInfo ExtraScale = new(); public AreaTriggerScaleInfo ExtraScale = new();
public AreaTriggerShapeInfo Shape; public AreaTriggerShapeInfo Shape = new();
public List<Vector2> PolygonVertices = new(); public List<Vector2> PolygonVertices = new();
public List<Vector2> PolygonVerticesTarget = new(); public List<Vector2> PolygonVerticesTarget = new();
public List<Vector3> SplinePoints = new(); public List<Vector3> SplinePoints = new();
@@ -327,7 +327,7 @@ namespace Game.Entities
public uint PhaseGroup; public uint PhaseGroup;
public byte PhaseUseFlags; public byte PhaseUseFlags;
public AreaTriggerShapeInfo Shape; public AreaTriggerShapeInfo Shape = new();
} }
public struct AreaTriggerAction public struct AreaTriggerAction
+15 -5
View File
@@ -41,7 +41,8 @@ namespace Game.Spells
if (spellEffect == null) if (spellEffect == null)
continue; 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; SpellName = spellName.Name;
@@ -252,7 +253,10 @@ namespace Game.Spells
SpellName = spellName.Name; SpellName = spellName.Name;
foreach (SpellEffectRecord spellEffect in effects) 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) public bool HasEffect(SpellEffectName effect)
@@ -307,6 +311,9 @@ namespace Game.Spells
public bool IsExplicitDiscovery() public bool IsExplicitDiscovery()
{ {
if (GetEffects().Count < 2)
return false;
return ((GetEffect(0).Effect == SpellEffectName.CreateRandomItem return ((GetEffect(0).Effect == SpellEffectName.CreateRandomItem
|| GetEffect(0).Effect == SpellEffectName.CreateLoot) || GetEffect(0).Effect == SpellEffectName.CreateLoot)
&& GetEffect(1).Effect == SpellEffectName.ScriptEffect) && GetEffect(1).Effect == SpellEffectName.ScriptEffect)
@@ -3917,9 +3924,11 @@ namespace Game.Spells
public class SpellEffectInfo public class SpellEffectInfo
{ {
public SpellEffectInfo(SpellInfo spellInfo, SpellEffectRecord effect) public SpellEffectInfo(SpellInfo spellInfo, SpellEffectRecord effect = null)
{ {
_spellInfo = spellInfo; _spellInfo = spellInfo;
if (effect != null)
{
EffectIndex = effect.EffectIndex; EffectIndex = effect.EffectIndex;
Effect = (SpellEffectName)effect.Effect; Effect = (SpellEffectName)effect.Effect;
ApplyAuraName = (AuraType)effect.EffectAura; ApplyAuraName = (AuraType)effect.EffectAura;
@@ -3948,6 +3957,7 @@ namespace Game.Spells
Scaling.Variance = effect.Variance; Scaling.Variance = effect.Variance;
Scaling.ResourceCoefficient = effect.ResourceCoefficient; Scaling.ResourceCoefficient = effect.ResourceCoefficient;
EffectAttributes = effect.EffectAttributes; EffectAttributes = effect.EffectAttributes;
}
ImplicitTargetConditions = null; ImplicitTargetConditions = null;
@@ -4669,8 +4679,8 @@ namespace Game.Spells
public int MiscValueB; public int MiscValueB;
public Mechanics Mechanic; public Mechanics Mechanic;
public float PositionFacing; public float PositionFacing;
public SpellImplicitTargetInfo TargetA; public SpellImplicitTargetInfo TargetA = new();
public SpellImplicitTargetInfo TargetB; public SpellImplicitTargetInfo TargetB = new();
public SpellRadiusRecord RadiusEntry; public SpellRadiusRecord RadiusEntry;
public SpellRadiusRecord MaxRadiusEntry; public SpellRadiusRecord MaxRadiusEntry;
public int ChainTargets; 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"); 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()); } while (effectsResult.NextRow());
} }