Jump to content

CArea loading optimization


Recommended Posts

  • Honorable Member

Hello everyone,

I was optimizing the loading of maps for my server and I decided to share it with the public. With this modifications, only the objects and effects around the character will be loaded and it will handle their load and unload as you move around. Also effect updatings are optimized a way that closer effects are updated more frequently.

.gif

Okay, so let's start the work 😄

This is the hidden content, please

 

Good luck! 🙂

Edited by Distraught
  • Metin2 Dev 253
  • Eyes 6
  • Dislove 2
  • Not Good 1
  • Sad 1
  • Cry 1
  • Scream 4
  • Good 45
  • Love 13
  • Love 97

WRnRW3H.gif

Link to comment
Share on other sites

  • Honorable Member

Thank you guys ❤️

  

31 minutes ago, Ulthar said:

Thanks! ^^
Do we need to create the python part for ourselves? 😮

@ ASIKOO #honorablefordistraught

Yes, that's not included, it will use the clipping distance by default. You can play with the distance in CArea::GetMaxLoadingDistanceSqr.

Edited by Distraught

WRnRW3H.gif

Link to comment
Share on other sites

in CArea::__UpdateLoadedObjectInstances u have new func "emplace" and here it is not used value_type

				if ((*it)->dwType == prt::PROPERTY_TYPE_BUILDING)
					m_GraphicThingInstanceCRCMap.emplace(TGraphicThingInstanceCRCMap::value_type((*it)->pThingInstance, c_pObjectData->dwCRC));

 

like this:

				if ((*it)->dwType == prt::PROPERTY_TYPE_BUILDING)
					m_GraphicThingInstanceCRCMap.emplace((*it)->pThingInstance, c_pObjectData->dwCRC);
Link to comment
Share on other sites

  • 3 weeks later...
  • Premium
53 minutes ago, Jimmermania said:

Hello,i have this error when i compile, any ideas?
BUG

#include "StdAfx.h"

Be sure you didn't broke something in the #includes + in the Template declaration.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

16 hours ago, WeedHex said:
#include "StdAfx.h"

Be sure you didn't broke something in the #includes + in the Template declaration.

These are my includes in file Area.cpp:
 

#include "../eterLib/ResourceManager.h"
#include "../eterLib/StateManager.h"
#include "../effectLib/EffectManager.h"
#include "../SpeedTreeLib/SpeedTreeForestDirectX8.h"
#include "../eterBase/Timer.h"


#include "Area.h"
#include "PropertyManager.h"
#include "Property.h"

#include <boost/algorithm/string.hpp>
#ifdef CAREA_OPTIMIZATION
#include "StdAfx.h"
#include "../effectLib/EffectInstance.h"
#include "../UserInterface/PythonApplication.h"
#include "../UserInterface/StdAfx.h"
#include "../UserInterface/PythonCharacterManager.h"
#include "../UserInterface/PythonBackground.h"
#endif

 

Link to comment
Share on other sites

  • 1 month later...
  • Active Member
On 8/4/2022 at 6:17 PM, Ulthar said:

Thanks! ^^
Do we need to create the python part for ourselves? 😮

@ ASIKOO #honorablefordistraught

As far as I understand, to change the download area, you need to change the fFar value from the file PythonApplication.cpp (it is necessary to implement the possibility of changing this value from the settings inside the game)
This can be done by following the example of fNear (MIN_FOG)

  • Good 1
Link to comment
Share on other sites

  • Honorable Member

You just need to modify the return value of CArea::GetMaxLoadingDistanceSqr function, that's why I put this into a seperated function so it's easy to implement a slider.

For example interpolate between pfStart and pfFarClip. Just add a new option to CPythonSystem and a slider in python which sets its value and you can use the value of the sliderbar as it is (0.0-1.0).

float CArea::GetMaxLoadingDistanceSqr() const
{
	int peNum;
	float pfStart, pfEnd, pfFarClip;
	CPythonBackground::instance().GetDistanceSetInfo(&peNum, &pfStart, &pfEnd, &pfFarClip);

	// you need to get your value for exmaple from CPythonSystem or from whenever you want
	float fRatio = CPythonSystem::instance().GetLoadingDistance();

	// use one of the interpolation functions i provided
	return LinearInterpolation(pfStart * pfStart, pfFarClip * pfFarClip, fRatio);
}

 

