store ship base-price as a double in C++ (to match Lua)

fixes #3129
master
John Bartholomew 2014-08-15 19:16:19 +01:00
parent 0386f9c0f6
commit 209e8abbe8
3 changed files with 8 additions and 5 deletions

View File

@ -214,7 +214,7 @@ void LuaShipDef::Register()
pi_lua_settable(l, "capacity", st.capacity);
pi_lua_settable(l, "hullMass", st.hullMass);
pi_lua_settable(l, "fuelTankMass", st.fuelTankMass);
pi_lua_settable(l, "basePrice", double(st.baseprice)*0.01);
pi_lua_settable(l, "basePrice", st.baseprice);
pi_lua_settable(l, "minCrew", st.minCrew);
pi_lua_settable(l, "maxCrew", st.maxCrew);
pi_lua_settable(l, "hyperdriveClass", st.hyperdriveClass);

View File

@ -41,7 +41,7 @@ static double GetEffectiveExhaustVelocity(double fuelTankMass, double thrusterFu
static bool ShipIsUnbuyable(const ShipType::Id &id)
{
const ShipType &t = ShipType::types[id];
return (t.baseprice == 0);
return is_zero_exact(t.baseprice);
}
static std::string s_currentShipFile;
@ -115,8 +115,7 @@ int _define_ship(lua_State *L, ShipType::Tag tag, std::vector<ShipType::Id> *lis
Output("Warning: Both thruster_fuel_use and effective_exhaust_velocity defined for %s, using effective_exhaust_velocity.\n", s.modelName.c_str());
}
s.baseprice = t.Get("price", 0);
s.baseprice *= 100; // in hundredths of credits
s.baseprice = t.Get("price", 0.0);
s.minCrew = t.Get("min_crew", 1);
s.maxCrew = t.Get("max_crew", 1);

View File

@ -59,7 +59,11 @@ struct ShipType {
int hullMass;
float effectiveExhaustVelocity; // velocity at which the propellant escapes the engines
int fuelTankMass; //full fuel tank mass, on top of hullMass
int baseprice;
// storing money as a double is weird, but the value is a double on the Lua side anyway,
// so we don't lose anything by storing it as a double here too
double baseprice;
int hyperdriveClass;
vector3d cameraOffset;
int minCrew, maxCrew; // XXX really only for Lua, but needs to be declared in the ship def