Honorable Member Mali 41769 Posted December 16, 2022 Honorable Member Share Posted December 16, 2022 (edited) This is the hidden content, please Sign In or Sign Up From: 22.5.7.0 It includes a modification that changes the custom distance based on the map names. This is the hidden content, please Sign In or Sign Up Edited January 10, 2023 by Mali 109 1 1 21 4 81 Link to comment Share on other sites More sharing options...
Premium WeedHex 635 Posted December 17, 2022 Premium Share Posted December 17, 2022 I did it by myself time ago because so ugly in thight places the long zoom, stonks. Thanks for posting! 1 Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7174 Posted December 17, 2022 Honorable Member Share Posted December 17, 2022 (edited) #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 December 17, 2022 by martysama0134 4 1 1 Check out my GitHub Link to comment Share on other sites More sharing options...
Active Member ReFresh 2339 Posted December 17, 2022 Active Member Share Posted December 17, 2022 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 Sign In or Sign Up 22 4 1 5 I'll be always helpful! Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7174 Posted December 17, 2022 Honorable Member Share Posted December 17, 2022 6 minutes ago, ReFresh said: 'c_rstrMapFileName': redefinition Fixed. 1 Check out my GitHub Link to comment Share on other sites More sharing options...
Honorable Member Mali 41769 Posted December 17, 2022 Author Honorable Member Share Posted December 17, 2022 (edited) Let's increase the number of comments Edited March 12, 2023 by Mali 3 2 Link to comment Share on other sites More sharing options...
Deso 721 Posted December 19, 2022 Share Posted December 19, 2022 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(); } 3 Link to comment Share on other sites More sharing options...
Developer PACI 920 Posted December 19, 2022 Developer Share Posted December 19, 2022 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? 1 when you return 0 and server doesn't boot: Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7174 Posted December 19, 2022 Honorable Member Share Posted December 19, 2022 (edited) 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 December 19, 2022 by martysama0134 1 Check out my GitHub Link to comment Share on other sites More sharing options...
Contributor Amun 1898 Posted December 19, 2022 Contributor Share Posted December 19, 2022 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! Link to comment Share on other sites More sharing options...
Deso 721 Posted December 19, 2022 Share Posted December 19, 2022 Well it was a joke, i made use of a artificial intelligence. Dont take everything so serious. 1 Link to comment Share on other sites More sharing options...
Premium WeedHex 635 Posted December 19, 2022 Premium Share Posted December 19, 2022 1 minute ago, Deso said: Well it was a joke, i made use of a artificial intelligence. Dont take everything so serious. You know how used to say for the math... Link to comment Share on other sites More sharing options...
Recommended Posts