.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Space Empires: IV & V (http://forum.shrapnelgames.com/forumdisplay.php?f=20)
-   -   Modder warning - potential range check errors (http://forum.shrapnelgames.com/showthread.php?t=1641)

Barnacle Bill January 28th, 2001 01:00 PM

Modder warning - potential range check errors
 
I have discovered a way you can introduce range check errors with a mod that folks might want to be aware of. I got used to being able to lay all the mines I could carry from a transport full of cargo bays with only one mine layer component, so when MM changed it to 1 per turn per mine layer component I modded it back. I gave the mine layer components a per strategic turn launch ability of 3056, which was calculated to support a large transport loaded with Mine I's. Got through a full game without any problems.

Second game with this mod installed, I tried a stategic experiment: play like a neutral race until some AI creates first contact by entering my home system. This allows the AI's to get really big & advanced, even though the game started at low tech. I started getting RCE's during the AI's turns. Investigation showed that every RCE was the result of a dreadnought-hulled mine layer (loaded with max mine layer components - the one I counted had 26) trying to remote launch mines.

I theorized that there is some number the program uses for how many mines a particular ship can launch in a turn, and if this is too big (probably bigger than the word size allotted) an RCE occurs even though the number of mines actually being launched is very small (none of them had more than 10 mines aboard total). So, I changed the number in components.txt from 3056 per strategic turn to 459 (calculated to support a large transport carrying Mine III's). No RCE's since this change.

The long-term fix will be to edit all the AI design files to design mine layer ships the way I do, then put the value back to 3056.

Anyway, it looks like there are some inherent maximum values of the parameters in the text files that can bite you.



[This message has been edited by Barnacle Bill (edited 28 January 2001).]

Tenryu January 28th, 2001 03:18 PM

Re: Modder warning - potential range check errors
 
Oh yeah, Bill, they're around. I've attributed some of my problems to the same cause.

I got them in Setting.txt. I think by raising the "Planet Value High Resources" to 5000000.

Don't think it liked the "Plr Planet Values" at 1000000, 3000000, and 5000000 either.

Of course, it could have been the fact that I was using these setting in a finite resource game. We know that's broken.

Barnacle Bill January 28th, 2001 03:36 PM

Re: Modder warning - potential range check errors
 
I'm not sure this really counts as a "bug" for MM to try to fix. More of a program limitation that modders need to watch out for. There was not a problem with the component being able to launch 3056 mines per turn. Where it "broke" was when the AI put 26 of those components in the same ship, which a human would not do - no need, since launching mines in combat is useless so if 1 component will launch all you can carry...you get more cargo capacity cheaper with cargo bays.

[This message has been edited by Barnacle Bill (edited 28 January 2001).]

ColdSteel January 28th, 2001 06:06 PM

Re: Modder warning - potential range check errors
 
These aren't really bugs. All programs use tables or subscripts to store game information. Those have finate sizes. There are also defined maximum sizes for other variables used to manuipulate and access these tables as well as for other stuff as well. The point is that in most games the values that go into these are hard coded in the program or in associated data files that no one can touch or change except the developer. So, when the size of one of these tables is exceeded it means the progam has a bug because it doesn't account for a condition that wasn't anticipated. Not the case in SE4 however, we get to actually play with the data values that are acted on by the game. MM made them external. If we make them too big you blow off the end of an array in the program somewhere and get the RCEs. Probably what MM should do at some point is add a "Max Size" comment to each of the setting in the data files so that modders won't exceed the game's variable limits. Right now we have to do it by trial and error as described here.

tictoc January 29th, 2001 02:20 AM

Re: Modder warning - potential range check errors
 
hi, have you posted to MM with your results, i'm sure a specific finding is better than a save, every posting to them helps, good work friend.

tic

jimbob55 January 29th, 2001 10:39 PM

Re: Modder warning - potential range check errors
 
The mine laying problem could have been due to your DN minelayer trying to launch 79456 mines in one turn....This is a little outside the unsigned int limit of 65,536.
A minelaying component that lays 'only' 100 mines per turn would fix the problem.

Best to limit any values you edit to the restrictions of common data type.
unsigned (unsigned int) 0 to 65535
long int ± 2 billions
unsigned long int 0 to 4 billion
float 3.4 ±e38
double 1.7 ±e308

Unfortunately, I have no idea which type is used for which values in the game....

Barnacle Bill January 30th, 2001 05:11 AM

Re: Modder warning - potential range check errors
 
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by jimbob55:
The mine laying problem could have been due to your DN minelayer trying to launch 79456 mines in one turn....This is a little outside the unsigned int limit of 65,536.
A minelaying component that lays 'only' 100 mines per turn would fix the problem.

Best to limit any values you edit to the restrictions of common data type.
unsigned (unsigned int) 0 to 65535
long int ± 2 billions
unsigned long int 0 to 4 billion
float 3.4 ±e38
double 1.7 ±e308

Unfortunately, I have no idea which type is used for which values in the game....
<HR></BLOCKQUOTE>

I'm pretty sure that is the problem. Not that it tried to launch that many, as it only had 5 on board. I think when it tried to launch, though, the game checked its total capacity and found it too high. Again, when I lower the value to 459 per turn, the problem went away.



All times are GMT -4. The time now is 03:59 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.