The super autoupdater by jack norton (bugged)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
jack_norton
Lemma-Class Veteran
Posts: 4067
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

The super autoupdater by jack norton (bugged)

#1 Post by jack_norton » Thu Jul 15, 2010 10:58 am

Ok since I have SOME (not many, but still I'd say 10-20%) of people that can't make this work I'm going to post it here.
I made it a separate .rpy file so you should be able to use it. Expert programmers only sorry, don't have time to explain how it works in details. Also, right now is probably not a good idea to use it except for testing.
I think the problem are in the threading. Not sure, since here on my PC works fine except if I shut down the game window!

Quick explanation:
since the system uses renpy.utter_restart() (line 155) to restart the game once it has finished applying the update, you need to run the updater BEFORE the main menu screen.
In the label splashscreen: if you comment the return on line 85, will run the autoupdater (and then go on with your game).
I made a simple system, I check an URL that has a index.php (had to upload as index.txt because won't let me, but rename that to index.php).
That php simply reads the directory content ON SERVER. The updates are numbered files 000000.zip,000001.zip,000002.zip and so on.
The game has a variable in options.rpy:

Code: Select all

python early:
    GameVersion=2
so it compares the gameversion with the latest available zip on server.
Example, I have gameversion=3, and latest file is 000010.zip, it will download all the zips from 4 to 10, then unzip and extract the contents into the game_dir (in mac, is inside the bundle).
NOTE: of course when you do the update you must update that value in the options.rpy file too. If you leave it to old version the program once restarts will think it still needs updating, and enter an infinite loop! So the latest .zip should contain a options.rpy with the matching GameVersion value.
A more nice way would have been to check the files on server, use a diff, or something else but as I said, I'm not a great programmer (just good :D).
The downloading uses a threading code to refresh a bar showing the percentage progress of the download.

More in detail:
line 90 - calls the function servercheck which returns ok (if has trouble connecting is false) and lastV variable which sets the last version available on server
line 112 - starts a loop, downloads all the zips from current version number to latest version available
line 122 - is_downloading is a variable True if the program is still downloading the files
line 136 - program finished downloading all files, can now proceed to extract all the zips, of course from version older to more recent

On line 158 I also download from server a text file called releasenotes.txt but that's completely optional, if you want you can skip that part (I do it because is nice to show the player what has changed).

Now, I have NO CLUE why for some people it doesn't work. Here works on Pc/Mac, and I remember pytom tested it on linux and worked fine. So, if you find and fix the bug please repost the code so everyone can benefit from this, in the name of opensource development! 8)
Attachments
index.txt
(160 Bytes) Downloaded 61 times
web.rpy
(6.36 KiB) Downloaded 58 times
follow me on Image Image Image
computer games

User avatar
Spiky Caterpillar
Veteran
Posts: 253
Joined: Fri Nov 14, 2008 7:59 pm
Completed: Lots.
Projects: Black Closet
Organization: Slipshod
Location: Behind you.
Contact:

Re: The super autoupdater by jack norton (bugged)

#2 Post by Spiky Caterpillar » Thu Jul 15, 2010 5:33 pm

If the problem manifested as checking for new versions, then not downloading the update (but possibly skipping ahead to the release notes), then it was probably a race condition around the is_downloading variable - the fix was to set it to True before starting the thread.

The new one also has a pile of extraneous prints I put in while poking it, slightly more error handling, tries to use existing zipfiles if they're already present, and downloads the zip to a .part file and then renames it.

It seems to work on my machine, but for all I know it'll catch on fire on Windows and MacOS. Or I may have introduced a Subtle Bug that I don't know about.
Attachments
web.rpy
(7.32 KiB) Downloaded 34 times
Nom nom nom nom nom LEAVES.

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4067
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: The super autoupdater by jack norton (bugged)

#3 Post by jack_norton » Thu Jul 15, 2010 5:39 pm

hah thanks! well I can try it here and see if works. If works will ask people who had problems with planet stronghold to test it :)
An autoupdater would be very useful for all games made in renpy, for everyone (in particular commercial authors but even free games).
follow me on Image Image Image
computer games

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4067
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: The super autoupdater by jack norton (bugged)

#4 Post by jack_norton » Thu Jul 15, 2010 5:42 pm

Spiky Caterpillar wrote: downloads the zip to a .part file and then renames it.
May I ask why you did this? any particular reason ?
edit: maybe I got it, to avoid extracting unfinished downloads :p
follow me on Image Image Image
computer games

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: The super autoupdater by jack norton (bugged)

#5 Post by Aleema » Fri Jul 16, 2010 8:55 am

Image SO COOL!
Thank you for posting this! I will need to wrap my head around this to see how it works and start testing it.

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4067
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: The super autoupdater by jack norton (bugged)

#6 Post by jack_norton » Sat Jul 17, 2010 3:55 am

Ok the modified version doesn't work on windows :D
The error is:

Code: Select all

Traceback (most recent call last):
  File "threading.pyo", line 532, in __bootstrap_inner
  File "C:\- indie dev -\games\renpy.new\Planet Stronghold\game/web.rpy", line 45, in run
  File "urllib.py", line 89, in urlretrieve
  File "urllib.py", line 255, in retrieve
  File "C:\- indie dev -\games\renpy.new\Planet Stronghold\game/web.rpy", line 58, in dprogress
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
looking in game directory I see still the .part file. So what doesn't work seems to be the renaming, probably the file is still in use by the urrlib.py ?
follow me on Image Image Image
computer games

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4067
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: The super autoupdater by jack norton (bugged)

#7 Post by jack_norton » Sat Jul 17, 2010 3:59 am

I think I fixed it, was enough to move the rename to def apply_update(i): , just before the unzipping :)
Attachments
web.rpy
(7.32 KiB) Downloaded 52 times
follow me on Image Image Image
computer games

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: The super autoupdater by jack norton (bugged)

