• 🏆 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!

Code Gen Doesn

Status
Not open for further replies.
Level 7
Joined
Apr 3, 2009
Messages
317
Sorry, the title isn't finished because hive is bugged atm and won't let me finish what I write!
Anyway, CodeGen doesn't work for me, why? Please help!
I've copied the CodeGen folder to my map and now there script errors! Stupid codegen what am I doing wrong? My map doesn't even work anymore because of this trash.. Does it even work? Is it real?

Can anyone help me PLEASE?


Heres my custom script:

Code:
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

//TESH.scrollpos=223
//TESH.alwaysfold=0
function CG_Init takes nothing returns nothing
    set udg_Compress = SubString(udg_Alphabet, StringLength(udg_Alphabet)-1, 999)
    set udg_Alphabet = SubString(udg_Alphabet, 0, StringLength(udg_Alphabet)-1)
endfunction

function CG_Encode takes integer i returns string
    local integer b
    local string s = ""
    if i < udg_Base then
        return SubString(udg_Alphabet, i, i + 1)
    endif
    loop
        exitwhen i <= 0
        set b = i - (i / udg_Base) * udg_Base
        set s = SubString(udg_Alphabet, b, b + 1) + s
        set i = i / udg_Base
    endloop
    return s
endfunction

function CG_SaveChar takes string c returns integer
    local string low  = "abcdefghijklmnopqrstuvwxyz"
    local string high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    local string int  = "0123456789"
    local integer i   = S2I(c)
    if i > 0 then
        return i
    endif
    if c == "0" then
        return 0
    endif
    set i = 0
    loop
        exitwhen i > 26
        if SubString(low, i, i + 1) == c then
            return i
        elseif SubString(high, i, i + 1) == c then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

function CG_SaveString takes string name returns string
    local integer i   = 0
    local integer a   = StringLength(name)
    local integer c   = 0
    loop
        exitwhen i > a
        set c = c + CG_SaveChar(SubString(name, i, i + 1))
        set i = i + 1
    endloop
    return CG_Encode(c)
endfunction

function CG_StrPos takes string s returns integer
    local integer i = 0
    loop
        exitwhen i > udg_Base
        if s == SubString(udg_Alphabet, i, i + 1) then
            return i
        endif
        set i = i + 1
    endloop
    return -1
endfunction

function CG_Decode takes string s returns integer
    local integer a = 0
    loop
        exitwhen StringLength(s) == 1
        set a = a * udg_Base + udg_Base * CG_StrPos(SubString(s, 0, 1))
        set s = SubString(s, 1, 50)
    endloop
    return a+CG_StrPos(s)
endfunction

function CG_SaveBoolean takes boolean flag returns integer
    if flag then
        return 1
    endif
    return 0
endfunction

function CG_SaveHero takes unit it returns integer
    local integer i = 1
    loop
        exitwhen i > udg_HeroCount
        if udg_SaveHero[i] == GetUnitTypeId(it) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

function CG_SaveItem takes item it returns integer
    local integer i = 1
    loop
        exitwhen i > udg_ItemCount
        if udg_SaveItem[i] == GetItemTypeId(it) then
            return i
        endif
        set i = i + 1
    endloop
    return 0
endfunction

function CG_Seperate takes string s returns string
    local integer i = 0
    local integer b = StringLength(s)
    local integer a = 0
    loop
        exitwhen i > b
        if a == 4 then
            set s = SubString(s, 0, i) + "-" + SubString(s, i, 999)
            set a = 0
        else
            set a = a + 1
        endif
        set i = i + 1
    endloop
    return s
endfunction

function CG_Unseperate takes string s returns string
    local integer i = 0
    loop
        exitwhen i > StringLength(s)
        if SubString(s, i, i + 1) == "-" then
            set s = SubString(s, 0, i) + SubString(s, i+1, 999)
        endif
        set i = i + 1
    endloop
    return s
endfunction

function CG_IsLower takes string s returns boolean
    return s == "a" or s == "b" or s == "c" or s == "d" or s == "e" or s == "f" or s == "g" or s == "h" or s == "i" or s == "j" or s == "k" or s == "l" or s == "m" or s == "n" or s == "o" or s == "p" or s == "q" or s == "r" or s == "s" or s == "t" or s == "u" or s == "v" or s == "w" or s == "x" or s == "y" or s == "z"
endfunction

