Jump to content

How To Metin2 & Cython


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

Intro

This release will explain how to "convert" your root .py files to .c ones.

Actually, Cython only converts those files to pure CPython code.

 

Download

 

As requested by many people, you can download the compatible and clean official cn root dated 20131228-0034 without further edits:

 

Is Cython really worth it?

  • Pros
    • All the modules are compiled, and they can't be "extracted as .py" anymore.

      We can always disassemble the launcher with IDA, but the result will be pseudo-c code after waiting 6-8h of analyzing.

    • Since we're not using .pyx files but directly .py ones, there's no "so much optimization".

      At least, 10% of performance increasing is guaranteed.

  • Cons
    • For testing purposes, it's heavy to maintain. Everytime you try to re-compile your root files, you should wait 5-10 minutes.

      You can always use the uncythonized root (.py files) when you perform tests, and compile cython whenever you will make an update in your live server.

    • The launcher's size will increase ~10mb. You can actually pack it to save space.

      If you directly use a .pyd (still 10mb), the launcher's size won't increase.

 

VideoTutorial

Credits

  • Me (lollo_9_1/martysama0134)
  • Night (OST suggestion)
  • Random Testers

 

What's New:

  • vsimpl
    • Visual studio implementation
    • automatic cythonization when compiling
    • only the edited files will be compiled
  • v2.0
    • The module's name check is now case-insensitive (colorInfo == colorinfo)
    • Added a new function rootlib/uiscriptlib.getList() to retrieve a tuple of all the available cythonized modules.
    • Now you can compile a uiscriptlib library from the uiscript*.py files! (implemented as __USE_EXTRA_CYTHON__)
    • Added a sample ui.py containing the code to run uiscriptlib.
  • Metin2 Dev 198
  • kekw 2
  • Eyes 4
  • Dislove 1
  • Angry 1
  • Cry 1
  • Think 2
  • Confused 4
  • Lmao 1
  • Good 72
  • Love 13
  • Love 168
Link to comment
Share on other sites

  • Bronze

Thanks, but  i think you should put a guide of how to repair the errors give the *.py files when you are cythonicing, a lot of people cant use the system if dont know how repair it. <-- this is not going for me, I know how to fix it.

Only to increase the information in the post.

Link to comment
Share on other sites

Absolutely worth a like.

Well, I think this is a good start for everybody who wants to start protecting his client a bit more and probably event get some more performance out of the client.

Based on this tutorial, everybody who knows c++ can go further and try things like removing the pack-module (or at least modifying it) or do some other fancy stuff :P

So again: Great tutorial! I'd be way too lazy to spend that much effort in something like doing tutorials but its great to see that others do.

Keep up the good work.

@ѕeмa™:

Don't you think that you should let at least a small part of work up to the people? Everybody who is capable of reading at least a bit english or even just using a translator should be able to read the error messaged and thus be able to fix them.

It's really not that hard.

Link to comment
Share on other sites

  • Bronze

@ѕeмa™:

Don't you think that you should let at least a small part of work up to the people? Everybody who is capable of reading at least a bit english or even just using a translator should be able to read the error messaged and thus be able to fix them.

It's really not that hard.

yep, you have right xd

Link to comment
Share on other sites

  • Honorable Member

Thanks, but i think you should put a guide of how to repair the errors give the *.py files when you are cythonicing, a lot of people cant use the system if dont know how repair it. <-- this is not going for me, I know how to fix it.

Only to increase the information in the post.

The only two errors you could get when you compile your root are:
  • "Decoding error, missing or incorrect coding"

    Since all the .py files are processed as korean strings, all of them written with a different charset (arabic) will trigger this issue.

    It's explained in the .txt file, and you can simply bypass this just writing the text in the locale_game.txt file.

  • "Expected an increase in indentation level"

    This happens when the .py file has a bad tabulation, so bad written:

    It's clear that you won't be able to compile unworkable/unrunnable/broken .py files.

  • Love 8
Link to comment
Share on other sites

  • Bronze

 

Thanks, but i think you should put a guide of how to repair the errors give the *.py files when you are cythonicing, a lot of people cant use the system if dont know how repair it. <-- this is not going for me, I know how to fix it.

Only to increase the information in the post.

The only two errors you could get when you compile your root are:
  • "Decoding error, missing or incorrect coding"

    Since all the .py files are processed as korean strings, all of them written with a different charset (arabic) will trigger this issue.

    It's explained in the .txt file, and you can simply bypass this just writing the text in the locale_game.txt file.

  • "Expected an increase in indentation level"

    This happens when the .py file has a bad tabulation, so bad written:

    It's clear that you won't be able to compile unworkable/unrunnable/broken .py files.

 

i rarely do something like that but some encoding error happened , well ppl should use what was made for such a thing (localeinfo/uiscriptlocale)

+ nice tuto

and thanks for the Credits ahah

  • Love 1
Link to comment
Share on other sites

  • Honorable Member

Maybe a stupid question, but can you cythonize all the python files of the client? I mean really each py file, including every script :)

The script as "it is", right now, creates a "rootlib" module. There are tons of way to do what you asked. (at least, 10 ways)

The easier one to do so, using cython, would be making a "uiscriptlib" library, and re-writing the Sandbox.execfile method inside the utils.py file.

Link to comment
Share on other sites

  • Premium

I have a problem.I follow this steps:

 

-Copy all your root*.py files into the .MainRootLib folder

 

-Copy python.exe, RootLibCythonizer.bat, and RootLibCythonizer.py from .Main into the .MainRootLib folder

 

-Run .MainRootLibRootLibCythonizer.bat ----at this step I have a problem

 

Can someone help me please?

 

1111111.png

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

  • Honorable Member

When I run the MakeFile_VC_Release.bat file, I get the following errors:

'cl' is not recognized as an internal or external command, operable program or batch file.
'lib' is not recognized as an internal or external command, operable program or batch file.

It's simple: it happens when the visual studio path is not specified in the %PATH% environment variable.

You have few solutions:

  • Add the visual studio path in the %PATH% environment variable. (I won't suggest it)
  • Add something like this at the beginning of the MakeFile_VC_Release.bat file and run it as administrator: (easy way)

    call "C:Program Files (x86)Microsoft Visual Studio 10.0VCvcvarsall.bat"
  • You should run as admininistrator the Visual Studio Command Prompt (2010)" and then recall the .bat from there. (highly preferable)
NB: I've used vs2010, but it works without any problems with any vs version. Edited by martysama0134
Link to comment
Share on other sites

  • Honorable Member

I can compile a few files from the root or all files is needed?

If you use the files as "they are", only system.py and prototype.py are required.

If the module you want to include is not present in the rootlib one, the client will try to open the relative <modulename>.py file.

  • Love 1
Link to comment
Share on other sites

  • Honorable Member

Hi, marty. When cythonized, is there still need dynamic linking e.g: python27.dll or library files?

Yes, the python27.dll, and the lib folder are still required.

You can now develop an interesting hash check of these files in the __hybrid_import function inside system.py.

Link to comment
Share on other sites

Announcements



  • Similar Content

  • Similar Content

  • Similar Content

  • Tags

  • Activity

    1. 4

      [Discussion] Rain - The First Person that leaked the M2 Files

    2. 4

      [Discussion] Rain - The First Person that leaked the M2 Files

    3. 0

      [Client] All tabs opening after quest/npc talk or even shop // PORTS

    4. 0

      Arrow does not hide at warp

    5. 0

      Problem with sidebar by vegas

    6. 58

      Discord Rich Presence

    7. 145

      Full Costume Mount System

    8. 3

      Memory allocation for beginner

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