• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Saving/calling very, very long string

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
I want to know if anybody has any clues on how I could save and call massive strings. With massive strings, you should think about lengths of thousands of characters. If there's a way to save such a string as save game name or (which I highly doubt) a text file in your Wc3 folder, and be able to check that string again in another gaming session? I got a strange feeling that there's probably some way to do this, but it's an annoying and time-taking way. If anybody has any idea's, please share them. If you don't know how to do this, but you do know a way to save it and allowing the player to copy it, I could divide the string into parts and let the player copy the strings separately. In this last case, I do would like to know the maximum amount of characters usable in an in-game chat message.

Many thanks in advance and if someone manages to figure out a solution, I'll gladly shower them with rep and credits :thumbs_up:
 
I want to save the players progress in my Final Fantasy IX game. I will probably release the game in different versions, since 1 complete version would be nearly impossible. The idea is to save everything of the player's progress. Since the game contains more then 300 items that all need their stacked amounts checked (up to 99 items, which means 2 characters/item), I need at least 600 characters for just the items. I also need to save the items equipped, the choices made in the game, scores at mini-games, current map played, affected terrain due to player actions (doors opened or closed or treasure chests opened), etc. This brings a huge code along, and I'd really be happy if I could get that code so players can continue their journey in a new version instead of having to start over if they want to play with the new updates in every newer version.
 
You have no idea whhat your getting into, imo :P.

As far as I am aware, there is no way to make this text file and load from it. I dont think WC3 can use anything outside of its MPQ for the map.

Im sure there are ways you could encrypt everything though, to make the coe very short. Im unaware how you would manage it, but yeah...good luck with it. IMO: you could just make your code (if your character only has 6 inventory spaces) get the id of the item, and its chargs, and do that for every item. You could easily abuse this, but maybe find a way to encrypt.. levels, skills etc, I think would be very difficult to do though.

Good luck, again.
 
You have no idea whhat your getting into, imo :P.

As far as I am aware, there is no way to make this text file and load from it. I dont think WC3 can use anything outside of its MPQ for the map.

Im sure there are ways you could encrypt everything though, to make the coe very short. Im unaware how you would manage it, but yeah...good luck with it. IMO: you could just make your code (if your character only has 6 inventory spaces) get the id of the item, and its chargs, and do that for every item. You could easily abuse this, but maybe find a way to encrypt.. levels, skills etc, I think would be very difficult to do though.

Good luck, again.

My game is like no other game I've ever seen. Everything is only statistics. Items are just info divided into variables like ItemCount, ItemName and ItemIcon. They're all categorised into a 4 digit array. So for the items, all I have to do is put their amounts in a certain order to be able to load them.
E.g.: 03821749 would mean that the first item would have 03 'charges' (aka amount), the 2nd item has 82, the 3rd item has 17 and there are 49 of the 4th item.
As I said above: I got over 300 items which can all have up to 99 'charges', so I already need at least 600 characters in the string reserved for the items.


Why not use gamecache?

I don't know if GameCache's support all this. It's been a while since I used it, so I don't remember if it's able to work between 2 different campaigns (since it's used to switch to a newly downloaded version of the campaign). If you know if that's possible, I'd appreciate it very much.


Use string array :P

That's what I got to use if GameCache's work. If they don't, I have to use something else, so if you got any idea's in that case...
I also need to know the maximum string length in a string variable.

EDIT: I just tested it, and the maximum string length is 300 characters.
 
You should have said that it is for a single player map.
But you have to save the game-cache in the old map and load it in the new.
Meaning you have to make changes in the old map...
 
255(6) is the max string length that can be displayed.
But strings can be really long and in this case they need not be displayed.
I suggest keeping the length under a thousand - functions like StringLength(string s) start to take a lot of time.
No idea if there is a length limit for stored(in GC) strings.
 
You should have said that it is for a single player map.
But you have to save the game-cache in the old map and load it in the new.
Meaning you have to make changes in the old map...

It's not just between maps in the same campaign. It's between 2 different campaigns. That's what I was wondering.


