1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 22:45:34 +00:00

implemented GetCurrentWeather script function

This commit is contained in:
scrawl 2012-02-25 21:34:38 +01:00
parent 8d5783d75d
commit d77d5080bd
6 changed files with 59 additions and 1 deletions

View file

@ -119,4 +119,5 @@ op 0x200013b: twf
op 0x200013c: FadeIn op 0x200013c: FadeIn
op 0x200013d: FadeOut op 0x200013d: FadeOut
op 0x200013e: FadeTo op 0x200013e: FadeTo
opcodes 0x200013f-0x3ffffff unused op 0x200013f: GetCurrentWeather
opcodes 0x2000140-0x3ffffff unused

View file

@ -80,11 +80,25 @@ namespace MWScript
} }
}; };
class OpGetCurrentWeather : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
runtime.push (context.getWorld().getCurrentWeather());
}
};
const int opcodeToggleSky = 0x2000021; const int opcodeToggleSky = 0x2000021;
const int opcodeTurnMoonWhite = 0x2000022; const int opcodeTurnMoonWhite = 0x2000022;
const int opcodeTurnMoonRed = 0x2000023; const int opcodeTurnMoonRed = 0x2000023;
const int opcodeGetMasserPhase = 0x2000024; const int opcodeGetMasserPhase = 0x2000024;
const int opcodeGetSecundaPhase = 0x2000025; const int opcodeGetSecundaPhase = 0x2000025;
const int opcodeGetCurrentWeather = 0x200013f;
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions)
{ {
@ -94,6 +108,7 @@ namespace MWScript
extensions.registerInstruction ("turnmoonred", "", opcodeTurnMoonRed); extensions.registerInstruction ("turnmoonred", "", opcodeTurnMoonRed);
extensions.registerFunction ("getmasserphase", 'l', "", opcodeGetMasserPhase); extensions.registerFunction ("getmasserphase", 'l', "", opcodeGetMasserPhase);
extensions.registerFunction ("getsecundaphase", 'l', "", opcodeGetSecundaPhase); extensions.registerFunction ("getsecundaphase", 'l', "", opcodeGetSecundaPhase);
extensions.registerFunction ("getcurrentweather", 'l', "", opcodeGetCurrentWeather);
} }
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter)
@ -103,6 +118,7 @@ namespace MWScript
interpreter.installSegment5 (opcodeTurnMoonRed, new OpTurnMoonRed); interpreter.installSegment5 (opcodeTurnMoonRed, new OpTurnMoonRed);
interpreter.installSegment5 (opcodeGetMasserPhase, new OpGetMasserPhase); interpreter.installSegment5 (opcodeGetMasserPhase, new OpGetMasserPhase);
interpreter.installSegment5 (opcodeGetSecundaPhase, new OpGetSecundaPhase); interpreter.installSegment5 (opcodeGetSecundaPhase, new OpGetSecundaPhase);
interpreter.installSegment5 (opcodeGetCurrentWeather, new OpGetCurrentWeather);
} }
} }
} }

View file

@ -316,6 +316,9 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen
mWeatherSettings["blizzard"] = blizzard; mWeatherSettings["blizzard"] = blizzard;
setWeather("foggy", true); setWeather("foggy", true);
// const ESM::Region *region =
// context.getWorld().getStore().regions.find (cell->region);
} }
void WeatherManager::setWeather(const String& weather, bool instant) void WeatherManager::setWeather(const String& weather, bool instant)
@ -661,3 +664,32 @@ void WeatherManager::setDate(const int day, const int month)
mDay = day; mDay = day;
mMonth = month; mMonth = month;
} }
unsigned int WeatherManager::getWeatherID() const
{
// Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather
if (mCurrentWeather == "clear")
return 0;
else if (mCurrentWeather == "cloudy")
return 1;
else if (mCurrentWeather == "foggy")
return 2;
else if (mCurrentWeather == "overcast")
return 3;
else if (mCurrentWeather == "rain")
return 4;
else if (mCurrentWeather == "thunder")
return 5;
else if (mCurrentWeather == "ashstorm")
return 6;
else if (mCurrentWeather == "blight")
return 7;
else if (mCurrentWeather == "snow")
return 8;
else if (mCurrentWeather == "blizzard")
return 9;
else
return 0;
}

View file

@ -233,6 +233,8 @@ namespace MWWorld
void setDate(const int day, const int month); void setDate(const int day, const int month);
unsigned int getWeatherID() const;
private: private:
float mHour; float mHour;
int mDay, mMonth; int mDay, mMonth;

View file

@ -736,6 +736,11 @@ namespace MWWorld
return false; return false;
} }
int World::getCurrentWeather() const
{
return mWeatherManager->getWeatherID();
}
OEngine::Render::Fader* World::getFader() OEngine::Render::Fader* World::getFader()
{ {
return mRendering->getFader(); return mRendering->getFader();

View file

@ -164,6 +164,8 @@ namespace MWWorld
bool toggleSky(); bool toggleSky();
///< \return Resulting mode ///< \return Resulting mode
int getCurrentWeather() const;
int getMasserPhase() const; int getMasserPhase() const;
int getSecundaPhase() const; int getSecundaPhase() const;