Witchie NL Posted May 8, 2007 Report Posted May 8, 2007 Does anyone have a piece of C++ code that exports en imports an lvl format.Im trying to learn how to import/export binary files.(since i have no coded outside mervbot yet i thought this would be ok to start with) Ive looked at DCME's source (VB) but since i dont know the language and its someone else his code (samapico) its a !@#$%^&* to understand it. Thank you,Witchie EDIT: Ive looked at DCME's source (VB) but since i dont know the language and its someone else his code (samapico and drake) its a !@#$%^&* to understand it.
»Maverick Posted May 8, 2007 Report Posted May 8, 2007 I have that code in my old and halted Tutorial project, I will paste it here when I get home (and remember to do this )
grazzhoppa Posted May 8, 2007 Report Posted May 8, 2007 (edited) whoops, thought this was about LVZ files.--------------------------------------------------------I posted code that reads an .lvz file. It's attached to the forum post:http://forums.minegoboom.com/viewtopic.php?t=7087 It's actually a program that runs from the command line.It's command line paramter is the path to the .lvz file.then extracts all the files into the program's folder, and outputs the names of the files.It's an "importer". It's in C/C++ and uses bit-shifting to read the LVZ format within the file's data.There is an easier way, I've been told, by using "bitfields" rather than bitshifting, to read binary data. The code is heavily commented/messy. Edited May 10, 2007 by grazzhoppa
»jabjabjab Posted May 8, 2007 Report Posted May 8, 2007 They need an update of LVZ (Manual) because i want to be able to make chatbg.bm2 actualy work. i know its possible.. just was never written to recognize the file (Dmn lazy MGB)
Samapico Posted May 9, 2007 Report Posted May 9, 2007 chatbg.bm2? what would that be? in a lvz, 'ressource files' (like ship1.bm2 or things like that) are not seen differently than plain bitmaps used for mapobjects or screenobjects... So the 'chatbg.bm2 not being recognized' is just impossible... in no way is it an issue that MGB can do anything about (in his LVZtoolkit, atleast).If you want a background for your chat, just put a screenobject aftergauges at 0,0, relative to chat and Witchie, just hook me up on MSN I'll "translate" that vb code in c++ for you... By the way that part of code was done by Drake, not me
»Maverick Posted May 9, 2007 Report Posted May 9, 2007 guys, Witchie asked about the lvl format (map data), not the lvz format Oh and I didn't have time yesterday so maybe this evening
Drake7707 Posted May 9, 2007 Report Posted May 9, 2007 ... By the way that part of code was done by Drake, not me OBJECTION! (!@#$%^&* i play way too much phoenix wright lately) You wrote the import & export functions, i made the interface & interactions with the imported data
Witchie NL Posted May 9, 2007 Author Report Posted May 9, 2007 better? lolAnd sama. ill contact you when your on.
Samapico Posted May 9, 2007 Report Posted May 9, 2007 ... By the way that part of code was done by Drake, not me OBJECTION! (!@#$%^&* i play way too much phoenix wright lately) You wrote the import & export functions, i made the interface & interactions with the imported datathat was for LVZ LVL open/save were already written before I even started working on DCME Apart from the few add-ons (verifying # of flags, fixing tileset importing, ssme-compatible...)
»jabjabjab Posted May 9, 2007 Report Posted May 9, 2007 Sigh.. id ont see it as impossible.. its just lvz dosent recognize it and format it to work like what the other bm2 work like. THE CHATBG.BM2 IS IN continuum0.39.dll file along with the other recognized in LVZ BM2's. It''s the version of LVZTOOLKIT, Not impossible.
Samapico Posted May 9, 2007 Report Posted May 9, 2007 It's the client that decides to 'use' or not use a .bm2 (or .wa2, or whatever) file that it finds in a lvz, it has nothing to do with the lvz file itselfIf you read the LVZ format, you'll notice that the LVZ file only stores information about the name of the file, and the data in the file... and then mapobjects/screenobjects but that has nothing to do with it. It does not have any way to know if the file is a 'ressource file', or just a plain bitmap or other file
»D1st0rt Posted May 10, 2007 Report Posted May 10, 2007 Yes, MERV definitely has what you are looking for: map.cpp, map.h
Witchie NL Posted May 10, 2007 Author Report Posted May 10, 2007 K ill take a look at that.Mav can you plz send me your code aswell? Thanks alot @ jabjabjab:LVZ's can only be used to:- place images on the map - Place images on the screen- And replace images from .../Continuum/GraphicsNot replacing images build in the plugin/application.
»Maverick Posted May 11, 2007 Report Posted May 11, 2007 Hm it was in my Labyrinth plugin instead which never got released Write a .lvl filechar buf[4];//the char array Uint32 *data=(Uint32*)buf;//pointer to the array int tile=0;//info we want in file int x=0; int y=0; ofstream file("get/labyrinth.lvl", ios::binary | ios::app);//open a file in binary mode file.seekp(0, ios::end); //Make sure we append at the end of the file *data = ((tile & 0xFF) << 24) | ((i & 0x3FF) << 12) | (x & 0x3FF); //^^^^--pushes data into the array, If you know the data is good then you dont need the bitwise & file.write(buf, 4);//write file.close(); If you want a tileset, you need to prepend a bitmap image or level file (which is almost the same): ifstream org("labyrinth.lvl", ios::binary); ofstream nnew("get/labyrinth.lvl", ios::binary | ios::trunc); nnew << org.rdbuf(); org.close(); nnew.close(); Note; you need to do this before writing any other tiles (before the first piece of code) since the bitmap has to be at the begin of the file. Reading a map.lvl file:I seem to have lost that piece of code. It's pretty easy, you only need to read that buf[4] array out each time until you reach the end of the file. However, make sure you skip the first 3435921408 bytes if the file begins with "BM-" (it's the size of the BMP image).
»Maverick Posted May 11, 2007 Report Posted May 11, 2007 More code about reading a map file from disk - as D1st0rt said - see the convertFileToMatrix() method of map.cpp . That method checks if a tileset is present (by checking the BMP header) and skips it. It then reads out 4 bytes each time and puts it into a tileData object (which contains the x, y and tile number) using the makeTileData() method.
Samapico Posted May 11, 2007 Report Posted May 11, 2007 However, make sure you skip the first 3435921408 bytes if the file begins with "BM-" (it's the size of the BMP image). uh... a 3GB bitmap? lol I think you mean 49720... don't ask me where you got 3435921408 from :SBut that would be for a 256colors tileset, if the tileset is 24bit, it will be something like the first 145920 bytes... (the value can be read somewhere in the header)
»Maverick Posted May 11, 2007 Report Posted May 11, 2007 Don't know either, I got it from the code comments
Smong Posted May 14, 2007 Report Posted May 14, 2007 What jabjabjab is referring to is the custom background image zones can display in the alt-tab chat. It is indeed called chatbg.bm2. Since alt-tab chat is part of the frontend and not part of the game, it is necessary to include it outside of any lvz files, for example you would set your LevelFiles setting to chatbg.bm2 not somelvzcontainingchatbg.lvz. Also it must be a bmp file with the .bm2 extension.
Smong Posted May 15, 2007 Report Posted May 15, 2007 No don't put the chatbg.bm2 inside a lvz file. Just place the bm2 in the server folder and add chatbg.bm2 to the [Misc] LevelFiles setting in server.cfg.
Samapico Posted May 15, 2007 Report Posted May 15, 2007 bahaha, and jabjabjab was talking to me like he had solved the mistery himself and it was super secret
Recommended Posts