Its 255 max, i think. But can't you use String 1+ string 2+ string 3. That gives you almost 900 characters.

I tested the string length and in total it's exactly 300. So I need to make arrayed string variables and save them. I know how to save and load strings via GameCache's, so that won't be a problem.
 
Ok did some more testing:
In game resolution 1024x768 the maximum string length to be displayed is infinite, but to be correctly viewed - 360(+(~2)). Any more and the characters go under the UI.
But still strings can be really long. Tested a bit and the length went over 3000(or something close). But as I said, String length takes a couple of seconds(of game freeze) to return a value.
Strings are limited to 1024 by the WE - if you have a constant string ( i.e. "asdjajfhadjf" ) with 1024(1025) characters we crashes(or used to). Editing the map via (MPQ editor) text editor allowed you to make a string with 1025 chars resulting in a crash on opening ( a way of protection).
 
But in the WE, I was only able to enter a string of 300 characters. I need a lot of substrings for everything I'm saving. You can imagine that I'm not looking forward to letting the player copy 20 load codes that are too long to simply write down on a little paper.

So the only question still open is: Can GameCache's be loaded between different campaigns? The GameCache is saved to a .w3v file, but where is that saved? If it's saved in the Warcraft III folder and can be opened by any map, it would be possible.
 
But in the WE, I was only able to enter a string of 300 characters. I need a lot of substrings for everything I'm saving. You can imagine that I'm not looking forward to letting the player copy 20 load codes that are too long to simply write down on a little paper.

So the only question still open is: Can GameCache's be loaded between different campaigns? The GameCache is saved to a .w3v file, but where is that saved? If it's saved in the Warcraft III folder and can be opened by any map, it would be possible.

Oh...
Gui is sure limiting.
I entered them in jass and not manually. I did a loop.

Anyways I think game-cache will work.
 
But in the WE, I was only able to enter a string of 300 characters. I need a lot of substrings for everything I'm saving. You can imagine that I'm not looking forward to letting the player copy 20 load codes that are too long to simply write down on a little paper.

So the only question still open is: Can GameCache's be loaded between different campaigns? The GameCache is saved to a .w3v file, but where is that saved? If it's saved in the Warcraft III folder and can be opened by any map, it would be possible.

Yes. gamecache is stored in your folder,and yes, it can be opened by any map. Gamecache will work. And remember there are 255 slots for strings of 2^x(where x is between 8 and 13, I think). So yes, gamecache is your answer. There is no other way to save data on your computer using GUI (or Jass, for that matter).
 
Yes, for items I can just keep the ItemCount stored directly on the GameCache. However for other non-standard Blizzard supported info (like game progress), I'll have to store that in a string array.

Thank you everyone for your great help with my question! +rep and credits to those who've been most helpful! :smile:
 
Yes, for items I can just keep the ItemCount stored directly on the GameCache. However for other non-standard Blizzard supported info (like game progress), I'll have to store that in a string array.

Thank you everyone for your great help with my question! +rep and credits to those who've been most helpful! :smile:

May I ask what could possibly require string representation?
As anything other than that is either boolean or numerical(quest is done or not, level of ability and etc).
 
Map number currently playing in, field number current present in, Save point number of last saved game, stuff like that. I'm not going to say 'If MapNumber[1] is True, then ..., else If MapNumber{2] is True, then ..., else, etc.' That's why a string is needed.
 
Map number currently playing in, field number current present in, Save point number of last saved game, stuff like that. I'm not going to say 'If MapNumber[1] is True, then ..., else If MapNumber{2] is True, then ..., else, etc.' That's why a string is needed.

...
You said it yourself:
"Map number" ... "field number"

Am I missing something?
 
And ... ?
Yes, you would have to get 50 variables, but now you have to get 50 substrings and then convert them back to whatever you need in the exact order you put them there(I mean you have to get all the substring limits for all the variables you need).
Isn't it just simpler to save all numbers as numbers(mind that this way you do not care about the order you put or retrieve them at all).
 
Well, they're not directly put to variables when saving the game, so if I want to use the integer way, I need to set them to an integer variable first. With the substrings I don't need to. I can just load the info I put directly into the string.
 
