local TraceFrame = DEFAULT_CHAT_FRAME;

--DBCS_mobs_locs
--	[inummob]	=	numéro du mob/pnj
--		[sregion]
--			[nivcarte]
--				[0]	=	loc prise en parlant
--				[1]	=	loc prise ds journal de combat ou target
--supprimé--		[2]	=	loc prise en ouvrant le corp

local DBCS_mobs_locs_tableau_event_cast_a_ignorer = {};
DBCS_mobs_locs_tableau_event_cast_a_ignorer["SPELL_AURA_REMOVED"] = 0;
DBCS_mobs_locs_tableau_event_cast_a_ignorer["SPELL_PERIODIC_DAMAGE"] = 0;
DBCS_mobs_locs_tableau_event_cast_a_ignorer["SPELL_PERIODIC_MISSED"] = 0;

local DBCS_mobs_locs_wow_build;
local DBCS_mobs_locs_wow_build_live = 13623;

_, DBCS_mobs_locs_wow_build, _, _ = GetBuildInfo();
DBCS_mobs_locs_wow_build = tonumber(DBCS_mobs_locs_wow_build);

local DBCS_mobs_locs_time = 0;

function DBCS_mobs_locs_OnLoad(self)

	self:RegisterEvent("BANKFRAME_OPENED");
	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
	self:RegisterEvent("GOSSIP_SHOW");
	self:RegisterEvent("MERCHANT_SHOW");
	self:RegisterEvent("PLAYER_TARGET_CHANGED");
--	self:RegisterEvent("QUEST_GREETING");
	self:RegisterEvent("UPDATE_MOUSEOVER_UNIT");
	--self:RegisterEvent("TAXIMAP_OPENED");	--	à réparer, fonction disparue
--	self:RegisterEvent("TRAINER_UPDATE");
--	self:RegisterEvent("TRAINER_DESCRIPTION_UPDATE");
	self:RegisterEvent("VARIABLES_LOADED");

	--DBCS_mobs_locs = {};

end

local DBCS_mobs_locs_OnUpdate_inbchildren = -1;
local DBCS_mobs_locs_OnUpdate_kids = nil;

local DBCS_mobs_locs_OnUpdate_t_indecis = {};

function DBCS_mobs_locs_OnUpdate()

--local inbchildren;
local oframe;
--local kids;
local name, level, bar, icon, border, glow;
local inbregions;
local regions;
local otype;
local stexte;
local stextenommob;
local stextenivmob;
local inbpdvmax;
local bskull;
local inum;
local i;
local iGUID_7_10;
local sregion;
local x;
local y;
local idate;
local b1;
local kids2;
local oframe2;
local j;
local oframe_name;
local sname;
local snominverse;
local k;
local ilen;
local stexte2;
local ipos;

	if ( ( GetTime() - DBCS_mobs_locs_time ) < 1 ) then
		return nil;
	end


--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : ----------------------------------------------------");
--end
	if ( DBCS_mobs_locs_OnUpdate_inbchildren < WorldFrame:GetNumChildren() ) then
		DBCS_mobs_locs_OnUpdate_inbchildren = WorldFrame:GetNumChildren();
		if ( DBCS_mobs_locs_OnUpdate_inbchildren > 0 ) then
			DBCS_mobs_locs_OnUpdate_kids = { WorldFrame:GetChildren() };
		else
			DBCS_mobs_locs_OnUpdate_kids = {};
		end
	end
	if ( DBmobs_Local_exist ) then
		DBmobs_Local_Init_Inverse();
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : DBmobs_Local_Init_Inverse");
--end
	end
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : fin DBmobs_Local_exist");
	for _, oframe in ipairs(DBCS_mobs_locs_OnUpdate_kids) do
		if ( oframe:GetObjectType() == "Frame" and oframe:GetName() == nil ) then
--interface\\targetingframe\\ui-targetingframe-flash
--interface\\tooltips\\nameplate-border
--interface\\tooltips\\nameplate-border
--interface\\tooltips\\nameplate-castbar-shield
--
--interface\\tooltips\\nameplate-glow
--worg de braise géant
--50
--interface\\targetingframe\\ui-targetingframe-skull
--interface\\targetingframe\\ui-raidtargetingicons
--interface\\tooltips\\elitenameplateicon
--children1 = StatusBar
--	region1 = interface\\targetingframe\\ui-targetingframe-barfill
--children2 = StatusBar
--	region1 = interface\\targetingframe\\ui-targetingframe-barfill
			if oframe:IsVisible() then
				name = nil;
				level = nil;
				bar = nil;
				icon = nil;
				border = nil;
				glow = nil;
				inbregions = oframe:GetNumRegions();
				if ( inbregions > 0 ) then
					regions = { oframe:GetRegions() };
				else
					regions = {};
				end
				inum = 0;
				b1 = false;
				stextenommob = nil;
				stextenivmob = nil;
				inbpdvmax = nil;
				bskull = false;
				for _, oregion in ipairs(regions) do
					otype = oregion:GetObjectType();
					if ( ( otype == "FontString" ) and ( oregion:IsVisible() ) ) then	--
						inum = inum + 1;
						stexte = oregion:GetText();
						if ( strsub(stexte,1,2) == "|c" ) then
							stexte = strsub(stexte,11);
						end
						ilen = strlen(stexte);
						if ( strsub(stexte,ilen-1) == "|r" ) then
							stexte = strsub(stexte,1,ilen-2);
						end
						ilen = strlen(stexte);
						if ( strsub(stexte,ilen-9,ilen-8) == "|c" ) then
							stexte = strsub(stexte,1,ilen-10);
						end
						--if ( inum == 1 and stexte and strfind(stexte," ") ) then
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : snom = -"..(stexte or "").."-");
--end
						--end
						if ( inum == 1 ) then
							if ( stexte ) then
								stextenommob = stexte;
								if ( ( strfind(stextenommob," ") or strfind(stextenommob,"-") or strfind(stextenommob,"'") ) and DBmobs_Local_exist ) then
								--if ( DBmobs_Local_exist ) then
							--DBmobs_Local_inverse
									if ( DBmobs_Local_inverse[stextenommob] == nil ) then
										if ( DBCS_mobs_locs_OnUpdate_t_indecis[stextenommob] == nil ) then
