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

<SOLVED!> Please help! "//" not printed to file, Preloader

Status
Not open for further replies.

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
Hi and thank you for reading my thread! I've been working on a new ORPG since 1.5 years back now called Bosses of Warcraft 2.0. I'm almost at the finish line and I'm trying to implement @TriggerHappy Codeless Save and Load (Multiplayer) - v2.0.0

I am hopeful that someone here can help me with the issue that I am having, I've been trying to get in touch with @TriggerHappy since the 19th, I've tried PM, the spell thread and discord but to no avail.

The issue that I am having:
When using the system to save ingame it produces a file to C:\Users\XXX\Documents\Warcraft III\CustomMapData\BoW. This file contains my save/load code. The problem is that when I use the system to save a lot of information the system wont write "//" at a specific spot in the file, causing the code inside the file to be unreadable by the system. I've tried to manually add this line into the file and it renders the file readable again.

This is an example of a file that can be read by the system:

function PreloadFiles takes nothing returns nothing

call Preload( "" )

call BlzSetAbilityTooltip('Amls', "Ranger (WorldEdit)
b-DBTRsdhI>h^iup!BLIu:HcvUYcO`*X3Y5de(]!nw`}n1'}4{-?x7edn-&TI:KHsO[>Nt5eK_EG!:.@JMK'bbw'N4+=LHt7d-}8j?cS|}!--LwKu.R_b(XhNxO:+hTHZ`Z#bKh:;!2", 1)
endfunction
function a takes nothing returns nothing
//" )
call PreloadEnd( 0.0 )

endfunction

This is an example of a file that cannot be read by the system:


function PreloadFiles takes nothing returns nothing

call Preload( "" )

call BlzSetAbilityTooltip('Amls', "Ranger (WorldEdit)
b-DBTRsdhI>h^iup!BLIu:HcvUYcO`*X3Y5de(]!nw`}n1'}4{-?x7edn-&TI:KHsO[>Nt5eK_EG!:.@JMK'bbw'N4+=LHt7d-}8j?cS|}!--LwKu.R_b(XhNxO:+hTHZ`Z#bKh:;!2", 1)
endfunction
function a takes nothing returns nothing
" )
call PreloadEnd( 0.0 )

endfunction



Code:
call Preload("\" ) \n\n\tcall BlzSetAbilityTooltip('Amls', \"" + contents + "\", 1)\nendfunction\nfunction a takes nothing returns nothing\n //")

This is the line responsible for adding the "//"

If anyone would be as kind to help me figure this problem out I would be immensely greatful. I can send the map if anyone wants to have look at it!

TLDR: When trying to save a lot of information using Codeless Save and Load (Multiplayer) - v2.0.0 the system doesn't print "//" to the save/load file, rendering it unreadable.