Edited by Distraught
  • Love 3

WRnRW3H.gif

Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...
  • 1 month later...
On 4/16/2023 at 7:00 PM, Gurgarath said:

update your sources

i have same problem, but for dump_proto when i try to compile it!

error C2146: syntax error : missing ';' before identifier 'T'
_src\client\gamelib\../eterBase/Utils.h(223): error C2146: syntax error : missing ';' before identifier 'LinearInterpolation'
_src\client\gamelib\../eterBase/Utils.h(223): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
_src\client\gamelib\../eterBase/Utils.h(223): error C2143: syntax error : missing ',' before '&'
_src\client\gamelib\../eterBase/Utils.h(226): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
_src\client\gamelib\../eterBase/Utils.h(229): error C2146: syntax error : missing ';' before identifier 'T'
src\client\gamelib\../eterBase/Utils.h(229): error C2146: syntax error : missing ';' before identifier 'HermiteInterpolation'
_src\client\gamelib\../eterBase/Utils.h(229): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
_src\client\gamelib\../eterBase/Utils.h(229): error C2143: syntax error : missing ',' before '&'
_src\client\gamelib\../eterBase/Utils.h(234): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

 

 

Utils.h

#include "../UserInterface/Locale_inc.h"
#ifdef ENABLE_MAP_OBJECT_OPTIMIZATION
template<typename T>
constexpr T LinearInterpolation(const T& tMin, const T& tMax, float fRatio)
{
    return T((1.0f - fRatio) * tMin + fRatio * tMax);
}

template<typename T>
constexpr T HermiteInterpolation(const T& tMin, const T& tMax, float fRatio)
{
    fRatio = MINMAX(0.0f, fRatio, 1.0f);
    fRatio = fRatio * fRatio * (3.0f - 2.0f * fRatio);
    return LinearInterpolation(tMin, tMax, fRatio);
}
#endif

Edited by Hornet
Link to comment
Share on other sites

  • Forum Moderator
21 hours ago, Hornet said:

i have same problem, but for dump_proto when i try to compile it!

error C2146: syntax error : missing ';' before identifier 'T'
_src\client\gamelib\../eterBase/Utils.h(223): error C2146: syntax error : missing ';' before identifier 'LinearInterpolation'
_src\client\gamelib\../eterBase/Utils.h(223): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
_src\client\gamelib\../eterBase/Utils.h(223): error C2143: syntax error : missing ',' before '&'
_src\client\gamelib\../eterBase/Utils.h(226): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
_src\client\gamelib\../eterBase/Utils.h(229): error C2146: syntax error : missing ';' before identifier 'T'
src\client\gamelib\../eterBase/Utils.h(229): error C2146: syntax error : missing ';' before identifier 'HermiteInterpolation'
_src\client\gamelib\../eterBase/Utils.h(229): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
_src\client\gamelib\../eterBase/Utils.h(229): error C2143: syntax error : missing ',' before '&'
_src\client\gamelib\../eterBase/Utils.h(234): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

 

 

Utils.h

#include "../UserInterface/Locale_inc.h"
#ifdef ENABLE_MAP_OBJECT_OPTIMIZATION
template<typename T>
constexpr T LinearInterpolation(const T& tMin, const T& tMax, float fRatio)
{
    return T((1.0f - fRatio) * tMin + fRatio * tMax);
}

template<typename T>
constexpr T HermiteInterpolation(const T& tMin, const T& tMax, float fRatio)
{
    fRatio = MINMAX(0.0f, fRatio, 1.0f);
    fRatio = fRatio * fRatio * (3.0f - 2.0f * fRatio);
    return LinearInterpolation(tMin, tMax, fRatio);
}
#endif

You quoted the solution to tell me the problem. Update your sources, simple as, use C++14/17>

Gurgarath
coming soon

Link to comment
Share on other sites

Announcements



  • Similar Content

  • Similar Content

  • Similar Content

  • Tags

  • Activity

    1. 3

      Crystal Metinstone

    2. 3

      Feeding game source to LLM

    3. 113

      Ulthar SF V2 (TMP4 Base)

    4. 3

      Feeding game source to LLM

    5. 0

      Target Information System

    6. 3

      Feeding game source to LLM

    7. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.