Selamlar. Turkmmo Server Files Projesi #1'de kullanılan kanal değiştirme sistemini sizlerle paylaşmak istiyorum.
[CODE lang="cpp" title="common\service.h"]//müsait bir yere ekleyin;
#define ENABLE_CHANNEL_SWITCH_SYSTEM[/CODE]
[CODE lang="cpp" title="common\tables.h"]//aratın;
HEADER_GD_AUTH_LOGIN = 100,
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
HEADER_GD_FIND_CHANNEL = 99,
#endif
//tekrar aratın;
HEADER_DG_MAP_LOCATIONS = 0xfe,
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
HEADER_DG_CHANNEL_RESULT = 184,
#endif
//tekrar aratın;
typedef struct SChannelStatus
{
[...]
} TChannelStatus;
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
typedef struct
{
long lMapIndex;
int channel;
} TPacketChangeChannel;
typedef struct
{
long lAddr;
WORD port;
} TPacketReturnChannel;
#endif[/CODE]
[CODE lang="cpp" title="db\src\ClientManager.cpp"]//aratın;
default:
sys_err("Unknown header (header: %d handle: %d length: %d)", header, dwHandle, dwLength);
break;
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
case HEADER_GD_FIND_CHANNEL:
FindChannel(peer, dwHandle, (TPacketChangeChannel*)data);
break;
#endif
//dosyanın sonuna ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void CClientManager::FindChannel(CPeer* requestPeer, DWORD dwHandle, TPacketChangeChannel* p)
{
if (!p->lMapIndex || !p->channel)
return;
long lAddr = 0;
WORD port = 0;
for (const auto peer : m_peerList)
{
if (peer->GetChannel() != p->channel)
continue;
TMapLocation kMapLocation;
thecore_memcpy(kMapLocation.alMaps, peer->GetMaps(), sizeof(kMapLocation.alMaps));
for (const auto midx : kMapLocation.alMaps)
{
if (midx == p->lMapIndex)
{
char host[16];
strlcpy(host, peer->GetPublicIP(), sizeof(kMapLocation.szHost));
lAddr = inet_addr(host);
port = peer->GetListenPort();
break;
}
}
if (lAddr && port)
break;
}
TPacketReturnChannel r;
r.lAddr = lAddr;
r.port = port;
requestPeer->EncodeHeader(HEADER_DG_CHANNEL_RESULT, dwHandle, sizeof(r));
requestPeer->Encode(&r, sizeof(r));
}
#endif[/CODE]
[CODE lang="cpp" title="db\src\ClientManager.h"]//aratın;
void WeddingEnd(TPacketWeddingEnd* p);
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void FindChannel(CPeer* pkPeer, DWORD dwHandle, TPacketChangeChannel* p);
#endif[/CODE]
[CODE lang="cpp" title="game\src\char.cpp"]//dosyanın sonuna ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
bool CHARACTER::SwitchChannel(long newAddr, WORD newPort)
{
if (!IsPC() || !GetDesc() || !CanWarp())
return false;
long x = GetX();
long y = GetY();
long lAddr = newAddr;
long lMapIndex = GetMapIndex();
WORD wPort = newPort;
if (lMapIndex >= 10000)
{
sys_err("Invalid change channel request from dungeon %d!", lMapIndex);
return false;
}
if (g_bChannel == 99)
{
sys_err("%s attempted to change channel from CH99, ignoring req.", GetName());
return false;
}
Stop();
Save();
if (GetSectree())
{
GetSectree()->RemoveEntity(this);
ViewCleanup();
EncodeRemovePacket(this);
}
m_lWarpMapIndex = lMapIndex;
m_posWarp.x = x;
m_posWarp.y = y;
sys_log(0, "ChangeChannel %s, %ld %ld map %ld to port %d", GetName(), x, y, GetMapIndex(), wPort);
TPacketGCWarp p;
p.bHeader = HEADER_GC_WARP;
p.lX = x;
p.lY = y;
p.lAddr = lAddr;
p.wPort = wPort;
GetDesc()->Packet(&p, sizeof(p));
char buf[256];
snprintf(buf, sizeof(buf), "%s Port%d Map%ld x%ld y%ld", GetName(), wPort, GetMapIndex(), x, y);
LogManager::instance().CharLog(this, 0, "CHANGE_CH", buf);
return true;
}
EVENTINFO(switch_channel_info)
{
DynamicCharacterPtr ch;
int secs;
long newAddr;
WORD newPort;
switch_channel_info()
: ch(),
secs(0),
newAddr(0),
newPort(0)
{
}
};
EVENTFUNC(switch_channel)
{
switch_channel_info* info = dynamic_cast<switch_channel_info*>(event->info);
if (!info)
{
sys_err("No switch channel event info!");
return 0;
}
LPCHARACTER ch = info->ch;
if (!ch)
{
sys_err("No char to work on for the switch.");
return 0;
}
if (!ch->GetDesc())
return 0;
if (info->secs > 0)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel switch in %d seconds."), info->secs);
--info->secs;
return PASSES_PER_SEC(1);
}
ch->SwitchChannel(info->newAddr, info->newPort);
ch->m_pkTimedEvent = NULL;
return 0;
}
bool CHARACTER::StartChannelSwitch(long newAddr, WORD newPort)
{
if (IsHack(false, true, 10))
return false;
switch_channel_info* info = AllocEventInfo<switch_channel_info>();
info->ch = this;
info->secs = CanWarp() && !IsPosition(POS_FIGHTING) ? 3 : 10;
info->newAddr = newAddr;
info->newPort = newPort;
m_pkTimedEvent = event_create(switch_channel, info, 1);
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel switch starting."));
return true;
}
#endif[/CODE]
[CODE lang="cpp" title="game\src\char.h"]//aratın;
int GetSyncHackCount() { return m_iSyncHackCount; }
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
public:
bool SwitchChannel(long newAddr, WORD newPort);
bool StartChannelSwitch(long newAddr, WORD newPort);
#endif[/CODE]
[CODE lang="cpp" title="game\src\cmd.cpp"]//aratın;
ACMD(do_duel);
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
ACMD(do_change_channel);
#endif
//tekrar aratın;
{ "duel", do_duel, 0, POS_DEAD, GM_LOW_WIZARD },
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
{ "channel", do_change_channel, 0, POS_DEAD, GM_PLAYER },
#endif[/CODE]
[CODE lang="cpp" title="game\src\cmd_general.cpp"]//dosyanın sonuna ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
ACMD(do_change_channel)
{
if (!ch)
return;
if (ch->m_pkTimedEvent)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ae¨ùO ¥ìC¨úu¨öA¢¥I¢¥U."));
event_cancel(&ch->m_pkTimedEvent);
return;
}
char arg1[256];
one_argument(argument, arg1, sizeof(arg1));
if (!*arg1)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Usage: channel <new channel>"));
return;
}
short channel;
str_to_number(channel, arg1);
if (channel < 0 || channel > 6)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Please enter a valid channel."));
return;
}
if (channel == g_bChannel)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are already on channel %d."), g_bChannel);
return;
}
if (g_bChannel == 99)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The map you are at is cross-channel, changing won't have any effect."));
return;
}
if (ch->GetDungeon())
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot change channel while in a dungeon."));
return;
}
TPacketChangeChannel p;
p.channel = channel;
p.lMapIndex = ch->GetMapIndex();
db_clientdesc->DBPacket(HEADER_GD_FIND_CHANNEL, ch->GetDesc()->GetHandle(), &p, sizeof(p));
}
#endif[/CODE]
[CODE lang="cpp" title="game\src\input.h"]//aratın;
void RespondChannelStatus(LPDESC desc, const char* pcData);
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void ChangeChannel(LPDESC desc, const char* pcData);
#endif[/CODE]
[CODE lang="cpp" title="game\src\input_db.cpp"]//aratın;
bool GetServerLocation(TAccountTable& rTab, BYTE bEmpire)
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void CInputDB::ChangeChannel(LPDESC d, const char* pcData)
{
if (!d || !d->GetCharacter())
{
sys_err("Change channel request with empty or invalid description handle!");
return;
}
TPacketReturnChannel* p = (TPacketReturnChannel*)pcData;
if (!p->lAddr || !p->port)
{
std::string pName = d->GetCharacter()->GetName();
d->GetCharacter()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("CANNOT_CHANGE_CHANNEL"));
sys_err("Can't switch channel for player %s!", pName.c_str());
return;
}
d->GetCharacter()->StartChannelSwitch(p->lAddr, p->port);
}
#endif
//tekrar aratın;
default:
return (-1);
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
case HEADER_DG_CHANNEL_RESULT:
ChangeChannel(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData);
break;
#endif[/CODE]
[CODE lang="cpp" title="UserInterface\Locale_inc.h"]//müsait bir yere ekleyin;
#define ENABLE_CHANNEL_SWITCH_SYSTEM[/CODE]
[CODE lang="cpp" title="UserInterface\PythonApplicationModule.cpp"]//aratın;
#ifdef ENABLE_COSTUME_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_COSTUME_SYSTEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_COSTUME_SYSTEM", 0);
#endif
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_CHANNEL_SWITCH_SYSTEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_CHANNEL_SWITCH_SYSTEM", 0);
#endif[/CODE]
[CODE lang="python" title="root\constinfo.py"]#müsait bir yere ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
channel_idx = 0[/CODE]
[CODE lang="python" title="root\uisystem.py"]#aratın;
self.gameOptionDlg = None
#altına ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
self.moveChannelDlg = None
#tekrar aratın;
self.GetChild("cancel_button").SAFE_SetEvent(self.Close)
#altına ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
self.GetChild("movechannel_button").SAFE_SetEvent(self.__ClickMoveChannelButton)
#tekrar aratın;
self.GetChild("cancel_button").SAFE_SetEvent(self.Close)
#altına ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
self.GetChild("movechannel_button").SAFE_SetEvent(self.__ClickMoveChannelButton)
#tekrar aratın;
def OnPressExitKey(self):
#üstüne ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
def __ClickMoveChannelButton(self):
self.Close()
if self.moveChannelDlg:
self.moveChannelDlg.Show()
else:
moveChannelDlg = MoveChannelDialog()
moveChannelDlg.Show()
self.moveChannelDlg = moveChannelDlg
#dosyanın sonuna ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
class MoveChannelDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadDialog()
self.StartChannelNumber = 0
self.IsShow = False
def __del__(self):
ui.ScriptWindow.__del__(self)
def __LoadDialog(self) :
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/MoveChannelDialog.py")
except:
import exception as exception
exception.Abort("MoveChannelDialog.__LoadDialog")
self.ParentBoard = self.GetChild("MoveChannelBoard")
self.ChildBoard = self.GetChild("BlackBoard")
self.GetChild("MoveChannelTitle").SetCloseEvent(ui.__mem_func__(self.Close))
self.ChannelList = []
cnt = 5
cnt = cnt - 1
self.DlgWidht = 190
self.BlackBoardHeight = 23*cnt + 5*(cnt-1) + 13
self.DlgHeight = self.BlackBoardHeight + 75
self.AcceptBtn = ui.MakeButton(self.ParentBoard, 13, self.DlgHeight - 33, "", "d:/ymir work/ui/public/", "acceptbutton00.sub", "acceptbutton01.sub", "acceptbutton02.sub")
# self.AcceptBtn.SetText( localeInfo.MOVE_CHANNEL_SELECT )
self.AcceptBtn.SetEvent(ui.__mem_func__(self.AcceptButton))
self.CloseBtn = ui.MakeButton(self.ParentBoard, self.DlgWidht - 73, self.DlgHeight - 33, "", "d:/ymir work/ui/public/", "canclebutton00.sub", "canclebutton01.sub", "canclebutton02.sub")
# self.CloseBtn.SetText( localeInfo.MOVE_CHANNEL_CANCEL )
self.CloseBtn.SetEvent(ui.__mem_func__(self.Close))
for i in xrange(cnt):
btn = ui.MakeButton(self.ChildBoard, 8, 6 + i*28, "", "d:/ymir work/ui/game/myshop_deco/", "select_btn_01.sub", "select_btn_02.sub", "select_btn_03.sub")
btn.SetText("Kanal {0}".format(int(i+1)))
btn.SetEvent(ui.__mem_func__(self.__SelectChannel), i+1)
self.ChannelList.append(btn)
self.ParentBoard.SetSize(self.DlgWidht, self.DlgHeight)
self.ChildBoard.SetSize(self.DlgWidht - 26, self.BlackBoardHeight)
self.SetSize(self.DlgWidht, self.DlgHeight)
self.UpdateRect()
def __SelectChannel(self, idx):
self.ChangeChannelNumber = idx
for btn in self.ChannelList:
btn.SetUp()
btn.Enable()
self.ChannelList[idx-1].Down()
self.ChannelList[idx-1].Disable()
def AcceptButton(self):
if self.ChangeChannelNumber == self.StartChannelNumber:
return
net.SendChatPacket("/channel " + str(self.ChangeChannelNumber))
self.Close()
def Show(self) :
ui.ScriptWindow.Show(self)
self.StartChannelNumber = constInfo.channel_idx
self.__SelectChannel(self.StartChannelNumber)
self.IsShow = True
def Close(self):
self.Hide()
self.IsShow = False
def OnPressEscapeKey(self):
self.Close()
return True
def IsShowWindow(self):
return self.IsShow[/CODE]
[CODE lang="python" title="uiscript\systemdialog.py"]#aratın;
"y" : (SCREEN_HEIGHT - 298) /2,
#değiştirin;
"y" : (SCREEN_HEIGHT - 328) /2,
#tekrar aratın;
"height" : 298,
#değiştirin;
"height" : 328,
#tekrar aratın;
"height" : 298,
#değiştirin;
"height" : 328,
#tekrar aratın;
{
"name" : "game_option_button",
"type" : "button",
"x" : 10,
"y" : 117,
"text" : uiScriptLocale.GAMEOPTION_TITLE,
"default_image" : ROOT + "XLarge_Button_01.sub",
"over_image" : ROOT + "XLarge_Button_02.sub",
"down_image" : ROOT + "XLarge_Button_03.sub",
},
#altına ekleyin;
# if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
{
"name" : "movechannel_button",
"type" : "button",
"x" : 10,
"y" : 147,#Esc menüsündeki konumunu buradan ayarlamanız gerekecek.
"text" : uiScriptLocale.SYSTEM_MOVE_CHANNEL,
"default_image" : ROOT + "XLarge_Button_01.sub",
"over_image" : ROOT + "XLarge_Button_02.sub",
"down_image" : ROOT + "XLarge_Button_03.sub",
},[/CODE]
[CODE title="locale_game.txt"]MOVE_CHANNEL_TITLE Kanal Seçimi
MOVE_CHANNEL_SELECT Tamam
MOVE_CHANNEL_CANCEL İptal[/CODE]
[CODE title="locale_interface.txt"]SYSTEM_MOVE_CHANNEL Kanal Değiştir[/CODE]
[CODE title="locale_string.txt"]"CANNOT_CHANGE_CHANNEL";
"Şu anda kanal değiştiremezsin.";
"Channel switch starting.";
"Kanal değiştiriliyor.";
"Usage: channel <new channel>";
"Kullanım: Kanal <Yeni Kanal>";
"Please enter a valid channel.";
"Lütfen geçerli bir kanal seç.";
"You are already on channel %d";
"Zaten %d kanalındasın.";
"The map you are at is cross-channel, changing won't have any effect.";
"Ortak kanalda bulunan bir haritada bulunduğunuz için kanal değiştirmeniz bir şey ifade etmeyecek.";
"You cannot change channel while in a dungeon.";
"Zindandayken kanal değiştiremezsin.";
"Channel switch in %d seconds.";
"%d saniye içinde kanal değiştiriliyor.";[/CODE]
[CODE lang="cpp" title="common\service.h"]//müsait bir yere ekleyin;
#define ENABLE_CHANNEL_SWITCH_SYSTEM[/CODE]
[CODE lang="cpp" title="common\tables.h"]//aratın;
HEADER_GD_AUTH_LOGIN = 100,
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
HEADER_GD_FIND_CHANNEL = 99,
#endif
//tekrar aratın;
HEADER_DG_MAP_LOCATIONS = 0xfe,
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
HEADER_DG_CHANNEL_RESULT = 184,
#endif
//tekrar aratın;
typedef struct SChannelStatus
{
[...]
} TChannelStatus;
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
typedef struct
{
long lMapIndex;
int channel;
} TPacketChangeChannel;
typedef struct
{
long lAddr;
WORD port;
} TPacketReturnChannel;
#endif[/CODE]
[CODE lang="cpp" title="db\src\ClientManager.cpp"]//aratın;
default:
sys_err("Unknown header (header: %d handle: %d length: %d)", header, dwHandle, dwLength);
break;
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
case HEADER_GD_FIND_CHANNEL:
FindChannel(peer, dwHandle, (TPacketChangeChannel*)data);
break;
#endif
//dosyanın sonuna ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void CClientManager::FindChannel(CPeer* requestPeer, DWORD dwHandle, TPacketChangeChannel* p)
{
if (!p->lMapIndex || !p->channel)
return;
long lAddr = 0;
WORD port = 0;
for (const auto peer : m_peerList)
{
if (peer->GetChannel() != p->channel)
continue;
TMapLocation kMapLocation;
thecore_memcpy(kMapLocation.alMaps, peer->GetMaps(), sizeof(kMapLocation.alMaps));
for (const auto midx : kMapLocation.alMaps)
{
if (midx == p->lMapIndex)
{
char host[16];
strlcpy(host, peer->GetPublicIP(), sizeof(kMapLocation.szHost));
lAddr = inet_addr(host);
port = peer->GetListenPort();
break;
}
}
if (lAddr && port)
break;
}
TPacketReturnChannel r;
r.lAddr = lAddr;
r.port = port;
requestPeer->EncodeHeader(HEADER_DG_CHANNEL_RESULT, dwHandle, sizeof(r));
requestPeer->Encode(&r, sizeof(r));
}
#endif[/CODE]
[CODE lang="cpp" title="db\src\ClientManager.h"]//aratın;
void WeddingEnd(TPacketWeddingEnd* p);
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void FindChannel(CPeer* pkPeer, DWORD dwHandle, TPacketChangeChannel* p);
#endif[/CODE]
[CODE lang="cpp" title="game\src\char.cpp"]//dosyanın sonuna ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
bool CHARACTER::SwitchChannel(long newAddr, WORD newPort)
{
if (!IsPC() || !GetDesc() || !CanWarp())
return false;
long x = GetX();
long y = GetY();
long lAddr = newAddr;
long lMapIndex = GetMapIndex();
WORD wPort = newPort;
if (lMapIndex >= 10000)
{
sys_err("Invalid change channel request from dungeon %d!", lMapIndex);
return false;
}
if (g_bChannel == 99)
{
sys_err("%s attempted to change channel from CH99, ignoring req.", GetName());
return false;
}
Stop();
Save();
if (GetSectree())
{
GetSectree()->RemoveEntity(this);
ViewCleanup();
EncodeRemovePacket(this);
}
m_lWarpMapIndex = lMapIndex;
m_posWarp.x = x;
m_posWarp.y = y;
sys_log(0, "ChangeChannel %s, %ld %ld map %ld to port %d", GetName(), x, y, GetMapIndex(), wPort);
TPacketGCWarp p;
p.bHeader = HEADER_GC_WARP;
p.lX = x;
p.lY = y;
p.lAddr = lAddr;
p.wPort = wPort;
GetDesc()->Packet(&p, sizeof(p));
char buf[256];
snprintf(buf, sizeof(buf), "%s Port%d Map%ld x%ld y%ld", GetName(), wPort, GetMapIndex(), x, y);
LogManager::instance().CharLog(this, 0, "CHANGE_CH", buf);
return true;
}
EVENTINFO(switch_channel_info)
{
DynamicCharacterPtr ch;
int secs;
long newAddr;
WORD newPort;
switch_channel_info()
: ch(),
secs(0),
newAddr(0),
newPort(0)
{
}
};
EVENTFUNC(switch_channel)
{
switch_channel_info* info = dynamic_cast<switch_channel_info*>(event->info);
if (!info)
{
sys_err("No switch channel event info!");
return 0;
}
LPCHARACTER ch = info->ch;
if (!ch)
{
sys_err("No char to work on for the switch.");
return 0;
}
if (!ch->GetDesc())
return 0;
if (info->secs > 0)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel switch in %d seconds."), info->secs);
--info->secs;
return PASSES_PER_SEC(1);
}
ch->SwitchChannel(info->newAddr, info->newPort);
ch->m_pkTimedEvent = NULL;
return 0;
}
bool CHARACTER::StartChannelSwitch(long newAddr, WORD newPort)
{
if (IsHack(false, true, 10))
return false;
switch_channel_info* info = AllocEventInfo<switch_channel_info>();
info->ch = this;
info->secs = CanWarp() && !IsPosition(POS_FIGHTING) ? 3 : 10;
info->newAddr = newAddr;
info->newPort = newPort;
m_pkTimedEvent = event_create(switch_channel, info, 1);
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel switch starting."));
return true;
}
#endif[/CODE]
[CODE lang="cpp" title="game\src\char.h"]//aratın;
int GetSyncHackCount() { return m_iSyncHackCount; }
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
public:
bool SwitchChannel(long newAddr, WORD newPort);
bool StartChannelSwitch(long newAddr, WORD newPort);
#endif[/CODE]
[CODE lang="cpp" title="game\src\cmd.cpp"]//aratın;
ACMD(do_duel);
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
ACMD(do_change_channel);
#endif
//tekrar aratın;
{ "duel", do_duel, 0, POS_DEAD, GM_LOW_WIZARD },
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
{ "channel", do_change_channel, 0, POS_DEAD, GM_PLAYER },
#endif[/CODE]
[CODE lang="cpp" title="game\src\cmd_general.cpp"]//dosyanın sonuna ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
ACMD(do_change_channel)
{
if (!ch)
return;
if (ch->m_pkTimedEvent)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ae¨ùO ¥ìC¨úu¨öA¢¥I¢¥U."));
event_cancel(&ch->m_pkTimedEvent);
return;
}
char arg1[256];
one_argument(argument, arg1, sizeof(arg1));
if (!*arg1)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Usage: channel <new channel>"));
return;
}
short channel;
str_to_number(channel, arg1);
if (channel < 0 || channel > 6)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Please enter a valid channel."));
return;
}
if (channel == g_bChannel)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are already on channel %d."), g_bChannel);
return;
}
if (g_bChannel == 99)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The map you are at is cross-channel, changing won't have any effect."));
return;
}
if (ch->GetDungeon())
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot change channel while in a dungeon."));
return;
}
TPacketChangeChannel p;
p.channel = channel;
p.lMapIndex = ch->GetMapIndex();
db_clientdesc->DBPacket(HEADER_GD_FIND_CHANNEL, ch->GetDesc()->GetHandle(), &p, sizeof(p));
}
#endif[/CODE]
[CODE lang="cpp" title="game\src\input.h"]//aratın;
void RespondChannelStatus(LPDESC desc, const char* pcData);
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void ChangeChannel(LPDESC desc, const char* pcData);
#endif[/CODE]
[CODE lang="cpp" title="game\src\input_db.cpp"]//aratın;
bool GetServerLocation(TAccountTable& rTab, BYTE bEmpire)
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
void CInputDB::ChangeChannel(LPDESC d, const char* pcData)
{
if (!d || !d->GetCharacter())
{
sys_err("Change channel request with empty or invalid description handle!");
return;
}
TPacketReturnChannel* p = (TPacketReturnChannel*)pcData;
if (!p->lAddr || !p->port)
{
std::string pName = d->GetCharacter()->GetName();
d->GetCharacter()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("CANNOT_CHANGE_CHANNEL"));
sys_err("Can't switch channel for player %s!", pName.c_str());
return;
}
d->GetCharacter()->StartChannelSwitch(p->lAddr, p->port);
}
#endif
//tekrar aratın;
default:
return (-1);
//üstüne ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
case HEADER_DG_CHANNEL_RESULT:
ChangeChannel(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData);
break;
#endif[/CODE]
[CODE lang="cpp" title="UserInterface\Locale_inc.h"]//müsait bir yere ekleyin;
#define ENABLE_CHANNEL_SWITCH_SYSTEM[/CODE]
[CODE lang="cpp" title="UserInterface\PythonApplicationModule.cpp"]//aratın;
#ifdef ENABLE_COSTUME_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_COSTUME_SYSTEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_COSTUME_SYSTEM", 0);
#endif
//altına ekleyin;
#ifdef ENABLE_CHANNEL_SWITCH_SYSTEM
PyModule_AddIntConstant(poModule, "ENABLE_CHANNEL_SWITCH_SYSTEM", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_CHANNEL_SWITCH_SYSTEM", 0);
#endif[/CODE]
[CODE lang="python" title="root\constinfo.py"]#müsait bir yere ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
channel_idx = 0[/CODE]
[CODE lang="python" title="root\uisystem.py"]#aratın;
self.gameOptionDlg = None
#altına ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
self.moveChannelDlg = None
#tekrar aratın;
self.GetChild("cancel_button").SAFE_SetEvent(self.Close)
#altına ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
self.GetChild("movechannel_button").SAFE_SetEvent(self.__ClickMoveChannelButton)
#tekrar aratın;
self.GetChild("cancel_button").SAFE_SetEvent(self.Close)
#altına ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
self.GetChild("movechannel_button").SAFE_SetEvent(self.__ClickMoveChannelButton)
#tekrar aratın;
def OnPressExitKey(self):
#üstüne ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
def __ClickMoveChannelButton(self):
self.Close()
if self.moveChannelDlg:
self.moveChannelDlg.Show()
else:
moveChannelDlg = MoveChannelDialog()
moveChannelDlg.Show()
self.moveChannelDlg = moveChannelDlg
#dosyanın sonuna ekleyin;
if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
class MoveChannelDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadDialog()
self.StartChannelNumber = 0
self.IsShow = False
def __del__(self):
ui.ScriptWindow.__del__(self)
def __LoadDialog(self) :
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/MoveChannelDialog.py")
except:
import exception as exception
exception.Abort("MoveChannelDialog.__LoadDialog")
self.ParentBoard = self.GetChild("MoveChannelBoard")
self.ChildBoard = self.GetChild("BlackBoard")
self.GetChild("MoveChannelTitle").SetCloseEvent(ui.__mem_func__(self.Close))
self.ChannelList = []
cnt = 5
cnt = cnt - 1
self.DlgWidht = 190
self.BlackBoardHeight = 23*cnt + 5*(cnt-1) + 13
self.DlgHeight = self.BlackBoardHeight + 75
self.AcceptBtn = ui.MakeButton(self.ParentBoard, 13, self.DlgHeight - 33, "", "d:/ymir work/ui/public/", "acceptbutton00.sub", "acceptbutton01.sub", "acceptbutton02.sub")
# self.AcceptBtn.SetText( localeInfo.MOVE_CHANNEL_SELECT )
self.AcceptBtn.SetEvent(ui.__mem_func__(self.AcceptButton))
self.CloseBtn = ui.MakeButton(self.ParentBoard, self.DlgWidht - 73, self.DlgHeight - 33, "", "d:/ymir work/ui/public/", "canclebutton00.sub", "canclebutton01.sub", "canclebutton02.sub")
# self.CloseBtn.SetText( localeInfo.MOVE_CHANNEL_CANCEL )
self.CloseBtn.SetEvent(ui.__mem_func__(self.Close))
for i in xrange(cnt):
btn = ui.MakeButton(self.ChildBoard, 8, 6 + i*28, "", "d:/ymir work/ui/game/myshop_deco/", "select_btn_01.sub", "select_btn_02.sub", "select_btn_03.sub")
btn.SetText("Kanal {0}".format(int(i+1)))
btn.SetEvent(ui.__mem_func__(self.__SelectChannel), i+1)
self.ChannelList.append(btn)
self.ParentBoard.SetSize(self.DlgWidht, self.DlgHeight)
self.ChildBoard.SetSize(self.DlgWidht - 26, self.BlackBoardHeight)
self.SetSize(self.DlgWidht, self.DlgHeight)
self.UpdateRect()
def __SelectChannel(self, idx):
self.ChangeChannelNumber = idx
for btn in self.ChannelList:
btn.SetUp()
btn.Enable()
self.ChannelList[idx-1].Down()
self.ChannelList[idx-1].Disable()
def AcceptButton(self):
if self.ChangeChannelNumber == self.StartChannelNumber:
return
net.SendChatPacket("/channel " + str(self.ChangeChannelNumber))
self.Close()
def Show(self) :
ui.ScriptWindow.Show(self)
self.StartChannelNumber = constInfo.channel_idx
self.__SelectChannel(self.StartChannelNumber)
self.IsShow = True
def Close(self):
self.Hide()
self.IsShow = False
def OnPressEscapeKey(self):
self.Close()
return True
def IsShowWindow(self):
return self.IsShow[/CODE]
[CODE lang="python" title="uiscript\systemdialog.py"]#aratın;
"y" : (SCREEN_HEIGHT - 298) /2,
#değiştirin;
"y" : (SCREEN_HEIGHT - 328) /2,
#tekrar aratın;
"height" : 298,
#değiştirin;
"height" : 328,
#tekrar aratın;
"height" : 298,
#değiştirin;
"height" : 328,
#tekrar aratın;
{
"name" : "game_option_button",
"type" : "button",
"x" : 10,
"y" : 117,
"text" : uiScriptLocale.GAMEOPTION_TITLE,
"default_image" : ROOT + "XLarge_Button_01.sub",
"over_image" : ROOT + "XLarge_Button_02.sub",
"down_image" : ROOT + "XLarge_Button_03.sub",
},
#altına ekleyin;
# if app.ENABLE_CHANNEL_SWITCH_SYSTEM:
{
"name" : "movechannel_button",
"type" : "button",
"x" : 10,
"y" : 147,#Esc menüsündeki konumunu buradan ayarlamanız gerekecek.
"text" : uiScriptLocale.SYSTEM_MOVE_CHANNEL,
"default_image" : ROOT + "XLarge_Button_01.sub",
"over_image" : ROOT + "XLarge_Button_02.sub",
"down_image" : ROOT + "XLarge_Button_03.sub",
},[/CODE]
[CODE title="locale_game.txt"]MOVE_CHANNEL_TITLE Kanal Seçimi
MOVE_CHANNEL_SELECT Tamam
MOVE_CHANNEL_CANCEL İptal[/CODE]
[CODE title="locale_interface.txt"]SYSTEM_MOVE_CHANNEL Kanal Değiştir[/CODE]
[CODE title="locale_string.txt"]"CANNOT_CHANGE_CHANNEL";
"Şu anda kanal değiştiremezsin.";
"Channel switch starting.";
"Kanal değiştiriliyor.";
"Usage: channel <new channel>";
"Kullanım: Kanal <Yeni Kanal>";
"Please enter a valid channel.";
"Lütfen geçerli bir kanal seç.";
"You are already on channel %d";
"Zaten %d kanalındasın.";
"The map you are at is cross-channel, changing won't have any effect.";
"Ortak kanalda bulunan bir haritada bulunduğunuz için kanal değiştirmeniz bir şey ifade etmeyecek.";
"You cannot change channel while in a dungeon.";
"Zindandayken kanal değiştiremezsin.";
"Channel switch in %d seconds.";
"%d saniye içinde kanal değiştiriliyor.";[/CODE]
