How to ensure all players have entered the game

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Deathmatcher
Posts: 120
Joined: Thu Dec 11, 2003 12:16 pm

How to ensure all players have entered the game

Post by Deathmatcher »

How can I ensure that, at the beginning of the game, all designated players have entered the game, before running things in a script?

For example, if I call HudMessageBold() in an ENTER or OPEN script of a cooperative game, is it guaranteed that the message is broadcast to all players that have joined the game with -join? Or is there a possibility that players are omitted because they are not technically in the game yet?

Now, I'm aware that for this particular simple example I could just use HudMessage() in an ENTER script and it would execute for each player. But what if things get more complex? For example imagine an ENTER script where I want to to show a skippable cutscene to all players, that contains HudMessageBold and other broadcasts.
If I couldn't rely on HudMessageBold() and other broadcasts being shown to all players at game start, I would need to fall back to HudMessage() and call that from an ACS_ExecuteAlways-script. But ACS_Terminate wouldn't work on this script, so the cutscene wouldn't be skippable.

Essentially, what I would like to do is some check like this:

Code: Select all

while (PlayerCount < HostPlayerCount) {
  delay(1);
}
// broadcast stuff to all players
Is there a best-practice, to achieve something like this? Or are the broadcasts much more robust than I think them to be? Does it maybe suffice to wait for a second before using them in an ENTER script?
User avatar
Kappes Buur
 
 
Posts: 4200
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: How to ensure all players have entered the game

Post by Kappes Buur »

I have not played a multiplayer game for ages, but from what I remember,
GZDoom, by its Peer-to-Peer nature, will not start until all players have
entered the game.
User avatar
Deathmatcher
Posts: 120
Joined: Thu Dec 11, 2003 12:16 pm

Re: How to ensure all players have entered the game

Post by Deathmatcher »

For all practical purposes this seems to work, as far as I can see. I'm still somewhat sceptical about assigning a TID to a player in an ENTER script and then refering to the TIDs of all the players in the ENTER script as well. I have feeling that I'm just narrowly avoiding a hidden race condition here. But testing shows that it works and it solves a lot of other problems for me, so I will stick to it for the time being. :)
Post Reply

Return to “Scripting”