- infile.get(in);
- infile.ignore(); // ignore the next character (this was probably originally stored as an int)
shaktazuki | Oct 05, 2008 4:08 am |
---|---|
Subject: resource stripper help If anyone has the time - Here's my resource stripper program. It is supposed to write a 16 color bitmap of the resource layout from a MAX savegame. The bitmap is not turning out well, and I don't know why. If anyone can take a look and tell me how I am messing up, I would appreciate it. |
|
Attachments: editor.zip (Filesize: 3.77 KB) |
Artlav | Oct 05, 2008 12:27 pm |
---|---|
Subject: Re: resource stripper help There seems to be many problems. First, why the offset is 12768 and not 12763? EDIT: Right, version 1.56 vs 1.04. It is 12768 in 1.04 and 12763 in 1.56, so that is all right. Why unsigned char bmpdata[BMP_DIM / 2][BMP_DIM]; ? You make a bitmap that is not a square, probably messing the things downcode. Like, writebmp16(filename, BMP_DIM, BMP_DIM, (unsigned char *)&bmpdata); Does not sound right to me. DownloadSource code (Text): You ignore player visibility bitmask. Good, but comment makes it senseless.
You read bytes of resource distribution. The resources block format is thus, in case you don't know it : DownloadSource code (Text):
So, your code below DownloadSource code (Text): Makes somewhat doubtful sense.
You can use my save game reader as a reference: http://www.rumaxclub.ru/etc/maxse_081005.zip It takes a save file as first parameter, and outputs bitmaps and information. No source code, unless you ask for it. |
Artlav | Oct 05, 2008 12:59 pm |
---|---|
Subject: Re: resource stripper help Ok, got it fixed. You can disregard the BMP_DIM/2 argument, as i didn't dig deep enough on the first round to figure it out properly. Here is the fixed code: http://www.rumaxclub.ru/etc/editor_fixed.zip Basically, the problem was in the data distribution in memory - you got x and y swapped in several places. |
shaktazuki | Oct 05, 2008 7:00 pm |
---|---|
Subject: Re: resource stripper help You even aligned it to the map display in the game; wow! I would have settled for just getting it in any alignment. Thanks! I only knew the resource masks / amounts / offset. I wish I knew the rest - if you have a description of the savegame format, I'd like to get it. My next step is to also output the amounts. This will take significant effort. I wrote the bmp writer and I still didn't know exactly how it works. Thanks to you, I know now. |
Artlav | Oct 05, 2008 9:59 pm |
---|---|
Subject: Re: resource stripper help Quote by shaktazuki: Why should it?My next step is to also output the amounts. This will take significant effort. Quote by shaktazuki: You wrote a BMP writer without knowing about how it works?I wrote the bmp writer and I still didn't know exactly how it works. Nicely done, considering that it seem to work well. Quote by shaktazuki: The whole format description does not exist yet.I only knew the resource masks / amounts / offset. I wish I knew the rest - if you have a description of the savegame format, I'd like to get it. I've decoded a big deal of it, but there are still lots of blind spots. At the start, a word of version - 0x0046 for 1.04, 0x0045 for 1.56. Then, a header: DownloadSource code (Text): (Not exactly C++ syntax, but the structure is preserved)
After that, pass map - one byte per cell passability, then resource map as described above. After the maps - player information: red, green, blue, gray one after another: Here the blind spots become more obvious DownloadSource code (Text):
That ends the static part, the stuff downrange from here goes somewhat cryptic. There are unit updates tables, unit objects, updates objects, construction objects, all without an obvious structure i can cleanly define, the most common being - a word for object id, object type, object record. But there are also size-like intermittents in the stream, i can't find out the sequence of, only ignore. It can be read nicely enough to do basic conversion to MGA in about 90% of times, but a lot is being lost and not known yet. After the units part, there are scan maps and message log of some sort. The current state of my save-game reader. This one comes with both 1.04 and 1.56 version support, unlike the above one, that only worked on 1.56. http://www.rumaxclub.ru/etc/maxse_081005_all.zip . |
shaktazuki | Oct 05, 2008 11:04 pm |
---|---|
Subject: Re: resource stripper help Quote: Well, the purpose of this editor is for me to be able to compare the actual resource distribution of the game to my reconstruction of the resource distribution. I wanted to be able to see the entire resource map at once rather than having to pan the viewport. My screen is 1280x800, so I am able to spend about 7x7 pixels per square of map per bitmap and keep it all on one screen, or maybe 3x3 pixels per square per bitmap to have them both on the screen at once. That reqires a special font or symbol system to represent, then writing them to the bitmap correctly (from low y to high y) and it just seems like a long process. Ideally, I suppose I could use the game's resource icons...Why should it? Quote: Thanks. I had conceptually switched Y with X, assuming that it was outputting Y lines along the X axis; as it appears, BMP readers read them as scalines in the X direction along the Y axis, which you showed me. I had made that data arrangement assumption in my editor, which was my mistake.You wrote a BMP writer without knowing about how it works? About the savegame - thank you for that information! - have you determined where the victory conditions are stored? In one scenario, for example, the victory condition is to hijack 2 enemy trucks in 40 turns, and so forth. |
Artlav | Oct 06, 2008 2:19 pm |
---|---|
Subject: Re: resource stripper help Quote by shaktazuki: Unfortunately, it appears that the conditions are hardcoded into the game itself. There are "level" field in the save game header, that corresponds to the save file number in scenario/campaign menu.have you determined where the victory conditions are stored? In one scenario, for example, the victory condition is to hijack 2 enemy trucks in 40 turns, and so forth. If you swap the files, like scn 4 and scn 1, then select scn 4, you will go into scn 1, and all the descriptions and conditions will be for scn 1. If you change the level field in scn 1 file to 4, then if you go to that scn, it will load scn 1 game, but show scn 4 descriptions, and will not respond to completing scn 1 goal, like destroy some building to win. It is certain for campaign games, it is likely for single-player scenarios. There seems to be nothing in the actual save game file that shows any kind of correlation to victory conditions besides the default ones of turns and score. |
shaktazuki | Oct 07, 2008 1:19 am |
---|---|
Subject: Re: resource stripper help Well, that sounds like a feature that can be added when AI is implemented: victory conditions (and perhaps scripted game events). Aha! My next move is to display the resource results using SDL. |
Eiko | Dec 05, 2008 2:28 pm |
---|---|
Subject: Re: resource stripper help by the way, are there any result from your resource distribution algorithm project? ![]() Our algorithm really sucks. We had several times the situation, that one player found very much metall and the other almost nothing. |
jarli | Dec 08, 2008 7:13 pm |
---|---|
Subject: Re: resource stripper help I put it aside until the mve player was done. I guess it's time to fire it back up, if there are no more MVE issues ![]() |