--											k = 0;
--											for snominverse, _ in pairs(DBmobs_Local_inverse) do
--												if ( snominverse == stextenommob ) then
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : "..snominverse.." en "..k);
--end
--												end
--												if ( k < 100 ) then
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : "..snominverse);
--end
--												end
--												k = k + 1;
--											end
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : DBmobs_Local_inverse a "..k.." noms.");
--end
											DBCS_mobs_locs_OnUpdate_t_indecis[stextenommob] = 0;
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : "..stextenommob.." est inconnu en inverse. longueur = "..strlen(stextenommob));
--DBCS_ecrirecodedutexte(stextenommob);
end
										end
									else
										--for _, i in pairs(DBmobs_Local_inverse[stextenommob]) do
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : num = "..i);
--end
										--end
										if ( table.getn(DBmobs_Local_inverse[stextenommob]) == 1 ) then
											b1 = true;
											iGUID_7_10 = DBmobs_Local_inverse[stextenommob][1];
											sregion = DBCS_Region_liste_code_region_courante_new();
											if ( sregion == "000" ) then
											else
												x,y = DBCS_Region_liste_position100(1);
												idate = tonumber(date("%Y%m%d"));
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : "..iGUID_7_10..", "..x..", "..y..", "..idate);
--end
												DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),1,x,y,idate,nil);
--if ( DBCS_debug and DBCS_debug > 1 ) then
--DBCS_liste_children(oframe);
--end
											end
											oframe_name = oregion;
											sname = stextenommob;
										else
											if ( DBCS_mobs_locs_OnUpdate_t_indecis[stextenommob] == nil ) then
												DBCS_mobs_locs_OnUpdate_t_indecis[stextenommob] = 0;
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : "..stextenommob.." est inconnu car doublons");
end
											end
										end
									end
								else
									if ( DBCS_mobs_locs_OnUpdate_t_indecis[stextenommob] == nil ) then
										DBCS_mobs_locs_OnUpdate_t_indecis[stextenommob] = 0;
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : "..stextenommob.." est inconnu car en un seul mot");
end
									end
								end
							end
						end
						if ( inum == 2 and stexte and b1 == true and DBCS_mobs_detail_tableau_type ) then
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : inumPNJ = "..iGUID_7_10..", iniveau = "..stexte);
--end
							stextenivmob = stexte;
							kids2 = { oframe:GetChildren() };
							j = 0;
							--imax = nil;
							for _, oframe2 in ipairs(kids2) do
								j = j + 1;
								if ( ( j == 1 ) and ( oframe2:IsVisible() ) ) then
									_, inbpdvmax = oframe2:GetMinMaxValues();
								end
							end
							stexte2 = oframe_name:GetText();
							if ( strsub(stexte2,1,2) == "|c" ) then
								stexte2 = strsub(stexte2,11);
							end
							ilen = strlen(stexte2);
							if ( strsub(stexte2,ilen-1) == "|r" ) then
								stexte2 = strsub(stexte2,1,ilen-2);
							end
							if ( sname == stexte2 ) then
								if ( inbpdvmax ) then
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : inumPNJ = "..iGUID_7_10..", iniveau = "..stextenivmob..", pdvmax = "..inbpdvmax);
--DBCS_ecrirecodedutexte(stextenivmob);
--end
									--if ( oregion:IsVisible() ) then
									--else
									--	stextenivmob = -1;
									--end
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : stextenivmob = /"..stextenivmob.."/");
--end
									--if ( stextenivmob == "-----" ) then
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : stextenivmob = "..stextenivmob);
--end
									--	stextenivmob = -1;
									--else
									--end
									--if ( strlen(stextenivmob) > 0 ) then
									--else
									--	stextenivmob = "-1";
									--end
									DBCS_mobs_detail_init_niveau_et_pdvmax(iGUID_7_10,tonumber(stextenivmob),inbpdvmax);
								else
									DBCS_mobs_detail_init_niveau(iGUID_7_10,tonumber(stextenivmob));
								end
							else
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("DBCS_mobs_locs_OnUpdate : "..sname.." change de nom en "..oframe_name:GetText());
end
							end
						end
					else
					end
				end
			end
		end
	end
	
	DBCS_mobs_locs_time = GetTime();

end

