Merge branch 'next' of ssh://git.code.sf.net/p/flightgear/flightgear into next
This commit is contained in:
commit
0272a4fa3f
4 changed files with 14 additions and 17 deletions
|
@ -47,14 +47,12 @@ FGFDM::~FGFDM()
|
||||||
{
|
{
|
||||||
for(int i=0; i<_thrusters.size(); i++) {
|
for(int i=0; i<_thrusters.size(); i++) {
|
||||||
EngRec* er = (EngRec*)_thrusters.get(i);
|
EngRec* er = (EngRec*)_thrusters.get(i);
|
||||||
delete[] er->prefix;
|
|
||||||
delete er->eng;
|
delete er->eng;
|
||||||
delete er;
|
delete er;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<_weights.size(); i++) {
|
for(int i=0; i<_weights.size(); i++) {
|
||||||
WeightRec* wr = (WeightRec*)_weights.get(i);
|
WeightRec* wr = (WeightRec*)_weights.get(i);
|
||||||
delete[] wr->prop;
|
|
||||||
delete wr;
|
delete wr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +363,7 @@ void FGFDM::getExternalInput(float dt)
|
||||||
|
|
||||||
if(t->getPropEngine()) {
|
if(t->getPropEngine()) {
|
||||||
PropEngine* p = t->getPropEngine();
|
PropEngine* p = t->getPropEngine();
|
||||||
sprintf(buf, "%s/rpm", er->prefix);
|
sprintf(buf, "%s/rpm", er->prefix.c_str());
|
||||||
p->setOmega(fgGetFloat(buf, 500) * RPM2RAD);
|
p->setOmega(fgGetFloat(buf, 500) * RPM2RAD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,7 +371,7 @@ void FGFDM::getExternalInput(float dt)
|
||||||
|
|
||||||
// Linearly "seeks" a property by the specified fraction of the way to
|
// Linearly "seeks" a property by the specified fraction of the way to
|
||||||
// the target value. Used to emulate "slowly changing" output values.
|
// the target value. Used to emulate "slowly changing" output values.
|
||||||
static void moveprop(SGPropertyNode* node, const char* prop,
|
static void moveprop(SGPropertyNode* node, const std::string& prop,
|
||||||
float target, float frac)
|
float target, float frac)
|
||||||
{
|
{
|
||||||
float val = node->getFloatValue(prop);
|
float val = node->getFloatValue(prop);
|
||||||
|
@ -875,7 +873,7 @@ void FGFDM::parsePropeller(const XMLAttributes* a)
|
||||||
sprintf(buf, "/engines/engine[%d]", _nextEngine++);
|
sprintf(buf, "/engines/engine[%d]", _nextEngine++);
|
||||||
EngRec* er = new EngRec();
|
EngRec* er = new EngRec();
|
||||||
er->eng = thruster;
|
er->eng = thruster;
|
||||||
er->prefix = strdup(buf);
|
er->prefix = buf;
|
||||||
_thrusters.add(er);
|
_thrusters.add(er);
|
||||||
|
|
||||||
_currObj = thruster;
|
_currObj = thruster;
|
||||||
|
@ -933,7 +931,7 @@ void FGFDM::parseJet(const XMLAttributes* a)
|
||||||
sprintf(buf, "/engines/engine[%d]", _nextEngine++);
|
sprintf(buf, "/engines/engine[%d]", _nextEngine++);
|
||||||
EngRec* er = new EngRec();
|
EngRec* er = new EngRec();
|
||||||
er->eng = j;
|
er->eng = j;
|
||||||
er->prefix = strdup(buf);
|
er->prefix = buf;
|
||||||
_thrusters.add(er);
|
_thrusters.add(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,7 +1133,7 @@ void FGFDM::parseWeight(const XMLAttributes* a)
|
||||||
|
|
||||||
float v[3];
|
float v[3];
|
||||||
attrf_xyz(a, v);
|
attrf_xyz(a, v);
|
||||||
wr->prop = strdup(a->getValue("mass-prop"));
|
wr->prop = std::string{a->getValue("mass-prop")};
|
||||||
wr->size = attrf(a, "size", 0);
|
wr->size = attrf(a, "size", 0);
|
||||||
wr->handle = _airplane.addWeight(v, wr->size);
|
wr->handle = _airplane.addWeight(v, wr->size);
|
||||||
_weights.add(wr);
|
_weights.add(wr);
|
||||||
|
|
|
@ -32,11 +32,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct EngRec {
|
struct EngRec {
|
||||||
char* prefix {nullptr};
|
std::string prefix;
|
||||||
Thruster* eng {nullptr};
|
Thruster* eng {nullptr};
|
||||||
};
|
};
|
||||||
struct WeightRec {
|
struct WeightRec {
|
||||||
char* prop {nullptr};
|
std::string prop;
|
||||||
float size {0};
|
float size {0};
|
||||||
int handle {0};
|
int handle {0};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1212,14 +1212,13 @@ NavDataCache::NavDataCache()
|
||||||
os << "navdata_" << versionParts[0] << "_" << versionParts[1] << ".cache";
|
os << "navdata_" << versionParts[0] << "_" << versionParts[1] << ".cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
homePath.append(os.str());
|
|
||||||
|
|
||||||
// permit additional DB connections from the same process
|
// permit additional DB connections from the same process
|
||||||
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
|
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
|
||||||
|
|
||||||
for (int t=0; t < MAX_TRIES; ++t) {
|
for (int t=0; t < MAX_TRIES; ++t) {
|
||||||
|
SGPath cachePath = homePath / os.str();
|
||||||
try {
|
try {
|
||||||
d.reset(new NavDataCachePrivate(homePath, this));
|
d.reset(new NavDataCachePrivate(cachePath, this));
|
||||||
d->init();
|
d->init();
|
||||||
//d->checkCacheFile();
|
//d->checkCacheFile();
|
||||||
// reached this point with no exception, success
|
// reached this point with no exception, success
|
||||||
|
@ -1239,14 +1238,14 @@ NavDataCache::NavDataCache()
|
||||||
d.reset();
|
d.reset();
|
||||||
|
|
||||||
// only wipe the existing if not readonly
|
// only wipe the existing if not readonly
|
||||||
if (!fgGetBool("/sim/fghome-readonly", false)) {
|
if (cachePath.exists() && !fgGetBool("/sim/fghome-readonly", false)) {
|
||||||
bool ok = homePath.remove();
|
bool ok = cachePath.remove();
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
SG_LOG(SG_NAVCACHE, SG_ALERT, "NavCache: failed to remove previous cache file");
|
SG_LOG(SG_NAVCACHE, SG_ALERT, "NavCache: failed to remove previous cache file");
|
||||||
flightgear::fatalMessageBoxThenExit(
|
flightgear::fatalMessageBoxThenExit(
|
||||||
"Unable to re-create navigation cache",
|
"Unable to re-create navigation cache",
|
||||||
"Attempting to remove the old cache failed.",
|
"Attempting to remove the old cache failed.",
|
||||||
"Location: " + homePath.utf8Str());
|
"Location: " + cachePath.utf8Str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -838,9 +838,9 @@ static naRef f_removeCommand(naContext c, naRef me, int argc, naRef* args)
|
||||||
const string commandName(naStr_data(args[0]));
|
const string commandName(naStr_data(args[0]));
|
||||||
bool ok = nasalSys->removeCommand(commandName);
|
bool ok = nasalSys->removeCommand(commandName);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
naRuntimeError(c, "Failed to remove command:%s", commandName.c_str());
|
return naNum(0);
|
||||||
}
|
}
|
||||||
return naNil();
|
return naNum(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static naRef f_open(naContext c, naRef me, int argc, naRef* args)
|
static naRef f_open(naContext c, naRef me, int argc, naRef* args)
|
||||||
|
|
Loading…
Reference in a new issue