Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about top-left TGA field order when packing #6

Closed
Aciz opened this issue Jun 3, 2024 · 0 comments
Closed

Warn about top-left TGA field order when packing #6

Aciz opened this issue Jun 3, 2024 · 0 comments

Comments

@Aciz
Copy link
Collaborator

Aciz commented Jun 3, 2024

Not sure how trivially this could be implemented, but detecting top-left field order in itself on TGA files is very trivial. Top-left ordered TGA files draw upside-down on 2.60b clients, but correctly on ETe/ETL clients, so this is something that a mapper can easily overlook.

By checking the 17th byte of the TGA header for value 0x20, you can detect the field order of TGA files - if it's 0x20, the field order is top-left.

Sample bash script

#!/bin/sh

if [ $# -ne 1 ]; then
    echo "Usage: $0 <TGA file>"
    exit 1
fi

tga_file="$1"

if [ ! -f "$tga_file" ]; then
    echo "File not found: $tga_file"
    exit 1
fi

byte=$(xxd -s 17 -l 1 -p "$tga_file")
byte_decimal=$((16#$byte))

if (( byte_decimal & 0x20 )); then
    echo "The TGA file has a field order of top-left."
else
    echo "The TGA file has a field order of bottom-left."
fi

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants