Author Topic: Glitch...  (Read 8832 times)

0 Members and 1 Guest are viewing this topic.

Offline Timballisto

  • Posts: 941
    • View Profile
Glitch...
« on: April 20, 2005, 07:16:41 PM »
I was in the process of building a level yesterday, and, I ran out of pieces to place (unfortunately I could've used about 200 more or so) and I had to rearrange a little and just barely finish the level.  I did accomplish this, and saved it.  When I played the level though, certain piece information was corrupted, so certain pieces would be positioned in the wrong place, be the wrong piece type, or both.

Strange.

Why do you think this is?  Also, is there any way to get to the true maximum amount of pieces without corrupting the level?

(No real request for technical help was in here (this was just interesting) so I put it in the level design board).

guest

  • Guest
Re: Glitch...
« Reply #1 on: April 20, 2005, 08:30:14 PM »
Hmm...this is good for me to know, in more ways than you realize.

I'd love to get a copy of the level you're having the problems with but it sounds like you won't consent.

My first guess as to the glitch is that perhaps when it comes to terrain, the game specifically looks for an FF FF FF FF for the "end of terrain list" marker, so if you used up all 400 slots it would keep going into the steel section in the level data and start trying to intepret those as terrain pieces, which could possibly explain the corrupted piece information.  Maybe.

(If this theory is right then you'd never be able to actually do 400 terrain pieces, unless there's a way to put FF FF FF FF in the first 4 bytes of the steel section without crashing the game.)

Offline Timballisto

  • Posts: 941
    • View Profile
Re: Glitch...
« Reply #2 on: April 21, 2005, 09:49:07 AM »
I'll get the level to you eventually, I guess.  If you make your own 400 piece level I suppose you could just experiment with that.

guest

  • Guest
Re: Glitch... (I have a fix)
« Reply #3 on: April 21, 2005, 09:50:16 AM »
Okay, I've done a little more research and I now believe that my theory is correct.

With that in mind, I have a possible method for fixing this so you can safely use all 400 terrain slots.  (Disclaimer:  I haven't actually tried this.)  Basically, if the x coordinates of all your steel areas are at least 56 or higher, then it'll turn out that when the bits for a steel area is interpreted by the game as a terrain piece, it will see an x-coordinate for the terrain piece that is off the right-hand level boundary.  As a result, whatever that terrain piece is, it won't actually be in the level.

If the level satisfies this condition, then the fix is relatively simple, providing you have the capability to hex-edit the level (when saved in the direct-save .LVL format).  Basically, the only thing left in the steel section that would be messing up the terrain is the end-of-steel-section marker, which is 4 bytes of 0.  When interpreted as a terrain piece this may result in an unwanted terrain piece falling within the level boundaries.  So instead, we will fill up the rest of the steel section with a repeat of one of your steel areas.  That way, there will never be an end-of-steel-section marker (which is okay, the game automatically stops after reading 32 steel areas).  This part can be done directly in LemEdit.

We still need to stick the end-of-terrain-section marker somewhere, otherwise the game will also interpret the level title as terrain pieces.  This is where hex-editing comes into place.  Specifically, we will stick the FF FF FF FF end-of-terrain-section marker in the first 4 bytes of the level title.  This will result in 4 glitched characters as the first 4 characters of your title, but the game's otherwise fine.  A bit of a tradeoff, but hey, the player sees the level title less often than the actual level.  (It might be possible to do this directly in LemEdit too if it somehow lets you enter the ASCII character 0xFF into the title.)

If your level don't have any steel area, for this to work you'll have to make one whose x-coordinate is 56 or higher.  This is not as bad as you might think.  You can for example stick the steel area in the middle of water, if your level uses water.  Or just stick it somewhere out of the way.  Remember though the steel area cannot stray off level boundaries or you might suffer game crashes.

guest

  • Guest
Re: Glitch...
« Reply #4 on: April 21, 2005, 10:02:38 AM »
In fact, if my theory is correct, you can actually theoretically get a maximum of 407 terrain pieces instead of just 400.  But each additional terrain pieces beyond 399 will glitch 4 more characters of your level title.

guest

  • Guest
Re: Glitch...
« Reply #5 on: April 21, 2005, 10:37:04 AM »
I have even better news:  it turns out you don't need a full FF FF FF FF to mark the end of terrain section.  Instead as soon as the game sees FF FF, it will take that as end of terrain section, no matter what the following 2 bytes are.

This means that you actually only need to glitch the first 2 characters of the level title, rather than 4.

Just to show you what a glitched title would look like, here's a screenshot after I hacked my copy of Insane Steve's "Watch Ye Step!" level  (Take that, isteve!  This is what you get for overwriting my post in the Cheapo level thread.  :P)




As you can see, the 2 glitched characters are clearly visible but not too big a deal.  It helps somewhat to insert spaces between the 2 glitched characters and the real title, as you would if you want your title to be centered on the line.

guest

  • Guest
Re: Glitch... (I have a fix)
« Reply #6 on: April 21, 2005, 10:58:14 AM »
Quote from: guest  link=1114024601/0#3 date=1114077016
Basically, if the x coordinates of all your steel areas are at least 56 or higher

Turns out I miscalculated, and the actual minimum x only needs to be 40.  Hey, even better!

guest

  • Guest
Re: Glitch... (I have a fix)
« Reply #7 on: April 21, 2005, 11:26:01 AM »
I also calculated an alternative condition, in case there are steel areas whose minimum x has to be below 40.  This alternative condition imposes a restriction on the minimum width of the steel area, for the steel areas whose minimum x is below 40.

Specifically, if the width of your steel area is at least 28, then it turns out the steel area, when intepreted as a terrain piece, will have a y coordinate that's off the level's bottom boundary and therefore not visible.  If the width of your steel area is only 24, you can still get it to work if the height of the steel area is at least 12.  It doesn't work anymore when the width of your steel area is below 24.

With three possible ways to satisfy the condition for steel areas to be intepreted as off-level-boundary terrain pieces, my method should be applicable 99% of the time.

guest

  • Guest
Re: Glitch...
« Reply #8 on: April 21, 2005, 01:45:03 PM »
Here's proof that my method works:

http://www.geocities.com/guestlevels/lemmings/400terr.zip

Inside the zip file is a levelpak (.DAT) for customized lemmings.  Make sure to examine the levels both in customized lemmings and in lemedit.  (Sorry, they aren't levels you'd actually want to play for real.)

The first level is a 400 terrain pieces level, you can clearly see that even though lemedit handles it okay, when you actually play it you get all sorts of extraneous terrain pieces.  The second level is the same 400 terrain pieces level with my fix method applied.  You can't see the steel areas though unless you look at the level in LemEdit, but I tested all 3 conditions I mentioned by making 3 distinct steel areas, and then I fill up the rest of the steel section with repeating copies of each.  The final level proves that you can indeed get 407 terrain pieces safely in a level through my trick and some hex-editing.