This repository was archived by the owner on Sep 16, 2019. It is now read-only.
Open
Conversation
WAD2 is the same as WAD3 except that the miptex entries don't have a palette after the pixel data, the palette needs to be supplied externally.
Sledge.Packages/Wad/WadPackage.cs
Outdated
Owner
There was a problem hiding this comment.
I think it'd probably be cleaner to branch in the switch instead of here, maybe something like this?
case WadEntryType.Texture:
textureDataOffset = MoveToTextureData(br, out width, out height);
paletteSize = br.ReadUInt16();
paletteDataOffset = br.BaseStream.Position;
break;
case WadEntryType.QuakeTexture:
textureDataOffset = MoveToTextureData(br, out width, out height);
paletteSize = 256;
paletteDataOffset = 0;
break;
...
private long MoveToTextureData(BinaryReader br, out uint width, out uint height)
{
br.BaseStream.Position += 16; // Skip name
width = br.ReadUInt32();
height = br.ReadUInt32();
var textureDataOffset = br.BaseStream.Position + 16;
var num = (int)(width * height);
var skipMapData = (num / 4) + (num / 16) + (num / 64);
br.BaseStream.Position += 16 + num + skipMapData; // Skip mipmap offsets, texture data, mipmap texture data
return textureDataOffset;
}
Contributor
Author
There was a problem hiding this comment.
Agreed, I refactored it like that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I didn't add anything to disable this code if the game is GoldSrc; it always tries to load gfx/palette.lmp in the Document constructor, but this could be surrounded by a check for the game engine type.