Map screwed up in-game

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
Why can't you place the flowers as back objects?

Your only limitation is you can't have 2 images on the same layer - but a back object should work fine against a back tile.

I've never come across this issue on any official map (or on any map i've seen built up to now) - so you should be able to use back/front objects to achieve everything you need.

Middle layer is rarely used (if i remember correctly Mir3 doesn't even have a middle layer, it just treats it as a front layer) - a middle layer only gives you a third overlay effect for some complex tiles which use depth i guess.

It simply wont allow for the creation/placement of back images using objects, it never has. Objects must be middle/front. I always just assumed there was a good reason for this.
(As in, you can't place them on the map if 'back image' is selected, it just does nothing)

The only thing you can place as a back image are 'Tiles' & 'SmTiles'
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
It simply wont allow for the creation/placement of back images using objects, it never has. Objects must be middle/front. I always just assumed there was a good reason for this.
(As in, you can't place them on the map if 'back image' is selected, it just does nothing)

The only thing you can place as a back image are 'Tiles'

Oh maybe i looked at the code wrong - i thought i saw both back objects and back tiles being drawn separately. Haven't looked at the map editor in so long that i can't really remember how it works.

Objects aren't always in front of you on existing maps though, so what are they using if it's not middle?
 

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
Maybe I have missed something, but I'm pretty sure the previous statement is true.

Can you think of a map/example where this is the case for me to go check out?
The objects only appear infront of you depending on where you stand in relation to the 'front' tag.

Edit:
Bare in mind this misplacement issue only occurs when we have an image that uses multiple cells with 1 tag. Like this. Most of the SM tiles etc I've been using upto now have been build with a tag on every cell.

OcSdsA.jpg


---------- Post Merged at 03:25 PM ---------- Previous Post was at 03:06 PM ----------

Does middle layer floor code do the same thing as middle layer objects?

I just tried this and middle layer 'Tile' appears in the position it was placed. So works fine.

--

I can't seem to find any such examples. The only middle images I see are the SmTiles.
Except this rock wall, they for whatever reason decided to make it as a middle image. But, as you can see, it is tagged on every cell.

2IMdXW.jpg


---------- Post Merged at 04:35 PM ---------- Previous Post was at 03:25 PM ----------

I just had a look at the 'private void DrawObjects()'
But i can't find what I'm supposed to be comparing it to in the map editor master, sorry.

There does only seem to be a few cases where this is a problem, such as that flower, and a few others. Mainly Shanda bits. So it's not a huge issue, can always just extract and cut the images so they can be build with tags on each cell if necessary.
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
What i'm getting at is that plant image you're putting on the map must be used in an official map somewhere? Do they use it as a back/middle/front object?
 

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
Front, in the official maps.
But it looks as i posted in the image. Flowers showing through.

Maybe I'm just being too picky, i just don't like that effect.

If everything else works fine, as I've not had any such issues up to now, then its OK. I'll just cut up the images myself to use them as middle.

Their solution to this seems to be just stick a 'no move' tag on stuff so people can't actually walk on it. But yeah, thats just silly, and annoying as hell to the player trying to run around.

---------- Post Merged at 05:10 PM ---------- Previous Post was at 04:59 PM ----------

Edit: New signpost object release coming soon!

hxcH9G.jpg


---------- Post Merged at 05:20 PM ---------- Previous Post was at 05:10 PM ----------

In regards to using 'back objects' this is something i never thought possible.
There are a few instances where they have images used in this way such as this:
Tho it's not actually an object, it's just a 'detailed' back image.

Nq8jnM.jpg


However, that is buit from a collection of tiles located in Tiles4. So is there code somewhere that is determining the source of the images and deciding what's acceptable use. i.e why can anything in Tiles be placed as back images, but not images in the Objects / SmTiles lib's?

I'd be happy to go through and try decipher this myself, but the code largely makes little sense to me.
 
Last edited:

mir2pion

TL;DR
Veteran
Feb 21, 2013
3,091
502
175
E
@mir2pion
That was hard to read.

While i see that you had similar issues, your conclusion is not quite there. It is undoubtedly a simple issue of the client loading the middle tagged images wrong.

Testing a little more, it is doing as i believe you suggested. Loading the image from the top isnstead of the bottom.
Yes, 'it is doing' as I determined it is doing, I didn't suggest it, it was no guessing. And after I pointed you in the right direction after you've been stumped and not just you, I thought I deserved a like of my post or adding to rep or just a thx in reply post. Not that I really care about that, as long as at least I don't get put down for my posting style, how hard it is to read. All I get is critique or jeering by local peeping toms.

As for "look at official maps" we already established that they were lazy ****s. Even with the better Shando ones. Let's take a look at what happens when i use the 'official' front image shall we.

I don't know about you but i don't want to be seeing flowers that im supposed to be stood in front of, thanks.
uH47nB.jpg



Placing move limits on flowers to stop this is not an acceptable solution. I really don't think i need to explain why.

Well, all I can say it is your call, you're putting down the official maps when they've been good for what, eighteen yrs and thousands of pple playing on them... I wouldn't put those maps down so definitely but again, its your call.
I just said one longstanding mir2 player's view and what I found how it works on those maps, that's all.
---------------------------
@Far
Some (and that means 'some') single tile 'item', like small flower images can be placed as backimages on existing backtile background but they replace the backtiles leaving white or transparent background as shown here. Placing even single tile features as backimages is just not a solution to problems with placing multicell objects on midlayer. BTW aren't dead mob images showing on middle layer? If so that would be definite use for the mid layer on mir2.
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
Players/mob/dead mob etc are all drawn completely independent of the map layers

Sent from my SM-G930F using Tapatalk
 

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
Thinking back to when i was making the custom round platform map, i did have the same issue.
Initially i cut into strips but couldn't place as back image.

I used it for this yeah, its mostly a back image to walk on, so needs to be done in 96*64 blocks.

So the images must be 96*64 or smaller to be placed as a back image it seems, irrespective of Lib location.

Gonna re-make the images, see what i can get sorted.

---------- Post Merged at 08:15 PM ---------- Previous Post was at 07:36 PM ----------

So I exported the images, re-cut them to the correct size, and built/saved the object using back images.
However, the object now overwrites any current back images/floor tiles.

Seems like there is no difference when it comes to back image/object.
GCVL9v.jpg


---------- Post Merged at 08:20 PM ---------- Previous Post was at 08:15 PM ----------

Building it as a middle image, it works fine.
Shows in the position it was placed on the editor.
Lq8JOV.jpg


So yeah, basically the sizes need to be re-done for anything you wish to use as middle images.

Worth all this to not see flowers you are standing infront of? Probably not, but the previously mention issues i.e the canal steps can all be solved this way.
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
Yeah i'm just looking at the code again to remember, and there are only 3 layers total (there is actually no difference between tiles and objects, everything is just a tile)

It draws like so

BackLayer
MiddleLayer
FrontLayer
Dead Objects
Living Objects + FrontLayer (in the same loop)
Own Player (so you can see yourself transparent on top of everything)
Items

---------- Post Merged at 08:41 PM ---------- Previous Post was at 08:28 PM ----------

there is a slight difference in code between the mapeditor and client

Map Editor

Code:
var s = Libraries.MapLibs[libIndex].GetSize(index);
                        if ((s.Width != CellWidth || s.Height != CellHeight) &&
                            (s.Width != CellWidth*2 || s.Height != CellHeight*2))
                        {
                            drawY = (y - mapPoint.Y + 1)*(CellHeight*zoomMIN/zoomMAX);
                            Draw(libIndex, index, drawX, drawY - s.Height*zoomMIN/zoomMAX);
                        }
                        else
                        {
                            drawY = (y - mapPoint.Y)*(CellHeight*zoomMIN/zoomMAX);
                            Draw(libIndex, index, drawX, drawY);
                        }

Client

Code:
if (M2CellInfo[x, y].MiddleIndex > 199)
                    {//mir3 mid layer is same level as front layer not real middle + it cant draw index -1 so 2 birds in one stone :p
                        Size s = Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].GetSize(index);

                        if (s.Width != CellWidth || s.Height != CellHeight) continue;
                    }
                    Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].Draw(index, drawX, drawY);

Ignoring the zoom code which the map editor has - it looks to recalculate the X/Y coords depending on the cell Height/Width over 2 cells. The client doesn't so any of this (with the exception of simply not drawing Mir3 middle images unless they're a single square image)

