- Joined
- Jun 23, 2007
- Messages
- 4,066
Feel free to try and add detection for more patches. For example you could detect 1.28.1 by checking order id's (some got changed on that patch).
JASS:
local integer patch = GetPatchLevel()
if (patch == PATCH_LEVEL_127) then
call BJDebugMsg("You are on patch 1.27b or lower")
elseif (patch == PATCH_LEVEL_128) then
call BJDebugMsg("You are on patch 1.28")
elseif (patch == PATCH_LEVEL_129) then
call BJDebugMsg("You are on patch 1.29")
elseif (patch == PATCH_LEVEL_130) then
call BJDebugMsg("You are on patch 1.30.0 or 1.30.1")
elseif (patch == PATCH_LEVEL_1302) then
call BJDebugMsg("You are on patch 1.30.2, 1.30.3, 1.30.4, or higher (bye hostbots)")
elseif (patch == PATCH_LEVEL_131) then
call BJDebugMsg("You are on patch 1.31.0 or higher.")
endif
JASS:
library GameVersion
globals
constant integer PATCH_LEVEL_127 = 1
constant integer PATCH_LEVEL_128 = 2
constant integer PATCH_LEVEL_129 = 3
constant integer PATCH_LEVEL_130 = 4
constant integer PATCH_LEVEL_1302 = 5
constant integer PATCH_LEVEL_131 = 6
endglobals
function GetPatchLevel takes nothing returns integer
local image img
local string tmp
// This icon wasn't introduced until 1.28a
set img = CreateImage("ReplaceableTextures\\WorldEditUI\\Editor-Toolbar-MapValidation.blp", 64, 64, 0, 0,0,0,64,64,0, 1)
if (GetHandleId(img) == -1) then
return PATCH_LEVEL_127 // 1.27b or lower
endif
call DestroyImage(img)
// The array size limit was increased in 1.29, so if it's the same
// then we are on 1.28.
if (JASS_MAX_ARRAY_SIZE <= 8192) then
return PATCH_LEVEL_128
endif
// This string didn't exist until 1.30
if (GetLocalizedString("DOWNLOADING_MAP") == "DOWNLOADING_MAP") then
return PATCH_LEVEL_129
endif
// This string changed in 1.30.2.
set tmp = GetLocalizedString("ERROR_ID_CDKEY_INUSE")
if (SubString(tmp, StringLength(tmp)-1, StringLength(tmp)) == ")") then // check the last character to presumably support all locales
return PATCH_LEVEL_130
endif
set tmp = GetLocalizedString("WINDOW_MODE_WINDOWED")
if (tmp == "WINDOW_MODE_WINDOWED") then
return PATCH_LEVEL_1302
endif
return PATCH_LEVEL_131 // or higher
endfunction
endlibrary
Attachments
Last edited: