Revenge of the Source Code

Finally as promised, you can take a look at the source code to Revenge of the Titans here. Inside that zip file you will find:

  • A src folder containing all the Java and XML source code. Yes, the package name is “worm”. It’s a long story. The whole project was codenamed Ultraworm.
  • A docs folder containing some licenses and a readme.
  • A libs folder containing the Java dependencies for the project.

License

Now read this carefully: you can do what you want with the contents of that zip, provided you leave the license header alone that’s at the top of each file and respect its meaning (and the licenses of the various libraries). Make your own RTS or Tower Defence game, pinch any bits of code you like from within (in which case the license header is probably in a grey area but… I don’t care much), or maybe make some mods for Revenge of the Titans itself.

What you absolutely may not do is redistribute our assets – that’s the graphics and sounds and music – without our express permission, which if I don’t know you quite well, you are unlikely to get. Although some of the sound in the game comes from the incredibly awesome Freesound.org project, the oggs and jars are still ours; if you want the original .wav files which are licensed under the creative commons license, we’ve included links to every one of them in the docs.

You may also absolutely not use the name “Revenge of the Titans”, “Puppygames”, or “Shaven Puppy Ltd” when redistributing any derivative works without our express permission, as that’d again be stepping on our trademarks.

Some bright spark might cunningly put the lot up on github or sourceforge or whatever – go ahead. Said bright spark might also produce an Ant build.xml file.

Support

This is very important: I have almost no time to actually support this source code and your many complicated questions about how it works. If you’re asking me much about how it works in the first place I suspect you shouldn’t be bothering to look at the source anyway.

Anyone who emails the support email address about the source code will be ignored, after being hung by the foreskin until sorry.

Other than that: I now apologise in advance for the extremely crappy code and terrible inaccurate or nonexistent commenting! It just grew that way. In fact it’s all been growing for 10 years and the subject of constant bodging, retrofitting, and general breaking and poor design. I have it on good authority from Markus that it’s not quite as horrible as the Minecraft code but I suspect it’s not far off.

Making Mods

The one area where I will help out is making mods for the game. However, it’s quite an advanced sort of subject, and I shall expound upon exactly how to do this in a forthcoming blog post.

Other News

I got another 2000 keys from Steam, just as we were about to run out. And finally the Steam version has been patched to v1.80.11. The Mac version is imminent.

