Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move player inventory retrieval from db to a later time to improve logon time #3858

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions Source/ACE.Server/Managers/WorldManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,10 @@ public static void PlayerEnterWorld(Session session, Character character)
return;
}

var start = DateTime.UtcNow;
DatabaseManager.Shard.GetPossessedBiotasInParallel(character.Id, biotas =>
{
log.Debug($"GetPossessedBiotasInParallel for {character.Name} took {(DateTime.UtcNow - start).TotalMilliseconds:N0} ms");

ActionQueue.EnqueueAction(new ActionEventDelegate(() => DoPlayerEnterWorld(session, character, offlinePlayer.Biota, biotas)));
});
ActionQueue.EnqueueAction(new ActionEventDelegate(() => DoPlayerEnterWorld(session, character, offlinePlayer.Biota)));
}

private static void DoPlayerEnterWorld(Session session, Character character, Biota playerBiota, PossessedBiotas possessedBiotas)
private static void DoPlayerEnterWorld(Session session, Character character, Biota playerBiota)
{
Player player;

Expand Down Expand Up @@ -150,11 +144,11 @@ private static void DoPlayerEnterWorld(Session session, Character character, Bio
}

if (playerBiota.WeenieType == WeenieType.Admin)
player = new Admin(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session);
player = new Admin(playerBiota, character, session);
else if (playerBiota.WeenieType == WeenieType.Sentinel)
player = new Sentinel(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session);
player = new Sentinel(playerBiota, character, session);
else
player = new Player(playerBiota, possessedBiotas.Inventory, possessedBiotas.WieldedItems, character, session);
player = new Player(playerBiota, character, session);

session.SetPlayer(player);

Expand Down Expand Up @@ -217,6 +211,13 @@ private static void DoPlayerEnterWorld(Session session, Character character, Bio
if (olthoiPlayerReturnedToLifestone)
session.Player.Location = new Position(session.Player.Sanctuary);

var start = DateTime.UtcNow;
DatabaseManager.Shard.GetPossessedBiotasInParallel(character.Id, biotas =>
{
log.Debug($"GetPossessedBiotasInParallel for {character.Name} took {(DateTime.UtcNow - start).TotalMilliseconds:N0} ms");
player.SetBiotas(biotas.Inventory, biotas.WieldedItems);
});

session.Player.PlayerEnterWorld();

var success = LandblockManager.AddObject(session.Player, true);
Expand Down Expand Up @@ -274,7 +275,9 @@ private static void DoPlayerEnterWorld(Session session, Character character, Bio
if (olthoiPlayerReturnedToLifestone)
session.Network.EnqueueSend(new GameMessageSystemChat("You have returned to the Olthoi Queen to serve the hive.", ChatMessageType.Broadcast));
else if (playerLoggedInOnNoLogLandblock) // see http://acpedia.org/wiki/Mount_Elyrii_Hive
session.Network.EnqueueSend(new GameMessageSystemChat("The currents of portal space cannot return you from whence you came. Your previous location forbids login.", ChatMessageType.Broadcast));
session.Network.EnqueueSend(new GameMessageSystemChat("The currents of portal space cannot return you from whence you came. Your previous location forbids login.", ChatMessageType.Broadcast));


}

private static string AppendLines(params string[] lines)
Expand Down
5 changes: 5 additions & 0 deletions Source/ACE.Server/WorldObjects/Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public Admin(Biota biota, IEnumerable<ACE.Database.Models.Shard.Biota> inventory
SetEphemeralValues();
}

public Admin(Biota biota, Character character, Session session) : base(biota, character, session)
{
SetEphemeralValues();
}

private void SetEphemeralValues()
{
//BaseDescriptionFlags |= ObjectDescriptionFlag.Admin;
Expand Down
19 changes: 19 additions & 0 deletions Source/ACE.Server/WorldObjects/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ public Player(Biota biota, IEnumerable<ACE.Database.Models.Shard.Biota> inventor
UpdateCoinValue(false);
}

public Player(Biota biota, Character character, Session session) : base(biota)
{
Character = character;
Session = session;

Account = DatabaseManager.Authentication.GetAccountById(Character.AccountId);

SetEphemeralValues();

UpdateCoinValue(false);
}


public override void InitPhysicsObj()
{
base.InitPhysicsObj();
Expand Down Expand Up @@ -1201,5 +1214,11 @@ public void HandleActionEnterPkLite()
});
actionChain.EnqueueChain();
}

public void SetBiotas(IEnumerable<ACE.Database.Models.Shard.Biota> inventory, IEnumerable<ACE.Database.Models.Shard.Biota> wieldedItems)
{
SortBiotasIntoInventory(inventory);
AddBiotasToEquippedObjects(wieldedItems);
}
}
}
2 changes: 1 addition & 1 deletion Source/ACE.Server/WorldObjects/Player_Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ public void DoTeleportPhysicsStateChanges()

public void OnTeleportComplete()
{
if (CurrentLandblock != null && !CurrentLandblock.CreateWorldObjectsCompleted)
if ((CurrentLandblock != null && !CurrentLandblock.CreateWorldObjectsCompleted) || !this.EquippedObjectsLoaded)
{
// If the critical landblock resources haven't been loaded yet, we keep the player in the pink bubble state
// We'll check periodically to see when it's safe to let them materialize in
Expand Down
11 changes: 11 additions & 0 deletions Source/ACE.Server/WorldObjects/Sentinel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ public Sentinel(Biota biota, IEnumerable<ACE.Database.Models.Shard.Biota> invent
SetEphemeralValues();
}

public Sentinel(Biota biota, Character character, Session session) : base(biota, character, session)
{
if (!Character.IsPlussed)
{
Character.IsPlussed = true;
CharacterChangesDetected = true;
}

SetEphemeralValues();
}

private void SetEphemeralValues()
{
ObjectDescriptionFlags |= ObjectDescriptionFlag.Admin;
Expand Down