diff --git a/CGALib/gameinterface.cpp b/CGALib/gameinterface.cpp index 8517596..441c2c9 100644 --- a/CGALib/gameinterface.cpp +++ b/CGALib/gameinterface.cpp @@ -121,6 +121,8 @@ namespace CGAServiceProtocol TIMAX_DEFINE_PROTOCOL(LoginGameServer, void(std::string, std::string, int, int, int, int)); TIMAX_DEFINE_PROTOCOL(CreateCharacter, void(cga_create_chara_t)); TIMAX_DEFINE_PROTOCOL(GetGameServerInfo, cga_game_server_info_t()); + TIMAX_DEFINE_PROTOCOL(SetBlockAllChatMsg, void(bool)); + TIMAX_DEFINE_FORWARD(NotifyServerShutdown, int); TIMAX_DEFINE_FORWARD(NotifyBattleAction, int); TIMAX_DEFINE_FORWARD(NotifyBattleMotionPacket, std::string); @@ -1465,6 +1467,18 @@ namespace CGA } return false; } + virtual bool SetBlockAllChatMsg(bool bShouldBlock) + { + if (m_connected) { + try { + info = m_client.call(std::chrono::milliseconds(10000), m_endpoint, CGAServiceProtocol::SetBlockAllChatMsg, bShouldBlock); + return true; + } + catch (timax::rpc::exception const &e) { if (e.get_error_code() != timax::rpc::error_code::TIMEOUT) m_connected = false; OutputDebugStringA("rpc exception from " __FUNCTION__); OutputDebugStringA(e.get_error_message().c_str()); } + catch (msgpack::parse_error &e) { OutputDebugStringA("parse exception from " __FUNCTION__); OutputDebugStringA(e.what()); } + } + return false; + } virtual bool RegisterServerShutdownNotify(const std::function &callback) { if (m_connected) diff --git a/CGALib/gameinterface.h b/CGALib/gameinterface.h index f44da5f..d1d59e7 100644 --- a/CGALib/gameinterface.h +++ b/CGALib/gameinterface.h @@ -1240,6 +1240,7 @@ namespace CGA virtual bool SendMail(int index, const std::string &msg, bool &result) = 0; virtual bool SendPetMail(int index, int petid, int itempos, const std::string &msg, bool &result) = 0; virtual bool GetGameServerInfo(cga_game_server_info_t &info) = 0; + virtual bool SetBlockAllChatMsg(bool bShouldBlock) = 0; virtual bool RegisterServerShutdownNotify(const std::function &callback) = 0; virtual bool RegisterBattleActionNotify(const std::function &callback) = 0; diff --git a/CGAssistant/chatform.cpp b/CGAssistant/chatform.cpp index afbb40e..e641e48 100644 --- a/CGAssistant/chatform.cpp +++ b/CGAssistant/chatform.cpp @@ -1,6 +1,7 @@ #include "chatform.h" #include "ui_chatform.h" +#include #include extern CGA::CGAInterface *g_CGAInterface; @@ -13,6 +14,10 @@ ChatForm::ChatForm(QWidget *parent) : m_ChatMaxLines = 100; ui->textEdit_chat->document()->setMaximumBlockCount(m_ChatMaxLines); + + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(OnAutoChat())); + timer->start(1000); } ChatForm::~ChatForm() @@ -20,6 +25,14 @@ ChatForm::~ChatForm() delete ui; } +void ChatForm::OnAutoChat() +{ + if(g_CGAInterface->IsConnected()) + { + g_CGAInterface->SetBlockAllChatMsg(true); + } +} + void ChatForm::on_lineEdit_returnPressed() { auto saystring = ui->lineEdit->text().toStdString(); @@ -36,6 +49,10 @@ void ChatForm::OnNotifyGetPlayerInfo(QSharedPointer player) m_player = player; } +void ChatForm::OnNotifyFillChatSettings(bool blockallchatmsgs) +{ + ui->checkBox_BlockAllChatMsgs->setChecked(blockallchatmsgs); +} void ChatForm::OnNotifyFillStaticSettings(int freezetime, int chatmaxlines) { @@ -132,10 +149,24 @@ bool ChatForm::ParseChatSettings(const QJsonValue &val) if(!val.isObject()) return false; + auto obj = val.toObject(); + + if(obj.contains("blockallchatmsgs")) + ui->checkBox_BlockAllChatMsgs->setChecked(obj.take("blockallchatmsgs").toBool()); + return true; } void ChatForm::SaveChatSettings(QJsonObject &obj) { + obj.insert("blockallchatmsgs", ui->checkBox_BlockAllChatMsgs->isChecked()); +} +void ChatForm::on_checkBox_BlockAllChatMsgs_stateChanged(int state) +{ + if(g_CGAInterface->IsConnected()) + { + g_CGAInterface->SetBlockAllChatMsg(state ? true : false); + } } + diff --git a/CGAssistant/chatform.h b/CGAssistant/chatform.h index 1f8d496..ac08e67 100644 --- a/CGAssistant/chatform.h +++ b/CGAssistant/chatform.h @@ -20,6 +20,7 @@ class ChatForm : public QWidget ~ChatForm(); public slots: + void OnNotifyFillChatSettings(bool blockallchatmsgs); void OnNotifyFillStaticSettings(int freezetime, int chatmaxlines); void OnNotifyGetPlayerInfo(QSharedPointer player); void OnNotifyChatMsg(int unitid, QString msg, int size, int color); @@ -29,6 +30,9 @@ public slots: private slots: void on_lineEdit_returnPressed(); + void on_checkBox_BlockAllChatMsgs_stateChanged(int state); + + void OnAutoChat(); private: Ui::ChatForm *ui; QSharedPointer m_player; diff --git a/CGAssistant/chatform.ui b/CGAssistant/chatform.ui index 4704fce..5ca907d 100644 --- a/CGAssistant/chatform.ui +++ b/CGAssistant/chatform.ui @@ -26,11 +26,37 @@ - - - [Enter] to send chat - - + + + + + [Enter] to send chat message + + + + + + + + 0 + 0 + + + + + 128 + 0 + + + + Qt::LeftToRight + + + Block all chat messages + + + + diff --git a/CGAssistant/lang.qm b/CGAssistant/lang.qm index 1566991..687a7da 100644 Binary files a/CGAssistant/lang.qm and b/CGAssistant/lang.qm differ diff --git a/CGAssistant/lang.ts b/CGAssistant/lang.ts index 3878149..e4dcf8a 100644 --- a/CGAssistant/lang.ts +++ b/CGAssistant/lang.ts @@ -806,7 +806,7 @@ meet BOSS [Enter] to send chat - [回车] 发送聊天消息 + [回车] 发送聊天消息 Display Time @@ -856,6 +856,14 @@ Chat database will not work properly. Chat database will not work properly. 创建索引uploadtime失败,消息数据库可能无法正常工作。 + + [Enter] to send chat message + [回车] 发送聊天消息 + + + Block all chat messages + 屏蔽所有聊天消息 + ItemForm diff --git a/CGAssistant/main.cpp b/CGAssistant/main.cpp index ec43293..fa264cb 100644 --- a/CGAssistant/main.cpp +++ b/CGAssistant/main.cpp @@ -116,6 +116,8 @@ int main(int argc, char *argv[]) QCommandLineOption chatmaxlines("chatmaxlines", "", "chatmaxlines", "100"); + QCommandLineOption blockallchatmsgs("blockallchatmsgs"); + QCommandLineParser parser; parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); @@ -151,6 +153,7 @@ int main(int argc, char *argv[]) parser.addOption(consolemaxlines); parser.addOption(scriptfreezeduration); parser.addOption(chatmaxlines); + parser.addOption(blockallchatmsgs); parser.process(a); QTranslator translator; @@ -168,7 +171,6 @@ int main(int argc, char *argv[]) MainWindow w; - for(unsigned int qport = 14396; qport < 14396 + 1000; ++qport) { if(qserver.listen(QHostAddress::LocalHost, qport, [&w](QHttpRequest* req, QHttpResponse* res) { @@ -264,6 +266,8 @@ int main(int argc, char *argv[]) w.show(); + w.NotifyFillStaticSettings(parser.value(killfreeze).toInt(), parser.value(chatmaxlines).toInt()); + w.NotifyFillAutoLogin(parser.value(gameType).toInt(), parser.value(loginUser), parser.value(loginPwd), @@ -293,9 +297,9 @@ int main(int argc, char *argv[]) parser.value(consolemaxlines).toInt(), parser.value(scriptfreezeduration).toInt() ); - w.NotifyFillLoadSettings(parser.value(loadsettings)); + w.NotifyFillChatSettings(parser.isSet(blockallchatmsgs) ? true : false); - w.NotifyFillStaticSettings(parser.value(killfreeze).toInt(), parser.value(chatmaxlines).toInt()); + w.NotifyFillLoadSettings(parser.value(loadsettings)); return a.exec(); } diff --git a/CGAssistant/mainwindow.cpp b/CGAssistant/mainwindow.cpp index 839f156..3c27afa 100644 --- a/CGAssistant/mainwindow.cpp +++ b/CGAssistant/mainwindow.cpp @@ -80,6 +80,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(playerFrom, &PlayerForm::SaveItemTweaker, itemForm, &ItemForm::SaveItemTweaker); connect(playerFrom, &PlayerForm::SaveBattleSettings, autoBattleForm, &AutoBattleForm::SaveBattleSettings); connect(playerFrom, &PlayerForm::SaveChatSettings, chatForm, &ChatForm::SaveChatSettings); + connect(this, &MainWindow::NotifyChangeWindow, processFrom, &ProcessForm::OnNotifyChangeWindow); connect(this, &MainWindow::NotifyFillAutoLogin, accountForm, &AccountForm::OnNotifyFillAutoLogin); @@ -87,6 +88,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, &MainWindow::NotifyFillLoadSettings, playerFrom, &PlayerForm::OnNotifyFillLoadSettings); connect(this, &MainWindow::NotifyFillStaticSettings, processWorker, &CProcessWorker::OnNotifyFillStaticSettings); connect(this, &MainWindow::NotifyFillStaticSettings, chatForm, &ChatForm::OnNotifyFillStaticSettings); + connect(this, &MainWindow::NotifyFillChatSettings, chatForm, &ChatForm::OnNotifyFillChatSettings); connect(playerWorker, &CPlayerWorker::NotifyGetSkillsInfo, autoBattleForm, &AutoBattleForm::OnNotifyGetSkillsInfo, Qt::ConnectionType::QueuedConnection); connect(playerWorker, &CPlayerWorker::NotifyGetPetsInfo, autoBattleForm, &AutoBattleForm::OnNotifyGetPetsInfo, Qt::ConnectionType::QueuedConnection); diff --git a/CGAssistant/mainwindow.h b/CGAssistant/mainwindow.h index eaa630e..ea76f71 100644 --- a/CGAssistant/mainwindow.h +++ b/CGAssistant/mainwindow.h @@ -36,6 +36,7 @@ class MainWindow : public QMainWindow QString create_chara_points, QString create_chara_elements, QString create_chara_name); void NotifyFillLoadScript(QString path, int autorestart, bool freezestop, bool injuryprot, bool soulprot, int consolemaxlines, int scriptfreezeduration); void NotifyFillLoadSettings(QString path); + void NotifyFillChatSettings(bool blockallchatmsgs); void NotifyFillStaticSettings(int freezetime, int chatmaxlines); void HttpGetGameProcInfo(QJsonDocument* doc); void HttpGetSettings(QJsonDocument* doc); diff --git a/CGAssistant/player.cpp b/CGAssistant/player.cpp index cd0e1d9..decaf6b 100644 --- a/CGAssistant/player.cpp +++ b/CGAssistant/player.cpp @@ -276,7 +276,6 @@ void CPlayerWorker::OnDownloadMap(int xsize, int ysize) m_IsDownloadingMap = true; } - void CPlayerWorker::OnQueueAntiAFKKick() { if(!m_bAntiAFKKick) diff --git a/CGAssistant/player.h b/CGAssistant/player.h index fa0292d..e74e96a 100644 --- a/CGAssistant/player.h +++ b/CGAssistant/player.h @@ -283,6 +283,7 @@ public slots: void OnSetNoSwitchAnim(int state); void OnSetGameTextUI(int state); void OnSetAntiAFKKick(int state); + void OnSetBlockAllChatMsgs(int state); void OnDownloadMap(int xsize, int ysize); void OnTabChanged(int tabindex); void OnSetUseFoodAt(QString str); @@ -330,6 +331,7 @@ public slots: bool m_bHighSpeedBattle; bool m_bGameTextUI; bool m_bAntiAFKKick; + QSharedPointer m_player; QSharedPointer m_pets; diff --git a/cgahook/gameservice.cpp b/cgahook/gameservice.cpp index 627053a..d77141e 100644 --- a/cgahook/gameservice.cpp +++ b/cgahook/gameservice.cpp @@ -507,7 +507,7 @@ int __fastcall NewOnLoginResult(void *pthis, int dummy, int a1, int result, cons puts(sb.GetString()); fflush(stdout); - WriteLog("NtTerminateProcess\n"); + //WriteLog("NtTerminateProcess\n"); NtTerminateProcess((HANDLE)-1, 0); return 0; } @@ -710,7 +710,7 @@ void CGAService::NewBATTLE_PlayerAction() } if (prevPlayerStatus != 1 && playerStatus == 1) { - WriteLog("CGA_NotifyBattleAction player\n"); + //WriteLog("CGA_NotifyBattleAction player\n"); int flags = FL_BATTLE_ACTION_ISPLAYER; if (m_btl_double_action) @@ -724,14 +724,14 @@ void CGAService::NewBATTLE_PlayerAction() { if (m_btl_pet_skill_packet_send) { - WriteLog("m_btl_pet_skill_packet_send = true\n"); + //WriteLog("m_btl_pet_skill_packet_send = true\n"); *g_btl_action_done = 1; m_btl_pet_skill_packet_send = false; return; } else { - WriteLog("CGA_NotifyBattleAction pet\n"); + //WriteLog("CGA_NotifyBattleAction pet\n"); } //Notify pet action int flags = 0; @@ -753,15 +753,15 @@ void __cdecl NewNET_WriteEndBattlePacket_cgitem(int a1, int a2) { g_CGAService.NET_WriteEndBattlePacket_cgitem(a1, a2); - WriteLog("NewNET_WriteEndBattlePacket_cgitem\n"); + //WriteLog("NewNET_WriteEndBattlePacket_cgitem\n"); CGA_NotifyBattleAction(FL_BATTLE_ACTION_END); } void CGAService::NewNET_ParseTradeItemsPackets(int a1, const char *buf) { - WriteLog("NewNET_ParseTradeItemsPackets\n"); - WriteLog(buf); + //WriteLog("NewNET_ParseTradeItemsPackets\n"); + //WriteLog(buf); NET_ParseTradeItemsPackets(a1, buf); @@ -818,9 +818,9 @@ void CGAService::NewNET_ParseTradePetPackets(int a1, int index, const char *buf) { NET_ParseTradePetPackets(a1, index, buf); - WriteLog("NewNET_ParseTradePetPackets\n"); + //WriteLog("NewNET_ParseTradePetPackets\n"); - WriteLog2(buf); + //WriteLog2(buf); char name[256]; @@ -872,9 +872,9 @@ void CGAService::NewNET_ParseTradePetSkillPackets(int a1, int index, const char { NET_ParseTradePetSkillPackets(a1, index, buf); - WriteLog("NewNET_ParseTradePetSkillPackets\n"); + //WriteLog("NewNET_ParseTradePetSkillPackets\n"); - WriteLog2(buf); + //WriteLog2(buf); cga_trade_stuff_info_t info(TRADE_STUFFS_PETSKILL); @@ -902,7 +902,7 @@ void __cdecl NewNET_ParseTradePetSkillPackets(int a1, int index, const char *buf void CGAService::NewNET_ParseTradeGoldPackets(int a1, int gold) { - WriteLog("NewNET_ParseTradeGoldPackets\n"); + //WriteLog("NewNET_ParseTradeGoldPackets\n"); NET_ParseTradeGoldPackets(a1, gold); @@ -920,7 +920,7 @@ void __cdecl NewNET_ParseTradeGoldPackets(int a1, int gold) void CGAService::NewNET_ParseTradePlayers(int a1, const char *src, char *src2) { - WriteLog("NewNET_ParseTradePlayers\n"); + //WriteLog("NewNET_ParseTradePlayers\n"); NET_ParseTradePlayers(a1, src, src2); @@ -968,7 +968,7 @@ void __cdecl NewNET_ParseTradePlayers(int a1, const char *src, char *src2) void CGAService::NewNET_ParseHealPlayers(int a1, const char *src) { - WriteLog("NewNET_ParseHealPlayers %s\n", src); + //WriteLog("NewNET_ParseHealPlayers %s\n", src); NET_ParseHealPlayers(a1, src); @@ -1057,7 +1057,7 @@ void __cdecl NewNET_ParseHealPlayers(int a1, const char *src) void CGAService::NewNET_ParseHealUnits(int a1, const char *src) { - WriteLog("NewNET_ParseHealUnits\n"); + //WriteLog("NewNET_ParseHealUnits\n"); NET_ParseHealUnits(a1, src); @@ -1178,7 +1178,7 @@ void __cdecl NewNET_ParseHealUnits(int a1, const char *src) void CGAService::NewNET_ParseItemPlayers(int a1, const char *src) { - WriteLog("NewNET_ParseItemPlayers\n"); + //WriteLog("NewNET_ParseItemPlayers\n"); NET_ParseItemPlayers(a1, src); @@ -1267,7 +1267,7 @@ void __cdecl NewNET_ParseItemPlayers(int a1, const char *src) void CGAService::NewNET_ParseItemUnits(int a1, const char *src) { - WriteLog("NewNET_ParseItemUnits\n"); + //WriteLog("NewNET_ParseItemUnits\n"); NET_ParseItemUnits(a1, src); @@ -1379,7 +1379,7 @@ void __cdecl NewNET_ParseItemUnits(int a1, const char *src) void CGAService::NewNET_ParseBattlePackets(int a1, const char *buf) { - WriteLog("NewNET_ParseBattlePackets %s %s\n", (*g_playerBase)->name, buf); + //WriteLog("NewNET_ParseBattlePackets %s %s\n", (*g_playerBase)->name, buf); if (*buf == 'M') { @@ -1400,7 +1400,7 @@ void CGAService::NewNET_ParseBattlePackets(int a1, const char *buf) m_btl_delayanimpacket.a1 = a1; strcpy(m_btl_delayanimpacket.buf, buf); m_btl_delayanimpacket.lasttick = GetTickCount(); - WriteLog("anim packet delayed\n"); + //WriteLog("anim packet delayed\n"); } return; } @@ -1413,7 +1413,7 @@ void CGAService::NewNET_ParseBattlePackets(int a1, const char *buf) { NET_ParseBattlePackets(m_btl_delayanimpacket.a1, m_btl_highspeed_enable ? "M|" : m_btl_delayanimpacket.buf); m_btl_delayanimpacket.isdelay = false; - WriteLog("delay anim played\n"); + //WriteLog("delay anim played\n"); } } @@ -1600,14 +1600,14 @@ void CGAService::NewNET_ParseWorkingResult(int a1, int success, int type, const void __cdecl NewNET_ParseWorkingResult(int a1, int success, int type, const char *buf) { - //WriteLog("type=%d, success=%d, buf=%s\n", type, success, buf); + ////WriteLog("type=%d, success=%d, buf=%s\n", type, success, buf); g_CGAService.NewNET_ParseWorkingResult(a1, success, type, buf); } void CGAService::NewNET_ParseChatMsg(int a1, int unitid, const char *buf, int color, int size) { - WriteLog("NewNET_ParseChatMsg u=%d, buf=%s, color=%d, size=%d\n", unitid, buf, color, size); + //WriteLog("NewNET_ParseChatMsg u=%d, buf=%s, color=%d, size=%d\n", unitid, buf, color, size); if (buf[0] == 'P' && buf[1] == '|') { @@ -1620,6 +1620,9 @@ void CGAService::NewNET_ParseChatMsg(int a1, int unitid, const char *buf, int co void __cdecl NewNET_ParseChatMsg(int a1, int unitid, const char *buf, int color, int size) { + if (g_CGAService.m_ui_block_all_chatmsgs && buf[0] == 'P' && buf[1] == '|' && unitid != -1) + return; + g_CGAService.NewNET_ParseChatMsg(a1, unitid, buf, color, size); } @@ -1631,7 +1634,7 @@ void CGAService::NewNET_ParseSysMsg(int a1, const char *buf) cga_chat_msg_t msg(-1, boost::locale::conv::to_utf(temp, "GBK"), 0, 0); CGA_NotifyChatMsg(msg); - WriteLog("NewNET_ParseSysMsg %s\n", temp); + //WriteLog("NewNET_ParseSysMsg %s\n", temp); NET_ParseSysMsg(a1, buf); } @@ -1643,7 +1646,7 @@ void __cdecl NewNET_ParseSysMsg(int a1, const char *buf) void CGAService::NewNET_ParseReadyTrade() { - WriteLog("NewNET_ParseConfirmTrade\n"); + //WriteLog("NewNET_ParseConfirmTrade\n"); NET_ParseReadyTrade(); @@ -1657,7 +1660,7 @@ void __cdecl NewNET_ParseReadyTrade() void CGAService::NewNET_ParseConfirmTrade(int a1, int a2) { - WriteLog("NewNET_ParseConfirmTrade\n"); + //WriteLog("NewNET_ParseConfirmTrade\n"); NET_ParseConfirmTrade(a1, a2); @@ -1683,7 +1686,7 @@ void __cdecl NewNET_ParseMeetEnemy(int a1, int a2, int a3) void CGAService::NewNET_ParseDownloadMap(int sock, int index1, int index3, int xbase, int ybase, int xtop, int ytop, const char *buf) { - //WriteLog("NewNET_ParseDownloadMap %d %d %d %d %d %d\n", index1, index3, xbase, ybase, xtop, ytop); + ////WriteLog("NewNET_ParseDownloadMap %d %d %d %d %d %d\n", index1, index3, xbase, ybase, xtop, ytop); cga_download_map_t msg(index1, index3, xbase, ybase, xtop, ytop); CGA_NotifyDownloadMap(msg); @@ -2250,7 +2253,7 @@ int __cdecl NewIsMapObjectEntrance(int xpos, int ypos) void CGAService::NewNET_WritePrepareCraftItemPacket_cgitem(int a1, int a2) { - //WriteLog("NewNET_WritePrepareCraftItemPacket_cgitem %d\n", a2); + ////WriteLog("NewNET_WritePrepareCraftItemPacket_cgitem %d\n", a2); if (m_work_immediate) { if (m_work_immediate_state == 2) @@ -2278,7 +2281,7 @@ void __cdecl NewNET_WritePrepareCraftItemPacket_cgitem(int a1, int a2) void CGAService::NewNET_WriteWorkPacket_cgitem(int a1, int skill, int a3, int a4, const char *buf) { - //WriteLog("NET_WriteWorkPacket_cgitem %d %d %d %s\n", skill, a3, a4, buf); + ////WriteLog("NET_WriteWorkPacket_cgitem %d %d %d %s\n", skill, a3, a4, buf); if (m_work_immediate && m_work_immediate_state == 1) { m_work_immediate_state = 2; @@ -3462,9 +3465,10 @@ void CGAService::Initialize(game_type type) m_ui_create_character = false; m_run_game_pid = 0; m_run_game_tid = 0; - m_ui_battle_action = 0; - m_ui_battle_hevent = CreateEventA(NULL, FALSE, FALSE, NULL); + //m_ui_battle_action = 0; + //m_ui_battle_hevent = CreateEventA(NULL, FALSE, FALSE, NULL); m_trade_add_all_stuffs = false; + m_ui_block_all_chatmsgs = false; if (*g_mutex) { @@ -3530,9 +3534,10 @@ void CGAService::Initialize(game_type type) m_ui_create_character = false; m_run_game_pid = 0; m_run_game_tid = 0; - m_ui_battle_action = 0; - m_ui_battle_hevent = CreateEventA(NULL, FALSE, FALSE, NULL); + //m_ui_battle_action = 0; + //m_ui_battle_hevent = CreateEventA(NULL, FALSE, FALSE, NULL); m_trade_add_all_stuffs = false; + m_ui_block_all_chatmsgs = false; DetourTransactionBegin(); DetourAttach(&(void *&)BATTLE_PlayerAction, ::NewBATTLE_PlayerAction); @@ -3658,7 +3663,7 @@ void CGAService::DrawCustomText() { if (m_btl_highspeed_enable && m_btl_delayanimpacket.isdelay && GetTickCount() > m_btl_delayanimpacket.lasttick + 3500) { - WriteLog("end of battle with exception\n"); + //WriteLog("end of battle with exception\n"); m_btl_delayanimpacket.lasttick = 0; m_btl_delayanimpacket.isdelay = false; NET_ParseBattlePackets(m_btl_delayanimpacket.a1, "M|END|"); @@ -5214,6 +5219,11 @@ void CGAService::AddAllTradeItems(void) m_trade_add_all_stuffs = true; } +void CGAService::SetBlockAllChatMsg(bool bShouldBlock) +{ + m_ui_block_all_chatmsgs = true; +} + bool CGAService::WM_BattleNormalAttack(int target) { if (!IsInGame()) @@ -5230,7 +5240,7 @@ bool CGAService::WM_BattleNormalAttack(int target) *g_btl_action_done = 1; COMMON_PlaySound(57, 320, 240); - WriteLog("BattleNormalAttack %d\n", target); + //WriteLog("BattleNormalAttack %d\n", target); return true; } @@ -5254,7 +5264,7 @@ bool CGAService::WM_BattleSkillAttack(int skillpos, int skilllv, int target) if (!g_skill_base[skillpos].name[0]) { - WriteLog("skill %d not valid\n", skillpos); + //WriteLog("skill %d not valid\n", skillpos); return false; } @@ -5268,7 +5278,7 @@ bool CGAService::WM_BattleSkillAttack(int skillpos, int skilllv, int target) NET_WritePacket(*g_net_buffer, *g_net_socket, net_header_battle, buf); //*g_btl_action_done = 1; //COMMON_PlaySound(57, 320, 240); - WriteLog("BattleSkillAttack %d %d %d\n", skillpos, skilllv, target); + //WriteLog("BattleSkillAttack %d %d %d\n", skillpos, skilllv, target); return TRUE; } @@ -5277,18 +5287,18 @@ bool CGAService::WM_BattleSkillAttack(int skillpos, int skilllv, int target) if (!(*g_btl_skill_allowbit & (1 << skillpos)))//skill not allowed!!! { - WriteLog("skill %d not allowed\n", skillpos); + //WriteLog("skill %d not allowed\n", skillpos); return false; } if (g_skill_base[skillpos].level < skilllv) { - WriteLog("skill lv%d not enough\n", skilllv); + //WriteLog("skill lv%d not enough\n", skilllv); return false; } if (g_skill_base[skillpos].sub[skilllv].available == 0) { - WriteLog("skill lv%d not available, downgrade\n", skilllv); + //WriteLog("skill lv%d not available, downgrade\n", skilllv); bool available = false; for (int lv = skilllv - 1; lv >= 0; --lv) { @@ -5302,7 +5312,7 @@ bool CGAService::WM_BattleSkillAttack(int skillpos, int skilllv, int target) if (!available) { - WriteLog("skill lv%d not available\n", skilllv); + //WriteLog("skill lv%d not available\n", skilllv); return false; } } @@ -5322,7 +5332,7 @@ bool CGAService::WM_BattleSkillAttack(int skillpos, int skilllv, int target) if (!available) { - WriteLog("skill lv%d no enough mp\n", skilllv); + //WriteLog("skill lv%d no enough mp\n", skilllv); return false; } } @@ -5336,7 +5346,7 @@ bool CGAService::WM_BattleSkillAttack(int skillpos, int skilllv, int target) *g_btl_action_done = 1; COMMON_PlaySound(57, 320, 240); - WriteLog("BattleSkillAttack2 %d %d %d\n", skillpos, skilllv, target); + //WriteLog("BattleSkillAttack2 %d %d %d\n", skillpos, skilllv, target); return true; } @@ -5348,7 +5358,7 @@ bool CGAService::BattleSkillAttack(int skillpos, int skilllv, int target, bool p target |= 0x10000000; } - //WriteLog("BattleSkillAttack %d %d %d\n", skillpos, skilllv, target); + ////WriteLog("BattleSkillAttack %d %d %d\n", skillpos, skilllv, target); return SendMessageA(g_MainHwnd, WM_CGA_BATTLE_SKILLATTACK, skillpos | (skilllv << 8), target) ? true : false; } @@ -5539,13 +5549,13 @@ bool CGAService::WM_BattlePetSkillAttack(int skillpos, int target) m_btl_pet_skill_packet_send = true; } - WriteLog("BattlePetSkillAttack FF\n"); + //WriteLog("BattlePetSkillAttack FF\n"); return true; } if (!(*g_btl_petskill_allowbit & (1 << skillpos)))//skill not allowed!!! { - WriteLog("pet skill %d not allowed\n", skillpos); + //WriteLog("pet skill %d not allowed\n", skillpos); return false; } @@ -5570,7 +5580,7 @@ bool CGAService::WM_BattlePetSkillAttack(int skillpos, int target) m_btl_pet_skill_packet_send = true; } - WriteLog("BattlePetSkillAttack %d %d %d\n", skillpos, target, packetOnly ? 1 : 0); + //WriteLog("BattlePetSkillAttack %d %d %d\n", skillpos, target, packetOnly ? 1 : 0); return true; } @@ -5859,7 +5869,7 @@ bool CGAService::WM_SellNPCStore(cga_sell_items_t *items) if (*g_npc_dialog_type != 7 && *g_npc_dialog_type != 6 && *g_npc_dialog_type != 22 && *g_npc_dialog_type != 20 && *g_npc_dialog_type != 31) { - //WriteLog("type mismatch %d\n", *g_npc_dialog_type); + ////WriteLog("type mismatch %d\n", *g_npc_dialog_type); return false; } @@ -5869,7 +5879,7 @@ bool CGAService::WM_SellNPCStore(cga_sell_items_t *items) { if (items->at(i).itemid != 0 && (*g_playerBase)->iteminfos[items->at(i).itempos].item_id != items->at(i).itemid) { - //WriteLog("id mismatch %d %d\n", items->at(i).itemid, (*g_playerBase)->iteminfos[items->at(i).itempos].item_id); + ////WriteLog("id mismatch %d %d\n", items->at(i).itemid, (*g_playerBase)->iteminfos[items->at(i).itempos].item_id); return false; } bool allow = false; @@ -5877,7 +5887,7 @@ bool CGAService::WM_SellNPCStore(cga_sell_items_t *items) { if (g_npcdlg_item_base[j].valid && g_npcdlg_item_base[j].itempos == items->at(i).itempos) { - //WriteLog("j=%d g_npcdlg_item_base[j].itempos=%d\n", j, g_npcdlg_item_base[j].itempos); + ////WriteLog("j=%d g_npcdlg_item_base[j].itempos=%d\n", j, g_npcdlg_item_base[j].itempos); allow = true; break; } @@ -5907,11 +5917,11 @@ bool CGAService::WM_SellNPCStore(cga_sell_items_t *items) { if (items->at(i).itemid != 0 && (*g_playerBase)->iteminfos[items->at(i).itempos].item_id != items->at(i).itemid) { - //WriteLog("id mismatch %d %d %d\n", items->at(i).itemid, (*g_playerBase)->iteminfos[items->at(i).itempos].item_id, items->at(i).itemid); + ////WriteLog("id mismatch %d %d %d\n", items->at(i).itemid, (*g_playerBase)->iteminfos[items->at(i).itempos].item_id, items->at(i).itemid); return false; } if ((*g_playerBase)->iteminfos[items->at(i).itempos].count != 0 && (*g_playerBase)->iteminfos[items->at(i).itempos].count < items->at(i).count) { - //WriteLog("count mismatch %d %d\n", (*g_playerBase)->iteminfos[items->at(i).itempos].count, items->at(i).count); + ////WriteLog("count mismatch %d %d\n", (*g_playerBase)->iteminfos[items->at(i).itempos].count, items->at(i).count); return false; } sprintf(buf, "%d\\z%d", items->at(i).itempos, items->at(i).count); @@ -6314,7 +6324,7 @@ bool CGAService::WM_StartWork(int skill_index, int sub_index) break; } if (!isavailable) { - WriteLog("WM_StartWork WORK_TYPE_HEALING subindex %d not available", sub_index); + //WriteLog("WM_StartWork WORK_TYPE_HEALING subindex %d not available", sub_index); return false; } @@ -6334,7 +6344,7 @@ bool CGAService::WM_StartWork(int skill_index, int sub_index) int sub_index2 = sub_index & 0xFF; int sub_type = (sub_index >> 8) & 0xFF; if (sub_index2 < 0 || sub_index2 > 50 || !g_skill_base[skill_index].craft[sub_index2].available) { - WriteLog("WM_StartWork subtype %d, subindex %d not available", sub_type, sub_index2); + //WriteLog("WM_StartWork subtype %d, subindex %d not available", sub_type, sub_index2); return false; } UI_OpenCraftDialog(skill_index, sub_index, sub_type); @@ -6362,7 +6372,7 @@ bool CGAService::WM_StartWork(int skill_index, int sub_index) break; } if (!isavailable) { - WriteLog("WM_StartWork WORK_TYPE_PET subindex %d not available", sub_index); + //WriteLog("WM_StartWork WORK_TYPE_PET subindex %d not available", sub_index); return false; } @@ -7229,7 +7239,7 @@ void CGAService::WM_FixMapWarpStuck(int type) { if (type == 0) { - WriteLog("FixMapWarpStuck type 0\n"); + //WriteLog("FixMapWarpStuck type 0\n"); *g_disable_move = 0; if (m_game_type == cg_item_6000) @@ -7239,7 +7249,7 @@ void CGAService::WM_FixMapWarpStuck(int type) } else if (type == 1) { - WriteLog("FixMapWarpStuck type 1\n"); + //WriteLog("FixMapWarpStuck type 1\n"); if (IsMapObjectEntrance(g_player_xpos->decode(), g_player_ypos->decode())) { diff --git a/cgahook/gameservice.h b/cgahook/gameservice.h index d8b8270..e2b6506 100644 --- a/cgahook/gameservice.h +++ b/cgahook/gameservice.h @@ -1159,6 +1159,7 @@ namespace CGA int IsItemTypeAssessable(int type); void AddAllTradeItems(void); + void SetBlockAllChatMsg(bool bShouldBlock); bool WM_BattleNormalAttack(int target); bool WM_BattleSkillAttack(int skillpos, int skilllv, int target); bool WM_BattleGuard(); @@ -1307,18 +1308,20 @@ namespace CGA int m_run_game_pid; int m_run_game_tid; - int m_ui_battle_action; + /*int m_ui_battle_action; struct { int change_petid; int select_skill_index; bool select_skill_ok; int select_target; - }m_ui_battle_action_param; - HANDLE m_ui_battle_hevent; + }m_ui_battle_action_param;*/ + //HANDLE m_ui_battle_hevent; bool m_trade_add_all_stuffs; + bool m_ui_block_all_chatmsgs; + game_type m_game_type; HFONT m_hFont; diff --git a/cgahook/server.cpp b/cgahook/server.cpp index 2868063..1f59506 100644 --- a/cgahook/server.cpp +++ b/cgahook/server.cpp @@ -127,11 +127,11 @@ void CGA_CreateSharedData(int port) { ULONG ProcessId = GetCurrentProcessId(); - WCHAR szLockName[32]; + WCHAR szLockName[64]; wsprintfW(szLockName, L"CGASharedDataLock_%d", ProcessId); g_hDataLock = CreateMutexW(NULL, TRUE, szLockName); - WCHAR szMappingName[32]; + WCHAR szMappingName[64]; wsprintfW(szMappingName, L"CGASharedData_%d", ProcessId); g_hFileMapping = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(CGA::CGAShare_t), szMappingName); if (g_hFileMapping && GetLastError() != ERROR_ALREADY_EXISTS) @@ -300,6 +300,7 @@ DWORD WINAPI CGAServerThread(LPVOID) server->register_handler("SendMail", timax::bind(&CGAService::SendMail, &g_CGAService)); server->register_handler("SendPetMail", timax::bind(&CGAService::SendPetMail, &g_CGAService)); server->register_handler("GetGameServerInfo", timax::bind(&CGAService::GetGameServerInfo, &g_CGAService)); + server->register_handler("SetBlockAllChatMsg", timax::bind(&CGAService::SetBlockAllChatMsg, &g_CGAService)); server->start();