78 thoughts on 'Revenge of the Source Code'

    1. They’re in a background project which I work on when I have the time. When I’ve finished I’ll test it out and it’s quite probably the case that you’ll suddenly get a load of Steam achievements just by booting the game up and finishing a level – it looks like the API will be able to send all your medals you’ve already earned at that point without any bother.

      Don’t hold your breath though ๐Ÿ™‚

  1. For what it’s worth, thank you for releasing the source code. That’s awesome-sauce on an awesome sandwich.

    1. I agree – I don’t know much about programming, but I think it’s great that you put the source out there, hopefully allowing other people to build on it, and maybe in the end, feeding back into the game to make it even better (or creating interesting spin-offs).

      I also think that this game and it’s devs are unusually linux friendly, and that the linux community greatly appreciates this sort of thing. I’ve been plugging this game and others like it on forums, and will continue to do so, even though I haven’t been playing it much lately. The casual tone of these blogs and the openness of the devs all feed into building a great community, which is why I will always choose indie games over flashy major releases (also they don’t run on my netbook). Thanks again guys!

    1. The steam patch is the recently released 1.80.11 version, which took steam a while to update for some reason.

  2. Yeah, thanks! I won’t be using it personally, but I appreciate your kindness. Maybe something good will result for us gamers!

  3. Open your source? o_O

    I haven’t wasted my money buying this game. ๐Ÿ™‚

    Thanks you! Hope some mods will be created!

  4. Cas, thanks for publishing the source under a free license! This is so incredibly awesome! I’ll be looking into how you did some of the lighting when I get a chance, I’m interested in seeing how you got to reuse some of the textures across different planets.

    I’m a little sad that you guys built a custom license for the code (instead of the GPL, or even the 3-clause BSD license) because including the company name in the license makes it really tricky to create derivative and combined works (ROTT + X, where X = Wesnoth, Doom, FreeCiv, etc). Would you consider switching to the 3-clause BSD (without releasing freeing the artistic assets, just like it is now)? Get in touch with the SFLC (softwarefreedom.org) or the OSI (opensource.org) if you’d like to discuss it.

    Again though, thank you so much for putting this out there! If you get the chance to release any updates to the game, please do!

    1. I’ll periodically refresh the source download (well, whenever I release a new patch).

      The license is already remarkably similar to the BSD one isn’t it? We used the same license as found in the LWJGL. All we don’t want is people using our trademarks; it’s fine to redistribute source code with the headers in containing those trademarks – we just don’t want anyone giving away deriviative works (or selling them) and saying it’s by Puppygames for example.

      1. Mozilla licenses Firefox and XULRunner under MPL, GNU GPL and GNU LGPL and still fight off trademark infringements. Just thought it would be worth a mention. They have a trademark policy outlined on their website for more information [2009]:

        http://www.mozilla.org/foundation/trademarks/policy.html

        Cools stuff either way. It’s always nice to see a Java game that’s performant share its code. =)

  5. More than achievements, I’m really looking forward to Steam Cloud support… Any ETA for this Cas ?

  6. Yay… Let’s dive into this thing… See if we can get things to compile… *Breaks out the NetBeans*
    My apologies if it appears as if I’m just rambling on in the following bit of text. I might say odd things, and I’m not too experienced with the way the RotT sourcecode is structured and deals with datafiles, but some of what I’m about to write may be of interest to people who are just looking through the sources for a few seconds..

    Main classes:
    com.shavenpuppy.jglib.resources.ResourceConverter
    com.shavenpuppy.jglib.util.XMLUtil
    net.puppygames.applet.Launcher

    There’s some errors in net.puppygames.applet.server.* – Looks like there’s some code missing (net.puppygames.gamecommerce.server.*).. Luckily, the classes in net.puppygames.applet.server.* do not seem to be used anywhere, so removing/commenting them out gets rid of those annoying error messages in your IDE.. I’m guessing net.puppygames.applet.server.* is something used for the core DRM stuff which might explain why it’s not in the source packages..

    — com.shavenpuppy.jglib.util.XMLUtil: Generic random XML stuff. Looks like someone was writing random code here to test or do temporary actions on XML files.. Not really interesting, unless I’m missing something..
    — net.puppygames.applet.Launcher: appears to load resources and boot up the actual game once those are loaded. This is probably what you need to run to get the game to run. Unfortunately, it requires the resources of the game (gfx, music, …) which is as of yet a slight problem…
    — com.shavenpuppy.jglib.resources.ResourceConverter: This seems to convert a .XML file into a serialized version. I’m guessing you need this to convert all the XMLs into resources that can then be loaded by the Loader class. Unfortunately, the ResourceConverter does not appear to have an implementation for ‘texture’ classes, which is what you’d need to convert the more interesting XML files such as “sprites.xml”..

    Luckily, the version of RotT on Steam isn’t packed into one huge .exe file (I think the HIB version does do that) and thus we can probably load the resources from the Steam version by screwing around with the Java Classpath. This should work, unless there are problems with serialization and different versions (my experiments did once reveal such an issue, though this was with the older version of the sourcecodes)..

      1. Currently idling on #ultraworm on Freenode..

        I did manage to create myself a resources.dat file using the ResourceConverter. What you need to do is create a ResourceConverter, then run the .include method of the ResourceConverter on all the XML files. Note that some XML files have dependencies on others, so it’s best to ignore all files that contain a “-” character. Once all the files have been included, do Resources.save(new FileOutputStream(new File(“resources.dat”)); — This should give you a resources.dat file that can be loaded by the game..

        Unfortunately, I’ve had a plethora of problems with this resources.dat that I generated:
        -TextResources couldn’t get loaded (such as the game’s title, game’s version and game’s internal version number). I’m guessing that there’s some extra .XML file that needs to be loaded through the resource manager that corresponds to the game you’re building a .dat file for… Fixed this by editing the code and setting these strings myself, though this might mean that there’s some other errors that might creep up..
        -Game could not be found. Had to create an instance of the game, set the name to “game.puppygames”, and then put the game as a resource in Resources.. or something. I really have no idea, but that seemed to work.. bleh!
        -Game Window was created with width=0 and height=0. Had to set game.width, game.height and game.scale to 800, 600 and 1. That got rid of some GL errors, too.
        -Some .jgimages couldn’t be found. Fixed this by appending gfx.jar and a bunch of other jars from the Steam version to the CLASSPATH (at least, that is what I think NetBeans does when I add those .jars to the ‘run’ property thingamajig)…
        -Lots of resources couldn’t be found.. ric*.buffer, crumble*.buffer, transparent.style, glowing.style… amongst others. Even adding *all* jars from the Steam version didn’t work here, so I have no idea how to fix this..

        So what I have now, is a 800×600 black window that loads a bunch of resources, and stops responding as soon as I click or attempt to do anything. Once it is finished loading, it doesn’t do anything anymore.

        I have the feeling that I am missing something.. Some RotT.xml file, or something, which contains some vital settings to make things not bug out completely..

        1. I haven’t checked the bundle that Cas uploaded but doesn’t resources.xml contain all the XML dependencies? (there’s dynamic.xml too IIRC) do you have these files? I’m coming at if from an XNA / C# angle though so maybe steering you down a dead end…

          1. resources.xml is the root – it includes all the other resources. You run the ResourceConverter on it and it generates a complete resources.dat from there.

            1. resources.xml isn’t included in the .zip you uploaded. Did you forget to include it? I think I managed to get around a fair bit of the stuff included in it by manually adding the Texture styles and such to the loaded Resources, but there’s probably a few stuff I’m missing to make it run smoothly.. ๐Ÿ™‚

              and Paul: there is indeed a dynamic.xml..

        2. It seems that Revenge of the Titans uses the Shaven Puppy Game Library, and their SourceForge repository has other tools such as an ImageConverter. They might help.

          1. Only if you’ve got the original images ๐Ÿ™‚ You’ll be needing those tools if you want to replace graphics and so on.

  7. Thank you !!!! I hope to learn something really usefull about game progamming from it !!!

  8. It seems you’ve changed the source code zip since its first publication :
    net.puppygames.applet.server.AppletHiscoreServer and net.puppygames.applet.server.AppletMessageCheckerServer are missing (the two class not compiling in the first place)…

    IMO, there’s no problem with changing the sources released but it would be cool if you could notify your rabbid fans! (In fact making an official GitHub repo for RevengeOfTheTitans would be even better so we can track you^H^H^H your modifications)

    1. Yes, those two classes aren’t part of the distribution, they just sneaked in by mistake. Also, it seems I left out resources.xml, whoopsie. I’ll fix that in a short while. Someone can figure out git for me ๐Ÿ™‚

  9. This is soooo coooool!!! Thank you for a great game and a great gestus !

    BTW I am an Android programmer.
    The game would be so cool to play on the newer tablets.

    so…. Anyone fresh on a collaborative effort for an Android port for Puppygames?

    Jacob ๐Ÿ™‚

    1. Well… Android is no way going to cope with Revenge, as it’s just Too Shit, and also the license with the source is not likely to be a great deal of help for an Android port, as nobody will be allowed to redistribute it as Revenge of the Titans. If anyone’s doing a port, it’s us! And we’re not.

      1. Whoa, thanks for the reply.

        WRT what Android is and isn’t I agree that its definately alien in a lot of ways to a ‘normal’ Java programming practice, and learning curve is steep, so that’s why I’d definately ally with Android coders if ever doing a port.

        1. it’s not so much the irritatingly different-to-avoid-lawsuits APIs in Dalvik, it’s the fact that Android devices vary wildly and widely in capability, the GL drivers are frequently buggy, but most of all, the VM is like going back to Java in 1995: extremely slow and forces you to do all manner of hax to get it to run games at an acceptable speed.

          1. How about a C++ port for Android then Cas? Granted, it’d be a right royal PITA and you’d need to mod the licence to allow it (and probably end up getting more involved than you would like) but if it gets done and it gets done right, then it’s just mostly free money no? Or at the very least, more exposure for the Puppy brand.

            1. bleh. We’re getting an iPad port sorted as we speak. But Android? Still not worth it I think.

              1. Porting a JAVA game to Android should be a lot easier than porting it to iOS. Of course dealing with the hardware deficiencies might even out the playing field. The hardware shouldn’t be that bad though since most tablets use NVidia Tegra2; a dual core ARM A9 processor as well as a GeForce GPU.

                I for one would really like to see a port for Android tablets. Is the released source code up to date enough to run with the original assets?

      1. Weekends gone ๐Ÿ™
        but no new update….(sigh)
        but imo, WORTH waiting for… it’ll be ready for monday right?
        p.s. buffed tanks?
        0_0
        buffed tanks! ๐Ÿ™‚ four words Cas – a.s.a.p.

        1. Luke, Slight Hint: Download the demo from PG and install it.
          (if you are a PG customer then its a bonus)

      2. Need humble and steam versions! Please. No longer have the weekend to try it out. ๐Ÿ™ But it’s all good. We know your doing your best. ๐Ÿ™‚

          1. Actually the real reason I’ve not announced it yet is because we are waiting for the Humble builds to get updated ๐Ÿ™‚

            1. Well, they haven’t updated and according to the HIB support staff they havent gotten the builds yet.

            2. The humble version is up! YES!
              Really could use some data on how the new tech functions. Looking forward to the blog.

                1. Holy sweet muther of bejebus – the new tech is friggin’ beyond awesome; celebrations all around! Cant believe how effective scarecrows are at ‘herding’ most of the titans, and the tanks! The tanks…… soooo much like the tachikomas from Ghost In The Shell (minus the cute voices)
                  Cas/Chas – you’ve made me a VERY happy gamer; you rock!
                  (and there was much merriment and joy abound, whilst pie and ale flowed freely)

  10. Is there any activity in analyzing the sources? I’ve tried to add some minor feature, but didn’t manage to build a playable version of the game. Looks like resources distribution varies in this version and bundled. I found only 43 jgimage files in bundle, while sprites.xml suggests at least 154. and “stencils-earth.jgimage” is nowhere to be found (may be there are more, but it was the one I noticed). Is there any way to get hold of these 154 jgimages (or the xmls that correspond to the bundled resources)?
    Cas, you said that you will support modmakers, but I need at least to check if the feature I implemented is working, not to tell if it will improve the gameplay.

  11. Trying to mod the Robotics Factories to produce more units than 6, I would prefer 24 per factory ๐Ÿ™‚ No success though, really don’t know much about modding a game like this, can anyone help?

    1. Well, the adjusting itself will be very easy:

      all the parameters are described in the file buildings.xml in lines 631-730.

      But after this you’ll need to produce a working dat file, which you won’t be able to do, since there is no resource packs matching opened xmls. I have some idea about hackish way of producing the correct xmls, but I don’t know if it will work, and even if it will – if it will comply with Cas’s license (may be there is a good reason why there is no xmls that corresponds to the art in bundled games).

      But may be there IS a way to tweak the game a little. I didn’t dig in the game this much, but probably if you make a dat file with just the part of the xml you actually change, and then load the resulting dat file after the bundled one, may be this will replace the standard objects with tweaked ones. We’ll have to wait until the promised post about modding to know for sure.

      1. Well I am still eagerly awaiting any modding post from the Dev’s as I really want to modify the droid factories (I love Droids) ๐Ÿ™‚

      1. So did you actually mange to launch the game? Where did you get 154 (or what was the number) jgimage files which are described in the sprites.xml?

        1. You don’t need those resources to compile the resources.dat file. See the commentary near line 86 in resources-public.xml — They’re loaded dynamically at run-time. This is why the resources.dat file is so small…

          These files are actually contained within the .jar files of RotT; both the Steam version and the latest HIB version contain all these .jgimage files within the .jar files (see gfx.jar and images.jar)

          It’s been a while, but I think you can get things to run if you make sure that all the .jar files are in the Java Classpath, and then run the following Java class: http://pastebin.com/qGpkZyku
          (replace y:\\resources.dat with a path to your generated .dat file)

          As far as the ant buildscript goes: the buildres should work (at least if you tweak the paths a bit), but I don’t think I’ve gotten the run one to work.

          1. Unfortunately, I wasn’t there during HIB, and I don’t have steam account as well. The version that can be downloaded from puppygames site has only 43 jgimage files, and that’s what confused me. So, the xmls correspond to the resources of the steam or HIB versions. Good to know.

            And yes, of course I understand that this *.dat file doesn’t contain the art itself. But the objects in it contain the “classpath” to jgimage file and “object” within this file, and if this “object” is actually in another jgimage file (which is my case), then the whole thing won’t work.

            1. Hmm..

              If you’re good with graphics, you can help out with creating some replacement assets (https://github.com/megagun/ultraworm/tree/master/datasrc for whatever’s been done as of yet). Units and buildings seem to be the more difficult items that need replacing. Remaining GUI elements may just be a big chore (lots of duplication of icons and mouse-cursors, for example) unless someone’s good with generating those kind of images procedurally (combine a cursor icon with an icon for a powerup, for example)…

              Alternatively, write up some code that replaces assets that can’t be loaded with “error” assets (beeps for sound; ‘error’ textures for textures, etc)…

      1. I am sorry but … It seem not to be the 1.80.12 source code. The tank factory, for example, seem to be unfinished and its research depend from “cantResearchThisYet”.
        Would it be possible for it to be updated ? I am trying to make my home-made personnal patch to change some oddities that I don’t like. But loosing tank factory make me a sad panda.

  12. I just modified the game so that it spawns a Smartbomb when the mouse is clicked, even when not in Smartbomb mode, giving me unlimited smartbombs. Being an “author of Armageddon” is fun.

    1. Is there any way to modify the Driod factories, to allow them to produce 3 times as many standard droids and the advanced battle droids? Also to produce them slightly quicker and be cheaper to build? I was waiting for the mod bolg post, but it doesn’t seem to be forth coming? I only need slight instruction.

      1. There is – everything’s completely configurable. I will get around to that blog post but I’m just waiting to get 1.80.13 out the door first. Got quite a lot on at the moment – releasing upgraded Titan Attacks and Ultratron, fixing a bug or two in Droid Assault, doing a German translation of Revenge of the Titans for retail, attempting to make Android work nicely, managing the Revenge of the Titans addon development, doing company accounts, wrangling children, etc. etc…

        1. That is ok Cas and many thanks for the response!! Much appriceated, I shall wait patiently ๐Ÿ™‚

          P.S. Hope you managed to wrangle them kidz XD

  13. Was a resources.xml file ever distributed? I’d love to get this compiling but I need the resources.dat.

    I have the HiB version, BTW

    1. It was not included in the original source download, but it was fixed, and the download now, I think, contain resources-public.xml .

Comments are closed.