[Question]Dmap into C# form

01/04/2011 23:00 Korvacs#16
Quote:
Originally Posted by Ian* View Post
Well when you try to access your dmap from another thread it will crash your program and thrown an exception saying something like no cross thread calls allowed.

If this is j ust a GUI with no functionality in it then I can totally see why there is no issue <yet>.
You can remove the check for that, and aslong as what your doing is safe then its actually not a problem at all.
01/04/2011 23:35 OELABOELA#17
I tried it on another pc that was 32 bit, but almost the same specs. It did go well, it updated the dmap better then on my own pc >.>
01/05/2011 04:01 Real~Death#18
a buddy of mine gave me some code for this.seems to be like a binarie reader of the dmaps.he said it should help on what we are trying to do.soon as I get the connection problems im having with the alchemy source,ill try it/
01/05/2011 09:49 OELABOELA#19
Quote:
Originally Posted by Real~Death View Post
a buddy of mine gave me some code for this.seems to be like a binarie reader of the dmaps.he said it should help on what we are trying to do.soon as I get the connection problems im having with the alchemy source,ill try it/
Are you having connection problems within the code, or just with settings.txt etc..
01/05/2011 11:11 IAmHawtness#20
Quote:
Originally Posted by Korvacs View Post
You can remove the check for that, and aslong as what your doing is safe then its actually not a problem at all.
Are you talking about CheckForIllegalCrossThreadCalls? If so, why not just update the map by invoking? It's thread safe and easy
01/05/2011 12:13 Ian*#21
Quote:
Originally Posted by Real~Death View Post
a buddy of mine gave me some code for this.seems to be like a binarie reader of the dmaps.he said it should help on what we are trying to do.soon as I get the connection problems im having with the alchemy source,ill try it/
Probably not a binary reader lol, dmaps are like..

0 = invalid coords
1 = valid coords

so for 0 draw a pixel of black for 1 draw a pixel of white.


@martin

yeah that's the exception i was talking about, and yea easy fix :p delegate/ invoke the function and its gone.

i wasn't aware there was a way to just disable the check? + that's not thread safe? O.o
01/05/2011 12:20 IAmHawtness#22
Quote:
Originally Posted by Ian* View Post
@martin

yeah that's the exception i was talking about, and yea easy fix :p delegate/ invoke the function and its gone.

i wasn't aware there was a way to just disable the check? + that's not thread safe? O.o
I tried using the "CheckForIllegalCrossThreadCalls = False" but to be honest, I prefer invoking since it seems like the easiest/best solution to me.
01/05/2011 12:44 Korvacs#23
Both methods work, you can just disable it and be just fine so long as you dont do something really ridiculous.
01/05/2011 13:27 IAmHawtness#24
Quote:
Originally Posted by Korvacs View Post
Both methods work, you can just disable it and be just fine so long as you dont do something really ridiculous.
True, but I'm pretty sure setting CheckForIllegalCrossThreadCalls to false doesn't mean that you can access control properties. I mean, like you can by invoking. Like: If chkMyCheckBox.Checked = True then do something...
Can't do that in a seperate thread unless you're using invoke.

Also, another advantage that comes with invoking: BeginInvoke allows you to access the GUI asynchronously which is pretty neat at certain occasions.
01/05/2011 16:39 Real~Death#25
Quote:
Originally Posted by OELABOELA View Post
Are you having connection problems within the code, or just with settings.txt etc..
not sure as of yet but i have a week off work so i should all the time in the world to fix it...lol
i sent you the code,my buddy said it was ok.just dont post please not mine or your.
Quote:
Originally Posted by Ian* View Post
Probably not a binary reader lol, dmaps are like..

0 = invalid coords
1 = valid coords

so for 0 draw a pixel of black for 1 draw a pixel of white.
well only checked the code a bit,does me no good at the mmoment
01/05/2011 17:02 pro4never#26
The reason why he hasn't had any issues with crossthreadcall crashing is cause I already set it to false for the gui I had originally added for myself (I had one with some basic stuff like kill counter/character tracker + some basic settings). I never bothered doing any of the map stuff though cause it was always being hosted through 1 main server with everyone logging in through it. At the time I had no desire to do a proper proxy cause well... that wasn't something that really interested me.

But yes, currently the proxy he is using already has the check disabled. I've never had any problems using that system but as you said, I'm sure there are PLENTY of better ways to do things.

Note: You can access the form members but you have to set them to public (IE: set the label to public and then when starting the gui from your main program save the instance you created of it and use that to modify all the form members)
01/05/2011 17:04 Korvacs#27
Quote:
Originally Posted by Ian* View Post
Probably not a binary reader lol, dmaps are like..

0 = invalid coords
1 = valid coords

so for 0 draw a pixel of black for 1 draw a pixel of white.
You read the .dmap format with a binary reader. Heres the entire file:

Code:
                _FileStream.Seek(268, SeekOrigin.Begin);
                Map.PopulateTiles(Reader.ReadUInt32(), Reader.ReadUInt32());

                for (ushort y = 0; y < Map.Height; y++)
                {
                    for (ushort x = 0; x < Map.Width; x++)
                    {
                        Map.SetWalk(x, y, !Convert.ToBoolean(Reader.ReadUInt16()));
                        _FileStream.Seek(2, SeekOrigin.Current);
                        if (_Height)
                            Map.SetHeight(x, y, Reader.ReadUInt16());
                        else
                            _FileStream.Seek(2, SeekOrigin.Current);
                    }
                    _FileStream.Seek(4, SeekOrigin.Current);
                }

                uint PortalCount = Reader.ReadUInt32();

                Map.PopulatePortals(PortalCount);

                for (ushort y = 0; y < PortalCount; y++)
                {
                    DMapPortal portal = new DMapPortal();
                    portal.XCord = (ushort)Reader.ReadUInt32();
                    portal.YCord = (ushort)Reader.ReadUInt32();
                    Map.SetPortal(y, portal);

                    _FileStream.Seek(4, SeekOrigin.Current);
                }
Between access and height is a third variable which denotes the type of tile, not really necessary for private servers. Also i seek the first section of the file as its not necessary for loading the tiles.

And of course portals at the end of the file.

Edit: And also i just noticed that someone posted a copy of my loader from the CUOSP project, that loader is custom made to be used with my .smap format, it determines access based on the bits used in a byte to compress the size even further and reduce loading time. It will not work with standard dmap files.
01/05/2011 19:03 OELABOELA#28
My problem is that im using it on a 64 bit pc, while its 32 bit. I saw korvacs made a thread about making it 64 bit a while ago, but i think that when i turn it on 64 bit, everything will be fucked.
01/05/2011 21:51 Korvacs#29
Quote:
Originally Posted by OELABOELA View Post
My problem is that im using it on a 64 bit pc, while its 32 bit. I saw korvacs made a thread about making it 64 bit a while ago, but i think that when i turn it on 64 bit, everything will be fucked.
Ok, what actually is the problem?