fix: role_history records the old role instead of the new one - #1421
Closed
Karlious wants to merge 1 commit into
Closed
fix: role_history records the old role instead of the new one#1421Karlious wants to merge 1 commit into
Karlious wants to merge 1 commit into
Conversation
update_role() pushed [role(), turn] into role_history after obj_ini.role[company][marine_number] was already set to new_role. Since role() is a live read (obj_ini.role[company][marine_number]), this logged the role a marine was promoted TO at every step instead of the role he held, making the career history record off-by-one forever. Capture the old role into a local before the write.
Collaborator
|
This is just claude straight out hallucinating the function logs the new role and the turn it was given and stores it in the role_history array |
Contributor
Author
|
You're right — with the creation-time entry recording the starting role, appending the new role at each change gives a complete timeline, and "old role" would just duplicate the previous entry. Withdrawing this one; thanks for the quick read. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
In
update_role()(scripts/scr_marine_struct/scr_marine_struct.gml), therole_historyentry is pushed after the role has already been overwritten:role()is a live read (return obj_ini.role[company][marine_number];), not a cached value, so by the time it's called here it returnsnew_role, not the role the marine actually held before the change.Why this is unintended
Every other place in the same file that records a role into history captures it before overwriting the field — see the struct-init logic a few lines up (
role_history = [[role, obj_controller.turn]]style, built from the role at creation time, not a post-write read). The ordering here is a straightforward "the value was already overwritten before it was logged" bug, not a deliberate choice — nothing downstream readsrole_historyexpecting the new role, and there's no comment or intent suggesting this was on purpose.Before / after
[new_role, turn]torole_history— the marine's logged career history shows the role he was promoted to at each step, never the role he actually held. The record is off by one forever (and the very first entry a marine ever gets is meaningless, since it just repeats itself).role_historycorrectly logs[old_role, turn]— the role the marine held immediately before the change, matching what "history" is supposed to mean.How to observe it in game
role_history(e.g. via a save file, or any UI/tooltip that surfaces it).Fix
Capture
role()into a local before the write, then log the local instead of re-reading the (now-updated) field.🤖 Generated with Claude Code
Summary by cubic
Fix role history logging so it records the marine’s previous role at each change, not the new one. We now capture the old role before updating and log it with the current turn, correcting the off-by-one career history.
Written for commit 151823f. Summary will update on new commits.