Jump to content

Fix MSM count group (Shape and Hair)


niokio

Recommended Posts

Hi dev. 
Why use such a bad method? Why is there "HairDataCount" there? Let's fix this. Because specifying 999 is a bad decision. Since our loop costs 999 iterations (although that much is not required).

Group HairData
{
	PathName	"d:/ymir Work/pc2/assassin/"

	HairDataCount 			999
	Group HairData00
	{	
		HairIndex			0
		Model				"hair/hair_1_1.gr2"
		SourceSkin			"hair/hair_1_1.dds"
		TargetSkin			"assassin_hair_01.dds"
	}


1. Go to GameLib->RaceDataFile.cpp

2. looking for a string "if (TextFileLoader.SetChildNode("shapedata"))"

3. look for "FIX_SHAPE_GROUP_COUNT" and do how

	if (TextFileLoader.SetChildNode("shapedata"))
	{
		std::string strPathName;
		DWORD dwShapeDataCount = 0;
		if (
			TextFileLoader.GetTokenString("pathname", &strPathName)
#ifndef FIX_SHAPE_GROUP_COUNT
			&& TextFileLoader.GetTokenDoubleWord("shapedatacount", &dwShapeDataCount)
#endif
		)
		{
#ifdef FIX_SHAPE_GROUP_COUNT
			while (TextFileLoader.SetChildNode("shapedata", dwShapeDataCount))
#else
			for (DWORD i = 0; i < dwShapeDataCount; ++i)
#endif
			{
#ifndef FIX_SHAPE_GROUP_COUNT
				if (!TextFileLoader.SetChildNode("shapedata", i))
				{
					continue;
				}
#endif

				/////////////////////////
				// Temporary - АМєҐЖ®ё¦ А§ЗС АУЅГ ±вґЙ
				TextFileLoader.GetTokenString("specialpath", &strPathName);
				/////////////////////////

				DWORD dwShapeIndex;
				if (!TextFileLoader.GetTokenDoubleWord("shapeindex", &dwShapeIndex))
				{
#ifdef FIX_SHAPE_GROUP_COUNT
					dwShapeDataCount++;
#endif
					continue;
				}

				// LOCAL_PATH_SUPPORT
				std::string strModel;
				if (TextFileLoader.GetTokenString("model", &strModel))
				{
					SetShapeModel(dwShapeIndex, (strPathName + strModel).c_str());
				}
				else
				{
					if (!TextFileLoader.GetTokenString("local_model", &strModel))
					{
#ifdef FIX_SHAPE_GROUP_COUNT
						dwShapeDataCount++;
#endif
						continue;
					}

					SetShapeModel(dwShapeIndex, strModel.c_str());
				}
				// END_OF_LOCAL_PATH_SUPPORT

				std::string strSourceSkin;
				std::string strTargetSkin;

				// LOCAL_PATH_SUPPORT
				if (TextFileLoader.GetTokenString("local_sourceskin", &strSourceSkin) && TextFileLoader.GetTokenString("local_targetskin", &strTargetSkin))
				{
					AppendShapeSkin(dwShapeIndex, 0, strSourceSkin.c_str(), strTargetSkin.c_str());
				}
				// END_OF_LOCAL_PATH_SUPPORT

				if (TextFileLoader.GetTokenString("sourceskin", &strSourceSkin) && TextFileLoader.GetTokenString("targetskin", &strTargetSkin))
				{
					AppendShapeSkin(dwShapeIndex, 0, (strPathName + strSourceSkin).c_str(), (strPathName + strTargetSkin).c_str());
				}

				if (TextFileLoader.GetTokenString("sourceskin2", &strSourceSkin) && TextFileLoader.GetTokenString("targetskin2", &strTargetSkin))
				{
					AppendShapeSkin(dwShapeIndex, 0, (strPathName + strSourceSkin).c_str(), (strPathName + strTargetSkin).c_str());
				}

#ifdef FIX_SHAPE_GROUP_COUNT
				dwShapeDataCount++;
#endif
				TextFileLoader.SetParentNode();
			}
		}

		TextFileLoader.SetParentNode();
	}


4. and do the same with hair part

	if (TextFileLoader.SetChildNode("hairdata"))
	{
		std::string strPathName;
		DWORD dwHairDataCount = 0;

		if (
			TextFileLoader.GetTokenString("pathname", &strPathName)
#ifndef FIX_HAIR_GROUP_COUNT
			&& TextFileLoader.GetTokenDoubleWord("hairdatacount", &dwHairDataCount)
#endif
		)
		{
#ifdef FIX_HAIR_GROUP_COUNT
			while(TextFileLoader.SetChildNode("hairdata", dwHairDataCount))
#else
			for (DWORD i = 0; i < dwHairDataCount; ++i)
#endif
			{
#ifndef FIX_HAIR_GROUP_COUNT
				if (!TextFileLoader.SetChildNode("hairdata", i))
				{
					continue;
				}
#endif

				/////////////////////////
				// Temporary - АМєҐЖ®ё¦ А§ЗС АУЅГ ±вґЙ
				TextFileLoader.GetTokenString("specialpath", &strPathName);
				/////////////////////////

				DWORD dwShapeIndex;
				if (!TextFileLoader.GetTokenDoubleWord("hairindex", &dwShapeIndex))
				{
#ifdef FIX_HAIR_GROUP_COUNT
					dwHairDataCount++;
#endif
					continue;
				}

				std::string strModel;
				std::string strSourceSkin;
				std::string strTargetSkin;
				if (TextFileLoader.GetTokenString("model", &strModel) && TextFileLoader.GetTokenString("sourceskin", &strSourceSkin) && TextFileLoader.GetTokenString("targetskin", &strTargetSkin))
				{
					SetHairSkin(dwShapeIndex, 0, (strPathName + strModel).c_str(), (strPathName + strSourceSkin).c_str(), (strPathName + strTargetSkin).c_str());
				}

#ifdef FIX_HAIR_GROUP_COUNT
				dwHairDataCount++;
#endif
				TextFileLoader.SetParentNode();
			}
		}

		TextFileLoader.SetParentNode();
	}

 

5. Add to Userinterface->Locale_inc.h

#define FIX_SHAPE_GROUP_COUNT
#define FIX_HAIR_GROUP_COUNT

 

6. And most importantly, you need to have the correct sequence of groups. For example:

	Group ShapeData08
	{
		ShapeIndex			9
		Model				"assassin_yonga.GR2"
		SourceSkin			"assassin_yonga.DDS"
		TargetSkin			"assassin_yonga.DDS"
	}
	Group ShapeData09
	{
		ShapeIndex			10
		Model				"assassin_yonga.GR2"
		SourceSkin			"assassin_yonga.DDS"
		TargetSkin			"assassin_salpung.DDS"
	}
	Group ShapeData10
	{
		ShapeIndex			11
		Model				"assassin_bihyeon.GR2"
		SourceSkin			"assassin_bihyeon.DDS"
		TargetSkin			"assassin_bihyeon.DDS"
	}

(if, for example, after ShapeData08 there is ShapeData11, then the loop will end on ShapeData08 and finish its work.)

If anyone has any ideas on how to improve the code, please share.

  • Metin2 Dev 1
  • Lmao 1
  • Good 2
  • Love 1
  • Love 2
Link to comment
Share on other sites

Very nice release, I was bothering with that since I first saw that stupidity!

There is only one way we could improve the code 'style'. I think at the end, performance wise, It won't really affect the compilation or execution speed:

Instead of increasing the counters before any continue; or at the end of the while loop, use "do-while" in combination with the increment operator:

 

			do
			{
				[...]
			}
			while (TextFileLoader.SetChildNode("hairdata", dwHairDataCount++));

 

Edited by Lead0b110010100
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.