SC2Mapster Forums

Development > Triggers

Loading bank sometimes fails

  • 16 posts
    #1 Nov 07, 2012 at 22:02 UTC - 0 likes

    Players who are playing my map are often loosing their banks. Problem appear to be not my fault, but... I'm using starcode, to encrypt banks. People report that they loose exp and it sometimes return in next game. When I start game with my bank broken (bank not loaded properly) and then try to load it in another game (or in editor) sometimes it work properly, sometimes not. I think data may be lost because of saiving current progress (but we have no progress, because bank was not loaded). I'm loading data at start of game and saving at end. No triggers errors. Players are getting message like "Your bank file is corrupted", so Validate String fail (maybe, because nothing was loaded from bank).

    Someone have similar problems? My banks have 317 bytes. Here's code, IDK if something is wrong with it - works 90% time:

    // Bank preload trigger w/o events, never called
            Bank - Preload and synchronize bank "TheThingBank" for player 1
    	(...)
            Bank - Preload and synchronize bank "TheThingBank" for player 14
    
    // Banks init tigger, called in map init trigger
            Player Group - Pick each player in (Active Players) and do (Actions)
                Actions
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            (Controller of player (Picked player)) == User
                        Then
                            Bank - Open bank "MyBank" for player (Picked player)
                            Variable - Set Banks[(Picked player)] = (Last opened bank)
                            Banks Load((Picked player))
                        Else
    
    
    // Banks Load acton definition
            Variable - Set TempString = (Load key "key" of section "scetion" from bank Banks[Player] as a String)
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    And
                        Conditions
                            TempString != ""
                            (<Starcode> Validate String(TempString, 4)) == True // this is failing
                Then
                    Variable - Set TempString = (<Starcode> Remove Hash from String(TempString, 4))
                    Variable - Set TempString = (<Starcode> Decrypt String(TempString, Banks Encryptionkey))
                    Variable - Set TempString = (<Starcode> Decompress String(TempString))
                    <Starcode> Set Code(TempString)
                    Variable - Set SomeVar = (<Starcode> Get Integer Value(500))
                    UI - Display ("Your archive version: " + (Text(ArchiveVer))) for (Player group(Player)) to Debug area
                Else
                    UI - Display "Your bank file is corrupted, new filecreated instead" for (Player group(Player)) to Subtitle area // and pple are getting this message
    
    #2 Nov 08, 2012 at 05:39 UTC - 0 likes

    Just pointing out the first thing that jumps to my mind-

    // Banks init tigger, called in map init trigger
            Player Group - Pick each player in (Active Players) and do (Actions)
                Actions
                    General - If (Conditions) then do (Actions) else do (Actions)
                        If
                            (Controller of player (Picked player)) == User
                        Then
                            Bank - Open bank "MyBank" for player (Picked player)
                            Variable - Set Banks[(Picked player)] = (Last opened bank)
                            Banks Load((Picked player))
                        Else
    

    Unless I'm mistaken, you cannot use anything but implicit values for "Open Bank". Try opening each bank and assigning to to a variable separately, instead of through a loop. I'm not 100% sure if this is correct (or if I'm getting this mixed up), so check the action description to be sure.

    That could be an issue, though I doubt it's related to what you're describing. The issue could be related to how you save your banks- are you doing everything in the right order (reverse of how you load it)?

    Send me a PM with any questions or comments.

    Learn about HotS mods, publishing, and regions here

    #3 Nov 08, 2012 at 06:10 UTC - 0 likes

    @zeldarules28: Go

    zelda speaks truth.... you need to use a hard coded player integer value for the "bank - open bank" statement

    Inside the loop you can use a switch statement per player

    and put the hard coded statement in there for each player that could possibly be playing.

    Last edited Nov 08, 2012 by SouLCarveRR

    Skype
    KageNinpo = SN

    My Libraries
    DialogLeaderboard & TeamSort

    My Projects
    SPACEWAR Tribute
    Infinite TD

    #4 Nov 08, 2012 at 06:53 UTC - 0 likes

    @SouLCarveRR: Go yeah, thats how you do it.
    Just like you used Preload.

    Homepage: www.sc2goa.com

    #5 Nov 08, 2012 at 08:12 UTC - 0 likes

    Sadly there is alot of wrong information in this thread.

    "Open bank" works well with variables, loops and so forth. The only action that needs literal values is "Preload bank", thats because its actually not a real function in script, instead it just adds a line to a file in the maps .mpq that tells the game which banks to preload before the source code gets loaded.

    About your problem:

    I cant tell 100% whats causing it, but you pretty much nailed it down by yourself already, didnt you? Since sometimes the bank validation fails it could either be a problem of Starcode (for example if your bank file contains characters that are not part of the encryption alphabet) or it could be an engine overload. This can happen if to much bank data is loaded at the same time, resulting in some banks not getting loaded properly. Note that an empty bank key will return "false" for starcode validation.

    If you encounter a bank validation failure in game 1 while the bank works in game 2, this would point towards an engine overload or maybe a trigger execution limit (Note: Starcode is very slow depending on the size of keys etc). Try to insert small waits within the "Load Banks" function after each player and see if it fixes the issue.

    Additionally try to place more debug messages everywhere in your script. Did the trigger get run for player X? What exactly is the value of the bank key? etc etc Also make sure that the trigger debug window is open in your tests (Also in multiplayer!) to track eventual script errors.

    Finding issues of this sort can take some time and you need to make small steps in order to succeed.

    Last edited Nov 08, 2012 by Mille25

    http://i55.tinypic.com/wio5t0.jpg

    Starcraft Universe lead programmer

    #6 Nov 08, 2012 at 17:14 UTC - 0 likes
    Quote from SouLCarveRR: Go

    zelda speaks truth.... you need to use a hard coded player integer value for the "bank - open bank" statement

    Don't think so. If it was issue it wouldn't work in 100% cases, not in 1%, right?

    Mille25: My banks have 300-500 bytes. I don't think that it could cause problems. Script is executed for 100%, because each player see error message (not trigger execution limit or trigger error then). I'll check what's loaded, that's good idea. Invalid characters aren't issue too, because whole string is created by starcode. Also bank one time is loaded and second time it is not, so it can't be saving problem.

    Opening debug window in multiplayer is bad idea, because players could cheat in game, also it never happened to me. This problem is bothering me for couple months, (I'm even not playing this map really often), just players cry about loosing their progress.

    #7 Nov 08, 2012 at 18:41 UTC - 0 likes

    Just wanted to chime in ShadowDancer... I had tons of these issues with banks with my map Death Haven. When it was popular, I was restoring bank files for pages of people every day lol... and Death Haven saves kills to bank fairly often.

    I put in a safety where I had another bank that would save every 5s and if the main bank came back blank, I would then pull from the 5s one.

    I think the issue is if the file is being written and someone disconnects, it wipes it. I believe it's a Blizz issue :/

    Last edited Nov 08, 2012 by OneTwoSC

    SC2 video tutorials: http://www.youtube.com/onetwosc
    p.s. I've quit mapping since Nov 2011.

    #8 Nov 08, 2012 at 19:13 UTC - 0 likes

    Ach, nearly forgot. I'm opening banks once at game start, and saving them when i write something. Is it correct?

    #9 Nov 08, 2012 at 23:35 UTC - 0 likes

    @ShadowDancer93: Go

    That sounds right to me if my memory is correct.

    #10 Nov 09, 2012 at 00:00 UTC - 0 likes

    never had that problem in my map but also i only save map when someone leaves games and in game end no need to be allways saving i think just load on start and save everything at exit

    My little baby map: Snipers Promod

    #11 Nov 09, 2012 at 20:13 UTC - 0 likes

    Try to completly remove Starcode from your save system and see if it fixes the issue.

    #12 Nov 09, 2012 at 20:50 UTC - 0 likes

    @Mille25: Go

    I dunno about you guys, but i stopped using the preload and synchronize statements. I also hardcode the values of each open statement. I find it works much better this way.

    #13 Nov 09, 2012 at 21:17 UTC - 0 likes

    I'm saving more entries than most people, I'm saving much more often than most people. I'm not aware of any problems appearing with my banks. =/
    Maybe some char combinations that starcode adds that the banks accidentally not like?

    http://img42.imageshack.us/img42/7586/signaturemj.jpg

    #14 Nov 09, 2012 at 22:10 UTC - 0 likes
    Quote from Mille25: Go

    Try to completly remove Starcode from your save system and see if it fixes the issue.

    But bank is sometimes loaded, sometimes not. Exacly the same bank file.

    #15 Nov 10, 2012 at 00:06 UTC - 0 likes

    Well, ive understood that.

    You can either accept it as some sort of mysterious, random bug, or you can start to remove/change components of your save system in order to track down the potential mistake. If you dont really accept any tips, why do you even ask for them?

    The "sometimes loaded, sometimes not" thing is not a proof that its not Starcode. Your source code also doesnt change at all and it still happens. Therefore it could either really be a Blizzard bug, or an issue in your code that isnt that obvious.

    From my personal experience I can tell that banks sometimes behave a little bit weird, as an example i had pretty much the same issue as you describe here (banks randomly not loaded) and managed to fix it with a 0 second wait in the load-player-loop. My banks were alot bigger though. However, there were 0 logical mistakes in my source code that could explain the problem, meaning that it was some sort of internal engine problem (not able to load so much bank data at once, whatever)

    Last edited Nov 10, 2012 by Mille25
    #16 Nov 10, 2012 at 12:18 UTC - 0 likes

    Looks like adding small waits fixed problem (at least nothing bad happened until now). In addition I created second backup bank, saved after "normal", and loaded when normal fail (but I don't know if it was necessary). When I gather more data I'll post it.

  • 16 posts

You must login to post a comment. Don't have an account? Register to get one!