Misc cleanups
This commit is contained in:
@@ -285,9 +285,7 @@ namespace System
|
||||
|
||||
public static string ConvertFormatSyntax(this string str)
|
||||
{
|
||||
// @"%(\d+(\.\d+)?)?(d|f|s|u|i|llX|X|ll)"; old working
|
||||
//@"%(\d+(\.\d+)?)?(-\d+[a-z]|[[a-z])"; working somewhat
|
||||
string pattern = @"(%\W*\d*[a-zA-Z]*)"; //Working fully????
|
||||
string pattern = @"(%\W*\d*[a-zA-Z]*)";
|
||||
|
||||
int count = 0;
|
||||
string result = Regex.Replace(str, pattern, m =>
|
||||
|
||||
@@ -494,8 +494,8 @@ namespace Game.Chat
|
||||
handler.HasLowerSecurityAccount(null, accountId, true))
|
||||
return false;
|
||||
|
||||
int expansion = int.Parse(exp); //get int anyway (0 if error)
|
||||
if (expansion < 0 || expansion > WorldConfig.GetIntValue(WorldCfg.Expansion))
|
||||
byte expansion = byte.Parse(exp); //get int anyway (0 if error)
|
||||
if (expansion > WorldConfig.GetIntValue(WorldCfg.Expansion))
|
||||
return false;
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_EXPANSION);
|
||||
|
||||
@@ -55,9 +55,11 @@ namespace Game.Chat
|
||||
string activeStr = target.GetUInt32Value(PlayerFields.ChosenTitle) == titleInfo.MaskID
|
||||
? handler.GetCypherString(CypherStrings.Active) : "";
|
||||
|
||||
string titleNameStr = string.Format(name.ConvertFormatSyntax(), targetName);
|
||||
|
||||
// send title in "id (idx:idx) - [namedlink locale]" format
|
||||
if (handler.GetSession() != null)
|
||||
handler.SendSysMessage(CypherStrings.TitleListChat, titleInfo.Id, titleInfo.MaskID, titleInfo.Id, name, loc, knownStr, activeStr);
|
||||
handler.SendSysMessage(CypherStrings.TitleListChat, titleInfo.Id, titleInfo.MaskID, titleInfo.Id, titleNameStr, loc, knownStr, activeStr);
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.TitleListConsole, titleInfo.Id, titleInfo.MaskID, name, loc, knownStr, activeStr);
|
||||
}
|
||||
|
||||
@@ -607,10 +607,10 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
int currentValue = (int)handler.GetSession().GetPlayer().GetUInt32Value(opcode);
|
||||
uint currentValue = handler.GetSession().GetPlayer().GetUInt32Value(opcode);
|
||||
|
||||
currentValue += value;
|
||||
handler.GetSession().GetPlayer().SetUInt32Value(opcode, (uint)currentValue);
|
||||
currentValue += (uint)value;
|
||||
handler.GetSession().GetPlayer().SetUInt32Value(opcode, currentValue);
|
||||
|
||||
handler.SendSysMessage(CypherStrings.Change32bitField, opcode, currentValue);
|
||||
|
||||
|
||||
@@ -829,7 +829,7 @@ namespace Game.Chat
|
||||
string activeStr = target && target.GetUInt32Value(PlayerFields.ChosenTitle) == titleInfo.MaskID
|
||||
? handler.GetCypherString(CypherStrings.Active) : "";
|
||||
|
||||
string titleNameStr = name + targetName;
|
||||
string titleNameStr = string.Format(name.ConvertFormatSyntax(), targetName);
|
||||
|
||||
// send title in "id (idx:idx) - [namedlink locale]" format
|
||||
if (handler.GetSession() != null)
|
||||
|
||||
@@ -110,11 +110,8 @@ namespace Game.Chat
|
||||
}
|
||||
|
||||
[Command("faction", RBACPermissions.CommandModifyFaction)]
|
||||
static bool Faction(StringArguments args, CommandHandler handler)
|
||||
static bool HandleModifyFactionCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
string pfactionid = handler.extractKeyFromLink(args, "Hfaction");
|
||||
|
||||
Creature target = handler.getSelectedCreature();
|
||||
|
||||
@@ -957,7 +957,7 @@ namespace Game.Chat
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
uint phaseGroupId = args.NextUInt32();
|
||||
int phaseGroupId = args.NextInt32();
|
||||
|
||||
Creature creature = handler.getSelectedCreature();
|
||||
if (!creature || creature.IsPet())
|
||||
@@ -968,11 +968,11 @@ namespace Game.Chat
|
||||
|
||||
creature.ClearPhases();
|
||||
|
||||
foreach (uint id in Global.DB2Mgr.GetPhasesForGroup(phaseGroupId))
|
||||
foreach (uint id in Global.DB2Mgr.GetPhasesForGroup((uint)phaseGroupId))
|
||||
creature.SetInPhase(id, false, true); // don't send update here for multiple phases, only send it once after adding all phases
|
||||
|
||||
creature.UpdateObjectVisibility();
|
||||
creature.SetDBPhase(-(int)phaseGroupId);
|
||||
creature.SetDBPhase(-phaseGroupId);
|
||||
|
||||
creature.SaveToDB();
|
||||
|
||||
@@ -1030,28 +1030,20 @@ namespace Game.Chat
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
int spawnTime = args.NextInt32();
|
||||
|
||||
if (spawnTime < 0)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.BadValue);
|
||||
return false;
|
||||
}
|
||||
uint spawnTime = args.NextUInt32();
|
||||
|
||||
Creature creature = handler.getSelectedCreature();
|
||||
ulong guidLow = 0;
|
||||
|
||||
if (creature)
|
||||
guidLow = creature.GetSpawnId();
|
||||
else
|
||||
if (!creature)
|
||||
return false;
|
||||
|
||||
ulong guidLow = creature.GetSpawnId();
|
||||
|
||||
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_SPAWN_TIME_SECS);
|
||||
stmt.AddValue(0, spawnTime);
|
||||
stmt.AddValue(1, guidLow);
|
||||
DB.World.Execute(stmt);
|
||||
|
||||
creature.SetRespawnDelay((uint)spawnTime);
|
||||
creature.SetRespawnDelay(spawnTime);
|
||||
handler.SendSysMessage(CypherStrings.CommandSpawntime, spawnTime);
|
||||
|
||||
return true;
|
||||
@@ -1167,11 +1159,10 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
int item_int = int.Parse(pitem);
|
||||
if (item_int <= 0)
|
||||
uint itemId = uint.Parse(pitem);
|
||||
if (itemId == 0)
|
||||
return false;
|
||||
|
||||
uint itemId = (uint)item_int;
|
||||
uint maxcount = args.NextUInt32();
|
||||
uint incrtime = args.NextUInt32();
|
||||
uint extendedcost = args.NextUInt32();
|
||||
|
||||
@@ -152,14 +152,14 @@ namespace Game.Chat
|
||||
|
||||
string maxPureSkill = args.NextString();
|
||||
|
||||
int skill = int.Parse(skillStr);
|
||||
if (skill <= 0)
|
||||
uint skill = uint.Parse(skillStr);
|
||||
if (skill == 0)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.InvalidSkillId, skill);
|
||||
return false;
|
||||
}
|
||||
|
||||
int level = int.Parse(levelStr);
|
||||
uint level = uint.Parse(levelStr);
|
||||
Player target = handler.getSelectedPlayerOrSelf();
|
||||
if (!target)
|
||||
{
|
||||
@@ -180,13 +180,13 @@ namespace Game.Chat
|
||||
// the max level of the new profession.
|
||||
ushort max = !string.IsNullOrEmpty(maxPureSkill) ? ushort.Parse(maxPureSkill) : targetHasSkill ? target.GetPureMaxSkillValue((SkillType)skill) : (ushort)level;
|
||||
|
||||
if (level <= 0 || level > max || max <= 0)
|
||||
if (level == 0 || level > max || max <= 0)
|
||||
return false;
|
||||
|
||||
// If the player has the skill, we get the current skill step. If they don't have the skill, we
|
||||
// add the skill to the player's book with step 1 (which is the first rank, in most cases something
|
||||
// like 'Apprentice <skill>'.
|
||||
target.SetSkill((SkillType)skill, (uint)(targetHasSkill ? target.GetSkillStep((SkillType)skill) : 1), (uint)level, max);
|
||||
target.SetSkill((SkillType)skill, (uint)(targetHasSkill ? target.GetSkillStep((SkillType)skill) : 1), level, max);
|
||||
handler.SendSysMessage(CypherStrings.SetSkill, skill, skillLine.DisplayName[handler.GetSessionDbcLocale()], handler.GetNameLink(target), level, max);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace Game.Chat.Commands
|
||||
Player player = handler.GetSession() != null ? handler.GetSession().GetPlayer() : null;
|
||||
if (player && ticket.IsAssignedNotTo(player.GetGUID()))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandTicketalreadyassigned, ticket.GetId(), target);
|
||||
handler.SendSysMessage(CypherStrings.CommandTicketalreadyassigned, ticket.GetId());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ using Framework.IO;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Game.Chat.Commands
|
||||
{
|
||||
@@ -34,8 +35,8 @@ namespace Game.Chat.Commands
|
||||
if (string.IsNullOrEmpty(id_p))
|
||||
return false;
|
||||
|
||||
int id = int.Parse(id_p);
|
||||
if (id <= 0)
|
||||
uint id = uint.Parse(id_p);
|
||||
if (id == 0)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.InvalidTitleId, id);
|
||||
return false;
|
||||
@@ -76,8 +77,8 @@ namespace Game.Chat.Commands
|
||||
if (string.IsNullOrEmpty(id_p))
|
||||
return false;
|
||||
|
||||
int id = int.Parse(id_p);
|
||||
if (id <= 0)
|
||||
uint id = uint.Parse(id_p);
|
||||
if (id == 0)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.InvalidTitleId, id);
|
||||
return false;
|
||||
@@ -103,7 +104,7 @@ namespace Game.Chat.Commands
|
||||
|
||||
string tNameLink = handler.GetNameLink(target);
|
||||
|
||||
string titleNameStr = (target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()] + target.GetName();
|
||||
string titleNameStr = string.Format((target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()].ConvertFormatSyntax(), target.GetName());
|
||||
|
||||
target.SetTitle(titleInfo);
|
||||
handler.SendSysMessage(CypherStrings.TitleAddRes, id, titleNameStr, tNameLink);
|
||||
@@ -119,8 +120,8 @@ namespace Game.Chat.Commands
|
||||
if (string.IsNullOrEmpty(id_p))
|
||||
return false;
|
||||
|
||||
int id = int.Parse(id_p);
|
||||
if (id <= 0)
|
||||
uint id = uint.Parse(id_p);
|
||||
if (id == 0)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.InvalidTitleId, id);
|
||||
return false;
|
||||
@@ -148,7 +149,7 @@ namespace Game.Chat.Commands
|
||||
|
||||
string tNameLink = handler.GetNameLink(target);
|
||||
|
||||
string titleNameStr = (target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()] + target.GetName();
|
||||
string titleNameStr = string.Format((target.GetGender() == Gender.Male ? titleInfo.NameMale : titleInfo.NameFemale)[handler.GetSessionDbcLocale()].ConvertFormatSyntax(), target.GetName());
|
||||
|
||||
handler.SendSysMessage(CypherStrings.TitleRemoveRes, id, titleNameStr, tNameLink);
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace Game.Chat.Commands
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
handler.SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r");
|
||||
handler.SendSysMessage("|cffff33ffERROR: No valid waypoint script id not present.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Game.Chat.Commands
|
||||
if (arg_string == "setid")
|
||||
{
|
||||
uint newid = uint.Parse(arg_3);
|
||||
handler.SendSysMessage("|cff00ff00Wp Event: Wypoint scipt guid: {0}|r|cff00ffff id changed: |r|cff00ff00{1}|r", newid, id);
|
||||
handler.SendSysMessage("|cff00ff00Wp Event: Waypoint script guid: {0}|r|cff00ffff id changed: |r|cff00ff00{1}|r", newid, id);
|
||||
|
||||
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_SCRIPT_ID);
|
||||
stmt.AddValue(0, newid);
|
||||
@@ -774,7 +774,7 @@ namespace Game.Chat.Commands
|
||||
|
||||
if (show == "first")
|
||||
{
|
||||
handler.SendSysMessage("|cff00ff00DEBUG: wp first, GUID: {0}|r", pathid);
|
||||
handler.SendSysMessage("|cff00ff00DEBUG: wp first, pathid: {0}|r", pathid);
|
||||
|
||||
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_FIRST_BY_ID);
|
||||
stmt.AddValue(0, pathid);
|
||||
|
||||
@@ -499,14 +499,14 @@ namespace Game.Entities
|
||||
UpdatePolygonOrientation();
|
||||
}
|
||||
|
||||
bool UnitFitToActionRequirement(Unit unit, Unit caster, AreaTriggerActionUserTypes targetType)
|
||||
bool UnitFitToActionRequirement(Unit unit, Unit caster, AreaTriggerAction action)
|
||||
{
|
||||
switch (targetType)
|
||||
switch (action.TargetType)
|
||||
{
|
||||
case AreaTriggerActionUserTypes.Friend:
|
||||
return caster.IsFriendlyTo(unit);
|
||||
return caster._IsValidAssistTarget(unit, Global.SpellMgr.GetSpellInfo(action.Param));
|
||||
case AreaTriggerActionUserTypes.Enemy:
|
||||
return !caster.IsFriendlyTo(unit);
|
||||
return caster._IsValidAttackTarget(unit, Global.SpellMgr.GetSpellInfo(action.Param));
|
||||
case AreaTriggerActionUserTypes.Raid:
|
||||
return caster.IsInRaidWith(unit);
|
||||
case AreaTriggerActionUserTypes.Party:
|
||||
@@ -528,7 +528,7 @@ namespace Game.Entities
|
||||
{
|
||||
foreach (AreaTriggerAction action in GetTemplate().Actions)
|
||||
{
|
||||
if (UnitFitToActionRequirement(unit, caster, action.TargetType))
|
||||
if (UnitFitToActionRequirement(unit, caster, action))
|
||||
{
|
||||
switch (action.ActionType)
|
||||
{
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Game.Maps
|
||||
instResetTime[instance] = Tuple.Create(pair.Item1, resettime);
|
||||
}
|
||||
}
|
||||
while (result.NextRow());
|
||||
while (result2.NextRow());
|
||||
}
|
||||
|
||||
// schedule the reset times
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Game.Scripting
|
||||
InstanceMap instance = obj.GetMap().ToInstanceMap();
|
||||
if (instance != null && instance.GetInstanceScript() != null)
|
||||
if (instance.GetScriptName() == scriptName)
|
||||
return (T)Activator.CreateInstance(typeof(T), new object[] { obj });
|
||||
return (T)Activator.CreateInstance(typeof(T), obj);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ namespace Game.Scripting
|
||||
if (me.GetInstanceScript() != null)
|
||||
return GetInstanceAI<AI>(me);
|
||||
else
|
||||
return (AI)Activator.CreateInstance(typeof(AI), me, _args);
|
||||
return (AI)Activator.CreateInstance(typeof(AI), new object[] { me }.Combine(_args));
|
||||
}
|
||||
|
||||
object[] _args;
|
||||
|
||||
Reference in New Issue
Block a user