Added a way to specify the min and max attributes values.

This can now be done in attributes.xml through the
minimum and maximum attribute parameters.

I also changed the AttributeInfo struct as requested by bjorn.

Reviewed-by: Erik Schilling, Thorbjørn Lindeijer
Clear the gid flags before processing them

Also read the gids as unsigned integers since that's how Tiled writes them
to prevent the number going negative when the highest flag is used.

Reviewed-by: Yohann Ferreira
Added a generic Lua user data cache

Based on a native Lua table with weak values, so that the user data objects
that are created can be garbage collected when no longer referenced.

Reviewed-by: Yohann Ferreira
Simplified merchant.lua

Just defined an inline function to make talking to the player easier.
Would be nice when NPC scripts could look more like this by default.

Also indented with 4 spaces, which we do in C++ so why not Lua files
(the file had mixed 2 and 4 space indentation before).
Moved @announce permission to GM group

Reviewed-by: Erik Schilling
Merged the example client and server data

It's easier to just talk about world data and to modify it as a whole.
If there is really a need to separate it, a project can still choose to do
that (and in whatever suitable way). There is no need to enforce this
separation or to do it in our example.

Reviewed-by: Erik Schilling
Renamed some iterators + fixed one TODO (stored guilds in a map)

Reviewed-by: bjorn.
Some random code cleanup

Moved a code comment about syncmessages to the bugtracker: #473.

Reviewed-by: bjorn.
Fixed compilation again + some more code cleanup

I did some cleanup but i had a wrong path set inside qtcreator.
So i recompiled old versions and it all worked fine.
But when i recompiled from console i got a whole bunch of errors.

Sorry for pushing broken commits.

Reviewed-by: bjorn.
Prevent calculating movement of being further if it does not move

Reviewed-by: bjorn.
Removed unnessecary second check for same condition

Reviewed-by: Bertram.
Fixed bug with erasing the last status effect

It's not nice to use ++ on an iterator that may be std::map::end(),
in my case this caused it to hang indefinitely.

Reviewed-by: Yohann Ferreira
Merged all the different Lua states into one

No more Lua state for each status effect, monster, item effect or map. All
scripts are loaded into the same state. This should be more efficient overall
and make it easier to implement dynamic reloading of the scripts in the
future.

Now, this introduces the problem of name collisions between different Lua
scripts. For now this is solved by using more specific function names, like
'tick_plague' and 'tick_jump' rather than just 'tick'. The plan is however
to get rid of these globals, and register these callbacks from the script,
so that they can be local functions without the danger of colliding with
other scripts.

Reviewed-by: Erik Schilling
Reviewed-by: Yohann Ferreira
A bunch of cleanups to example Lua scripts

Mostly removed bulky copyright headers and fixed indentation and line length.

Reviewed-by: Yohann Ferreira
Reviewed-by: Erik Schilling
Simplified some of the Lua backend

Mainly introduced a helper function for getting to the Script instance for
the current Lua state.

Reviewed-by: Erik Schilling
Reviewed-by: Yohann Ferreira
Use callbacks for handling character death and respawn

Rather than relying on the availability of global functions with certain
predefined names, the Lua script now calls API functions to set which
function should be called on these global events.

This mechanism should make it easier to avoid name collisions in the global
namespace, which is important now that there is only a single script state.
For these global events this was not likely to become a problem, but this
solution can also be used for callbacks on specific item or monster types,
or even allow setting callbacks on certain instances.

Reviewed-by: Erik Schilling
Reviewed-by: Yohann Ferreira
Converted functions called by LuaScript to callbacks

This includes the quest reply, post reply, death notification and
remove notification.

Also, Script::Ref was changed from a typedef to a small class,
automating initialization and making the check for validness clearer.

Reviewed-by: Erik Schilling
Added further missing callbacks

Reviewed-by: bjorn.
Use callbacks for items, monsters and status effects

Previously, global function names were defined in the respective XML
definitions of items, monsters and status effects. This was reasonable when
they all had the same state, but now they're sharing the single global
Lua state.

Now the Lua API provides access to the ItemClass, MonsterClass and
StatusEffect instances, on which callbacks for both standard and custom
events can be explicitly set.

Reviewed-by: Erik Schilling
Made some global Lua variables local

We have to be careful with introducing globals now that there is only a
single Lua state, so we shouldn't use globals unnecessarily. Any variable
should be declared 'local' unless there is a reason to make it global.

For additional safety we can also think about disallowing the use of globals
entirely. This also helps to catch typos in scripts.

Reviewed-by: Erik Schilling