• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

DisplayTextToplayer doesn't work

Status
Not open for further replies.

Deleted member 219079

D

Deleted member 219079

My system outprints like this:
attachment.php

My code is in 3 triggers, but here's the one which does the stuff:
JASS:
scope TBMS /*Turn Based Movement System v1.0.0*/ initializer init //Requires PlayerEx, PlayerColor
//===========================================================================

    globals
            //Constants
        private constant force FORCE = CreateForce()
        private constant timer TIMER = CreateTimer()
        private PlayerList Players
    
            //System configuration
        private constant integer DUMMY_ID = 'h000'
        
            //Presentation configuration
        private constant real INTERVAL = 5.
        private constant string TEXT_COL = "|c006699ff"
        private constant string DIGIT_COL = "|c00ffcc66"
        private constant real MSG_DURATION = 5.
    endglobals
    
//===========================================================================

    private function PlayerFilter takes nothing returns boolean
        return GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
    endfunction
    
//===========================================================================

    private function TimeOut takes nothing returns nothing
        call Players.RemovePlayer(Player(2))
        call Players.RemovePlayer(Players.GetCurrentPlayer())
        call Players.PrintOrderForPlayer(GetLocalPlayer(),MSG_DURATION)
    endfunction

//===========================================================================
    
    private function init takes nothing returns nothing
        set Players = PlayerList.create(Condition(function PlayerFilter))
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, /*
        */TEXT_COL+"Player list:\n\n")
        call Players.PrintOrderForPlayer(GetLocalPlayer(),MSG_DURATION)
        
        call TimerStart(TIMER, INTERVAL, true, function TimeOut)
        
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, /*
        */TEXT_COL+"\nGame starting in "+DIGIT_COL+I2S(R2I(INTERVAL))+TEXT_COL+" seconds, hold on...|r")
        
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, MSG_DURATION, /*
        */TEXT_COL+"Next turn: "+GetPlayerNameColored(Players.Next())+"|r")
    endfunction

//===========================================================================
endscope
And then here's the other one which might cause errors:
JASS:
library ForceEx requires PlayerColor /*

    Player list library ;
    
        Methods:
        
            method RemovePlayer takes player pl returns nothing
                - remove a player from your list
                
            method PrintOrderForPlayer takes player pl, real d returns nothing
                - prints the player list for specific player

            method Next takes nothing returns player
                - sets the next player on the list, and returns it
                
            method GetNext takes nothing returns player
                - returns the next player on the list
            
            method GetCurrentPlayer takes nothing returns player
                - returns the current player
*/

    constant function GetBigger takes real r1, real r2 returns real
        if r1 > r2 then
            return r1
        endif
        return r2
    endfunction

    constant function GetBiggerInt takes integer r1, integer r2 returns integer
        if r1 > r2 then
            return r1
        endif
        return r2
    endfunction
    
//===========================================================================
    
    struct IndexPlayer extends array
        player pl
        static method flush takes integer index, integer end returns nothing
            local integer i = index
            loop
                exitwhen i == end
                set thistype[i].pl = thistype[i+1].pl
            endloop
        endmethod
    endstruct
    
//===========================================================================
    
    struct PlayerList
    
        private integer first
        private integer last
        private integer index
        
        private static integer tempInt = - 1 //represents the highest player index used
        
//===========================================================================
        
        method RemovePlayer takes player pl returns nothing
            local integer i = first
            if i > last then //if first > last, a.k.a. the list is empty
                debug call BJDebugMsg("|c00ff0000ForceEx ERROR: Function call for an empty player list!|r")
                return
            endif
            loop
                if IndexPlayer[i].pl == pl then
                    call IndexPlayer.flush(i,last)
                    set last = last - 1
                    return
                endif
                exitwhen i == last
                set i = i + 1
            endloop
            debug call BJDebugMsg("|c00ff0000ForceEx ERROR: Unlisted player index used!|r")
        endmethod
        
//===========================================================================
        
        method PrintOrderForPlayer takes player pl, real d returns nothing
            local integer i = first
            if i > last then //if first > last, a.k.a. the list is empty
                debug call BJDebugMsg("|c00ff0000ForceEx ERROR: Function call for an empty player list!|r")
                return
            endif
            loop
                call DisplayTimedTextToPlayer(pl, 0, 0, d, I2S(i+1)+". "+GetPlayerNameColored(IndexPlayer[i].pl))
                exitwhen i == last
                set i = i + 1
            endloop
        endmethod
        
//===========================================================================
        
        method Next takes nothing returns player
            set index = index + 1
            if index>last then
                set index = first
            endif
            return IndexPlayer[index].pl
        endmethod
        
        method GetNext takes nothing returns player
            local integer i = index+1
            if i>last then
                set i=first
            endif
            return IndexPlayer[i].pl
        endmethod
        
        method GetCurrentPlayer takes nothing returns player
            return IndexPlayer[index].pl
        endmethod
        
//===========================================================================
        
        static method initPlayerList takes nothing returns nothing
            set tempInt = tempInt + 1
            set IndexPlayer[tempInt].pl = GetEnumPlayer()
        endmethod
        
        static method create takes boolexpr be returns thistype
            local thistype tbr = thistype.allocate()
            local force f = CreateForce()
            call ForceEnumPlayers(f, be)
            
            set tbr.first = tempInt+1
            set tbr.index = tempInt
            
            call ForForce(f, function thistype.initPlayerList)
            set tbr.last = tempInt
            call DestroyForce(f)
            set f = null
            return tbr
        endmethod
        
//===========================================================================
    endstruct
endlibrary

Here's the map:
 

Attachments

  • nimetön.png
    nimetön.png
    34.8 KB · Views: 246
Level 12
Joined
Feb 22, 2010
Messages
1,115
You shouldn't use handle variables as constant globals, make them nonconstant.

I will take a look again in a free time.
 

Deleted member 219079

D

Deleted member 219079

It seems like unchecking sharpcraft feature solves it, dunno why...
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
It seems like unchecking sharpcraft feature solves it, dunno why...

Maybe sharpcraft inlines constant globals so whenever compiler encounters a FORCE it puts CreateForce() there which causes problems.
 

Deleted member 219079

D

Deleted member 219079

Oh well, I better have it just turned off in that case..
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
The problem is not sharpcraft, this is the point of why constant variables exist in vjass.They get inlined by map optimizer.

You never use them with handle variables.
 
Status
Not open for further replies.
Top