Skip to content

Improve client index consistency in debug mode#3

Merged
tabularelf merged 2 commits intotabularelf:mainfrom
JujuAdams:dev-debug-mode-consistency
Aug 18, 2024
Merged

Improve client index consistency in debug mode#3
tabularelf merged 2 commits intotabularelf:mainfrom
JujuAdams:dev-debug-mode-consistency

Conversation

@JujuAdams
Copy link
Contributor

When running in debug mode (with the debug mode compatibility option turned on), one would expect the client indexes to be 0 and 1 to 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 of 0 and 7 or 1 and 2. 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.

@tabularelf
Copy link
Owner

tabularelf commented Aug 4, 2024

LTS doesn't have extension_* support last I recalled. That probably has changed, but as far as I'm aware it's a clear problem.
I would've had thought of this way if I was more willing to break LTS compatibility. I may look into this in the mean time, otherwise when LTS 2025.0 comes around, I'll accept this.

@JujuAdams
Copy link
Contributor Author

To be clear, this PR works in LTS. I made the changes necessary.

@tabularelf tabularelf merged commit 9f50b8d into tabularelf:main Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants