Listing 6. Loading Vehicle Physics Constants from the XML Configuration File

const char *World::CFG_VEHICLES_NUMTYPES =
            "shmaffic/vehicles?numtypes";

const char *World::CFG_VEHICLE_LENGTH   =
            "shmaffic/vehicles/vehicle?length";
const char *World::CFG_VEHICLE_SLOWDIST =
            "shmaffic/vehicles/vehicle?slowdistance";
const char *World::CFG_VEHICLE_STOPDIST =
            "shmaffic/vehicles/vehicle?stopdistance";
const char *World::CFG_VEHICLE_MAXSPEED =
            "shmaffic/vehicles/vehicle?maxspeed";
const char *World::CFG_VEHICLE_ACCEL    =
            "shmaffic/vehicles/vehicle?accel";

void World::loadVehiclePhysics()
{
  VPhysicsOptions *p; // ptr to new vehicle
  int    RawLength,   // scratch vehicle parameters
         RawSlow,
         RawHalt,
         RawMaxSpeed;
  double RawMaxAccel;

  // # "vehicle types"
  int NumTypes = Cfg->int_attr_first(
                  CFG_VEHICLES_NUMTYPES);

  VehiclePhysicsOpts = new vector<VPhysicsOptions *>
                 (NumTypes);

  for (int i = 0; i < NumTypes; i++){
    RawLength   = Cfg->int_attr_nth((i+1),
                       CFG_VEHICLE_LENGTH);
    RawSlow     = Cfg->int_attr_nth((i+1),
                       CFG_VEHICLE_SLOWDIST);
    RawHalt     = Cfg->int_attr_nth((i+1),
                       CFG_VEHICLE_STOPDIST);
    RawMaxSpeed = Cfg->int_attr_nth((i+1),
                       CFG_VEHICLE_MAXSPEED);
    RawMaxAccel = Cfg->int_attr_nth((i+1),
                       CFG_VEHICLE_ACCEL);

    p = new VPhysicsOptions(RawLength,RawSlow,
                            RawHalt,RawMaxSpeed,
             RawMaxAccel);
    (*VehiclePhysicsOpts)[i] = p;
  }
}
//