- Katılım
- 6 Mayıs 2022
- Konular
- 48,264
- Mesajlar
- 48,574
- Tepkime puanı
- 74
- M2 Yaşı
- 3 yıl 11 ay 10 gün
- Trophy Puan
- 48
- M2 Yang
- 488,609
python için py kodları ve starter kodları :
CLIENT_PATH = r'E:\EGEMEKSERVER\Binary\Client\UserInterface'
SERVER_PATH = r'E:\EGEMEKSERVER\Srcs\Server\game\src'
çokta açıklamaya gerek yok bence ama dosya yollarını başlarında kendinize göre düzenleyiniz.
Game ile Client packetlerini kontrol eder nerede ne eksik fazla görmenizi sağlar, klasöre loglar.
Kod:
import os import re import logging # --- AYARLAR (Windows Yolları) --- CLIENT_PATH = r'E:\EGEMEKSERVER\Binary\Client\UserInterface' GAME_PATH = r'E:\EGEMEKSERVER\Srcs\Server\game\src' LOG_FILE = "paket_hatalari.log" # -------------------------------- # Loglama ayarları (Hem dosyaya hem konsola yazar) logging.basicConfig( level=logging.INFO, format='%(message)s', handlers=[ logging.FileHandler(LOG_FILE, encoding='utf-8'), logging.StreamHandler() ] ) def extract_packets(directory): packets = {} # Metin2 Paket yapılarını yakalamak için Regex struct_regex = re.compile(r'typedef\s+struct\s+(\w+)\s*\{(.*?)\}\s*(\w+);', re.DOTALL) if not os.path.exists(directory): logging.error(f"[HATA] Klasör bulunamadı: {directory}") return packets for root, dirs, files in os.walk(directory): for file in files: if file.endswith(('.h', '.cpp')): try: # Windows source dosyaları genelde ANSI/GBK veya UTF-8 olur with open(os.path.join(root, file), 'r', encoding='gbk', errors='ignore') as f: content = f.read() matches = struct_regex.findall(content) for match in matches: struct_name = match[0] body = match[1].strip() fields = [line.strip() for line in body.split(';') if line.strip()] packets[struct_name] = {"fields": fields, "file": file} except Exception as e: logging.error(f"Dosya okuma hatası ({file}): {e}") return packets def compare(): logging.info("="*70) logging.info(f" TARAMA BASLADI: {CLIENT_PATH} <-> {GAME_PATH}") logging.info("="*70 + "\n") client_pkts = extract_packets(CLIENT_PATH) game_pkts = extract_packets(GAME_PATH) all_structs = sorted(set(client_pkts.keys()).union(set(game_pkts.keys()))) error_count = 0 for struct in all_structs: # 1. Eksik Paket Kontrolü if struct not in client_pkts: logging.error(f"[EKSIK] '{struct}' -> Sadece GAME'de var. (Dosya: {game_pkts[struct]['file']})") error_count += 1 continue if struct not in game_pkts: logging.error(f"[EKSIK] '{struct}' -> Sadece CLIENT'ta var. (Dosya: {client_pkts[struct]['file']})") error_count += 1 continue # 2. Değişken Sayısı ve İçerik Kontrolü cf = client_pkts[struct]['fields'] gf = game_pkts[struct]['fields'] if len(cf) != len(gf): logging.error(f"[BOYUT FARKI] '{struct}'") logging.error(f" -> Client: {len(cf)} degisken | Game: {len(gf)} degisken") error_count += 1 else: # 3. Basit Sıralama Kontrolü for i in range(len(cf)): if cf[i].split()[-1] != gf[i].split()[-1]: logging.warning(f"[SIRALAMA/ISIM] '{struct}' icinde uyusmazlik!") logging.warning(f" -> Client: {cf[i]}") logging.warning(f" -> Game: {gf[i]}") error_count += 1 break logging.info("\n" + "="*70) if error_count == 0: logging.info("SONUC: Hic hata bulunmadi. Paketler tertemiz!") else: logging.info(f"SONUC: Toplam {error_count} adet hata/uyusmazlik loglandi.") logging.info("="*70) if __name__ == "__main__": compare()
Starter paket.
Kod:
@echo off title Metin2 Packet Checker color 0b python --version >nul 2>&1 if %errorlevel% neq 0 ( echo [HATA] Python bulunamadi! Lutfen Python yukleyin veya PATH'e ekleyin. pause exit ) echo ====================================================== echo METIN2 PAKET KONTROL BOTU BASLATILIYOR echo ====================================================== echo. python marker.py echo. echo ====================================================== echo Islem tamamlandi. Cikmak icin bir tusa basin. pause >nul
Metin2 Lobby olarak Metin2 Private Server dünyasında geliştirici dostu araçlar sunmaya devam ediyoruz. Bu makalede, Metin2 geliştiricilerinin en çok karşılaştığı sorunlardan biri olan packet hatalarını çözmeye yönelik kolaylaştırıcı uygulamalar hakkında bilgi vereceğiz.
Packet Hatası Nedir?
Metin2 sunucu geliştirme sürecinde, client[/BR] ile server[/BR] arasında veri alışverişinde packet adı verilen yapılar kullanılır. Bu yapılarda meydana gelen uyumsuzluklar, packet hatalarına neden olur. Bu hatalar genellikle disconnect, crash veya bozuk veri iletilmesine yol açar. C++ tabanlı game server veya auth server[/BR] yapılarında bu tür hatalar sıklıkla görülür.
Packet Hatalarının Nedenleri
1. Client[/BR] ve server[/BR] arasında packet header uyuşmazlığı
2. Python root veya uiscript dosyalarında hatalı veri tanımlaması
3. Martysama veya benzeri sistemlerde pack yapısı eksikliği
4. Source edit sırasında struct tanımlarında değişiklikler
Packet Hatalarını Tespit Etmede Kullanılabilecek Uygulamalar
1. Wireshark: Ağ trafiğini analiz etmenizi sağlar. Packet yapılarını detaylıca inceleyebilir, hataları tespit edebilirsiniz.
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
2. Metin2 Packet Logger: Özellikle Metin2 özel sunucuları için geliştirilmiş, paket akışını takip eden bir Python tabanlı uygulamadır. Py GUI arayüzü sayesinde kullanımı oldukça kolaydır.
3. Custom Packet Debugger: Geliştiricilerin kendi sistemlerine göre özelleştirebildiği, C++ ile yazılmış bir debug aracıdır. Game core veya db core ile entegre çalışabilir.
Packet Hatalarını Önlemek İçin Öneriler
- Server src ve client src[/BR] uyumuna dikkat edilmelidir.
- Compile işlemi öncesinde tüm header dosyaları kontrol edilmelidir.
- DB ve game[/BR] sunucuları senkronize edilmelidir.
- PVP sistem[/BR] geliştirmelerinde core[/BR] dosyalarında değişiklikler dikkatle yapılmalıdır.
Metin2 Lobby olarak, Metin2 development[/BR] konusunda aktif topluluk desteğimizi sürdürüyoruz. Daha fazla source edit[/BR] kaynağı, C++ script[/BR] örneği ve python system[/BR] için Metin2 Lobby adresini ziyaret edebilirsiniz.
Metin2 Lobby continues to provide developer-friendly tools in the Metin2 Private Server world. In this article, we will provide information about facilitating applications designed to solve one of the most common issues encountered by Metin2 developers: packet errors.
What is a Packet Error?
In the process of developing Metin2 servers, structures called packets are used for data exchange between the client[/BR] and server[/BR]. Mismatches in these structures can lead to packet errors. Such errors often cause disconnections, crashes[/BR], or transmission of corrupted data. These types of errors frequently occur in C++-based game servers[/BR] or auth servers[/BR].
Causes of Packet Errors
1. Mismatch in packet headers between client[/BR] and server[/BR]
2. Incorrect data definitions in Python root or uiscript files
3. Missing structure in pack creation with systems like Martysama
4. Modifications in struct definitions during source edits
Applications for Detecting Packet Errors
1. Wireshark: Allows you to analyze network traffic. You can examine packet structures in detail and detect errors.
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
2. Metin2 Packet Logger: A Python-based application specifically developed for Metin2 private servers to track packet flows. Its Py GUI interface makes it very user-friendly.
3. Custom Packet Debugger: A debugging tool written in C++ that can be customized according to developers' own systems. It can integrate with game cores or db cores.
Suggestions for Preventing Packet Errors
- Ensure compatibility between server src and client src[/BR].
- Check all header files before compilation.
- Synchronize DB and game[/BR] servers.
- Modifications in core[/BR] files during PVP system[/BR] development should be done carefully.
Metin2 Lobby continues to offer active community support on Metin2 development[/BR]. For more source edit[/BR] resources, C++ script[/BR] examples, and python systems[/BR], visit Metin2 Lobby.
