This adds a chat console the server owner can use for administration
or to talk with players.
It runs in its own thread, which makes the user interface immune to
the server's lag, behaving just like a client, except timeout.
As it uses the same console code as the f10 console, things like nick
completion or a scroll buffer basically come for free.
The terminal itself is written in a general way so that adding a
client version later on is just about implementing an interface.
Fatal errors are printed after the console exists and the ncurses
terminal buffer gets cleaned up with endwin(), so that the error still
remains visible.
The server owner can chose their username their entered text will
have in chat and where players can send PMs to.
Once the username is secured with a password to prevent anybody to
take over the server, the owner can execute admin tasks over the
console.
This change includes a contribution by @kahrl who has improved ncurses
library detection.
The Atomic implementation was only partially correct, and was very complex.
Use locks for sake of simplicity, following KISS principle.
Only remaining atomic operation use is time of day speed, because that
really is only read + written.
Also fixes a bug with m_time_conversion_skew only being decremented, never
incremented (Regresion from previous commit).
atomic.h changes:
* Add GenericAtomic<T> class for non-integral types like floats.
* Remove some last remainders from atomic.h of the volatile use.
It isn't possible to use atomic operations for floats, so don't use them there.
Having a lock is good out of other reasons too, because this way the float time
and the integer time both match, and can't get different values in a race,
e.g. when two setTimeofDay() get executed simultaneously.
Cleanup:
* Remove volatile keyword, it is of no use at all. [1]
* Remove the enable_if stuff. It had no use either.
The most likely explanation why the enable_if stuff was there is that it
was used as something like a STATIC_ASSERT to verify that sizeof(T) is not larger
than sizeof(void *). This check however is not just misplaced in a place where we
already use a lock, it isn't needed at all, as gcc will just generate a call to
to the runtime if it compiles for platforms that don't support atomic instructions.
The runtime will then most likely use locks.
Code style fixes:
* Prefix name of the mutex
* Line everything up nicely, where it makes things look nice
* Filling \ continuations with spaces is code style rule
Added operations on the atomic var:
* Compare and swap
* Swap
The second point of the cleanup also fixes the Android build of the next commit.
[1]: http://stackoverflow.com/q/2484980
On Windows Release x64 bit build this changes:
ProfilerGraph::put
1.68% -> 0.061%
ProfilerGraph::draw
12% -> 17.%
So yes, there is a tradeoff between saving profiling data
(executed always) and drawing the profiler graph (executed very rarely).
But usually you don't have the profiler graph open.
For several years now, the lua script lock has been completely broken.
This commit fixes the main issue (creation of a temporary rather than
scoped object), and fixes a subsequent deadlock issue caused by
nested script API calls by adding support for recursive mutexes.