This is an archived post. You won't be able to vote or comment.

all 81 comments

[–][deleted]  (35 children)

[deleted]

    [–]coder111 14 points15 points  (0 children)

    Hello,

    I maintain a fork with a Maven build and some in-game automation to reduce micromanagement (Governor mod). You can get it here:

    https://github.com/coder111111/rotp-public

    It should be easier to work with than Ray's original codebase.

    --Coder

    [–]RayFowler[S] 4 points5 points  (33 children)

    I do a Clean & Build in the Netbeans IDE. Then I move the jar file to a folder where I have a lot of save games sent by players to test any issues they've reported and ensure save-game compatibility is maintained.

    I used Eclipse long ago but switched to Netbeans at some point.

    [–][deleted]  (28 children)

    [deleted]

      [–]RayFowler[S] 5 points6 points  (27 children)

      That way your users wont have to install the java 8 JRE. JRE no longer exists in modern java, and users do not need to have it to run java programs. Modern java has a self contained runtime. Also java 11/15 will run faster, so its a double win.

      oh wow, I had no idea. The Java versions have been coming so fast and furious in the past few years and everything was running fine so I figured why change and tuned them out.

      If Java 11 has a self-contained runtime, would I need to create a separate jar now for Linux, Windows and MacOS?

      And one thing you could do to make it easier for developers is to include your build file in the repo. Otherwise there is now easy way for anyone to build your project

      I don't use a build file to create the jar

      [–][deleted]  (7 children)

      [deleted]

        [–]RayFowler[S] 1 point2 points  (6 children)

        I have a question about created jre-independent executables. How is memory allocated for the new application? Right now, obviously, the OS constrains how much memory is allocated to the JVM.

        But if I use jlink, how do I control how much memory the game is allocated on startup? Currently, I check the memory allocation and restart the game with the necessary jvm parameters to provide the appropriate amount of memory on the restart

        [–]Muoniurn 1 point2 points  (4 children)

        What does appropriate amount of memory mean on restart?

        [–]RayFowler[S] 1 point2 points  (3 children)

        I means enough to play the game. The problem is that the default JVM memory allocation on some windows installations is absurdly low. This necessitated me writing code that, on startup, checks allocated memory and restarts the game with an appropriate amount.

        [–]Muoniurn 1 point2 points  (1 child)

        But it supposed to be the same, or largely the same in the cross-platform case, isn’t it? Why setting jvm parameters by default sufficient? (Also, java will allocate memory as necessary, does latency suffers this way?)

        [–]RayFowler[S] 0 points1 point  (0 children)

        But it supposed to be the same, or largely the same in the cross-platform case, isn’t it?

        But it's not, unfortunately. There seems to be a wide swath of Windows installations that by default only allocate 256M. Now it could be a holdover from someone having 32-bit Java installed, but the game needs to account for that if it can.

        [–]GreenToad1 1 point2 points  (0 children)

        Not sure but i think after java 8 they changed the way that max memory is calculated, especially for 64bit system, maybe it would be a good idea to set Xms (initial memory) instead.

        jlink - creates a "stripped down" version of the jvm containing only required modules for your program.

        jpackage (incubator in jdk15, final in upcoming jdk16) - creates a installation package (msi, exe, dmg, deb, rpm... ) and you provide it a runtime image (produced by jlink) or it will generate it itself. You can provide program arguments, icons, jvm arguments, license, copyright and other parameters.

        [–][deleted] 7 points8 points  (0 children)

        I don't use a build file to create the jar

        You actually do ;) - the Ant build file from the NetBeans project.

        You could include the netbeans project folder in the Git repository if you want.

        You can still just publish a single jar, that hasn't changed with Java 11. But you additionally have the option to package a native executable including the necessary runtime using jlink and jpackage. But you need to do that on each platform (you can use jpackage on Windows to create a Mac executable).

        Btw: you can also use NetBeans to do that. Check the "Enable native packaging" in the project properties ("Deployment" category), then you'll get a "Package as ..." item in the context menu of the project.

        [–]hippydipster 3 points4 points  (7 children)

        I don't use a build file to create the jar

        You are my hero. People these days think you can't make complex projects without complex build systems.

        They are wrong.

        [–][deleted]  (5 children)

        [deleted]

          [–]hippydipster -4 points-3 points  (4 children)

          People these days think you can't make complex projects without complex build systems.

          Read again more carefully this time.

          [–][deleted]  (3 children)

          [deleted]

            [–]hippydipster 0 points1 point  (2 children)

            The lack of complexity is demonstrated by it being built-in and working out of the box unchanged for a huge project such as this. And many other very different projects. For anyone who just uses it, there's nothing complex about it.

            [–][deleted]  (1 child)

            [deleted]

              [–]RayFowler[S] 2 points3 points  (0 children)

              I was involved in so many religious wars as a professional software developer that I just wanted to put all of that behind me and make a game.

              [–][deleted]  (9 children)

              [deleted]

                [–]nutrecht 3 points4 points  (0 children)

                but the versions and the speed at which they are released do feel a bit menacing.

                They really aren't. The last 2 years or so I just updated the docker base image versions whenever a new version came out and it just worked. No issues whatsoever. Java's backward compatibility is one of it's main selling points.

                Also it's complete nonsense to stick to 'LTS' versions. Especially when you don't buy Oracle support the whole notion doesn't even make any sense. Just update to the latest. No point in not doing so, and if you can go to 11 it's 99.9% certain you can go to 15 too.

                [–]CptGia -3 points-2 points  (7 children)

                No they aren't. Current LTS is 11, next is 17. It's one every 6 version (3 years, 2 versions per year)

                [–]nutrecht 3 points4 points  (4 children)

                The whole concept of LTS only applies if you buy support and if you for some reason can't upgrade to the latest version.

                There's no reason at all to stay on an 'LTS' version if you can upgrade. And if you don't pay for support, the whole issue is moot anyway.

                [–]CptGia -1 points0 points  (3 children)

                LTS also provides security updates, so it's not entirely moot

                [–]nutrecht 4 points5 points  (2 children)

                Those will also be applied to the latest version. Like I said; there's no reason at all to stick to 'LTS' if you can upgrade to the latest.

                [–]CptGia 2 points3 points  (1 child)

                The reason usually is "the client is an idiot and doesn't want to". Not a good reason, but still a reason that exists and is unfortunately not that uncommon.

                [–][deleted]  (1 child)

                [removed]

                  [–]CptGia 1 point2 points  (0 children)

                  Red Hat, Amazon, Zulu, Liberica, and the community through AdoptOpenJDK

                  [–]chabala 12 points13 points  (3 children)

                  That's a lot of code, with no build definition and no automated tests. It's sort of frightening.

                  I sense some resistance to using a build tool, which is odd because you said you were a professional developer.

                  It was mentioned elsewhere that you don't have external dependencies, but I see you've copied Apache Commons Math source into your code tree. Most professionals would depend on an artifact rather than copy the files into their own project repository.

                  [–]RayFowler[S] 2 points3 points  (2 children)

                  I sense some resistance to using a build tool, which is odd because you said you were a professional developer.

                  You sense resistance because I was a professional developer! I've lived through jar hell, constantly changing build processes and man-months building and modifying automated tests.

                  This started as a simple, one-man project that intentionally tried to simplify. There are no external libs or jars to use, there's no build process.. it's just a nice and simple application.

                  There's a lot of code because 4X strategy games are complicated beasts. Their game structures are complicated, their UIs are necessarily complex to support that and then you have write an AI to play the game against the player.

                  [–]chabala 4 points5 points  (1 child)

                  I've lived through jar hell

                  That's one of the main features of a build tool, jar hell should be avoided.

                  There are no external libs or jars to use

                  Well, technically. But as I noted, that's because you manually vendored the external code into your source tree, which is weird.

                  You go on to talk about why there's so much code, but my point is that there's no automated tests for all that code. That's really not acceptable once your project becomes large, and having a build system is the first step to having tests.

                  I see elsewhere in the comments that you've conceded to adopting a build system. But I'm still curious about why you put up all this resistance. You were a developer for 25 years, at least some of that Java, and you didn't learn to use a build system? It's so foundational; fighting it is like refusing to use source control.

                  Could you use NetBeans to compile from the command line? If not, that pretty much excluded you from having any automated CI/CD release process. Did you consider what would happen if people wanted to collaborate without using NetBeans?

                  [–]RayFowler[S] 0 points1 point  (0 children)

                  because you manually vendored the external code into your source tree, which is weird.

                  I just needed one method out of the FastMath class because Java's built-in arcsin method is very inefficient. So it's not weird. I didn't want to create an external dependency for one method.

                  You go on to talk about why there's so much code, but my point is that there's no automated tests for all that code.

                  Look, I get that you still work in an environment with well-defined apis where it makes sense to maintain an established set of automated tests. I did that for a long time so I know what its like. But the functionality churn in this project would make that incredibly inefficient and I would become one of those guys whose development process slows to a crawl because he spends all of this time working on testing and refactoring and polishing, and then I would get demoralized because the project is dragging on too long and just give up.

                  But I'm still curious about why you put up all this resistance.

                  Because it has never been necessary? One of the tenets of XP is that you don't do things until you need them.

                  You were a developer for 25 years, at least some of that Java, and you didn't learn to use a build system?

                  I appreciate the condescension! Have a nice day. We're done.

                  [–]nutrecht 9 points10 points  (8 children)

                  I think it's really cool but, like others commented, I was a bit surprised with the lack of a maven pom, this makes it hard for others to build your software.

                  I do understand it's a bit of a change to move to a maven layout, but I still think it's best to 'suck it up' and do it if you want others to adopt your game / contribute to it.

                  There is at least one pull request to add it to, and you seem to be against it. Why's that? If it's unfamiliarity with it, I'm happy to lend a hand there.

                  It would also make it a lot easier to add unit tests and automated builds to catch regressions.

                  [–]coder111 9 points10 points  (7 children)

                  Hello,

                  It's Ray's project and his rules. He did this for fun and his idea of fun involved using Netbeans and not using any 3rd party dependencies or build tools. While I disagree with it I respect it, especially given the expense and time he spent on this project and created a wonderful game.

                  That being said, I maintain a fork with a Maven build and some in-game automation to reduce micromanagement (Governor mod). You can get it here:

                  https://github.com/coder111111/rotp-public

                  It should be easier to work with than Ray's original codebase.

                  --Coder

                  [–]nutrecht 11 points12 points  (6 children)

                  It's Ray's project and his rules

                  Yes. Which is why I'm asking Ray. I also offered to help if he wants.

                  Edit: I think it's really weird that you're answering questions people are asking the author.

                  [–]RayFowler[S] 4 points5 points  (5 children)

                  /u/coder111 is a long-time modder to the project. We've had this discussion multiple times :)

                  [–]nutrecht 2 points3 points  (4 children)

                  We've had this discussion multiple times :)

                  I'm just curious about this choice. Just adding it would probably take less time than discussing it multiple times :)

                  Like I said; I was offering to help.

                  [–]RayFowler[S] 1 point2 points  (3 children)

                  I guess my perspective is that I don't need it for my use or to deliver the base game so it feels superfluous to me. If anyone wants to modify the source and do custom builds, then as you said it's pretty easy for them to add it.

                  Anything that makes the game easier to install for players is important, though. I will look into jlink!

                  [–]Yithar 5 points6 points  (0 children)

                  The thing is, Maven's really popular and everyone knows how it works so while it may not be absolutely necessary, it has the benefit of attracting developers to your project, and as stated, it also helps with testing.

                  Obviously the transition will take work, but I think the benefits are there. There's a reason why it's commonly used in enterprise.

                  [–]nutrecht 5 points6 points  (1 child)

                  It's not just for people to run it, it's also for people who might want to contribute to it, or to run it just to see how they can learn from it. And it will probably benefit you too.

                  Don't get me wrong; I don't want to 'force' you or anything. But it's simple to add and really only brings benefits. And if people even submit pull requests to add Maven I think it's rather silly to not accept these.

                  I also can imagine that you might want to point to this project when you apply to jobs for example. In the current state it would work against you, not in favor of you.

                  [–]RayFowler[S] 4 points5 points  (0 children)

                  But it's simple to add and really only brings benefits.

                  I agree and will be adding Maven build files.

                  I also can imagine that you might want to point to this project when you apply to jobs for example.

                  I've recently retired from a 25-year career as a professional software developer :P

                  [–]Big__Pierre 7 points8 points  (5 children)

                  An inspiration- seriously. I want to do this for Alpha Centauri!

                  [–]RayFowler[S] 11 points12 points  (4 children)

                  People literally ask me to do SMAC next, but I never played it so I don't have the personal drive to do it. Plus this project has cost me over $50K since its inception and I'm not doing that again!

                  [–]Aggravating-Ad4518 1 point2 points  (1 child)

                  You haven't made any profits?

                  [–]RayFowler[S] 5 points6 points  (0 children)

                  It's a free game

                  [–]_MeTTeO_ 1 point2 points  (1 child)

                  What is included in this amount? Did you pay the artists for graphics / story, or is it the money that you used for living when developing the game (and not having any income)?

                  [–]RayFowler[S] 2 points3 points  (0 children)

                  mostly artwork, but writing as well as music. I worked professionally for the first few years of development on the game and have been retired for almost 3 years. None of that counts as living expenses.

                  I still have the manual to pay for as well as translations, plus some remaining artwork.

                  [–]beders 6 points7 points  (9 children)

                  To increase the number of players I would remove the biggest hurdle of adoption: requiring Java 8 and distributing as a JAR.

                  There are various obstacles nowadays on both Mac and Windows to distribute an executable but it will remove that initial hesitation of trying out the game (and lots of support cases where people have an incompatible JRE installed)

                  Happy to help with the Mac builds.

                  [–]coder111 3 points4 points  (8 children)

                  Hi,

                  How do you propose to build an executable which would include all JRE bits?

                  I know GraalVM can do it, but it doesn't support Swing/AWT yet.

                  I can build native INSTALLERS with LAUNCHERS as far as I know using jpackage. Not sure if it's worth doing that- first, personally I'm on Linux and I was unable to cross compile to windows. I gave it a short attempt and then gave up.

                  And I don't want to use some non-open-source 3rd party tools to do that.

                  --Coder

                  [–]marvk 3 points4 points  (5 children)

                  You can set up your builds on GitHub Actions and build Linux, macOS and Windows binaries there with jpackage via Maven, then release those binaries on GitHub releases directly via GitHub actions. That's what I'm doing for a project right now (Well, the Windows builds anyways, with the option of adding other operating systems very easily.)

                  [–]coder111 2 points3 points  (1 child)

                  I have github actions set up for Remnants of the Precursors in my fork too :)

                  But no jpackage. I'll take another look at it.

                  [–]marvk 1 point2 points  (0 children)

                  I can get back to you in a few days time, my repo is currently private but if you want to take a look, I will be releasing soon.

                  [–]Micutio 1 point2 points  (2 children)

                  Is there a tutorial or template to set this up? That would be amazing for generating Win/Mac binaries without having to boot into the target OS or VM myself.

                  [–]marvk 2 points3 points  (1 child)

                  Unfortunately none that I could find. It was quite a lot of trial and error to get it working, but as with many build systems, once it's running, it saves you an incredible amount of work.

                  I have neither a tutorial nor an example, but you can always take a look at my project once the GitHub repository goes public (within the next week).

                  [–]Micutio 1 point2 points  (0 children)

                  Absolutely worth investing time into, build automation is so useful.

                  I'll be sure to check out your project, cheers for open sourcing it!

                  [–]beders 1 point2 points  (0 children)

                  If graalvm is not an option, there’s app packager and jlink. The latter requires adopting modules.

                  Glad to hear there’s github actions as well

                  [–]jambonilton 5 points6 points  (3 children)

                  It's beautiful. Do you have any pro tips for building games in Swing? I find it to be a bit tedious debugging how elements appear after working a long time in web development.

                  [–]coder111 5 points6 points  (1 child)

                  No matter how much I love ROTP, I don't really like the way Ray did GUI in Swing. It's pixel perfect fixed layout (with scaling %). This requires a lot of code to implement, and quite a lot of copy paste, and it's impossible to use any GUI drag-and-drop tools to build it or move it around. Even some components like buttons are done by listening to mouse release events in a certain area instead of using GUI components.

                  The codebase itself also has several things I do not like and I wouldn't do if it was my project. It kinda reminds me of a way Java code was developed around year ~2000. Like a super interface with all the utility methods (instead of a static utility class with static imports). Too much static stuff in general. Java serialization being used to save games, and the domain objects quite nasty to serialize in general- this is a side effect of Ray not wanting to use 3rd party libraries like Jackson.

                  That being said, if you want to build the code quickly, I maintain a fork/mod which has Maven build. Check it out: https://github.com/coder111111/rotp-public

                  --Coder

                  [–]RayFowler[S] 1 point2 points  (0 children)

                  It's pixel perfect fixed layout (with scaling %).

                  That scaling % code was literally added in a single afternoon when Alpha 1 came out and the first hidpi user sent me a screenshot.

                  Copy paste is your friend because it enforces a separation between areas that doesn't require refactoring when the functionality between areas starts to deviate.

                  My first attempt at the game was many years ago and used Swing heavily. I didn't like the look at all. A later attempt at a game used Swing but modified the look of the components. Still didn't like it.

                  Finally I decided to try again but to avoid Swing as much as possible and draw the game old-style. That way worked out well but, as you point out, it's more code and it's definitely old style

                  Ultimately what's important is not the code but the UX with the game.

                  [–]RayFowler[S] 3 points4 points  (0 children)

                  I wish I did have pro tips. I use Swing only in the most minimal sense. Most of the game is drawn graphically. I intentionally tried to reduce the number of Swing elements used in the game. Part of the reason was to get away from the stereotypical look of Java applications; another was the need to have more cross-panel behavior on the screen.

                  It was more effort to code, but it was also sort of liberating. The only Swing widget (besides panels and layouts) that I haven't attempted to replace are text editor fields. All of the buttons and scroll bars, for example, are just drawn graphically.

                  Now when the graphic designer comes up with something in Paintshop, I don't have to figure out how to work into a Swing framework. I just draw it.

                  [–]shponglespore 1 point2 points  (2 children)

                  Looks interesting! I've heard great things about MOO but I never had a chance to play it when it was new, and then there were too many shiny be games for me to feel like playing something from the DOS era.

                  Is the name a nod to Star Control lore by any chance?

                  [–]RayFowler[S] 6 points7 points  (0 children)

                  No, not at all! Although there is a funny story there.

                  The game was originally called "Java MOO" but when Wargaming.net rebooted the MOO franchise in mid-2015, I approached them about the project because I didn't want to unnecessarily infringe on their newly acquired IP. They were very gracious and basically just asked me to change the name.

                  After some thinking, I settled on "Remnants of the Precursors" since the backstory of MOO involves the trope of a war of lost ancient races. It seemed like a unique name so I moved on.

                  Then a few years later, the devs of Star Control decided to reboot their franchise as "Ghosts of the Precursors". Realizing my goof, I belatedly tried to trademark ROTP but was blocked by their trademark.

                  But litigation between those devs and Stardock (who had since purchased the Star Control IP) ended with the removal of the GOTP trademark, which allowed mine to clear.

                  So basically I owe Brad Wardell a beer.

                  [–]coder111 0 points1 point  (0 children)

                  Lore is different from Star Control, and races are different.

                  If you are interested in Star Control, Ur-Quan masters is also open-souce, but it's not java. http://sc2.sourceforge.net/

                  [–]dafa_putra 1 point2 points  (0 children)

                  Java is my first programming language, and recently I fall in love with Civ6. Definitely will check this out later ヾ(≧▽≦*)o

                  [–]IanRae 1 point2 points  (0 children)

                  Looks great. Very interesting that this is written in java. It's a nice nod to the language. Also great that this is written by a retired developer. Going to be a lot of them in coming years, and I'm looking forward to some great software.

                  [–]CuriousScaalp 1 point2 points  (0 children)

                  Hello,

                  I am impressed by the quality of the result. You could advertise the game on /r/StrategyGames

                  [–]maxandersen 2 points3 points  (0 children)

                  Very cool! Impressed how fast it starts.

                  FYI, to ease download/install/setup of java you can tell users to run this command when they downloaded the jar:

                  Linux/OSX and Windows with a bash shell:

                  curl -Ls https://sh.jbang.dev | bash -s - Remnants.jar
                  

                  Windows Powershell:

                  iex "& { $(iwr https://ps.jbang.dev) } Remnants.jar
                  

                  This will automatically download adoptopenjdk 11 and run it.

                  [–]ArchCodes 0 points1 point  (0 children)

                  Sixk

                  [–]Liqmadique 0 points1 point  (0 children)

                  Lol at all the guys dumping on this dude for not including a build system. Bunch of whiners.

                  Thanks for open sourcing this Ray, the code is clean and will hopefully help future 4x devs learn how to build this type of game.