forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 94
[GEN][ZH] Fix limit of 100 in Replay Menu #760
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
Open
helmutbuhler
wants to merge
4
commits into
TheSuperHackers:main
Choose a base branch
from
helmutbuhler:replaymaxfix_sh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
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.
This approach looks not ideal.
Problems:
Is the replay menu rebuilt from scratch when reopening the replay menu?
The better implementation is to create the list with 0 initial elements, then get the number of replays, allocate the list for that amount, then populate it.
Calling
readReplayHeader
twice to generate the accurate list count is too expensive, but we can simply allocate the list forreplayFilenames.size()
which should be accurate enough.With this approach we avoid allocating more than once and we avoid overallocating, and logically this is a lot cleaner.
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.
Yes it is. It is how I increased/decreased the number of replay files. Very noticeable if you have 1.000 replay files, as it needs time to read the meta-data of all of them (takes about 3 - 5 seconds).
Uh oh!
There was an error while loading. Please reload this page.
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.
FYI I'm looking into implementing these suggestions. First fighting
vscodevs2022, trying to get a build working again etc, so might take a while.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.
Ok afaiu the initial length of 100 is defined in
ReplayMenu.wnd
(that took me some digging 😅), which I assume we don't want to change for this since it's not part of the code. So then initially creating the listbox with 0 elements goes out the window.So my plan now is to just resize it once, i.e.
GadgetListBoxSetListLength(listbox, replayFilenames.size())
inPopulateReplayFileListbox()
; that seems to work fine.Will test a bit more and then push it here, probably Friday (busy day tomorrow).
@helmutbuhler do you mind if I rebase this PR on main first? (I did that locally because some build configuration stuff was changed on main in the meantime, and switching between old & new drove me crazy.)
BTW,
I mean, kind of, but I think the
listbox
itself (the thing we're resizing to >100) persists between menu reopenings:PopulateReplayFileListbox(listbox)
starts off by callingGadgetListBoxReset(listbox)
, andPopulateReplayFileListbox
's callerReplayMenuInit()
fetches the listbox aslistboxReplayFiles = TheWindowManager->winGetWindowFromId(...)
. So I assume the adjusted listbox size will persist, until the next time the menu is loaded, when it will just be resized again. Doesn't seem like a problem to me, but then again I know nothing 🙃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.
If the initial size is already controllable by ReplayMenu.wnd, why do we need to change the behaviour in code then?
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.
You can create local INI edits to accommodate code. The code is not meant to be a playground, unless that code is put behind debug macros.
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.
Playground? Seriously? This code is fine, it's already tested and works as advertised. It's no harm to the user, even if we forget about it and it remains.
I want this to be fixed for everyone who is using the repository. If everyone first needs to make local edits to INI files, it's pointless. There is also nothing unusual about fixing stuff in code until we figure out a way to fix and sync data files.
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.
Just to be clear, unless I'm mistaken this cannot be fixed in data, simply because the list length is only known at run time. There is no length value we could set in the data that would accomodate all runtime situations, unless we set the length to something idiotically large, which would be very dirty imo.
It seems to me that this is simply a bug, impacting both users and developers, that can only be fixed in code.
And yes, ideally one day we'd drop the initial length of 100 from the data, and just set it in code. But that is just some bonus cleanup and an (imo very insignificant and thus irrelevant) optimization that we can do on top of this change, one day, if we really want to. For now, this change fixes the bug, in the right place, and is all we need.
My 2c 🙃
(Regardless of all this, I'll be pushing my changes here to implement @xezon's above suggestion, i.e. change the length once, instead of doubling the length until it fits. Nice practice material for me, and I do concur that it's slightly prettier, although you could argue about how important that is.)
Uh oh!
There was an error while loading. Please reload this page.
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.
Data setups needs to be fixed in our data branch, which is here:
https://github.com/TheSuperHackers/GeneralsGamePatch
The list box length is set here:
https://github.com/TheSuperHackers/GeneralsGamePatch/blob/b8f68f905e16fdaae2beda7dbea56ce753e1ab3c/Patch104pZH/GameFilesOriginalZH/Window/Menus/ReplayMenu.wnd#L190
I disagree with overriding INI settings by code. INI settings need to mean something.
LENGTH: 100
says that the max length is 100. This should not be violated by code.Options to change list lengths
LISTBOXDATA = LENGTH: 1000
I tested setting LENGTH to 0 and that works and will not show any replays. (Setting it to -1 will crash the client.)
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.
Ooooh I thought
GeneralsGamePatch
was unrelated to this project and just the repo for the balance-incompatible 1.06 patch (or whatever it's called). But now I found TheSuperHackers/GeneralsGamePatch#2596; apparently I thought wrong :)So okay I have no opinion on this until I get more acquainted with the plans. I'll ask around. In the meantime I guess I'll stop messing with this PR and see if I can help out with #651 when I have time.
As an aside, either I've just been daft for the last few weeks or we really need some toplevel documentation on the plans and how to contribute, to enable more devs to join. I've spent many hours trying to figure everything out and still the whole status/plan is in large parts a mystery to me. Not how to build but just what the idea is and which tasks need doing and why.
Even just a 10 line up-to-date CONTRIBUTING.md saying "our main priorities now are x and y; we want to keep 1.04 compatibility for now; we want to release after z; we will bundle this release with foo from GeneralsGamePatch; we'll need a launcher for that because bar" would have saved me much time and frustration.
I don't feel equipped yet to write this, but obviously I'd be happy to help if someone else wants to.