Jump to content

Takuma

Developer
  • Posts

    23
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Takuma

  1.  

    2 hours ago, DeYaN. said:

    up

    It's been years since I touched Metin2. You're using the pc.count_item function, right?
    If so, try to look in the questlua_pc (I don't remember the name exactly), and look at the count_item method.

    Try to see what it refer to.. It seems to me it's CountSpecifyItem. Did you modify the INVENTORY_MAX_NUM constant?
    Show us this function if it is used, we might be able to help you...

  2. Maybe I'm going to ask a stupid question, but if the hash function hasn't been changed, why not directly use the MySQL PASSWORD() function?

    $sql = "INSERT INTO account (login, password, social_id, email) VALUES (?, PASSWORD(?), ?, ?)";
        $stmt = $pdo1->prepare($sql);
        $stmt->execute([$login, $password, $social_id, $email]);

    PASSWORD('123456789') give you *CC67043C7BCFF5EEA5566BD9B1F3C74FD9A5CF5D.

     

    Edit :  or this if you're on MySQL 8 (ty Gurgarath)

    CONCAT('*', UPPER(SHA1(UNHEX(SHA1(?)))));

    or

    -- not tested
    CREATE FUNCTION PASSWORD(input VARCHAR(255)) RETURNS CHAR(41)
    BEGIN
        DECLARE output CHAR(41);
        SET output = CONCAT('*', UPPER(SHA1(UNHEX(SHA1(input)))));
        RETURN output;
    END;

     

  3. Hi!

    Thanks for sharing. I have a couple of questions:

    • Why use a JSON file when the bonuses are already stored in the database?
    • Why pull all the data from PHP and then process it?

    I believe it would be more efficient (and maybe better for your learning ? if you're trying to) to try joining the item and item_attr tables to perform this processing entirely in the database. Then, you could simply retrieve the result to display it.

  4. 5 hours ago, Kio said:

    Yes, the messenger manager system is a complete disgrace. Because a database query is made with every teleportation. and there are many other nonsense topics. If we use the player ID, you will still have to send a database query every time you teleport. Because imagine a player on the disabled list leaves the game. But you need to write the player's name on that list, you cannot do this with the id because it is not in the game. You will need to pull it with a database query. The reason why I don't use id is to avoid making database queries for every player in every teleport.

    Actually,  what I was saying is that you can do all the queries with the player name at the source level and your DBMS will store IDs for it. You just have to adapt a little bit the queries in your player_block.cpp.

    Example to insert new line in the  player_block_list table : 

    INSERT INTO player_bloc_list (id1, id2)
    SELECT p1.id, p2.id
    FROM player p1
    JOIN player p2 ON p1.name = 'Kio' AND p2.name = 'Takuma';

    Same way for select etc..

    By doing this, indeed, you add an additional join during insertion (though considering the capabilities of the DBMS compared to the current Metin2 servers, it may be negligible). However, on the other hand, storing IDs is easier, and it aligns a bit more with standards.

  5. 1 hour ago, Kio said:

    Hey dude <3, 

    While coding the system, I was coding it with id but

    .png

    When I started coding the block list, it occurred to me that not every player I blocked would always be in the game.

    Now let's come to the scenarios I would experience if I coded with id.

    * I send the list packet when the player teleports. If the blocked player is not in the game, I cannot write their name there. However, if I only saved the id in memory and saved the player's name along with the id in the database, then I would send the packet of the list by pulling it from the database, not from memory. But I didn't want to use the database every time a player teleported. Additionally, if you change a player name, I will need to correct it in the database.

    * If a player I want to unblock is not in the game, I will have to query the player table with the player's name in the database and get his id

    In short, I did not use id because I wanted to minimize database usage. Can it be used? Yes, it can be used, but with 2-3 database queries.

    When I write systems, I always write them in a way that high-player games can use and I think very carefully. That's why it made more sense to me to code it this way, so I preferred to code it with names.

    I don't use name changing in my own active game, so I didn't feel the need to do it. But if you use it, just do this 🙂

    // Open player_block.h
    // Search:
    
    	auto DeletePlayerBlock(const std::string &strBlockingPlayerName, const std::string &strBlockedPlayerName) -> void;
    
    // Add below:
    
    	auto ChangeName(const std::string &strOldName, const std::string &strNewName) -> void;
    
    // Open player_block.cpp
    // Search:
    
    auto CPlayerBlock::DeletePlayerBlock(const std::string &strBlockingPlayerName, const std::string &strBlockedPlayerName) -> void
    {
    	DBManager::Instance().DirectQuery("DELETE FROM player.player_block_list WHERE blockingplayername = '%s' AND blockedplayername = '%s'", strBlockingPlayerName.c_str(), strBlockedPlayerName.c_str());
    }
    
    // Add below:
    
    auto CPlayerBlock::ChangeName(const std::string &strOldName, const std::string &strNewName) -> void
    {
    	auto it = m_map_PlayerBlock.find(strOldName);
    	if (it != m_map_PlayerBlock.end())
    	{
    		m_map_PlayerBlock[strNewName] = std::move(it->second);
    		m_map_PlayerBlock.erase(it);
    	}
    
    	for (auto &it : m_map_PlayerBlock)
    	{
    		auto it2 = it.second.find(strOldName);
    		if (it2 != it.second.end())
    		{
    			it.second.erase(it2);
    			it.second.emplace(strNewName);
    		}
    	}
    
    	DBManager::Instance().DirectQuery("UPDATE player.player_block_list SET blockingplayername = '%s' WHERE blockingplayername = '%s'", strNewName.c_str(), strOldName.c_str());
    	DBManager::Instance().DirectQuery("UPDATE player.player_block_list SET blockedplayername = '%s' WHERE blockedplayername = '%s'", strNewName.c_str(), strOldName.c_str());
    
    	sys_log(0, "PLAYER_BLOCK: ChangeName: %s -> %s", strOldName.c_str(), strNewName.c_str());
    }
    
    // Open questlua_pc.cpp
    
    // Add includes:
    
    #ifdef ENABLE_PLAYER_BLOCK_SYSTEM
    #include "player_block.h"
    #endif
    
    // Search:
    
    		/* delete messenger list */
    		MessengerManager::instance().RemoveAllList(ch->GetName());
    
    // Add below:
    
    #ifdef ENABLE_PLAYER_BLOCK_SYSTEM
    		/* player block list */
    		CPlayerBlock::Instance().ChangeName(ch->GetName(), szName);
    #endif

    Actually, I don't understand the problem. You can store the id very well, but still ask your DBMS to return the player name to you without creating new queries. This takes up less space, it ensures that you don't keep data that doesn't correspond to anything, etc.

    Gurgarath told me that friends management was a real disaster. And I think we don't have to start again on this bad basis. You can keep your internal operation with loading the nicknames into memory (for displaying the list), but store the IDs in the database. You just need to change your queries (not adding new queries) to support it

     

     

     

     

  6. Hey!

    Thanks for sharing.

    Why store in database player name and not foreign keys on player IDs? As these are direct queries it could made them lighter a little no? There may be a constraint that I don't understand.

    This can even be problematic for servers where you can change your player name.

     

     

    • Love 1
    • Love 3
  7. Just a few details... Because when addressing beginners (the target audience for this post), it's important to lay a solid foundation:

    Quote

    Generally, the logic used in all programming is the same, what changes is the syntax.

    No. It depends on the paradigm.

    Quote

    C++ is an independent language but it comes from C, but many functions in C++ are exactly the same as C.

    It should be emphasized that the entirety of C is supported in C++. In fact, C++ is just an extensions of C with a vast number of libraries.

    Quote

    Note: This was a personal choice! You don't need to learn C to learn C++, and if someone told you that, get away from them because it's a lie.

    Well, then I am a liar. Not learning C to understand what C++ does under the hood is like saying you know how a car works because when you turn the key, it starts.

    And in terms of courses (for English spearks), I also recommend https://www.learncpp.com. It's comprehensive and well-explained. 

  8. My opinion is that I didn't even know about the ast module; I've never really had the opportunity to use it. I'll be back to work on Monday and will be less available. However, if you find that this improvement is beneficial and necessary, I invite you to make a pull request on GitHub so that you can be directly listed as a contributor.

    As soon as I have some time, I'll study the matter. Thank you!

    • Metin2 Dev 1
    • Good 1
  9. Hi devs ! I was getting bored during my vacation, so i had to keep myself occupied...

    At the request of @ Gurgarath :3, I created a small Python script that allows you to clean up unused lines from your locale_game.txt and locale_interface.txt. It is coded with Python 3.11, compatibility with earlier versions is not guaranteed. It also uses the chardet module, which is specified in the requirements.txt. For any additional information (such as the How To), please refer to the README.md.

     This script currently does not support imports like import LocaleInfo as li. It also does not support dynamically constructing variable names. It only detects raw constants like localeInfo.MY_CONSTANT.

     

    Downloads :

    This is the hidden content, please

    Find this tool on my Github or

    This is the hidden content, please

     

    Exemple of output :

    Quote

    > python main.py

    Reading locale/locale_game.txt...
    Reading locale/locale_interface.txt...

    Reading source/uicommon.py
        -> Found 4 constants for localeInfo
        -> Found 1 constants for uiScriptLocale

    Writing new files...
    Writing locale/new_locale_game.txt...
    Writing locale/new_locale_interface.txt...

    Ended ! Enjoy you new cleaned files ! 🙂

     

    Takuma.

     

    • Metin2 Dev 37
    • Good 11
    • Love 3
    • Love 11
  10. 3 hours ago, msnas said:

    I found something interesting.

    The tool is only checking if Pi_InitModule starts as a PyObject's variable.
    However, there are some files that aren't being initialized in that way - 14 to be exact:

    6596a8b2cc806aa54c2d3f836a350ba0.png7095949cac34b57eaf0a2e696921ab5f.png733bcc18bf420eec814c35eb6d90fecb.png

     

    The solution would be to remove/comment this line:
    ffdfdc2f4aae619d3d080972d984543a.png

     

    And voilá, files like PythonDebugModule.cpp are being called correctly:
    11cdb0243d339d7e263616d4f74befe8.png
    8242fe080a591f7cf72a0d5246b5fac1.png

    Hi. I'm a little bit busy now. Could you maybe make a pull request on github ? I'll check this. 

     

    Thanks you ! 

    • Love 1
  11. I cannot edit my subject, so... I'll write the changes here.

    Now you no longer need to use bin and src folders mandatorily.

    This is the hidden content, please

    Please, read README.md file to know how to use the script. A example of use could be :

    Quote

    python main.py -s src -o bin

    to use src and bin folders as before.

    Thank to NewWars ❤️

     

    • Metin2 Dev 4
    • Good 1
    • Love 2
  12. Hi devs !

    So, I just pushed a commit. It's a an uptdate :

    • I refactored all the code (not in only one file);
    • Tools can know support many modules in same file;
    • Some parameters, such as the use of the snake_case for the arguments, can be configured in the CONSTANTS.py file

    No modification to use the script. Do as before.

     

    (Sorry for my bad english)

     

    Takuma.

    • Metin2 Dev 2
    • Good 1
    • Love 3
  13. On 11/13/2021 at 2:39 PM, msnas said:

    After trying it out on atom and pycharm, I decided to use it on VS Code.

    However, there's a problem with the sintax from the pylance (built-in with the python extension):

    spacer.png

    This is because the functions are set as NoReturn and pylance doesn't like that, that's why the code seems unreachable.

     

    In order to fix this, you need to change the type NoReturn to None:

    spacer.png

    You can do it by changing all the files after the manipulation or change the 

    Hidden Content

    • Give reaction to this post to see the hidden content.

    .

     

     

    Thank you for the release, everything is working as expected!

     

    Thanks for the feedback. I update the repo, sorry for be late !
    I also add you to Thanks part in README.MD, I can put your GitHub profile if you want.

    I was wrong on the NoReturn, it is actually intended for a code that exits the program (Source).
     

    Takuma.

    • Love 2
  14. Hey ! Sorry, i'm late, but I just tought about it because I'm upgradding my client to Py3. I think you fourgot something (And I have one in my system.py).

    In python2 you can specifie a numeric type for numer like :

    my_numeric = 0L

    But it is no longer supported in Python3, and we need juse use :

    my_numeric = 0

    Same with 0j.

    (Source: PEP 237)

    • Metin2 Dev 4
    • Love 1
  15. 2 hours ago, Mali61 said:

    Thank you, it's working great ❤️

     

    You can add these two modules(EterPythonLib)

      Hide contents

    yrtqWv0.png

    yCJ2bQw.png

    Aoy6hJ8.png

    wudbZZk.png

     

     

    Hi ! 

    Thanks for your feedback !

    I added the two functions. I did as they took an int as parameter. I will think about how to properly model these objects in Python automatically.

    • Love 1
  16. Hi !

    Use Python3 with the client can be very interesting.. For use UTF-8 everywhere for example (Unicode...). i tried to do this before, but my client crashed when I created empty tuple... xd if someone want share a client with Python3.. I take it  !

     

     

    I just specify that i updated the code for two errors that were reported to me :

    • Tuple in return;
    • GetWindow() method.

     

     

    • Love 1
  17. 1 hour ago, VegaS™ said:

     Sorry, you understood it wrong, maybe my bad.

    I talked about general stuff, tools, not crap metin2 or about porting it to py3, doesn't have any relevance with what I said. 

    Was all about that in the last years I didn't saw any public tool coded in py3 well, just py2 and that's really sad when you look at py3 release date: 03-Dec-2008.
    Those tools don't have anything related to metin2 code, that's why I told those things.

    It's like still using full C++98 after 20 years in your tools when you've no limits and C++2x is here.

     

    @TakumaA good feature would be a detailed documentation for functions, like this

     

    I've already thought about converting the docstrings, but I don't know the sources well enough to comment everything... But when I have some time I will do the docstrings converter.

     

    Thanks for the idea ! 

     

    I will add the method to use venv with Visual Studio Code too. Added.

     

     

    • Love 1
  18. M2 Download Center

    This is the hidden content, please
    ( Internal )

    This is the hidden content, please
    ( GitHub )

    Hi !

     

    First: sorry. My code is not clean, I am not a developer or anything, I am just a math student. I am just trying to do my best. And my skills in English are… non-existent. So, be nice please.

     

    Using very often PyCharm, I wanted to be able to use it on Metin2, but PyCharm (or another IDE) hit me hard with baseball bat because he could not find the modules.

    So, I have made this tool to create module’s python skeleton and use autocompletion with IDE. The biggest flaw is that you must have Python3 installed on your machine to use typing.

     

    Example of result with PyCharm:

    205724result-example.png

     

    And you can't find an exemple of output here.

     

     

    To follow this tutorial, you must have:

    • Python3 (i'm using Python3.8)
    • PyCharm or other IDE, but in this tutorial, I will use PyCharm (from JetBrains).
    • This is the hidden content, please
      .

     

     

     

     

    I – Generate your module skeleton.

    You can find just upper, a link to download my script. It is easy to use. You can find all the manipulations in README.md file, but I will explain it here too:

    • Move all your client’s .cpp file (with module) in src folder.
    • Just use now main.py with Python3 (I developed it with Python3.8)

    You will see many files in bin folder.

     

     

    II – Make a virtual environment of Python3 for IDEs

    We will have to create a virtual environment for our IDEs to do not dirty our real Python installation. To do that, you can use the command :

     

    python3 -m venv /path/to/new/virtual/environment

     

    Find all information on the doc : https://docs.python.org/3/library/venv.html

     

    I will show you how to do that with PyCharm:

    Spoiler

     

    1. Open your pack folder with PyCharm, you will have something like this :
      201037Capture-d-ecran-2021-01-20-163730.
    2. Now, we have to create a new virtual environment of Python. For this, click on the button at the bottom right of PyCharm to select an interpreter, and choose Add interpreter:
      201231Image1.png
    3. Configure now a new virtual environment with Python3x as base intrepreter and create it. You will have something like that:
      201358Capture-d-ecran-2021-01-20-165314.

     

     

     

     

    And with Visual Studo Code:

    Spoiler

     

    You must have Python extension. You can get it in the MarketPlace, and create your venv with command.

    1. Open your pack folder with Visual Studio Code and save it as a Workspace.
      211238image-2021-01-21-001218.png
    2. In this Workspace, on Visual Studio Code Press : Ctrl + Alt + P.
    3. Select Python: Select Interpreter:
      211554Capture-d-ecran-2021-01-21-001535.
    4. Specify that it's for the Entire WorkSpace:
      211659image-2021-01-21-001657.png
    5. Select after Enter interpreter path...:
      212011image-2021-01-21-002010.png
    6. After, Find... and go search python.exe in venv folder (venv/Script/python.exe).

    And it's done. Congratulation.

     

     

     

    III - Add our skeletons to virtualenv

    For that, you just must move all your .py file in bin folder to venv/Lib/site-packages. Example :

    201556Capture-d-ecran-2021-01-20-214039.

    This manipulation is a little dirty ... But I couldn't find anything better so as not to have too much change to make. If you have a better one, I take...

     

    Don't forget to configure your IDE to use new virtualenv.

     

     

    IV - Known issues:

    • Script cannot predict value of the constants;
    • It does not yed manage structures of this type:

    202028unknown.png

     

    V - Debug:

    • Script now support Tuple in functions' returns;
    • Add the method GetWindow for arguments.

     

    With using Python3 IDE, he will consider print without parentheses and except bloc as error...

     

    Thanks to @Gurgarath for his help ❤️ 

     

     

    This is the hidden content, please

     

    Takuma.

    • Metin2 Dev 52
    • Dislove 2
    • Think 1
    • Good 3
    • Love 3
    • Love 29
×
×
  • 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.