Code:
library FileIO
/***************************************************************
*
*   v1.0.4, by TriggerHappy
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*
*   Provides functionality to read and write files.
*   _________________________________________________________________________
*   1. Requirements
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*       - Patch 1.29 or higher.
*       - JassHelper (vJASS)
*   _________________________________________________________________________
*   2. Installation
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*   Copy the script to your map and save it.
*   _________________________________________________________________________
*   3. API
*   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*       struct File extends array
*
*           readonly static boolean ReadEnabled
*           readonly static integer Counter
*           readonly static integer array List
*
*           static method open takes string filename returns File
*           static method create takes string filename returns File
*
*           ---------
*
*           method write takes string contents returns File
*           method read takes nothing returns string
*           method append takes string contents returns string
*
*           method readEx takes boolean close returns string
*           method readAndClose takes nothing returns string
*           method readBuffer takes nothing returns string
*           method writeBuffer takes string contents returns nothing
*           method appendBuffer takes string contents returns nothing
*
*           method close takes nothing returns nothing
*
*           public function Write takes string filename, string contents returns nothing
*           public function Read takes string filename returns string
*           public function Append takes string filename, string contents returns nothing
*
***************************************************************/
    private keyword FileInit

    struct File extends array

        readonly static integer Counter = 0
        readonly static integer array List
     
        readonly static boolean ReadEnabled // async before patch 1.30

        readonly string filename
        private string buffer
     
        static method open takes string filename returns thistype
            local thistype this = .List[0]
     
            if (this == 0) then
                set this = Counter + 1
                set Counter = this
            else
                set .List[0] = .List[this]
            endif
           
            set this.filename = filename
            set this.buffer = null
         
            debug if (this >= JASS_MAX_ARRAY_SIZE) then
            debug   call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 120, "FileIO(" + filename + ") WARNING: Maximum instance limit " + I2S(JASS_MAX_ARRAY_SIZE) + " reached.")
            debug endif
         
            return this
        endmethod
     
        // This is used to detect invalid characters which aren't supported in preload files.
        static if (DEBUG_MODE) then
            private static method validateInput takes string contents returns string
                local integer i = 0
                local integer l = StringLength(contents)
                local string ch = ""
                loop
                    exitwhen i >= l
                    set ch = SubString(contents, i, i + 1)
                    if (ch == "\\") then
                        return ch
                    elseif (ch == "\"") then
                        return ch
                    endif
                    set i = i + 1
                endloop
                return null
            endmethod
        endif

        method write takes string contents returns thistype
            debug if (.validateInput(contents) != null) then
            debug   call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 120, "FileIO(" + filename + ") ERROR: Invalid character |cffffcc00" + .validateInput(contents) + "|r")
            debug   return this
            debug endif
         
            set this.buffer = null
         
            call PreloadGenClear()
            call PreloadGenStart()
            call Preload("\" ) \n\n\tcall BlzSetAbilityTooltip('Amls', \"" + contents + "\", 1)\nendfunction\nfunction a takes nothing returns nothing\n //")
            call PreloadGenEnd(this.filename)
     
            return this
        endmethod
     
        private method readPreload takes nothing returns string
            local string original = BlzGetAbilityTooltip('Amls', 1)
            local string output
     
            // Execute the preload file
            call Preloader(this.filename)
     
            // Read the output
            set output = BlzGetAbilityTooltip('Amls', 1)
            call BlzSetAbilityTooltip('Amls', original, 1)
         
            // Make sure the output is valid
            if (output == original) then
                return null
            endif
         
            return output
        endmethod
     
        method close takes nothing returns nothing
            if (this.buffer != null) then
                call .write(.readPreload() + this.buffer)
                set this.buffer = null
            endif
            set .List[this] = .List[0]
            set .List[0] = this
        endmethod
     
        method readEx takes boolean close returns string
            local string output = .readPreload()
            local string buf = this.buffer
     
            if (close) then
                call this.close()
            endif
         
            if (output == null) then
                return buf
            endif
         
            if (buf != null) then
                set output = output + buf
            endif
         
            return output
        endmethod
     
        method read takes nothing returns string
            return .readEx(false)
        endmethod
     
        method readAndClose takes nothing returns string
            return .readEx(true)
        endmethod
     
        method appendBuffer takes string contents returns thistype
            set .buffer = .buffer + contents
            return this
        endmethod

        method readBuffer takes nothing returns string
            return .buffer
        endmethod
     
        method writeBuffer takes string contents returns nothing
            set .buffer = contents
        endmethod

        method append takes string contents returns thistype
            return this.write(this.read() + contents)
        endmethod

        static method create takes string filename returns thistype
            return .open(filename).write("")
        endmethod

        implement FileInit
    endstruct

    private module FileInit
        private static method onInit takes nothing returns nothing
            set File.ReadEnabled = File.open("FileTester.pld").write(SCOPE_PREFIX).readEx(true) == SCOPE_PREFIX
        endmethod
    endmodule

    public function Write takes string filename, string contents returns nothing
        call File.open(filename).write(contents).close()
    endfunction

    public function Read takes string filename returns string
        return File.open(filename).readEx(true)
    endfunction

    public function Append takes string filename, string contents returns nothing
        call File.open(filename).write(contents).close()
    endfunction

endlibrary