Well, they're not directly put to variables when saving the game, so if I want to use the integer way, I need to set them to an integer variable first. With the substrings I don't need to. I can just load the info I put directly into the string.

No!?? You just store the value you want, no need to put them in variables.

And again, with a string you will have to keep track of the length(digits) and position(where in the string it is) of each and every variable.
 
No!?? You just store the value you want, no need to put them in variables.

And again, with a string you will have to keep track of the length(digits) and position(where in the string it is) of each and every variable.
You won't need to keep track of where each item is in the string - just code it so that each item goes in the string at the same place each time... anyway, since he has 300 items (more than the 255 values a gamecache will fit in) it's best to use a string so he can fir more data into the gamecache without having to go into different caches.
 
You won't need to keep track of where each item is in the string - just code it so that each item goes in the string at the same place each time... anyway, since he has 300 items (more than the 255 values a gamecache will fit in) it's best to use a string so he can fir more data into the gamecache without having to go into different caches.

Lol.

Where the **** did this 255 variable limit per GC come from!??
So all systems relying on game cache are ******* ... no wait, there is no such limit.

The limits of GC:
You can have a maximum of 255 different GC on the hard at the same time.
Other than that it is limited by space on hard drive, maybe operational memory. But unless you are really determined you will never reach it.

It is just easier to do so:
Save ( Level of some_ability for Hero) as "Level of some_ability" in "levels" category in Your_GC
and then
set a = Load "Level of some_ability" of category "levels" from Your_GC
(Which is copy/paste-able, in GUI and even easier in Jass)

Because you do not care at all for where you have stored (in the string) your value.
As for strings, you will have to check each and every value for length(if it can vary). If it is 1 add a 0 before it, if it is 2, do nothing(though this is easier in Jass with a function). And then you have to keep track of 300 values like this:
The level of my first ability is stored between(at) 79 and 81.
The level of mu second ability is stored between(at) 553 and 555.
Players gold is stored between(at) 447 and 454.
Do you intend to do so for 300 values?

I just give up. Tried explaining to you why it is simpler and easier and a **** load of less work. But if you insist on doing it the hard way, be my guest.
 
No, afaik, it's not a maximum of 255 gamecaches on the hard drive at one time, its a maximum of about 100, and the limit for values stored inside gamecache is 255. That wouldn't make all systems relying on gamecache useless, because most of them will never reach that limit anyways.

Dude, please.

