Jump to content

Recommended Posts

  • Active+ Member

After a long time I tried to add armor and realized how annoying it is to use the 
ShapeDataCount or the HairDataCount every time, so I did it “automatically” via Source

we open:
GameLib/RaceDataFile.cpp

replace the whole code with:
 

Spoiler
#include "StdAfx.h"
#include "../eterLib/ResourceManager.h"

#include "RaceData.h"
#include "RaceMotionData.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

BOOL CRaceData::LoadRaceData(const char* c_szFileName) {
    CTextFileLoader TextFileLoader;
    if (!TextFileLoader.Load(c_szFileName)) {
        return false;
    }

    TextFileLoader.SetTop();

    TextFileLoader.GetTokenString("basemodelfilename", &m_strBaseModelFileName);
    TextFileLoader.GetTokenString("treefilename", &m_strTreeFileName);
    TextFileLoader.GetTokenString("attributefilename", &m_strAttributeFileName);
    TextFileLoader.GetTokenString("smokebonename", &m_strSmokeBoneName);
    TextFileLoader.GetTokenString("motionlistfilename", &m_strMotionListFileName);

    if (!m_strTreeFileName.empty()) {
        CFileNameHelper::StringPath(m_strTreeFileName);
    }

    CTokenVector* pSmokeTokenVector;
    if (TextFileLoader.GetTokenVector("smokefilename", &pSmokeTokenVector)) {
        if (pSmokeTokenVector->size() % 2 != 0) {
            TraceError("SmokeFileName ArgCount[%d]%%2==0", pSmokeTokenVector->size());
            return false;
        }

        for (size_t i = 0; i < pSmokeTokenVector->size(); i += 2) {
            int eSmoke = std::stoi(pSmokeTokenVector->at(i));
            if (eSmoke < 0 || eSmoke >= SMOKE_NUM) {
                TraceError("SmokeFileName SmokeNum[%d] OUT OF RANGE", eSmoke);
                return false;
            }

            const std::string& effectFileName = pSmokeTokenVector->at(i + 1);
            if (!CEffectManager::Instance().RegisterEffect2(effectFileName.c_str(), &m_adwSmokeEffectID[eSmoke])) {
                TraceError("CRaceData::RegisterEffect2(%s) ERROR", effectFileName.c_str());
                m_adwSmokeEffectID[eSmoke] = 0;
                return false;
            }
        }
    }

    if (TextFileLoader.SetChildNode("shapedata")) {
        std::string pathName;
        if (TextFileLoader.GetTokenString("pathname", &pathName)) {
            size_t shapeDataIndex = 0;
            while (TextFileLoader.SetChildNode("shapedata", shapeDataIndex)) {
                DWORD shapeIndex;
                if (!TextFileLoader.GetTokenDoubleWord("shapeindex", &shapeIndex)) {
                    TextFileLoader.SetParentNode();
                    ++shapeDataIndex;
                    continue;
                }

                std::string model, sourceSkin, targetSkin;
                if (TextFileLoader.GetTokenString("model", &model)) {
                    SetShapeModel(shapeIndex, (pathName + model).c_str());
                }

                if (TextFileLoader.GetTokenString("sourceskin", &sourceSkin) &&
                    TextFileLoader.GetTokenString("targetskin", &targetSkin)) {
                    AppendShapeSkin(shapeIndex, 0, (pathName + sourceSkin).c_str(), (pathName + targetSkin).c_str());
                }

                TextFileLoader.SetParentNode();
                ++shapeDataIndex;
            }
        }

        TextFileLoader.SetParentNode();
    }

    if (TextFileLoader.SetChildNode("hairdata")) {
        std::string pathName;
        if (TextFileLoader.GetTokenString("pathname", &pathName)) {
            size_t hairDataIndex = 0;
            while (TextFileLoader.SetChildNode("hairdata", hairDataIndex)) {
                DWORD hairIndex;
                if (!TextFileLoader.GetTokenDoubleWord("hairindex", &hairIndex)) {
                    TextFileLoader.SetParentNode();
                    ++hairDataIndex;
                    continue;
                }

                std::string model, sourceSkin, targetSkin;
                if (TextFileLoader.GetTokenString("model", &model) &&
                    TextFileLoader.GetTokenString("sourceskin", &sourceSkin) &&
                    TextFileLoader.GetTokenString("targetskin", &targetSkin)) {
                    SetHairSkin(hairIndex, 0,
                        (pathName + model).c_str(),
                        (pathName + sourceSkin).c_str(),
                        (pathName + targetSkin).c_str());
                }

                TextFileLoader.SetParentNode();
                ++hairDataIndex;
            }
        }

        TextFileLoader.SetParentNode();
    }

    if (TextFileLoader.SetChildNode("attachingdata")) {
        if (!NRaceData::LoadAttachingData(TextFileLoader, &m_AttachingDataVector)) {
            return false;
        }
        TextFileLoader.SetParentNode();
    }

    return true;
}

 

I think that should be clear and understandable. I have tested it and it works without any problems

  • Metin2 Dev 1
  • muscle 1
  • Love 1
Link to comment
https://metin2.dev/topic/33390-c-race-msm-improvement/
Share on other sites

  • 4 weeks later...
  • Active+ Member
9 hours ago, yomidseven said:

Can you explain better please how can be replace msm way?

There's not really much to say about it, you don't have to increase the index when you add new armor or hair

Link to comment
https://metin2.dev/topic/33390-c-race-msm-improvement/#findComment-169384
Share on other sites

  • Active+ Member
13 hours ago, yomidseven said:

But if I set 999 in the msm is not the “same results”?

(obv more clean and professional)

I don't know if it gives the same result. So far I only know that you have to have it +1 we the actual index

Link to comment
https://metin2.dev/topic/33390-c-race-msm-improvement/#findComment-169389
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.