It is currently 24 Jun 2019, 17:29
   
Text Size

Manalink 3.0 multiplayers setup and test

Discuss Upcoming Releases, Coding New Cards, Etc.
PLEASE DO NOT REPORT BUGS HERE!

Moderators: BAgate, drool66, stassy, Aswan jaguar, gmzombie, CCGHQ Admins

Re: Manalink 3.0 multiplayers setup and test

Postby Korath » 14 Sep 2015, 18:39

The three most obvious things that'll desync multiplayer are
  1. generating random numbers and not sending them over the network
  2. calling the non-network-aware versions of low-level UI choice functions (I think the only one Manalink uses is choose_a_card()) without communicating the result over the network
  3. treating players 0 (the human in a human-AI duel, or the local player in multiplayer) and 1 (the AI in a human-AI duel, or the remote player in multiplayer) differently.
Misuse of random numbers is easy to find - grep finds 152 uses of internal_rand() in Manalink source, essentially all of them problematic - but not terribly difficult to fix. There's a function at 0x44E070 that I've labeled network_rand_raw() which takes a player and an upper bound (the same way internal_rand() does), and either picks a random number and sends it if player is the local player, or waits to receive the random number if player is the remote one. All you need to do is make a front end that calls that instead of internal_rand() during multiplayer, like I've done in network_rand() in src/shandalar/ai.cpp.

There's no premade network-aware front end for choose_a_card(), since it was originally only used for Ring of Ma'ruf, but the network handling for it can be lifted out of that card's function in magic.exe.

The third case is the hardest to automatically find, the most extensive, and the hardest to fix. There are many, many cases where, instead of coaxing the AI to choose to do the right thing, it's instead forced to - Energy Arc, for example, can only legally target non-attacking creatures if player 0 is casting it; and many cards similar to Bloodthirsty Ogre have end-of-turn triggers forcing them to activate if controlled by player 1. So if one player - remember, both players in a network game think they're player 0, and the other is player 1 - casts Energy Arc and targets a blocking creature, the other player is going to think the target's illegal; and if someone controls an untapped Bloodthirsty Ogre at the end of his opponent's turn, the other player is going to think it has more devotion counters than it should. Kaboom.
User avatar
Korath
DEVELOPER
 
Posts: 3388
Joined: 02 Jun 2013, 05:57
Has thanked: 482 times
Been thanked: 938 times

Previous

Return to Development

Who is online

Users browsing this forum: No registered users and 2 guests


Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 2 guests

Login Form