Core/Guild: Implemented guild master dethrone
This commit is contained in:
@@ -45,6 +45,8 @@ namespace Framework.Constants
|
||||
public static uint MinNewsItemLevel = 353;
|
||||
|
||||
public static byte OldMaxLevel = 25;
|
||||
|
||||
public static uint MasterDethroneInactiveDays = 90;
|
||||
}
|
||||
|
||||
public enum GuildRankRights
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the sum.</returns>
|
||||
public static Matrix2 operator +(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return Matrix2.Add(left, right); ;
|
||||
return Matrix2.Add(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
@@ -534,7 +534,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the difference.</returns>
|
||||
public static Matrix2 operator -(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return Matrix2.Subtract(left, right); ;
|
||||
return Matrix2.Subtract(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
@@ -554,7 +554,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix2"/> instance containing the result.</returns>
|
||||
public static Matrix2 operator *(Matrix2 left, Matrix2 right)
|
||||
{
|
||||
return Matrix2.Multiply(left, right); ;
|
||||
return Matrix2.Multiply(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
|
||||
@@ -693,7 +693,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the sum.</returns>
|
||||
public static Matrix3 operator +(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return Matrix3.Add(left, right); ;
|
||||
return Matrix3.Add(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
@@ -723,7 +723,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the difference.</returns>
|
||||
public static Matrix3 operator -(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return Matrix3.Subtract(left, right); ;
|
||||
return Matrix3.Subtract(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
@@ -743,7 +743,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix3"/> instance containing the result.</returns>
|
||||
public static Matrix3 operator *(Matrix3 left, Matrix3 right)
|
||||
{
|
||||
return Matrix3.Multiply(left, right); ;
|
||||
return Matrix3.Multiply(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
|
||||
@@ -780,7 +780,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the sum.</returns>
|
||||
public static Matrix4 operator +(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return Matrix4.Add(left, right); ;
|
||||
return Matrix4.Add(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a matrix and a scalar.
|
||||
@@ -810,7 +810,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the difference.</returns>
|
||||
public static Matrix4 operator -(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return Matrix4.Subtract(left, right); ;
|
||||
return Matrix4.Subtract(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtracts a scalar from a matrix.
|
||||
@@ -830,7 +830,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A new <see cref="Matrix4"/> instance containing the result.</returns>
|
||||
public static Matrix4 operator *(Matrix4 left, Matrix4 right)
|
||||
{
|
||||
return Matrix4.Multiply(left, right); ;
|
||||
return Matrix4.Multiply(left, right);
|
||||
}
|
||||
/// <summary>
|
||||
/// Transforms a given vector by a matrix.
|
||||
|
||||
@@ -834,7 +834,7 @@ public static partial class Detour
|
||||
vArrays[k] = tile.detailVerts;
|
||||
}
|
||||
}
|
||||
float h = .0f; ;
|
||||
float h = .0f;
|
||||
if (dtClosestHeightPointTriangle(pos, posStart, vArrays[0], vIndices[0], vArrays[1], vIndices[1], vArrays[2], vIndices[2], ref h))
|
||||
{
|
||||
closest[1] = h;
|
||||
|
||||
@@ -366,7 +366,7 @@ namespace Game.DungeonFinding
|
||||
foreach (var guid in check)
|
||||
{
|
||||
if (!(numLfgGroups < 2) && !(numPlayers <= MapConst.MaxGroupSize))
|
||||
break; ;
|
||||
break;
|
||||
|
||||
var itQueue = QueueDataStore.LookupByKey(guid);
|
||||
if (itQueue == null)
|
||||
|
||||
@@ -2448,7 +2448,7 @@ namespace Game.Entities
|
||||
if (vItem.maxcount == 0)
|
||||
return 0;
|
||||
|
||||
VendorItemCount vCount = null; ;
|
||||
VendorItemCount vCount = null;
|
||||
for (var i = 0; i < m_vendorItemCounts.Count; i++)
|
||||
{
|
||||
vCount = m_vendorItemCounts[i];
|
||||
|
||||
@@ -4759,7 +4759,7 @@ namespace Game.Entities
|
||||
if ((pvp && WorldConfig.GetBoolValue(WorldCfg.DeathCorpseReclaimDelayPvp)) ||
|
||||
(!pvp && WorldConfig.GetBoolValue(WorldCfg.DeathCorpseReclaimDelayPve)))
|
||||
{
|
||||
count = (ulong)(m_deathExpireTime - corpse.GetGhostTime()) / PlayerConst.DeathExpireStep; ;
|
||||
count = (ulong)(m_deathExpireTime - corpse.GetGhostTime()) / PlayerConst.DeathExpireStep;
|
||||
|
||||
if (count >= PlayerConst.MaxDeathCount)
|
||||
count = PlayerConst.MaxDeathCount - 1;
|
||||
|
||||
+41
-19
@@ -228,7 +228,7 @@ namespace Game.Guilds
|
||||
memberData.AreaID = (int)member.GetZoneId();
|
||||
memberData.PersonalAchievementPoints = (int)member.GetAchievementPoints();
|
||||
memberData.GuildReputation = (int)member.GetTotalReputation();
|
||||
memberData.LastSave = (member.IsOnline() ? 0.0f : ((ulong)Time.UnixTime - member.GetLogoutTime()) / Time.Day);
|
||||
memberData.LastSave = member.GetInactiveDays();
|
||||
|
||||
//GuildRosterProfessionData
|
||||
|
||||
@@ -405,30 +405,45 @@ namespace Game.Guilds
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleSetNewGuildMaster(WorldSession session, string name)
|
||||
public void HandleSetNewGuildMaster(WorldSession session, string name, bool isSelfPromote)
|
||||
{
|
||||
Player player = session.GetPlayer();
|
||||
// Only the guild master can throne a new guild master
|
||||
if (!_IsLeader(player))
|
||||
SendCommandResult(session, GuildCommandType.ChangeLeader, GuildCommandError.Permissions);
|
||||
// Old GM must be a guild member
|
||||
Member oldGuildMaster = GetMember(player.GetGUID());
|
||||
if (oldGuildMaster != null)
|
||||
Member oldGuildMaster = GetMember(GetLeaderGUID());
|
||||
|
||||
Member newGuildMaster;
|
||||
if (isSelfPromote)
|
||||
{
|
||||
// Same for the new one
|
||||
Member newGuildMaster = GetMember(name);
|
||||
if (newGuildMaster != null)
|
||||
newGuildMaster = GetMember(player.GetGUID());
|
||||
if (newGuildMaster == null)
|
||||
return;
|
||||
|
||||
if (!newGuildMaster.IsRankNotLower(GuildDefaultRanks.Member) || oldGuildMaster.GetInactiveDays() < GuildConst.MasterDethroneInactiveDays)
|
||||
{
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
|
||||
_SetLeader(trans, newGuildMaster);
|
||||
oldGuildMaster.ChangeRank(trans, GuildDefaultRanks.Initiate);
|
||||
|
||||
SendEventNewLeader(newGuildMaster, oldGuildMaster);
|
||||
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
SendCommandResult(session, GuildCommandType.ChangeLeader, GuildCommandError.Permissions);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_IsLeader(player))
|
||||
{
|
||||
SendCommandResult(session, GuildCommandType.ChangeLeader, GuildCommandError.Permissions);
|
||||
return;
|
||||
}
|
||||
|
||||
newGuildMaster = GetMember(name);
|
||||
if (newGuildMaster == null)
|
||||
return;
|
||||
}
|
||||
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
|
||||
_SetLeader(trans, newGuildMaster);
|
||||
oldGuildMaster.ChangeRank(trans, GuildDefaultRanks.Initiate);
|
||||
|
||||
SendEventNewLeader(newGuildMaster, oldGuildMaster, isSelfPromote);
|
||||
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
public void HandleSetBankTabInfo(WorldSession session, byte tabId, string name, string icon)
|
||||
@@ -2581,6 +2596,13 @@ namespace Game.Guilds
|
||||
return true;
|
||||
}
|
||||
|
||||
public float GetInactiveDays()
|
||||
{
|
||||
if (IsOnline())
|
||||
return 0.0f;
|
||||
return (float)((Time.UnixTime - (long)GetLogoutTime()) / (float)Time.Day);
|
||||
}
|
||||
|
||||
// Decreases amount of slots left for today.
|
||||
public void UpdateBankTabWithdrawValue(SQLTransaction trans, byte tabId, uint amount)
|
||||
{
|
||||
|
||||
@@ -440,12 +440,20 @@ namespace Game
|
||||
guild.HandleNewsSetSticky(this, (uint)packet.NewsID, packet.Sticky);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.GuildReplaceGuildMaster)]
|
||||
void HandleGuildReplaceGuildMaster(GuildReplaceGuildMaster replaceGuildMaster)
|
||||
{
|
||||
Guild guild = GetPlayer().GetGuild();
|
||||
if (guild)
|
||||
guild.HandleSetNewGuildMaster(this, "", true);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.GuildSetGuildMaster)]
|
||||
void HandleGuildSetGuildMaster(GuildSetGuildMaster packet)
|
||||
{
|
||||
Guild guild = GetPlayer().GetGuild();
|
||||
if (guild)
|
||||
guild.HandleSetNewGuildMaster(this, packet.NewMasterName);
|
||||
guild.HandleSetNewGuildMaster(this, packet.NewMasterName, false);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.GuildSetAchievementTracking)]
|
||||
|
||||
@@ -534,7 +534,7 @@ namespace Game
|
||||
|
||||
LootItem item = slotid >= loot.items.Count ? loot.quest_items[slotid - loot.items.Count] : loot.items[slotid];
|
||||
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>(); ;
|
||||
List<ItemPosCount> dest = new List<ItemPosCount>();
|
||||
InventoryResult msg = target.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count);
|
||||
if (item.follow_loot_rules && !item.AllowedForPlayer(target))
|
||||
msg = InventoryResult.CantEquipEver;
|
||||
|
||||
@@ -1000,7 +1000,7 @@ namespace Game.Network.Packets
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
Player = _worldPacket.ReadPackedGuid(); ;
|
||||
Player = _worldPacket.ReadPackedGuid();
|
||||
|
||||
byte[] stringLengths = new byte[SharedConst.MaxDeclinedNameCases];
|
||||
|
||||
|
||||
@@ -438,16 +438,16 @@ namespace Game.Network.Packets
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WriteBit(SelfPromoted);
|
||||
_worldPacket.WriteBits(NewLeaderName.GetByteCount(), 6);
|
||||
_worldPacket.WriteBits(OldLeaderName.GetByteCount(), 6);
|
||||
_worldPacket.WriteBits(NewLeaderName.GetByteCount(), 6);
|
||||
|
||||
_worldPacket.WritePackedGuid(OldLeaderGUID);
|
||||
_worldPacket.WriteUInt32(OldLeaderVirtualRealmAddress);
|
||||
_worldPacket.WritePackedGuid(NewLeaderGUID);
|
||||
_worldPacket.WriteUInt32(NewLeaderVirtualRealmAddress);
|
||||
|
||||
_worldPacket.WriteString(NewLeaderName);
|
||||
_worldPacket.WriteString(OldLeaderName);
|
||||
_worldPacket.WriteString(NewLeaderName);
|
||||
}
|
||||
|
||||
public ObjectGuid NewLeaderGUID;
|
||||
@@ -981,7 +981,7 @@ namespace Game.Network.Packets
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket .WriteInt64( RemainingWithdrawMoney);
|
||||
_worldPacket.WriteInt64(RemainingWithdrawMoney);
|
||||
}
|
||||
|
||||
public long RemainingWithdrawMoney;
|
||||
@@ -1023,7 +1023,7 @@ namespace Game.Network.Packets
|
||||
{
|
||||
_worldPacket.WriteUInt32(tab.TabIndex);
|
||||
_worldPacket.WriteBits(tab.Name.GetByteCount(), 7);
|
||||
_worldPacket.WriteBits(tab.Icon.GetByteCount(), 9);;
|
||||
_worldPacket.WriteBits(tab.Icon.GetByteCount(), 9);
|
||||
|
||||
_worldPacket.WriteString(tab.Name);
|
||||
_worldPacket.WriteString(tab.Icon);
|
||||
@@ -1245,6 +1245,13 @@ namespace Game.Network.Packets
|
||||
public bool Sticky;
|
||||
}
|
||||
|
||||
class GuildReplaceGuildMaster : ClientPacket
|
||||
{
|
||||
public GuildReplaceGuildMaster(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read() { }
|
||||
}
|
||||
|
||||
public class GuildSetGuildMaster : ClientPacket
|
||||
{
|
||||
public GuildSetGuildMaster(WorldPacket packet) : base(packet) { }
|
||||
|
||||
@@ -724,7 +724,7 @@ namespace Game.Network.Packets
|
||||
public void Read(WorldPacket data)
|
||||
{
|
||||
Context = data.ReadUInt8();
|
||||
uint bonusListIdSize = data.ReadUInt32(); ;
|
||||
uint bonusListIdSize = data.ReadUInt32();
|
||||
|
||||
BonusListIDs = new List<uint>();
|
||||
for (uint i = 0u; i < bonusListIdSize; ++i)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Game.Network.Packets
|
||||
public override void Read()
|
||||
{
|
||||
Data.Read(_worldPacket);
|
||||
VehicleRecID = _worldPacket.ReadInt32(); ;
|
||||
VehicleRecID = _worldPacket.ReadInt32();
|
||||
}
|
||||
|
||||
public MovementAck Data;
|
||||
|
||||
Reference in New Issue
Block a user