--function DBCS_mobs_locs_process_possible_nameplate(frame)
--	-- This was mostly copied from "Nameplates - Nameplate Modifications" by Biozera.
--	-- Nameplates are unnamed children of WorldFrame.
--	-- So: drop it if it's not the right type, has a name, or we already know about it.
--	if frame:GetObjectType() ~= "Frame" or frame:GetName() or nameplates[frame] then
--		return
--	end
--	local name, level, bar, icon, border, glow
--	for i=1,frame:GetNumRegions(),1 do
--		local region = select(i, frame:GetRegions())
--		if region then
--			local oType = region:GetObjectType()
--			if oType == "FontString" then
--				local point, _, relativePoint = region:GetPoint()
--				if point == "BOTTOM" and relativePoint == "CENTER" then
--					name = region
--				elseif point == "CENTER" and relativePoint == "BOTTOMRIGHT" then
--					level = region
--				end
--			elseif oType == "Texture" then
--				local path = region:GetTexture()
--				if path == "Interface\\TargetingFrame\\UI-RaidTargetingIcons" then
--					icon = region
--				elseif path == "Interface\\Tooltips\\Nameplate-Border" then
--					border = region
--				elseif path == "Interface\\Tooltips\\Nameplate-Glow" then
--					glow = region
--				end
--			end
--		end
--	end
--	for i=1,frame:GetNumChildren(),1 do
--		local childFrame = select(i, frame:GetChildren())
--		if childFrame:GetObjectType() == "StatusBar" then
--			bar = childFrame
--		end
--	end
--	if name and level and bar and border and glow then -- We have a nameplate!
--		nameplates[frame] = {name = name, level = level, bar = bar, border = border, glow = glow}
--		return true
--	end
--end

--function DBCS_mobs_locs_ScanNameplates()
--	if GetCVarBool("nameplateShowEnemies") ~= 1 then
--		return
--	end
--	--local typ = L["Plakette"]
--	--local dead = nil
--	if num_worldchildren ~= WorldFrame:GetNumChildren() then
--		num_worldchildren = WorldFrame:GetNumChildren()
--		for i=1, num_worldchildren, 1 do
--			ESN_Rare:process_possible_nameplate(select(i, WorldFrame:GetChildren()))
--		end
--	end	
--	for nameplate, regions in pairs(nameplates) do
--		if nameplate:IsVisible() then
--			local platename = regions.name:GetText()
--			for id, rname in pairs(L["Rares"]) do
--				if rname == platename then
--					ESN_Rare:Output(regions.name:GetText(),regions.level:GetText(),typ,dead)
--					break -- it's pretty unlikely there'll be two rares on screen at once
--				end
--			end	
--		end
--	end
--end

function DBCS_mobs_locs_OnEvent(self,event,...)

local snom;
local sGUID;
local sGUID_7_10;
local iGUID_7_10;
local sregion;
local x,y;

local arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20 = ...;

local val3,val4,val6,val7;

	if ( event == "" ) then
	elseif ( event == "BANKFRAME_OPENED" ) then
		sGUID = UnitGUID("target");
		snom = BankFrameTitleText:GetText();
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("BANKFRAME_OPENED : snom = "..(snom or ""));
end
		if ( snom == UnitName("target") ) then
			if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
				--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
					sGUID_7_10 = strsub(sGUID,7,10);
				--else
				--	sGUID_7_10 = strsub(sGUID,9,12);
				--end
				iGUID_7_10 = tonumber(sGUID_7_10,16);
				sregion = DBCS_Region_liste_code_region_courante_new();
				if ( sregion == "000" ) then
				else
					x,y = DBCS_Region_liste_position100(1);
					idate = tonumber(date("%Y%m%d"));
					DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),0,x,y,idate);
				end
			end
		end
if ( DBCS_debug and DBCS_debug > 1 ) then
DBCS_afficherevent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20);
end
	elseif ( event == "COMBAT_LOG_EVENT_UNFILTERED" ) then
-- if ( DBCS_debug and DBCS_debug > 1 ) then
-- DBCS_afficherevent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20);
-- end
		if ( arg2 and DBCS_mobs_locs_tableau_event_cast_a_ignorer[arg2] ) then
		else
			sGUID = nil;
			snom = nil;
			if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
				val3 = arg4;
				val4 = arg5;
				val6 = arg7;
				val7 = arg8;
			else
				val3 = arg3;
				val4 = arg4;
				val6 = arg6;
				val7 = arg7;
			end
			if ( val4 and val3 and ( strsub(val3,1,5) == "0xF13" or strsub(val3,1,5) == "0xF15" or strsub(val3,1,5) == "0xF53" or strsub(val3,1,5) == "0xF55" ) ) then
				sGUID = val3;
				snom = val4;
			end
			if ( sGUID ) then
				--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
					sGUID_7_10 = strsub(sGUID,7,10);
				--else
				--	sGUID_7_10 = strsub(sGUID,9,12);
				--end
				iGUID_7_10 = tonumber(sGUID_7_10,16);
				sregion = DBCS_Region_liste_code_region_courante_new();
				if ( sregion == "000" ) then
				else
					x,y = DBCS_Region_liste_position100(1);
					idate = tonumber(date("%Y%m%d"));
					DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),1,x,y,idate,arg2);
				end
			end
			sGUID = nil;
			snom = nil;
			if ( val7 and val6 and ( strsub(val6,1,5) == "0xF13" or strsub(val6,1,5) == "0xF15" or strsub(val6,1,5) == "0xF53" or strsub(val6,1,5) == "0xF55" ) ) then
				sGUID = val6;
				snom = val7;
			end
			if ( sGUID ) then
				--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
					sGUID_7_10 = strsub(sGUID,7,10);
				--else
				--	sGUID_7_10 = strsub(sGUID,9,12);
				--end
				iGUID_7_10 = tonumber(sGUID_7_10,16);
				sregion = DBCS_Region_liste_code_region_courante_new();
				if ( sregion == "000" ) then
				else
					x,y = DBCS_Region_liste_position100(1);
					idate = tonumber(date("%Y%m%d"));
					DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),1,x,y,idate,arg2);
				end
			end
		end
	elseif ( event == "GOSSIP_SHOW" ) then
		sGUID = UnitGUID("target");
		snom = GossipFrameNpcNameText:GetText();
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("GOSSIP_SHOW : snom = "..(snom or ""));
end
		if ( snom == UnitName("target") ) then
			if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
				--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
					sGUID_7_10 = strsub(sGUID,7,10);
				--else
				--	sGUID_7_10 = strsub(sGUID,9,12);
				--end
				iGUID_7_10 = tonumber(sGUID_7_10,16);
				sregion = DBCS_Region_liste_code_region_courante_new();
				if ( sregion == "000" ) then
				else
					x,y = DBCS_Region_liste_position100(1);
					idate = tonumber(date("%Y%m%d"));
					DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),0,x,y,idate);
				end
			end
		end