Could be this causing it. (Maybe the person who made the editor found a bug in the draw code but didn't mention the bug so just fixed the editor)

Completely untested - but i've just copied the editor code and added to the client.

Replace the whole middle index loop with this

Code:
for (int y = User.Movement.Y - ViewRangeY; y <= User.Movement.Y + ViewRangeY + 5; y++)
            {
                if (y <= 0) continue;
                if (y >= Height) break;
                drawY = (y - User.Movement.Y + OffSetY) * CellHeight + User.OffSetMove.Y; //Moving OffSet

                for (int x = User.Movement.X - ViewRangeX; x <= User.Movement.X + ViewRangeX; x++)
                {
                    if (x < 0) continue;
                    if (x >= Width) break;
                    drawX = (x - User.Movement.X + OffSetX) * CellWidth - OffSetX + User.OffSetMove.X; //Moving OffSet

                    index = M2CellInfo[x, y].MiddleImage - 1;

                    if ((index < 0) || (M2CellInfo[x, y].MiddleIndex == -1)) continue;

                    Size s = Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].GetSize(index);

                    if (M2CellInfo[x, y].MiddleIndex > 199)
                    {//mir3 mid layer is same level as front layer not real middle + it cant draw index -1 so 2 birds in one stone :p
                        
                        if (s.Width != CellWidth || s.Height != CellHeight) continue;
                    }

                    if ((s.Width != CellWidth || s.Height != CellHeight) &&
                            (s.Width != CellWidth * 2 || s.Height != CellHeight * 2))
                    {
                        Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].Draw(index, drawX, drawY + 1);
                    }
                    else
                    {
                        Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].Draw(index, drawX, drawY);
                    }
                }
            }
 

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
It's all good.

