Shiptype: store the slot informations in an map<string, int>

This allows the system to decouple ship definition from the rest of the
Lua, thus returning to the previous state and easing any future
migration of the ship definition file format.

Conflicts:
	src/LuaModelViewer.cpp
	src/Pi.cpp
	src/Ship.cpp
	src/ShipType.cpp
	src/ShipType.h
master
Simon Chopin 2012-10-22 23:53:06 +02:00
parent a6ddf64630
commit fbdc9b3543
2 changed files with 8 additions and 0 deletions

View File

@ -111,6 +111,12 @@ int _define_ship(lua_State *L, ShipType::Tag tag, std::vector<ShipType::Id> *lis
s.hullMass = t.Get("hull_mass", 100);
s.fuelTankMass = t.Get("fuel_tank_mass", 5);
LuaTable slot_table = t.Sub("slots");
if (slot_table.GetLua()) {
s.slots = slot_table.GetMap<std::string, int>();
}
lua_pop(L, 1);
// fuel_use_rate can be given in two ways
float thruster_fuel_use = 0;
s.effectiveExhaustVelocity = t.Get("effective_exhaust_velocity", -1.0f);

View File

@ -9,6 +9,7 @@
#include "EquipType.h"
#include <vector>
#include <map>
#include <string>
struct ShipType {
enum Thruster { // <enum scope='ShipType' name=ShipTypeThruster prefix=THRUSTER_ public>
@ -55,6 +56,7 @@ struct ShipType {
DualLaserOrientation orient;
} gunMount[GUNMOUNT_MAX];
int equipSlotCapacity[Equip::SLOT_MAX];
std::map<std::string, int> slots;
int capacity; // tonnes
int hullMass;
float effectiveExhaustVelocity; // velocity at which the propellant escapes the engines