if ( DBCS_debug and DBCS_debug > 1 ) then
DBCS_afficherevent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20);
end
	elseif ( event == "MERCHANT_SHOW" ) then
		sGUID = UnitGUID("target");
		snom = MerchantNameText:GetText();
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("MERCHANT_SHOW : snom = "..(snom or ""));
end
		if ( snom == UnitName("target") ) then
			if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
				--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
					sGUID_7_10 = strsub(sGUID,7,10);
				--else
				--	sGUID_7_10 = strsub(sGUID,9,12);
				--end
				iGUID_7_10 = tonumber(sGUID_7_10,16);
				sregion = DBCS_Region_liste_code_region_courante_new();
				if ( sregion == "000" ) then
				else
					x,y = DBCS_Region_liste_position100(1);
					idate = tonumber(date("%Y%m%d"));
					DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),0,x,y,idate);
				end
			end
		end
if ( DBCS_debug and DBCS_debug > 1 ) then
DBCS_afficherevent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20);
end
	elseif ( event == "PLAYER_TARGET_CHANGED" ) then
		sGUID = UnitGUID("target");
		if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
			--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
				sGUID_7_10 = strsub(sGUID,7,10);
			--else
			--	sGUID_7_10 = strsub(sGUID,9,12);
			--end
			iGUID_7_10 = tonumber(sGUID_7_10,16);
			sregion = DBCS_Region_liste_code_region_courante_new();
			if ( sregion == "000" ) then
			else
				x,y = DBCS_Region_liste_position100(1);
				idate = tonumber(date("%Y%m%d"));
				DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),1,x,y,idate);
			end
		end
--	elseif ( event == "QUEST_GREETING" ) then
--		--nomfinisseur = QuestFrameNpcNameText:GetText();
--if ( DBCS_debug and DBCS_debug > 1 ) then
--DBCS_afficherevent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20);
--end
	elseif ( event == "UPDATE_MOUSEOVER_UNIT" ) then
		sGUID = UnitGUID("mouseover");
		if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
			--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
				sGUID_7_10 = strsub(sGUID,7,10);
			--else
			--	sGUID_7_10 = strsub(sGUID,9,12);
			--end
			iGUID_7_10 = tonumber(sGUID_7_10,16);
			sregion = DBCS_Region_liste_code_region_courante_new();
			if ( sregion == "000" ) then
			else
				x,y = DBCS_Region_liste_position100(1);
				idate = tonumber(date("%Y%m%d"));
				DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),1,x,y,idate);
			end
		end
	elseif ( event == "TAXIMAP_OPENED" ) then
		sGUID = UnitGUID("target");
		snom = TaxiMerchant:GetText();
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("TAXIMAP_OPENED : snom = "..(snom or ""));
end
		if ( snom == UnitName("target") ) then
			if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
				--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
					sGUID_7_10 = strsub(sGUID,7,10);
				--else
				--	sGUID_7_10 = strsub(sGUID,9,12);
				--end
				iGUID_7_10 = tonumber(sGUID_7_10,16);
				sregion = DBCS_Region_liste_code_region_courante_new();
				if ( sregion == "000" ) then
				else
					x,y = DBCS_Region_liste_position100(1);
					idate = tonumber(date("%Y%m%d"));
					DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),0,x,y,idate);
				end
			end
		end
if ( DBCS_debug and DBCS_debug > 1 ) then
DBCS_afficherevent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15,arg16,arg17,arg18,arg19,arg20);
end
	elseif ( event == "VARIABLES_LOADED" ) then
		if ( DBCS_data_Mobs_locs_LOADED and DBCS_data_Mobs_locs_LOADED == true ) then
		else
			DBCS_mobs_locs_copier_vers_serveur(false,0);
		end
	end

end

function DBCS_mobs_locs_enreg(inumpnj,sregion,inivcarte,imode,x,y,idate,stype)

local smot = nil;
local sligne = nil;
local ipos = nil;
local ipos2 = nil;
local smot_milieu;
local ilen;
local smot_tout;
local slink;
local idate2;

