Jump to content

Recommended Posts

  • Honorable Member

This is the hidden content, please

This is the hidden content, please

It includes a modification that changes the custom max distance & position based on the map names

REQUIREMENTS:

Spoiler

 

 

Edited by Mali
  • Metin2 Dev 146
  • Eyes 1
  • Think 1
  • Good 28
  • Love 6
  • Love 100

 

Link to comment
https://metin2.dev/topic/30063-official-fix-camera-according-to-map-reversed/
Share on other sites

  • Honorable Member
#define ENABLE_CAMERA_ZOOM_OPTIMIZE
#ifdef ENABLE_CAMERA_ZOOM_OPTIMIZE
#include <unordered_map>
#endif

PyObject* appSetCameraMaxDistance(PyObject* poSelf, PyObject* poArgs)
{
	float fMax{};
	if (!PyTuple_GetFloat(poArgs, 0, &fMax))
		return Py_BuildException();

#ifdef ENABLE_CAMERA_ZOOM_OPTIMIZE
	static const std::unordered_map<std::string, float> mapCameraZoom = {
		{"metin2_map_n_flame_dragon", 6000.0f},
		{"metin2_12zi_stage", 5000.0f},
		{"metin2_map_defensewave", 5000.0f},
		{"metin2_map_miniboss_01", 5000.0f},
		{"metin2_map_miniboss_02", 5000.0f},
		{"metin2_map_mists_of_island", 5000.0f},
	};
	const std::string c_rstrMapFileName = CPythonBackground::Instance().GetWarpMapName();
	const auto it = mapCameraZoom.find(c_rstrMapFileName);
	if (it != mapCameraZoom.end())
		fMax = it->second;
#endif

	CCamera::SetCameraMaxDistance(fMax);
	return Py_BuildNone();
}

I slightly refactored it. Now it's O(1).

Edited by martysama0134
  • Metin2 Dev 6
  • Love 1
  • Love 1
  • Active+ Member

You can get this error: 'c_rstrMapFileName': redefinition; multiple initialization'

Just remove const std::string c_rstrMapFileName = CPythonBackground::Instance().GetWarpMapName(); in @ martysama0134 code it's defined twice.

This is the hidden content, please

  • Metin2 Dev 28
  • Good 6
  • Love 1
  • Love 5

I'll be always helpful!  😉

  • Active Member

 Here is my slightly refactored version.. ?

 

#include <unordered_map>

// Add a list of maps and their corresponding max distance values to a map.
// This allows us to look up the max distance value for a given map more efficiently than using a series of if statements.
std::unordered_map<std::string, float> mapMaxDistances = {
    {"metin2_map_n_flame_dragon", 6000.0f},
    {"metin2_12zi_stage", 5000.0f},
    {"metin2_map_defensewave", 5000.0f},
    {"metin2_map_miniboss_01", 5000.0f},
    {"metin2_map_miniboss_02", 5000.0f},
    {"metin2_map_mists_of_island", 5000.0f}
};

PyObject* appSetCameraMaxDistance(PyObject* poSelf, PyObject* poArgs)
{
    float fMax;
    if (!PyTuple_GetFloat(poArgs, 0, &fMax))
        return Py_BuildException();

    const std::string c_rstrMapFileName = CPythonBackground::Instance().GetWarpMapName();

    // Look up the max distance value for the current map in the mapMaxDistances map.
    // If the map is not found in the map, the max distance value will be the default value of 0.0f.
    fMax = mapMaxDistances[c_rstrMapFileName];

    CCamera::SetCameraMaxDistance(fMax);
    return Py_BuildNone();
}

 

  • Facepalm 3
  • Developer
13 minutes ago, Deso said:

 Here is my slightly refactored version.. ?

 

#include <unordered_map>

// Add a list of maps and their corresponding max distance values to a map.
// This allows us to look up the max distance value for a given map more efficiently than using a series of if statements.
std::unordered_map<std::string, float> mapMaxDistances = {
    {"metin2_map_n_flame_dragon", 6000.0f},
    {"metin2_12zi_stage", 5000.0f},
    {"metin2_map_defensewave", 5000.0f},
    {"metin2_map_miniboss_01", 5000.0f},
    {"metin2_map_miniboss_02", 5000.0f},
    {"metin2_map_mists_of_island", 5000.0f}
};

PyObject* appSetCameraMaxDistance(PyObject* poSelf, PyObject* poArgs)
{
    float fMax;
    if (!PyTuple_GetFloat(poArgs, 0, &fMax))
        return Py_BuildException();

    const std::string c_rstrMapFileName = CPythonBackground::Instance().GetWarpMapName();

    // Look up the max distance value for the current map in the mapMaxDistances map.
    // If the map is not found in the map, the max distance value will be the default value of 0.0f.
    fMax = mapMaxDistances[c_rstrMapFileName];

    CCamera::SetCameraMaxDistance(fMax);
    return Py_BuildNone();
}

 

Absolutely nonsense.
What's the point of passing fMax to define the camera max distance if it's replaced by 0?

  • kekw 1

when you return 0 and server doesn't boot:

unknown.png

  • Honorable Member
15 minutes ago, Deso said:
fMax = mapMaxDistances[c_rstrMapFileName];

If the key is missing, it will create a new entry inside the unordered_map. Any m2 map not in table will have a max distance of 0.f. 

Edited by martysama0134
  • kekw 1
  • Contributor
Spoiler

  

10 minutes ago, Deso said:

 Here is my slightly refactored version.. ?

 

#include <unordered_map>

// Add a list of maps and their corresponding max distance values to a map.
// This allows us to look up the max distance value for a given map more efficiently than using a series of if statements.
std::unordered_map<std::string, float> mapMaxDistances = {
    {"metin2_map_n_flame_dragon", 6000.0f},
    {"metin2_12zi_stage", 5000.0f},
    {"metin2_map_defensewave", 5000.0f},
    {"metin2_map_miniboss_01", 5000.0f},
    {"metin2_map_miniboss_02", 5000.0f},
    {"metin2_map_mists_of_island", 5000.0f}
};

PyObject* appSetCameraMaxDistance(PyObject* poSelf, PyObject* poArgs)
{
    float fMax;
    if (!PyTuple_GetFloat(poArgs, 0, &fMax))
        return Py_BuildException();

    const std::string c_rstrMapFileName = CPythonBackground::Instance().GetWarpMapName();

    // Look up the max distance value for the current map in the mapMaxDistances map.
    // If the map is not found in the map, the max distance value will be the default value of 0.0f.
    fMax = mapMaxDistances[c_rstrMapFileName];

    CCamera::SetCameraMaxDistance(fMax);
    return Py_BuildNone();
}

 

 

The fuck did you refactor?

 

Thanks, Mali!

  • 3 years later...

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.