Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Map editor snags and snares
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  SS NewsMaker 1.3 Post :: Post Greenland Lvz Editor  View next topic  
Author Message
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Tue Nov 11, 2003 4:59 pm    Post subject: Map editor snags and snares Reply to topic Reply with quote

(I am going to use this thread to encapsulate all of my basic (stupid) and not so stupid questions)

Here we go:

1: is there a constant string of data in a map file which will always signify the end of the bitmap (if it has one) which i could use to split a .lvl?

2: Are there any prewritten file parsers (w/ src) for maps available somewhere?

i will probably have some gfx/buffering/performace issues soon...
_________________
Signatures just seem so quaint.
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Nov 11, 2003 5:17 pm    Post subject: Reply to topic Reply with quote

1. Use the BITMAPFILEHEADER structure for loading the size of the bmp. I believe there is even a quick hack that I wrote up on skipping past the BMP section somewhere in the Misc User Apps, just do a search for it. But if you are making a map editor, I'd recommend actually learning to read the BMP section correctly.

The bfSize is the full size of the whole BMP section. So just seek that many bits from the beginning of the file, and thats where the LVL data will be placed.

If the first 2 bytes are not BM, then there is no tileset for the map, thus you use the default one, which should be supplied by your map editor.

Code: Show/Hide
typedef struct tagBITMAPFILEHEADER {
  WORD    bfType;
  DWORD   bfSize;
  WORD    bfReserved1;
  WORD    bfReserved2;
  DWORD   bfOffBits;
} BITMAPFILEHEADER, *PBITMAPFILEHEADER;

Members

bfType
    Specifies the file type, must be BM.
bfSize
    Specifies the size, in bytes, of the bitmap file.
bfReserved1
    Reserved; must be zero.
bfReserved2
    Reserved; must be zero.
bfOffBits
    Specifies the offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits.


2. I'd recommend you creating your own parser. Most of them out there, such as what I wrote up for someone here before, just skip pasted all the good stuff, and may assume that the tile information is correct, and comes in chunks of 4 bytes.

Plus, if you create your own parser, you could support png tilesets and such. If a good map editor came out that is can support different image types natively, it would be very simple for Priitk to add it into continuum. Thus it can decrease the filesizes by a great deal. Could maybe store the tile information compressed.
Back to top
View users profile Send private message Add User to Ignore List Send email
Guest



Offline

PostPosted: Tue Nov 11, 2003 5:49 pm    Post subject: Reply to topic Reply with quote

I think they may be something on SSDL (sslvl?) written in VB with source that can read map files and give stats. Although as MGB says it assumes data comes in 4 byte chunks (I think Asss has this problem too), so it can only read the map file up to a certain point (on my machine anyway).

I also think maps are sent zlib compressed, but saving space on the end users machine is always nice.
Back to top
SuSE
Me measures good


Joined: Dec 02 2002
Posts: 2307
Offline

PostPosted: Tue Nov 11, 2003 5:58 pm    Post subject: Reply to topic Reply with quote

I wouldn't bother with anything at ssdownloads (for taking coding notes sa_tongue.gif)
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Nov 11, 2003 10:26 pm    Post subject: Reply to topic Reply with quote

Anonymous wrote:
it assumes data comes in 4 byte chunks (I think Asss has this problem too)


For ASSS, it will read it all, but does not error checking if the last chunk is < 4 bytes, it just ignores it. A good map editor should warn the user that the map maybe invalid, and attempt to do error checking on the data, to see where it might have fucked up.
Back to top
View users profile Send private message Add User to Ignore List Send email
SuSE
Me measures good


Joined: Dec 02 2002
Posts: 2307
Offline

PostPosted: Tue Nov 11, 2003 10:31 pm    Post subject: Reply to topic Reply with quote

ie - it should work sa_tongue.gif
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Wed Nov 12, 2003 4:04 pm    Post subject: Reply to topic Reply with quote

will see what i can do... java has not historically been my choice for handling bit-by-bit filetypes
Back to top
View users profile Send private message Add User to Ignore List
Dustpuppy
Server Help Squatter


Age:39
Gender:Gender:Male
Joined: Jan 23 2003
Posts: 215
Location: England
Offline

PostPosted: Thu Nov 13, 2003 11:03 am    Post subject: Reply to topic Reply with quote

MERV loads maps, you could take a look at the source. It's in map.* IIRC
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Nov 13, 2003 4:22 pm    Post subject: Reply to topic Reply with quote

i've been hacking, and so far my only concerns have been dealing with the annoyance of not knowing whether the first bits are bmp are not... java is not very friendly below the Byte size... it will end up being no problem.. though i will undoubtedly have to get someone to look over it.
Back to top
View users profile Send private message Add User to Ignore List
Guest



Offline

PostPosted: Thu Nov 13, 2003 5:00 pm    Post subject: Reply to topic Reply with quote

Whether the first bits are bmp or not?
Can't you just do a string check for the 'BM' header?
Back to top
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Nov 13, 2003 5:46 pm    Post subject: Reply to topic Reply with quote

