Jump to content

JSon Converter for Server Data Files


Recommended Posts

  • Silver

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 34
  • Eyes 1
  • Cry 1
  • Think 1
  • Scream 1
  • Lmao 1
  • Good 6
  • Love 14
Link to comment
Share on other sites

  • 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 24
  • Good 2
  • Love 8
Link to comment
Share on other sites

  • 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

 

Link to comment
Share on other sites

  • 5 months later...

Announcements



×
×
  • 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.