Release Xiyue MapEditor - Akaras' mod updated by M2P

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
That data type would have to be something that would single out, be unique for the smTiles category and only ShandaMir2 at that.

The layer swap works for all other tiles, even the Tiles (bigTiles -> 4x4 smTiles from ShandaMir2) which normally you wouldn't place on front or middle layers but you can and the layer swapping works on them too if you do so. Somehow these particular tags are immune to being overwritten with new layer information.
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
Shanda use have image heavy files, so will likely exceed ushort limit. Others like wemade probably don't, so you'll only see it on shanda if that's the case.
 

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
I noticed Akaras made appearance here last week, this would be something for him to chew on :D
It is not a big thing, just inconvenience if you run into it.

================================================================

I checked the layer swapping code and noticed SmTiles term does figure in it and likely that is where the glitch that prevents layer swapping is going to be.
I didn't write the code, just 'repurposed it' from other sections.

This line: if (!(str.IndexOf("SmTiles", StringComparison.Ordinal) > -1))

As much as I learned to read code, this line is not clear to me what it does.
The re-used code was taken from the 'swapping layers process' from Mir3 Layer Inversion, the "Save Invert Mir3 Layer"


C#:
        private void menu_InvertMiddleFrontLayersToggle_Click(object sender, EventArgs e)    //M2P
        {
            if (M2CellInfo != null)
            {
                //this should swap the points if point 2 is not a higher value
                if (p1.X > p2.X)
                {
                    p1.X += p2.X;
                    p2.X = p1.X - p2.X - 1;
                    p1.X -= p2.X;
                }

                if (p1.Y > p2.Y)
                {
                    p1.Y += p2.Y;
                    p2.Y = p1.Y - p2.Y - 1;
                    p1.Y -= p2.Y;
                }

                for (var x = p1.X; x <= p2.X; x++)
                {
                    for (var y = p1.Y; y <= p2.Y; y++)
                    {
                        string str;
                        if ((M2CellInfo[x, y].MiddleImage != 0) && ((M2CellInfo[x, y].FrontImage & 0x7FFF) == 0)) //M2P - Invert Middle to Front if Only MiddleImage Exists
                        {
                            str = GetLibName(M2CellInfo[x, y].MiddleIndex);
                            if (!(str.IndexOf("SmTiles", StringComparison.Ordinal) > -1))
                            {
                                if ((M2CellInfo[x, y].MiddleAnimationFrame != 0) &&
                                    (M2CellInfo[x, y].MiddleAnimationFrame != 255) &&
                                    (M2CellInfo[x, y].FrontAnimationFrame == 0))
                                {
                                    M2CellInfo[x, y].FrontAnimationFrame =
                                        (byte)(M2CellInfo[x, y].MiddleAnimationFrame & 0x0F);
                                    M2CellInfo[x, y].FrontAnimationTick = M2CellInfo[x, y].MiddleAnimationTick;
                                    M2CellInfo[x, y].MiddleAnimationFrame = 0;
                                    M2CellInfo[x, y].MiddleAnimationTick = 0;
                                }
                                M2CellInfo[x, y].FrontImage = M2CellInfo[x, y].MiddleImage;
                                M2CellInfo[x, y].FrontIndex = M2CellInfo[x, y].MiddleIndex;
                                M2CellInfo[x, y].MiddleImage = 0;
                                M2CellInfo[x, y].MiddleIndex = 0;
                            }
                        }
                        else if ((M2CellInfo[x, y].FrontImage != 0) && ((M2CellInfo[x, y].MiddleImage & 0x7FFF) == 0)) //M2P - Invert Front to Middle if Only Front Exists
                        {
                            str = GetLibName(M2CellInfo[x, y].FrontIndex);
                            if (!(str.IndexOf("SmTiles", StringComparison.Ordinal) > -1))
                            {
                                if ((M2CellInfo[x, y].FrontAnimationFrame != 0) &&
                                    (M2CellInfo[x, y].FrontAnimationFrame != 255) &&
                                    (M2CellInfo[x, y].MiddleAnimationFrame == 0))
                                {
                                    M2CellInfo[x, y].MiddleAnimationFrame =
                                        (byte)(M2CellInfo[x, y].FrontAnimationFrame & 0x0F);
                                    M2CellInfo[x, y].MiddleAnimationTick = M2CellInfo[x, y].FrontAnimationTick;
                                    M2CellInfo[x, y].FrontAnimationFrame = 0;
                                    M2CellInfo[x, y].FrontAnimationTick = 0;
                                }
                                M2CellInfo[x, y].MiddleImage = M2CellInfo[x, y].FrontImage;
                                M2CellInfo[x, y].MiddleIndex = M2CellInfo[x, y].FrontIndex;
                                M2CellInfo[x, y].FrontImage = 0;
                                M2CellInfo[x, y].FrontIndex = 0;
                            }
                        }
                        else if ((M2CellInfo[x, y].MiddleImage != 0) && ((M2CellInfo[x, y].FrontImage & 0x7FFF) != 0)) //M2P - Invert (Swap) Layers if Both FrontImage & MiddleImage Exist [Toggle]
                        {
                            str = GetLibName(M2CellInfo[x, y].MiddleIndex);
                            if (!(str.IndexOf("SmTiles", StringComparison.Ordinal) > -1))
                            {
                                if ((M2CellInfo[x, y].MiddleAnimationFrame == 255) ||
                                    (M2CellInfo[x, y].MiddleAnimationFrame == 0))
                                {
                                    if (M2CellInfo[x, y].FrontAnimationFrame == 0)
                                    {
                                        var temp = M2CellInfo[x, y].MiddleImage;
                                        M2CellInfo[x, y].MiddleImage =
                                            (short)(M2CellInfo[x, y].FrontImage & 0x7FFF);
                                        M2CellInfo[x, y].FrontImage = temp;
                                        temp = M2CellInfo[x, y].MiddleIndex;
                                        M2CellInfo[x, y].MiddleIndex = M2CellInfo[x, y].FrontIndex;
                                        M2CellInfo[x, y].FrontIndex = temp;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

WemadeM2 uses 'Smtiles' (lower case 't') while ShandaM2 libraries are SmTiles (capital 'T'). That means in the above code, the line

if (!(str.IndexOf("SmTiles", StringComparison.Ordinal) > -1))

'somehow' excludes the tiles that are from the library spelled SmTiles from having their tags re-written (which are the ShandaM2 libraries).

Now I could change SmTiles to Smtiles and then I suppose ShandaM2 SmTiles would allow layer swap and WemadeM2 Smtiles would be excluded from the swap.
Could I just remove that line or maybe it needs changing?
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
Don't just remove random lines . It's probably there because smtiles should only be on the middle layer, but there's a bug with the casing so It doesn't work on all smtiles.

That line btw is just saying if the naming doesn't contain smtiles then do the code, otherwise ignore.

Ideally the check should use an ignore case.

I can't think off my head why smtiles would be compatible for middle layer only, but I expect there's a valid reason that code was added.
 
  • Like
Reactions: Jev

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
They (mir3) didn't want us (mir2) to have the goodies they have :p

After working on the code and with maps for some time, I became convinced that

a) Front & Middle layers are just copies (in code) of one another and only difference is in these two 'names'.

b) The functionality of these two layers is fully identical in Map Editor when working with maps. It is only mir2 client which is not included to use the middle layer to its full functionality (image strips on middle layer) which is done by a simple 'exclusion' in the client code. Actually not exclusion, just not inclusion.

There might have been a reason for it deep in the past, probably going back to when mir3 was split off mir2. For whatever reason they got the idea to build all mir3 maps primarily on middle layer and only use front one when tags would collide. Mir2 has maps built primarily on the other layer and uses the middle one only for basic tiles (48x32) to avoid collision with front layer object tags.

Mir2 client as I tested it, has the same capability on both layers to display 'tall' image strips that make up objects, except that for some reason that capability for middle layer is not 'unlocked'. Likely there was a historic reason at the time having to do with a need to make mir3 maps not compatible with mir2 or something like that and I can't see any technical reason for it. That need to make things different could simply be to prevent hackers use of mir3 maps on mir2. But now Crystal Client loads them anyway.

Another way to look at it - we can place tiles from SmTiles folders on either of the two layers but they can't be swapped btw the two layers. But Object libraries also contain many basic 48x32 pixels SmTiles (beside the strips of them) and those can be swapped btw layers and only thing different here is that the library has different name (Object vs SmTiles lib). Why then the same tiles shouldn't be able to be swapped between layers the same way it the only difference here is that they come from differently named libraries (SmTiles.Lib). There can be no technical reason for the exclusion of SmTiles from being placed on either layer and allow swapping between them.

Now I know coming from me, you'd be sceptic. It is time to fix client now that we can swap layers freely in the editor. I will send you mir2 client pull request with the fix for 'middle layer tile strips draw' tonight and you can judge for yourself. I have already tested it in the client.
 
Last edited:
  • Like
Reactions: FantasticTroll

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
Well, for one, you didn't need to quote my post. Second, this has nothing to do with this thread. This is meant for map editor release and related posts.

Third, I don't know anything about Zircon, atmospheric lighting on maps also is a matter for clients, not map editors. I only touched on client here to port into it changes that map editor needs to be there (for it to use middle layer with full functionality).

Why don't you move your post into Zircon section you might get answers there. Copy, delete here and paste into new post there. I might answer there with maybe a related finding I had when working with maps.
 

Jev

ғᴜᴄᴋɪɴɢ ᴊᴇᴠ
Staff member
Moderator
May 16, 2017
3,355
20
1,898
175
Worthing, West Sussex
Well, for one, you didn't need to quote my post. Second, this has nothing to do with this thread. This is meant for map editor release and related posts.

Third, I don't know anything about Zircon, atmospheric lighting on maps also is a matter for clients, not map editors. I only touched on client here to port into it changes that map editor needs to be there (for it to use middle layer with full functionality).

Why don't you move your post into Zircon section you might get answers there. Copy, delete here and paste into new post there. I might answer there with maybe a related finding I had when working with maps.
Post moved to Mir 3 Help Section
 
  • Like
Reactions: mir2pion

FantasticTroll

Loyal Member
Loyal Member
Nov 21, 2019
85
35
30
I'd like to report a bug of v1.4 editor: upon pressing the close button, the editor doesn't actually quit, I will have to kill it by Task Manager.

I'm not sure if this is the right place to report this, if not, please kindly ignore or delete this post
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
I'd like to report a bug of v1.4 editor: upon pressing the close button, the editor doesn't actually quit, I will have to kill it by Task Manager.

I'm not sure if this is the right place to report this, if not, please kindly ignore or delete this post
There's a whole bug section for the map editor I think
 

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
I don't think this would qualify as a bug. Having worked on the editor development, it is likely I have started and quit the program more times than anybody around here and it always closed. It is more likely this would point to some issues in your windows OS rather than the program's issue.

I know this sounds like a support line advice but when did you last restart your computer? Maybe unpack a fresh copy of the editor.

On a fairly rare occasion while the editor would close as usual it would leave a background process hanging behind in task manager and trying to start the editor again, windows would report it already running. Normally the editor doesn't have such process but it seems to have one on occasion if I recall it right and don't get it mixed up with some other program. I would put it on account of windows faulting as I leave my computer running around the clock for weeks or months on end and only restart when I notice some things like this happening or when there is a power failure (like when I forget and run both kettle and toaster together :)).

When it comes to bugs/errors besides that common one we all know about (due to program's memory limitations), I recall when doing actual mapping work and putting the editor through long sessions and heavy paces, the editor would display a wide red cross over the top menu bar (wide as the program window) but that was just some glitch (likely also related to memory) that got 'fixed' by restarting the program. Chalace also had that happen.
 
Last edited:

andykid131

Golden Oldie
Golden Oldie
Mar 16, 2006
621
3
53
135
Iv experienced issues with the program not closing properly across both windows 7 and windows 10 operating systems, BOTH fresh installs. Was never able to pinpoint exactly what causes it though. Happened during prolonged use of the map editor AND after simply opening it and closing it after looking at a single map.

Happened somtimes but not others.. just learned to deal with it lol
 
  • Like
Reactions: mir2pion

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
If something is not persistent or not reliably triggered fault, then it is not a proper bug (at least not in my books :geek: ). Also issues of this type would be beyond my abilities to do anything about and I doubt anybody around accomplished enough would look into it unless it was an issue that would make working in the editor practically impossible.

I should add, that 'red cross' I mentioned happened even in the very original Xiyue editor version, before it was developed further by Akaras and myself.

Also the editor is a portable program and while it doesn't install into the OS, it still requires OS for its operation. It being 32 bit program, it might have some issues at times since most here run it on a 64 bit platform on which older 32 bit programs run in emulation. At least that's my rudimentary understanding.

I am actually amazed how the editor program is stable and that that most frequent error it pops up is so friendly, I mean if you select Continue, you can actually continue your work. Most programs if they give you an option to continue, they either won't work anymore or be almost unusable in short time.
 

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
1677002854555.png

Problem is right in the header of map editor from your screenshot. This is due to confusion that the Map folder inside Data folder is meant for map files (here 7.map). That is wrong.

\Data\Map folder is where Object.Lib, that is libraries, should be. Map files themselves can be anywhere at all, even here, but putting them into this location is, to put it mildly, silly and unnecessarily complicated (like scratching left ear with your right hand).

Next to the MapEditor.exe and the rest of files that support the program should be Data folder with Map folder inside it and inside that Map folder should be WemadeMir2 and ShandaMir2 (also Mir3) folders and inside those should be libraries themselves. But you don't need to bother to put map files there since as I said those can be opened from anywhere at all.

For starters, do as Jev said, put the map editor files into your mir2 client folder (where the client's mir2.exe is). It will then use the \Data\Map\*.Lib libraries that are in there.

If you launch the map editor somewhere else (not in existing mir2 client), it will generate \Data\Map (plus also \Data\Objects) empty folders into which you need to copy libraries, those ones from mir2 client \Data\Map\*.Lib

'Objects' folder is for map editor use, it will save objects.X files in there for its own use later on (\Objects\*.X)

That 'Map' folder should really have been called 'Library' to save some confusion.

---
maybe you can also edit your posts, click into each image to select it and pull the handle in to reduce the image sizes, or you can delete them if you can't figure out how to resize them. Thanks

Also just in case something is not clear to you, don't quote this whole post of mine (as pple often do).
 
Last edited:

Andeh

Golden Oldie
Golden Oldie
Jun 21, 2003
835
24
175
Am I crazy or is there a more intuitive way to navigate your map, than using the sliders on the right side and bottom? Its quite possibly the most tedious way you could possibly do it. What's wrong with using the arrow keys to move around? Or even holding down the middle mouse button to pan around?
 

Valhalla

Nexus Mir Developer
Veteran
Sep 7, 2012
1,948
3
447
150
127.0.0.1
Am I crazy or is there a more intuitive way to navigate your map, than using the sliders on the right side and bottom? Its quite possibly the most tedious way you could possibly do it. What's wrong with using the arrow keys to move around? Or even holding down the middle mouse button to pan around?
WASD
 

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,093
502
175
As you have found out, but there is more. Besides WASD keys, you can also use keypad (that is, if your keyboard has it).

Numpad keys 8456 emulate WASD movement but move several tiles in a single press, keypad 2 moves down much faster than 5.
Numpad keys 1379 scroll diagonally in all directions plus zero on numpad jumps back to map's origin 0:0 while Enter key jumps to map's bottom right corner.
+ & - numpad keys zoom in & out and * & / keys zoom fully in & out in a single key press.
Keep in mind that numpad keys are different from all other keys on the rest of keyboard. Visually they share the same keys but unlike in your typical program, here their action differs.

For full shortcut list, press H where it is all noted.

Scroll bars are there for visual indication where you are on large maps. Map editor due to its nature (map display) lacks some scrolling functionality of your typical windows program, like the map will not scroll with your mouse wheel while the cursor is over the map area, it only works if you move the cursor over the bars.