View Single Post
froducish

JCF Member

Joined: Jan 1970

Posts: 12

froducish has disabled reputation

May 10, 2026, 04:37 PM
froducish is offline
Reply With Quote
jjPAL(...).load(): possibly false positive detection of no GIF global color table?

Save this as a mutator and test on a local server. Pay attention to chatlogger for angelscript warnings.
Code:
// Reference: https://en.wikipedia.org/wiki/GIF#Example_GIF_file
// Reference: https://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html
bool hasGlobalColorTable(string filename) {
	jjSTREAM dat(filename);
	if (dat.getSize() < 13) {
		return false;
	}
	
	string magic;
	dat.get(magic, 6);
	if (magic != "GIF89a") {
		return false;
	}
	dat.discard(2); // discard logical screen width
	dat.discard(2); // discard logical screen height
	uint8 gctFlags;
	dat.pop(gctFlags);
	if (gctFlags & 0x80 != 0) { // "the highest true bit means that the GCT is present"
		return true;
	}
	return false;
}

void onLevelBegin() {
	jjConsole("Test GIFs by typing a filename in chat");
}

bool onLocalChat(string &in stringReceived, CHAT::Type) {
	bool res1 = jjPAL().load(stringReceived);
	bool res2 = hasGlobalColorTable(stringReceived);
	if (res1 != res2) {
		jjAlert("jjPAL().load(...) != hasGlobalColorTable(...)");
		jjAlert("    " + res1 + " != " + res2);
	}
	return true;
}
Attached Images
File Type: gif globe.gif (242.0 KB, 0 views)
File Type: gif spr_tenna_freakout.gif (127.5 KB, 0 views)
File Type: gif consider.gif (499.6 KB, 0 views)
File Type: gif 1078739080889761993.gif (13.1 KB, 0 views)