Refactored the move map structuring when exposed to LuaAI

This commit is contained in:
Dmitry Kovalenko 2012-04-08 23:54:34 +00:00
parent fe631c40a3
commit 2adbf5ae5f
2 changed files with 11 additions and 3 deletions

View file

@ -263,10 +263,10 @@ ai_stdlib.init(ai)
function my_ai:stage_hello()
local debug_utils = wesnoth.require "~add-ons/Wesnoth_Lua_Pack/debug_utils.lua"
--local mm = ai.get_dstsrc()
local mm = ai.get_dstsrc()
--wesnoth.message("type " .. type(mo))
--debug_utils.dbms(dstsrc,false,"variable",false)
--debug_utils.dbms(mo,false,"variable",false)
debug_utils.dbms(mm,false,"variable",false)
end

View file

@ -523,7 +523,15 @@ static void push_move_map(lua_State *L, const move_map& m)
{
map_location key = it->first;
push_map_location(L, key);
//push_map_location(L, key); // deprecated
// This should be factored out. The same function is defined in data/lua/location_set.lua
// At this point, it is not clear, where this(hashing) function can be placed
// Implemented it this way, to test the new version of the data structure
// as requested from the users of LuaAI <Nephro>
int hashed_index = (key.x + 1) * 16384 + (key.y + 1) + 2000;
lua_pushinteger(L, hashed_index);
lua_createtable(L, 0, 0);
while (key == it->first) {