Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Call To Power II > CtP2-Source Code Project > DEBUG: Sprite Limit
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
CivGroups
CTP2 Source Code Project (59): Not a Member - Join

bottom of page
  
Author
Thread   
Pages (2): [ 1   2   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:31
  Old Post 30-10-2003 00:14 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Sprite Limit Support Apolyton or Terrorists Win

Who'd have thought it'd be this easy?

code:
// from SpriteGroupList.h #define k_MAX_SPRITES 200


... How likely is it () that there is no other code dependant on this number?

Locutus is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:31
  Old Post 30-10-2003 01:32 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Re: Sprite Limit Help yourself to an AD-FREE life

quote:
Originally posted by Immortal Wombat
Who'd have thought it'd be this easy?




quote:
... How likely is it () that there is no other code dependant on this number?


Well, we'll find out as soon as the code compiles. But I'd say very likely...

Last edited by Locutus on 30-10-2003 at 01:41

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:31
  Old Post 30-10-2003 01:38 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Remove this text

very likely

you have to set up a number there are 68 main ctp units that’s over 130 for moding now how likely does it sound you must put a number in however I would recommend you replace it with one for the modern sys spec say 500

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 30-10-2003 03:02 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Suffering from ads?

quote:
Originally posted by Immortal Wombat
... How likely is it (:rolleyes that there is no other code dependant on this number?


Do you mean other code that uses it or this line duplicated?

code:
//from SpriteList.h #define k_MAX_SPRITES 200


Well I made a search for 200 in the sprite folder and found k_MAX_SPRITES in a third file SpriteGroupList.cpp were it is actually used. From what I saw they used for loops to cycle through all possible sprites and check if they are there in the according folder, well I could imagine some ways that a little bit more elegant meaning faster if you allow any number for the sprite files. And it means another thing: All the sprite graphics must be available in the memory while CTP2 is running irrespective whether they are used or not. At least that is my guest from I have seen so far.

To make shure that our raising of the limit will work we should change the number in both files. So far I think this is only defined once, because of the #pragma once line that came before. Of course correct me if I am wrong here.

So what is left is that we should discuss the new limit, if we just change the number then CTP2 needs more time for starting, so a limit of 50000 is still a little bit too high. Actual I prefer a limit of 1000 so that the last sprite number would be 999.

-Martin

Dale is offline Dale
King
Sir! Why do you keep clicking on me?
Dec 2000
time: 15:31
  Old Post 30-10-2003 03:09
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton

Also need to consider too, that if we change this too high it'll take vital memory that we may need for something a little more critical than pretty graphics, like for instance, AI processing.

ahenobarb is offline ahenobarb
Prince

Nov 2001
time: 05:31
  Old Post 30-10-2003 03:58
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Enter the AD-FREE zone

I'd prefer dropping the #define all together and letting the program check the number of available sprites. That way it's scalable and you can slip in and out sprites you want/don't want. Why have a limit when you can just ask the program to count through the available sprites once at the beginning of the game and assign the total to a variable.

Since, IIRC all of the sprites have their specific numbers built into the file names, it shouldn't be a problem associating the right unit with the right sprite in the units.txt file.

Also, as Dale mentions this has the virtue of only using the amount of virtual memory you actually need.

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:31
  Old Post 30-10-2003 04:20 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Help yourself to an AD-FREE life

quote:

All the sprite graphics must be available in the memory while CTP2 is running irrespective whether they are used or not. At least that is my guest from I have seen so far.

Yes, I think Pyaray mentioned this before.

Well, anyway, that's just dandy then. Woo!

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:31
  Old Post 31-10-2003 01:04 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Support Apolyton buy from Amazon

Will it be possible to rename sprites other than the number convention? I remember the big problem of new sprites sharing the same number.

DDowell is offline DDowell
Chieftain
Västerås, Sweden
Nov 2001
time: 06:31
  Old Post 31-10-2003 21:06
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Inflate your Upload Space

quote:
Originally posted by E
Will it be possible to rename sprites other than the number convention? I remember the big problem of new sprites sharing the same number.


Yes, but it might be to cumbersome to implement. We could maybe do it by not having a maximum at all but read in all sprites that exist in the folder (and are necessary to play the selected scenario/mod). That shouldn't be too difficult I reckon.

MrBaggins is offline MrBaggins
King

May 1999
time: 05:31
  Old Post 02-11-2003 03:50
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Support Apolyton

Hmm.. might not be that simple

If sprites are loaded onto a DD surface in GFX Card texture memory (limited resource, unless you have a latest and greatest graphics card, basically,) then we may have a problem with capacity, other than changing a number. It just depends how they did the DirectDraw stuff.

I'll take a look at some point soon.

Caranorn is offline Caranorn
Warlord
Luxembourg, Europe
Mar 2000
time: 06:31
  Old Post 09-11-2003 19:18 Visit Caranorn's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Support Apolyton buy from Amazon

I'll just comment that additional sprite capacity would be very handy. No one is forced to use a higher limit, and I expect most serious mods will try and limit themselves to make the mod as playable as possible. But lets say 1000 sprites would be quite handy for the modder himself to have all sprites he's working on available for his test sessions and such.

I wonder, would it be possible for a mod to have a file listing all it's active sprites and for CTP2 to only load those at start? This assumes using mod swapper or a similar function. That way one could keep a huge sprite library but only load those needed for a particular game. In that case sprite ID might not require a numerical limit either, though I for one would would still use that feature for standardisation.

Marc aka Caran... with the usual disclaimer, I'm not a programmer, anything beyond a script and my brain starts smoking.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 09-11-2003 20:10 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

quote:
Originally posted by Caranorn
I wonder, would it be possible for a mod to have a file listing all it's active sprites and for CTP2 to only load those at start? This assumes using mod swapper or a similar function. That way one could keep a huge sprite library but only load those needed for a particular game. In that case sprite ID might not require a numerical limit either, though I for one would would still use that feature for standardisation.


newsprte.txt is such a library for unit sprites and there are also such files for city sprites, effect sprites and good sprites.

-Martin

DDowell is offline DDowell
Chieftain
Västerås, Sweden
Nov 2001
time: 06:31
  Old Post 09-11-2003 23:53
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Inflate your Upload Space

As far as I can understand from browsing the source, the sprite numbers in the newsprite.txt has no limit, it is only the constant k_MAX_SPRITES that cause the limit.

Therefore we could simply remove the constant and voila! No limit whatsoever!

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 10-11-2003 00:28 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#14 Report this post to a moderator
Got spare money?

quote:
Originally posted by DDowell
As far as I can understand from browsing the source, the sprite numbers in the newsprite.txt has no limit, it is only the constant k_MAX_SPRITES that cause the limit.

Therefore we could simply remove the constant and voila! No limit whatsoever!


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

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:31
  Old Post 10-11-2003 00:52 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#15 Report this post to a moderator
Support Apolyton, buy GURPS/ Alpha Centauri

is it martin when the game loads it looks in activsion\ctp2\gamedata\newsprites and there at the top is a model number

DDowell is offline DDowell
Chieftain
Västerås, Sweden
Nov 2001
time: 06:31
  Old Post 10-11-2003 03:37
Edit/Delete Message Reply w/Quote
#16 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

quote:
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.

star mouse is offline star mouse
Prince
of the Barbarians
Aug 2001
time: 16:31
  Old Post 14-11-2003 14:52
Edit/Delete Message Reply w/Quote
#17 Report this post to a moderator
Full PM-box? Change here!

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.

Caranorn is offline Caranorn
Warlord
Luxembourg, Europe
Mar 2000
time: 06:31
  Old Post 14-11-2003 18:38 Visit Caranorn's homepage!
Edit/Delete Message Reply w/Quote
#18 Report this post to a moderator
Support Apolyton, buy Civilization: The Boardgame

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...

ahenobarb is offline ahenobarb
Prince

Nov 2001
time: 05:31
  Old Post 14-11-2003 20:24
Edit/Delete Message Reply w/Quote
#19 Report this post to a moderator
Increase the size of your Attachments

quote:
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.

Gilgamensch is offline Gilgamensch
King
France
Jun 2002
time: 06:31
  Old Post 14-11-2003 21:50
Edit/Delete Message Reply w/Quote
#20 Report this post to a moderator
Support Apolyton buy from Amazon

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.

ahenobarb is offline ahenobarb
Prince

Nov 2001
time: 05:31
  Old Post 14-11-2003 22:18
Edit/Delete Message Reply w/Quote
#21 Report this post to a moderator
Increase the size of your Attachments

quote:
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.

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:31
  Old Post 15-11-2003 04:57 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#22 Report this post to a moderator
Increase Your PM Length

I recommend the first line of newsprites

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 15-11-2003 21:55 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#23 Report this post to a moderator
Support Apolyton, buy GURPS/ Alpha Centauri

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

star mouse is offline star mouse
Prince
of the Barbarians
Aug 2001
time: 16:31
  Old Post 16-11-2003 03:20
Edit/Delete Message Reply w/Quote
#24 Report this post to a moderator
Suffering from ads?

quote:
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.

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:31
  Old Post 17-11-2003 03:52 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#25 Report this post to a moderator
Enter the AD-FREE zone

how about we get the game to count the number of entry in the newspr file then that we no real number is coded

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 17-11-2003 04:07 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#26 Report this post to a moderator
Support Apolyton buy from Amazon

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

stankarp is offline stankarp
Prince
australia
Feb 2002
time: 05:31
  Old Post 18-02-2004 04:41
Edit/Delete Message Reply w/Quote
#27 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

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?

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:31
Post  Old Post 19-02-2004 23:22 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#28 Report this post to a moderator
Support Apolyton or Terrorists Win

quote:
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

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:31
  Old Post 13-04-2004 21:53 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#29 Report this post to a moderator
Support Apolyton, buy Call to Power 2

Has it been decided what the max number should be for the upcoming Apolyton Edition?

Solver is offline Solver
Apolyton Duke Of Something
Latvia, Riga
Sep 2000
time: 07:31
  Old Post 13-04-2004 22:48 Visit Solver<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#30 Report this post to a moderator
Put an end to popups!

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

quote:
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.

 
Pages (2): [ 1   2   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:31.
Apolyton Time is 00:31.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0637 seconds (92.53% PHP - 7.47% MySQL) with 36 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net