[C++] Metin2 Zemin bozulması fix

  • Konbuyu başlatan Konbuyu başlatan Admin
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 0
  • Görüntüleme Görüntüleme 44

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
136051_99bbe115eb32d339f52d27f8f5f8ca9c.png


Ctrl+Alt+Del Tuşlarına bastıktan sonra zemin bozuluyordu
bu değişiklik sayesinde artık bozulmuyacak :)

Kod:
// Arat void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice) // Komple Değiştir void CStateManager::SetDevice(LPDIRECT3DDEVICE8 lpDevice) {     StateManager_Assert(lpDevice);     lpDevice->AddRef();     if (m_lpD3DDev)     {         m_lpD3DDev->Release();         m_lpD3DDev = NULL;     }     m_lpD3DDev = lpDevice;     SetDefaultState(); } // Arat     SetPixelShaderConstant(0, av4Null, STATEMANAGER_MAX_PCONSTANTS);     m_bForce = false;     int i, j;     for (i = 0; i < STATEMANAGER_MAX_RENDERSTATES; i++)         m_bRenderStateSavingFlag[i] = FALSE;     for (j = 0; j < STATEMANAGER_MAX_TRANSFORMSTATES; j++)         m_bTransformSavingFlag[j] = FALSE;     for (j = 0; j < STATEMANAGER_MAX_STAGES; ++j)         for (i = 0; i < STATEMANAGER_MAX_TEXTURESTATES; ++i)             m_bTextureStageStateSavingFlag[j][i] = FALSE; // Altına Ekle     D3DCAPS8 d3dCaps;     m_lpD3DDev->GetDeviceCaps(&d3dCaps);     if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC)         m_dwBestMagFilter = D3DTEXF_ANISOTROPIC;     else         m_dwBestMagFilter = D3DTEXF_LINEAR;     if (d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC)         m_dwBestMinFilter = D3DTEXF_ANISOTROPIC;     else         m_dwBestMinFilter = D3DTEXF_LINEAR;     DWORD dwMax = d3dCaps.MaxAnisotropy;     dwMax = dwMax < 4 ? dwMax : 4;     for (int i = 0; i < 8; ++i)         m_lpD3DDev->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, dwMax);

Metin2 Zemin Bozulması Fix | C++ ile Oyun Temel Sorunları Çözümü


Metin2 özel sunucularında karşılaşılan yaygın sorunlardan birisi de 'zemin bozulması' problemidir. Bu sorun, oyuncuların bazı haritalarda ya da belirli bölgelerde zeminin doğru şekilde render edilmemesiyle ortaya çıkar. Bu durumda oyuncular zeminin altına düşebilir veya harita içinde garip boşluklar oluşabilir. Bu yazıda C++ tabanlı Metin2 sunucu kaynak kodlarında bu hatayı nasıl düzelteceğimizi detaylıca ele alacağız.

Zemin Bozulmasının Nedenleri
Metin2 özel sunucularda zemin bozulması genellikle şu nedenlerden dolayı meydana gelir:
- Eski veya eksik terrain dosyaları
- Sunucu ve istemci arasında senkronizasyon sorunları
- Render motorundaki hatalar
- Yanlış mesh yönetimi
- Terrain bilgilerinin hatalı yüklenmesi

C++ Kaynak Kodlarında Giderilebilecek Hatalar
Zemin bozulması sorunu, genellikle game core içinde yer alan terrain rendering kısmında meydana gelen hatalardan kaynaklanır. Bu sorunu çözmek için öncelikle terrain verilerinin nasıl işlendiğini anlamamız gerekir.

Öncelikle src/entry/terrain/ klasöründe yer alan Terrain.cpp dosyasını incelemekle başlayalım. Burada LoadTerrainData() fonksiyonu terrain dosyalarını yükler. Eğer bu fonksiyon eksik veya hatalı implement edilmişse, zemin verileri doğru okunamaz.

Fix Uygulaması
Aşağıdaki örnek, Terrain.cpp dosyasındaki temel bir düzeltmeyi göstermektedir:

Kod:
void LoadTerrainData(const char* fileName) { [BR][/BR]FILE* file = fopen(fileName, 'rb');[BR][/BR]if (!file) return;[BR][/BR][BR][/BR]fseek(file, 0, SEEK_END);[BR][/BR]int fileSize = ftell(file);[BR][/BR]rewind(file);[BR][/BR][BR][/BR]char* buffer = new char[fileSize];[BR][/BR]fread(buffer, 1, fileSize, file);[BR][/BR][BR][/BR]// Buffer'ı işle ve zemin verisini yükle[BR][/BR]ProcessTerrainBuffer(buffer, fileSize);[BR][/BR][BR][/BR]delete[*] buffer;[BR][/BR]fclose(file);[BR][/BR]}


Yukarıdaki kodda dikkat edilmesi gereken nokta, buffer'ın doğru şekilde işlenmesidir. Eğer buffer eksik okunursa ya da işlem hatası alınırsa zemin bozulabilir. Ayrıca, ProcessTerrainBuffer() fonksiyonu da güvenli bir şekilde yazılmalıdır.

İstemci Tarafında Kontroller
Sunucu tarafında düzeltme yapmanın yanında, istemci tarafında da bazı kontroller yapılmalıdır. Özellikle client root içindeki data/terrain/[/BR] klasöründe yer alan terrain dosyalarının doğru olduğundan emin olunmalıdır. Bu dosyaların pack içine alınırken hata yapılmadığından ve integrity kontrolünün sağlandığından emin olunmalıdır.

Derleme ve Test Aşaması
Değişiklikleri yaptıktan sonra kodu yeniden derlemek ve test etmek önemlidir. Metin2 compile işlemleri sırasında hata mesajlarını dikkatlice takip etmeliyiz. Compile sırasında herhangi bir uyarı varsa bu, runtime sırasında zemin bozulmasına sebep olabilir.

Sonuç
Metin2 özel sunucularında zemin bozulması gibi grafiksel sorunlar, hem kullanıcı deneyimini hem de sunucu kalitesini etkiler. Bu tür hatalar genellikle C++ seviyesinde çözülür ve game core üzerinde yapılan değişikliklerle engellenir. Bu makalede anlatılan adımları takip ederek zemin bozulması sorununu minimum seviyeye indirebilirsiniz. Daha fazla teknik destek ve C++ sistem çözümleri için Metin2Lobby'i takip etmeyi unutmayın.


Metin2 Ground Corruption Fix | Solving Basic Game Issues with C++


One of the common problems encountered in Metin2 private servers is 'ground corruption'. This issue occurs when the ground is not rendered correctly in certain maps or specific areas. In this situation, players may fall under the ground or gaps may appear within the map. In this article, we will detail how to fix this error in C++ based Metin2 server source codes.

Causes of Ground Corruption
Ground corruption in Metin2 private servers generally occurs due to the following reasons:
- Outdated or missing terrain files
- Synchronization issues between server and client
- Errors in the render engine
- Incorrect mesh management
- Faulty loading of terrain information

Errors That Can Be Fixed in C++ Source Code
Ground corruption often stems from errors occurring in the terrain rendering part located within the game core. To solve this issue, we first need to understand how terrain data is processed.

Let's start by examining the Terrain.cpp file located in the src/entry/terrain/ folder. The LoadTerrainData() function in this file loads the terrain files. If this function is implemented incompletely or incorrectly, terrain data cannot be read properly.

Applying the Fix
The following example shows a basic correction in the Terrain.cpp file:

Kod:
void LoadTerrainData(const char* fileName) { [BR][/BR]FILE* file = fopen(fileName, 'rb');[BR][/BR]if (!file) return;[BR][/BR][BR][/BR]fseek(file, 0, SEEK_END);[BR][/BR]int fileSize = ftell(file);[BR][/BR]rewind(file);[BR][/BR][BR][/BR]char* buffer = new char[fileSize];[BR][/BR]fread(buffer, 1, fileSize, file);[BR][/BR][BR][/BR]// Process buffer and load ground data[BR][/BR]ProcessTerrainBuffer(buffer, fileSize);[BR][/BR][BR][/BR]delete[*] buffer;[BR][/BR]fclose(file);[BR][/BR]}


The key point in the above code is the correct processing of the buffer. If the buffer is read incompletely or if a processing error occurs, the ground may corrupt. Additionally, the ProcessTerrainBuffer() function must also be written securely.

Client-Side Checks
In addition to fixing the issue on the server side, some checks should be performed on the client side as well. Especially, ensure that the terrain files located in the data/terrain/[/BR] folder within the client root are correct. Ensure that no errors occurred while packing these files into pack and that their integrity has been verified.

Compilation and Testing Phase
After making the changes, it's important to recompile and test the code. We must carefully monitor any error messages during the Metin2 compile process. Any warnings during compilation might cause ground corruption at runtime.

Conclusion
Graphical issues like ground corruption in Metin2 private servers affect both user experience and server quality. Such errors are typically resolved at the C++ level and can be prevented through modifications made to the game core. By following the steps outlined in this article, you can minimize ground corruption issues. For more technical support and C++ system solutions, don't forget to follow Metin2Lobby.
 

Şuan Bu Konuyu Görüntüleyen Kullanıcılar (Toplam : 0, Üye : 0, Misafir : 0)

Benzer konular

Geri
Üst Alt