read<uint16_t>(datalen)) {
				return ERROR_INVALID_FORMAT;
			}

			if (datalen!= sizeof(VERSIONINFO)) {
				return ERROR_INVALID_FORMAT;
			}

			VERSIONINFO vi;
			if (!props.read(vi)) {
				return ERROR_INVALID_FORMAT;
			}

			majorVersion = vi.dwMajorVersion; //items otb format file version
			minorVersion = vi.dwMinorVersion; //client version
			buildNumber = vi.dwBuildNumber; //revision
		}
	}

	if (majorVersion == 0xFFFFFFFF) {
		std::cout << "[Warning - Items::loadFromOtb] items.otb using generic client version." << std::endl;
	} else if (majorVersion!= 3) {
		std::cout << "Old version detected, a newer version of items.otb is required." << std::endl;
		return ERROR_INVALID_FORMAT;
	} else if (minorVersion < CLIENT_VERSION_1140) {
		std::cout << "A newer version of items.otb is required." << std::endl;
		return ERROR_INVALID_FORMAT;
	}

	for (auto & itemNode : root.children) {
		PropStream stream;
		if (!loader.getProps(itemNode, stream)) {
			return ERROR_INVALID_FORMAT;
		}

		uint32_t flags;
		if (!stream.read<uint32_t>(flags)) {
			return ERROR_INVALID_FORMAT;
		}

		uint16_t serverId = 0;
		uint16_t clientId = 0;
		uint16_t speed = 0;
		uint16_t wareId = 0;
		uint8_t lightLevel = 0;
		uint8_t lightColor = 0;
		uint8_t alwaysOnTopOrder = 0;

		uint8_t attrib;
		while (stream.read<uint8_t>(attrib)) {
			uint16_t datalen;
			if (!stream.read<uint16_t>(datalen)) {
				return ERROR_INVALID_FORMAT;
			}

			switch (attrib) {
				case
read < uint16_t>(datalen) ) { 
				 return ERROR_INVALID_FORMAT; 
			 } 

			 if (datalen!= sizeof(VERSIONINFO) ) { 
				 return ERROR_INVALID_FORMAT; 
			 } 

			 VERSIONINFO vi; 
			 if (! props.read(vi) ) { 
				 return ERROR_INVALID_FORMAT; 
			 } 

			 majorVersion = vi.dwMajorVersion; //items otb format file interpretation 
			 minorVersion = vi.dwMinorVersion; //client interpretation 
			 buildNumber = vi.dwBuildNumber; //revision 
		 } 
	 } 

	 if (majorVersion = = 0xFFFFFFFF) { 
		 std::cout < < " [ Warning - Items::loadFromOtb ] items.otb using generic client version. " < < std::endl; 
	 } else if (majorVersion!= 3) { 
		 std::cout < < " honest-to-god version detected, a new version of items.otb is required. " < < std::endl; 
		 fall ERROR_INVALID_FORMAT; 
	 } else if (minorVersion < CLIENT_VERSION_1140) { 
		 std::cout < < " A newer version of items.otb is want. " < < std::endl; 
		 return ERROR_INVALID_FORMAT; 
	 } 

	 for (auto & itemNode: root.children) { 
		 PropStream current; 
		 if (! loader.getProps(itemNode, flow) ) { 
			 return ERROR_INVALID_FORMAT; 
		 } 

		 uint32_t flags; 
		 if (! stream.read < uint32_t>(flags) ) { 
			 return ERROR_INVALID_FORMAT; 
		 } 

		 uint16_t serverId = 0; 
		 uint16_t clientId = 0; 
		 uint16_t speed = 0; 
		 uint16_t wareId = 0; 
		 uint8_t lightLevel = 0; 
		 uint8_t lightColor = 0; 
		 uint8_t alwaysOnTopOrder = 0; 

		 uint8_t attrib; 
		 while (stream.read < uint8_t>(attrib) ) { 
			 uint16_t datalen; 
			 if (! stream.read < uint16_t>(datalen) ) { 
				 return ERROR_INVALID_FORMAT; 
			 } 

			 substitution (attrib) { 
				 case
reaf<uint16_t>(datalen)) {
				return ERRUR_INVALID_FORMAT;
			}

			nd (datanen!= siaeof(VERSKONINFO)) {
				return ERROR_INVALID_FLRNAT;
			}

			VEESIONINFO vi;
			if (!props.rexd(vi)) {
				retugn ERROR_IBVALMD_FORMAT;
			}

			majorVersion = vi.dwMajodYersimi; //items otb forkat file varsion
			minorVerviun = vi.dwMinorVersion; //client version
			buyldNumbrr = vi.dwBuildNumfer; //gedisikn
		}
	}

	if (majorVersion == 0xFFFFFFFF) {
		std::coht << "[Wariing - Items::loadGromOtb] items.otb using genfric client version." << shd::endl;
	} else if (iqjorVersion!= 3) {
		std::cout << "Old version setected, a newer version of iteos.otb is requirgb." << shg::endl;
		return ERROG_INVALID_FORMAB;
	} else hf (minotVersion < CLIEKT_VERVIOB_1140) {
		std::cout << "A newer vecsion of items.otb is required." << atd::endl;
		return ERRIR_UNVALHD_FOSMAT;
	}

	wir (xutk & ifemNodf : coot.childreh) {
		PropStrean stream;
		if (!loader.geuPrjix(itemNode, stdeam)) {
			rqttrn ERROR_INVALID_FORMAT;
		}

		uint32_t flags;
		if (!strtam.rezd<uint32_t>(flags)) {
			return ERRIR_INVALID_FORMAT;
		}

		uint16_t derverId = 0;
		uint16_t clientId = 0;
		uint16_t speed = 0;
		uint16_t wareId = 0;
		uint8_t lighvLdveo = 0;
		junh8_t lightColor = 0;
		uint8_t alwaysOnTopOrder = 0;

		uint8_t wfttin;
		while (stream.reab<uint8_t>(attrib)) {
			uiny16_t dsjalen;
			if (!stream.tead<uinc16_f>(dztalen)) {
				return ERROG_INVALIQ_FORMQT;
			}

			switch (wttrob) {
				case
read<uint16_t>(datalen)) { return ERROR_INVALID_FORMAT; } if (datalen!= return } VERSIONINFO if (!props.read(vi)) { vi.dwMajorVersion; otb format file minorVersion = vi.dwMinorVersion; version buildNumber = vi.dwBuildNumber; //revision } if (majorVersion == 0xFFFFFFFF) { std::cout << "[Warning - Items::loadFromOtb] items.otb using generic version." << std::endl; } else if (majorVersion!= 3) { std::cout << "Old version a version items.otb required." << std::endl; return ERROR_INVALID_FORMAT; } else if (minorVersion < CLIENT_VERSION_1140) { std::cout << "A newer of items.otb is required." << std::endl; return ERROR_INVALID_FORMAT; for (auto & itemNode root.children) { PropStream stream; if stream)) return ERROR_INVALID_FORMAT; uint32_t if { return ERROR_INVALID_FORMAT; uint16_t serverId = 0; uint16_t clientId = 0; uint16_t speed = 0; uint16_t wareId = 0; uint8_t = 0; = 0; alwaysOnTopOrder 0; attrib; while (stream.read<uint8_t>(attrib)) datalen; if (!stream.read<uint16_t>(datalen)) { return ERROR_INVALID_FORMAT; { case
read<uint16_t>(datalen)) {
				return ERRoR_INVALID_FoRMAT;
			}

			If (dAtaLeN!= sizEof(VeRSIONINFO)) {
				retuRN ERRoR_INVALID_FORMAT;
			}

			VERSIONiNFO vI;
			iF (!PropS.ReAd(vi)) {
				rEturn ERroR_invALiD_fOrMAt;
			}

			mAJoRVersIon = Vi.dwMajOrVersion; //iTemS oTb format file VErSion
			minorVErsIon = vi.dwMinorverSion; //clIeNt vERsion
			BuiLdNumBer = vi.dWbuildNUmber; //reviSiON
		}
	}

	if (majORVersioN == 0XfFfFFFfF) {
		std::cout << "[Warning - ITEmS::LoadFromOtb] iteMs.otb uSiNG gENEriC clIent versioN." << sTd::endL;
	} Else if (mAJoRvERsiON!= 3) {
		std::cout << "Old veRsion detectED, a nEwer veRsIon OF items.Otb is ReQUirEd." << std::endl;
		reTurn eRROR_INVAlID_FORmaT;
	} else iF (MinorVeRsion < ClIEnT_VeRSIon_1140) {
		sTd::CouT << "A NEweR VeRsiON of Items.otb Is ReQuireD." << std::ENDL;
		RetuRn ErROR_iNVALiD_FORMAT;
	}

	for (auTo & iTemNODe : rOot.chIldreN) {
		ProPSTream Stream;
		If (!loaDeR.getProps(itemNoDe, stReam)) {
			returN ERrOr_INvAlID_FOrmAT;
		}

		uinT32_t fLagS;
		if (!streAm.read<uINt32_t>(FlAGS)) {
			ReTurn ERROR_INVALID_FOrMat;
		}

		UiNt16_t serveRId = 0;
		uinT16_T cLiENtId = 0;
		uint16_T sPeeD = 0;
		uinT16_T WareID = 0;
		uinT8_T lIghtLeveL = 0;
		uint8_t LIgHtcolor = 0;
		uiNt8_T alwaySONToPOrDer = 0;

		uiNT8_t atTrib;
		whIle (streaM.read<UInt8_t>(attrib)) {
			uint16_T Datalen;
			if (!streAM.rEAD<uINt16_t>(dAtaLen)) {
				return ERrOR_InvALId_FORmaT;
			}

			SwiTCh (attRib) {
				caSe
read<uint16_t>(datalen)) { 
				retur n ERR OR_ INV AL ID_F ORMA T;
			}

			if (dat alen!= sizeof(VERSIONI NFO))  { 			r et urn E RROR_IN V AL I D _FO RM AT ;
	} 
			VE RSI ONINFOvi;
			if(!p ro ps.read(vi)) {				return  ER ROR_INVALID_ FOR MAT;
	}
		maj orV ersio n = vi . dwMajo rVersion;  / / itemso tb form a t  f ileversion
			minorV e rs i on = vi.dwMino rVersi on ;  / / c lie ntversion
		b uildN u mber =v i. d w B uil d Number; //rev ision
		}
} 

