Skip to content

Commit 444d7f4

Browse files
authored
Fixed big-endian (DPLWii) bug for all HUD versions
1 parent fa1c1d5 commit 444d7f4

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

VisualEdit.wlua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ end
1717
local elementSizeBytes = 48
1818
local elementSizeBytesDPL = 112 -- bigger, isn't it?
1919
local supportedVersion = {37049,37053,61862}
20+
local WiiVerMagic = 18000
2021
local typeNames = {
2122
[1] = "Drawable",
2223
[2] = "Reserved (on car)",
@@ -50,7 +51,7 @@ function binaryHUDFile(buffer,ver)
5051
Height = string.unpack("f",string.sub(buffer,15+8,64)), --720,
5152
Elements = {}
5253
}
53-
print(string.format("Align: %d, Count: %d, Version: %d",align,count,HUD.Version))
54+
print(string.format("Align: %d, Count: %d, Version: %d, Magic: %d",align,count,HUD.Version,HUD.Magic))
5455
local dpl = HUD.Version == 37053 or HUD.Version == 61862
5556
--local off = align
5657
--[[
@@ -109,7 +110,7 @@ function binaryHUDFile(buffer,ver)
109110
elseif HUD.Version == 37053 or HUD.Version == 61862 then
110111
--print("DRIVER POROLOLELLAINES")
111112
local fmt = elementFormatDPL
112-
if HUD.Magic>=1800 then fmt = ">"..fmt end -- checks if it's Wii so we can make the order big-endian
113+
if HUD.Magic>=WiiVerMagic then fmt = ">"..fmt else fmt = elementFormatDPL end -- checks if it's Wii so we can make the order big-endian
113114
r,g,b,a,x,y,w,h,input,unk1,sx,sy,unk2,unk3,id,flags,unk4,unk5,unk6,unk7,unk8,unk9,unk10,unk11,unk12,unk13,unk14,unk15 = string.unpack(fmt,string.sub(buffer,off,off+elementSizeBytesDPL+64))
114115
-- main
115116
elemtable.Type = 0
@@ -168,7 +169,7 @@ function newBinaryHUDFile(HUD)
168169
bin = string.pack(elementFormat,elemtable.Type, elemtable.Align,elemtable.Unk2,elemtable.Unk3,elemtable.Input,elemtable.ID,elemtable.X,elemtable.Y,elemtable.Width,elemtable.Height,elemtable.SizeX,elemtable.SizeY,elemtable.R,elemtable.G,elemtable.B,elemtable.A)
169170
elseif HUD.Version == 37053 then
170171
local fmt = elementFormatDPL
171-
if HUD.Magic>=1800 then fmt = ">"..fmt end -- checks if it's Wii so we can make the order big-endian
172+
if HUD.Magic>=WiiVerMagic then fmt = ">"..fmt end -- checks if it's Wii so we can make the order big-endian
172173
local r,g,b,a,x,y,w,h,input,unk1,sx,sy,unk2,unk3,id,flags,unk4,unk5,unk6,unk7,unk8,unk9,unk10,unk11,unk12,unk13,unk14,unk15 = elemtable.R, elemtable.G,elemtable.B,elemtable.A,elemtable.X,elemtable.Y,elemtable.Width,elemtable.Height,elemtable.Input,elemtable.Unk1,elemtable.SizeX,elemtable.SizeY,elemtable.Unk2,elemtable.Unk3,elemtable.ID,elemtable.Flags,elemtable.Unk4,elemtable.Unk5,elemtable.Unk6,elemtable.Unk7,elemtable.Unk8,elemtable.Unk9,elemtable.Unk10,elemtable.Unk11,elemtable.Unk12,elemtable.Unk13,elemtable.Unk14,elemtable.Unk15
173174
print(sx,sy,w,h)
174175
print(id)
@@ -392,9 +393,9 @@ local HelpMenu = ui.Menu()
392393
win.menu:add("&Help").submenu = HelpMenu
393394
local aboutButton = HelpMenu:add("&About\tF1")
394395
local helpButton = HelpMenu:add("&How to Use")
395-
local build = "Version 0.1B Oct. 31" --"Build October 27 9485"
396+
local build = "Version 0.1BA Oct. 31" --"Build October 27 9485"
396397
function aboutButton:onClick()
397-
ui.info("MADE IN BRAZIL\nMade with LuaRT Lua Framework v1.5.2\nAuthor: BuilderDemo7\nBeta Testers: NismoRacer00 & Sunrise_424\n\t"..build,"About")
398+
ui.info("Made with LuaRT Lua Framework v1.5.2\nAuthor: BuilderDemo7\nBeta Testers: NismoRacer00 & Sunrise_424\n\t"..build,"About")
398399
end
399400
win:shortcut("f1", aboutButton.onClick)
400401
function helpButton:onClick()

0 commit comments

Comments
 (0)