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

Save system that does not requires writing down codes

Level 2
Joined
Nov 17, 2007
Messages
24
I have developed a system for RPG maps that generates color-coded text that can be read (from the screenshot) by a program, thus avoiding the need to write the code manually.

The JASS code, as well as the decoding program can be found here. This page contains more informations about the program and the script.



Anyways I post the JASS code here:

JASS:
function CharCode takes string char returns integer
    local string charTable = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTIVWXYZ- "
    local integer currentIndex = 1
    local integer endIndex = 64

    loop
        exitwhen currentIndex > endIndex

        if SubStringBJ(charTable, currentIndex, currentIndex) == char then
            return currentIndex - 1
        endif

        set currentIndex = currentIndex + 1
    endloop

    // This is invalid
    return -1
endfunction

function EncodeChar takes integer charCode returns string
    local integer base = 3
    local string array colors
    local string result

    set colors[0] = "|c00ff0000I" // Red
    set colors[1] = "|c0000ff00I" // Green
    set colors[2] = "|c000000ffI" // Blue

    set result = colors[charCode - (charCode / base * base)]
    set charCode = charCode / base

    set result = colors[charCode - (charCode / base * base)] + result
    set charCode = charCode / base

    set result = colors[charCode - (charCode / base * base)] + result
    set charCode = charCode / base

    set result = colors[charCode] + result
   
    return result
endfunction

function EncodeString takes string text returns string
    local string result = ""
    local integer currentChar
    local integer currentIndex
    local integer endIndex

    set currentIndex = 1
    set endIndex = StringLength(text)
    loop
        exitwhen currentIndex > endIndex

        set currentChar = CharCode(SubStringBJ(text, currentIndex, currentIndex))
        set result = result + EncodeChar(currentChar)

        set currentIndex = currentIndex + 1
    endloop

    return result
endfunction
 
Level 2
Joined
Nov 17, 2007
Messages
24
Each character in the save code is encoded with four colored 'I's. Each 'I' is either red, green or blue. The program looks at the screenshot and converts each group of four 'I's into the corresponding character, then copies the resulting text to the clipboard.
 
Level 2
Joined
Nov 17, 2007
Messages
24
I have an example on the project's web page. Anyways, this is a screenshot of the code F34t-2dt5-3T2c-EurZ-ryTq-vg4n-v04S-q2eh-Hm4h-v, encoded with my method:

