Announcement

Collapse
No announcement yet.

DEBUG: Sprite Limit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by Martin Gühmann

    Unfortunatly it isn't such simple, this constant is used to datamine how much space is reserved for the sprites that the game loads, so just removing it would prevent the code from compiling, increasing it means using more memory and more time to fill it. Maybe 300 sprites of each type is ok, but this isn't very intelegent. The best solution is to make it so that as much memory is used as needed. And that is a little bit more tricky.

    -Martin
    I agree with that. But regarding the reservation of space it is merely used to created an array of pointers. Therefore, the amount of memory used up by that array is quite small.
    So much to do in so little time...

    Comment


    • #17
      You will always need a hardcoded constant for a maximum number of sprites somewhere.

      Suppose we change the file to have the number of sprites read in from a TXT file. This would be good because we could reduce the amount of memory we use to just the memory that we are using.

      Now suppose someone, in a fit of madness or with a malicious streak, decided to set the maximum number of sprites in this hypothetical text file to a very large value such as 2000000000 just to see what would happen. Without a hardcoded limit to check against, the game could crash rather spectacularly as it tried to allocate this much memory.

      The constant will allow us to check the number of sprites in the scenario's sprite TXT file, and values that are too large could be rejected. (A message would appear on screen and the scenario wouldn't run.)

      It might be possible to determine this maximum number of sprites at runtime, thus relieving us of the need to hardcode a constant, but that's not something I know how to do.
      None, Sedentary, Roving, Restless, Raging ... damn, is that all? Where's the "massive waves of barbarians that can wipe out your civilisation" setting?

      Comment


      • #18
        You know, you can't prevent people from wrecking their computer anyhow. I bet there are quite a few features in the official CTP2 text files that could be turned into a nasty system crash. All that is usually done is to add a warning to such lines that putting values beyond a certain level into those lines could lead to unexpected even dangerous results. A similar warning could be added in this case and if it's no more then saying that putting a number above 500 (just an example) is not recommended.

        In the end this limit is also based on the end user's system configuration.

        The more technical aspects I will leave to those who actually understand the math and programming involved (unlike me;-).

        Marc aka Caran...

        Comment


        • #19
          Originally posted by star mouse

          Now suppose someone, in a fit of madness or with a malicious streak, decided to set the maximum number of sprites in this hypothetical text file to a very large value such as 2000000000 just to see what would happen. Without a hardcoded limit to check against, the game could crash rather spectacularly as it tried to allocate this much memory.
          It depends on the computer you are running the game on. If you are running CTP2 on BlueGene or MCR you could handle an exponentially larger number of sprites. About a year ago I created an enormous map by playing with the values in the map.txt file without crashing my system. It took five minutes to load and shutdown the game and it probably would have crashed an older computer. My preference is to set no maximum and if your computer can't handle the memory requried, lower the number or buy a faster computer.

          Comment


          • #20
            I know my computer is kind of ancient *grumble* but I don't think we shall not put a limit. It would make it a bit easier to keep an overview for moders, if they know there is a limit. Also we would prevent to many 'complaints' because of no limits (maybe).

            But putting the limit into a .txt file might be easiest to adjust.

            Comment


            • #21
              Originally posted by Gilgamensch
              I know my computer is kind of ancient *grumble* but I don't think we shall not put a limit. It would make it a bit easier to keep an overview for moders, if they know there is a limit. Also we would prevent to many 'complaints' because of no limits (maybe).

              But putting the limit into a .txt file might be easiest to adjust.
              I agree. That way as computers increase in speed, you can add extra capacity without being required to alter the source code.

              Comment


              • #22
                I recommend the first line of newsprites
                "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
                The BIG MC making ctp2 a much unsafer place.
                Visit the big mc’s website

                Comment


                • #23
                  I don't like to set a limit somewhere in the text files, in my opinion it is better to have something like just using as much memory as necessary. So if there are only five sprites at programm start only memory for five sprites is assigned. If you 1000 then memory for 1000 sprites is assigned, so no hardencoded limit or set somewhere. And if it needs to be a value somewhere then the const.txt is the right place for it, we have also city, good and effect sprites.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment


                  • #24
                    Originally posted by Martin Gühmann
                    So if there are only five sprites at programm start only memory for five sprites is assigned. If you 1000 then memory for 1000 sprites is assigned, so no hardencoded limit or set somewhere.
                    -Martin
                    It would be prudent to check the number of sprites against some suitably large number so that people don't shoot themselves in the foot. (Crash!) By "suitably large", we can choose a power of 2 and don't allow the number of sprites to go over that limit. Any power of 2 between 1024 and 32768 would be a good "absolute maximum". However, 32768 does not quite fit into a signed 16-bit integer, so that needs to be taken into account.
                    None, Sedentary, Roving, Restless, Raging ... damn, is that all? Where's the "massive waves of barbarians that can wipe out your civilisation" setting?

                    Comment


                    • #25
                      how about we get the game to count the number of entry in the newspr file then that we no real number is coded
                      "Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
                      The BIG MC making ctp2 a much unsafer place.
                      Visit the big mc’s website

                      Comment


                      • #26
                        Actual I thought of counting the number of sprite files in the sprite directory. For a number like 32768 I wouldn't call this really a limit. My point is just to use as much space as needed to store the sprites in the memory and not 32768 as it would be if I just change the number in the according file.

                        -Martin
                        Civ2 military advisor: "No complaints, Sir!"

                        Comment


                        • #27
                          Quick question.

                          Has anyone managed to increase the number of unit sprites available in the game?

                          I would have thought 250 or 300 would be about the max to allow some new units as well as civ specific plus possibly other special units such as leaders tec?

                          Comment


                          • #28
                            Originally posted by stankarp
                            Has anyone managed to increase the number of unit sprites available in the game?
                            Managed?

                            I thought it is obvious in this thread how to do it, if you accept that you use more cpu time and memory for all the sprites. But if you mean considering increasing it in a more intelegent way, no one managed it. But a temporal sollution could be to increase this number.

                            -Martin
                            Civ2 military advisor: "No complaints, Sir!"

                            Comment


                            • #29
                              Has it been decided what the max number should be for the upcoming Apolyton Edition?
                              Formerly known as "E" on Apolyton

                              See me at Civfanatics.com

                              Comment


                              • #30
                                Well, I would think that Martin's solution from a few posts above is the most reasonable:

                                Actual I thought of counting the number of sprite files in the sprite directory. For a number like 32768 I wouldn't call this really a limit. My point is just to use as much space as needed to store the sprites in the memory and not 32768 as it would be if I just change the number in the according file.


                                With, well, probably adding some sanity check to make sure that no more than x sprites are loaded into the memory, where x could, as said, be any power of 2 between 1024 and 32768... though I can't really see us ever having more than 2^11 sprites, say = 2048.
                                Solver, WePlayCiv Co-Administrator
                                Contact: solver-at-weplayciv-dot-com
                                I can kill you whenever I please... but not today. - The Cigarette Smoking Man

                                Comment

                                Working...
                                X