Ported .Net Core commits:
hondacrx: - Initial commit: Switch to .Net Core 2.0 - Fix build and removed not needed files Fabi: - Updated solution platforms. - Changed folder structure. - Change library target framework to netstandard2.0. - Updated solution platforms again... - Removed windows specific kernel32 function usage (Ctrl-C handler).
This commit is contained in:
@@ -0,0 +1,386 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Game.Chat;
|
||||
using Game.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Game.SupportSystem
|
||||
{
|
||||
public class SupportManager : Singleton<SupportManager>
|
||||
{
|
||||
SupportManager() { }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
SetSupportSystemStatus(WorldConfig.GetBoolValue(WorldCfg.SupportEnabled));
|
||||
SetTicketSystemStatus(WorldConfig.GetBoolValue(WorldCfg.SupportTicketsEnabled));
|
||||
SetBugSystemStatus(WorldConfig.GetBoolValue(WorldCfg.SupportBugsEnabled));
|
||||
SetComplaintSystemStatus(WorldConfig.GetBoolValue(WorldCfg.SupportComplaintsEnabled));
|
||||
SetSuggestionSystemStatus(WorldConfig.GetBoolValue(WorldCfg.SupportSuggestionsEnabled));
|
||||
}
|
||||
|
||||
public T GetTicket<T>(uint Id) where T : Ticket
|
||||
{
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
return _bugTicketList.LookupByKey(Id) as T;
|
||||
case "ComplaintTicket":
|
||||
return _complaintTicketList.LookupByKey(Id) as T;
|
||||
case "SuggestionTicket":
|
||||
return _suggestionTicketList.LookupByKey(Id) as T;
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public uint GetOpenTicketCount<T>() where T : Ticket
|
||||
{
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
return _openBugTicketCount;
|
||||
case "ComplaintTicket":
|
||||
return _openComplaintTicketCount;
|
||||
case "SuggestionTicket":
|
||||
return _openSuggestionTicketCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void LoadBugTickets()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
_bugTicketList.Clear();
|
||||
|
||||
_lastBugId = 0;
|
||||
_openBugTicketCount = 0;
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GM_BUGS);
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 GM bugs. DB table `gm_bug` is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
uint count = 0;
|
||||
do
|
||||
{
|
||||
BugTicket bug = new BugTicket();
|
||||
bug.LoadFromDB(result.GetFields());
|
||||
|
||||
if (!bug.IsClosed())
|
||||
++_openBugTicketCount;
|
||||
|
||||
uint id = bug.GetId();
|
||||
if (_lastBugId < id)
|
||||
_lastBugId = id;
|
||||
|
||||
_bugTicketList[id] = bug;
|
||||
++count;
|
||||
} while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} GM bugs in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
public void LoadComplaintTickets()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
_complaintTicketList.Clear();
|
||||
|
||||
_lastComplaintId = 0;
|
||||
_openComplaintTicketCount = 0;
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GM_COMPLAINTS);
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 GM complaints. DB table `gm_complaint` is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
uint count = 0;
|
||||
PreparedStatement chatLogStmt;
|
||||
SQLResult chatLogResult;
|
||||
do
|
||||
{
|
||||
ComplaintTicket complaint = new ComplaintTicket();
|
||||
complaint.LoadFromDB(result.GetFields());
|
||||
|
||||
if (!complaint.IsClosed())
|
||||
++_openComplaintTicketCount;
|
||||
|
||||
uint id = complaint.GetId();
|
||||
if (_lastComplaintId < id)
|
||||
_lastComplaintId = id;
|
||||
|
||||
chatLogStmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GM_COMPLAINT_CHATLINES);
|
||||
chatLogStmt.AddValue(0, id);
|
||||
chatLogResult = DB.Characters.Query(stmt);
|
||||
|
||||
if (!chatLogResult.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
complaint.LoadChatLineFromDB(chatLogResult.GetFields());
|
||||
} while (chatLogResult.NextRow());
|
||||
}
|
||||
|
||||
_complaintTicketList[id] = complaint;
|
||||
++count;
|
||||
} while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} GM complaints in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
public void LoadSuggestionTickets()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
_suggestionTicketList.Clear();
|
||||
|
||||
_lastSuggestionId = 0;
|
||||
_openSuggestionTicketCount = 0;
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_GM_SUGGESTIONS);
|
||||
SQLResult result = DB.Characters.Query(stmt);
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 GM suggestions. DB table `gm_suggestion` is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
uint count = 0;
|
||||
do
|
||||
{
|
||||
SuggestionTicket suggestion = new SuggestionTicket();
|
||||
suggestion.LoadFromDB(result.GetFields());
|
||||
|
||||
if (!suggestion.IsClosed())
|
||||
++_openSuggestionTicketCount;
|
||||
|
||||
uint id = suggestion.GetId();
|
||||
if (_lastSuggestionId < id)
|
||||
_lastSuggestionId = id;
|
||||
|
||||
_suggestionTicketList[id] = suggestion;
|
||||
++count;
|
||||
} while (result.NextRow());
|
||||
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded {0} GM suggestions in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
public void AddTicket<T>(T ticket)where T : Ticket
|
||||
{
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
_bugTicketList[ticket.GetId()] = ticket as BugTicket;
|
||||
if (!ticket.IsClosed())
|
||||
++_openBugTicketCount;
|
||||
break;
|
||||
case "ComplaintTicket":
|
||||
_complaintTicketList[ticket.GetId()] = ticket as ComplaintTicket;
|
||||
if (!ticket.IsClosed())
|
||||
++_openComplaintTicketCount;
|
||||
break;
|
||||
case "SuggestionTicket":
|
||||
_suggestionTicketList[ticket.GetId()] = ticket as SuggestionTicket;
|
||||
if (!ticket.IsClosed())
|
||||
++_openSuggestionTicketCount;
|
||||
break;
|
||||
}
|
||||
|
||||
ticket.SaveToDB();
|
||||
}
|
||||
|
||||
public void RemoveTicket<T>(uint ticketId) where T : Ticket
|
||||
{
|
||||
T ticket = GetTicket<T>(ticketId);
|
||||
if (ticket != null)
|
||||
{
|
||||
ticket.DeleteFromDB();
|
||||
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
_bugTicketList.Remove(ticketId);
|
||||
break;
|
||||
case "ComplaintTicket":
|
||||
_complaintTicketList.Remove(ticketId);
|
||||
break;
|
||||
case "SuggestionTicket":
|
||||
_suggestionTicketList.Remove(ticketId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseTicket<T>(uint ticketId, ObjectGuid closedBy) where T : Ticket
|
||||
{
|
||||
T ticket = GetTicket<T>(ticketId);
|
||||
if (ticket != null)
|
||||
{
|
||||
ticket.SetClosedBy(closedBy);
|
||||
if (!closedBy.IsEmpty())
|
||||
{
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
--_openBugTicketCount;
|
||||
break;
|
||||
case "ComplaintTicket":
|
||||
--_openComplaintTicketCount;
|
||||
break;
|
||||
case "SuggestionTicket":
|
||||
--_openSuggestionTicketCount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ticket.SaveToDB();
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetTickets<T>() where T : Ticket
|
||||
{
|
||||
PreparedStatement stmt;
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
_bugTicketList.Clear();
|
||||
|
||||
_lastBugId = 0;
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ALL_GM_BUGS);
|
||||
DB.Characters.Execute(stmt);
|
||||
break;
|
||||
case "ComplaintTicket":
|
||||
_complaintTicketList.Clear();
|
||||
|
||||
_lastComplaintId = 0;
|
||||
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
trans.Append(DB.Characters.GetPreparedStatement(CharStatements.DEL_ALL_GM_COMPLAINTS));
|
||||
trans.Append(DB.Characters.GetPreparedStatement(CharStatements.DEL_ALL_GM_COMPLAINT_CHATLOGS));
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
break;
|
||||
case "SuggestionTicket":
|
||||
_suggestionTicketList.Clear();
|
||||
|
||||
_lastSuggestionId = 0;
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ALL_GM_SUGGESTIONS);
|
||||
DB.Characters.Execute(stmt);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ShowList<T>(CommandHandler handler) where T : Ticket
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandTicketshowlist);
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
foreach (var ticket in _bugTicketList.Values)
|
||||
if (!ticket.IsClosed())
|
||||
handler.SendSysMessage(ticket.FormatViewMessageString(handler));
|
||||
break;
|
||||
case "ComplaintTicket":
|
||||
foreach (var ticket in _complaintTicketList.Values)
|
||||
if (!ticket.IsClosed())
|
||||
handler.SendSysMessage(ticket.FormatViewMessageString(handler));
|
||||
break;
|
||||
case "SuggestionTicket":
|
||||
foreach (var ticket in _suggestionTicketList.Values)
|
||||
if (!ticket.IsClosed())
|
||||
handler.SendSysMessage(ticket.FormatViewMessageString(handler));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowClosedList<T>(CommandHandler handler) where T : Ticket
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandTicketshowclosedlist);
|
||||
switch (typeof(T).Name)
|
||||
{
|
||||
case "BugTicket":
|
||||
foreach (var ticket in _bugTicketList.Values)
|
||||
if (ticket.IsClosed())
|
||||
handler.SendSysMessage(ticket.FormatViewMessageString(handler));
|
||||
break;
|
||||
case "ComplaintTicket":
|
||||
foreach (var ticket in _complaintTicketList.Values)
|
||||
if (ticket.IsClosed())
|
||||
handler.SendSysMessage(ticket.FormatViewMessageString(handler));
|
||||
break;
|
||||
case "SuggestionTicket":
|
||||
foreach (var ticket in _suggestionTicketList.Values)
|
||||
if (ticket.IsClosed())
|
||||
handler.SendSysMessage(ticket.FormatViewMessageString(handler));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
long GetAge(ulong t) { return (Time.UnixTime - (long)t) / Time.Day; }
|
||||
|
||||
IEnumerable<KeyValuePair<uint, ComplaintTicket>> GetComplaintsByPlayerGuid(ObjectGuid playerGuid)
|
||||
{
|
||||
return _complaintTicketList.Where(ticket => ticket.Value.GetPlayerGuid() == playerGuid);
|
||||
}
|
||||
|
||||
public bool GetSupportSystemStatus() { return _supportSystemStatus; }
|
||||
public bool GetTicketSystemStatus() { return _supportSystemStatus && _ticketSystemStatus; }
|
||||
public bool GetBugSystemStatus() { return _supportSystemStatus && _bugSystemStatus; }
|
||||
public bool GetComplaintSystemStatus() { return _supportSystemStatus && _complaintSystemStatus; }
|
||||
public bool GetSuggestionSystemStatus() { return _supportSystemStatus && _suggestionSystemStatus; }
|
||||
public ulong GetLastChange() { return _lastChange; }
|
||||
|
||||
public void SetSupportSystemStatus(bool status) { _supportSystemStatus = status; }
|
||||
public void SetTicketSystemStatus(bool status) { _ticketSystemStatus = status; }
|
||||
public void SetBugSystemStatus(bool status) { _bugSystemStatus = status; }
|
||||
public void SetComplaintSystemStatus(bool status) { _complaintSystemStatus = status; }
|
||||
public void SetSuggestionSystemStatus(bool status) { _suggestionSystemStatus = status; }
|
||||
|
||||
public void UpdateLastChange() { _lastChange = (ulong)Time.UnixTime; }
|
||||
|
||||
public uint GenerateBugId() { return ++_lastBugId; }
|
||||
public uint GenerateComplaintId() { return ++_lastComplaintId; }
|
||||
public uint GenerateSuggestionId() { return ++_lastSuggestionId; }
|
||||
|
||||
bool _supportSystemStatus;
|
||||
bool _ticketSystemStatus;
|
||||
bool _bugSystemStatus;
|
||||
bool _complaintSystemStatus;
|
||||
bool _suggestionSystemStatus;
|
||||
Dictionary<uint, BugTicket> _bugTicketList = new Dictionary<uint, BugTicket>();
|
||||
Dictionary<uint, ComplaintTicket> _complaintTicketList = new Dictionary<uint, ComplaintTicket>();
|
||||
Dictionary<uint, SuggestionTicket> _suggestionTicketList = new Dictionary<uint, SuggestionTicket>();
|
||||
uint _lastBugId;
|
||||
uint _lastComplaintId;
|
||||
uint _lastSuggestionId;
|
||||
uint _openBugTicketCount;
|
||||
uint _openComplaintTicketCount;
|
||||
uint _openSuggestionTicketCount;
|
||||
ulong _lastChange;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Framework.GameMath;
|
||||
using Game.Chat;
|
||||
using Game.Entities;
|
||||
using Game.Network.Packets;
|
||||
using System.Text;
|
||||
|
||||
namespace Game.SupportSystem
|
||||
{
|
||||
public class Ticket
|
||||
{
|
||||
protected uint _id;
|
||||
protected ObjectGuid _playerGuid;
|
||||
protected uint _mapId;
|
||||
protected Vector3 _pos;
|
||||
protected ulong _createTime;
|
||||
protected ObjectGuid _closedBy; // 0 = Open, -1 = Console, playerGuid = player abandoned ticket, other = GM who closed it.
|
||||
protected ObjectGuid _assignedTo;
|
||||
protected string _comment;
|
||||
|
||||
public Ticket() { }
|
||||
public Ticket(Player player)
|
||||
{
|
||||
_createTime = (ulong)Time.UnixTime;
|
||||
_playerGuid = player.GetGUID();
|
||||
}
|
||||
|
||||
public void TeleportTo(Player player)
|
||||
{
|
||||
player.TeleportTo(_mapId, _pos.X, _pos.Y, _pos.Z, 0.0f, 0);
|
||||
}
|
||||
|
||||
public virtual string FormatViewMessageString(CommandHandler handler, bool detailed = false) { return ""; }
|
||||
public virtual string FormatViewMessageString(CommandHandler handler, string closedName, string assignedToName, string unassignedName, string deletedName)
|
||||
{
|
||||
StringBuilder ss = new StringBuilder();
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistguid, _id));
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistname, GetPlayerName()));
|
||||
|
||||
if (!string.IsNullOrEmpty(closedName))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketclosed, closedName));
|
||||
if (!string.IsNullOrEmpty(assignedToName))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistassignedto, assignedToName));
|
||||
if (!string.IsNullOrEmpty(unassignedName))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistunassigned, unassignedName));
|
||||
if (!string.IsNullOrEmpty(deletedName))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketdeleted, deletedName));
|
||||
return ss.ToString();
|
||||
}
|
||||
|
||||
public bool IsClosed() { return !_closedBy.IsEmpty(); }
|
||||
bool IsFromPlayer(ObjectGuid guid) { return guid == _playerGuid; }
|
||||
public bool IsAssigned() { return !_assignedTo.IsEmpty(); }
|
||||
public bool IsAssignedTo(ObjectGuid guid) { return guid == _assignedTo; }
|
||||
public bool IsAssignedNotTo(ObjectGuid guid) { return IsAssigned() && !IsAssignedTo(guid); }
|
||||
|
||||
public uint GetId() { return _id; }
|
||||
public ObjectGuid GetPlayerGuid() { return _playerGuid; }
|
||||
public Player GetPlayer() { return Global.ObjAccessor.FindConnectedPlayer(_playerGuid); }
|
||||
public string GetPlayerName()
|
||||
{
|
||||
string name = "";
|
||||
if (!_playerGuid.IsEmpty())
|
||||
ObjectManager.GetPlayerNameByGUID(_playerGuid, out name);
|
||||
|
||||
return name;
|
||||
}
|
||||
public Player GetAssignedPlayer() { return Global.ObjAccessor.FindConnectedPlayer(_assignedTo); }
|
||||
public ObjectGuid GetAssignedToGUID() { return _assignedTo; }
|
||||
public string GetAssignedToName()
|
||||
{
|
||||
string name;
|
||||
if (!_assignedTo.IsEmpty())
|
||||
if (ObjectManager.GetPlayerNameByGUID(_assignedTo, out name))
|
||||
return name;
|
||||
|
||||
return "";
|
||||
}
|
||||
string GetComment() { return _comment; }
|
||||
|
||||
public virtual void SetAssignedTo(ObjectGuid guid, bool IsAdmin = false) { _assignedTo = guid; }
|
||||
public virtual void SetUnassigned() { _assignedTo.Clear(); }
|
||||
public void SetClosedBy(ObjectGuid value) { _closedBy = value; }
|
||||
public void SetComment(string comment) { _comment = comment; }
|
||||
public void SetPosition(uint mapId, Vector3 pos)
|
||||
{
|
||||
_mapId = mapId;
|
||||
_pos = pos;
|
||||
}
|
||||
|
||||
public virtual void LoadFromDB(SQLFields fields) { }
|
||||
public virtual void SaveToDB() { }
|
||||
public virtual void DeleteFromDB() { }
|
||||
}
|
||||
|
||||
public class BugTicket : Ticket
|
||||
{
|
||||
float _facing;
|
||||
string _note;
|
||||
|
||||
|
||||
public BugTicket() : base()
|
||||
{
|
||||
_note = "";
|
||||
}
|
||||
|
||||
public BugTicket(Player player) : base(player)
|
||||
{
|
||||
_note = "";
|
||||
_id = Global.SupportMgr.GenerateBugId();
|
||||
}
|
||||
|
||||
public override void LoadFromDB(SQLFields fields)
|
||||
{
|
||||
byte idx = 0;
|
||||
_id = fields.Read<uint>(idx);
|
||||
_playerGuid = ObjectGuid.Create(HighGuid.Player, fields.Read<ulong>(++idx));
|
||||
_note = fields.Read<string>(++idx);
|
||||
_createTime = fields.Read<uint>(++idx);
|
||||
_mapId = fields.Read<ushort>(++idx);
|
||||
_pos = new Vector3(fields.Read<float>(++idx), fields.Read<float>(++idx), fields.Read<float>(++idx));
|
||||
_facing = fields.Read<float>(++idx);
|
||||
|
||||
long closedBy = fields.Read<long>(++idx);
|
||||
if (closedBy == 0)
|
||||
_closedBy = ObjectGuid.Empty;
|
||||
else if (closedBy < 0)
|
||||
_closedBy.SetRawValue(0, (ulong)closedBy);
|
||||
else
|
||||
_closedBy = ObjectGuid.Create(HighGuid.Player, (ulong)closedBy);
|
||||
|
||||
ulong assignedTo = fields.Read<ulong>(++idx);
|
||||
if (assignedTo == 0)
|
||||
_assignedTo = ObjectGuid.Empty;
|
||||
else
|
||||
_assignedTo = ObjectGuid.Create(HighGuid.Player, assignedTo);
|
||||
|
||||
_comment = fields.Read<string>(++idx);
|
||||
}
|
||||
|
||||
public override void SaveToDB()
|
||||
{
|
||||
byte idx = 0;
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_GM_BUG);
|
||||
stmt.AddValue(idx, _id);
|
||||
stmt.AddValue(++idx, _playerGuid.GetCounter());
|
||||
stmt.AddValue(++idx, _note);
|
||||
stmt.AddValue(++idx, _mapId);
|
||||
stmt.AddValue(++idx, _pos.X);
|
||||
stmt.AddValue(++idx, _pos.Y);
|
||||
stmt.AddValue(++idx, _pos.Z);
|
||||
stmt.AddValue(++idx, _facing);
|
||||
stmt.AddValue(++idx, _closedBy.GetCounter());
|
||||
stmt.AddValue(++idx, _assignedTo.GetCounter());
|
||||
stmt.AddValue(++idx, _comment);
|
||||
|
||||
DB.Characters.Execute(stmt);
|
||||
}
|
||||
|
||||
public override void DeleteFromDB()
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GM_BUG);
|
||||
stmt.AddValue(0, _id);
|
||||
DB.Characters.Execute(stmt);
|
||||
}
|
||||
|
||||
public override string FormatViewMessageString(CommandHandler handler, bool detailed = false)
|
||||
{
|
||||
ulong curTime = (ulong)Time.UnixTime;
|
||||
|
||||
StringBuilder ss = new StringBuilder();
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistguid, _id));
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistname, GetPlayerName()));
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistagecreate, Time.secsToTimeString(curTime - _createTime, true, false)));
|
||||
|
||||
if (!_assignedTo.IsEmpty())
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistassignedto, GetAssignedToName()));
|
||||
|
||||
if (detailed)
|
||||
{
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistmessage, _note));
|
||||
if (!string.IsNullOrEmpty(_comment))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistcomment, _comment));
|
||||
}
|
||||
return ss.ToString();
|
||||
}
|
||||
|
||||
string GetNote() { return _note; }
|
||||
|
||||
public void SetFacing(float facing) { _facing = facing; }
|
||||
public void SetNote(string note) { _note = note; }
|
||||
}
|
||||
|
||||
public class ComplaintTicket : Ticket
|
||||
{
|
||||
float _facing;
|
||||
ObjectGuid _targetCharacterGuid;
|
||||
GMSupportComplaintType _complaintType;
|
||||
SupportTicketSubmitComplaint.SupportTicketChatLog _chatLog;
|
||||
string _note;
|
||||
|
||||
public ComplaintTicket() : base()
|
||||
{
|
||||
_note = "";
|
||||
}
|
||||
|
||||
public ComplaintTicket(Player player) : base(player)
|
||||
{
|
||||
_note = "";
|
||||
_id = Global.SupportMgr.GenerateComplaintId();
|
||||
}
|
||||
|
||||
public override void LoadFromDB(SQLFields fields)
|
||||
{
|
||||
byte idx = 0;
|
||||
_id = fields.Read<uint>(idx);
|
||||
_playerGuid = ObjectGuid.Create(HighGuid.Player, fields.Read<ulong>(++idx));
|
||||
_note = fields.Read<string>(++idx);
|
||||
_createTime = fields.Read<uint>(++idx);
|
||||
_mapId = fields.Read<ushort>(++idx);
|
||||
_pos = new Vector3(fields.Read<float>(++idx), fields.Read<float>(++idx), fields.Read<float>(++idx));
|
||||
_facing = fields.Read<float>(++idx);
|
||||
_targetCharacterGuid = ObjectGuid.Create(HighGuid.Player, fields.Read<ulong>(++idx));
|
||||
_complaintType = (GMSupportComplaintType)fields.Read<byte>(++idx);
|
||||
int reportLineIndex = fields.Read<int>(++idx);
|
||||
if (reportLineIndex != -1)
|
||||
_chatLog.ReportLineIndex.Set((uint)reportLineIndex);
|
||||
|
||||
long closedBy = fields.Read<long>(++idx);
|
||||
if (closedBy == 0)
|
||||
_closedBy = ObjectGuid.Empty;
|
||||
else if (closedBy < 0)
|
||||
_closedBy.SetRawValue(0, (ulong)closedBy);
|
||||
else
|
||||
_closedBy = ObjectGuid.Create(HighGuid.Player, (ulong)closedBy);
|
||||
|
||||
ulong assignedTo = fields.Read<ulong>(++idx);
|
||||
if (assignedTo == 0)
|
||||
_assignedTo = ObjectGuid.Empty;
|
||||
else
|
||||
_assignedTo = ObjectGuid.Create(HighGuid.Player, assignedTo);
|
||||
|
||||
_comment = fields.Read<string>(++idx);
|
||||
}
|
||||
|
||||
public void LoadChatLineFromDB(SQLFields fields)
|
||||
{
|
||||
_chatLog.Lines.Add(new SupportTicketSubmitComplaint.SupportTicketChatLine(fields.Read<uint>(0), fields.Read<string>(1)));
|
||||
}
|
||||
|
||||
public override void SaveToDB()
|
||||
{
|
||||
var trans = new SQLTransaction();
|
||||
|
||||
byte idx = 0;
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_GM_COMPLAINT);
|
||||
stmt.AddValue(idx, _id);
|
||||
stmt.AddValue(++idx, _playerGuid.GetCounter());
|
||||
stmt.AddValue(++idx, _note);
|
||||
stmt.AddValue(++idx, _mapId);
|
||||
stmt.AddValue(++idx, _pos.X);
|
||||
stmt.AddValue(++idx, _pos.Y);
|
||||
stmt.AddValue(++idx, _pos.Z);
|
||||
stmt.AddValue(++idx, _facing);
|
||||
stmt.AddValue(++idx, _targetCharacterGuid.GetCounter());
|
||||
stmt.AddValue(++idx, _complaintType);
|
||||
if (_chatLog.ReportLineIndex.HasValue)
|
||||
stmt.AddValue(++idx, _chatLog.ReportLineIndex.Value);
|
||||
else
|
||||
stmt.AddValue(++idx, -1); // empty ReportLineIndex
|
||||
stmt.AddValue(++idx, _closedBy.GetCounter());
|
||||
stmt.AddValue(++idx, _assignedTo.GetCounter());
|
||||
stmt.AddValue(++idx, _comment);
|
||||
trans.Append(stmt);
|
||||
|
||||
uint lineIndex = 0;
|
||||
foreach (var c in _chatLog.Lines)
|
||||
{
|
||||
idx = 0;
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_GM_COMPLAINT_CHATLINE);
|
||||
stmt.AddValue(idx, _id);
|
||||
stmt.AddValue(++idx, lineIndex);
|
||||
stmt.AddValue(++idx, c.Timestamp);
|
||||
stmt.AddValue(++idx, c.Text);
|
||||
|
||||
trans.Append(stmt);
|
||||
++lineIndex;
|
||||
}
|
||||
|
||||
DB.Characters.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
public override void DeleteFromDB()
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GM_COMPLAINT);
|
||||
stmt.AddValue(0, _id);
|
||||
DB.Characters.Execute(stmt);
|
||||
|
||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GM_COMPLAINT_CHATLOG);
|
||||
stmt.AddValue(0, _id);
|
||||
DB.Characters.Execute(stmt);
|
||||
}
|
||||
|
||||
public override string FormatViewMessageString(CommandHandler handler, bool detailed = false)
|
||||
{
|
||||
ulong curTime = (ulong)Time.UnixTime;
|
||||
|
||||
StringBuilder ss = new StringBuilder();
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistguid, _id));
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistname, GetPlayerName()));
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistagecreate, Time.secsToTimeString(curTime - _createTime, true, false)));
|
||||
|
||||
if (!_assignedTo.IsEmpty())
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistassignedto, GetAssignedToName()));
|
||||
|
||||
if (detailed)
|
||||
{
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistmessage, _note));
|
||||
if (!string.IsNullOrEmpty(_comment))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistcomment, _comment));
|
||||
}
|
||||
return ss.ToString();
|
||||
}
|
||||
|
||||
ObjectGuid GetTargetCharacterGuid() { return _targetCharacterGuid; }
|
||||
GMSupportComplaintType GetComplaintType() { return _complaintType; }
|
||||
string GetNote() { return _note; }
|
||||
|
||||
public void SetFacing(float facing) { _facing = facing; }
|
||||
public void SetTargetCharacterGuid(ObjectGuid targetCharacterGuid)
|
||||
{
|
||||
_targetCharacterGuid = targetCharacterGuid;
|
||||
}
|
||||
public void SetComplaintType(GMSupportComplaintType type) { _complaintType = type; }
|
||||
public void SetChatLog(SupportTicketSubmitComplaint.SupportTicketChatLog log) { _chatLog = log; }
|
||||
public void SetNote(string note) { _note = note; }
|
||||
}
|
||||
|
||||
public class SuggestionTicket : Ticket
|
||||
{
|
||||
float _facing;
|
||||
string _note;
|
||||
|
||||
public SuggestionTicket() : base()
|
||||
{
|
||||
_note = "";
|
||||
}
|
||||
|
||||
public SuggestionTicket(Player player) : base(player)
|
||||
{
|
||||
_note = "";
|
||||
_id = Global.SupportMgr.GenerateSuggestionId();
|
||||
}
|
||||
|
||||
public override void LoadFromDB(SQLFields fields)
|
||||
{
|
||||
byte idx = 0;
|
||||
_id = fields.Read<uint>(idx);
|
||||
_playerGuid = ObjectGuid.Create(HighGuid.Player, fields.Read<ulong>(++idx));
|
||||
_note = fields.Read<string>(++idx);
|
||||
_createTime = fields.Read<uint>(++idx);
|
||||
_mapId = fields.Read<ushort>(++idx);
|
||||
_pos = new Vector3(fields.Read<float>(++idx), fields.Read<float>(++idx), fields.Read<float>(++idx));
|
||||
_facing = fields.Read<float>(++idx);
|
||||
|
||||
long closedBy = fields.Read<long>(++idx);
|
||||
if (closedBy == 0)
|
||||
_closedBy = ObjectGuid.Empty;
|
||||
else if (closedBy < 0)
|
||||
_closedBy.SetRawValue(0, (ulong)closedBy);
|
||||
else
|
||||
_closedBy = ObjectGuid.Create(HighGuid.Player, (ulong)closedBy);
|
||||
|
||||
ulong assignedTo = fields.Read<ulong>(++idx);
|
||||
if (assignedTo == 0)
|
||||
_assignedTo = ObjectGuid.Empty;
|
||||
else
|
||||
_assignedTo = ObjectGuid.Create(HighGuid.Player, assignedTo);
|
||||
|
||||
_comment = fields.Read<string>(++idx);
|
||||
}
|
||||
|
||||
public override void SaveToDB()
|
||||
{
|
||||
byte idx = 0;
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.REP_GM_SUGGESTION);
|
||||
stmt.AddValue(idx, _id);
|
||||
stmt.AddValue(++idx, _playerGuid.GetCounter());
|
||||
stmt.AddValue(++idx, _note);
|
||||
stmt.AddValue(++idx, _mapId);
|
||||
stmt.AddValue(++idx, _pos.X);
|
||||
stmt.AddValue(++idx, _pos.Y);
|
||||
stmt.AddValue(++idx, _pos.Z);
|
||||
stmt.AddValue(++idx, _facing);
|
||||
stmt.AddValue(++idx, _closedBy.GetCounter());
|
||||
stmt.AddValue(++idx, _assignedTo.GetCounter());
|
||||
stmt.AddValue(++idx, _comment);
|
||||
|
||||
DB.Characters.Execute(stmt);
|
||||
}
|
||||
|
||||
public override void DeleteFromDB()
|
||||
{
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_GM_SUGGESTION);
|
||||
stmt.AddValue(0, _id);
|
||||
DB.Characters.Execute(stmt);
|
||||
}
|
||||
|
||||
public override string FormatViewMessageString(CommandHandler handler, bool detailed = false)
|
||||
{
|
||||
ulong curTime = (ulong)Time.UnixTime;
|
||||
|
||||
StringBuilder ss = new StringBuilder();
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistguid, _id));
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistname, GetPlayerName()));
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistagecreate, Time.secsToTimeString(curTime - _createTime, true, false)));
|
||||
|
||||
string name;
|
||||
if (ObjectManager.GetPlayerNameByGUID(_assignedTo, out name))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistassignedto, name));
|
||||
|
||||
if (detailed)
|
||||
{
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistmessage, _note));
|
||||
if (!string.IsNullOrEmpty(_comment))
|
||||
ss.Append(handler.GetParsedString(CypherStrings.CommandTicketlistcomment, _comment));
|
||||
}
|
||||
return ss.ToString();
|
||||
}
|
||||
|
||||
string GetNote() { return _note; }
|
||||
public void SetNote(string note) { _note = note; }
|
||||
|
||||
public void SetFacing(float facing) { _facing = facing; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user