i can identify, but if i find its not a bmp, i have to concat that data to map data. It's not a serious issue, i was just momentarily frustrated by it
Back to top
View users profile Send private message Add User to Ignore List
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Nov 13, 2003 10:03 pm    Post subject: Reply to topic Reply with quote

Next Question:

java is a serious pain here... though JNI is going to be a bad idea if this can be done in java:

i have never had to read a 12-bit int.
Java supports bools and bytes, nothing in between
does anyone know how to do the following in java:
split 3 bytes into 2 consecutive 12-bit ints
make an int from 12 booleans

this should get me working(buggy) lvl loader, assuming i know what im doing (i don't)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Thu Nov 13, 2003 10:16 pm    Post subject: Reply to topic Reply with quote

int int1 = byte1 << 4 + byte2 >> 4;
int int2 = (byte2 << 8 + byte3) & (0xFFF);

Note: if the compiler doesnt like it, cast the bytes to ints.

int from tweleve bools is harder. You could simply do 12 consecutive OR masks, but thats a real real pain. If you can byte shift bools into ints, it makes it easier.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Nov 13, 2003 10:33 pm    Post subject: Reply to topic Reply with quote

we non-programmers suck with anything smaller than classes sa_tongue.gif

thanks brain (*poit*)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Thu Nov 13, 2003 11:06 pm    Post subject: Reply to topic Reply with quote

Check the API for a bit storage class. It may be able to export to an int.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Nov 13, 2003 11:08 pm    Post subject: Reply to topic Reply with quote

did so, maybe im looking in the wrong places... but i dont think so
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Nov 14, 2003 9:31 am    Post subject: Reply to topic Reply with quote

Well, I found a bitset, but that doesnt give you back an integer.

It may be easier to store everything in the integer, and when you need to get the boolean, simply:

boolean myBool = (myBitInt & (1 << x) == (1 << x))

where x is the place you need, starting at 0.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Fri Nov 14, 2003 4:12 pm    Post subject: Reply to topic Reply with quote

Sorry, I have barely any Java experience, but there isn't a C++ union type thing in Java? It would be easy to form an integer from bits with a union.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Fri Nov 14, 2003 5:07 pm    Post subject: Reply to topic Reply with quote

i dont believe there are native unions. what i want is a struct, which isn't supported

thanks brain,but once i get to ints i'm happy. I can just reverse the operation to write 12 - bit ints to files
Back to top
View users profile Send private message Add User to Ignore List
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Tue Nov 18, 2003 8:49 pm    Post subject: Reply to topic Reply with quote

i've hit a stumbling block on the lvl loader... is there a good (reliable) java bitmap class around that supports conversion to Image object s, clipping subimages, and reading files like lvls without splitting off the ends (just read length in the file)???
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Tue Nov 18, 2003 10:57 pm    Post subject: Reply to topic Reply with quote

So you need a way to view the tileset as an Image? Is that what you need?

Take a look at the javax.imageio package. It can read a FileStream into a BufferedImage, which you can take and clip and stuff.

Reading the LVL data from the Image is probably impossible. What you will probably have to do is to read the file in twice (or put it into a buffer). Read it once for the tileset using imageio, and once again for the lvl data.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Wed Nov 19, 2003 4:47 pm    Post subject: Reply to topic Reply with quote

could someone give me a rundown on how to skip over the bitmap with a stream?
also, i'm needing to convert to unsigned int for the file size. i don't want to mess this up. any solutions?
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed Nov 19, 2003 8:51 pm    Post subject: Reply to topic Reply with quote

I don't know specifics of the bitmap format, but all you need to do is read the bitmap stuff until its end, then pass your BufferedReader into your LVL parser.

Unisgned int? How do you mean convert? From what, into what?
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Wed Nov 19, 2003 10:56 pm    Post subject: Reply to topic Reply with quote

here comes a mess...
this has (somewhere) gone very wrong
please take a look.
obviously some of these classes are not completed. I attempted to finish the read/input ones, and wrote a test app for it. That's when things get ugly

any help appreciated.
Thanks




here it is... straight from my eclipse workspace directory

Map.zip - 12.6 KB
File downloaded or viewed 58 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Thu Nov 20, 2003 9:19 am    Post subject: Reply to topic Reply with quote

Ok, looking through your code, the easiest way to do what you want is to pass the two reading functions the same FileStream. That way, when one is done reading the bitmap, the stream is all ready to read in the LVL. You should be careful of missing a single read at the transition, I'm not sure if that will happen, but you should be careful.

I'm not familiar with the BMP format, but a simple google search should yeild BMP reading code (its not included in imageio :<). The only thing you need to watch for is that the code doesn't read the entire stream, but rather stops when its done with the bitmap section.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Misc User Apps All times are GMT - 5 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 673 page(s) served in previous 5 minutes.

phpBB Created this page in 0.522536 seconds : 52 queries executed (91.8%): GZIP compression disabled