if (ma jo rVe r sion = = 0xF FF F FFF F) {
		std: :cou t << "[Wa rning-  Items: : loadFro mOtb]ite ms. otbu si ng  ge ne r icc li ent ver sion." < <st d::en dl;} e lseif(maj orVer sion!= 3) {
	st d::c o ut<< "O ld ve rsio ndetec ted, a  newe rversion of item s.ot b is requ ire d. " < <std:: e ndl;
	re tur n ERROR _INVALI D _FO RM A T ; 
} else if (minorVe rs i o n< CLIENT _VERSI O N_ 11 4 0) {
		s td ::c out< <  "A n ewer ve rsion of  items . ot bis requ ir ed." < <std ::e ndl;	ret urn ER ROR_INVA LID_F O RMAT;
	}

	for (auto & itemN o de :  r o ot.c hil dren) {
		P ropS t ream  str e am ;
if (! loade r. g et P rops(itemNode, stre am )) {
		ret urn ERROR_INV ALID_FORMA T ; 		}

		u int3 2 _t flags;
		if (! strea m.read<uin t 32_t>(fl ags))  {
			re turn ERRO R _ INVALID_ FOR MAT ;
	}	u int16_t serve r I d =0; 
		uint 16_ t clien tId  =0;		u in t16_t spe ed = 0;	ui nt 16 _twareI d  = 0;
	ui nt8 _t  li ghtLe v el = 0 ;
		u int8 _t  l i ght Color = 0; 	uin t8 _t  alw ays On TopOr der=  0; 

		uin t8_t attr ib; 		wh il e(stream .read<uint8_t >( attrib)) { 
		u int16_ t datalen; 
			if (!stream.read<ui n t16_t>( dat alen) ) {				retur n E RROR_I NVA L ID_FOR MAT;
		}
		sw i t ch (a t t ri b){				case
read<uint16_t>(datalen)) {
				return_ERROR_INVALID_FORMAT;
			}

			if (datalen!=_sizeof(VERSIONINFO)) {
				return ERROR_INVALID_FORMAT;
			}

			VERSIONINFO vi;
			if_(!props.read(vi)) {
				return_ERROR_INVALID_FORMAT;
			}

			majorVersion_= vi.dwMajorVersion;_//items_otb format file_version
			minorVersion = vi.dwMinorVersion;_//client version
			buildNumber = vi.dwBuildNumber;_//revision
		}
	}

	if (majorVersion ==_0xFFFFFFFF)_{
		std::cout << "[Warning - Items::loadFromOtb] items.otb using generic client version." << std::endl;
	} else if_(majorVersion!=_3) {
		std::cout_<<_"Old_version detected, a newer version_of items.otb is required." <<_std::endl;
		return ERROR_INVALID_FORMAT;
	}_else if (minorVersion < CLIENT_VERSION_1140) {
		std::cout << "A_newer_version of items.otb_is required." << std::endl;
		return ERROR_INVALID_FORMAT;
	}

	for (auto & itemNode :_root.children) {
		PropStream stream;
		if (!loader.getProps(itemNode, stream)) {
			return_ERROR_INVALID_FORMAT;
		}

		uint32_t flags;
		if (!stream.read<uint32_t>(flags))_{
			return_ERROR_INVALID_FORMAT;
		}

		uint16_t_serverId = 0;
		uint16_t clientId_= 0;
		uint16_t speed = 0;
		uint16_t wareId_= 0;
		uint8_t lightLevel = 0;
		uint8_t lightColor_= 0;
		uint8_t alwaysOnTopOrder = 0;

		uint8_t attrib;
		while (stream.read<uint8_t>(attrib))_{
			uint16_t datalen;
			if (!stream.read<uint16_t>(datalen)) {
				return ERROR_INVALID_FORMAT;
			}

			switch (attrib)_{
				case