- push Robert's patch for racetrack
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6750 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 7f5ada5b685903878556b366c8758da32da6a6a3 Former-commit-id: 89d6d38afd09e1b3456b5ec404245ed3d84bfce6
This commit is contained in:
parent
5ffdc54e9d
commit
88fc10796e
1 changed files with 24 additions and 27 deletions
|
@ -39,8 +39,11 @@
|
||||||
#include "racetrack.h"
|
#include "racetrack.h"
|
||||||
|
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include "racewebmetar.h"
|
#include "racewebmetar.h"
|
||||||
|
|
||||||
static ReWebMetarCloud webMetarCloud;
|
static ReWebMetarCloud webMetarCloud;
|
||||||
static ReWebMetarRunway webMetarRunway;
|
static ReWebMetarRunway webMetarRunway;
|
||||||
static ReWebMetarVisibility webMetarVisibility;
|
static ReWebMetarVisibility webMetarVisibility;
|
||||||
|
@ -66,7 +69,7 @@ static void reTrackUpdatePhysics(void);
|
||||||
int
|
int
|
||||||
ReTrackInit(void)
|
ReTrackInit(void)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[1024];
|
||||||
|
|
||||||
const char *trackName;
|
const char *trackName;
|
||||||
const char *catName;
|
const char *catName;
|
||||||
|
@ -520,14 +523,19 @@ reTrackInitRealWeather(void)
|
||||||
reTrackInitSimuWeather();
|
reTrackInitSimuWeather();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[1024];
|
||||||
snprintf(buffer, 255, "%sconfig/weather.txt", GetLocalDir());
|
snprintf(buffer, sizeof(buffer), "%sconfig/weather.txt", GetLocalDir());
|
||||||
|
|
||||||
std::string data = buffer;
|
std::string data = buffer;
|
||||||
GfLogDebug("Path weather.txt : %s\n", data.c_str());
|
GfLogDebug("Path weather.txt : %s\n", data.c_str());
|
||||||
|
|
||||||
std::ifstream file(data.c_str());
|
std::ifstream file(data.c_str());
|
||||||
|
|
||||||
|
if (!file.is_open()) {
|
||||||
|
GfLogError("Failed to open %s\n", data.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// compter le nombre de lignes
|
// compter le nombre de lignes
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::string line;
|
std::string line;
|
||||||
|
@ -631,6 +639,7 @@ reTrackInitRealWeather(void)
|
||||||
trackLocal->clouds2 = webMetar->getCloud2();
|
trackLocal->clouds2 = webMetar->getCloud2();
|
||||||
trackLocal->cloud_altitude2 = webMetar->getAltitude2();
|
trackLocal->cloud_altitude2 = webMetar->getAltitude2();
|
||||||
GfLogDebug("Clouds 2 = %i - Alitude cloud 2 = %.3f\n", trackLocal->clouds2, trackLocal->cloud_altitude2);
|
GfLogDebug("Clouds 2 = %i - Alitude cloud 2 = %.3f\n", trackLocal->clouds2, trackLocal->cloud_altitude2);
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
trackLocal->clouds3 = webMetar->getCloud3();
|
trackLocal->clouds3 = webMetar->getCloud3();
|
||||||
trackLocal->cloud_altitude3 = webMetar->getAltitude3();
|
trackLocal->cloud_altitude3 = webMetar->getAltitude3();
|
||||||
|
@ -708,35 +717,22 @@ reTrackInitSimuWeather(void)
|
||||||
#else
|
#else
|
||||||
gmtime_r(&now_sec, &now);
|
gmtime_r(&now_sec, &now);
|
||||||
#endif
|
#endif
|
||||||
char month[2] = "";
|
|
||||||
char day[2] = "";
|
|
||||||
|
|
||||||
snprintf(day, 3, "%i", now.tm_mday);
|
std::ostringstream weatherfile;
|
||||||
snprintf(month, 3, "%i", now.tm_mon + 1);
|
weatherfile << GetDataDir() << "data/weather/" << trackLocal->station << "/"
|
||||||
GfLogDebug("Day = %s - Month = %s\n", day, month);
|
<< std::setw(2) << std::setfill('0') << std::right << now.tm_mday << "-"
|
||||||
|
<< std::setw(2) << std::setfill('0') << std::right << (now.tm_mon + 1) << ".txt";
|
||||||
|
|
||||||
char buffer[256];
|
GfLogDebug("Path file weather : %s\n", weatherfile.str().c_str());
|
||||||
snprintf(buffer, 255, "%sdata/weather/", GetDataDir());
|
|
||||||
std::string weatherfile = buffer;
|
|
||||||
weatherfile = weatherfile + trackLocal->station+"/";
|
|
||||||
|
|
||||||
if (now.tm_mday < 10)
|
std::ifstream file(weatherfile.str().c_str());
|
||||||
weatherfile = weatherfile + "0" + day + "-";
|
|
||||||
/*else if (now.tm_mday == 10 || now.tm_mday == 20 || now.tm_mday == 30)
|
|
||||||
weatherfile = weatherfile + day + "0-";*/
|
|
||||||
else
|
|
||||||
weatherfile = weatherfile + day + "-";
|
|
||||||
|
|
||||||
if ((now.tm_mon + 1) < 10)
|
if (!file.is_open())
|
||||||
weatherfile = weatherfile + "0" + month + ".txt";
|
{
|
||||||
/*else if (now.tm_mon == 10)
|
GfLogError("Failed to open %s\n", weatherfile.str().c_str());
|
||||||
weatherfile = weatherfile + month + "0-";*/
|
|
||||||
else
|
|
||||||
weatherfile = weatherfile + month + ".txt";
|
|
||||||
|
|
||||||
GfLogDebug("Path file weather : %s\n", weatherfile.c_str());
|
return;
|
||||||
|
}
|
||||||
std::ifstream file(weatherfile.c_str());
|
|
||||||
|
|
||||||
// compter le nombre de lignes
|
// compter le nombre de lignes
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -839,6 +835,7 @@ reTrackInitSimuWeather(void)
|
||||||
trackLocal->clouds2 = webMetar->getCloud2();
|
trackLocal->clouds2 = webMetar->getCloud2();
|
||||||
trackLocal->cloud_altitude2 = webMetar->getAltitude2();
|
trackLocal->cloud_altitude2 = webMetar->getAltitude2();
|
||||||
GfLogDebug("Clouds 2 = %i - Alitude cloud 2 = %.3f\n", trackLocal->clouds2, trackLocal->cloud_altitude2);
|
GfLogDebug("Clouds 2 = %i - Alitude cloud 2 = %.3f\n", trackLocal->clouds2, trackLocal->cloud_altitude2);
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
trackLocal->clouds3 = webMetar->getCloud3();
|
trackLocal->clouds3 = webMetar->getCloud3();
|
||||||
trackLocal->cloud_altitude3 = webMetar->getAltitude3();
|
trackLocal->cloud_altitude3 = webMetar->getAltitude3();
|
||||||
|
|
Loading…
Reference in a new issue