1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-05 01:26:20 +00:00

Better logging in the term code

This commit is contained in:
Jonathan Coates 2023-06-01 20:28:59 +01:00
parent 5082b1677c
commit 9cca908bff
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
2 changed files with 3 additions and 8 deletions

View File

@ -20,12 +20,8 @@ import java.nio.ByteBuffer;
*/
public abstract class TermMethods {
private static int getHighestBit(int group) {
var bit = 0;
while (group > 0) {
group >>= 1;
bit++;
}
return bit;
// Equivalent to log2(group) - 1.
return 32 - Integer.numberOfLeadingZeros(group);
}
public abstract Terminal getTerminal() throws LuaException;

View File

@ -367,8 +367,7 @@ colors.toBlit(colors.red)
]]
function toBlit(color)
expect(1, color, "number")
return color_hex_lookup[color] or
string.format("%x", math.floor(math.log(color) / math.log(2)))
return color_hex_lookup[color] or string.format("%x", math.floor(math.log(color, 2)))
end
--[[- Converts the given paint/blit hex character (0-9a-f) to a color.