P2PSendSwitchbot: No switchbot found to transfer. (pid 28 source_port 13000 target_port 16000)
error appears when you change ch,port etc
new_switchbot.cpp
1
void CSwitchbotManager::Initialize()
{
m_map_Switchbots.clear();
}
to
void CSwitchbotManager::Initialize()
{
for (auto& it : m_map_Switchbots)
{
delete it.second;
}
m_map_Switchbots.clear();
}
2
void CSwitchbotManager::P2PSendSwitchbot(DWORD player_id, WORD wTargetPort)
{
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
if (!pkSwitchbot)
{
sys_err("No switchbot found to transfer. (pid %d source_port %d target_port %d)", player_id, mother_port, wTargetPort);
return;
}
pkSwitchbot->Pause();
to
void CSwitchbotManager::P2PSendSwitchbot(DWORD player_id, uint16_t wTargetPort)
{
CSwitchbot* pkSwitchbot = FindSwitchbot(player_id);
if (!pkSwitchbot)
{
return;
}
pkSwitchbot->Pause();
m_map_Switchbots.erase(player_id);
TPacketGGSwitchbot pack;
pack.wPort = wTargetPort;
pack.table = pkSwitchbot->GetTable();
delete pkSwitchbot;
pkSwitchbot = nullptr;
P2P_MANAGER::Instance().Send(&pack, sizeof(pack));
}