Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > 4Story > 4Story Hacks, Bots, Cheats & Exploits
You last visited: Today at 00:10

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#][Open Source]FrameLoader (.tif File)

Discussion on [C#][Open Source]FrameLoader (.tif File) within the 4Story Hacks, Bots, Cheats & Exploits forum part of the 4Story category.

Reply
 
Old   #1
 
Logtetsch's Avatar
 
elite*gold: 192
Join Date: May 2009
Posts: 2,227
Received Thanks: 3,262
[C#][Open Source]FrameLoader (.tif File)

Hi folks,

today I'm gonna release a small part of my (actually unfinished) .tif Editor.
It's compatible with the 4Story 3.5 .tif files. Well, actually the .tif file isn't only representing frames but I think I'm good with it throughout the other parts are not that complex like a frame.

Here's how to use it (Pseudo) :
Code:
var reader = new BinaryReader(TifFilePath, FileEncoding);
var frame = new Frame();
frame.Read(ref reader);
Here's the business logic
Code:
public sealed class Frame
{
    public Frame()
    {
        ChildFrame = null;
        NextFrame = null;
        Comp = new Components();
    }

    public Frame ChildFrame { get; set; }
    public Frame NextFrame { get; set; }
    public Components Comp { get; set; }

    public bool Read(ref BinaryReader reader)
    {
        Comp.Id = reader.ReadUInt32();
        Comp.Type = reader.ReadByte();

        for (var i = 0; i < Components.MenuCount; i++)
            Comp.Menu[i] = reader.ReadUInt32();
        for (var i = 0; i < Components.ImageCount; i++)
            Comp.ImageId[i] = reader.ReadUInt32();

        Comp.TooltipId = reader.ReadUInt32();
        Comp.FontId = reader.ReadUInt32();
        Comp.Style = reader.ReadUInt32();
        Comp.Color = reader.ReadUInt32();
        Comp.Snd = reader.ReadUInt32();

        Comp.MargineH = reader.ReadInt32();
        Comp.MargineV = reader.ReadInt32();
        Comp.PosX = reader.ReadInt32();
        Comp.PosY = reader.ReadInt32();
        Comp.Width = reader.ReadInt32();
        Comp.Height = reader.ReadInt32();

        Comp.Display = reader.ReadByte();
        Comp.Align = reader.ReadByte();

        //Placeholder for union Components until there'll be no solution
        for (var i = 0; i < TypeSpecification.ListDescription.MaxListColumn; i++)
            Comp.Ex.List.Item[i] = reader.ReadUInt32();
        Comp.Ex.List.Column = reader.ReadUInt32();
        Comp.Ex.List.Vs = reader.ReadUInt32();

        //reads string → Comp.Tooltip
        var count = reader.ReadInt32();
        if (count > 0)
        {
            var cstring = new byte[count + 1];
            for (var i = 0; i < count; i++)
                cstring[i] = reader.ReadByte();
            cstring[count] = 0x0;

            Comp.Tooltip = Encoding.ASCII.GetString(cstring);
        }

        //reads string → Comp.Text
        count = reader.ReadInt32();
        if (count > 0)
        {
            var cstring = new byte[count + 1];
            for (var i = 0; i < count; i++)
                cstring[i] = reader.ReadByte();
            cstring[count] = 0x0;

            Comp.Text = Encoding.ASCII.GetString(cstring);
        }


        //read next frames
        count = reader.ReadInt32();
        if (count == 0)
            return true;


        var next = this;
        for (var i = 0; i < count; i++)
        {
            if (i == 0)
            {
                next.ChildFrame = new Frame();
                next.ChildFrame.Read(ref reader);
                next = next.ChildFrame;
                continue;
            }

            next.NextFrame = new Frame();
            next.NextFrame.Read(ref reader);
            next = next.NextFrame;
        }

        return true;
    }

    ~Frame()
    {
        ChildFrame = null;
        NextFrame = null;
        Comp = null;
    }

    public sealed class TypeSpecification
    {
        public TypeSpecification()
        {
            Button = new ButtonDescription();
            Scroll = new ScrollDescription();
            Combo = new ComboDescription();
            Meter = new MeterDescription();
            Edit = new EditDescription();
            List = new ListDescription();
            Gauge = new GaugeDescription();
        }

        public ButtonDescription Button { get; set; }
        public ScrollDescription Scroll { get; set; }
        public ComboDescription Combo { get; set; }
        public MeterDescription Meter { get; set; }
        public EditDescription Edit { get; set; }
        public ListDescription List { get; set; }
        public GaugeDescription Gauge { get; set; }

        public sealed class ButtonDescription
        {
            public uint Up { get; set; }
            public uint Down { get; set; }
            public uint Hover { get; set; }
        }

        public sealed class ScrollDescription
        {
            public uint Bar { get; set; }
            public uint Ul { get; set; }
            public uint Dr { get; set; }
        }

        public sealed class ComboDescription
        {
            public uint Drop { get; set; }
            public uint Downlist { get; set; }
        }

        public sealed class MeterDescription
        {
            public const byte MaxMeterSublevel = 7;

            public MeterDescription()
            {
                Sub = new uint[MaxMeterSublevel];
            }

            public uint[] Sub { get; set; }
            public uint Sublevel { get; set; }
            public uint Super { get; set; }
            public uint Superlevel { get; set; }
        }

        public sealed class EditDescription
        {
            public uint Caret { get; set; }
        }

        public sealed class ListDescription
        {
            public const byte MaxListColumn = 15;

            public ListDescription()
            {
                Item = new uint[MaxListColumn];
            }

            public uint[] Item { get; set; }
            public uint Column { get; set; }
            public uint Vs { get; set; }
        }

        public sealed class GaugeDescription
        {
            public const byte MaxGaugeBar = 10;

            public GaugeDescription()
            {
                Bar = new uint[MaxGaugeBar];
            }

            public uint[] Bar { get; set; }
            public uint Count { get; set; }
        }
    }

    public sealed class Components
    {
        public static readonly byte MenuCount;
        public static readonly byte ImageCount;

        static Components()
        {
            MenuCount = 12;
            ImageCount = 2;
        }

        public Components()
        {
            Menu = new uint[MenuCount];
            ImageId = new uint[ImageCount];
            Ex = new TypeSpecification();
        }

        public string Tooltip { get; set; }
        public string Text { get; set; }
        public uint Id { get; set; }
        public byte Type { get; set; }
        public uint[] Menu { get; set; }
        public uint[] ImageId { get; set; }
        public uint TooltipId { get; set; }
        public uint FontId { get; set; }
        public uint Style { get; set; }
        public uint Color { get; set; }
        public uint Snd { get; set; }
        public int MargineH { get; set; }
        public int MargineV { get; set; }
        public int PosX { get; set; }
        public int PosY { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }
        public byte Display { get; set; }
        public byte Align { get; set; }
        public TypeSpecification Ex { get; set; }
    }
}
Logtetsch is offline  
Thanks
5 Users
Old 08/04/2015, 15:43   #2
 
elite*gold: 12
Join Date: Feb 2013
Posts: 442
Received Thanks: 246
Nice work logtetsch
AllCowsAreBurgers is offline  
Thanks
1 User
Old 08/04/2015, 18:09   #3
 
elite*gold: 0
Join Date: Jul 2015
Posts: 27
Received Thanks: 41
Awesome. ^.^
JirkusDaRealMVP is offline  
Thanks
1 User
Old 08/04/2015, 18:44   #4
 
Logtetsch's Avatar
 
elite*gold: 192
Join Date: May 2009
Posts: 2,227
Received Thanks: 3,262
Thanks. Although it works just fine, you should be aware of a small issue. Follwing lines are affected:
Code:
        //Placeholder for union Components until there'll be no solution
        for (var i = 0; i < TypeSpecification.ListDescription.MaxListColumn; i++)
            Comp.Ex.List.Item[i] = reader.ReadUInt32();
        Comp.Ex.List.Column = reader.ReadUInt32();
        Comp.Ex.List.Vs = reader.ReadUInt32();
While the components are originally stored within an union there is no 1:1 equivalent in C#. Therefore I've created this walkaround. I've already found a solution which isn't implemented, yet.
Logtetsch is offline  
Thanks
1 User
Old 08/04/2015, 19:17   #5
 
elite*gold: 0
Join Date: Feb 2013
Posts: 141
Received Thanks: 37
Awesome Relase !!!
tomeczkoo is offline  
Old 08/04/2015, 20:11   #6

 
elite*gold: 0
Join Date: Jan 2015
Posts: 73
Received Thanks: 13
Quote:
Originally Posted by Logtetsch View Post
Thanks. Although it works just fine, you should be aware of a small issue. Follwing lines are affected:
Code:
        //Placeholder for union Components until there'll be no solution
        for (var i = 0; i < TypeSpecification.ListDescription.MaxListColumn; i++)
            Comp.Ex.List.Item[i] = reader.ReadUInt32();
        Comp.Ex.List.Column = reader.ReadUInt32();
        Comp.Ex.List.Vs = reader.ReadUInt32();
While the components are originally stored within an union there is no 1:1 equivalent in C#. Therefore I've created this walkaround. I've already found a solution which isn't implemented, yet.
Are you sure it is an union ? It seems to be a struct in source.
Code:
// cinterf.h
#define MAX_LIST_COLUMN    15
typedef struct _tagListDesc
{
	unsigned int item[MAX_LIST_COLUMN];
	unsigned int column;
	unsigned int vs;
}LISTDESC, *LP_LISTDESC;
tincs is offline  
Old 08/04/2015, 20:53   #7
 
elite*gold: 0
Join Date: Oct 2013
Posts: 68
Received Thanks: 27
Quote:
Originally Posted by Logtetsch View Post
While the components are originally stored within an union there is no 1:1 equivalent in C#. Therefore I've created this walkaround. I've already found a solution which isn't implemented, yet.
There is no 1:1, indeed, but if you knew DotNet, you would know you can easily make compatible solution with FieldOffsets attributes ^^ #NextTimeCryAboutOthersInjectingVM #JustSaying #Whatever
ReadersClub is offline  
Old 08/04/2015, 20:56   #8
 
Logtetsch's Avatar
 
elite*gold: 192
Join Date: May 2009
Posts: 2,227
Received Thanks: 3,262
Code:
typedef union _tagTypeSpec
{		
	GAUGEDESC		gauge;
	LISTDESC		list;
	EDITDESC		edit;
	METERDESC		meter;
	COMBODESC		combo;
	SCROLLDESC		scroll;
	BUTTONDESC		button;
}TSATR;//Component type specific attributes
Well, in fact that an union is a special class type it's only as big as the biggest member itself because every smaller member fits into it. In this case it's the structure _tagListDesc(LISTDESC) with a size of 68 bytes. So, what's the problem? While reading an union type from a file you must read that amount of bytes as the biggest member represents. The reader will always read 68 bytes and load these into the union object.

It's impossible to determine which item the union object is really representing during execution time. It can be BUTTONDESC, either SCROLLDESC and so on. So what to do? You should have a help object (I'm really sure it's Comp.Type) which state is indicating the real representing item.

Quote:
Originally Posted by ReadersClub View Post
There is no 1:1, indeed, but if you knew DotNet, you would know you can easily make compatible solution with FieldOffsets attributes ^^ #NextTimeCryAboutOthersInjectingVM #JustSaying #Whatever
Well, actually I'm aware of FieldOffsets but I have no need to use them while there are much more cleaner solutions. Btw. FieldOffsets are unmanged, therefore I'm not going to use them.
Logtetsch is offline  
Old 08/05/2015, 13:53   #9
 
elite*gold: 0
Join Date: Apr 2011
Posts: 113
Received Thanks: 17
Ist das ein Hack? Oder wie funktioniert das?
abuantar is offline  
Old 08/05/2015, 16:01   #10
 
Logtetsch's Avatar
 
elite*gold: 192
Join Date: May 2009
Posts: 2,227
Received Thanks: 3,262
Nein, das ist kein Hack.
Logtetsch is offline  
Reply


Similar Threads Similar Threads
[Open-Source][C#] EloBuddy, open source League of Legends Bot
05/27/2014 - League of Legends Hacks, Bots, Cheats & Exploits - 8 Replies
-- Snipped --
[Source Problem]Cannot open include file
03/18/2012 - Flyff Private Server - 11 Replies
Jup wie im Titel gesagt bekommen ich beim rebuilden des Coreserver immer folgende meldung: c:\Users\****\*****\server files\Flyff Source\Source\_Common\ProjectCmn.h(58): fatal error C1083: Cannot open include file: 'defineitemkind.h': No such file or directory Ähnliche Fehler waren bei Account Cache und Certifier aber die habe ich bereits gefixt. Ich weiß nicht warum er die Datei nicht findet.... Hilfe wäre nett...oder ein "Tipp" würde denke auch reichen.
How to open mesh file and anim file(dekaron).PLZ~
02/15/2010 - Dekaron Private Server - 11 Replies
How to open mesh file and anim file(dekaron).PLZ~



All times are GMT +2. The time now is 00:10.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.