Skip to content
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

When adding an MPFEventHandler configured to listen to player_added results in an error in the GMCServer #19

Closed
bernarma opened this issue Dec 18, 2024 · 1 comment

Comments

@bernarma
Copy link
Contributor

bernarma commented Dec 18, 2024

Start the game and add more than 1 player.

Without Handler

13:52:33.214 : DEBUG : GMCServer : { "player_num": 1, "cmd": "player_added" }
13:52:40.543 : DEBUG : GMCServer : { "player_num": 2, "cmd": "player_added" }
13:52:41.850 : DEBUG : GMCServer : { "player_num": 3, "cmd": "player_added" }
13:52:42.822 : DEBUG : GMCServer : { "player_num": 4, "cmd": "player_added" }

With Handler

13:55:40.844 : DEBUG : GMCServer : { "player_num": 1, "cmd": "player_added" }
13:55:42.387 : DEBUG : GMCServer : { "player_num": 2, "cmd": "player_added" }
13:55:42.387 : DEBUG : GMCServer : { "name": "player_added", "player": "<Player 2>", "num": 2, "cmd": "player_added" }

This code fails when attempting to access the player_num property.

func add_player(kwargs: Dictionary) -> void:
	players.append({
		"score": 0,
		"number": kwargs.player_num
	})
	num_players = players.size()
	emit_signal("player_added", num_players)

Using the latest Godot MC and MPF (0.8+) versions.

@avanwinkle
Copy link
Contributor

Thanks! The naming of player number properties has been a troublesome spot in MPF for a while, and in this case there were two code paths broadcasting a player_added event and using different kwarg names for the player number.

I've pushed a fix to GMC to better handle the duplicate events, and created issue missionpinball/mpf#1858 to track the MPF side and resolve the issue.

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

No branches or pull requests

2 participants