1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

day/night working client side

This commit is contained in:
Perttu Ahola 2010-12-19 16:51:45 +02:00
parent 240499dc2c
commit 0ca9423b8b
22 changed files with 955 additions and 676 deletions

View file

@ -28,9 +28,18 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <fstream>
#include <string>
#include <sstream>
#include <jthread.h>
#include <jmutex.h>
#include <jmutexautolock.h>
#ifdef _WIN32
#include <windows.h>
#define sleep_ms(x) Sleep(x)
#else
#include <unistd.h>
#define sleep_ms(x) usleep(x*1000)
#endif
#include "common_irrlicht.h"
#include "debug.h"
#include "strfnd.h"
@ -1100,5 +1109,43 @@ private:
JMutex m_mutex;
};
class SimpleThread : public JThread
{
bool run;
JMutex run_mutex;
public:
SimpleThread():
JThread(),
run(true)
{
run_mutex.Init();
}
virtual ~SimpleThread()
{}
virtual void * Thread() = 0;
bool getRun()
{
JMutexAutoLock lock(run_mutex);
return run;
}
void setRun(bool a_run)
{
JMutexAutoLock lock(run_mutex);
run = a_run;
}
void stop()
{
setRun(false);
while(IsRunning())
sleep_ms(100);
}
};
#endif