mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix: Dummy setting updates
This commit is contained in:
parent
9bf6f3ed6c
commit
9f509eeedb
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
// dummy
|
||||
virtual void DummyDisconnect(const char *pReason) = 0;
|
||||
virtual void DummyConnect(bool Info = true, int NetClient = 1) = 0;
|
||||
virtual void DummyConnect() = 0;
|
||||
virtual bool DummyConnected() = 0;
|
||||
|
||||
virtual void Quit() = 0;
|
||||
|
@ -124,6 +124,7 @@ public:
|
|||
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
||||
|
||||
virtual int SendMsg(CMsgPacker *pMsg, int Flags) = 0;
|
||||
virtual int SendMsgExY(CMsgPacker *pMsg, int Flags, bool System=true, int NetClient=1) = 0;
|
||||
|
||||
template<class T>
|
||||
int SendPackMsg(T *pMsg, int Flags)
|
||||
|
@ -172,6 +173,7 @@ public:
|
|||
virtual void OnActivateEditor() = 0;
|
||||
|
||||
virtual int OnSnapInput(int *pData) = 0;
|
||||
virtual void SendDummyInfo(bool Start) = 0;
|
||||
|
||||
virtual const char *GetItemName(int Type) = 0;
|
||||
virtual const char *Version() = 0;
|
||||
|
|
|
@ -606,14 +606,14 @@ bool CClient::DummyConnected()
|
|||
return m_DummyConnected;
|
||||
}
|
||||
|
||||
void CClient::DummyConnect(bool Info, int NetClient)
|
||||
void CClient::DummyConnect()
|
||||
{
|
||||
if(m_LastDummyConnectTime > GameTick())
|
||||
return;
|
||||
|
||||
char aBuf[512];
|
||||
|
||||
m_NetClient[NetClient].Disconnect(0);
|
||||
m_NetClient[1].Disconnect(0);
|
||||
|
||||
str_copy(aBuf, g_Config.m_UiServerAddress, sizeof(aBuf));
|
||||
|
||||
|
@ -629,41 +629,27 @@ void CClient::DummyConnect(bool Info, int NetClient)
|
|||
|
||||
//connecting to the server
|
||||
m_DummyConnected = 1;
|
||||
m_NetClient[NetClient].Connect(&m_ServerAddress);
|
||||
m_NetClient[1].Connect(&m_ServerAddress);
|
||||
|
||||
// send client info
|
||||
CMsgPacker MsgInfo(NETMSG_INFO);
|
||||
MsgInfo.AddString(GameClient()->NetVersion(), 128);
|
||||
MsgInfo.AddString(g_Config.m_Password, 128);
|
||||
SendMsgExY(&MsgInfo, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, NetClient);
|
||||
SendMsgExY(&MsgInfo, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, 1);
|
||||
|
||||
// update netclient
|
||||
m_NetClient[NetClient].Update();
|
||||
m_NetClient[1].Update();
|
||||
|
||||
// send ready
|
||||
CMsgPacker MsgReady(NETMSG_READY);
|
||||
SendMsgExY(&MsgReady, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, NetClient);
|
||||
SendMsgExY(&MsgReady, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, 1);
|
||||
|
||||
// startinfo
|
||||
if(Info)
|
||||
DummyInfo();
|
||||
{
|
||||
CNetMsg_Cl_StartInfo Msg;
|
||||
Msg.m_pName = g_Config.m_DummyName;
|
||||
Msg.m_pClan = g_Config.m_DummyClan;
|
||||
Msg.m_Country = g_Config.m_DummyCountry;
|
||||
Msg.m_pSkin = g_Config.m_DummySkin;
|
||||
Msg.m_UseCustomColor = g_Config.m_DummyUseCustomColor;
|
||||
Msg.m_ColorBody = g_Config.m_DummyColorBody;
|
||||
Msg.m_ColorFeet = g_Config.m_DummyColorFeet;
|
||||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
SendMsgExY(&Packer, MSGFLAG_VITAL,false, NetClient);
|
||||
}
|
||||
GameClient()->SendDummyInfo(true);
|
||||
|
||||
// send enter game an finish the connection
|
||||
CMsgPacker MsgEnter(NETMSG_ENTERGAME);
|
||||
SendMsgExY(&MsgEnter, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, NetClient);
|
||||
SendMsgExY(&MsgEnter, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, 1);
|
||||
}
|
||||
|
||||
void CClient::DummyDisconnect(const char *pReason)
|
||||
|
@ -706,7 +692,7 @@ void CClient::DummyInfo()
|
|||
CNetMsg_Cl_ChangeInfo Msg;
|
||||
Msg.m_pName = g_Config.m_DummyName;
|
||||
Msg.m_pClan = g_Config.m_DummyClan;
|
||||
Msg.m_Country = g_Config.m_PlayerCountry;
|
||||
Msg.m_Country = g_Config.m_DummyCountry;
|
||||
Msg.m_pSkin = g_Config.m_DummySkin;
|
||||
Msg.m_UseCustomColor = g_Config.m_DummyUseCustomColor;
|
||||
Msg.m_ColorBody = g_Config.m_DummyColorBody;
|
||||
|
@ -2297,7 +2283,7 @@ void CClient::Con_Disconnect(IConsole::IResult *pResult, void *pUserData)
|
|||
void CClient::Con_DummyConnect(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CClient *pSelf = (CClient *)pUserData;
|
||||
pSelf->DummyConnect(false);
|
||||
pSelf->DummyConnect();
|
||||
}
|
||||
|
||||
void CClient::Con_DummyDisconnect(IConsole::IResult *pResult, void *pUserData)
|
||||
|
|
|
@ -202,6 +202,7 @@ public:
|
|||
|
||||
// ----- send functions -----
|
||||
virtual int SendMsg(CMsgPacker *pMsg, int Flags);
|
||||
virtual int SendMsgExY(CMsgPacker *pMsg, int Flags, bool System=true, int NetClient=1);
|
||||
|
||||
int SendMsgEx(CMsgPacker *pMsg, int Flags, bool System=true);
|
||||
void SendInfo();
|
||||
|
@ -240,12 +241,11 @@ public:
|
|||
virtual void Disconnect();
|
||||
|
||||
virtual void DummyDisconnect(const char *pReason);
|
||||
virtual void DummyConnect(bool Info = true, int NetClient = 1);
|
||||
virtual void DummyConnect();
|
||||
virtual bool DummyConnected();
|
||||
void DummyInfo();
|
||||
int m_DummyConnected;
|
||||
int m_LastDummyConnectTime;
|
||||
int SendMsgExY(CMsgPacker *pMsg, int Flags, bool System=true, int NetClient=1);
|
||||
|
||||
virtual void GetServerInfo(CServerInfo *pServerInfo);
|
||||
void ServerInfoRequest();
|
||||
|
|
|
@ -59,6 +59,7 @@ CMenus::CMenus()
|
|||
m_NeedRestartGraphics = false;
|
||||
m_NeedRestartSound = false;
|
||||
m_NeedSendinfo = false;
|
||||
m_NeedSendDummyinfo = false;
|
||||
m_MenuActive = true;
|
||||
m_UseMouseButtons = true;
|
||||
|
||||
|
@ -1352,6 +1353,12 @@ void CMenus::SetActive(bool Active)
|
|||
m_NeedSendinfo = false;
|
||||
}
|
||||
|
||||
if(m_NeedSendDummyinfo)
|
||||
{
|
||||
m_pClient->SendDummyInfo(false);
|
||||
m_NeedSendDummyinfo = false;
|
||||
}
|
||||
|
||||
if(Client()->State() == IClient::STATE_ONLINE)
|
||||
{
|
||||
m_pClient->OnRelease();
|
||||
|
|
|
@ -162,6 +162,7 @@ class CMenus : public CComponent
|
|||
bool m_NeedRestartGraphics;
|
||||
bool m_NeedRestartSound;
|
||||
bool m_NeedSendinfo;
|
||||
bool m_NeedSendDummyinfo;
|
||||
int m_SettingPlayerPage;
|
||||
|
||||
//
|
||||
|
|
|
@ -123,7 +123,7 @@ void CMenus::RenderGame(CUIRect MainView)
|
|||
{
|
||||
if(!Client()->DummyConnected())
|
||||
{
|
||||
Client()->DummyConnect(false);
|
||||
Client()->DummyConnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -210,7 +210,10 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
UI()->DoLabelScaled(&Label, aBuf, 14.0, -1);
|
||||
static float s_OffsetName = 0.0f;
|
||||
if(DoEditBox(Name, &Button, Name, sizeof(g_Config.m_PlayerName), 14.0f, &s_OffsetName))
|
||||
m_NeedSendinfo = true;
|
||||
if(s_Dummy)
|
||||
m_NeedSendDummyinfo = true;
|
||||
else
|
||||
m_NeedSendinfo = true;
|
||||
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowKillMessages, Localize("Dummy Settings"), s_Dummy, &Dummy))
|
||||
{
|
||||
|
@ -226,7 +229,10 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
UI()->DoLabelScaled(&Label, aBuf, 14.0, -1);
|
||||
static float s_OffsetClan = 0.0f;
|
||||
if(DoEditBox(Clan, &Button, Clan, sizeof(g_Config.m_PlayerClan), 14.0f, &s_OffsetClan))
|
||||
m_NeedSendinfo = true;
|
||||
if(s_Dummy)
|
||||
m_NeedSendDummyinfo = true;
|
||||
else
|
||||
m_NeedSendinfo = true;
|
||||
|
||||
// country flag selector
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
|
@ -260,7 +266,10 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
if(OldSelected != NewSelected)
|
||||
{
|
||||
*Country = m_pClient->m_pCountryFlags->GetByIndex(NewSelected)->m_CountryCode;
|
||||
m_NeedSendinfo = true;
|
||||
if(s_Dummy)
|
||||
m_NeedSendDummyinfo = true;
|
||||
else
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +337,10 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
if(DoButton_CheckBox(&ColorBody, Localize("Custom colors"), *UseCustomColor, &Button))
|
||||
{
|
||||
*UseCustomColor = *UseCustomColor?0:1;
|
||||
m_NeedSendinfo = true;
|
||||
if(s_Dummy)
|
||||
m_NeedSendDummyinfo = true;
|
||||
else
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
if(DoButton_CheckBox(&g_Config.m_ClShowSpecialSkins, Localize("Show Bandana Brothers skins"), g_Config.m_ClShowSpecialSkins, &Button2))
|
||||
{
|
||||
|
@ -381,7 +393,12 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
}
|
||||
|
||||
if(PrevColor != Color)
|
||||
m_NeedSendinfo = true;
|
||||
{
|
||||
if(s_Dummy)
|
||||
m_NeedSendDummyinfo = true;
|
||||
else
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
|
||||
*paColors[i] = Color;
|
||||
}
|
||||
|
@ -455,7 +472,10 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
if(OldSelected != NewSelected)
|
||||
{
|
||||
mem_copy(Skin, s_paSkinList[NewSelected]->m_aName, sizeof(g_Config.m_PlayerSkin));
|
||||
m_NeedSendinfo = true;
|
||||
if(s_Dummy)
|
||||
m_NeedSendDummyinfo = true;
|
||||
else
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -235,6 +235,14 @@ void CGameClient::OnConsoleInit()
|
|||
Console()->Chain("player_color_feet", ConchainSpecialInfoupdate, this);
|
||||
Console()->Chain("player_skin", ConchainSpecialInfoupdate, this);
|
||||
|
||||
Console()->Chain("dummy_name", ConchainSpecialDummyInfoupdate, this);
|
||||
Console()->Chain("dummy_clan", ConchainSpecialDummyInfoupdate, this);
|
||||
Console()->Chain("dummy_country", ConchainSpecialDummyInfoupdate, this);
|
||||
Console()->Chain("dummy_use_custom_color", ConchainSpecialDummyInfoupdate, this);
|
||||
Console()->Chain("dummy_color_body", ConchainSpecialDummyInfoupdate, this);
|
||||
Console()->Chain("dummy_color_feet", ConchainSpecialDummyInfoupdate, this);
|
||||
Console()->Chain("dummy_skin", ConchainSpecialDummyInfoupdate, this);
|
||||
|
||||
//
|
||||
m_SuppressEvents = false;
|
||||
}
|
||||
|
@ -560,7 +568,8 @@ void CGameClient::OnRender()
|
|||
g_Config.m_PlayerColorBody != m_aClients[m_Snap.m_LocalClientID].m_ColorBody ||
|
||||
g_Config.m_PlayerColorFeet != m_aClients[m_Snap.m_LocalClientID].m_ColorFeet)))
|
||||
{
|
||||
SendInfo(false);
|
||||
if (!g_Config.m_ClDummy)
|
||||
SendInfo(false);
|
||||
}
|
||||
m_LastSendInfo = 0;
|
||||
}
|
||||
|
@ -1307,7 +1316,9 @@ void CGameClient::SendInfo(bool Start)
|
|||
Msg.m_UseCustomColor = g_Config.m_PlayerUseCustomColor;
|
||||
Msg.m_ColorBody = g_Config.m_PlayerColorBody;
|
||||
Msg.m_ColorFeet = g_Config.m_PlayerColorFeet;
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1319,7 +1330,9 @@ void CGameClient::SendInfo(bool Start)
|
|||
Msg.m_UseCustomColor = g_Config.m_PlayerUseCustomColor;
|
||||
Msg.m_ColorBody = g_Config.m_PlayerColorBody;
|
||||
Msg.m_ColorFeet = g_Config.m_PlayerColorFeet;
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 0);
|
||||
|
||||
// activate timer to resend the info if it gets filtered
|
||||
if(!m_LastSendInfo || m_LastSendInfo+time_freq()*5 < time_get())
|
||||
|
@ -1327,6 +1340,42 @@ void CGameClient::SendInfo(bool Start)
|
|||
}
|
||||
}
|
||||
|
||||
void CGameClient::SendDummyInfo(bool Start)
|
||||
{
|
||||
if(Start)
|
||||
{
|
||||
CNetMsg_Cl_StartInfo Msg;
|
||||
Msg.m_pName = g_Config.m_DummyName;
|
||||
Msg.m_pClan = g_Config.m_DummyClan;
|
||||
Msg.m_Country = g_Config.m_DummyCountry;
|
||||
Msg.m_pSkin = g_Config.m_DummySkin;
|
||||
Msg.m_UseCustomColor = g_Config.m_DummyUseCustomColor;
|
||||
Msg.m_ColorBody = g_Config.m_DummyColorBody;
|
||||
Msg.m_ColorFeet = g_Config.m_DummyColorFeet;
|
||||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
CNetMsg_Cl_ChangeInfo Msg;
|
||||
Msg.m_pName = g_Config.m_DummyName;
|
||||
Msg.m_pClan = g_Config.m_DummyClan;
|
||||
Msg.m_Country = g_Config.m_DummyCountry;
|
||||
Msg.m_pSkin = g_Config.m_DummySkin;
|
||||
Msg.m_UseCustomColor = g_Config.m_DummyUseCustomColor;
|
||||
Msg.m_ColorBody = g_Config.m_DummyColorBody;
|
||||
Msg.m_ColorFeet = g_Config.m_DummyColorFeet;
|
||||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 1);
|
||||
|
||||
// activate timer to resend the info if it gets filtered
|
||||
//if(!m_LastSendInfo || m_LastSendInfo+time_freq()*5 < time_get())
|
||||
// m_LastSendInfo = time_get();
|
||||
}
|
||||
}
|
||||
|
||||
void CGameClient::SendKill(int ClientID)
|
||||
{
|
||||
CNetMsg_Cl_Kill Msg;
|
||||
|
@ -1350,6 +1399,13 @@ void CGameClient::ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pU
|
|||
((CGameClient*)pUserData)->SendInfo(false);
|
||||
}
|
||||
|
||||
void CGameClient::ConchainSpecialDummyInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
{
|
||||
pfnCallback(pResult, pCallbackUserData);
|
||||
if(pResult->NumArguments())
|
||||
((CGameClient*)pUserData)->SendDummyInfo(false);
|
||||
}
|
||||
|
||||
IGameClient *CreateGameClient()
|
||||
{
|
||||
return &g_GameClient;
|
||||
|
|
|
@ -67,6 +67,7 @@ class CGameClient : public IGameClient
|
|||
static void ConKill(IConsole::IResult *pResult, void *pUserData);
|
||||
|
||||
static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainSpecialDummyInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
||||
public:
|
||||
IKernel *Kernel() { return IInterface::Kernel(); }
|
||||
|
@ -236,6 +237,7 @@ public:
|
|||
// TODO: move these
|
||||
void SendSwitchTeam(int Team);
|
||||
void SendInfo(bool Start);
|
||||
virtual void SendDummyInfo(bool Start);
|
||||
void SendKill(int ClientID);
|
||||
|
||||
// pointers to all systems
|
||||
|
|
Loading…
Reference in a new issue