| 01-06-2010, 03:13 AM | #1 |
I can't figure this one out. It's a map that creates turn-based battles. I was testing with a buddy and when Blue attacks, he desyncs. I really don't know why. There are no handles created. The crash takes place in a function called PlayerTurn located in the Combat library and seems to be before the "Checking battle id" debug message. Map info: You'll need a Zinc-capable version of JassHelper. Take you and your buddy (since the bug doesn't show with one player) and walk together up to the first enemy. Battles start when you get close enough and the enemy unit attacks you. You will get a battle bar above your head. You can use your "Attack an enemy!" ability to do damage to enemy units. Or, you just need player 2 to initiate a battle and attack. |
| 01-06-2010, 08:26 AM | #2 |
It might help if you also post the scripts which cause the desync. |
| 01-06-2010, 11:21 AM | #3 |
in those two parts of the Battle library, you use BJ functions for a local player. Those functions create handles, and you mustnt do that for local player...creating handles for local player causes desyncs. Instead create the handle before GetLocalPlayer and just use StartSound(handle). JASS:method StartTurn(Fighter f) if(GetOwningPlayer(f.m_Unit) == GetLocalPlayer()) PlaySound("Buildings\\Other\\FountainOfLife\\FountainOfLifeWhat1.wav") JASS:function PlaySound takes string soundName returns nothing local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "") call StartSound(soundHandle) call KillSoundWhenDone(soundHandle) endfunction same goes for music. JASS:method PlayBattleMusic(unit CenterUnit) p = GetOwningPlayer(m_Fighters[i].m_Unit) if(GetLocalPlayer() == p) PlayMusicBJ("war3mapImported\\battle.mp3") JASS:function PlayMusicBJ takes string musicFileName returns nothing set bj_lastPlayedMusic = musicFileName call PlayMusic(musicFileName) endfunction |
| 01-06-2010, 10:39 PM | #4 |
The sounds aren't directly causing the desyncs. They play, but does it work like: next action client realizes it's not in sync, bam? As an aside, I really wish the CreateMIDISound stuff worked out of the box. There's a whole lot of tracks I want to put in but can't if it's going to be playable over Battle.Net and downloadable with a reasonable size. |
| 01-07-2010, 02:22 PM | #5 |
The problem here is not the sound itself. it will play, but at the same time, by using GetLocalPlayer, PlaySound creates a handle for one player only. Handles must always be created for all player. if the handle is created for only one player, it causes a desync. So heres the idea for a fix: So all you need to do is create the handle before the GetLocalplayer section. Then you can play the sound(and music too) for one player JASS:method StartTurn(Fighter f) local sound soundHandle = CreateSound("Buildings\\Other\\FountainOfLife\\FountainOfLifeWhat1.wav", false, false, true, 12700, 12700, "") if(GetOwningPlayer(f.m_Unit) == GetLocalPlayer()) StartSound(soundHandle) endif call KillSoundWhenDone(soundHandle) |