A bit of fiddling about cutting/re-building to get it working, but it is not a common occurrence really.

The only real downside, if you can call it that, is my data libs are getting more and more 'custom' each day. So compatability issues for anyone trying to use them outside of my client.

Edit: Ill give that a try, see what happens, after dinner.
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
It's all good.

A bit of fiddling about cutting/re-building to get it working, but it is not a common occurrence really.

The only real downside, if you can call it that, is my data libs are getting more and more 'custom' each day. So compatability issues for anyone trying to use them outside of my client.

Edit: Ill give that a try, see what happens, after dinner.

Instead of making custom libs (on existing libs) - you could make a new lib for them all, then make a new map format to read your lib.

It's not that difficult once you see how it works already - and it gives the added bonus that people will struggle to use your maps outside of your client.
 

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
That does sound interesting.

Without sounding like a complete ****. It's hard to be different these days content wise. As everything is client based as readily accessible once you release it. That's something.

---------- Post Merged at 09:18 PM ---------- Previous Post was at 08:59 PM ----------

Edit: I replaced the code you posted, no change ingame that can see.
The objects placed as middle images are still offset.
 

iJam

To the rhythm
VIP
Oct 8, 2007
1,522
99
195
London
Not really sure if you've worked it out yet. Ill try explain Middle tiles are meant to be 48x32 that's why those cliffs are entirely made up from single middle tiles of 48x32 from the Image below if you placed a strip 48x96 as middle then the tag(purple) where you placed it will be at the top and it will draw below giving you that offset and if placed on front the tag(red) will be at the bottom and draw above it.

CR8ZD0C.png


---------- Post Merged at 10:11 PM ---------- Previous Post was at 10:02 PM ----------

If you was to place middle(left) and front(right) on the same X coord represented by the green line it would look like this.
DjjMZ07.png

You need to cut them down into 48x32 making it x3 tiles shown below to the right, instead of 1 strip.
TYyTZII.png
 
Last edited:

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
Thanks iJam, did work it out in the end, but you explanation was better :)

---------- Post Merged on 24-04-2018 at 01:50 AM ---------- Previous Post was on 23-04-2018 at 10:45 PM ----------

Instead of making custom libs (on existing libs) - you could make a new lib for them all, then make a new map format to read your lib.

It's not that difficult once you see how it works already - and it gives the added bonus that people will struggle to use your maps outside of your client.

Looking at the MLibrary code, hoping i understand what you meant.

So basically:
- Make a new .lib. - This would need adding to the map editor/client/server code for reading. Seems easy enough.
- Define a new map type/format? Then add the code for the client/server to read the new format, easy enough looking at the current ones listed.

And this is where I'm a bit lost. Assuming this is along the right lines.
This is what determines the current maps to be MapType100. Where is this defined/saved?
Code:
if ((Bytes[2] == 0x43) && (Bytes[3] == 0x23))

