Repository navigation
Fall back to a starting loadout when the client omits start_class_id #38
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,27 @@ public SDB(IOptions<DbConnectionSettings> config, ILogger<SDB> logger) : base(co | |
| return result.FirstOrDefault(); | ||
| } | ||
|
|
||
| // The client omits start_class_id when the player re-enters the creator from the customize screen. | ||
| // Returns the requested frame when it is a starting loadout, otherwise the first starting loadout | ||
| // (Accord Dreadnaught), so a character never ends up with battleframe_sdb_id 0, which breaks the | ||
| // zone selection paperdoll ("Invalid item ID") and leaves "Enter World" dead. | ||
| public async Task<int> GetStartingBattleframeId(int requestedFrameId) | ||
| { | ||
| const string SELECT_SQL = @"SELECT frame_id FROM sdb.""dbcharacter::CharCreateLoadout"" | ||
| WHERE is_starting_loadout = 1 AND is_dev = 0 | ||
| ORDER BY CASE WHEN frame_id = @requestedFrameId THEN 0 ELSE 1 END, id | ||
| LIMIT 1;"; | ||
|
|
||
| var result = await DBCall(conn => conn.QueryAsync<int>(SELECT_SQL, new { requestedFrameId }), | ||
| exception => Logger.LogError($"Error looking up starting battleframe for requested frame {requestedFrameId} due to: {exception}")); | ||
|
|
||
| var frameId = result.FirstOrDefault(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the lookup comes back empty (e.g. SDB not imported), this returns 0, logs "using 0" and we store I'd rather fail loudly here and throw when no starting loadout is found, than create a broken character. |
||
| if (frameId != requestedFrameId) | ||
| Logger.LogWarning("Requested start class {Requested} is not a starting loadout, using {Fallback}", requestedFrameId, frameId); | ||
|
Comment on lines
+57
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the case this PR is about, this logs "Requested start class 0 is not a starting loadout", which is a bit misleading. Maybe log |
||
|
|
||
| return frameId; | ||
| } | ||
|
|
||
| public async Task<IEnumerable<CosmeticInfo>> GetOrnamentsInfoList() | ||
| { | ||
| const string SELECT_SQL = @"SELECT ornaments.id, lang.english AS lang_name, display_flags, ""Usage"" AS ""usage"" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explanation doesn't quite match what the 1962
CharacterCreation.luadoes. Going back from Customize to Select keepsg_currentFrame,OnCancelnever touches it.The field goes missing when
g_currentFrameisnil, becauseBuildCreateHTTPRequestthen just drops the key. OnlyOnCloseCC()resets it, which runs after a successful create, on Back from the Select screen and when the random name request fails.OnCloseCC()however doesn't callClearCharacterSelection(), so the Next button stays visible. When you open the creator a second time in the same session, you can click Next without picking a frame and end up in Customize with no frame at all.Can you adjust the comment, commit message and PR description to that? I'd also only keep the comment to the why, the paperdoll and "Enter World" symptoms are better placed in the commit message. Claude loves to write books in code comments. 😅