[Solved] This function just crashes, no error at all.

Level 23
Joined
Mar 15, 2012
Messages
2,710
Kind of wondering if there is any fix for this? Apparently the jass checker dislikes this so much it crashes itself and your editor with it.

JASS:
function GetHost takes nothing returns nothing
    local gamecache g = InitGameCache("Map.w3v")
    call StoreInteger ( g, "Map", "Host", GetPlayerId(GetLocalPlayer ())+1)
    call TriggerSyncStart ()
    call SyncStoredInteger ( g, "Map", "Host" )
    call TriggerSyncReady ()
    set udg_Host = Player( GetStoredInteger ( g, "Map", "Host" )-1)
    call FlushGameCache( g )
    set g = null
endfunction
 
Level 39
Joined
Jun 23, 2007
Messages
4,058
Use JassHelper and pJASS. Never use the default JASS syntax checker. The code above works perfectly fine for me in JNGP.

I think you can also get the host with my SyncInteger library (not thoroughly tested).

JASS:
library GetHost initializer Init requires SyncInteger
   
    globals
        player Host = null
    endglobals
   
    private function FoundHost takes nothing returns boolean
        if (Host == null) then
            set Host = GetSyncedPlayer()
            call BJDebugMsg(GetPlayerName(Host))
        endif
       
        return false
    endfunction
   
    function OnMapStart takes nothing returns nothing
        call SyncInteger(GetPlayerId(GetLocalPlayer()), 1)
    endfunction
   
    function Init takes nothing returns nothing
        call TimerStart(CreateTimer(), 0.00, false, function OnMapStart)
        call OnSyncInteger(function FoundHost)
    endfunction

endlibrary
 
Level 23
Joined
Mar 15, 2012
Messages
2,710
It actually broke on my newgen as well, the fix for it was to re-type the entire thing. Apparently there's an invisible char somewhere in the original post I CnP'd. Thanks, when it worked perfectly for you, got me to realize I must have copy and pasted a hidden char/space. =)

Edit: I don't use vJASS but your system looks interesting. I prefer vanilla editing, easier for myself because I like seeing what the code looks like.
 

Dr Super Good

Spell Reviewer
Level 61
Joined
Jan 18, 2005
Messages
26,963
Be aware that the function returns the player with the lowest latency. WC3 has no concept of "host player". When a user hosts a game in WC3 the game starts an internal server which they join in the same way as other clients. As such it is completely possible for different computers to have lower latency, as I experienced once when playing on BattleNet with my brother who is on the same LAN network as me.

As such it is almost always far better to hard-code a player as "host" or to use a vote system for equality purposes.
 
Top