diff --git a/BrokenBot.au3 b/BrokenBot.au3 index df3a786..73fbf07 100644 --- a/BrokenBot.au3 +++ b/BrokenBot.au3 @@ -3,12 +3,12 @@ #pragma compile(Icon, "BrokenBot.org\images\icons\brokenbot.ico") #pragma compile(FileDescription, BrokenBot.org - Clash of Clans Bot) #pragma compile(ProductName, BrokenBot.org - Clash of Clans Bot) -#pragma compile(ProductVersion, 2.5.1) -#pragma compile(FileVersion, 2.5.1) +#pragma compile(ProductVersion, 2.5.2) +#pragma compile(FileVersion, 2.5.2) #include -$sBotVersion = "2.5.1" +$sBotVersion = "2.5.2" $sBotTitle = "BrokenBot.org - Break FREE - v" & $sBotVersion Global $StartupLanguage = IniRead(@ScriptDir & "\config\default.ini", "config", "language", "English") @@ -70,6 +70,19 @@ If IsArray($CmdLine) Then EndIf EndIf +_CaptureRegion() +Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) +$ret = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotRedLineCheck", "ptr", $hHBitmap, "int", 1, "int", 1, "int", 0, "int", 0, "int", 0) +_WinAPI_DeleteObject($hHBitmap) +If Not IsArray($ret) Then + If MsgBox($MB_ICONWARNING + $MB_OKCANCEL, GetLangText("msgMissing"), GetLangText("msgMissing1") & @CRLF & @CRLF & GetLangText("msgMissing2") & @CRLF & @CRLF & GetLangText("msgMissing3") & " " & GetLangText("msgMissing4") & " " & GetLangText("msgMissing5") & @CRLF & @CRLF & GetLangText("msgMissing6")) = $IDOK Then + ShellExecute("https://www.microsoft.com/en-us/download/details.aspx?id=40784") + _GDIPlus_Shutdown() + _GUICtrlRichEdit_Destroy($txtLog) + Exit + EndIf +EndIf + While 1 If $StartImmediately Then $StartImmediately = False diff --git a/BrokenBot.exe b/BrokenBot.exe index 79eef8c..e597dbf 100644 Binary files a/BrokenBot.exe and b/BrokenBot.exe differ diff --git a/BrokenBot.org/functions/Other/checkupdate.au3 b/BrokenBot.org/functions/Other/checkupdate.au3 index 62319a8..208127f 100644 --- a/BrokenBot.org/functions/Other/checkupdate.au3 +++ b/BrokenBot.org/functions/Other/checkupdate.au3 @@ -1,4 +1,60 @@ -; This code was created for public use by BrokenBot.org and falls under the GPLv3 license. +; #FUNCTION# ;=============================================================================== +; +; Name...........: _ExtractZip +; Description ...: Extracts file/folder from ZIP compressed file +; Syntax.........: _ExtractZip($sZipFile, $sDestinationFolder) +; Parameters ....: $sZipFile - full path to the ZIP file to process +; $sDestinationFolder - folder to extract to. Will be created if it does not exsist exist. +; Return values .: Success - Returns 1 +; - Sets @error to 0 +; Failure - Returns 0 sets @error: +; |1 - Shell Object creation failure +; |2 - Destination folder is unavailable +; |3 - Structure within ZIP file is wrong +; |4 - Specified file/folder to extract not existing +; Author ........: trancexx, modifyed by corgano +; +;========================================================================================== +Func _ExtractZip($sZipFile, $sDestinationFolder, $sFolderStructure = "") + + Local $i + Do + $i += 1 + $sTempZipFolder = @TempDir & "\Temporary Directory " & $i & " for " & StringRegExpReplace($sZipFile, ".*\\", "") + Until Not FileExists($sTempZipFolder) ; this folder will be created during extraction + + Local $oShell = ObjCreate("Shell.Application") + + If Not IsObj($oShell) Then + Return SetError(1, 0, 0) ; highly unlikely but could happen + EndIf + + Local $oDestinationFolder = $oShell.NameSpace($sDestinationFolder) + If Not IsObj($oDestinationFolder) Then + DirCreate($sDestinationFolder) +;~ Return SetError(2, 0, 0) ; unavailable destionation location + EndIf + + Local $oOriginFolder = $oShell.NameSpace($sZipFile & "\" & $sFolderStructure) ; FolderStructure is overstatement because of the available depth + If Not IsObj($oOriginFolder) Then + Return SetError(3, 0, 0) ; unavailable location + EndIf + + Local $oOriginFile = $oOriginFolder.Items();get all items + If Not IsObj($oOriginFile) Then + Return SetError(4, 0, 0) ; no such file in ZIP file + EndIf + + ; copy content of origin to destination + $oDestinationFolder.CopyHere($oOriginFile, 20) ; 20 means 4 and 16, replaces files if asked + + DirRemove($sTempZipFolder, 1) ; clean temp dir + + Return 1 ; All OK! + +EndFunc + +; The code below was created for public use by BrokenBot.org and falls under the GPLv3 license. ; This code can be incorporated into open source/non-profit projects free of charge and without consent. ; **NOT FOR COMMERCIAL USE** by any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org ; You **MAY NOT SOLICIT DONATIONS** from any project which includes any part of the code in this sub-directory without express written consent of BrokenBot.org @@ -21,11 +77,52 @@ Func checkupdate() SetLog(GetLangText("msgVersionOnline") & $split[2]) If $sBotVersion < $split[2] Then SetLog(GetLangText("msgUpdateNeeded")) - If MsgBox($MB_OKCANCEL, GetLangText("boxUpdate"), GetLangText("boxUpdate2") & @CRLF & @CRLF & GetLangText("boxUpdate3") & @CRLF & GetLangText("boxUpdate4") & @CRLF & @CRLF & GetLangText("boxUpdate5"), 0, $frmBot) = $IDOK Then - ShellExecute("https://github.com/codebroken/BrokenBot") - _GDIPlus_Shutdown() - _GUICtrlRichEdit_Destroy($txtLog) - Exit + InetGet("https://raw.githubusercontent.com/codebroken/BrokenBot/master/changelog.md", @TempDir & "\brokenbotchangelog.md", 3) + $strReleaseNotes = "" + $fileopen = FileOpen(@TempDir & "\brokenbotchangelog.md") + If @error Then SetLog(GetLangText("msgFailedVersion")) + FileReadLine($fileopen) + FileReadLine($fileopen) + While True + $line = FileReadLine($fileopen) + If @error Then ExitLoop + If StringLeft($line, 3) = "###" Then + If StringReplace($line, "### v", "") <= $sBotVersion Then + ExitLoop + EndIf + EndIf + If StringStripWS($line, 3) <> "" Then SetLog($line) + $strReleaseNotes = $strReleaseNotes & StringReplace($line, "### ", "") & @CRLF + WEnd + FileClose($fileopen) + FileDelete(@TempDir & "\brokenbotchangelog.md") + If MsgBox($MB_OKCANCEL, GetLangText("boxUpdate"), GetLangText("boxUpdate2") & @CRLF & @CRLF & GetLangText("boxUpdate3") & @CRLF & @CRLF & GetLangText("boxUpdate5") & @CRLF & @CRLF & GetLangText("boxUpdate6") & @CRLF & @CRLF & $strReleaseNotes, 0, $frmBot) = $IDOK Then + SetLog(GetLangText("msgDownloading")) + InetGet("https://github.com/codebroken/BrokenBot/archive/master.zip", @TempDir & "\BrokenBot-master.zip", 3) + If Not FileExists(@TempDir & "\BrokenBot-master.zip") Then + MsgBox(0, "", GetLangText("boxUpdateError")) + Else + SetLog(GetLangText("msgUnzipping")) + If not FileExists(@TempDir & "\TempUpdateFolder") Then + DirCreate(@TempDir & "\TempUpdateFolder") + EndIf + If _ExtractZip(@TempDir & "\BrokenBot-master.zip", @TempDir & "\TempUpdateFolder") <> 1 Then + MsgBox(0, "", GetLangText("boxUpdateExtract")) + Else + SetLog(GetLangText("msgInstallandRestart")) + _GDIPlus_Shutdown() + $fileopen = FileOpen(@TempDir & "\brokenbotupdate.bat", 2) + FileWriteLine($fileopen, 'xcopy "' & @TempDir & '\TempUpdateFolder\BrokenBot-master\*.*" "' & @ScriptDir & '\" /S /E /Y') + FileWriteLine($fileopen, 'del "' & @TempDir & '\TempUpdateFolder\*.*" /S /Q') + FileWriteLine($fileopen, 'del "' & @TempDir & '\BrokenBot-master.zip" /S /Q') + FileWriteLine($fileopen, 'rd "' & @TempDir & '\TempUpdateFolder" /S /Q') + FileWriteLine($fileopen, 'start "" /D "' & @ScriptDir & '\" BrokenBot.exe') + FileClose($fileopen) + _GUICtrlRichEdit_Destroy($txtLog) + Run(@ComSpec & ' /c "' & @TempDir & '\brokenbotupdate.bat"', @SystemDir, @SW_SHOW) + Exit + EndIf + EndIf EndIf ElseIf $sBotVersion > $split[2] Then SetLog(GetLangText("msgAheadMaster")) @@ -43,3 +140,4 @@ Func checkupdate() EndIf EndIf EndFunc ;==>checkupdate + diff --git a/BrokenBot.org/languages/English.ini b/BrokenBot.org/languages/English.ini index 078fd22..7414a7e 100644 --- a/BrokenBot.org/languages/English.ini +++ b/BrokenBot.org/languages/English.ini @@ -324,6 +324,13 @@ btnCloseBR = "Close" heroSkill = "0 = Activate at low HP" heroSkill2 = ">0 = Activate after number of seconds" lblDisconnected = "Disconnected :" +msgMissing = "Missing required file!" +msgMissing1 = "Your system appears to be missing a required file (MSVCP120.DLL) for redline detection to work." +msgMissing2 = "You may continue but the bot will not work as intended." +msgMissing3 = "Click OK to exit the bot and be directed to Microsoft's site to download the appropriate file." +msgMissing4 = "Make sure you download the 32 bit version, regardless of your computer being 32 or 64 bit." +msgMissing5 = "When given the option, choose the file: vcredist_x86.exe" +msgMissing6 = "Click Cancel to continue using the bot without this function." msgRestartNeeded = "Your newly selected language will not take full effect until you restart." msgExit = "Exiting !!!" msgFailedVersion = "Failed to check updated version info." @@ -582,14 +589,20 @@ msgTrophyInitial = "T" msgGemInitial = "GEM" msgTHInitial = "TH" msgDeadInitial = "Dead" +msgDownloading = "Downloading update..." +msgUnzipping = "Successful! Unzipping..." +msgInstallandRestart = "Successful! Installing and restarting..." boxAlreadyRunning = "Bot is already running." boxCompile1 = "Don't Run/Compile Script (x64)! try to Run/Compile Script (x86) to getting this bot work." boxCompile2 = "If this message still appear, try to re-install your AutoIt with newer version." boxUpdate = "Update needed!" -boxUpdate2 = "There is a newer version available online." -boxUpdate3 = "Press OK to open GitHub website and shutdown bot." -boxUpdate4 = "You will need to install and compile the new version." +boxUpdate2 = "There is a newer version of BrokenBot available online." +boxUpdate3 = "Click OK and update will be automatically installed and applied." +boxUpdate4 = "" boxUpdate5 = "Or click cancel to skip." +boxUpdate6 = "Here is what you are missing out on:" +boxUpdateError = "Error downloading update!" +boxUpdateExtract = "Error extracting the update" boxRestart = "Restart Computer" boxRestart2 = "Restart your computer for the applied changes to take effect." boxRestart3 = "If your BlueStacks is the correct size (860 x 720), click OK." diff --git a/COCBot/GUI Control.au3 b/COCBot/GUI Control.au3 index af1096e..a136910 100644 --- a/COCBot/GUI Control.au3 +++ b/COCBot/GUI Control.au3 @@ -100,7 +100,7 @@ Func GUIControl($hWind, $iMsg, $wParam, $lParam) Case $lblpushbulletenabled lblpushbulletenabled() Case $btnGitHub - ShellExecute("http://www.brokenbot.org/forum/index.php?u=/category/support-forums") + ShellExecute("http://http://forum.brokenbot.org/forum-8.html") Case $btnCloseBR GUISetState(@SW_ENABLE, $frmBot) GUISetState(@SW_HIDE, $frmBugReport) diff --git a/COCBot/Global Variables.au3 b/COCBot/Global Variables.au3 index d869117..c00edcd 100644 --- a/COCBot/Global Variables.au3 +++ b/COCBot/Global Variables.au3 @@ -21,6 +21,7 @@ #include #include #include +#include Global Const $COLOR_ORANGE = 0xFFA500 diff --git a/COCBot/functions/Config/readConfig.au3 b/COCBot/functions/Config/readConfig.au3 index 01b23ca..5d06c23 100644 --- a/COCBot/functions/Config/readConfig.au3 +++ b/COCBot/functions/Config/readConfig.au3 @@ -109,6 +109,11 @@ Func readConfig() ;Reads config and sets it to the variables Else GUICtrlSetState($chkUpdate, $GUI_UNCHECKED) EndIf + If IniRead($config, "config", "stayalive", "0") = 1 Then + GUICtrlSetState($chkStayAlive, $GUI_CHECKED) + Else + GUICtrlSetState($chkStayAlive, $GUI_UNCHECKED) + EndIf ;--------------------------------------------------------------------------------------- ; Base location settings --------------------------------------------------------------- diff --git a/COCBot/functions/Config/saveConfig.au3 b/COCBot/functions/Config/saveConfig.au3 index 9e271d1..765d797 100644 --- a/COCBot/functions/Config/saveConfig.au3 +++ b/COCBot/functions/Config/saveConfig.au3 @@ -282,6 +282,11 @@ Func saveConfig() ;Saves the controls settings to the config Else IniWrite($config, "config", "chkUpdate", 0) EndIf + If IsChecked($chkStayAlive) Then + IniWrite($config, "config", "stayalive", 1) + Else + IniWrite($config, "config", "stayalive", 0) + EndIf ;--------------------------------------------------------------------------------------- ; Base location settings --------------------------------------------------------------- diff --git a/COCBot/functions/Other/RedLineDeploy.au3 b/COCBot/functions/Other/RedLineDeploy.au3 index 6e95811..0c333fc 100644 --- a/COCBot/functions/Other/RedLineDeploy.au3 +++ b/COCBot/functions/Other/RedLineDeploy.au3 @@ -186,10 +186,18 @@ Func SeekEdges() $ret = DllCall(@ScriptDir & "\BrokenBot.org\BrokenBot32.dll", "str", "BrokenBotRedLineCheck", "ptr", $hHBitmap, "int", $mH, "int", $mS, "int", $ci, "int", $cl, "int", $cr) _WinAPI_DeleteObject($hHBitmap) - $Array = StringSplit($ret[0], "|", 2) - For $i = 0 to (43*43)-1 - $Grid[Floor($i/43)][Mod($i, 43)][2] = $Array[$i] - Next + If IsArray($ret) Then + $Array = StringSplit($ret[0], "|", 2) + For $i = 0 to (43*43)-1 + $Grid[Floor($i/43)][Mod($i, 43)][2] = $Array[$i] + Next + Else + For $i = 0 To 42 + For $j = 0 To 42 + $Grid[$i][$j][2] = 1 + Next + Next + EndIf SetLog(GetLangText("msgDone"), $COLOR_BLUE) EndFunc ;==>SeekEdges diff --git a/README.md b/README.md index d0b5d94..52e894d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # BrokenBot.org - Clash of Clans Bot -Latest version: 2.5.1 +Latest version: 2.5.2 ## Community Forums available for discussion at: http://brokenbot.org/ diff --git a/changelog.md b/changelog.md index fa5f44d..9859f38 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ ## Change Log: +### v2.5.2 +* Improved auto-update. Now bot actually can download and apply the update for you. +* Improved DLL error detection. Informs the user if they are missing the proper version and directs them about how to resolve. Falls back to dropping troops at the edge if DLL isn't working. + ### v2.5.1 * Added DLL dependancy for some machines that may be missing it.