Code:
Save GUI
    Events
        Player - Player 1 (Red) types a chat message containing -save as An exact match
        Player - Player 2 (Blue) types a chat message containing -save as An exact match
        Player - Player 3 (Teal) types a chat message containing -save as An exact match
        Player - Player 4 (Purple) types a chat message containing -save as An exact match
        Player - Player 5 (Yellow) types a chat message containing -save as An exact match
        Player - Player 6 (Orange) types a chat message containing -save as An exact match
        Player - Player 7 (Green) types a chat message containing -save as An exact match
        Player - Player 8 (Pink) types a chat message containing -save as An exact match
        Player - Player 9 (Gray) types a chat message containing -save as An exact match
        Player - Player 10 (Light Blue) types a chat message containing -save as An exact match
        Player - Player 11 (Dark Green) types a chat message containing -save as An exact match
        Player - Player 12 (Brown) types a chat message containing -save as An exact match
        Player - Player 13 (Maroon) types a chat message containing -save as An exact match
        Player - Player 14 (Navy) types a chat message containing -save as An exact match
        Player - Player 15 (Turquoise) types a chat message containing -save as An exact match
        Player - Player 16 (Violet) types a chat message containing -save as An exact match
        Player - Player 17 (Wheat) types a chat message containing -save as An exact match
        Player - Player 18 (Peach) types a chat message containing -save as An exact match
        Player - Player 19 (Mint) types a chat message containing -save as An exact match
        Player - Player 20 (Lavender) types a chat message containing -save as An exact match
        Player - Player 21 (Coal) types a chat message containing -save as An exact match
        Player - Player 22 (Snow) types a chat message containing -save as An exact match
        Player - Player 22 (Snow) types a chat message containing -save as An exact match
        Player - Player 23 (Emerald) types a chat message containing -save as An exact match
        Player - Player 24 (Peanut) types a chat message containing -save as An exact match
    Conditions
        SaveUseGUI Equal to True
        (SavePlayerHero[((Player number of (Triggering player)) - 1)] is A Hero) Equal to True
    Actions
        -------- ------------------- --------
        -------- NOTE: You must load values in the reverse order you saved them in. This is why we save the unit type last. --------
        -------- ------------------- --------
        Set SaveTempUnit = Unit_PlayerHero[((Player number of (Triggering player)) - 1)]
        Set SaveTempUnit = Unit_PlayerHero[(Player number of (Triggering player))]
        Set SaveCount = -1
        -------- ------------------- --------
        -------- Save Items Carried By Hero --------
        -------- ------------------- --------
        For each (Integer SaveTempInt) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (SaveTempInt + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_SaveTempInt)))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        -------- ------------------- --------
        -------- Save Items Carried By Bags --------
        -------- ------------------- --------
        -------- Blue --------
        Set SaveTempUnit = Unit_InventoryBlue[(Player number of (Triggering player))]
        Set SaveTempUnit = Unit_InventoryBlue[((Player number of (Triggering player)) - 1)]
        For each (Integer LoopIntegers[161]) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (LoopIntegers[161] + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_LoopIntegers[161])))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        -------- Green --------
        Set SaveTempUnit = Unit_InventoryGreen[(Player number of (Triggering player))]
        Set SaveTempUnit = Unit_InventoryGreen[((Player number of (Triggering player)) - 1)]
        For each (Integer LoopIntegers[162]) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (LoopIntegers[162] + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_LoopIntegers[162])))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        -------- Purple --------
        Set SaveTempUnit = Unit_InventoryPurple[(Player number of (Triggering player))]
        Set SaveTempUnit = Unit_InventoryPurple[((Player number of (Triggering player)) - 1)]
        For each (Integer LoopIntegers[163]) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (LoopIntegers[163] + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_LoopIntegers[163])))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        -------- Red --------
        Set SaveTempUnit = Unit_InventoryRed[(Player number of (Triggering player))]
        Set SaveTempUnit = Unit_InventoryRed[((Player number of (Triggering player)) - 1)]
        For each (Integer LoopIntegers[164]) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (LoopIntegers[164] + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_LoopIntegers[164])))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        -------- Teal --------
        Set SaveTempUnit = Unit_InventoryTeal[(Player number of (Triggering player))]
        Set SaveTempUnit = Unit_InventoryTeal[((Player number of (Triggering player)) - 1)]
        For each (Integer LoopIntegers[165]) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (LoopIntegers[165] + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_LoopIntegers[165])))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        -------- Yellow --------
        Set SaveTempUnit = Unit_InventoryYellow[(Player number of (Triggering player))]
        Set SaveTempUnit = Unit_InventoryYellow[((Player number of (Triggering player)) - 1)]
        For each (Integer LoopIntegers[166]) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (LoopIntegers[166] + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_LoopIntegers[166])))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        -------- Glyphs --------
        Set SaveTempUnit = Unit_GlyphBag[(Player number of (Triggering player))]
        Set SaveTempUnit = Unit_GlyphBag[((Player number of (Triggering player)) - 1)]
        For each (Integer LoopIntegers[167]) from 0 to 5, do (Actions)
            Loop - Actions
                Set SaveCount = (SaveCount + 1)
                Set SaveValue[SaveCount] = (Charges remaining in (Item carried by SaveTempUnit in slot (LoopIntegers[167] + 1)))
                Set SaveMaxValue[SaveCount] = SaveItemChargesMax
                Set SaveCount = (SaveCount + 1)
                Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertItemId(GetItemTypeId(UnitItemInSlot(udg_SaveTempUnit, udg_LoopIntegers[167])))
                Set SaveMaxValue[SaveCount] = SaveItemTypeMax
        Set SaveTempUnit = Unit_PlayerHero[(Player number of (Triggering player))]
        -------- ------------------- --------
        -------- Save Profession Levels --------
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_TailoringLevel[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_LeatherworkerLevel[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_HerbloreLevel[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_FishingLevel[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_EnchantingLevel[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_BlacksmithLevel[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_AlchemyLevel[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        -------- Save Questline1 --------
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_QuestLine1[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        -------- Save Title --------
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = Integer_Title[(Player number of (Owner of SaveTempUnit))]
        Set SaveMaxValue[SaveCount] = 999
        -------- ------------------- --------
        -------- Save Gold --------
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = ((Triggering player) Current gold)
        Set SaveMaxValue[SaveCount] = 99999
        -------- ------------------- --------
        -------- Save Lumber --------
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = ((Triggering player) Current lumber)
        Set SaveMaxValue[SaveCount] = 99999
        -------- ------------------- --------
        -------- Save Level --------
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Set SaveValue[SaveCount] = (Hero level of SaveTempUnit)
        Set SaveMaxValue[SaveCount] = 100
        -------- ------------------- --------
        -------- Save Unit Type --------
        -------- ------------------- --------
        Set SaveCount = (SaveCount + 1)
        Custom script:   set udg_SaveValue[udg_SaveCount] = SaveHelper.ConvertUnitId(GetUnitTypeId(udg_SaveTempUnit))
        Set SaveMaxValue[SaveCount] = SaveUnitTypeMax
        -------- ------------------- --------
        -------- Save to disk --------
        -------- ------------------- --------
        Custom script:   set udg_SaveTempInt = Savecode.create()
        For each (Integer LoopIntegers[160]) from 0 to SaveCount, do (Actions)
            Loop - Actions
                Custom script:   call Savecode(udg_SaveTempInt).Encode(udg_SaveValue[udg_LoopIntegers[160]], udg_SaveMaxValue[udg_LoopIntegers[160]])
        Set SaveTempString = <Empty String>
        Custom script:   set udg_SaveTempString = Savecode(udg_SaveTempInt).Save(GetTriggerPlayer(), 1)
        Custom script:   call SaveFile.create(GetTriggerPlayer(), SaveHelper.GetUnitTitle(udg_SaveTempUnit), -1, udg_SaveTempString)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                SaveShowCode Equal to True
            Then - Actions
                Custom script:   set udg_SaveCodeColored = Savecode_colorize(udg_SaveTempString)
                Set Temp_PlayerGroup = (Player group((Triggering player)))
                Game - Display to Temp_PlayerGroup the text: SaveCodeColored
                Custom script:   call DestroyForce(udg_Temp_PlayerGroup)
            Else - Actions

 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
@Illidan(Evil)X Dude! Now this is something new, it now correctly prints the code and it is readable by the dialog system, but I am not sure if it would be possible to load successfully using this code?
There are some differences between what a file with less code (a working save/load file) with the
Code:
call Preload("\" ) \n\n\tcall BlzSetAbilityTooltip('Amls', \"" + contents + "\", 1)\nendfunction\nfunction a takes nothing returns nothing\n //")
line looks like and a file with all the code that I want (a no-work save/load file) with the
Code:
call Preload("\")\ncall BlzSetAbilityTooltip('Amls',\"" + contents + "\",1)\nreturn//")
line looks like.


function PreloadFiles takes nothing returns nothing

call Preload( "" )

call BlzSetAbilityTooltip('Amls', "Ranger (WorldEdit)
O.xn03X5j,zm:mad:94dC>>84;Wr6SmB6g5XX5U$Hre2SBUIXV_aTx}", 1)
endfunction
function a takes nothing returns nothing
//" )
call PreloadEnd( 0.0 )

endfunction



function PreloadFiles takes nothing returns nothing

call Preload( "")
call BlzSetAbilityTooltip('Amls',"Ranger (WorldEdit)
b-DBTRsdhI>h^iup!BLIu:HcvUYcO`*X3Y5de(]!nw`}n1'}4{-?x7edn-&TI:KHsO[>Nt5eK_EG!:.@JMK'bbw'N4+=LHt7d-}8j?cS|}!--LwKu.R_b(XhNxO:+hTHZ`Z#bKh:;!2",1)
return//" )
call PreloadEnd( 0.0 )

endfunction



Do you think that the new file would be loadable or do I need to adjust something in the code for how the game loads data from the generated file for it to work?
 
Last edited:

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
@Illidan(Evil)X Alright, thanks! That makes sence :)
Now, I've just confirmed your theory about the Preload native (partly)

You see, it doesn't matter how long the save/load code is, I can save a code that is 2x bigger than what I will ever need to save, the whole code will exsist inside the file, but when I do save that much amount of code the native
Code:
call Preload
will somehow break after "contents" and not add anything beyond that.


function PreloadFiles takes nothing returns nothing

call Preload( "")
call BlzSetAbilityTooltip('Amls',"Ranger (WorldEdit)
b-DBTRsdhI>h^iup!BLIu:HcvUYcO`*X3Y5de(]!nw`}n1'}4{-?x7edn-&TI:KHsO[>Nt5eK_EG!:.@JMK'bbw'N4+=LHt7d-}8j?cS|}!--LwKu.R_b(XhNxO:+hTHZ`Z#bKh:;!2",1)
return//" )
call PreloadEnd( 0.0 )

endfunction



function PreloadFiles takes nothing returns nothing

call Preload( "")
call BlzSetAbilityTooltip('Amls',"Ranger (WorldEdit)
B:2`&sO6!q6CQARBV'Z@?b#juTi6Ri0m([-%f}>FER;%BipzpE`DEX){]L:HF9^TopnKF]sjO.YVAHiX(!KbtG*3@2FzXL,R%--v6#s4;xHh-+7O&DU8qN]&TK}ua2:`BgoboyG8.*:=)%2(xMw6N`@5%$5DX_Wu1fE@:EK]@J'[7G^hJa`Av2;{KV=UPOxEe`n{.F!WoV8" )
call PreloadEnd( 0.0 )

endfunction





Can you think of a way for me to work around this issue? Even if your suggestion to narrow down the native line will make me able to save as much as I want to save for today I don't want to be limited tomorrow if I ever feel to add more things that should be save/loadable if you get my point.

For you that are new to the thread, do you have any ideas/thoughts?
 
I did some testing. As theorized, the Preload native seem to have a hard limit of 259 characters (at least on patch 1.29.2).
JASS:
//! zinc
library PreloadTest {
    function onInit() {
        string chunk = "0123456789ABCDEF";
        string str = "";
        integer i = 0;
        while (i < 64) {
            str += chunk;
            i += 1;
        }
        BJDebugMsg(I2S(StringLength(str))); // 1024
      
        PreloadGenClear();
        PreloadGenStart();
        Preload(str);
        PreloadGenEnd("Tests\\PreloadTest.pld");
    }
}
//! endzinc
Generates->
JASS:
function PreloadFiles takes nothing returns nothing
    call Preload( "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012" ) // 259 chars
    call PreloadEnd( 0.0 )
endfunction
One workaround would be to split the string into multiple chunks using either multiple preload calls or multiple pld files and then merge the strings after loading.
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
@Illidan(Evil)X That's very interesting, thank you for having a look into this problem with me! You have helped me a lot! I've added +4 rep to you :)

This thread is now solved.

@Illidan(Evil)X Right now I am getting some wierd behaviour while trying to load. It just says "Synchronizing with other player..." and it never runs the load trigger. I've sent you a pastebin link with a map attatched to it to you, if you have time to have a look into it I would greatly appreciate it, it's the last piece of the puzzle :D
 
I haven't looked deeply into it, but I believe your setup for the save/load system is wrong.
SaveLoadMaxLength is currently set to a maximum of 64 characters, but your generated load codes is much longer.
Increasing this value might just solve your problem.

I isolated your save/load triggers to a new map (didn't feel like debugging a map with 11000 objects and a 1000 triggers and variables) and got a "invalid load code" error message.
Changing the maximum length to be larger than the load code seemingly made it work.

General tip: Make sure the JassHelper debug mode is enabled to catch any error messages thrown by the system.
 
Status
Not open for further replies.
Top