Page 1 of 1

Environment::getTimeOfDay Always returning same value

PostPosted: Thu Jun 18, 2015 18:43
by BrandonReese
I have been working on adding ambient sounds on the client side and I have ran into a problem with getTimeOfDay. It's probably a C++ noob problem. I have created a new class, ambiance.cpp. In client.cpp I initialize m_ambiance in Client::Client and pass m_env to the ambiance class constructor (https://github.com/Bremaweb/minetest/bl ... t.cpp#L284). m_env works fine with .getLocalPlayer(), .getMap().getNodeNoEx(), etc... but when I use m_env.getTimeOfDay() it always returns 9000 (https://github.com/Bremaweb/minetest/bl ... e.cpp#L177).

Is anybody willing to shed some light on what I might have done wrong, or what .getTimeOfDay may be doing wrong?

Re: Environment::getTimeOfDay Always returning same value

PostPosted: Sat Jun 20, 2015 11:20
by TeTpaAka
https://github.com/Bremaweb/minetest/bl ... ance.h#L28
You probably want a pointer to the environment instead of a hard copy.

Also my compiler complains about the use of c++11. If you want this code to be included to the main codebase, you should avoid c++11.