Game Launcher

Pages: 12
Nov 17, 2009 at 4:23pm
Wow, thanks. I'll let you know I can manage it with that. :D

Meh, they don't really explain how to do it all. :\
Last edited on Nov 17, 2009 at 7:57pm
Nov 24, 2009 at 5:04pm
Bump. XD
Nov 24, 2009 at 7:24pm
If you already know how to step up a progress bar; then it shouldn't be too hard to be able to increment it every time something is done...

If you're downloading a file in chunks; then you would step the progress bar like this:
progress += (int)(operation_number / amount_of_operations) * 100;
I may have gotten the * and / the wrong way round; I do that alot... so forgive me if I have.
Nov 25, 2009 at 6:47pm
Yeah I already know how to do that. :P But what I need is to check if there are any updates. And if yes, download it. :3
Dec 5, 2009 at 7:21pm
Meh, still can't figure this out. :O
Dec 6, 2009 at 2:29am
Wait, so you want to check if the file has been changed? What are you making, like a Windows version of apt-get?

And if you want to check if the file's been changed... well, the server might store the "date of last modification" (or whatever) information. You could check it against your local copy...

Or you could compare each byte; consider the following pseudo-code:
1. download the server's file
2. open the new copy and the local copy (even if they're zipped files) for reading
3. take a line from each one
4. if the lines aren't equal, delete the old file, rename the new one. Done.
   else jump to step 3
5. If you got here that means the files are exactly the same. Delete the new version. Done.


If you regulate the server yourself, it drastically simplifies things. You can probably change the first byte of each zipped file to something like '#' if it's updated or '!' if it isn't.
Last edited on Dec 6, 2009 at 2:30am
Dec 6, 2009 at 3:09pm
Well, not a single file, more like 100+ files. So checking every file individually is not an option I think. :\ The server will be ran by someone from the team.

I'm trying to create an auto-updating game launcher. :3
Dec 6, 2009 at 3:46pm
Ahhh... that's good. In this case, make sure the server stores a file somewhere which says which files have been changed. You'd probably have to manage that manually, but you could write a program to do it for you.

Anyway; the updater downloads the file (it'd only be a few kiB at most) and reads it. The file stores links to every new file, and the updater downloads them and moves them to the appropriate directory.

In pseudo-code:
1. connect to the server
2. find and download the update file
3. For each line in the file
    connect to the server and download the file pointed by the link found in the update file
4. Delete the update file.
Last edited on Dec 6, 2009 at 3:49pm
Dec 6, 2009 at 6:22pm
I have this now:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
URLDownloadToFile(NULL, L"http://dl.dropbox.com/u/297400/Chronicles/Update.txt", L"C:\\ProgramData\\TEMP\\Update.txt", 0, NULL);
FILE* update = fopen("C:\\ProgramData\\TEMP\\Update.txt", "r");
char update_check[128];
while (fgets(update_check, sizeof update_check, update) != NULL )
{
	 if(!File::Exists("C:\\ProgramData\\TEMP\\" + Convert::ToString(update_check)))
	 {
		 LPCWSTR download_from = "http://dl.dropbox.com/u/297400/Chronicles/Data/" + update_check;
		 LPCWSTR download_to = "C:\\ProgramData\\TEMP\\Data\\" + update_check;
		 URLDownloadToFile(NULL, download_from, download_to, 0, NULL);
	 }
}
fclose(update);
File::Delete("C:\\ProgramData\\TEMP\\Update.txt");


However, the
1
2
LPCWSTR download_from = "http://dl.dropbox.com/u/297400/Chronicles/Data/" + update_check;
LPCWSTR download_to = "C:\\ProgramData\\TEMP\\Data\\" + update_check;

part returns errors. I can't combine those 2. :\


Also, when checking if the files already exist, fill up a progressbar, simultaneously. :3 And when updating, fill up another, also simultaneously. :3
Last edited on Dec 6, 2009 at 7:46pm
Dec 6, 2009 at 9:45pm
Try:

1
2
LPCWSTR download_from = "http://dl.dropbox.com/u/297400/Chronicles/Data/" + Convert::ToString(update_check);
LPCWSTR download_to = "C:\\ProgramData\\TEMP\\Data\\" + Convert::ToString(update_check);
Dec 6, 2009 at 9:46pm
Already tried it, didn't work.
But now I found something that downloads, but not all files. :\ (EDIT: Fixed now, see code below)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
if(!Directory::Exists("C:\\ProgramData\\TEMP\\Data"))
{
 Directory::CreateDirectory("C:\\ProgramData\\TEMP\\Data"); 
}
URLDownloadToFile(NULL, L"http://dl.dropbox.com/u/297400/Chronicles/Update.txt", L"C:\\ProgramData\\TEMP\\Update.txt", 0, NULL);
IO::StreamReader^ inData;
inData = IO::File::OpenText("C:\\ProgramData\\TEMP\\Update.txt");
while(inData->Peek() != -1)
{
 String^ addon = inData->ReadLine();
 String^ downloadfrom = "http://dl.dropbox.com/u/297400/Chronicles/Data/" + addon;
 String^ downloadto = "C:\\ProgramData\\TEMP\\Data\\" + addon;
 if(!File::Exists(downloadto))
 {
  pin_ptr<const wchar_t> download_from = PtrToStringChars(downloadfrom);
  pin_ptr<const wchar_t> download_to = PtrToStringChars(downloadto);
  URLDownloadToFile(NULL, reinterpret_cast<LPCWSTR>(download_from), reinterpret_cast<LPCWSTR>(download_to), 0, NULL);
 }
}
inData->Close();
File::Delete("C:\\ProgramData\\TEMP\\Update.txt");


Now only left is the progressbar thingy and updating when the form is visible. :D But how am I going to set minimums and maximums for the progressbar. :\

EDIT #345678: I got it to work now. :3 Thanks for the help all!
Last edited on Dec 7, 2009 at 6:47pm
Topic archived. No new replies allowed.
Pages: 12