Mitus Posted October 11, 2010 Author Share Posted October 11, 2010 (1/10) easy :P**Credits**_Eclipse Origins - AutoupdaterCreated by: Robin PerrisWebsite: freemmorpgmaker.com_**Requeriment**_unrar.dll in you client folder_**Client-Side**Requeriment ComponentsGo menu project in VB and components or Ctrl+TAdd components MSINET.OCXMicrosoft Internet Transfer Control 6.0(SP6)**1* –-------- Create**Create new Module and named "modUnrar"And Add in new module```Option ExplicitPrivate Const ERAR_END_ARCHIVE As Byte = 10Private Const ERAR_NO_MEMORY As Byte = 11Private Const ERAR_BAD_DATA As Byte = 12Private Const ERAR_BAD_ARCHIVE As Byte = 13Private Const ERAR_UNKNOWN_FORMAT As Byte = 14Private Const ERAR_EOPEN As Byte = 15Private Const ERAR_ECREATE As Byte = 16Private Const ERAR_ECLOSE As Byte = 17Private Const ERAR_EREAD As Byte = 18Private Const ERAR_EWRITE As Byte = 19Private Const ERAR_SMALL_BUF As Byte = 20Private Const RAR_OM_LIST As Byte = 0Private Const RAR_OM_EXTRACT As Byte = 1Private Const RAR_SKIP As Byte = 0Private Const RAR_TEST As Byte = 1Private Const RAR_EXTRACT As Byte = 2Private Const RAR_VOL_ASK As Byte = 0Private Const RAR_VOL_NOTIFY As Byte = 1Public Enum RarOperations  OP_EXTRACT = 0  OP_TEST  OP_LISTEnd EnumPrivate Type RARHeaderData  ArcName As String * 260  FileName As String * 260  Flags As Long  PackSize As Long  UnpSize As Long  HostOS As Long  FileCRC As Long  FileTime As Long  UnpVer As Long  Method As Long  FileAttr As Long  CmtBuf As String  CmtBufSize As Long  CmtSize As Long  CmtState As LongEnd TypePrivate Type RAROpenArchiveData  ArcName As String  OpenMode As Long  OpenResult As Long  CmtBuf As String  CmtBufSize As Long  CmtSize As Long  CmtState As LongEnd TypePrivate Declare Function RAROpenArchive Lib "unrar.dll" (ByRef ArchiveData As RAROpenArchiveData) As LongPrivate Declare Function RARCloseArchive Lib "unrar.dll" (ByVal hArcData As Long) As LongPrivate Declare Function RARReadHeader Lib "unrar.dll" (ByVal hArcData As Long, ByRef HeaderData As RARHeaderData) As LongPrivate Declare Function RARProcessFile Lib "unrar.dll" (ByVal hArcData As Long, ByVal Operation As Long, ByVal DestPath As String, ByVal DestName As String) As LongPrivate Declare Sub RARSetChangeVolProc Lib "unrar.dll" (ByVal hArcData As Long, ByVal Mode As Long)Private Declare Sub RARSetPassword Lib "unrar.dll" (ByVal hArcData As Long, ByVal Password As String)Public Sub RARExecute(ByVal Mode As RarOperations, ByVal RarFile As String, Optional ByVal Password As String)  ' Description:-  ' Extract file(s) from RAR archive.  ' Parameters:-  ' Mode = Operation to perform on RAR Archive  ' RARFile = RAR Archive filename  ' sPassword = Password (Optional)  Dim lHandle As Long  Dim iStatus As Integer  Dim uRAR As RAROpenArchiveData  Dim uHeader As RARHeaderData  Dim sStat As String, Ret As Long  uRAR.ArcName = RarFile  uRAR.CmtBuf = Space(16384)  uRAR.CmtBufSize = 16384  If Mode = OP_LIST Then    uRAR.OpenMode = RAR_OM_LIST  Else    uRAR.OpenMode = RAR_OM_EXTRACT  End If  lHandle = RAROpenArchive(uRAR)  If uRAR.OpenResult <> 0 Then    Kill RarFile    OpenError uRAR.OpenResult, RarFile  End If  If Password <> "" Then RARSetPassword lHandle, Password  If (uRAR.CmtState = 1) Then MsgBox uRAR.CmtBuf, vbApplicationModal + vbInformation, "Comment"  iStatus = RARReadHeader(lHandle, uHeader)  Do Until iStatus <> 0    sStat = Left(uHeader.FileName, InStr(1, uHeader.FileName, vbNullChar) - 1)    Select Case Mode    Case RarOperations.OP_EXTRACT      Ret = RARProcessFile(lHandle, RAR_EXTRACT, "", uHeader.FileName)    Case RarOperations.OP_TEST      Ret = RARProcessFile(lHandle, RAR_TEST, "", uHeader.FileName)    Case RarOperations.OP_LIST      Ret = RARProcessFile(lHandle, RAR_SKIP, "", "")    End Select    If Ret = 0 Then      ProcessError Ret    End If    iStatus = RARReadHeader(lHandle, uHeader)  Loop  If iStatus = ERAR_BAD_DATA Then    MsgBox "File header broken", vbCritical    DestroyUpdater  End If  RARCloseArchive lHandleEnd Sub' Error handlingPrivate Sub OpenError(ErroNum As Long, ArcName As String)Dim erro As String  Select Case ErroNum    Case ERAR_NO_MEMORY      erro = "Not enough memory"      GoTo errorbox    Case ERAR_EOPEN:      erro = "Cannot open " & ArcName      GoTo errorbox    Case ERAR_BAD_ARCHIVE:      erro = ArcName & " is not RAR archive"      GoTo errorbox    Case ERAR_BAD_DATA:      erro = ArcName & ": archive header broken"      GoTo errorbox  End Select  Exit Suberrorbox:  MsgBox erro, vbCritical  DestroyUpdaterEnd SubPrivate Sub ProcessError(ErroNum As Long)Dim erro As String  Select Case ErroNum    Case ERAR_UNKNOWN_FORMAT      erro = "Unknown archive format"      GoTo errorbox    Case ERAR_BAD_ARCHIVE:      erro = "Bad volume"      GoTo errorbox    Case ERAR_ECREATE:      erro = "File create error"      GoTo errorbox    Case ERAR_EOPEN:      erro = "Volume open error"      GoTo errorbox    Case ERAR_ECLOSE:      erro = "File close error"      GoTo errorbox    Case ERAR_EREAD:      erro = "Read error"      GoTo errorbox    Case ERAR_EWRITE:      erro = "Write error"      GoTo errorbox    Case ERAR_BAD_DATA:      erro = "CRC error"      GoTo errorbox  End Select  Exit Suberrorbox:  MsgBox erro, vbCritical  DestroyUpdaterEnd Sub```**2* –-------- In modGeneral**Find```Public DX7 As New DirectX7 ' Master Object, early binding```and add below one line```' file hostPrivate UpdateURL As String' stores the variables for the version downloadersPrivate VersionCount As Long```Find "Public Sub Main()" and find```' Reset values  Ping = -1```and add below one line```If Not FileExists(App.Path & "\Data Files\updaterInfo.ini") Then DestroyUpdater  UpdateURL = GetVar(App.Path & "\Data Files\updaterInfo.ini", "UPDATER", "updateURL")```Next find "Public Function isStringLegal"and add below of subNew subs```Public Sub DestroyUpdater()  ' kill temp files  If FileExists(App.Path & "\tmpUpdate.ini") Then Kill App.Path & "\tmpUpdate.ini"  ' end updater  Unload frmMenu  EndEnd SubPublic Sub Update()Dim CurVersion As LongDim FileName As StringDim I As Long  AddProgress "Connecting to server..."  ' get the file which contains the info of updated files  DownloadFile UpdateURL & "/update.ini", App.Path & "\tmpUpdate.ini"  AddProgress "Connected to server!"  AddProgress "Retrieving version information."  ' read the version count  VersionCount = GetVar(App.Path & "\tmpUpdate.ini", "FILES", "Versions")  ' check if we've got a current client version saved  If FileExists(App.Path & "\Data Files\version.ini") Then    CurVersion = GetVar(App.Path & "\Data Files\version.ini", "UPDATER", "CurVersion")  Else    CurVersion = 0  End If  ' are we up to date?  If CurVersion < VersionCount Then    ' make sure it's not 0!    If CurVersion = 0 Then CurVersion = 1    ' loop around, download and unrar each update    For I = CurVersion To VersionCount      ' let them know!      AddProgress "Downloading version " & I & "."      FileName = "version" & I & ".rar"      ' set the download going through inet      DownloadFile UpdateURL & "/" & FileName, App.Path & "\" & FileName      ' us the unrar.dll to extract data      RARExecute OP_EXTRACT, FileName      ' kill the temp update file      Kill App.Path & "\" & FileName      ' update the current version      PutVar App.Path & "\Data Files\version.ini", "UPDATER", "CurVersion", Str(I)      ' let them know!      AddProgress "Version " & I & " installed."    Next    ' let them know the update has finished    AddProgress ""    AddProgress "Update Complete!"    AddProgress "You can now exit the updater.", False    AddProgress ""  Else    ' they're at the correct version, or perhaps higher!    AddProgress ""    AddProgress "You are completely up to date!"    AddProgress "You can now exit the updater.", False    AddProgress ""    frmMenu.cmdEnter.Visible = True  End IfEnd SubPublic Sub AddProgress(ByVal sProgress As String, Optional ByVal newline As Boolean = True)  ' add a string to the textbox on the form  frmMenu.txtProgress.text = frmMenu.txtProgress.text & sProgress  If newline = True Then frmMenu.txtProgress.text = frmMenu.txtProgress.text & vbNewLineEnd SubPrivate Sub DownloadFile(ByVal URL As String, ByVal FileName As String)  Dim fileBytes() As Byte  Dim fileNum As Integer  On Error GoTo DownloadError  ' download data to byte array  fileBytes() = frmMenu.inetDownload.OpenURL(URL, icByteArray)  fileNum = FreeFile  Open FileName For Binary Access Write As #fileNum    ' dump the byte array as binary    Put #fileNum, , fileBytes()  Close #fileNum  Exit SubDownloadError:  MsgBox Err.DescriptionEnd Sub```**3* –-------- modDatabase**Find "Public Function FileExist"And add below subnew sub```Public Function FileExists(ByVal FileName As String, Optional RAW As Boolean = False) As Boolean   If LenB(Dir(FileName)) > 0 Then FileExists = TrueEnd Function```OBS: Need add new Public FUnction FileExist**"S"** not use "Public Function FileExist"Next**4* –-------- frmMenu**in frmMenu find```Dim AlignText As Integer  Me.Show```and add below one line```  AddProgress "Welcome to the Eclipse Origins autoupdater."  AddProgress "Press 'Connect' to update your client."  AddProgress ""  ' call the update sub  Update```in frmMenu below sub Form_LoadAdd below sub, new sub```Private Sub cmdEnter_Click()  picUpdate.Visible = FalseEnd Sub```**5* –-------- frmMainGame**In frmMainGame, find "Private Sub imgExit_Click()"in sub find```txtChat.text = vbNullString```and add below one line```frmMenu.picUpdate.Visible = False```**6* –-------- Edit frmMenu**Now here is ghaphicsyou modifique for you preferences1 - Create new PictureBox, full size of frmMenu or not you prefenceand give name "picUpdate"2 - In new PictureBox, create textBoxand give name "txtProgress"in properties of textbox change* Locked for True* Multiline for True* ScrollBars for 2 - Vertical3 - In new PictureBox, create Inet 'you new componentand give name "inetDownload"4 - In new PictureBox, create CommandButtonand give name "cmdEnter"**7* –-------- INI Files**In folder "\Data Files" create a ini file name "updaterInfo"And add```[UPDATER]updateURL= http://yousite/update```**Server-Side**Now is for you site or folderCreate in folder update ini file name "update"And add```[FILES]versions=1version1=version1.rar```**Exemple** _[FILES]versions=3version1=version1.rarversion2=version2.rarversion3=version3.raretc._ –-------------------------------**Now is Done :D**SORRY ME ENGLISH NOT IS GOOD :S Link to comment Share on other sites More sharing options...
kibbelz Posted October 13, 2010 Share Posted October 13, 2010 Nice, i will test this out later. Link to comment Share on other sites More sharing options...
Gohan Posted October 13, 2010 Share Posted October 13, 2010 Umm… how is this supposed to update if the changes you made are within the client's source? To update, would it not have to extract the new client over the old one, therefore deleting the old one? How can it continue the update if it's been deleted? Link to comment Share on other sites More sharing options...
Robin Posted October 13, 2010 Share Posted October 13, 2010 This won't let you update the actual executable though. >_> Link to comment Share on other sites More sharing options...
Gohan Posted October 13, 2010 Share Posted October 13, 2010 Maybe you could have it extract the new executable and add the new version number to to the file name. After that have it start the new version then delete itself? Could that be done? Link to comment Share on other sites More sharing options...
Robin Posted October 13, 2010 Share Posted October 13, 2010 That's a stupid way of doing it. Pretty much all mainstream games have a separate updater. It's like that for a reason. Link to comment Share on other sites More sharing options...
ÃËœÂÃËœÂØ Posted October 31, 2010 Share Posted October 31, 2010 I've modified robin's updater into my game, as seperate program. If you lauch the client, it first checks lauches the updater, if there is no update, it lets you in the game, by clicking a button on the updater. You cannot play until you've updated.Besides, this DOESN'T work, because it will not let you overwrite your client.exe as the program is running. Link to comment Share on other sites More sharing options...
erkro1 Posted December 4, 2010 Share Posted December 4, 2010 I have a question : does this also work with version like this :1.1.4 or 1.1? Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2010 Share Posted December 4, 2010 It doesn't work with anything, Erkro. Link to comment Share on other sites More sharing options...
Aramyth Posted December 4, 2010 Share Posted December 4, 2010 @Robin:> This won't let you update the actual executable though. >_>That's exactly the reason why i removed the Unrar process from my updater and made a standalone "Unrar - "patch installer" application so that the client + updater and all the other rest can be patched without a problem. Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2010 Share Posted December 4, 2010 @Aramyth:> @Robin:> > > This won't let you update the actual executable though. >_>> > That's exactly the reason why I removed the Unrar process from my updater and made a standalone "Unrar - "patch installer" application so that the client + updater and all the other rest can be patched without a problem.Post a tutorial on it then ;D Link to comment Share on other sites More sharing options...
Aramyth Posted December 4, 2010 Share Posted December 4, 2010 Ok i will make one today in the source code tutorial section. Link to comment Share on other sites More sharing options...
Guest Posted December 4, 2010 Share Posted December 4, 2010 Looking forward to it :P. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now