[Dev] SMA Editor

Results 1 to 18 of 18
  1. #1
    You won't get me... PanKJ is offline
    Grand MasterRank
    Sep 2010 Join Date
    Too Damn HighLocation
    593Posts

    [Dev] SMA Editor

    Hi guys, id been away and couldnt release my sma editor. So now, here it is. Its not comlete yet and please let me know any bugs. Beware, there are some :) Using the tool is easy, and if you wanna make a new sma file just copy an existing working one and edit its spawns. Make sure its 256x256 sma file tho (~4mb). Also, dont put stupid values in the editor or your spawns will probably not work.

    I want you tho, when making new maps to upload them (and give some description) so that we make a library of working custom maps. This will help a lot the server development in my opinion. When you make something new which youve tested just upload it in this thread.

    Known Bugs:
    1. Attempting to open a file that doesnt end with .sma throws an exception (just press continue and itll work - the file wont be loaded obviously).

    Plans for next version:
    1. Some functions to load map images
    2. A text-based spawns writer/reader to make easier the process of editing many spawns at once
    3. A search function.
    4. Better exception handling
    5. Better performance (this version loads all spawns in memory, but after all this isnt necessary at all)
    6. A drag-and-drop function
    7. A preferences menu where you can for instance disable default header checking.
    8. A function that generates an empty .sma file (meaning without spawns).

    HrxLux deserves some credits for this, i have to admit it. His sma editor ss, even if bragging, was what inspired me.

    You may redistribute this, but dont forget to give proper credits.
    Attached Files Attached Files
    Last edited by PanKJ; 26-01-11 at 09:13 PM.


  2. #2
    Grand Master yokohiro is online now
    Grand MasterRank
    Jan 2007 Join Date
    NarniaLocation
    731Posts

    Re: [Dev] SMA Editor

    great job.

    thx

  3. #3
    Sorcerer Supreme gigabyte is offline
    Member +Rank
    Sep 2010 Join Date
    CanadaLocation
    367Posts

    Re: [Dev] SMA Editor

    It works. On most EP 3 ones it says it can't read, either something wrong with it for EP 3 or the EP 3 ones I have have an issue.

    What is the window on the right for? It shows weird letters in difference places.

  4. #4
    You won't get me... PanKJ is offline
    Grand MasterRank
    Sep 2010 Join Date
    Too Damn HighLocation
    593Posts

    Re: [Dev] SMA Editor

    The image shows where the coordinates you put would be in the map (supposing the first byte is for the x axis and the second for the y axis, otherwise the image should be rotated 90 degrees rigth). S stands for starting point and E stands for ending point. About the sma editor inability to load your ep3 files, its probably because they arent in the right format.

    The editor must read these:
    20 bytes fixed header (look in any ep2 .sma, the first 20 bytes are the header it looks for).
    65536 (or 16384 if its for 128x128 map) times the 76 byte long pattern repeated pattern (which is 4980736 bytes for 256x256 or 1245184 bytes for 128x128 maps).
    4 bytes which indicate how many spawns are following
    60 bytes long spawns (how many spawns it wants depends on the 4 bytes it read before)

    I dont know whether the server checks all this stuff but my editor does. If you know c# here is the class deciding whether the file is sma:
    Code:
    /// <summary>
        /// A class obtaining and containing info concerning sma files.
        /// </summary>
        public class SMAInfo
        {
            public readonly bool isSMA;
            public readonly FileStream fs;
            public readonly int mSize;
            public readonly byte[] Pattern;
            public string fFullPath
            {
                get;
                private set;
            }
            public string fExtension
            {
                get
                {
                    return Path.GetExtension(fFullPath);
                }
            }
            public string fName
            {
                get
                {
                    return Path.GetFileNameWithoutExtension(fFullPath);
                }
            }
            private int _sCount;
            public int sCount
            {
                get
                {
                    return _sCount;
                }
                set
                {
                    fs.Lock(mSize - 4, mSize + (value * Default.smaSpawnLength));
                    fs.Position = mSize - 4;
                    Tools.WriteBigEndian(fs, value);
                    _sCount = value;
                    fs.SetLength(mSize + (value * Default.smaSpawnLength));
                    fs.Unlock(mSize - 4, mSize + (value * Default.smaSpawnLength));
                }
            }
            public SMAInfo(string FilePath)
            {
                isSMA = false;
                if (!FilePath.EndsWith(".sma")) return;
                fFullPath = Path.GetFullPath(FilePath);
                try { fs = File.Open(FilePath, FileMode.Open, FileAccess.ReadWrite); }
                catch (Exception) { return; }
                fs.Lock(0, fs.Length);
                if (fs.Length < ((128 * 128 * Default.smaPatternLength) + Default.smaHeaderLength + 4)) goto Return; //Default.smaPatternLength is 76 in this case
                fs.Position = 0;
                byte[] header = new byte[Default.smaHeaderLength]; //HeaderLength is 20
                fs.Read(header, 0, Default.smaHeaderLength);
                //Removed: if (!header.SequenceEqual<byte>(Default.smaHeader)) goto Return; // Default sma header is the first 20 bytes which can be found in any ep2 .sma file (try the 1001.sma)
                //Pattern = new byte[Default.smaPatternLength];
                //fs.Read(Pattern, 0, Default.smaPatternLength);
                if (fs.Length >= ((256 * 256 * Default.smaPatternLength) + Default.smaHeaderLength + 4)) mSize = ((256 * 256 * Default.smaPatternLength) + Default.smaHeaderLength + 4);
                else if (fs.Length >= ((128 * 128 * Default.smaPatternLength) + Default.smaHeaderLength + 4))  mSize = ((128 * 128 * Default.smaPatternLength) + Default.smaHeaderLength + 4);
                else goto Return;
                fs.Position = mSize - 4;
                _sCount = Tools.ReadBigEndian32(fs);
                if (((_sCount * Default.smaSpawnLength) + mSize) != fs.Length) goto Return;
                isSMA = true; //Only if this command is executed will the sma file be loaded
            Return: // Return Code
                fs.Unlock(0, fs.Length);
                return;
            }
        }
    Would you mind sending me the files to examine them ? If they are made by a masangish tool or are from a masangish server then ill edit the editor to read them. I just supposed ep2 and ep3 sma files have the same format (and thats how it should be like).

    I hope this helps.
    Last edited by PanKJ; 25-01-11 at 12:07 AM.

  5. #5
    Sorcerer Supreme gigabyte is offline
    Member +Rank
    Sep 2010 Join Date
    CanadaLocation
    367Posts

    Re: [Dev] SMA Editor


  6. #6
    Elite Member l34V3 is offline
    Member +Rank
    Jan 2011 Join Date
    244Posts

    Re: [Dev] SMA Editor

    Apparently it doesnt work with ep3.3 sma's , checked all my sma's and all of ep3.3 ones throws me "invalid file format or reading the file", also some of ep3.2 wich were updated doesnt werk either.
    Last edited by l34V3; 24-01-11 at 04:28 AM.

  7. #7
    You won't get me... PanKJ is offline
    Grand MasterRank
    Sep 2010 Join Date
    Too Damn HighLocation
    593Posts

    Re: [Dev] SMA Editor

    Just like i suspected it, the smas have a different header (first 3bytes differ only). So i assume depending on the sma tool you use the header may differ. Im gonna disable the header checking and it should work with everything. Note: the image displays the spawns coordinates rotated by 90 degrees. Looks like masang write (y,x) instead of (x,y) but nvm. Also i have the impression boss spawn times are counted in mins whereas normal are in secs.

    Just noticed that adding icons was like adding 200kb (uncompressed) !!! But its not much anyway.

    Refer to post #1
    Last edited by PanKJ; 25-01-11 at 07:35 PM.

  8. #8
    Elite Member l34V3 is offline
    Member +Rank
    Jan 2011 Join Date
    244Posts

    Re: [Dev] SMA Editor

    Quote Originally Posted by PanKJ View Post
    Just like i suspected it, the smas have a different header (first 3bytes differ only). So i assume depending on the sma tool you use the header may differ. Im gonna disable the header checking and it should work with everything. Note: the image displays the spawns coordinates rotated by 90 degrees. Looks like masang write (y,x) instead of (x,y) but nvm. Also i have the impression boss spawn times are counted in mins whereas normal are in secs.

    Just noticed that adding icons was like adding 200kb (uncompressed) !!! But its not much anyway.

    Updated:
    Cute one , ill check that in a a sec also didnt you saw that koreans do everything in different way they are koreans at the end :P


    Edit:

    werks awsome job . (till i find other "bug" :D lol )
    Last edited by l34V3; 25-01-11 at 12:56 AM.

  9. #9
    Sorcerer Supreme gigabyte is offline
    Member +Rank
    Sep 2010 Join Date
    CanadaLocation
    367Posts

    Re: [Dev] SMA Editor

    So far so good with 0.0.4.1.

  10. #10
    Newbie BabbOctopus is offline
    MemberRank
    Dec 2010 Join Date
    ItalyLocation
    8Posts

    Re: [Dev] SMA Editor

    Quote Originally Posted by PanKJ View Post
    Just like i suspected it, the smas have a different header (first 3bytes differ only). So i assume depending on the sma tool you use the header may differ. Im gonna disable the header checking and it should work with everything. Note: the image displays the spawns coordinates rotated by 90 degrees. Looks like masang write (y,x) instead of (x,y) but nvm. Also i have the impression boss spawn times are counted in mins whereas normal are in secs.

    Just noticed that adding icons was like adding 200kb (uncompressed) !!! But its not much anyway.

    Updated:
    PanKJ check the archive of the SMA editor 'cause is broken

  11. #11
    You won't get me... PanKJ is offline
    Grand MasterRank
    Sep 2010 Join Date
    Too Damn HighLocation
    593Posts

    Re: [Dev] SMA Editor

    It does work. But when you opened the rar you probably didnt read the comment : "PASS = my forum name". Anyway now posting a newer edition that loads the localization.

    Refer to post #1.
    Last edited by PanKJ; 25-01-11 at 10:13 PM.

  12. #12
    Newbie BabbOctopus is offline
    MemberRank
    Dec 2010 Join Date
    ItalyLocation
    8Posts

    Re: [Dev] SMA Editor

    Thx for the tip but the archive is broken.

    We read all the posts , we downloaded it 2 times but it give the same error by dezipping.

    TY for check

  13. #13
    You won't get me... PanKJ is offline
    Grand MasterRank
    Sep 2010 Join Date
    Too Damn HighLocation
    593Posts

    Re: [Dev] SMA Editor

    You used win-rar to extract it? Cause i just downloaded it and it works fine. Maybe you should try another directory?

    PS: if you already have an existing file with the same name in the folder you try to extract it might not work (ive had this problem once).

    If the problem persists post a ss.
    Last edited by PanKJ; 26-01-11 at 02:51 PM.

  14. #14
    Newbie BabbOctopus is offline
    MemberRank
    Dec 2010 Join Date
    ItalyLocation
    8Posts

    Re: [Dev] SMA Editor

    I tryed with Winrar 7zip and IZarc, same problem. Extract succesfull but if I try to launch the exe write me the same problem.

  15. #15
    You won't get me... PanKJ is offline
    Grand MasterRank
    Sep 2010 Join Date
    Too Damn HighLocation
    593Posts

    Re: [Dev] SMA Editor

    Ah. Why didnt you tell you could extract but couldnt RUN the exe? Did you read the error it throws? It says you need .Net 4 installed.

  16. #16
    Member Renaissance is offline
    MemberRank
    Apr 2011 Join Date
    64Posts

    Re: [Dev] SMA Editor

    My Computer has. Net 4 installed, but the program doesnt start, too.
    Tomorrow I can post the correct error.

  17. #17
    You won't get me... PanKJ is offline
    Grand MasterRank
    Sep 2010 Join Date
    Too Damn HighLocation
    593Posts

    Re: [Dev] SMA Editor

    Does it work now? Was it about the .net?

  18. #18
    Member Renaissance is offline
    MemberRank
    Apr 2011 Join Date
    64Posts

    Re: [Dev] SMA Editor

    Sorry, I forgot to repost.
    No, it does not work. I uninstalled .net 4 and reinstalled it, no effect.
    Error: (Need to translate, so not the original error)
    SMA Editor has a problem and must be closed.
    If you didn't save you work, datas of this could be lost.
    Inform Microsofrt about this Problem
    ...
    ...
    ...



Advertisement