Jump to content

Recommended Posts

  • Active+ Member

M2 Download Center

This is the hidden content, please
( Internal )

Hello, I started to convert some server data files from .txt to .json. I intend to convert them more understandable and modern with these changes, also few bugs and a memory leak in the old system has been fixed. Currently only mob_drop_info.txt file is translated, then all .txt files and proto files will be added.

 

Tutorial for mob_drop_info.txt game part:

Add to service.h:

#define ENABLE_JSON_GAME_FILES

Add to stl.h

inline std::wstring StringToWstring(std::string input)
{
    std::wstring output(input.begin(), input.end());
    return output;
}
inline std::string WstringToString(std::wstring input)
{
    std::string output(input.begin(), input.end());
    return output;
}

Search in input_db.cpp

"%s/mob_drop_item.txt", LocaleService_GetBasePath().c_str());

Change with:

#ifdef ENABLE_JSON_GAME_FILES
			"%s/mob_drop_item.json", LocaleService_GetBasePath().c_str());
#else
			"%s/mob_drop_item.txt", LocaleService_GetBasePath().c_str());
#endif

Search:

	if (!ITEM_MANAGER::instance().ReadMonsterDropItemGroup(szMOBDropItemFileName))

Change with:

#ifdef ENABLE_JSON_GAME_FILES
	if (!ITEM_MANAGER::instance().ReadMonsterDropItemGroupNew(szMOBDropItemFileName))
#else
	if (!ITEM_MANAGER::instance().ReadMonsterDropItemGroup(szMOBDropItemFileName))
#endif

Search in item_manager.h:

		bool			ReadDropItemGroup(const char * c_pszFileName);

Add it under:

#ifdef ENABLE_JSON_GAME_FILES
		bool			ReadMonsterDropItemGroupNew(const char * c_pszFileName);
#endif

Add in item_manager_read_tables.cpp

#ifdef ENABLE_JSON_GAME_FILES
#include <fstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#endif

Search:

bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName)

Change like this:

https://metin2.download/picture/rVSWiLGFIy5Xn4vbEi02wIdrId8btawD/.png

Codes:

This is the hidden content, please

 

Converter:

This is the hidden content, please

 

Note:

You need c ++ 11 and boost property tree module to use this configuration.

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 41
  • Eyes 1
  • Cry 1
  • Think 1
  • Scream 1
  • Lmao 1
  • Good 10
  • Love 21
Link to comment
https://metin2.dev/topic/20836-json-converter-for-server-data-files/
Share on other sites

  • Active+ Member

I used boost because it's already required dependecy from game server and I didn't want to add a new dependency for such a simple change., I'm sure there are more lightweight and simple alternatives here but I don't understand one thing, what's wrong with boost?

  • Love 1
  • Honorable Member
4 hours ago, Koray said:

what's wrong with boost?

Boost PropertyTree is not a json library (but it uses internally one). It drops tons of functionality from the JSON format. I also think it treats integers as strings. It's 20 times slower than the most used json libraries.

Its implementation looks very oldish. It's basically legacy code in its utmost definition.

Also, with the new c++ standards, many boost functionality can be replaced quite easily. Boost remains a bloatware for small projects, so I try to avoid it when possible.

As for other alternatives, these two are header-only (easily to implement/copy-paste on Extern/include/ or from "pkg install") and much more beautiful:

 

  • Metin2 Dev 32
  • Good 4
  • Love 10
  • 5 months later...
  • Honorable Member
1 hour ago, Tallywa said:

Bump

use cmake gui(https://cmake.org/download/) and convert. Example visual studio. Then download boost(https://www.boost.org/users/history/version_1_71_0.html) for windows and copy to M2TxtToJson-master\3rd\modular-boost. Then build https://gofile.io/?c=Bl2wQm

  • Metin2 Dev 1

 

  • 5 months 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.