function CG_IsUpper takes string s returns boolean
    return s == "W" or s == "A" or s == "B" or s == "C" or s == "D" or s == "E" or s == "F" or s == "G" or s == "H" or s == "I" or s == "J" or s == "K" or s == "L" or s == "M" or s == "N" or s == "O" or s == "P" or s == "Q" or s == "R" or s == "S" or s == "T" or s == "U" or s == "V" or s == "X" or s == "Y" or s == "Z"
endfunction

function CG_ColorChar takes string char returns string
    local integer i = 0
    local string s = udg_Alphabet + udg_Compress
    loop
        exitwhen i > udg_Base+1
        if char == SubString(s, i, i + 1) then
            if CG_IsLower(SubString(s, i, i + 1)) then
                return udg_LOWER_CASE_COLOR + char + "|r"
            elseif CG_IsUpper(SubString(s, i, i + 1)) then
                return udg_UPPER_CASE_COLOR + char + "|r"
            elseif SubString(s, i, i + 1) != "-" then
                return udg_OTHER_CHARS_COLOR + char + "|r"
            endif
        endif
        set i = i + 1
    endloop
    return char
endfunction

function CG_Color takes string s returns string
    local integer i = 0
    local string r = ""
    loop
        exitwhen i > StringLength(s)
        set r = r + CG_ColorChar(SubString(s, i, i + 1))
        set i = i + 1
    endloop
    return r
endfunction

function CG_ClearData takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i > 50
        set udg_Save[i] = 0
        set i = i + 1
    endloop
endfunction

function CG_SaveOnline takes nothing returns integer
    if not ReloadGameCachesFromDisk() then
        return 1
    endif
    return 0
endfunction

function CG_Execute takes nothing returns nothing
    local integer i   = 1
    local integer t   = 0
    local string val  = ""
    
    set udg_Code = ""
    
    loop
        exitwhen i > udg_SaveCount
        set val = CG_Encode(udg_Save[i])
        set t   = StringLength(val)
        if t > 1 then
            set udg_Code = udg_Code+udg_Compress+I2S(t)+val
        else
            set udg_Code = udg_Code+val
        endif
        set i = i + 1
    endloop
    
    if udg_SavePlayerName then
        set udg_Code = udg_Code+CG_SaveString(GetPlayerName(GetTriggerPlayer()))
    endif
    
    set udg_Code = CG_SaveString(udg_Code)+udg_Code
    set udg_Code = CG_Seperate(udg_Code)
    set udg_Code = CG_Color(udg_Code)
endfunction

function CG_Load takes string str returns nothing
    local integer i   = 0
    local integer b   = StringLength(CG_Unseperate(str))
    local integer key = 1
    local integer c   = 1
    local string tmp  = ""
    
    set str = CG_Unseperate(str)
    set udg_LOAD_VALID = true
    
    set tmp = CG_SaveString(SubString(str, 2, b))
    if SubString(str, 0, StringLength(tmp)) != tmp then
        set udg_LOAD_VALID = false
        return
    endif
    set str = SubString(str, StringLength(tmp), 999)
    set b = StringLength(str)
    if udg_SavePlayerName then
        set tmp = CG_SaveString(GetPlayerName(GetTriggerPlayer()))
        if StringLength(tmp) > b then
            set udg_LOAD_VALID = false
            return
        else
            if SubString(str, b-StringLength(tmp), b) != tmp then
                set udg_LOAD_VALID = false
                return
            endif
        endif
        set b = b-1
        set str = SubString(str, 0, b)
    endif
    set b = StringLength(str)
    loop
        exitwhen i >= b
        if SubString(str, i, i + 1) == udg_Compress then
            set key = S2I(SubString(str, i + 1, i + 2))
            set i = i + (key)
        endif
        set udg_Load[c] = CG_Decode(SubString(str, i, i + key))
        set c = c + 1
        set i = i + key
        set key = 1
    endloop
    
    //call CG_ClearData()
endfunction

Heres an SS of the error:
29pr8k9.jpg
 
Level 7
Joined
Apr 3, 2009
Messages
317
Use Jass New Gen Pack (JNGP) it should fix all these things...

Is there anything else besides that, I have AVG Internet Security 8.5 which I paid for ($69.95), and I don't want to change it just yet..

AVG Detects JNGP as a threat and even though I tell it to ignore the file, AVG will delete JNGP without my permission!

Is there any other way I can get CodeGen to work without JNGP?
 
Status
Not open for further replies.
Top