Jump to content
Maintenance ×
×
×
  • Create New...

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.
Edited by martysama0134
updated vsimpl
  • Metin2 Dev 78
  • Eyes 2
  • Love 107
  • Love 7
  • Good 41
  • Lmao 1
  • Think 3
  • Confused 3
  • Angry 1
  • Dislove 1
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

@ѕ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

  • Moon

 

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.

why don't you do it ?

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

  • Moon

 

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.


  • Activity

    1. 1

      Metin2 TitleBar Move Frezze

    2. 1

      Metin2 TitleBar Move Frezze

    3. 0

      Navicat "Trial" Reset

    4. 13

      Item ToolTip Width Fix

    5. 0

      Guild icon wrong position

    6. 3

      Monster health

    7. 4

      Luffy Pet

    8. 38

      Core X → Top Metin2 & Metin2 Download → Changelogs

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.