#8 Post by DaFool » Sat Jul 17, 2010 12:35 pm

This looks really neat, though I'd probably need to ask for help if ever I use it.

I'm already thinking of distributing a 'shareware' version which could auto-update to 'full version' once a valid serial number is entered. And of course both versions will qualify for lifetime patching so I won't have to ask everyone to re download a new version. But if the server is down or there is no internet, the game will still run in its latest state.

I originally didn't want to provide a demo but am also ambivalent about going freeware since this latest project is taking me a lot of effort just in the asset-creation stage (plus the fact that I'll be introducing new gameplay ideas which someone else might readily clone and profit off). I also realized I am currently planning too much extra bonus content (for New Game+) which would be better suited for an 'expansion pack' of some sorts. So that's how I arrived at the 'Freemium' model.

User avatar
Aashtarsrain
Regular
Posts: 188
Joined: Thu Oct 25, 2007 3:25 pm
Projects: Speed Dater Evolution, The Magistrate
Contact:

Re: The super autoupdater by jack norton (bugged)

#9 Post by Aashtarsrain » Sun Jul 18, 2010 7:18 am

:shock:
I originally didn't want to provide a demo but am also ambivalent about going freeware since this latest project is taking me a lot of effort just in the asset-creation stage (plus the fact that I'll be introducing new gameplay ideas which someone else might readily clone and profit off). I also realized I am currently planning too much extra bonus content (for New Game+) which would be better suited for an 'expansion pack' of some sorts.
:D Hey, that's great news to me !!! I'm definitely looking towards this new project !!!! What is it about ????

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: The super autoupdater by jack norton (bugged)

#10 Post by DaFool » Mon Jul 19, 2010 10:15 am

Aashtarsrain wrote::shock:
I originally didn't want to provide a demo but am also ambivalent about going freeware since this latest project is taking me a lot of effort just in the asset-creation stage (plus the fact that I'll be introducing new gameplay ideas which someone else might readily clone and profit off). I also realized I am currently planning too much extra bonus content (for New Game+) which would be better suited for an 'expansion pack' of some sorts.
:D Hey, that's great news to me !!! I'm definitely looking towards this new project !!!! What is it about ????
It's a GxB tactical wargame. No, seriously. Probably won't find an audience though, since it's not casual gameplay (well, as 'hardcore' as selecting menu choices with a mouse can ever possibly be). After more weighing the pros and cons, I'm now thinking of just releasing a free game with the following paid DLC:

