- Katılım
- 11 May 2023
- Konular
- 237
- Mesajlar
- 1,032
- Online süresi
- 1ay 23g
- Reaksiyon Skoru
- 678
- Altın Konu
- 1
- Başarım Puanı
- 176
- TM Yaşı
- 2 Yıl 11 Ay 14 Gün
- MmoLira
- 503
- DevLira
- 315
Metin2 EP, Valorant VP dahil tüm oyun ürünlerini en uygun fiyatlarla bulabilir, Item ve Karakterlerinizi hızlıca satabilirsiniz. HEMEN TIKLA!
örneğin.
ws turnuvasındasınız.
100 kişi kayıt oldu turnuva başladı.
ilk karşılaşacak sorun şu.
1.sürekli haritada ödürme ölme sonucu ışınlanma olacağı için cpu normalinden çok yükselicek.
2.aynı haritada içerisinde fazla ışınlanmadan ötürü clietn çöküp kapanıcak.bu seferde oyuncu ws turnuvasına katılamsı aşırı zorlanıcak.
burda yapılan düzelmede şöyle oluyor.
aynı harita içerisinde diyelim ışınlanma gerçekleşti.
böyle durumda oyuncu tekrardan loading ekranına dönüp ışınlanmıyor.
harita içerisinde yer değiştiriyor kordinatı değişiyor.
ikinci yapılan özellik
diyelim ch99 kanalındasınız ama ch1 kanalındna oyuncuyu yanınıza geticeksiniz.
bunun serbesti yokdu bu düzeltildi.
videoda daha iyi anlaşılıyor.
questlua_pc.cpp
cmd_gm.cpp
ws turnuvasındasınız.
100 kişi kayıt oldu turnuva başladı.
ilk karşılaşacak sorun şu.
1.sürekli haritada ödürme ölme sonucu ışınlanma olacağı için cpu normalinden çok yükselicek.
2.aynı haritada içerisinde fazla ışınlanmadan ötürü clietn çöküp kapanıcak.bu seferde oyuncu ws turnuvasına katılamsı aşırı zorlanıcak.
burda yapılan düzelmede şöyle oluyor.
aynı harita içerisinde diyelim ışınlanma gerçekleşti.
böyle durumda oyuncu tekrardan loading ekranına dönüp ışınlanmıyor.
harita içerisinde yer değiştiriyor kordinatı değişiyor.
ikinci yapılan özellik
diyelim ch99 kanalındasınız ama ch1 kanalındna oyuncuyu yanınıza geticeksiniz.
bunun serbesti yokdu bu düzeltildi.
videoda daha iyi anlaşılıyor.
questlua_pc.cpp
Kod:
ALUA(pc_teleport)
{
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
if (ch == nullptr) // C++20: nullptr kontrolü
return 0;
int x = 0, y = 0;
long targetMapIndex = 0; // Aynı harita kontrolü için hedef harita indeksi
if (lua_isnumber(L, 1))
{
const int TOWN_NUM = 10;
struct warp_by_town_name
{
const char* name;
DWORD x;
DWORD y;
} ws[TOWN_NUM] =
{
{"영안읍성", 4743, 9548},
{"임지곡", 3235, 9086},
{"자양현", 3531, 8829},
{"조안읍성", 638, 1664},
{"승룡곡", 1745, 1909},
{"복정현", 1455, 2400},
{"평무읍성", 9599, 2692},
{"방산곡", 8036, 2984},
{"박라현", 8639, 2460},
{"서한산", 4350, 2143},
};
int idx = static_cast<int>(lua_tonumber(L, 1)); // C++20: static_cast
// Güvenlik: Girilen index sınırı aşıyorsa sunucunun çökmesini engeller
if (idx < 0 || idx >= TOWN_NUM)
{
lua_pushnumber(L, 0);
return 1;
}
x = ws[idx].x * 100;
y = ws[idx].y * 100;
targetMapIndex = SECTREE_MANAGER::instance().GetMapIndex(x, y);
}
else if (lua_isstring(L, 1))
{
const char* arg1 = lua_tostring(L, 1);
LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(arg1);
if (tch == nullptr) // C++20: nullptr kontrolü
{
const CCI* pkCCI = P2P_MANAGER::instance().Find(arg1);
if (pkCCI != nullptr) // C++20: nullptr kontrolü
{
if (pkCCI->bChannel != g_bChannel)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Target is in %d channel (my channel %d)", pkCCI->bChannel, g_bChannel);
lua_pushnumber(L, 0);
return 1;
}
else
{
PIXEL_POSITION pos;
if (!SECTREE_MANAGER::instance().GetCenterPositionOfMap(pkCCI->lMapIndex, pos))
{
ch->ChatPacket(CHAT_TYPE_INFO, "Cannot find map (index %d)", pkCCI->lMapIndex);
lua_pushnumber(L, 0);
return 1;
}
x = pos.x;
y = pos.y;
targetMapIndex = pkCCI->lMapIndex;
}
}
else
{
ch->ChatPacket(CHAT_TYPE_INFO, "There is no one by that name");
lua_pushnumber(L, 0);
return 1;
}
}
else
{
// Orijinal kodda x = GetX() / 100 yapıp sonra x *= 100 yapılmıştı (gereksiz işlem).
// Direkt orijinal koordinatları alıyoruz.
x = tch->GetX();
y = tch->GetY();
targetMapIndex = tch->GetMapIndex();
}
}
else
{
lua_pushnumber(L, 0);
return 1;
}
ch->ChatPacket(CHAT_TYPE_INFO, "You warp to ( %d, %d )", x, y);
// AYNI HARİTA İÇİ YÜKLEME EKRANI (LOADING) BYPASS KONTROLÜ
if (targetMapIndex > 0 && ch->GetMapIndex() == targetMapIndex)
{
ch->Show(targetMapIndex, x, y, 0);
}
else
{
ch->WarpSet(x, y);
}
ch->Stop();
lua_pushnumber(L, 1);
return 1;
}
ALUA(pc_warp)
{
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
if (ch == nullptr) // C++20: nullptr kontrolü
return 0;
if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
{
lua_pushboolean(L, false);
return 1;
}
long map_index = 0;
if (lua_isnumber(L, 3))
map_index = static_cast<long>(lua_tonumber(L, 3)); // C++20: static_cast kullanımı
//PREVENT_HACK
if (ch->IsHack())
{
lua_pushboolean(L, false);
return 1;
}
//END_PREVENT_HACK
int x = static_cast<int>(lua_tonumber(L, 1));
int y = static_cast<int>(lua_tonumber(L, 2));
if (test_server)
ch->ChatPacket(CHAT_TYPE_INFO, "pc_warp %d %d %ld", x, y, map_index);
// Hedef harita indeksini belirliyoruz. Lua'dan girilmediyse (0 ise) global koordinattan buluyoruz.
long targetMapIndex = map_index;
if (targetMapIndex == 0)
targetMapIndex = SECTREE_MANAGER::instance().GetMapIndex(x, y);
// Aynı harita içi ışınlanma kontrolü (Yükleme ekranı olmadan)
if (targetMapIndex > 0 && ch->GetMapIndex() == targetMapIndex)
{
ch->Show(targetMapIndex, x, y, 0);
ch->Stop();
}
else
{
ch->WarpSet(x, y, map_index);
}
lua_pushboolean(L, true);
return 1;
}
ALUA(pc_warp_local)
{
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
if (ch == nullptr) // C++20: nullptr kontrolü
return 0;
if (!lua_isnumber(L, 1))
{
sys_err("no map index argument");
return 0;
}
if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3))
{
sys_err("no coodinate argument");
return 0;
}
long lMapIndex = static_cast<long>(lua_tonumber(L, 1));
const TMapRegion* region = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex);
if (region == nullptr) // C++20: nullptr kontrolü
{
sys_err("invalid map index %ld", lMapIndex);
return 0;
}
int x = static_cast<int>(lua_tonumber(L, 2));
int y = static_cast<int>(lua_tonumber(L, 3));
if (x > region->ex - region->sx)
{
sys_err("x coordinate overflow max: %d input: %d", region->ex - region->sx, x);
return 0;
}
if (y > region->ey - region->sy)
{
sys_err("y coordinate overflow max: %d input: %d", region->ey - region->sy, y);
return 0;
}
int global_x = region->sx + x;
int global_y = region->sy + y;
// Eğer oyuncu zaten questin gönderdiği hedeflenen haritadaysa yükleme ekranını atla
if (ch->GetMapIndex() == lMapIndex)
{
ch->Show(lMapIndex, global_x, global_y, 0);
ch->Stop();
}
else
{
ch->WarpSet(global_x, global_y);
}
return 0;
}
ALUA(pc_warp_exit)
{
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
if (ch != nullptr) // Güvenlik kontrolü eklendi
{
ch->ExitToSavedLocation();
}
return 0;
}
cmd_gm.cpp
Kod:
ACMD(do_goto)
{
char arg1[256], arg2[256];
int x = 0, y = 0, z = 0;
two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
if (!*arg1 && !*arg2)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Usage: goto <x meter> <y meter> or <mapname> [empire]");
return;
}
// E?er girilen argumanlar rakamsa (koordinat girildiyse)
if (isnhdigit(*arg1) && isnhdigit(*arg2))
{
str_to_number(x, arg1);
str_to_number(y, arg2);
PIXEL_POSITION p;
if (SECTREE_MANAGER::instance().GetMapBasePosition(ch->GetX(), ch->GetY(), p))
{
x += p.x / 100;
y += p.y / 100;
}
ch->ChatPacket(CHAT_TYPE_INFO, "You goto ( %d, %d )", x, y);
}
else // E?er girilen arguman harita isminden olu?uyorsa
{
int mapIndex = 0;
BYTE empire = 0;
if (*arg1 == '#')
str_to_number(mapIndex, (arg1 + 1));
if (*arg2 && isnhdigit(*arg2))
{
str_to_number(empire, arg2);
empire = MINMAX(1, empire, 3);
}
else
{
empire = ch->GetEmpire();
}
// Mantık Hatası Duzeltildi: E?er harita bulunamazsa (!false) hata versin.
if (!CHARACTER_GoToName(ch, empire, mapIndex, arg1))
{
ch->ChatPacket(CHAT_TYPE_INFO, "Cannot find map command syntax: /goto <mapname> [empire]");
}
return; // GoToName fonksiyonu i?ini bitirdi, devam etmesine gerek yok.
}
x *= 100;
y *= 100;
// Sadece koordinat (/goto x y) girildi?inde buraya ula?ır.
// Mevcut harita icerisinde yukleme ekranı olmadan (Show ile) ı?ınlar.
ch->Show(ch->GetMapIndex(), x, y, z);
ch->Stop();
}
ACMD(do_warp)
{
char arg1[256], arg2[256];
two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
if (!*arg1)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Usage: warp <character name> | <x meter> <y meter>");
return;
}
int x = 0, y = 0;
int targetMapIndex = 0;
if (isnhdigit(*arg1) && isnhdigit(*arg2))
{
str_to_number(x, arg1);
str_to_number(y, arg2);
targetMapIndex = SECTREE_MANAGER::instance().GetMapIndex(x * 100, y * 100);
}
else
{
LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(arg1);
if (tch == nullptr)
{
const CCI* pkCCI = P2P_MANAGER::instance().Find(arg1);
if (pkCCI != nullptr)
{
// KANAL KONTROLÜ KALDIRILDI: Farklı kanala warp atılabilir.
ch->ChatPacket(CHAT_TYPE_INFO, "Warping to %s on Channel %d...", arg1, pkCCI->bChannel);
ch->WarpToPID(pkCCI->dwPID);
return;
}
else
{
ch->ChatPacket(CHAT_TYPE_INFO, "There is no one(%s) by that name.", arg1);
return;
}
}
else
{
x = tch->GetX() / 100;
y = tch->GetY() / 100;
targetMapIndex = tch->GetMapIndex();
}
}
x *= 100;
y *= 100;
// Aynı haritadaysa loading ekranı bypass
if (targetMapIndex > 0 && ch->GetMapIndex() == targetMapIndex)
{
ch->Show(targetMapIndex, x, y, 0);
}
else
{
ch->WarpSet(x, y, targetMapIndex);
}
ch->Stop();
}
#ifdef ENABLE_NEWSTUFF
ACMD(do_rewarp)
{
ch->ChatPacket(CHAT_TYPE_INFO, "You warp to ( %d, %d )", ch->GetX(), ch->GetY());
// Zaten aynı haritada yenileniyor, direkt Show kullanıyoruz.
ch->Show(ch->GetMapIndex(), ch->GetX(), ch->GetY(), 0);
ch->Stop();
}
#endif
ACMD(do_transfer)
{
char arg1[256];
one_argument(argument, arg1, sizeof(arg1));
if (!*arg1)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Usage: transfer <name>");
return;
}
LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(arg1);
// Eğer oyuncu aynı çekirdekte/kanalda değilse P2P üzerinden ara
if (tch == nullptr)
{
CCI* pkCCI = P2P_MANAGER::instance().Find(arg1);
if (pkCCI != nullptr)
{
// KANAL KONTROLÜ KALDIRILDI: Artık farklı kanaldaysa da işlem yapacak.
TPacketGGTransfer pgg;
pgg.bHeader = HEADER_GG_TRANSFER;
strlcpy(pgg.szName, arg1, sizeof(pgg.szName));
pgg.lX = ch->GetX();
pgg.lY = ch->GetY();
P2P_MANAGER::instance().Send(&pgg, sizeof(TPacketGGTransfer));
ch->ChatPacket(CHAT_TYPE_INFO, "Transfer request sent to Channel %d.", pkCCI->bChannel);
}
else
{
ch->ChatPacket(CHAT_TYPE_INFO, "There is no character(%s) by that name.", arg1);
}
return;
}
if (ch == tch)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Transfer me?!?");
return;
}
// Aynı kanaldaki oyuncu için loading ekransız ışınlanma mantığı
tch->ChatPacket(CHAT_TYPE_INFO, "You were transferred by %s.", ch->GetName());
if (tch->GetMapIndex() == ch->GetMapIndex())
{
tch->Show(ch->GetMapIndex(), ch->GetX(), ch->GetY(), 0);
tch->Stop();
}
else
{
tch->WarpSet(ch->GetX(), ch->GetY(), ch->GetMapIndex());
}
}
Son düzenleme:


