Some startup fixes and cleanups

This commit is contained in:
hondacrx
2023-02-10 22:14:58 -05:00
parent 149fadccab
commit 7d4bbd78fc
10 changed files with 42 additions and 53 deletions
+20 -16
View File
@@ -15,13 +15,14 @@ namespace Game.Chat
class ModifyCommand
{
[Command("hp", RBACPermissions.CommandModifyHp)]
static bool HandleModifyHPCommand(CommandHandler handler, int hp, int? maxHp)
static bool HandleModifyHPCommand(CommandHandler handler, int hp)
{
Player target = handler.GetSelectedPlayerOrSelf();
int maxHp = 1;
if (CheckModifyResources(handler, target, ref hp, ref maxHp))
{
NotifyModification(handler, target, CypherStrings.YouChangeHp, CypherStrings.YoursHpChanged, hp, maxHp);
target.SetMaxHealth((uint)maxHp.Value);
target.SetMaxHealth((uint)maxHp);
target.SetHealth((uint)hp);
return true;
}
@@ -29,14 +30,14 @@ namespace Game.Chat
}
[Command("mana", RBACPermissions.CommandModifyMana)]
static bool HandleModifyManaCommand(CommandHandler handler, int mana, int? maxMana)
static bool HandleModifyManaCommand(CommandHandler handler, int mana)
{
Player target = handler.GetSelectedPlayerOrSelf();
int maxMana = 1;
if (CheckModifyResources(handler, target, ref mana, ref maxMana))
{
NotifyModification(handler, target, CypherStrings.YouChangeMana, CypherStrings.YoursManaChanged, mana, maxMana.Value);
target.SetMaxPower(PowerType.Mana, maxMana.Value);
NotifyModification(handler, target, CypherStrings.YouChangeMana, CypherStrings.YoursManaChanged, mana, maxMana);
target.SetMaxPower(PowerType.Mana, maxMana);
target.SetPower(PowerType.Mana, mana);
return true;
}
@@ -45,14 +46,15 @@ namespace Game.Chat
}
[Command("energy", RBACPermissions.CommandModifyEnergy)]
static bool HandleModifyEnergyCommand(CommandHandler handler, int energy, int? maxEnergy)
static bool HandleModifyEnergyCommand(CommandHandler handler, int energy)
{
Player target = handler.GetSelectedPlayerOrSelf();
byte energyMultiplier = 10;
int maxEnergy = 1;
if (CheckModifyResources(handler, target, ref energy, ref maxEnergy, energyMultiplier))
{
NotifyModification(handler, target, CypherStrings.YouChangeEnergy, CypherStrings.YoursEnergyChanged, energy / energyMultiplier, maxEnergy.Value / energyMultiplier);
target.SetMaxPower(PowerType.Energy, maxEnergy.Value);
NotifyModification(handler, target, CypherStrings.YouChangeEnergy, CypherStrings.YoursEnergyChanged, energy / energyMultiplier, maxEnergy / energyMultiplier);
target.SetMaxPower(PowerType.Energy, maxEnergy);
target.SetPower(PowerType.Energy, energy);
return true;
}
@@ -60,14 +62,15 @@ namespace Game.Chat
}
[Command("rage", RBACPermissions.CommandModifyRage)]
static bool HandleModifyRageCommand(CommandHandler handler, int rage, int? maxRage)
static bool HandleModifyRageCommand(CommandHandler handler, int rage)
{
Player target = handler.GetSelectedPlayerOrSelf();
byte rageMultiplier = 10;
int maxRage = 1;
if (CheckModifyResources(handler, target, ref rage, ref maxRage, rageMultiplier))
{
NotifyModification(handler, target, CypherStrings.YouChangeRage, CypherStrings.YoursRageChanged, rage / rageMultiplier, maxRage.Value / rageMultiplier);
target.SetMaxPower(PowerType.Rage, maxRage.Value);
NotifyModification(handler, target, CypherStrings.YouChangeRage, CypherStrings.YoursRageChanged, rage / rageMultiplier, maxRage / rageMultiplier);
target.SetMaxPower(PowerType.Rage, maxRage);
target.SetPower(PowerType.Rage, rage);
return true;
}
@@ -75,14 +78,15 @@ namespace Game.Chat
}
[Command("runicpower", RBACPermissions.CommandModifyRunicpower)]
static bool HandleModifyRunicPowerCommand(CommandHandler handler, int rune, int? maxRune)
static bool HandleModifyRunicPowerCommand(CommandHandler handler, int rune)
{
Player target = handler.GetSelectedPlayerOrSelf();
byte runeMultiplier = 10;
int maxRune = 1;
if (CheckModifyResources(handler, target, ref rune, ref maxRune, runeMultiplier))
{
NotifyModification(handler, target, CypherStrings.YouChangeRunicPower, CypherStrings.YoursRunicPowerChanged, rune / runeMultiplier, maxRune.Value / runeMultiplier);
target.SetMaxPower(PowerType.RunicPower, maxRune.Value);
NotifyModification(handler, target, CypherStrings.YouChangeRunicPower, CypherStrings.YoursRunicPowerChanged, rune / runeMultiplier, maxRune / runeMultiplier);
target.SetMaxPower(PowerType.RunicPower, maxRune);
target.SetPower(PowerType.RunicPower, rune);
return true;
}
@@ -816,7 +820,7 @@ namespace Game.Chat
}
}
static bool CheckModifyResources(CommandHandler handler, Player target, ref int res, ref int? resmax, byte multiplier = 1)
static bool CheckModifyResources(CommandHandler handler, Player target, ref int res, ref int resmax, byte multiplier = 1)
{
res *= multiplier;
resmax *= multiplier;
+2 -1
View File
@@ -3030,7 +3030,8 @@ namespace Game
"ConversationLine",
"AreaTrigger Client Triggered",
"Trainer Spell",
"Object Visibility (by ID)"
"Object Visibility (by ID)",
"Spawn Group"
};
public ConditionTypeInfo[] StaticConditionTypeData =
@@ -90,13 +90,11 @@ namespace Game.DataStorage
}
}
long previousStringTableSize = 0;
long previousRecordCount = 0;
for (int sectionIndex = 0; sectionIndex < Header.SectionsCount; sectionIndex++)
{
if (sections[sectionIndex].TactKeyLookup != 0)// && !hasTactKeyFunc(sections[sectionIndex].TactKeyLookup))
{
previousStringTableSize += sections[sectionIndex].StringTableSize;
previousRecordCount += sections[sectionIndex].NumRecords;
//Console.WriteLine("Detected db2 with encrypted section! HasKey {0}", CASC.HasKey(Sections[sectionIndex].TactKeyLookup));
continue;
@@ -116,17 +114,11 @@ namespace Game.DataStorage
// string data
stringsTable = new Dictionary<long, string>();
long stringDataOffset = 0;
if (sectionIndex == 0)
stringDataOffset = (Header.RecordCount - sections[sectionIndex].NumRecords) * Header.RecordSize;
else
stringDataOffset = previousStringTableSize;
for (int i = 0; i < sections[sectionIndex].StringTableSize;)
{
long oldPos = reader.BaseStream.Position;
stringsTable[i + stringDataOffset] = reader.ReadCString();
stringsTable[i] = reader.ReadCString();
i += (int)(reader.BaseStream.Position - oldPos);
}
@@ -220,7 +212,6 @@ namespace Game.DataStorage
}
}
previousStringTableSize += sections[sectionIndex].StringTableSize;
previousRecordCount += sections[sectionIndex].NumRecords;
}
}
+1 -1
View File
@@ -390,7 +390,7 @@ namespace Game.Entities
{
if (missingQuest != 0 && !string.IsNullOrEmpty(ar.questFailedText))
SendSysMessage("{0}", ar.questFailedText);
else if (mapDiff.Message[Global.WorldMgr.GetDefaultDbcLocale()][0] != '\0' || failedMapDifficultyXCondition != 0) // if (missingAchievement) covered by this case
else if (!mapDiff.Message[Global.WorldMgr.GetDefaultDbcLocale()].IsEmpty() && mapDiff.Message[Global.WorldMgr.GetDefaultDbcLocale()][0] != '\0' || failedMapDifficultyXCondition != 0) // if (missingAchievement) covered by this case
{
if (abortParams != null)
{
+2 -2
View File
@@ -813,10 +813,10 @@ namespace Game
// Send PVPSeason
{
SeasonInfo seasonInfo = new();
seasonInfo.MythicPlusMilestoneSeasonID = (WorldConfig.GetIntValue(WorldCfg.ArenaSeasonId) - (WorldConfig.GetBoolValue(WorldCfg.ArenaSeasonInProgress) ? 1 : 0));
seasonInfo.PreviousArenaSeason = (WorldConfig.GetIntValue(WorldCfg.ArenaSeasonId) - (WorldConfig.GetBoolValue(WorldCfg.ArenaSeasonInProgress) ? 1 : 0));
if (WorldConfig.GetBoolValue(WorldCfg.ArenaSeasonInProgress))
seasonInfo.PreviousArenaSeason = WorldConfig.GetIntValue(WorldCfg.ArenaSeasonId);
seasonInfo.CurrentArenaSeason = WorldConfig.GetIntValue(WorldCfg.ArenaSeasonId);
SendPacket(seasonInfo);
}
@@ -60,7 +60,7 @@ namespace Game.Networking.Packets
_worldPacket.WritePackedGuid(PlayerGUID);
_worldPacket.WriteUInt32(Flags);
_worldPacket.WritePackedTime(CurrentTime);
_worldPacket.WriteUInt32(ElapsedTime);
_worldPacket.WriteInt64(ElapsedTime);
_worldPacket.WriteInt64(CreationTime);
_worldPacket.WriteBit(RafAcceptanceID.HasValue);
_worldPacket.FlushBits();
@@ -74,7 +74,7 @@ namespace Game.Networking.Packets
public ObjectGuid PlayerGUID;
public uint Flags;
public long CurrentTime;
public uint ElapsedTime;
public long ElapsedTime;
public long CreationTime;
public ulong? RafAcceptanceID;
}
@@ -319,8 +319,8 @@ namespace Game.Networking.Packets
data.WriteUInt64(Quantity);
data.WritePackedGuid(Player);
data.WritePackedTime(Date);
data.WriteUInt32(TimeFromStart);
data.WriteUInt32(TimeFromCreate);
data.WriteInt64(TimeFromStart);
data.WriteInt64(TimeFromCreate);
data.WriteBits(Flags, 4);
data.WriteBit(RafAcceptanceID.HasValue);
data.FlushBits();
@@ -334,8 +334,8 @@ namespace Game.Networking.Packets
public ObjectGuid Player;
public uint Flags;
public long Date;
public uint TimeFromStart;
public uint TimeFromCreate;
public long TimeFromStart;
public long TimeFromCreate;
public ulong? RafAcceptanceID;
}
@@ -51,7 +51,7 @@ namespace Game.Networking.Packets
}
public byte State;
public bool SuppressNotification;
public bool SuppressNotification = true;
}
class ChangeRealmTicketResponse : ServerPacket
@@ -1657,8 +1657,8 @@ namespace Game.Networking.Packets
SendCastFlags = data.ReadBits<uint>(5);
bool hasMoveUpdate = data.HasBit();
bool hasCraftingOrderID = data.HasBit();
var weightCount = data.ReadBits<uint>(2);
bool hasCraftingOrderID = data.HasBit();
Target.Read(data);
@@ -375,7 +375,6 @@ namespace Game.Networking.Packets
_worldPacket.WriteString(ServerTimeTZ);
_worldPacket.WriteString(GameTimeTZ);
_worldPacket.WriteString(ServerRegionalTZ);
}
public string ServerTimeTZ;
+8 -14
View File
@@ -28,17 +28,6 @@ namespace Game.Spells
m_spellInfo = info;
m_caster = (info.HasAttribute(SpellAttr6.OriginateFromController) && caster.GetCharmerOrOwner() != null ? caster.GetCharmerOrOwner() : caster);
m_spellValue = new SpellValue(m_spellInfo, caster);
m_castItemLevel = -1;
if (IsIgnoringCooldowns())
m_castFlagsEx |= SpellCastFlagsEx.IgnoreCooldown;
m_castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, m_caster.GetMapId(), m_spellInfo.Id, m_caster.GetMap().GenerateLowGuid(HighGuid.Cast));
m_originalCastId = originalCastId;
m_SpellVisual.SpellXSpellVisualID = caster.GetCastSpellXSpellVisualId(m_spellInfo);
m_customError = SpellCustomErrors.None;
m_fromClient = false;
m_needComboPoints = m_spellInfo.NeedsComboPoints();
// Get data for type of attack
@@ -79,7 +68,6 @@ namespace Game.Spells
m_originalCaster = null;
}
m_spellState = SpellState.None;
_triggeredCastFlags = triggerFlags;
if (info.HasAttribute(SpellAttr2.DoNotReportSpellFailure))
@@ -88,7 +76,14 @@ namespace Game.Spells
if (m_spellInfo.HasAttribute(SpellAttr4.AllowCastWhileCasting))
_triggeredCastFlags = _triggeredCastFlags | TriggerCastFlags.IgnoreCastInProgress;
effectHandleMode = SpellEffectHandleMode.Launch;
m_castItemLevel = -1;
if (IsIgnoringCooldowns())
m_castFlagsEx |= SpellCastFlagsEx.IgnoreCooldown;
m_castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, m_caster.GetMapId(), m_spellInfo.Id, m_caster.GetMap().GenerateLowGuid(HighGuid.Cast));
m_originalCastId = originalCastId;
m_SpellVisual.SpellXSpellVisualID = caster.GetCastSpellXSpellVisualId(m_spellInfo);
//Auto Shot & Shoot (wand)
m_autoRepeat = m_spellInfo.IsAutoRepeatRangedSpell();
@@ -104,7 +99,6 @@ namespace Game.Spells
for (var i = 0; i < SpellConst.MaxEffects; ++i)
m_destTargets[i] = new SpellDestination(m_caster);
//not sure needed.
m_targets = new SpellCastTargets();
m_appliedMods = new List<Aura>();
}