Neler yeni

Foruma hoş geldin, Ziyaretçi

Metin2Lobby.com Metin2 Private Server Tanıtım Advertising Ve Geliştirme Forumudur.Metin2 pvp serverler,1-99,1-105,1-120,55-120 global serverları paylaş yada ara.
Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

[C++]Python file loader

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Konular
48,291
Mesajlar
48,601
Tepkime puanı
75
M2 Yaşı
3 yıl 11 ay 10 gün
Trophy Puan
48
Konum
Web sitesi
M2 Yang
488,879
Ticaret : 1 / 0 / 0
Ticaret Oranı : 100%
Merhabalar,

Bazı serverlarda python loader engellendiği için küçük bir loader yaptım.
Mantık basittir, yükleyeceğiniz py dosyasını load.py(default) ismiyle oyunun olduğu klasöre atıp verdiğim dll dosyasını inject edin

869047149219f306422366dec9d4c6e6.gif


Dll;
Proje;

Dll-Virustotal;
Proje-Virustotal;
C++ ile Python Dosya Yükleme Sistemi

Giriş
Metin2 özel sunucu geliştirme sürecinde, geliştiriciler genellikle C++ ve Python dillerini bir arada kullanırlar. Özellikle oyun motorunun çekirdek sistemi C++ tabanlıdır, ancak GUI ve bazı dinamik işlemler Python ile kolayca yönetilebilir. Bu bağlamda, C++ üzerinden Python dosyalarını yüklemek ve çalıştırmak büyük bir esneklik sağlar. Bu yazıda, C++ ile Python dosya yükleyici sistemini detaylı olarak inceleyeceğiz.

Python API ile Entegrasyon
Python, C++ ile entegre edilebilmesi için güçlü bir API sunar. Bu API sayesinde C++ projelerinizde Python komutlarını çalıştırabilir, modüller yükleyebilir ve veri alışverişinde bulunabilirsiniz. Bu süreçte öncelikle Python yorumlayıcısı başlatılır. Ardından belirtilen Python dosyası C++ tarafında çalıştırılır.

Python Ortamının Kurulması
Python yükleme işlemi için Python geliştirme kütüphanelerinin sisteminize kurulmuş olması gerekir. Windows ortamında bu kütüphaneler Python kurulumu sırasında otomatik gelmeyebilir. Bu durumda Python Developer Pack veya benzeri ekstra kütüphaneleri manuel olarak indirmeniz gerekebilir. Linux sistemlerde ise genellikle 'python-dev' veya 'python3-dev' paketi ile bu kütüphaneler sağlanır.

Py_Initialize() Fonksiyonu
Python yorumlayıcısını başlatmak için C++ tarafında Py_Initialize() fonksiyonu kullanılır. Bu fonksiyon Python sanal makinesini başlatır ve Python kodlarının çalıştırılmasını sağlar. PyRun_SimpleFile veya PyRun_File fonksiyonları yardımıyla Python dosyaları doğrudan çalıştırılabilir.

Hata Yönetimi
Python dosyalarının çalıştırılması sırasında oluşabilecek hataların yakalanması önemlidir. PyErr_Occurred() fonksiyonu ile Python tarafından oluşturulan hatalar tespit edilebilir. Bu sayede sistemsel hata mesajları loglanabilir ve kullanıcı dostu hata bildirimleri yapılabilir.

Python Modül Yükleme
Python dosyaları modül olarak da yüklenebilir. PyImport_ImportModule fonksiyonu ile Python modülü belleğe alınır ve PyModule_GetAttrString fonksiyonu ile modül içi fonksiyonlara erişim sağlanabilir. Bu yöntem özellikle belirli Python fonksiyonlarını C++ kodu içinde doğrudan çalıştırmak istediğinizde oldukça faydalıdır.

Metin2 Geliştirme Bağlamında Kullanımı
Metin2 özel sunucularında, GUI sistemleri genellikle Python (UIScript) ile oluşturulur. Bu sistemde, C++ backend kısmında Python GUI dosyaları yüklenerek oyun içi arayüzler oluşturulabilir. Örneğin, item tooltip'leri, menü sistemleri veya özel UI komponentleri Python ile tasarlanıp C++ tarafında çalıştırılabilir. Bu sayede hem performans hem de esneklik kazanılır.

Örnek Kod Yapısı
Basit bir Python dosya yükleyici sınıfı oluşturmak için önce Python.h kütüphanesini projeye dahil etmelisiniz. Ardından Py_Initialize() ile yorumlayıcıyı başlatıp PyRun_File ile dosya okuma işlemi yapabilirsiniz. Dosya başarıyla okunursa Py_Finalize() ile işlem sonlandırılmalıdır.

Sonuç
C++ ile Python dosya yükleme sistemi, Metin2 gibi oyun geliştirme projelerinde çok yönlü kullanım imkanı sunar. Doğru yapılandırıldığında hem backend performansı hem de frontend esnekliği artırılır. Bu yapı, geliştiricilere modern ve modüler sistemler kurma imkanı tanır.


C++ Python File Loader System

Introduction
In the process of developing Metin2 private servers, developers often use both C++ and Python languages together. The core system of the game engine is based on C++, but GUI and some dynamic operations can be easily managed with Python. In this context, loading and executing Python files through C++ provides great flexibility. In this article, we will examine the C++ Python file loader system in detail.

Integration with Python API
Python offers a powerful API that allows integration with C++. Thanks to this API, you can execute Python commands within your C++ projects, load modules, and exchange data. In this process, the Python interpreter is initialized first. Then, the specified Python file is executed from the C++ side.

Setting Up the Python Environment
To implement Python loading, you must have the Python development libraries installed on your system. On Windows, these libraries may not come automatically during the Python installation. In such cases, you may need to manually download additional libraries like Python Developer Pack. On Linux systems, these libraries are usually provided via packages such as 'python-dev' or 'python3-dev'.

Py_Initialize() Function
The Py_Initialize() function is used to start the Python interpreter in C++. This function initializes the Python virtual machine and allows Python code to be executed. Python files can be directly run using functions like PyRun_SimpleFile or PyRun_File.

Error Handling
It is important to catch errors that might occur during the execution of Python files. The PyErr_Occurred() function detects errors generated by Python. This allows system error messages to be logged and user-friendly error notifications to be created.

Loading Python Modules
Python files can also be loaded as modules. With the PyImport_ImportModule function, a Python module is loaded into memory, and access to functions inside the module can be achieved using PyModule_GetAttrString. This method is particularly useful when you want to run specific Python functions directly within your C++ code.

Usage in the Context of Metin2 Development
In Metin2 private servers, GUI systems are generally built with Python (UIScript). In this system, Python GUI files can be loaded via C++ to create in-game interfaces. For example, item tooltips, menu systems, or custom UI components can be designed in Python and executed on the C++ side. This approach enhances both performance and flexibility.

Sample Code Structure
To create a simple Python file loader class, you should first include the Python.h library in your project. Then initialize the interpreter with Py_Initialize() and read the file using PyRun_File. If the file is successfully read, the process should be finalized with Py_Finalize().

Conclusion
The C++ Python file loading system offers versatile usage opportunities in game development projects like Metin2. When configured correctly, it enhances both backend performance and frontend flexibility. This structure provides developers with the opportunity to build modern and modular systems.
 

Forumdan daha fazla yararlanmak için giriş yapın yada üye olun!

Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!

Kaydol

Forumda bir hesap oluşturmak tamamen ücretsizdir.

Üye ol
Giriş Yap

Eğer bir hesabınız var ise lütfen giriş yapın

Giriş Yap

Tema düzenleyici

Tema özelletirmeleri