Index: trunk/src/lua/lua_function.cc
===================================================================
--- trunk/src/lua/lua_function.cc	(revision 403)
+++ trunk/src/lua/lua_function.cc	(revision 406)
@@ -5,9 +5,14 @@
 // For conditions of distribution and use, see copying.txt file in root folder.
 
-#include <nv/lua/lua_function.hh>
+#include "nv/lua/lua_function.hh"
 
-#include <nv/lua/lua_raw.hh>
+#include "nv/core/logging.hh"
+#include "nv/lua/lua_raw.hh"
 
 using namespace nv;
+
+#define NV_LUA_ABORT( func, ... ) \
+	NV_LOG_CRITICAL( "lua::" func " : ", __VA_ARGS__ ) \
+	NV_ABORT( "lua::" func " : critical error!" )
 
 lua::function_base::function_base( lua_State* a_L, const path& a_path, bool a_global /*= true*/ ) : L(a_L)
@@ -16,5 +21,5 @@
 	{
 		lua_pop( L, 1 );
-		throw std::runtime_error("not a valid path - " + a_path.to_string() );
+		NV_LUA_ABORT( "function_base::function_base", "not a valid path - ", a_path.to_string() );
 	}
 
@@ -22,5 +27,5 @@
 	{
 		lua_pop( L, 1 );
-		throw std::runtime_error("not a valid function - " + a_path.to_string() );
+		NV_LUA_ABORT( "function_base::function_base", "not a valid function - ", a_path.to_string() );
 	}
 	m_ref = luaL_ref( L, LUA_REGISTRYINDEX );
@@ -61,5 +66,5 @@
 		std::string error = lua_tostring( L, -1 );
 		lua_pop( L, 1 );
-		throw std::runtime_error(error.c_str());
+		NV_LUA_ABORT( "function_base::call", "call failed - ", error.c_str() );
 	}
 }
Index: trunk/src/lua/lua_glm.cc
===================================================================
--- trunk/src/lua/lua_glm.cc	(revision 403)
+++ trunk/src/lua/lua_glm.cc	(revision 406)
@@ -11,5 +11,5 @@
 #include "nv/stl/type_traits/common.hh"
 
-static size_t nlua_swizzel_lookup[256];
+static int nlua_swizzel_lookup[256];
 
 using nv::lua::detail::is_vec;
@@ -18,5 +18,5 @@
 using nv::lua::detail::push_vec;
 
-inline bool nlua_is_swizzel( const unsigned char* str, size_t max )
+inline bool nlua_is_swizzel( const unsigned char* str, int max )
 {
 	while (*str)
@@ -155,8 +155,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) + (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) + static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) + to_vec<T>( L, 2 ) );
@@ -168,8 +168,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) - (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) - static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) - to_vec<T>( L, 2 ) );
@@ -181,8 +181,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) * (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) * static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) * to_vec<T>( L, 2 ) );
@@ -194,8 +194,8 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) );
+		push_vec<T>( L, static_cast<typename T::value_type>(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			push_vec<T>( L, to_vec<T>( L, 1 ) / (typename T::value_type)(lua_tonumber( L, 2 )) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) / static_cast<typename T::value_type>(lua_tonumber( L, 2 )) );
 		else
 			push_vec<T>( L, to_vec<T>( L, 1 ) / to_vec<T>( L, 2 ) );
@@ -226,7 +226,7 @@
 	T* v = to_pvec<T>( L, 1 );
 	size_t len  = 0;
-	size_t vlen = v->length();
-	const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) );
-	size_t idx = 255;
+	int vlen = v->length();
+	const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
+	int idx = 255;
 
 	if ( len == 1 )
@@ -264,7 +264,7 @@
 	T* v = to_pvec<T>( L, 1 );
 	size_t len  = 0;