* otome gamer pack contains:
-3 extra romanceable guys with their own story paths (and playable as part of your battle team)
- extra clothing sets for all male characters
- 5 extra towns to visit with interesting NPCs that give you nice items (though not impacting main campaign and I should cut down on fetch quests since they're so cliche)
-10 charming event CGs featuring lots of 'guy-snuggling'

[cue salesman voice] Yours for $9.99!

* hikikomori pack contains:
-3 extra female characters playable as part of your battle team, one of them a definitive loli. (I am still mulling over the romanceable / GxG aspects since I'm not confident in my ability to write them convincingly)
- extra clothing sets for all female characters
- 5 optional dungeons with their own hard bosses, with awesome items rewarded after beating them (though not impacting main campaign)
- 10 ecchi event CGs featuring lots of upskirt and various other borderline hentai fetishes.

Yours for $9.99!!!

And later you will be able to buy both packs at once for $14.99!

Okay, so they're all going to be 2D pre-rendered content but at least I won't be nickel and diming like the AAA studios (horse armor for $2.50, and 5 maps pack for $15). Even by the CG list alone it's worth the price (according to DLsite which sells some CGs at a buck a piece). The default shareware game will already come with a few main event CGs, at least 3 romanceable characters and plenty of dungeons and towns out of the box. I'm even going to include an extra campaign as New Game+ (you get to play as the opposite faction as a reward for having beaten -- and presumeably enjoyed -- my game).

I'm already allocating certain events, places, scenes, and characters as optionally-tagged according to player preferences as part of the overall game design so taking them further to DLC is the more logical solution (Remember the Tales of Vesperia fiasco about the empty space for the loli pirate already existing on disc?). So I'm just following what the big honchos are doing but simply offering more for the player.

Best part is, if my game crashes and bombs -- I won't have to make the assets for the DLC in the first place and can concentrate on my next project. I originally wanted to make something episodic or a trilogy with sequels of some sort but the risk is that the first release won't be entirely self-contained. With this DLC strategy I can keep the game updated and relevant longer and hopefully get more funds to make a fully 3D sequel which I'll know I'll need more professional help with. Plus I can channel a cut of the DLC revenue to certain people whose work will have helped me tremendously and made the game possible to begin with.

So I haven't yet released a commercial game, but that means I'm willing to take the risk with this strategy which is becoming the wave of the future for both good and bad (depends on how much abuse the game companies dish out and how much consumers take it). Many indies are already taking their games multiplayer but I can only craft single-player experiences and definitely don't want online requirement only for DRM. So DLC is the next best thing.

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4067
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: The super autoupdater by jack norton (bugged)

#11 Post by jack_norton » Mon Jul 19, 2010 11:56 am

Maybe better to move this to another thread since isn't related to OP?
Anyway, I wouldn't be so sure that "Probably won't find an audience". Mostly depens how you make it, but I think a part of my customers might be interested in that kind of game.
follow me on Image Image Image
computer games

User avatar
DaFool
Lemma-Class Veteran
Posts: 4171
Joined: Tue Aug 01, 2006 12:39 pm
Contact:

Re: The super autoupdater by jack norton (bugged)

#12 Post by DaFool » Mon Jul 19, 2010 12:13 pm

LOL... anyways, I would be willing to license an implementation where you enter a serial and it downloads the additional content, assuming everything falls under some /dlc folder or something. Since I don't know anything about serial key hash generation, it's assumed you'll implement that as well. Especially if the serial is tied to some email address so people won't just be posting them all over the net.

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: The super autoupdater by jack norton (bugged)

#13 Post by Jake » Mon Jul 19, 2010 12:24 pm

DaFool wrote:Since I don't know anything about serial key hash generation, it's assumed you'll implement that as well. Especially if the serial is tied to some email address so people won't just be posting them all over the net.
On one hand, it would be relatively easy conceptually for you to sign a license file with a private key that the game then examines via your corresponding public key to check whether it's licensed or not; said license file could contain an email address, or the MAC of the PC it's running on, or whatever you want to tie the license to.

On the other hand, anyone who's determined will be able to write a crack for such an approach which simply removes the method which checks the license file for validity and replaces it with one that says "valid license" all the time.

If you want to deter JimBob in Kentucky from borrowing his mate's license and playing your game, this is [far] more than enough. If you want to deter L33t-H4X0R-69 from cracking your game and passing around a 5kb patch that removes license validation, you're going to find it very difficult to succeed anyway.
Server error: user 'Jake' not found

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4067
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: The super autoupdater by jack norton (bugged)

#14 Post by jack_norton » Mon Jul 19, 2010 1:05 pm

Yes, personally I use fullversion downloads, so I can also save bandwidth for demo. Also if you just use a serial, pirates will of course link to YOUR DEMO, and when it happened to me in the past (my old games use serial) you can easily get 40Gb DAY of downloads. So not just piracy damage for lost sales but even for wasted bandwith / extra fees (depending which hosting you use).
I never use serials anymore and I'm happy :)
follow me on Image Image Image
computer games

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]