No system uses more that a 255 stored values???
Can you hook me to your dealer!!?
The simplest example Local Handle Variables - I can say I used to store(attach) 300 different variables to a single timer and that is just for one timer(next spell cast means new timer) (though I haven't actually done that).

Anyways how do you come up with this stuff, you imagine it?

Before my last post I made a really simple test. Stored over 300 variables in a GC, quit warcraft 3, opened again and checked the integrity of the stored data. Guess what it was perfect.
 
No need to get mad at eachother on a thread of which the solution has already been given. I know the possibilities now and know how I'm going to make this system work, so there's no need to argue and definitely no need to turn that argue into a fight.



-Problem solved and thread can be closed-
 
As I said above: I got over 300 items which can all have up to 99 'charges', so I already need at least 600 characters in the string reserved for the items.

that's interesting...this is off topic, but i sent you a list of all items and it was 254 items for the field. did you add the key items to that number?

if that's true then i'm pretty sure you can only have 1 of each key item.

although i think there are a few key items that have identical names to eachother...if i remember right.
Actually, I calculated it and there will be 2 types of items stored. 1 type is exactly 254 items xD
I can make another GameCache with the other info and load both in the new version.

...yeah so is the other type the key items? i assume so man i didn't realize how many of them there are. i guess you already figured out you don't need to stack those right?
 
Just wondering here:

Is it possible to handle strings in Wc3 the way you do in C++?
IE: Take your 300 character string, read first 2 chars, convert those chars, reduce the string length by 2, taking off the first two characters ("Right$(string, len(string) - 2)" in basic)...
I think that Wc3 should be able to do it. It's a very fast method of parsing a string. You just need to know where to put your stuff. EG: chars 1-2 for item 1 stack count, chars 3-4 for item 2 stack, etc.

But, this is an off-topic question. I'm just curious, as you peoples have been talking about strings and such.

On topic: The GC way of doing it would be far superior. Just do a loop, 1-300 storing the stack-count of each item class. There is no need to stuff around with strings.

@spiwn: Even though you did flame a little bit, you were still correct in your answers. I can see what you meant. Yes, the other people's ways(strings) would work, but as you put it:
I Tried explaining to you why it is simpler and easier and a **** load of less work. But if you insist on doing it the hard way, be my guest.
It would be significantly more work, to do it their way. That and your way is more efficient (faster, cleaner & less wasted CPU).

All-in-all, this topic was interesting to read... :xxd:
 
Just wondering here:

Is it possible to handle strings in Wc3 the way you do in C++?
IE: Take your 300 character string, read first 2 chars, convert those chars, reduce the string length by 2, taking off the first two characters ("Right$(string, len(string) - 2)" in basic)...
I think that Wc3 should be able to do it. It's a very fast method of parsing a string. You just need to know where to put your stuff. EG: chars 1-2 for item 1 stack count, chars 3-4 for item 2 stack, etc.
No, it wouldn't be possible unless you did something like:
JASS:
...
local string myString="0102030405060708091011121314151617181920212223242526272829"
local integer i=0
local integer array extracted
loop
    exitwhen StringLength(myString)<2
    
    set extracted[i]=SubString(myString, 0, 2)
    set myString=SubString(myString, 2, StringLength(myString))

    set i=i+1
endloop
...
Now as you can probably see, that way would be very inefficient.
 
Bugger. That's a disappointment. :sad:
They should have, at least, kept the ability to do it. Blizzard need to be led out into the desert, and shot.
As stated above, it's a very fast method of string manipulation. They want to keep strings in there, but not allow you to maniplate them quickly... what good is that :confused:
 
Strings in Jass aren't strings in C or any other language.
But still, you can increase performance of the above by doing so:
JASS:
local string myString="0102030405060708091011121314151617181920212223242526272829"
local integer i=0
local integer j=0
local integer array extracted
local integer length=StringLength(myString)
loop
    exitwhen length<j
    set extracted[i]=SubString(myString, j, j+2)
    set j=j+2
    set i=i+1
endloop
 
if that's true then i'm pretty sure you can only have 1 of each key item.

although i think there are a few key items that have identical names to eachother...if i remember right.

Game Cache is a simple hash table, which means you give every object in it a name and a value, so no, you can't have the same names.

When you try to retrieve an object, it just searches its name and returns the value stored for that name.
 
that's interesting...this is off topic, but i sent you a list of all items and it was 254 items for the field. did you add the key items to that number?

if that's true then i'm pretty sure you can only have 1 of each key item.

although i think there are a few key items that have identical names to eachother...if i remember right.


...yeah so is the other type the key items? i assume so man i didn't realize how many of them there are. i guess you already figured out you don't need to stack those right?

My first guess was that it was about 300 items when I roughly looked at it. When I checked the Field Items list you provided, I knew it was 254 excl. Key Items. There are exactly 56 Key Items, so the total item count would be 310 unique items.
And those don't need to be stacked, like you said. I don't however remember any Key Items with the same names except the Chocograph Piece (which I'm going to give a number ofcourse ^^)
 
well, i know next to nothing about game cache, but wouldn't it be correct to assume that items can have the same name and be stored under alternate names in the game cache? after all in jass when referring to items you don't refer to the item name but rather the item id number.
 
Ofcourse. If you got an indexed string variable ItemName, you can make the string say "Potion" for ItemName[1] and "Hi-Potion" for ItemName[2]. Chocographs can be seperated the same way. ItemName[1] = Chocograph, ItemName[2] = Chocograph, ItemName[3] = Chocograph, etc. They're all called Chocograph, but all I have to do is refer to ItemName[#].
 
Status
Not open for further replies.
Back
Top