This is the save code i found:
Code:
private void Save()
        {
            if (M2CellInfo == null)
            {
            }
            else
            {
                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Custom  Map (*.Map)|*.Map";
                saveFileDialog.FileName = "Custom  Map";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    var fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create);
                    var binaryWriter = new BinaryWriter(fileStream);
                    short ver = 1;
                    char[] tag = {'C', '#'};
                    binaryWriter.Write(ver);
                    binaryWriter.Write(tag);

                    binaryWriter.Write(Convert.ToInt16(mapWidth));
                    binaryWriter.Write(Convert.ToInt16(mapHeight));
                    for (var x = 0; x < mapWidth; x++)
                    {
                        for (var y = 0; y < mapHeight; y++)
                        {
                            binaryWriter.Write(M2CellInfo[x, y].BackIndex);
                            binaryWriter.Write(M2CellInfo[x, y].BackImage);
                            binaryWriter.Write(M2CellInfo[x, y].MiddleIndex);
                            binaryWriter.Write(M2CellInfo[x, y].MiddleImage);
                            binaryWriter.Write(M2CellInfo[x, y].FrontIndex);
                            binaryWriter.Write(M2CellInfo[x, y].FrontImage);
                            binaryWriter.Write(M2CellInfo[x, y].DoorIndex);
                            binaryWriter.Write(M2CellInfo[x, y].DoorOffset);
                            binaryWriter.Write(M2CellInfo[x, y].FrontAnimationFrame);
                            binaryWriter.Write(M2CellInfo[x, y].FrontAnimationTick);
                            binaryWriter.Write(M2CellInfo[x, y].MiddleAnimationFrame);
                            binaryWriter.Write(M2CellInfo[x, y].MiddleAnimationTick);
                            binaryWriter.Write(M2CellInfo[x, y].TileAnimationImage);
                            binaryWriter.Write(M2CellInfo[x, y].TileAnimationOffset);
                            binaryWriter.Write(M2CellInfo[x, y].TileAnimationFrames);
                            binaryWriter.Write(M2CellInfo[x, y].Light);
                        }
                    }
                    binaryWriter.Flush();
                    binaryWriter.Dispose();
                    MessageBox.Show("Map Saved");
                }
            }
        }

I'm assuming all i need to do is save a different Bytes value in the header as the identifier, and reference that as the new MapType?

Cheers,
 
Last edited:

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
Yes pretty much

Sent from my SM-G930F using Tapatalk
 

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
Thanks Far.

I am still unable to find where this Byte value is being saved to the map file.

This: ((Bytes[2] == 0x43) && (Bytes[3] == 0x23))
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
Thanks Far.

I am still unable to find where this Byte value is being saved to the map file.

This: ((Bytes[2] == 0x43) && (Bytes[3] == 0x23))

That is saying on the 3rd byte, check the character is 'C', and the 4th check it's '#'


find this line

Code:
char[] tag = {'C', '#'};


You can use this to convert to Hex, just add 0x on the beginning

https://www.browserling.com/tools/text-to-hex
 

Chalace

Dedicated Member
Dedicated Member
Jan 18, 2014
1,823
275
125
Aha, legend.

Think i got the idea now, will give the lot a go later today.

---------- Post Merged at 01:46 PM ---------- Previous Post was at 12:46 PM ----------

Edit: What am i missing here? Sorry if it's simple, just tying to understand what I'm doing before i make changes.
C - # actually converts to 63 - 23, not the 43 - 23 that we see in the format check, is it not MapType100 for C#, or am i using the conversion wrong?

Also will this Byte change overwrite the existing value on maps i have already saved, when i re-save them using the updated editor.
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
it's case sensitive

C = 43
c = 63

Yes it will overwrite any existing formats to the new format.
 

Akaras

LOMCN Developer
Developer
Jan 14, 2014
704
158
165
I just read most of the thread so I could see if I could offer any help...

Glad you seem to have figured out how to solve the flower in front of player problem, but instead of cutting the tiles into single tiles could you not just place the image on the different cell to account for the offset (it should still appear behind the player??) ... obviously if the editor is displaying differently to the client you would also have to edit how it displays in the editor so it matches but it may be worth it so you are not duplicating or having to edit images too often

If you are adding a custom tile/object .lib you do need to load it up in the Library code by adding your new files to the list of .lib files to be loaded (increasing the array count) then you reference the new file in the map the same way as other object/tile files (by its index number)... but I'm pretty sure you would not need to add a new MapType as it should load fine with MapType100 (Crystal format) because you are not changing any of the variables it saves/loads for the Map cell... creating a new MapType would be done if you wanted to add another layer to a map, like an effects layer or something similar you would add the new variable/s to the map save method and you would then have to create a new MapType to load the saved data in the correct order including the new variables (hope this makes sense)