--TraceFrame:AddMessage("DBCS_mobs_locs_enreg : inumpnj = "..inumpnj.." , imode = "..imode.." , x = "..x.." , y = "..y.." , idate = "..idate);
	if ( DBCS_mobs_locs[inumpnj] == nil ) then
		DBCS_mobs_locs[inumpnj] = {};
	end
	if ( DBCS_mobs_locs[inumpnj][sregion] == nil ) then
		DBCS_mobs_locs[inumpnj][sregion] = {};
	end
	if ( DBCS_mobs_locs[inumpnj][sregion][inivcarte] == nil ) then
		DBCS_mobs_locs[inumpnj][sregion][inivcarte] = {};
	end
	if ( DBCS_mobs_locs[inumpnj][sregion][inivcarte][imode] == nil ) then
		DBCS_mobs_locs[inumpnj][sregion][inivcarte][imode] = "@";
	end
	smot = x.."#"..y.."#";
	sligne = DBCS_mobs_locs[inumpnj][sregion][inivcarte][imode];
--TraceFrame:AddMessage("DBCS_mobs_locs_enreg : sligne = "..sligne);
	ipos = strfind(sligne,"@"..smot..idate.."@");
	if ( ipos ) then
--TraceFrame:AddMessage("DBCS_mobs_locs_enreg : revoir demain pour la position");
	else
		ipos = strfind(sligne,"@"..smot);
		if ( ipos == nil ) then
			DBCS_mobs_locs[inumpnj][sregion][inivcarte][imode] = sligne..smot..idate.."@";
			if ( DBmobs_Local and DBmobs_Local[inumpnj] and DBmobs_Local[inumpnj][1] ) then
				smot_milieu = format("%X",inumpnj);
				ilen = strlen(smot_milieu);
				--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
					smot_tout = "unit:0xF53"..strrep("0",5-ilen)..smot_milieu.."00000000:"..DBmobs_Local[inumpnj][1][1];
				--else
				--	smot_tout = "unit:0xF53"..strrep("0",7-ilen)..smot_milieu.."000000:"..DBmobs_Local[inumpnj][1][1];
				--end
				slink = "|cff4e96f7|H"..smot_tout.."|h["..DBmobs_Local[inumpnj][1][1].."]|h|r";
if ( DBCS_debug and DBCS_debug > 1 ) then
if ( stype ) then
	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : nouvelle position mob : "..inumpnj..":"..slink.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion)..", type ="..stype);
else
	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : nouvelle position mob : "..inumpnj..":"..slink.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion));
end
end
			else
if ( DBCS_debug and DBCS_debug > 1 ) then
if ( stype ) then
	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : nouvelle position mob : "..inumpnj.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion)..", type ="..stype);
else
	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : nouvelle position mob : "..inumpnj.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion));
end
end
			end
		else
--TraceFrame:AddMessage("DBCS_mobs_locs_enreg : ipos = "..ipos);
			ipos2 = strfind(sligne,"@",ipos+1);
			if ( ipos2 ) then
				idate2 = tonumber(strsub(sligne,ipos+1,ipos2-1));
			end
			if ( ipos2 ) then	--	à modifier que si date est supérieure
--TraceFrame:AddMessage("DBCS_mobs_locs_enreg : ipos2 = "..ipos2);
				if ( idate2 == nil or idate > idate2 ) then
					DBCS_mobs_locs[inumpnj][sregion][inivcarte][imode] = strsub(sligne,1,ipos)..strsub(sligne,ipos2+1)..smot..idate.."@";
--TraceFrame:AddMessage("DBCS_mobs_locs_enreg : sligne = "..DBCS_mobs_locs[inumpnj][sregion][inivcarte][imode]);
					if ( DBmobs_Local and DBmobs_Local[inumpnj] and DBmobs_Local[inumpnj][1] ) then
						smot_milieu = format("%X",inumpnj);
						ilen = strlen(smot_milieu);
						--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
							smot_tout = "unit:0xF53"..strrep("0",5-ilen)..smot_milieu.."00000000:"..DBmobs_Local[inumpnj][1][1];
						--else
						--	smot_tout = "unit:0xF53"..strrep("0",7-ilen)..smot_milieu.."000000:"..DBmobs_Local[inumpnj][1][1];
						--end
						slink = "|cff4e96f7|H"..smot_tout.."|h["..DBmobs_Local[inumpnj][1][1].."]|h|r";
--if ( DBCS_debug and DBCS_debug > 1 ) then
--if ( stype ) then
--	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : maj position mob : "..inumpnj..":"..slink.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion)..", type ="..stype);
--else
--	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : maj position mob : "..inumpnj..":"..slink.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion));
--end
--end
					else
