It is currently 18 Apr 2024, 00:52
   
Text Size

Forge Auto-Updater

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Forge Auto-Updater

Postby Qriist » 10 Dec 2017, 20:27

Hello there, I've created a simple updater that will look for the latest snapshot on snapshots.cardforge and update your copy of Forge if something new comes along.

It will simply launch Forge if you (a) have the latest snapshot or (b) cannot connect to the internet. Though, the very first time you run it, it will go through the whole process as it doesn't have a clue as to what version you actually have.

Once it finds the need to update it will download, test file integrity, and extract all the files to the folder the updater resides. Thusly, set it in your forge folder and create a shortcut to Forge Updater.ahk/exe.

It does have one dependecy, 7za.exe, which it will attempt to automatically download from my personal storage (static links, yay!). If you are leery about this you can download 7za.exe yourself from the 7-zip homepage (it's in the portable package) and place it in the same location as the updater.

Updating Forge is kind of a pain because I never know when there is a new release. Now I don't need to. :)

This was written in AHK and the source code is provided, as is the compiled version.
Enjoy!

Source Code: (minus the actual links it connects to, due to spam filters. It is provided in the zip'd copy.)

Code: Select all
#SingleInstance,ignore
IfNotExist,%A_scriptdir%\7za.exe
{
   SplashTextOn,,,Downloading 7za
   URLDownloadToFile,(SPAM FILTER EDIT!),%a_scriptdir%\7za.exe
}
IfNotExist,%A_scriptdir%\7za.exe
{
   MsgBox,,Forge Updater,7za.exe not found.`nPlease connect to the internet!
   ExitApp
}
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SplashTextOn,250,25,Forge Updater,Checking latest snapshot
IniRead,LatestSnapshot,%a_scriptdir%\Forge Updater.ini,Forge Updater,Latest Snapshot
FileDelete,%a_scriptdir%\snapshot.html
URLDownloadToFile,(SPAM FILTER EDIT!),%A_ScriptDir%\snapshot.html
IfNotExist,%a_scriptdir%\snapshot.html
   gosub,LaunchForge
FileRead,findsnapshot,%a_scriptdir%\snapshot.html
Loop,parse,findsnapshot,`n
{
   if a_loopfield contains forge-gui-desktop
   {
      StringSplit,snapshot,a_loopfield,`"
      foundsnapshot=%snapshot2%
   }
}
If Snapshot2=%LatestSnapshot%
   gosub,LaunchForge
SplashTextOn,400,25,Forge Updater,Found %snapshot2%
sleep,5000
SplashTextOn,450,25,Forge Updater,Downloading %snapshot2%
URLDownloadToFile,(SPAM FILTER EDIT!),%a_scriptdir%\%foundsnapshot%
SplashTextOn,250,25,Forge Updater,Testing package integrity...
RunWait,%a_scriptdir%\7za.exe t "%a_scriptdir%\%foundsnapshot%",,hide UseErrorLevel
If ErrorLevel != 0
{
   SplashTextOff
   MsgBox,,Forge Updater,Update failed!`nPlease rerun.
   ExitApp
}
FileDelete,%a_scriptdir%\*.jar
SplashTextOn,250,25,Forge Updater,Extracting package...
RunWait,%a_scriptdir%\7za.exe x -aoa "%a_scriptdir%\%foundsnapshot%",,hide
StringTrimRight,foundsnapshot_revised,foundsnapshot,4
RunWait,%a_scriptdir%\7za.exe x -aoa "%a_scriptdir%\%foundsnapshot_revised%",,hide
IniWrite,%foundsnapshot%,%a_scriptdir%\Forge Updater.ini,Forge Updater,Latest Snapshot

LaunchForge:
SplashTextOn,250,25,Forge Updater,Launching Forge...
Run, %a_scriptdir%\Forge.exe
FileDelete,%a_scriptdir%\Snapshot.html
FileDelete,%a_scriptdir%\*forge-gui-desktop.tar*
Sleep,3000
ExitApp
EDIT: Minor change to the package cleanup. Consolidated a few lines.
Attachments
Forge Updater.zip
(527.63 KiB) Downloaded 218 times
Qriist
 
Posts: 3
Joined: 26 Nov 2012, 20:50
Has thanked: 0 time
Been thanked: 1 time

Re: Forge Auto-Updater

Postby churrufli » 14 Dec 2017, 06:12

Good idea!
churrufli
 
Posts: 53
Joined: 15 Feb 2016, 12:12
Has thanked: 14 times
Been thanked: 15 times

Re: Forge Auto-Updater

Postby Pux » 14 Dec 2017, 09:20

It works perfectly on my machine. I think it would be a great feature in the base game too.
Pux
 
Posts: 99
Joined: 12 Feb 2013, 13:48
Has thanked: 12 times
Been thanked: 6 times

Re: Forge Auto-Updater

Postby Qriist » 14 Dec 2017, 10:20

Thank you for the kind words. :)
Qriist
 
Posts: 3
Joined: 26 Nov 2012, 20:50
Has thanked: 0 time
Been thanked: 1 time


Return to Forge

Who is online

Users browsing this forum: No registered users and 69 guests

cron

Who is online

In total there are 69 users online :: 0 registered, 0 hidden and 69 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 69 guests

Login Form