
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.
Python:
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.
bat:
@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