--if ( DBCS_debug and DBCS_debug > 1 ) then
--if ( stype ) then
--	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : maj position mob : "..inumpnj.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion)..", type ="..stype);
--else
--	TraceFrame:AddMessage("DBCS_mobs_locs_enreg : maj position mob : "..inumpnj.." en "..x.."/"..y.." dans "..sregion..":"..DBCS_Region_nom_region(sregion));
--end
--end
					end
				end
			else
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("erreur DBCS_mobs_locs_enreg : "..sligne.." mot = "..smot);
end
			end
		end
	end
	if ( DBCS_mobs_locs_Client and DBCS_prog_serveur == 0 ) then
		if ( DBCS_mobs_locs_Client[inumpnj] == nil ) then
			DBCS_mobs_locs_Client[inumpnj] = {};
		end
		if ( DBCS_mobs_locs_Client[inumpnj][sregion] == nil ) then
			DBCS_mobs_locs_Client[inumpnj][sregion] = {};
		end
		if ( DBCS_mobs_locs_Client[inumpnj][sregion][inivcarte] == nil ) then
			DBCS_mobs_locs_Client[inumpnj][sregion][inivcarte] = {};
		end
		if ( DBCS_mobs_locs_Client[inumpnj][sregion][inivcarte][imode] == nil ) then
			DBCS_mobs_locs_Client[inumpnj][sregion][inivcarte][imode] = "@";
		end
		sligne = DBCS_mobs_locs_Client[inumpnj][sregion][inivcarte][imode];
		ipos = strfind(sligne,"@"..smot..idate.."@");
		if ( ipos ) then
		else
			ipos = strfind(sligne,"@"..smot);
			if ( ipos == nil ) then
				DBCS_mobs_locs_Client[inumpnj][sregion][inivcarte][imode] = sligne..smot..idate.."@";
			else
				ipos2 = strfind(sligne,"@",ipos+1);
				if ( ipos2 ) then
					idate2 = tonumber(strsub(sligne,ipos+1,ipos2-1));
				end
				if ( ipos2 ) then	--	à modifier que si date est supérieure
					if ( idate2 == nil or idate > idate2 ) then
						DBCS_mobs_locs_Client[inumpnj][sregion][inivcarte][imode] = strsub(sligne,1,ipos)..strsub(sligne,ipos2+1)..smot..idate.."@";
					end
				end
			end
		end
	end

end

Saved_DBCS_mobs_locs_GetTrainerGreetingText = GetTrainerGreetingText;
function DBCS_mobs_locs_GetTrainerGreetingText()

local snom;
local sGUID;
local sGUID_7_10;
local iGUID_7_10;
local sregion;
local x,y;

	Saved_DBCS_mobs_locs_GetTrainerGreetingText();
	sGUID = UnitGUID("target");
	snom = ClassTrainerNameText:GetText();
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("DBCS_mobs_locs_GetTrainerGreetingText : snom = "..(snom or ""));
end
	if ( snom == UnitName("target") ) then
		if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
			--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
				sGUID_7_10 = strsub(sGUID,7,10);
			--else
			--	sGUID_7_10 = strsub(sGUID,9,12);
			--end
			iGUID_7_10 = tonumber(sGUID_7_10,16);
			sregion = DBCS_Region_liste_code_region_courante_new();
			if ( sregion == "000" ) then
			else
				x,y = DBCS_Region_liste_position100(1);
				idate = tonumber(date("%Y%m%d"));
				DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),0,x,y,idate);
			end
		end
	end

end
GetTrainerGreetingText = DBCS_mobs_locs_GetTrainerGreetingText;

Saved_DBCS_mobs_locs_QuestFrame_SetPortrait = QuestFrame_SetPortrait;
function DBCS_mobs_locs_QuestFrame_SetPortrait()

local snom;
local sGUID;
local sGUID_7_10;
local iGUID_7_10;
local sregion;
local x,y;

	Saved_DBCS_mobs_locs_QuestFrame_SetPortrait();
	sGUID = UnitGUID("target");
	snom = QuestFrameNpcNameText:GetText();
if ( DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("DBCS_mobs_locs_QuestFrame_SetPortrait : snom = "..(snom or ""));
end
	if ( snom == UnitName("target") ) then
		if ( sGUID and ( strsub(sGUID,1,5) == "0xF13" or strsub(sGUID,1,5) == "0xF15" or strsub(sGUID,1,5) == "0xF53" or strsub(sGUID,1,5) == "0xF55" ) ) then
			--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
				sGUID_7_10 = strsub(sGUID,7,10);
			--else
			--	sGUID_7_10 = strsub(sGUID,9,12);
			--end
			iGUID_7_10 = tonumber(sGUID_7_10,16);
			sregion = DBCS_Region_liste_code_region_courante_new();
			if ( sregion == "000" ) then
			else
				x,y = DBCS_Region_liste_position100(1);
				idate = tonumber(date("%Y%m%d"));
				DBCS_mobs_locs_enreg(iGUID_7_10,sregion,DBCS_Region_liste_numcarte(),0,x,y,idate);
			end
		end
	end

end
QuestFrame_SetPortrait = DBCS_mobs_locs_QuestFrame_SetPortrait;

--/script DBCS_mobs_locs_copier_vers_serveur();
function DBCS_mobs_locs_copier_vers_serveur(bafficher,nb)

local inumPNJ;
local smot_milieu;
local ilen;
local smot_tout;
local slink;
local sregion;
local inivcarte;
local imode;
local sligne;
local sligne2;
local bcontinuer;
local ideb;
local ifin;
local smot;
local smot2;
local x;
local y;
local idate;
local idate2;
local ipos;
local ipos2;
local inb;
local bmodif;
local ireste;

	if ( bafficher ) then
		if ( bafficher == false ) then
		else
			bafficher = true;
		end
	else
		bafficher = true;
	end
	if ( nb ) then
	else
		nb = 100;
	end
	inb = 0;
	ireste = 0;
	for inumPNJ, _ in pairs(DBCS_mobs_locs_Client) do
		if ( nb == 0 or inb < nb ) then
			bmodif = false;
			smot_milieu = format("%X",inumPNJ);
			ilen = strlen(smot_milieu);
			--if ( DBCS_mobs_locs_wow_build > DBCS_mobs_locs_wow_build_live ) then
				if ( DBmobs_Local and DBmobs_Local[inumPNJ] and DBmobs_Local[inumPNJ][1] and DBmobs_Local[inumPNJ][1][1] ) then
					smot_tout = "unit:0xF53"..strrep("0",5-ilen)..smot_milieu.."00000000:"..DBmobs_Local[inumPNJ][1][1];
					slink = "|cff4e96f7|H"..smot_tout.."|h["..DBmobs_Local[inumPNJ][1][1].."]|h|r";
				else
					smot_tout = "unit:0xF53"..strrep("0",5-ilen)..smot_milieu.."00000000:Inconnu";
					slink = "|cff4e96f7|H"..smot_tout.."|h[Inconnu]|h|r";
				end
			--else
			--	if ( DBmobs_Local and DBmobs_Local[inumPNJ] and DBmobs_Local[inumPNJ][1] and DBmobs_Local[inumPNJ][1][1] ) then
			--		smot_tout = "unit:0xF53"..strrep("0",7-ilen)..smot_milieu.."000000:"..DBmobs_Local[inumPNJ][1][1];
			--		slink = "|cff4e96f7|H"..smot_tout.."|h["..DBmobs_Local[inumPNJ][1][1].."]|h|r";
			--	else
			--		smot_tout = "unit:0xF53"..strrep("0",7-ilen)..smot_milieu.."000000:Inconnu";
			--		slink = "|cff4e96f7|H"..smot_tout.."|h[Inconnu]|h|r";
			--	end
			--end
			--if ( DBCS_mobs_locs[inumPNJ] == nil ) then
			--	DBCS_mobs_locs[inumPNJ] = DBCS_mobs_locs_Client[inumPNJ];
			--	bmodif = true;
--if ( bafficher == true and DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("0 j'ajoutes toutes les locs du mob "..inumPNJ.." : "..slink);
--end
			--else
				for sregion, _ in pairs(DBCS_mobs_locs_Client[inumPNJ]) do
					--if ( DBCS_mobs_locs[inumPNJ][sregion] == nil ) then
					--	DBCS_mobs_locs[inumPNJ][sregion] = DBCS_mobs_locs_Client[inumPNJ][sregion];
--					--	bmodif = true;
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("1 j'ajoutes toutes les locs du mob "..inumPNJ.." : "..slink.." pour la region "..sregion.." : "..DBCS_Region_nom_region(sregion));
--end
					--else
						for inivcarte, _ in pairs(DBCS_mobs_locs_Client[inumPNJ][sregion]) do
							--if ( DBCS_mobs_locs[inumPNJ][sregion][inivcarte] == nil ) then
							--	DBCS_mobs_locs[inumPNJ][sregion][inivcarte] = DBCS_mobs_locs_Client[inumPNJ][sregion][inivcarte];
--							--	bmodif = true;
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("2 j'ajoutes toutes les locs du mob "..inumPNJ.." : "..slink.." pour la region "..sregion.." : "..DBCS_Region_nom_region(sregion).." , inivcarte = "..inivcarte);
--end
							--else
								for imode, _ in pairs(DBCS_mobs_locs_Client[inumPNJ][sregion][inivcarte]) do
									--if ( DBCS_mobs_locs[inumPNJ][sregion][inivcarte][imode] == nil ) then
									--	DBCS_mobs_locs[inumPNJ][sregion][inivcarte][imode] = DBCS_mobs_locs_Client[inumPNJ][sregion][inivcarte][imode];
--									--	bmodif = true;
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("3 j'ajoutes toutes les locs du mob "..inumPNJ.." : "..slink.." pour la region "..sregion.." : "..DBCS_Region_nom_region(sregion).." , inivcarte = "..inivcarte.." , imode = "..imode);
--end
									--else
										sligne = DBCS_mobs_locs_Client[inumPNJ][sregion][inivcarte][imode];
										sligne2 = "@";
										if ( DBCS_mobs_locs[inumPNJ] and DBCS_mobs_locs[inumPNJ][sregion] and DBCS_mobs_locs[inumPNJ][sregion][inivcarte] and DBCS_mobs_locs[inumPNJ][sregion][inivcarte][imode] ) then
											sligne2 = DBCS_mobs_locs[inumPNJ][sregion][inivcarte][imode];
										end
										bcontinuer = true;
										ifin = 1;
										while ( bcontinuer == true ) do
											ideb = ifin + 1;
											ifin = strfind(sligne,"@",ideb);
											if ( ifin ) then
												smot = strsub(sligne,ideb,ifin-1);
												x,y = strsplit("#",smot);
												ilen = strlen(x) + strlen(y) + 2;
												idate = tonumber(strsub(smot,ilen + 1));
												if ( idate < 20101125 ) then
												else
													smot2 = "@"..x.."#"..y.."#";
													ipos = strfind(sligne2,smot2);
													if ( ipos ) then
														ipos2 = strfind(sligne2,"@",ipos+1);
														idate2 = tonumber(strsub(sligne2,ipos+strlen(smot2),ipos2-1));
														if ( idate > idate2 ) then
															sligne2 = strsub(sligne2,1,ipos)..strsub(sligne2,ipos2+1)..x.."#"..y.."#"..idate.."@";
--														bmodif = true;
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("4 je redates la loc "..x.."/"..y.." au "..idate.." au lieu du "..idate2.." du mob "..inumPNJ.." : "..slink.." pour la region "..sregion.." : "..DBCS_Region_nom_region(sregion).." , inivcarte = "..inivcarte.." , imode = "..imode);
--end
														end
													else
														sligne2 = sligne2..strsub(smot2,2)..idate.."@";
--													bmodif = true;
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("5 j'ajoutes la loc "..x.."/"..y.." du mob "..inumPNJ.." : "..slink.." pour la region "..sregion.." : "..DBCS_Region_nom_region(sregion).." , inivcarte = "..inivcarte.." , imode = "..imode);
--end
													end
												end
											else
												bcontinuer = false;
											end
										end
										if ( sligne2 == "@" ) then
										else
											if ( DBCS_mobs_locs[inumPNJ] == nil ) then
												DBCS_mobs_locs[inumPNJ] = {};
											end
											if ( DBCS_mobs_locs[inumPNJ][sregion] == nil ) then
												DBCS_mobs_locs[inumPNJ][sregion] = {};
											end
											if ( DBCS_mobs_locs[inumPNJ][sregion][inivcarte] == nil ) then
												DBCS_mobs_locs[inumPNJ][sregion][inivcarte] = {};
											end
											DBCS_mobs_locs[inumPNJ][sregion][inivcarte][imode] = sligne2;
										end
									--end
								end
							--end
						end
					--end
				end
			--end
			if ( nb == 0 ) then
			else
				DBCS_mobs_locs_Client[inumPNJ] = nil;
			end
			if ( bmodif == true ) then
				inb = inb + 1;
				bmodif = false;
			end
		else
			ireste = ireste + 1;
		end
	end
if ( bafficher == true and DBCS_debug and DBCS_debug > 1 ) then
TraceFrame:AddMessage("il reste "..ireste.." enregistrements mobs locs");
end

end

--/script DBCS_mobs_locs_copier_pnj2_vers_serveur();
function DBCS_mobs_locs_copier_pnj2_vers_serveur()

local snompnj;
local inumpnj;
local snumregion;
local sligne;
local iposdeb;
local iposfin;
local smot;
local ipos;
local x;
local y;
local i;

	i = 0;
	DBmobs_Local_Init_Inverse();
	for snompnj, _ in pairs(DBPS2) do
		if ( DBmobs_Local_inverse[snompnj] ) then
			if ( table.getn(DBmobs_Local_inverse[snompnj]) == 1 ) then
				inumpnj = DBmobs_Local_inverse[snompnj][1];
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("le mob "..inumpnj.."/"..snompnj.." existe une fois");
--end
				if ( DBCS_mobs_locs[inumpnj] == nil ) then
					DBCS_mobs_locs[inumpnj] = {};
				end
				i = i + 1;
				for snumregion, _ in pairs(DBPS2[snompnj]) do
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("region "..snumregion);
--end
					if ( snumregion == "000" ) then
					else
						if ( DBCS_mobs_locs[inumpnj][snumregion] == nil ) then
							DBCS_mobs_locs[inumpnj][snumregion] = {};
						end
						if ( DBCS_mobs_locs[inumpnj][snumregion][0] == nil ) then
							DBCS_mobs_locs[inumpnj][snumregion][0] = {};
						end
						if ( DBCS_mobs_locs[inumpnj][snumregion][0][1] == nil ) then
							DBCS_mobs_locs[inumpnj][snumregion][0][1] = "@";
						end
						--ignorer les locs 0/0
						if ( DBPS2[snompnj][snumregion]["xy"] ) then
							sligne = DBPS2[snompnj][snumregion]["xy"];
							iposdeb = 2;
							iposfin = 2;
							while ( iposfin ) do
								iposfin = strfind(sligne,"@",iposdeb);
								if ( iposfin ) then
									smot = strsub(sligne,iposdeb,iposfin-1);
									ipos = strfind(smot,"X");
									if ( ipos ) then
										x = tonumber(strsub(smot,1,ipos-1));
										y = tonumber(strsub(smot,ipos+1));
										if ( x == 0 and y == 0 ) then
										else
											smot = "@"..x.."#"..y.."#";
											ipos = strfind(DBCS_mobs_locs[inumpnj][snumregion][0][1],smot);
											if ( ipos == nil ) then
												DBCS_mobs_locs[inumpnj][snumregion][0][1] = DBCS_mobs_locs[inumpnj][snumregion][0][1]..x.."#"..y.."#0@";
											end
--											if ( i <= 10 ) then
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("le mob "..inumpnj.."/"..snompnj.." existe une fois");
--end
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("region "..snumregion);
--end
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("x = "..x..", y = "..y);
--end
--
--											end
										end
									end
									iposdeb = iposfin + 1;
								end
							end
						end
					end
				end
				DBPS2[snompnj] = nil;
			else
--if ( DBCS_debug and DBCS_debug > 1 ) then
--TraceFrame:AddMessage("le mob "..snompnj.." existe "..table.getn(DBmobs_Local_inverse[snompnj]).." fois");
--end
			end
		else
		end
	end

end