Screenshot.jpg
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
I should have a chance to test this and review the code soon enough (blah, almost dinner right now), but it looks great! (But it would kind've suck for the average BNetter, so there are two sides to this. I suppose you could also include the classic method)

Hmm.. that would be a good system idea if you don't already have it. Have an option to display the 'real' code for people who don't have this program.

Also, just an idea, couldn't you encode the ASCII with a single color channel, and thus have 3 letters per I? (I haven't messed with too much color shiz in programming, but I don't see why not)

I suppose it would make the JASS longer (making the hex), but I see it as an advantage... (Well, maybe not SO much, since there's not any reading done by the user.. However, it would certainly be handy for long codes)
 
Level 2
Joined
Nov 17, 2007
Messages
24
You are right. I choose to use only three colors to minimize the chances to have decoding errors. If you look closely at a screenshot, especially at low resolution, like 640x480 or 800x600, you will notice that the letters are blended. That means that color of the letters is a mix between the text color and the background.
I could probably use more colors and still avoid such problems, but I prefer to err on the safe side. By the way, I think the current encoding is enough for any save code I have ever encountered.
 
Level 2
Joined
Nov 17, 2007
Messages
24
Thanks for the advice.

You need to display the text in cinematics mode because when you do that, the text always appears at the same position, which simplifies the program. I plan to add code to detect the position of the code, but right now it has to be done like that.

About the crash, what resolution is your screenshot? I only included support for 640x480, 800x600 and 1024x768 because my computer supports only these modes. If that is the problem, if you provide-me a screenshot at the resolution you use, I will update the configuration of the program to make it support it.

I can see I really need to add code that detects the code's location...
 
Level 6
Joined
Aug 24, 2007
Messages
173
This sounds genius, but very impractical. it would be fairly good for a game that is already popular and to have it switch to this new system, but there are several flaws...
. If you accidently copy text or take another screenshot before decoding it, you lose all your progress...
. If you crash during alt-tabbing (which happens to a lot of people w/ wc3) its very possible for the screenshot to corrupt.
. 90% of B Net players are idiots. (~95% of all percentage statistics are made up on the spot). its very possible that they will be far too stupid to figure out how to work their Prnt Scrn button on their keyboard, much less paste it in a prog.
. Macs dont have the Prnt Scrn func, instead they have a different form of screenies. Or so Ive heard. Never used a mac myself, filthy little things.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
If you crash during alt-tabbing (which happens to a lot of people w/ wc3) its very possible for the screenshot to corrupt.
That would happen anyways.

90% of B Net players are idiots. (~95% of all percentage statistics are made up on the spot). its very possible that they will be far too stupid to figure out how to work their Prnt Scrn button on their keyboard, much less paste it in a prog.
Which is why you would include both ways in a map.

Macs dont have the Prnt Scrn func, instead they have a different form of screenies. Or so Ive heard. Never used a mac myself, filthy little things.
This is written for windows-only anyways.

If you accidently copy text or take another screenshot before decoding it, you lose all your progress...
What?

Oh, and the attached screenshot crashes it.
http://www.hiveworkshop.com/forums/attachment.php?attachmentid=17101&d=1195612470
 
Level 2
Joined
Nov 17, 2007
Messages
24
That is correct. Actually, I'm working on an improvement that will make the program automatic, meaning that taking the screenshot will be enough to save the code. The program will automatically decode it and save it to a text file or something like that.
 
Level 2
Joined
Nov 17, 2007
Messages
24
I have updated the program. Now it has an option for monitoring the clipboard. When it is enabled, each time you take a screenshot, the save code is written in a text file in the Screenshots folder (that can be changed in the options).

It should make the program much easier to use.

I also added support for another resolution: 1152x817
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Print Screen saves an image to the Clipboard. So does highlighting text and doing CTRL+C. You can only save one image/text selection in the clipboard at a time, so the old one is overwritten if you copy something.
I know how print screen works =/

~Testing new vers.

EDIT: Link is broken (404), can't get the installer.
 
Last edited:
Level 4
Joined
May 13, 2007
Messages
75
It is a lot easier just to use banlist guys. Banlist keeps track of all the chatting in Warcraft and you can just highlight and copy/paste it from there.

i know that is not what you are discussing but Brisemec, wouldn't it be easier to create a similar program that tracks the chatting but without the whole banlist?
 
Level 4
Joined
May 13, 2007
Messages
75
Damn, I really thought there was a trigger that allowed you to send a message....guess I was wrong.
 
Level 4
Joined
Dec 14, 2004
Messages
85
I'm not a mac user and I hate macs. but why would you make a warcraft 3 map that's for PC only? I understand that some tools take a lot of work to make work for both PC and Mac but a save system for war3 should not be a PC only thing.
 
Level 2
Joined
Nov 17, 2007
Messages
24
I'm not a mac user and I hate macs. but why would you make a warcraft 3 map that's for PC only? I understand that some tools take a lot of work to make work for both PC and Mac but a save system for war3 should not be a PC only thing.

1) I recommend to anybody implementing this save system to provide a traditional save command (that displays a code that has to be typed manually). This allows someone to play the map even if he does not want / can't use the decoder program. Mac users can use that method.

2) The decoder program is written in .NET and can therefore be run under MAC or Windows using MONO, a free, open-source, .NET implementation. The decoder program requires a few modifications because of the clipboard handling, but should be easy to adapt. I will probably do it myself, but anybody can do it also because the decoder is also open-source.
 
Level 2
Joined
Dec 29, 2007
Messages
21
Print Screen saves an image to the Clipboard. So does highlighting text and doing CTRL+C. You can only save one image/text selection in the clipboard at a time, so the old one is overwritten if you copy something.

thth problem is unrealated to this program. that is a common problem with any war3 save system.
what should be done, is just output the string to a textfile. one per each map.

open the file and read all of its context, and save it to a string var.
then clear the file.

output the latest save data.

output the save history, and tag them with date and time.




Juliens ORPG 1.1.txt
****************************
[37dh-frrh-nb3b-djbh]
[June 26th 3:23pm]

[22dh-3drh-nb3b-2ed3]
[June 24th 4:24pm]

[1fdh-frtt-nb0b-dj30]
[June 22th 1:45pm]
 
Level 11
Joined
Feb 18, 2004
Messages
394
It's possible to find JASS variables in memory, so it is conceivable that given a standard program, and a standard system for storing a code in memory, it would be possible to retrieve the code at any given time. The real problem would be injecting it back in to the game, but that may be possible by passing the correct packets to/from the host, simulating a chat message.

The problem would be standardizing it enough so that it works with all maps, as well as giving the ability to easily store more than a single hero / whatever you're storing. Sync may also be an issue.

In other words, yes, It can be done. But no, it's unlikely anyone will do it.
 
Top