Quick Changes.
This commit is contained in:
parent
aee7eb4af8
commit
1fff1a96c7
@ -264,7 +264,7 @@ public class GameAccount : PersistentRPCObject
|
||||
|
||||
public Toon CurrentToon
|
||||
{
|
||||
get => _currentToonId == 0 ? null : ToonManager.GetToonByLowID(_currentToonId);
|
||||
get => _currentToonId == 0 ? null : ToonManager.GetToonByLowId(_currentToonId);
|
||||
set
|
||||
{
|
||||
if (value.GameAccount.PersistentID != PersistentID) return; //just in case...
|
||||
|
||||
@ -282,7 +282,7 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => {
|
||||
try
|
||||
{
|
||||
Toons.ToonManager.GetToonByLowID((ulong)tscToonId).StateChanged();
|
||||
Toons.ToonManager.GetToonByLowId((ulong)tscToonId).StateChanged();
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
|
||||
@ -33,7 +33,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem
|
||||
|
||||
static Service()
|
||||
{
|
||||
foreach (var type in Assembly.GetExecutingAssembly().GetTypes().Where(type => type.GetInterface("IServerService") != null))
|
||||
foreach (var type in Assembly.GetExecutingAssembly().GetTypes().Where(type => type.GetInterface(nameof(IServerService)) != null))
|
||||
{
|
||||
var attributes = type.GetCustomAttributes(typeof(ServiceAttribute), true);
|
||||
if (attributes.Length == 0) return;
|
||||
|
||||
@ -1075,7 +1075,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
HeroDigestListResponse.Builder builder = HeroDigestListResponse.CreateBuilder();
|
||||
foreach (var toon in request.ToonIdList)
|
||||
{
|
||||
builder.AddDigestList(ToonManager.GetToonByLowID(toon).Digest);
|
||||
builder.AddDigestList(ToonManager.GetToonByLowId(toon).Digest);
|
||||
}
|
||||
|
||||
return builder.Build().ToByteString();
|
||||
@ -1103,7 +1103,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
private ByteString OnHeroDeleteParams(BattleClient client, ByteString data)
|
||||
{
|
||||
var deleteParams = DeleteHero.ParseFrom(data);
|
||||
var toon = ToonManager.GetToonByLowID(deleteParams.HeroId);
|
||||
var toon = ToonManager.GetToonByLowId(deleteParams.HeroId);
|
||||
ToonManager.DeleteToon(toon);
|
||||
return ByteString.Empty;
|
||||
}
|
||||
@ -1113,7 +1113,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
var request = GetToonSettings.ParseFrom(data);
|
||||
|
||||
var oldToon = client.Account.GameAccount.CurrentToon;
|
||||
var newToon = ToonManager.GetToonByLowID(request.HeroId);
|
||||
var newToon = ToonManager.GetToonByLowId(request.HeroId);
|
||||
|
||||
if (oldToon != newToon)
|
||||
{
|
||||
@ -3022,7 +3022,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
{
|
||||
foreach (var hero in testRequest.HeroIdsList)
|
||||
{
|
||||
var toon = ToonManager.GetToonByLowID(hero);
|
||||
var toon = ToonManager.GetToonByLowId(hero);
|
||||
if (toon.Dead == false)
|
||||
profileList.AddHeros(toon.Profile);
|
||||
}
|
||||
@ -3091,7 +3091,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
var request = HeroDigestListRequest.ParseFrom(data);
|
||||
var builder = HeroDigestListResponse.CreateBuilder();
|
||||
foreach (var toon in request.ToonIdList)
|
||||
builder.AddDigestList(ToonManager.GetToonByLowID(toon).Digest);
|
||||
builder.AddDigestList(ToonManager.GetToonByLowId(toon).Digest);
|
||||
|
||||
return builder.Build().ToByteString();
|
||||
}
|
||||
|
||||
@ -1242,28 +1242,18 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
|
||||
#endregion
|
||||
|
||||
public static ToonClass GetClassByID(int classId)
|
||||
{
|
||||
switch (classId)
|
||||
public static ToonClass GetClassByID(int classId) =>
|
||||
classId switch
|
||||
{
|
||||
case 0x4FB91EE2:
|
||||
return ToonClass.Barbarian;
|
||||
case unchecked((int)0xBE27DC19):
|
||||
return ToonClass.Crusader;
|
||||
case unchecked((int)0xC88B9649):
|
||||
return ToonClass.DemonHunter;
|
||||
case 0x003DAC15:
|
||||
return ToonClass.Monk;
|
||||
case 0x0343C22A:
|
||||
return ToonClass.WitchDoctor;
|
||||
case 0x1D4681B1:
|
||||
return ToonClass.Wizard;
|
||||
case unchecked((int)0x8D4D94ED):
|
||||
return ToonClass.Necromancer;
|
||||
}
|
||||
|
||||
return ToonClass.Barbarian;
|
||||
}
|
||||
0x4FB91EE2 => ToonClass.Barbarian,
|
||||
unchecked((int)0xBE27DC19) => ToonClass.Crusader,
|
||||
unchecked((int)0xC88B9649) => ToonClass.DemonHunter,
|
||||
0x003DAC15 => ToonClass.Monk,
|
||||
0x0343C22A => ToonClass.WitchDoctor,
|
||||
0x1D4681B1 => ToonClass.Wizard,
|
||||
unchecked((int)0x8D4D94ED) => ToonClass.Necromancer,
|
||||
_ => ToonClass.Barbarian
|
||||
};
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
{
|
||||
public static class ToonManager
|
||||
{
|
||||
private static readonly ConcurrentDictionary<ulong, Toon> LoadedToons = new ConcurrentDictionary<ulong, Toon>();
|
||||
private static readonly ConcurrentDictionary<ulong, Toon> LoadedToons = new();
|
||||
private static readonly Logger Logger = LogManager.CreateLogger("DataBaseSystem");
|
||||
|
||||
private static readonly DBInventory NewbiePants = new DBInventory
|
||||
@ -146,7 +146,7 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
Attributes = "383,:1|1E-45;103,:0|0;406,:0|0;409,:1|1E-45;401,:1|1E-45;405,:1941814752|3.0065772E+31;194,:1067030938|1.2;196,:1067030938|1.2;198,:1067030938|1.2;538,:1067030938|1.2;540,:1067030938|1.2;546,:1067030938|1.2;201,:1067030938|1.2;446,:0|0;447,:0|0;448,:0|0;449,:0|0;539,:0|0;541,:0|0;195,:0|0;197,:0|0;231,0:1073741824|2;224,0:1077936128|3;232,0:1073741824|2;225,0:1077936128|3;226,:1077936128|3;233,:1073741824|2;236,:1075838976|2.5;235,0:1075838976|2.5;542,0:1073741824|2;547,0:1073741824|2;220,0:1073741824|2;216,0:1073741824|2;543,0:0|0;234,0:1075838976|2.5;222,0:1065353216|1;223,0:1065353216|1;227,0:1065353216|1;228,:1065353216|1;544,0:1065353216|1;548,0:1065353216|1;213,0:1065353216|1;545,0:0|0;381,:1000|1.401E-42;380,:1000|1.401E-42;100,30592:1|1E-45;102,30592:1|1E-45;388,57:0|0"
|
||||
};
|
||||
|
||||
private static readonly DBInventory NewbieNecr = new DBInventory
|
||||
private static readonly DBInventory NewbieNecromancer = new DBInventory
|
||||
{
|
||||
EquipmentSlot = 4,
|
||||
LocationX = 0,
|
||||
@ -181,11 +181,8 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
public static void PreLoadToons()
|
||||
{
|
||||
Logger.Info("Loading Diablo III - Toons...");
|
||||
List<DBToon> all_toons = DBSessions.SessionQuery<DBToon>();
|
||||
foreach (var toon in all_toons)
|
||||
{
|
||||
foreach (var toon in DBSessions.SessionQuery<DBToon>())
|
||||
LoadedToons.TryAdd(toon.Id, new Toon(toon, null));
|
||||
}
|
||||
}
|
||||
|
||||
public static Toon GetToonByDBToon(DBToon dbToon, GameDBSession session = null)
|
||||
@ -203,15 +200,15 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
|
||||
public static Account GetOwnerAccountByToonLowId(ulong id)
|
||||
{
|
||||
return GetToonByLowID(id).GameAccount.Owner;
|
||||
return GetToonByLowId(id).GameAccount.Owner;
|
||||
}
|
||||
|
||||
public static GameAccount GetOwnerGameAccountByToonLowId(ulong id)
|
||||
{
|
||||
return GetToonByLowID(id).GameAccount;
|
||||
return GetToonByLowId(id).GameAccount;
|
||||
}
|
||||
|
||||
public static Toon GetToonByLowID(ulong id, GameDBSession session = null)
|
||||
public static Toon GetToonByLowId(ulong id, GameDBSession session = null)
|
||||
{
|
||||
if (LoadedToons.ContainsKey(id))
|
||||
return LoadedToons[id];
|
||||
@ -225,20 +222,14 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
public static Toon GetDeletedToon(GameAccount account)
|
||||
{
|
||||
var query = DBSessions.SessionQueryWhere<DBToon>(dbt => dbt.DBGameAccount.Id == account.PersistentID && dbt.Deleted);
|
||||
return query.Any() ? GetToonByLowID(query.Last().Id) : null;
|
||||
return query.Any() ? GetToonByLowId(query.Last().Id) : null;
|
||||
}
|
||||
|
||||
public static List<Toon> GetToonsForGameAccount(GameAccount account)
|
||||
{
|
||||
var toons = DBSessions.SessionQueryWhere<DBToon>(t => t.DBGameAccount.Id == account.PersistentID).Select(dbt => GetToonByLowID(dbt.Id));
|
||||
return toons.ToList();
|
||||
}
|
||||
public static List<Toon> GetToonsForGameAccount(GameAccount account) =>
|
||||
DBSessions.SessionQueryWhere<DBToon>(t => t.DBGameAccount.Id == account.PersistentID)
|
||||
.Select(dbt => GetToonByLowId(dbt.Id)).ToList();
|
||||
|
||||
|
||||
public static int TotalToons
|
||||
{
|
||||
get { return DBSessions.SessionQuery<DBToon>().Count; }
|
||||
}
|
||||
public static int TotalToons => DBSessions.SessionQuery<DBToon>().Count;
|
||||
|
||||
|
||||
public static Toon CreateNewToon(string name, int classId, ToonFlags flags, byte level, bool IsHardcore, GameAccount gameAccount, int Season)
|
||||
@ -274,7 +265,7 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
|
||||
DBSessions.SessionSave(newDBToon);
|
||||
|
||||
Toon createdToon = GetToonByLowID(newDBToon.Id);
|
||||
Toon createdToon = GetToonByLowId(newDBToon.Id);
|
||||
|
||||
CreateSkillSet(newDBToon);
|
||||
|
||||
@ -329,7 +320,7 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
armor.isHardcore = isHardcore;
|
||||
DBSessions.SessionSave(armor);
|
||||
|
||||
DBInventory weapon = new DBInventory();
|
||||
DBInventory weapon;
|
||||
switch (toon.DBToon.Class)
|
||||
{
|
||||
case ToonClass.Barbarian:
|
||||
@ -351,7 +342,7 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
weapon = NewbieWand;
|
||||
break;
|
||||
case ToonClass.Necromancer:
|
||||
weapon = NewbieNecr;
|
||||
weapon = NewbieNecromancer;
|
||||
break;
|
||||
default:
|
||||
weapon = NewbieKnife;
|
||||
@ -363,7 +354,6 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
DBSessions.SessionSave(weapon);
|
||||
if (toon.DBToon.Class == ToonClass.Crusader) //add shield
|
||||
{
|
||||
DBInventory shield = new DBInventory();
|
||||
weapon = NewbieShield;
|
||||
weapon.DBToon = toon.DBToon;
|
||||
weapon.DBGameAccount = toon.GameAccount.DBGameAccount;
|
||||
@ -374,14 +364,15 @@ namespace DiIiS_NA.LoginServer.Toons
|
||||
|
||||
public static void CreateHirelingProfile(Toon toon, int type)
|
||||
{
|
||||
var hireling = new DBHireling();
|
||||
hireling.Class = type;
|
||||
hireling.DBToon = toon.DBToon;
|
||||
hireling.Skill1SNOId = -1;
|
||||
hireling.Skill2SNOId = -1;
|
||||
hireling.Skill3SNOId = -1;
|
||||
hireling.Skill4SNOId = -1;
|
||||
DBSessions.SessionSave(hireling);
|
||||
DBSessions.SessionSave(new DBHireling
|
||||
{
|
||||
Class = type,
|
||||
DBToon = toon.DBToon,
|
||||
Skill1SNOId = -1,
|
||||
Skill2SNOId = -1,
|
||||
Skill3SNOId = -1,
|
||||
Skill4SNOId = -1
|
||||
});
|
||||
}
|
||||
|
||||
public static void DeleteToon(Toon toon)
|
||||
|
||||
@ -43,7 +43,7 @@ namespace DiIiS_NA.GameServer.ClientSystem
|
||||
var game = GameManager.GetGameById(message.SGameId);
|
||||
Toon toon = null;
|
||||
if (game != null)
|
||||
toon = ToonManager.GetToonByLowID((ulong)message.HeroID, game.GameDbSession);
|
||||
toon = ToonManager.GetToonByLowId((ulong)message.HeroID, game.GameDbSession);
|
||||
bool PVP = false;
|
||||
if (PVP)
|
||||
toon = new Toon(ToonManager.CreateFakeDBToon(toon.GameAccount.Owner.BattleTag, toon.GameAccount.DBGameAccount), game.GameDbSession);
|
||||
@ -53,7 +53,7 @@ namespace DiIiS_NA.GameServer.ClientSystem
|
||||
if (PVP)
|
||||
{
|
||||
game = GameManager.CreateGame(message.SGameId, 1);
|
||||
toon = ToonManager.GetToonByLowID((ulong)message.HeroID, game.GameDbSession);
|
||||
toon = ToonManager.GetToonByLowId((ulong)message.HeroID, game.GameDbSession);
|
||||
game.SetAct(0);
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
user.block.title