Index: make.py
===================================================================
--- make.py	(révision 10240)
+++ make.py	(copie de travail)
@@ -264,12 +264,12 @@
     # Prefer that because it will call our C++ destructors on unwind.
     # This avoids memory leaks that would be very cumbersome to fix in
     # any other way.
-    libs = 'lua5.1-c++ lua5.1 lua51 lua'.split()
+    libs = 'lua5.2 lua51 lua'.split()
     if b.usepkgconfig:
         for i in libs:
             if pkgconfig(b, i):
                 return
-    if CheckLibAlternatives(b, libs, header='lua.h'):
+    if CheckLibAlternatives(b, libs, header='lua5.2/lua.h'):
         return
     print('Did not find the Lua library, exiting !')
     sys.exit(1)
Index: engine/ui/widgets.cpp
===================================================================
--- engine/ui/widgets.cpp	(révision 10240)
+++ engine/ui/widgets.cpp	(copie de travail)
@@ -1222,7 +1222,7 @@
 {
 	clear();
 
-	int args = lua_objlen(lua, *lo);
+	int args = lua_rawlen(lua, *lo);
 	for (int j = 0; j < args; ++j) {
 		add(std::string(LuaToString(lua, *lo, j + 1)));
 	}
Index: engine/ui/script_ui.cpp
===================================================================
--- engine/ui/script_ui.cpp	(révision 10240)
+++ engine/ui/script_ui.cpp	(copie de travail)
@@ -244,7 +244,7 @@
 				TitleScreens[j]->Timeout = LuaToNumber(l, -1);
 			} else if (!strcmp(value, "Labels")) {
 				LuaCheckTable(l, -1);
-				subargs = lua_objlen(l, -1);
+				subargs = lua_rawlen(l, -1);
 				TitleScreens[j]->Labels = new TitleScreenLabel *[subargs + 1];
 				memset(TitleScreens[j]->Labels, 0, (subargs + 1) * sizeof(TitleScreenLabel *));
 				for (k = 0; k < subargs; ++k) {
@@ -267,7 +267,7 @@
 							int subk;
 
 							LuaCheckTable(l, -1);
-							subsubargs = lua_objlen(l, -1);
+							subsubargs = lua_rawlen(l, -1);
 							for (subk = 0; subk < subsubargs; ++subk) {
 								value = LuaToString(l, -1, subk + 1);
 								if (!strcmp(value, "center")) {
@@ -756,7 +756,7 @@
 			std::string allowstr;
 
 			LuaCheckTable(l, -1);
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			for (k = 0; k < subargs; ++k) {
 				s2 = LuaToString(l, -1, k + 1);
 				allowstr += s2;
@@ -775,7 +775,7 @@
 			LuaCheckTable(l, -1);
 			// FIXME: ba.UnitMask shouldn't be a string
 			umask = ",";
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			for (k = 0; k < subargs; ++k) {
 				s2 = LuaToString(l, -1, k + 1);
 				umask += s2;
Index: engine/map/script_map.cpp
===================================================================
--- engine/map/script_map.cpp	(révision 10240)
+++ engine/map/script_map.cpp	(copie de travail)
@@ -86,7 +86,7 @@
 			Map.Info.Description = LuaToString(l, j + 1);
 		} else if (!strcmp(value, "the-map")) {
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (int k = 0; k < subargs; ++k) {
 				value = LuaToString(l, j + 1, k + 1);
 				++k;
@@ -126,7 +126,7 @@
 					lua_rawgeti(l, j + 1, k + 1);
 					LuaCheckTable(l, -1);
 
-					subsubargs = lua_objlen(l, -1);
+					subsubargs = lua_rawlen(l, -1);
 					if (subsubargs != Map.Info.MapWidth * Map.Info.MapHeight) {
 						fprintf(stderr, "Wrong tile table length: %d\n", subsubargs);
 					}
@@ -137,7 +137,7 @@
 
 						lua_rawgeti(l, -1, subk + 1);
 						LuaCheckTable(l, -1);
-						args2 = lua_objlen(l, -1);
+						args2 = lua_rawlen(l, -1);
 						j2 = 0;
 
 						for (; j2 < args2; ++j2) {
Index: engine/unit/script_unittype.cpp
===================================================================
--- engine/unit/script_unittype.cpp	(révision 10240)
+++ engine/unit/script_unittype.cpp	(copie de travail)
@@ -160,7 +160,7 @@
 	int args;
 	CBuildRestrictionAnd *andlist = new CBuildRestrictionAnd();
 
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	Assert(!(args & 1)); // must be even
 
 	for (int i = 0; i < args; ++i) {
@@ -298,7 +298,7 @@
 			type->Name = LuaToString(l, -1);
 		} else if (!strcmp(value, "Image")) {
 			LuaCheckTable(l, -1);
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			for (k = 0; k < subargs; ++k) {
 				value = LuaToString(l, -1, k + 1);
 				++k;
@@ -317,7 +317,7 @@
 			}
 		} else if (!strcmp(value, "Shadow")) {
 			LuaCheckTable(l, -1);
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			for (k = 0; k < subargs; ++k) {
 				value = LuaToString(l, -1, k + 1);
 				++k;
@@ -534,7 +534,7 @@
 			type->VisibleUnderFog = LuaToBoolean(l, -1);
 		} else if (!strcmp(value, "BuildingRules")) {
 			LuaCheckTable(l, -1);
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			// Free any old restrictions if they are redefined
 			for (std::vector<CBuildRestriction *>::iterator b = type->BuildingRules.begin();
 					b != type->BuildingRules.end(); ++b) {
@@ -575,7 +575,7 @@
 				type->CanCastSpell = new char[SpellTypeTable.size()];
 				memset(type->CanCastSpell, 0, SpellTypeTable.size() * sizeof(char));
 			}
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			if (subargs == 0) {
 				delete[] type->CanCastSpell;
 				type->CanCastSpell = NULL;
@@ -601,7 +601,7 @@
 				type->AutoCastActive = new char[SpellTypeTable.size()];
 				memset(type->AutoCastActive, 0, SpellTypeTable.size() * sizeof(char));
 			}
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			if (subargs == 0) {
 				delete[] type->AutoCastActive;
 				type->AutoCastActive = NULL;
@@ -630,7 +630,7 @@
 			type->Organic = LuaToBoolean(l, -1);
 		} else if (!strcmp(value, "Sounds")) {
 			LuaCheckTable(l, -1);
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			for (k = 0; k < subargs; ++k) {
 				value = LuaToString(l, -1, k + 1);
 				++k;
@@ -890,7 +890,7 @@
 	const char *str;
 
 	LuaCheckTable(l, idx);
-	args = lua_objlen(l, idx);
+	args = lua_rawlen(l, idx);
 	anim = new CAnimation[args + 1];
 	tail = NULL;
 	Labels.clear();
Index: engine/unit/unit_save.cpp
===================================================================
--- engine/unit/unit_save.cpp	(révision 10240)
+++ engine/unit/unit_save.cpp	(copie de travail)
@@ -409,7 +409,7 @@
 			// The cast from ptrdiff_t to int will not
 			// overflow because the array of animation
 			// frames was converted from a Lua list
-			// and lua_objlen returns int.
+			// and lua_rawlen returns int.
 			file->printf("\"anim\", %d,",
 				     static_cast<int>(unit->Anim.Anim - unit->Anim.CurrAnim));
 			break;
Index: engine/unit/script_unit.cpp
===================================================================
--- engine/unit/script_unit.cpp	(révision 10240)
+++ engine/unit/script_unit.cpp	(copie de travail)
@@ -101,7 +101,7 @@
 	//
 	// Parse the list: (still everything could be changed!)
 	//
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	for (j = 0; j < args; ++j) {
 		value = LuaToString(l, -1, j + 1);
 		if (!strcmp(value, "action-none")) {
@@ -229,7 +229,7 @@
 	int j;
 
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	for (j = 0; j < args; ++j) {
 		value = LuaToString(l, -1, j + 1);
 		++j;
@@ -267,7 +267,7 @@
 	int j;
 
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	for (j = 0; j < args; ++j) {
 		value = LuaToString(l, -1, j + 1);
 		++j;
@@ -292,7 +292,7 @@
 	int j;
 
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	for (j = 0; j < args; ++j) {
 		value = LuaToString(l, -1, j + 1);
 		++j;
@@ -333,7 +333,7 @@
 	}
 
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	for (j = 0; j < args; ++j) {
 		value = LuaToString(l, -1, j + 1);
 		++j;
@@ -346,7 +346,7 @@
 
 			lua_rawgeti(l, -1, j + 1);
 			LuaCheckTable(l, -1);
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			if (subargs > MAX_PATH_LENGTH) {
 				// unit->Data.Move.Path[] would overflow.
 				LuaError(l, "path data is too long");
@@ -576,7 +576,7 @@
 			int k;
 
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k) {
 				value = LuaToString(l, j + 1, k + 1);
 				slot = strtol(value + 1, NULL, 16);
@@ -833,7 +833,7 @@
 	LuaCheckTable(l, 3);
 	x1 = LuaToNumber(l, 3, 1);
 	y1 = LuaToNumber(l, 3, 2);
-	if (lua_objlen(l, 3) == 4) {
+	if (lua_rawlen(l, 3) == 4) {
 		x2 = LuaToNumber(l, 3, 3);
 		y2 = LuaToNumber(l, 3, 4);
 	} else {
@@ -844,7 +844,7 @@
 	LuaCheckTable(l, 4);
 	dx1 = LuaToNumber(l, 4, 1);
 	dy1 = LuaToNumber(l, 4, 2);
-	if (lua_objlen(l, 4) == 4) {
+	if (lua_rawlen(l, 4) == 4) {
 		dx2 = LuaToNumber(l, 4, 3);
 		dy2 = LuaToNumber(l, 4, 4);
 	} else {
@@ -1106,7 +1106,7 @@
 	if (!lua_istable(l, 2)) {
 		LuaError(l, "SlotUsage called with invalid second arg, expected table.");
 	}
-	size_t n = lua_objlen(l, 2);
+	size_t n = lua_rawlen(l, 2);
 
 	if (n == 0) {
 		return 0;
Index: engine/include/script.h
===================================================================
--- engine/include/script.h	(révision 10240)
+++ engine/include/script.h	(copie de travail)
@@ -39,9 +39,9 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-#include "lua.h"
-#include "lauxlib.h"
-#include "lualib.h"
+#include <lua5.2/lua.h>
+#include <lua5.2/lauxlib.h>
+#include <lua5.2/lualib.h>
 #ifdef __cplusplus
 }
 #endif
@@ -91,7 +91,7 @@
 
 #define LuaCheckTableSize(l, index, size) \
 	do { \
-		if (!lua_istable((l), (index)) || lua_objlen((l), (index)) != (size)) { \
+		if (!lua_istable((l), (index)) || lua_rawlen((l), (index)) != (size)) { \
 			LuaError(l, "incorrect argument"); \
 		} \
 	} while (0)
Index: engine/sound/script_sound.cpp
===================================================================
--- engine/sound/script_sound.cpp	(révision 10240)
+++ engine/sound/script_sound.cpp	(copie de travail)
@@ -133,7 +133,7 @@
 		id = MakeSound(c_name, &c_file, 1);
 	} else if (lua_istable(l, 2)) {
 		// several files
-		args = lua_objlen(l, 2);
+		args = lua_rawlen(l, 2);
 		c_files = new char *[args];
 		for (j = 0; j < args; ++j) {
 			c_files[j] = new_strdup(LuaToString(l, 2, j + 1));
Index: engine/ai/script_ai.cpp
===================================================================
--- engine/ai/script_ai.cpp	(révision 10240)
+++ engine/ai/script_ai.cpp	(copie de travail)
@@ -202,7 +202,7 @@
 	for (j = 0; j < args; ++j)
 	{
 		LuaCheckTable(l, j + 1);
-		subargs = lua_objlen(l, j + 1);
+		subargs = lua_rawlen(l, j + 1);
 		k = 0;
 		value = LuaToString(l, j + 1, k + 1);
 		++k;
@@ -606,7 +606,7 @@
 		LuaError(l, "Force out of range: %d" _C_ force);
 	}
 
-	args = lua_objlen(l, 2);
+	args = lua_rawlen(l, 2);
 	for (j = 0; j < args; ++j)
 	{
 		lua_rawgeti(l, 2, j + 1);
@@ -910,7 +910,7 @@
 		else if (!strcmp(value, "force"))
 		{
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			k = 0;
 			i = LuaToNumber(l, j + 1, k + 1);
 			++k;
@@ -961,7 +961,7 @@
 
 					lua_rawgeti(l, j + 1, k + 1);
 					LuaCheckTable(l, -1);
-					subsubargs = lua_objlen(l, -1);
+					subsubargs = lua_rawlen(l, -1);
 					for (subk = 0; subk < subsubargs; ++subk)
 					{
 						int num;
@@ -984,7 +984,7 @@
 
 					lua_rawgeti(l, j + 1, k + 1);
 					LuaCheckTable(l, -1);
-					subsubargs = lua_objlen(l, -1);
+					subsubargs = lua_rawlen(l, -1);
 					for (subk = 0; subk < subsubargs; ++subk)
 					{
 						int num;
@@ -1017,7 +1017,7 @@
 		else if (!strcmp(value, "needed"))
 		{
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k)
 			{
 				const char *type;
@@ -1032,7 +1032,7 @@
 		else if (!strcmp(value, "need-mask"))
 		{
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k)
 			{
 				const char *type;
@@ -1048,7 +1048,7 @@
 		else if (!strcmp(value, "unit-type"))
 		{
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			i = 0;
 			if (subargs)
 			{
@@ -1070,7 +1070,7 @@
 		else if (!strcmp(value, "building"))
 		{
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k)
 			{
 				const char *ident;
@@ -1096,7 +1096,7 @@
 		else if (!strcmp(value, "repair-workers"))
 		{
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k)
 			{
 				int num;
Index: engine/game/construct.cpp
===================================================================
--- engine/game/construct.cpp	(révision 10240)
+++ engine/game/construct.cpp	(copie de travail)
@@ -220,7 +220,7 @@
 				construction->ShadowFile.Height = h;
 			}
 		} else if (!strcmp(value, "Constructions")) {
-			subargs = lua_objlen(l, -1);
+			subargs = lua_rawlen(l, -1);
 			for (k = 0; k < subargs; ++k) {
 				int percent;
 				ConstructionFileType file;
Index: engine/game/selection.cpp
===================================================================
--- engine/game/selection.cpp	(révision 10240)
+++ engine/game/selection.cpp	(copie de travail)
@@ -1161,7 +1161,7 @@
 	InitSelections();
 	NumSelected = LuaToNumber(l, 1);
 	i = 0;
-	args = lua_objlen(l, 2);
+	args = lua_rawlen(l, 2);
 	for (j = 0; j < args; ++j) {
 		const char *str;
 
Index: engine/game/script_missile.cpp
===================================================================
--- engine/game/script_missile.cpp	(révision 10240)
+++ engine/game/script_missile.cpp	(copie de travail)
@@ -307,7 +307,7 @@
 
 		const char *value;
 		BurningBuildingFrame *ptr = new BurningBuildingFrame;
-		int subargs = lua_objlen(l, j + 1);
+		int subargs = lua_rawlen(l, j + 1);
 
 		for (int k = 0; k < subargs; ++k) {
 			value = LuaToString(l, j + 1, k + 1);
Index: engine/game/script_spell.cpp
===================================================================
--- engine/game/script_spell.cpp	(révision 10240)
+++ engine/game/script_spell.cpp	(copie de travail)
@@ -66,7 +66,7 @@
 	Assert(location != NULL);
 
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	j = 0;
 
 	for (j = 0; j < args; ++j) {
@@ -107,7 +107,7 @@
 	int j;
 
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	j = 0;
 
 	value = LuaToString(l, -1, j + 1);
@@ -435,7 +435,7 @@
 	}
 	//  Now parse the list and set values.
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	for (j = 0; j < args; ++j) {
 		value = LuaToString(l, -1, j + 1);
 		++j;
@@ -499,7 +499,7 @@
 	int j;
 
 	LuaCheckTable(l, -1);
-	args = lua_objlen(l, -1);
+	args = lua_rawlen(l, -1);
 	for (j = 0; j < args; ++j) {
 		value = LuaToString(l, -1, j + 1);
 		++j;
@@ -594,7 +594,7 @@
 			int k;
 
 			LuaCheckTable(l, i + 1);
-			subargs = lua_objlen(l, i + 1);
+			subargs = lua_rawlen(l, i + 1);
 			for (k = 0; k < subargs; ++k) {
 				lua_rawgeti(l, i + 1, k + 1);
 				spell->Action.push_back(CclSpellAction(l));
Index: engine/game/trigger.cpp
===================================================================
--- engine/game/trigger.cpp	(révision 10240)
+++ engine/game/trigger.cpp	(copie de travail)
@@ -572,7 +572,7 @@
 		lua_gettable(l, LUA_GLOBALSINDEX);
 	}
 
-	i = lua_objlen(l, -1);
+	i = lua_rawlen(l, -1);
 	if (ActiveTriggers && !ActiveTriggers[i / 2]) {
 		lua_pushnil(l);
 		lua_rawseti(l, -2, i + 1);
@@ -632,7 +632,7 @@
 	ret = 0;
 
 	lua_rawgeti(Lua, -1, script + 1);
-	args = lua_objlen(Lua, -1);
+	args = lua_rawlen(Lua, -1);
 	for (j = 0; j < args; ++j) {
 		lua_rawgeti(Lua, -1, j + 1);
 		LuaCall(0, 0);
@@ -672,7 +672,7 @@
 
 	lua_pushstring(Lua, "_triggers_");
 	lua_gettable(Lua, LUA_GLOBALSINDEX);
-	triggers = lua_objlen(Lua, -1);
+	triggers = lua_rawlen(Lua, -1);
 
 	if (nextTrigger >= triggers) {
 		nextTrigger = 0;
@@ -733,7 +733,7 @@
 
 	lua_pushstring(Lua, "_triggers_");
 	lua_gettable(Lua, LUA_GLOBALSINDEX);
-	triggers = lua_objlen(Lua, -1);
+	triggers = lua_rawlen(Lua, -1);
 
 	file->printf("SetActiveTriggers(");
 	for (i = 0; i < triggers; i += 2) {
Index: engine/game/groups.cpp
===================================================================
--- engine/game/groups.cpp	(révision 10240)
+++ engine/game/groups.cpp	(copie de travail)
@@ -252,7 +252,7 @@
 	grp = &Groups[(int)LuaToNumber(l, 1)];
 	grp->NumUnits = LuaToNumber(l, 2);
 	i = 0;
-	args = lua_objlen(l, 3);
+	args = lua_rawlen(l, 3);
 	for (j = 0; j < args; ++j) {
 		const char *str;
 
Index: engine/game/script_player.cpp
===================================================================
--- engine/game/script_player.cpp	(révision 10240)
+++ engine/game/script_player.cpp	(copie de travail)
@@ -144,7 +144,7 @@
 			player->StartY = LuaToNumber(l, j + 1, 2);
 		} else if (!strcmp(value, "production-rate")) {
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k) {
 				value = LuaToString(l, j + 1, k + 1);
 				++k;
@@ -161,7 +161,7 @@
 			}
 		} else if (!strcmp(value, "stored-resources")) {
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k) {
 				value = LuaToString(l, j + 1, k + 1);
 				++k;
@@ -178,7 +178,7 @@
 			}
 		} else if (!strcmp(value, "storage-capacity")) {
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			for (k = 0; k < subargs; ++k) {
 				value = LuaToString(l, j + 1, k + 1);
 				++k;
@@ -217,7 +217,7 @@
 			player->TotalKills = LuaToNumber(l, j + 1);
 		} else if (!strcmp(value, "total-resources")) {
 			LuaCheckTable(l, j + 1);
-			subargs = lua_objlen(l, j + 1);
+			subargs = lua_rawlen(l, j + 1);
 			if (subargs != MaxCosts) {
 				LuaError(l, "Wrong number of total-resources: %d" _C_ i);
 			}
@@ -457,13 +457,13 @@
 	LuaCheckArgs(l, 1);
 	LuaCheckTable(l, 1);
 
-	args = lua_objlen(l, 1);
+	args = lua_rawlen(l, 1);
 	for (i = 0; i < args; ++i) {
 		PlayerColorNames[i / 2] = LuaToString(l, 1, i + 1);
 		++i;
 		lua_rawgeti(l, 1, i + 1);
 		LuaCheckTable(l, -1);
-		numcolors = lua_objlen(l, -1);
+		numcolors = lua_rawlen(l, -1);
 		if (numcolors != PlayerColorIndexCount) {
 			LuaError(l, "You should use %d colors (See DefinePlayerColorIndex())" _C_ PlayerColorIndexCount);
 		}
