Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #30

Merged
merged 9 commits into from
Apr 27, 2019
4 changes: 2 additions & 2 deletions src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);

char aBuf[256];
str_format(aBuf, sizeof(aBuf), "player is ready. ClientID=%x addr=%s", ClientID, aAddrStr);
str_format(aBuf, sizeof(aBuf), "player is ready. ClientID=%d addr=%s", ClientID, aAddrStr);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);

bool ConnectAsSpec = m_aClients[ClientID].m_State == CClient::STATE_CONNECTING_AS_SPEC;
Expand All @@ -921,7 +921,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);

char aBuf[256];
str_format(aBuf, sizeof(aBuf), "player has entered the game. ClientID=%x addr=%s", ClientID, aAddrStr);
str_format(aBuf, sizeof(aBuf), "player has entered the game. ClientID=%d addr=%s", ClientID, aAddrStr);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
m_aClients[ClientID].m_State = CClient::STATE_INGAME;
SendServerInfo(ClientID);
Expand Down
57 changes: 29 additions & 28 deletions src/game/client/components/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ CChat::CChat()
};
const int CommandsCount = sizeof(s_aapCommands) / sizeof(CChatCommand);
m_pCommands = new CChatCommands(s_aapCommands, CommandsCount);

OnReset();
}

CChat::~CChat()
Expand All @@ -46,33 +44,36 @@ CChat::~CChat()

void CChat::OnReset()
{
for(int i = 0; i < MAX_LINES; i++)
if(Client()->State() == IClient::STATE_OFFLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
m_aLines[i].m_Time = 0;
m_aLines[i].m_aText[0] = 0;
m_aLines[i].m_aName[0] = 0;
}

m_Mode = CHAT_NONE;
// m_WhisperTarget = -1;
m_LastWhisperFrom = -1;
m_ReverseCompletion = false;
m_Show = false;
m_InputUpdate = false;
m_ChatStringOffset = 0;
m_CompletionChosen = -1;
m_CompletionFav = -1;
m_aCompletionBuffer[0] = 0;
m_PlaceholderOffset = 0;
m_PlaceholderLength = 0;
m_pHistoryEntry = 0x0;
m_PendingChatCounter = 0;
m_LastChatSend = 0;
m_IgnoreCommand = false;
m_pCommands->Reset();
for(int i = 0; i < MAX_LINES; i++)
{
m_aLines[i].m_Time = 0;
m_aLines[i].m_aText[0] = 0;
m_aLines[i].m_aName[0] = 0;
}

for(int i = 0; i < CHAT_NUM; ++i)
m_aLastSoundPlayed[i] = 0;
m_Mode = CHAT_NONE;
// m_WhisperTarget = -1;
m_LastWhisperFrom = -1;
m_ReverseCompletion = false;
m_Show = false;
m_InputUpdate = false;
m_ChatStringOffset = 0;
m_CompletionChosen = -1;
m_CompletionFav = -1;
m_aCompletionBuffer[0] = 0;
m_PlaceholderOffset = 0;
m_PlaceholderLength = 0;
m_pHistoryEntry = 0x0;
m_PendingChatCounter = 0;
m_LastChatSend = 0;
m_IgnoreCommand = false;
m_pCommands->Reset();

for(int i = 0; i < CHAT_NUM; ++i)
m_aLastSoundPlayed[i] = 0;
}
}

void CChat::OnRelease()
Expand Down Expand Up @@ -178,7 +179,7 @@ void CChat::OnConsoleInit()

bool CChat::OnInput(IInput::CEvent Event)
{
if(m_Mode == CHAT_NONE)
if(m_Mode == CHAT_NONE || Client()->State() != Client()->STATE_ONLINE)
return false;

if(Event.m_Flags&IInput::FLAG_PRESS && Event.m_Key == KEY_ESCAPE)
Expand Down
28 changes: 23 additions & 5 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,11 @@ void CGameContext::SendSkinChange(int ClientID, int TargetID)
{
for(int i = 0; i < MAX_PLAYERS; ++i)
{
if(m_apPlayers[i] && !m_apPlayers[i]->IsDummy())
SendSkinChange(ClientID, i);
SendSkinChange(ClientID, i);
}
}
else if(!m_apPlayers[TargetID] || m_apPlayers[TargetID]->IsDummy() || !Server()->ClientIngame(TargetID))
return;
else if(Server()->GetClientVersion(TargetID) >= MIN_SKINCHANGE_CLIENTVERSION)//Send normal message
{
CNetMsg_Sv_SkinChange Msg;
Expand Down Expand Up @@ -911,9 +912,9 @@ void CGameContext::SetStartTeam(int ClientID)
{
//count people per teamid
std::map<int, int> teamcounts;
for(int i = 0; i < MAX_CLIENTS; i++)
for(int i = 0; i < MAX_PLAYERS; i++)
{
if(m_apPlayers[i])
if(m_apPlayers[i] && m_apPlayers[i]->GetTeamID() >= 0 && Server()->ClientIngame(i))
{
teamcounts[m_apPlayers[i]->GetTeamID()]++;
}
Expand All @@ -940,6 +941,9 @@ void CGameContext::SetStartTeam(int ClientID)
int randomteam = resultteams[rand()%(resultteams.size())];
m_apPlayers[ClientID]->SetTeamID(randomteam);
copy_skin(m_apPlayers[ClientID]->m_TeeInfos, m_apPlayers[randomteam]->m_TeeInfosOriginal);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "set startteam of player '%s' to '%d'", Server()->ClientName(ClientID), randomteam);
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
}
}

Expand Down Expand Up @@ -1307,7 +1311,21 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
pPlayer->m_TeeInfosOriginal.m_aSkinPartColors[p] = pMsg->m_aSkinPartColors[p];
}
ApplyStartColors(ClientID, pPlayer->m_TeeInfosOriginal);//does change feet and body colors of original skin
SendChat(ClientID, CHAT_ALL, ClientID, "Your skinchange will apply next round");

CNetMsg_Sv_Chat Msg;
Msg.m_Mode = CHAT_ALL;
Msg.m_ClientID = -1;

Msg.m_TargetID = ClientID;

Msg.m_pMessage = "Your skinchange will apply next round";
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID);

char aBuf[128];
str_format(aBuf, sizeof(aBuf), "Player '%s' updated skin", Server()->ClientName(ClientID));
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);

//SendChat(-1, CHAT_ALL, ClientID, "Your skinchange will apply next round");
// update all clients//don't update, the update will apply next round
/*for(int i = 0; i < MAX_CLIENTS; ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
#define GAME_NETVERSION "0.7 802f1be60a05665f"
#define CLIENT_VERSION 0x0703
static const char GAME_RELEASE_VERSION[8] = "0.7.3.1";
#define CATCH_VERSION "1.0.5"
#define CATCH_VERSION "1.0.6"
#endif