1
0
Fork 0

Merge branch 'next' of ssh://git.code.sf.net/p/flightgear/flightgear into next

This commit is contained in:
Erik Hofman 2020-09-04 16:03:39 +02:00
commit 0272a4fa3f
4 changed files with 14 additions and 17 deletions

View file

@ -47,14 +47,12 @@ FGFDM::~FGFDM()
{
for(int i=0; i<_thrusters.size(); i++) {
EngRec* er = (EngRec*)_thrusters.get(i);
delete[] er->prefix;
delete er->eng;
delete er;
}
for(int i=0; i<_weights.size(); i++) {
WeightRec* wr = (WeightRec*)_weights.get(i);
delete[] wr->prop;
delete wr;
}
@ -365,7 +363,7 @@ void FGFDM::getExternalInput(float dt)
if(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);
}
}
@ -373,7 +371,7 @@ void FGFDM::getExternalInput(float dt)
// Linearly "seeks" a property by the specified fraction of the way to
// 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 val = node->getFloatValue(prop);
@ -875,7 +873,7 @@ void FGFDM::parsePropeller(const XMLAttributes* a)
sprintf(buf, "/engines/engine[%d]", _nextEngine++);
EngRec* er = new EngRec();
er->eng = thruster;
er->prefix = strdup(buf);
er->prefix = buf;
_thrusters.add(er);
_currObj = thruster;
@ -933,7 +931,7 @@ void FGFDM::parseJet(const XMLAttributes* a)
sprintf(buf, "/engines/engine[%d]", _nextEngine++);
EngRec* er = new EngRec();
er->eng = j;
er->prefix = strdup(buf);
er->prefix = buf;
_thrusters.add(er);
}
@ -1135,7 +1133,7 @@ void FGFDM::parseWeight(const XMLAttributes* a)
float v[3];
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->handle = _airplane.addWeight(v, wr->size);
_weights.add(wr);

View file

@ -32,11 +32,11 @@ public:
private:
struct EngRec {
char* prefix {nullptr};
std::string prefix;
Thruster* eng {nullptr};
};
struct WeightRec {
char* prop {nullptr};
std::string prop;
float size {0};
int handle {0};
};

View file

@ -1212,14 +1212,13 @@ NavDataCache::NavDataCache()
os << "navdata_" << versionParts[0] << "_" << versionParts[1] << ".cache";
}
homePath.append(os.str());
// permit additional DB connections from the same process
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
for (int t=0; t < MAX_TRIES; ++t) {
SGPath cachePath = homePath / os.str();
try {
d.reset(new NavDataCachePrivate(homePath, this));
d.reset(new NavDataCachePrivate(cachePath, this));
d->init();
//d->checkCacheFile();
// reached this point with no exception, success
@ -1239,14 +1238,14 @@ NavDataCache::NavDataCache()
d.reset();
// only wipe the existing if not readonly
if (!fgGetBool("/sim/fghome-readonly", false)) {
bool ok = homePath.remove();
if (cachePath.exists() && !fgGetBool("/sim/fghome-readonly", false)) {
bool ok = cachePath.remove();
if (!ok) {
SG_LOG(SG_NAVCACHE, SG_ALERT, "NavCache: failed to remove previous cache file");
flightgear::fatalMessageBoxThenExit(
"Unable to re-create navigation cache",
"Attempting to remove the old cache failed.",
"Location: " + homePath.utf8Str());
"Location: " + cachePath.utf8Str());
}
}
}

View file

@ -838,9 +838,9 @@ static naRef f_removeCommand(naContext c, naRef me, int argc, naRef* args)
const string commandName(naStr_data(args[0]));
bool ok = nasalSys->removeCommand(commandName);
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)