Item Price Bug?

I've come across this problem when setting prices for items to be sold in shops. (This is in plug in mode by the way.)

If I set the value (cost to buy) of the item higher than 32,500, after saving, if I open the item back up in the item editor, the price has been changed to some negative value number. Example, 65,000 becomes -536.

If I check the item in the shop in the game, the item appears without any price when you click on it to find out the price and no price shows up.

Anyone know why this happens? Or if indeed, it is a bug in Coldstone. Any prices under the 32500 amount seem to work just fine.

------------------
CRH

(This message has been edited by ChristopherH (edited 01-25-2002).)

Quote

Originally posted by ChristopherH:
**I've come across this problem when setting prices for items to be sold in shops. (This is in plug in mode by the way.)

If I set the value (cost to buy) of the item higher than 32,500, after saving, if I open the item back up in the item editor, the price has been changed to some negative value number. Example, 65,000 becomes -536.

If I check the item in the shop in the game, the item appears without any price when you click on it to find out the price and no price shows up.

Anyone know why this happens? Or if indeed, it is a bug in Coldstone. Any prices under the 325000 amount seem to work just fine.
**

This is probably because the item price is saved in a two byte variable, which ranges from -32767 to 32768. Any value larger than 32768 is thought as negative (i.e., it is considered as the value - 65536). BTW 65536 is 2^16, and 32768 is 2^15.

Hope this helps,

Alois

------------------

Quote

Originally posted by alois:
**This is probably because the item price is saved in a two byte variable, which ranges from -32767 to 32768. Any value larger than 32768 is thought as negative (i.e., it is considered as the value - 65536). BTW 65536 is 2^16, and 32768 is 2^15.

Hope this helps,

Alois
**

Why on earth would they use a signed value? This should be a pretty easy fix. I'm not familiar with primatives in Real Basic, but I'm guessing this is an int type. They should use an unsigned 4 byte variable, like an unsigned long. It's not like there are that many items that it would chew up that much more memory.

Yeah, I'm sure that nobody needs a $4 billion item, but I could see somebody wanting a $100,000 item, which even an unsigned int can't handle.

Quote

Originally posted by alois:
**This is probably because the item price is saved in a two byte variable, which ranges from -32767 to 32768. Any value larger than 32768 is thought as negative (i.e., it is considered as the value - 65536). BTW 65536 is 2^16, and 32768 is 2^15.

Hope this helps,

Alois

**

Thanks for the quick response. Looks like I won't be having any real estate offices or car dealerships. 🙂 Ah well.

------------------
CRH

Quote

Originally posted by XxtraLarGe:
**Why on earth would they use a signed value? This should be a pretty easy fix. I'm not familiar with primatives in Real Basic, but I'm guessing this is an int type. They should use an unsigned 4 byte variable, like an unsigned long. It's not like there are that many items that it would chew up that much more memory.

Yeah, I'm sure that nobody needs a $4 billion item, but I could see somebody wanting a $100,000 item, which even an unsigned int can't handle.**

Probably so you can make an item go both ways -- cost money, or give money, etc.

Flexibility?

------------------
quitcherbellyachin.
---
New Fortress of Die Nacht released! (12/20) (url="http://"http://aviary.damnsw.net")Download it from here!(/url) | | (url="http://"http://aviary.damnsw.net/downloads/dienachtd5.sit")direct download(/url) | | (url="http://"http://aviary.damnsw.net/fortress/progresslog.html")Progress Log (12/20)(/url)

Quote

Originally posted by theGlueBubble:
**Probably so you can make an item go both ways -- cost money, or give money, etc.

Flexibility?

**

Since the value of the coin is arbitrary -- it could be sterling, it could be yen, it could be gold pieces -- the question is whether there are recurrent, lump-sum purchases in your game that are different by a factor of 32768. If a cheap meal at the inn costs "1" (maybe 4 bucks US?), then you could afford 32,768 of something else (131,000 dollars US; that'll get you a really nice car, or downpayment on a condo.)

Or if your character is buying firewood one stick at a time, they aren't likely to be buying castles on the used market.

A suggestion, tho; make them "bank" it. Convert large sums into jewelry or junk bonds or real estate, which are tracked with a different variable or as items...

------------------
everywhere else, it's --
"Nomuse"

Quote

Originally posted by Commander Arashi:
**< snip>
A suggestion, tho; make them "bank" it. Convert large sums into jewelry or junk bonds or real estate, which are tracked with a different variable or as items...
**

Thanks to everyone who responded to my question.

It really only came about because I was trying to set a price for a weapon above 32500.
(The claws weapon in trinity cost 22,000 gold pieces and since I wanted to make a weapon that outclassed it, I wanted the player to have to pay a somewhat exorbitant price for it.
I guess I just ran into one of the set limitations applied in the engine. No big deal in a way, I'll just keep my weapon prices under the max of 32768. As for the real estate and car dealership comment I made, it was more of a throw away comment responding to the low price that could be set for things if one stayed with-in the price limit that seems to be set. Of course one could come up with work arounds if they thought about it long enough.

Thanks again to all who responded.

------------------
CRH