Variable overflow

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Horux
Posts: 314
Joined: Tue, 1. Apr 08, 20:13
x4

Variable overflow

Post by Horux » Sat, 26. Jan 19, 20:01

Hi,

I found a problem what in my opinion is a bug, bit it only appears when modding so I posted it here.

I tried to change the prices for all the wares, and I found out, that the maximum allowed Prices for XL ships is around 30 mil and for L, at least destroyers 56 mill. If a higher price is given then I get money for buying a ship. :sceptic: It feels like 1980, when overflows where not tested. I do not know, why are there so many decimals in a money system, without decimals. A 32 bit variable, what is small for 2019 should able to handle upt to 2 billion .
If this is mention anywhere then I did not found it.
Is there any chance of getting rid of this problem?

Edit: I tested this for an M Frigate, there I can easily reach the 100 mil per Ship. I guess I can increase the price for fighters up to 200 mil. :evil: I really do not know, why the sice is part of the price variable... :sceptic:
Code included, in case of I did something wrong.

Code: Select all

	
	<replace sel="/wares/ware[@id='ship_arg_l_destroyer_01_a']/price/@min">50000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_l_destroyer_01_a']/price/@average">50000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_l_destroyer_01_a']/price/@max">50000000</replace>	
		
	<replace sel="/wares/ware[@id='ship_arg_l_destroyer_01_b']/price/@min">60000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_l_destroyer_01_b']/price/@average">60000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_l_destroyer_01_b']/price/@max">60000000</replace>	
	
	<replace sel="/wares/ware[@id='ship_arg_xl_builder_01_a']/price/@min">100000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_builder_01_a']/price/@average">100000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_builder_01_a']/price/@max">100000000</replace>	
		
	<replace sel="/wares/ware[@id='ship_arg_xl_builder_01_b']/price/@min">90000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_builder_01_b']/price/@average">90000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_builder_01_b']/price/@max">90000000</replace>	
		
	<replace sel="/wares/ware[@id='ship_arg_xl_carrier_01_a']/price/@min">110000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_carrier_01_a']/price/@average">110000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_carrier_01_a']/price/@max">110000000</replace>	
		
	<replace sel="/wares/ware[@id='ship_arg_xl_carrier_01_b']/price/@min">67000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_carrier_01_b']/price/@average">67000000</replace>	
	<replace sel="/wares/ware[@id='ship_arg_xl_carrier_01_b']/price/@max">67000000</replace>

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Re: Variable overflow

Post by UniTrader » Sun, 27. Jan 19, 17:45

i dont think its an overflow of the visible variables. as far as i know money is stored as 64 bit integer in cents (so divide by 100 to get the credits). i think its some quirk in the price calculation, i guess somehow related to material consumption. Did you adjust the Materials required so their total value better matches the new Ship Price?


PS before there is a misunderstanding - i am replying here as Modder trying to figure this out only.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Horux
Posts: 314
Joined: Tue, 1. Apr 08, 20:13
x4

Re: Variable overflow

Post by Horux » Sun, 27. Jan 19, 18:18

Thanks for Your reply. Yes I changed the material, too.
I think it can have something to do with price calculation. But nevertheless it is somehow a overflow somewhere. Because the ingame price is repeating every 30 million. It is always between 0 and -30 million. (I did not test every value). So even for 100 million target sell price it is again near -8 million and later again -20 million.

Selling XL ships again works fine. So I can buy a ship for -20 million and sell it for 100 million. Easy way to make money.

Do You have an idea where to look in the scripts? I would really like to get rid of this problem.

Edit: Yes definitly the accumulated prices of all materials has influence on the "maximal" possible price. So I can make the ships expensive, but not without "reason" behind the resource needed.

florianlt
EGOSOFT
EGOSOFT
Posts: 1304
Joined: Mon, 22. Aug 11, 14:05
x4

Re: Variable overflow

Post by florianlt » Thu, 28. Mar 19, 14:50

If you still have this problem, could you send me the complete mod?

Horux
Posts: 314
Joined: Tue, 1. Apr 08, 20:13
x4

Re: Variable overflow

Post by Horux » Fri, 29. Mar 19, 23:59

florianlt wrote:
Thu, 28. Mar 19, 14:50
If you still have this problem, could you send me the complete mod?
No need anymore. You fixed this bug in 2.0. I just tested it again to be sure. Resource prices up to ~450million and ship prices up 700 million no overflow. So if it still happens with billions I do not care.

Thanks again.

florianlt
EGOSOFT
EGOSOFT
Posts: 1304
Joined: Mon, 22. Aug 11, 14:05
x4

Re: Variable overflow

Post by florianlt » Tue, 2. Apr 19, 08:36

Cool, thanks for letting me know.

Post Reply

Return to “X4: Foundations - Scripts and Modding”