-	size_t vlen = v->length();
-	const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) );
-	size_t idx = 255;
+	int vlen = v->length();
+	const unsigned char * key = reinterpret_cast<const unsigned char *>( lua_tolstring( L, 2, &len ) );
+	int idx = 255;
 	if( len == 1 )
 	{
@@ -272,5 +272,5 @@
 		if ( idx < vlen )
 		{
-			(*v)[idx] = (typename T::value_type)luaL_checknumber( L, 3 );
+			(*v)[idx] = static_cast<typename T::value_type>( luaL_checknumber( L, 3 ) );
 			return 0;
 		}
@@ -279,7 +279,7 @@
 	{
  		switch (len) {
-		case 2 : { vec2 v2 = to_vec<vec2>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;
-		case 3 : { vec3 v3 = to_vec<vec3>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;
-		case 4 : { vec4 v4 = to_vec<vec4>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;
+		case 2 : { vec2 v2 = to_vec<vec2>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;
+		case 3 : { vec3 v3 = to_vec<vec3>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;
+		case 4 : { vec4 v4 = to_vec<vec4>(L,3); for ( int i = 0; i<int( len ); ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;
  		default: break;
 		}
Index: trunk/src/lua/lua_handle.cc
===================================================================
--- trunk/src/lua/lua_handle.cc	(revision 403)
+++ trunk/src/lua/lua_handle.cc	(revision 406)
@@ -16,5 +16,5 @@
 	NV_LUA_STACK_ASSERT( L, +1 );
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
-	lua_rawgeti( L, -1, (int)index );                 // table, entry
+	lua_rawgeti( L, -1, int( index ) );                 // table, entry
 	if ( !lua_istable( L, -1 ) )
 	{
@@ -58,5 +58,5 @@
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex );
 	lua_insert( L, -2 );
-	lua_rawseti( L, -2, (int)index );
+	lua_rawseti( L, -2, int( index ) );
 	lua_pop( L, 1 );
 }
@@ -67,5 +67,5 @@
 	lua_rawgeti( L, LUA_REGISTRYINDEX, pseudoindex ); // table
 	lua_pushinteger( L, 0 );
-	lua_rawseti( L, -2, (int)index );
+	lua_rawseti( L, -2, int( index ) );
 	lua_pop( L, 1 );
 }
Index: trunk/src/lua/lua_map_area.cc
===================================================================
--- trunk/src/lua/lua_map_area.cc	(revision 403)
+++ trunk/src/lua/lua_map_area.cc	(revision 406)
@@ -67,5 +67,5 @@
 	else
 	{
-		return *(nv::map_area**)luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE );
+		return *reinterpret_cast<nv::map_area**>( luaL_checkudata( L, index, NLUA_MAP_AREA_METATABLE ) );
 	}
 	return o;
@@ -88,5 +88,5 @@
 void nv::lua::detail::push_map_area( lua_State* L, nv::map_area* c )
 {
-	nv::map_area** pm = (nv::map_area**) (lua_newuserdata(L, sizeof(nv::map_area*)));
+	nv::map_area** pm = reinterpret_cast<nv::map_area**>( lua_newuserdata(L, sizeof(nv::map_area*) ) );
 	*pm = c;
 	luaL_getmetatable( L, NLUA_MAP_AREA_METATABLE );
@@ -237,5 +237,5 @@
 	lua_rawgeti( L, LUA_REGISTRYINDEX, object_index.get() );
 	lua_pushliteral( L, "__map_area_ptr" );
-	lua_pushlightuserdata( L, (map_area*)area );
+	lua_pushlightuserdata( L, area );
 	lua_rawset( L, -3 );
 	lua_pop( L, 1 );
Index: trunk/src/lua/lua_map_tile.cc
===================================================================
--- trunk/src/lua/lua_map_tile.cc	(revision 403)
+++ trunk/src/lua/lua_map_tile.cc	(revision 406)
@@ -40,10 +40,10 @@
 static map_tile* nlua_to_pmap_tile( lua_State* L, int index )
 {
-	return (map_tile*)luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE );
+	return reinterpret_cast<map_tile*>( luaL_checkudata( L, index, NLUA_MAP_TILE_METATABLE ) );
 }
 
 static void nlua_push_map_tile( lua_State* L, const map_tile& tile )
 {
-	map_tile* result = (map_tile*)lua_newuserdata( L, sizeof(map_tile) );
+	map_tile* result = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof(map_tile) ) );
 	*result = tile;
 	luaL_setmetatable( L, NLUA_MAP_TILE_METATABLE );
@@ -65,9 +65,9 @@
 	map_tile tile;
 
-	tile.size_y = (nv::uint16)( nv::count( code.begin(), code.end(), '\n' ) + 1 );
-	tile.size_x = (nv::uint16)( code.find( '\n' ) );
+	tile.size_y = nv::uint16( nv::count( code.begin(), code.end(), '\n' ) + 1 );
+	tile.size_x = nv::uint16( code.find( '\n' ) );
 	if ( tile.size_x == 0 )
 	{
-		tile.size_x = (nv::uint16)code.length();
+		tile.size_x = nv::uint16( code.length() );
 	}
 	tile.data  = new nv::uint8[ tile.size_x * tile.size_y ];
@@ -85,5 +85,5 @@
 			if ( lua_isstring( L, -2 ) && lua_objlen( L, -2 ) == 1 )
 			{
-				translation[ (nv::uint8)( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) );
+				translation[ nv::uint8( lua_tostring( L, -2 )[0] ) ] = nv::uint8( map_area->string_to_id( lua_tostring( L, -1 ) ) );
 			}
 			// removes 'value'; keeps 'key' for next iteration */
@@ -95,5 +95,5 @@
 		for ( nv::uint16 row = 0; row < tile.size_y; row++ )
 		{
-			nv::uchar8 gylph = (nv::uchar8)code[ row * ( tile.size_x + 1 ) + line ];
+			nv::uchar8 gylph = nv::uchar8( code[ row * ( tile.size_x + 1 ) + line ] );
 			// TODO: check for errors
 			tile.data[ row * tile.size_x + line ] = translation[ gylph ];
@@ -108,5 +108,5 @@
 {
 	map_tile* old_tile = nlua_to_pmap_tile( L, 1 );
-	map_tile* new_tile = (map_tile*) lua_newuserdata( L, sizeof( map_tile ) );
+	map_tile* new_tile = reinterpret_cast<map_tile*>( lua_newuserdata( L, sizeof( map_tile ) ) );
 	new_tile->size_x = old_tile->size_x;
 	new_tile->size_y = old_tile->size_y;
@@ -246,6 +246,6 @@
 	nv::uint16 org_x = tile->size_x;
 	nv::uint16 org_y = tile->size_y;
-	nv::uint16 new_x = ( nv::uint16 )nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 );
-	nv::uint16 new_y = ( nv::uint16 )nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 );
+	nv::uint16 new_x = nv::uint16( nv::accumulate( sizes_x.begin(), sizes_x.end(), 0 ) );
+	nv::uint16 new_y = nv::uint16( nv::accumulate( sizes_y.begin(), sizes_y.end(), 0 ) );
 
 	nv::uint8* data = new nv::uint8[ new_x * new_y ];
@@ -274,5 +274,5 @@
 static int nlua_map_tile_raw_get( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
@@ -289,13 +289,13 @@
 static int nlua_map_tile_raw_set( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
-		tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->data[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	else
 	{
 		nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 );
-		tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->data[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	return 0;
@@ -304,5 +304,5 @@
 static int nlua_map_tile_ascii_get( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
@@ -319,13 +319,13 @@
 static int nlua_map_tile_ascii_set( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( lua_type( L, 2 ) == LUA_TNUMBER )
 	{
-		tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->ascii[ ( lua_tointeger( L, 2 ) - 1 ) + ( lua_tointeger( L, 3 ) - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	else
 	{
 		nv::ivec2 coord = nv::lua::detail::to_coord( L, 2 );
-		tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = (nv::uint8)lua_tointeger( L, 3 );
+		tile->ascii[ ( coord.x - 1 ) + ( coord.y - 1 ) * tile->size_x ] = nv::uint8( lua_tointeger( L, 3 ) );
 	}
 	return 0;
@@ -334,5 +334,5 @@
 static int nlua_map_tile_gc( lua_State* L )
 {
-	map_tile* tile = (map_tile*)lua_touserdata( L, 1 );
+	map_tile* tile = reinterpret_cast<map_tile*>( lua_touserdata( L, 1 ) );
 	if ( tile != nullptr )
 	{
Index: trunk/src/lua/lua_raw.cc
===================================================================
--- trunk/src/lua/lua_raw.cc	(revision 403)
+++ trunk/src/lua/lua_raw.cc	(revision 406)
@@ -271,5 +271,5 @@
 		while ( lua_next( L, index ) != 0 )
 		{
-			result.push_back( (nv::uint8) lua_tointeger( L, -1 ) );
+			result.push_back( static_cast<nv::uint8>( lua_tointeger( L, -1 ) ) );
 			lua_pop( L, 1 );
 		}
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 403)
+++ trunk/src/lua/lua_state.cc	(revision 406)
@@ -258,5 +258,5 @@
 {
 	lua_getfield( m_state, -1, element.data() );
-	float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? (float)lua_tonumber( m_state, -1 ) : defval;
+	float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( m_state, -1 ) ) : defval;
 	lua_pop( m_state, 1 );
 	return result;
