mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
ESSImport: convert weather state
This commit is contained in:
parent
697ab16ec5
commit
9b3728d878
3 changed files with 65 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <components/esm/dialoguestate.hpp>
|
||||
#include <components/esm/custommarkerstate.hpp>
|
||||
#include <components/esm/loadcrea.hpp>
|
||||
#include <components/esm/weatherstate.hpp>
|
||||
|
||||
#include "importcrec.hpp"
|
||||
#include "importcntc.hpp"
|
||||
|
@ -455,11 +456,69 @@ public:
|
|||
class ConvertGAME : public Converter
|
||||
{
|
||||
public:
|
||||
ConvertGAME() : mHasGame(false) {}
|
||||
|
||||
std::string toString(int weatherId)
|
||||
{
|
||||
switch (weatherId)
|
||||
{
|
||||
case 0:
|
||||
return "clear";
|
||||
case 1:
|
||||
return "cloudy";
|
||||
case 2:
|
||||
return "foggy";
|
||||
case 3:
|
||||
return "overcast";
|
||||
case 4:
|
||||
return "rain";
|
||||
case 5:
|
||||
return "thunderstorm";
|
||||
case 6:
|
||||
return "ashstorm";
|
||||
case 7:
|
||||
return "blight";
|
||||
case 8:
|
||||
return "snow";
|
||||
case 9:
|
||||
return "blizzard";
|
||||
case -1:
|
||||
return "";
|
||||
default:
|
||||
{
|
||||
std::stringstream error;
|
||||
error << "unknown weather id: " << weatherId;
|
||||
throw std::runtime_error(error.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void read(ESM::ESMReader &esm)
|
||||
{
|
||||
GAME game;
|
||||
game.load(esm);
|
||||
mGame.load(esm);
|
||||
mHasGame = true;
|
||||
}
|
||||
|
||||
virtual void write(ESM::ESMWriter &esm)
|
||||
{
|
||||
if (!mHasGame)
|
||||
return;
|
||||
esm.startRecord(ESM::REC_WTHR);
|
||||
ESM::WeatherState weather;
|
||||
weather.mCurrentWeather = toString(mGame.mGMDT.mCurrentWeather);
|
||||
weather.mNextWeather = toString(mGame.mGMDT.mNextWeather);
|
||||
weather.mRemainingTransitionTime = mGame.mGMDT.mWeatherTransition/100.f*(0.015*24*3600);
|
||||
weather.mHour = mContext->mHour;
|
||||
weather.mWindSpeed = 0.f;
|
||||
weather.mTimePassed = 0.0;
|
||||
weather.mFirstUpdate = false;
|
||||
weather.save(esm);
|
||||
esm.endRecord(ESM::REC_WTHR);
|
||||
}
|
||||
|
||||
private:
|
||||
bool mHasGame;
|
||||
GAME mGame;
|
||||
};
|
||||
|
||||
/// Running global script
|
||||
|
|
|
@ -8,6 +8,9 @@ namespace ESSImport
|
|||
void GAME::load(ESM::ESMReader &esm)
|
||||
{
|
||||
esm.getHNT(mGMDT, "GMDT");
|
||||
mGMDT.mWeatherTransition &= (0x000000ff);
|
||||
mGMDT.mSecundaPhase &= (0x000000ff);
|
||||
mGMDT.mMasserPhase &= (0x000000ff);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ESSImport
|
|||
int mCurrentWeather, mNextWeather;
|
||||
int mWeatherTransition; // 0-100 transition between weathers, top 3 bytes may be garbage
|
||||
float mTimeOfNextTransition; // weather changes when gamehour == timeOfNextTransition
|
||||
int masserPhase, secundaPhase; // top 3 bytes may be garbage
|
||||
int mMasserPhase, mSecundaPhase; // top 3 bytes may be garbage
|
||||
};
|
||||
|
||||
GMDT mGMDT;
|
||||
|
|
Loading…
Reference in a new issue