GM8 cbyte v1.2beta

    • GEX

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • GM8 cbyte v1.2beta



      Probleme vorneweg:
      - cbyte kann nur positive Integer (bis max. 12-stellig) abspeichern.

      Neues in Version 1.2:
      - Ihr koennt eure Strings nun verschluesseln durch cbyte_set(); in 20 moegliche Level, und ihr braucht euch nicht an eure Verschluesselungswerte erinnern, cbyte erkennt diese automatisch.


      Neues in Version 1.1:
      - Real Values werden jetzt komprimiert bis zu 50%. Ihr sparrt somit Platz.
      - neue Funktion, um zu pruefen wo die naechste freie Stelle ist in der geschrieben werden kann. Diese gibt selbstverstaendlich die Position als Real wieder.
      - GMK Beispiel
      - Plattformunabhaengig(!) Windows oder Mac. (also wer Ahnung hat vom Extension App, kann das Ding revers-engineering fuer GM4Mac, theoretisch)
      Volle Werte um 50% komprimiert!
      ..so sieht's aus. Sagen wir, ihr habt einen 4 byte Wert und speichert diesen mit cbyte. Aus 4 bytes werden 2 bytes:


      Vorteile gegnueber INI's oder Crypt-Codes
      - Erstma, kann Keiner nachvollziehen, welche Positionen ihr verwendet und somit unmoeglich herausfiltern wo gewisse Werte und STrings beginnen, bzw. aufhoeren.
      - Zweitens ihr sparrt viel Platz, da cbyte keine Sections verwendet und somit auch keine Line CHaracters.
      z.B. Eine Ini-Datei sieht in der Regel so aus:

      Quellcode

      1. [data]
      2. health=1278
      3. name=Horst Walter

      und cbyte macht daraus:

      Quellcode

      1. 000011111111111111

      ...die #,0 und 1 sind in diesem Beispiel sind nur Platzhalter und nicht die tatsaechliche Uebersetzung.

      Ein kleines Beispiel (GML):

      GML-Quellcode

      1. score = real(get_string('New Score: ','0'));
      2. //Lasst uns den Dateinamen festlegen:
      3. var fname;
      4. fname = 'score.dat';
      5. //Jetzt pruefen wir, wo die naechste freie Position in unserer Datei ist:
      6. var cb_position;
      7. cb_position = cbyte_pin(fname,'',0);
      8. //Im naechste Schritt schreiben wir die Variable "score" in unsere Datei.
      9. cbyte_set(fname,score,0,cb_position,0); //since scroe is a real value rather than a string, we set the type-Argument to 0. Und wir setzen das letzte Argument auf 0, seit dem wir nur ein real speichern, der nicht zusaetzlich verschluesselt werden muss.
      10. //Zeit zu sehen, welche Stelle besetzt wurde
      11. show_message('Value score has been written in file: '+string(fname)+string(' at position ')+string(cb_position));
      12. //Jetzt lasst uns diesen Wert auslesen:
      13. var cb_score;
      14. cb_score = cbyte_get(fname,0,cb_position); //We read the value from the previous determined position. It's not reliable to do it this way. You might wanna record your entries to a textfile by using cbyte_pin(fname,txtfname,txtstring).
      15. //...Resultat als Mitteilung:
      16. show_message('The score valued stored is: '+string(cb_score));
      17. //Im Fall eines Falles, will man genau wissen, wohin man geschrieben hat, und so weiter, dann machen wir das so:
      18. cbyte_pin(fname,'record.txt','next free position');
      19. //Nun sollte eine Datei im Ordner auftauchen, die euch wie in diesem Bespiel gezeigt, wiedergibt wo die naechste freie Stelle ist.
      Alles anzeigen


      Ich habe diese Extension noch nicht auf GM8.1 getestet, und wuerde mich freuen, wenn das mal jemand taete. Danke :)
      WICHTIG: Ihr koennt keine Werte im >12 Stellenbereich abspeichern. Da tut sich dann ein ekliger Fehler auf.

      Fuer die Englisch-Sprachigen unter euch gibt's hier mehr info:
      Spoiler anzeigen
      cbyte v1.2 BETA
      ===============
      written by Nightrage (har_yar@hotmail.com)
      for GameMaker 8.0

      Info (Installation):
      This Extension needs to be installed in the following steps
      1) Open the Application GameMaker 8.0
      2) Find the icon "green plus" with the mouse-over-tag "select the extension packages used", in your toolbar on the top under the menu. And click on it.
      3) Find and click on the button "Install" (right bottom corner of the Extension Packages - Dialog).
      4) Again in the next Dialogind, find and click on the button "Install" (top right Corner of the Installing Extension Packages - Dialog)
      5) In the Open Dialog find the file "cbyte_v11.gex" and click on the button "open".
      6) Back in your "Install Extension Packages" click on the button ok (bottom right corner of the dialog).
      7) Now in your "Extension Packages-Dialog" find the Entry "cbyte" within the list-box to the right and select/mark it.
      8) With selecting the entry there should be an Arrow-Button between both List-Boxes, please click on it.
      9) When done so, please click on the button ok located on the bottom left corner of the Extension Packages Dialog.
      Done!

      About this extension:
      This Extension lets you store Values and String in Byte Format and lets you also save it in a file.
      Every real value will be downsized up to 50% and saves you valuable diskspace.

      How to use:
      Let's say you would like to store you variable "Score" or "Health" in a file as byte-string.
      You can do this with the function "cbyte_set()":

      //GML code starts here
      cbyte_set('filename.dat',Score,0,0,0); //we save it as "filename.dat" storing the value of the variable "Score" which is a value (real number) as Type "0" at Position "0". The last Argument defines the Crypt-level (which can only be used for Strings and can not be higher than 20).
      //GML code ends here

      MORE: cbyte_set(fname,string/value,type(0=real/1=string),position,crypt-level(1-20));

      And now let's say you would like to read this value. You can use therefore the function cbyte_get():

      //GML Code starts here
      var d1;
      d1 = cbyte_get('filename.dat',0,0); //Make sure you have remembered the correct position.
      show_message(string(d1));
      //GML Code ends here

      MORE: cbyte_get(fname,type(0=real/1=string),position);

      You can do this with Strings aswell. Just use Type 1 (for string) instead.
      IMPORTANT:
      1) You have to remember to use correct positions, for example:
      your string is 10 Chars long which u store at position 0.
      The NEXT Value has to be considered at position >string length + 6 which would be 16.
      So the next Value can be stored at position 16.

      BUT since version 1.1, cbyte provides a helpful function which lets you record where your positions are,
      and it also returns the next free position as a real number. It works as follow:

      //GML Code starts here
      var d1;
      d1 = cbyte_pin('yup.dat','record.txt','next'); //Returns the last free position in your file. Argument 1 is the file you wish to read from. Argument 2 is the file which you wish to store the position inormation in, leve it as '' if not wanted. In Argument 2 you can specify what you wish to mark it as leave as 0 if not needed.
      show_message(string(d1));
      //GML Code ends here

      in the text file it will look like this:

      //TXT
      Position 22 = next

      2) A real Value may not be longer than 12 numbers.

      Hope it helps.
      Please report any bugs to my email Address.
      Thank you :)


      Download Link (13KB @ mediafire.com):
      mediafire.com/?208xm8k2t2bsnga

      Dieser Beitrag wurde bereits 11 mal editiert, zuletzt von Nightrage ()

    • Ich finds schade, dass bis jetzt noch niemand hier was reingeschrieben hat, wobei es aussieht als hättest du viel
      Arbeit und Zeit dafür investiert :o
      Ich hatte noch nicht die Gelegenheit es auszuprobieren, aber soviel ich hier lesen konnte, scheint es etwas nützliches
      zu sein, das dazu beiträgt das eigene Projekt sicherer von außen zu machen [=

      Weiter so!


      mfg