Improve client index consistency in debug mode#3
Merged
tabularelf merged 2 commits intotabularelf:mainfrom Aug 18, 2024
Merged
Conversation
Owner
|
LTS doesn't have |
Contributor
Author
|
To be clear, this PR works in LTS. I made the changes necessary. |
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.
When running in debug mode (with the debug mode compatibility option turned on), one would expect the client indexes to be
0and1to match non-debug mode. However, I found that (on Windows at least) the client indexes of successfully opened windows can vary a lot. For example, for two clients, you might receive indexes of0and7or1and2. It further seems like the highest index client is the one that typically connectes to the debugger. This makes it hard to debug MultiClient projects.This PR addresses the inconsistency in client indexes by using networking sockets to allow clients to detect the presence of other clients. This works by creating sockets that we expect to fail to be created. When we fail then we increment the socket port and try again. We continue to do this until we create a socket successfully which tells us how many client already exist. A successfully created socket is destroyed 1 second later to avoid leaving it open unnecessarily. We then convert the number of open clients such that the last client to be created is index 0, thus ensuring that index 0 is always the instance that is connected to the debugger regardless of the number of clients that exist.
Due to bugs in LTS (I think?), the native
extension_*()functions fail. This means the number of clients and the starting port have to be routed through the batch file and into the executable parameters. This sucks, and when this utility is updated to a more recent version of GameMaker this should be addressed.