Check return value of GetPlayerNetInfo (bug 4315, r=fyren).
This commit is contained in:
		
							parent
							
								
									55205e631b
								
							
						
					
					
						commit
						fc88cd3cb1
					
				@ -1619,9 +1619,23 @@ void CPlayer::Kick(const char *str)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	MarkAsBeingKicked();
 | 
						MarkAsBeingKicked();
 | 
				
			||||||
	INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
 | 
						INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
 | 
				
			||||||
 | 
						if (pNetChan == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							/* What does this even mean? Hell if I know. */
 | 
				
			||||||
 | 
							int userid = GetUserId();
 | 
				
			||||||
 | 
							if (userid > 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								char buffer[255];
 | 
				
			||||||
 | 
								UTIL_Format(buffer, sizeof(buffer), "kickid %d %s\n", userid, str);
 | 
				
			||||||
 | 
								engine->ServerCommand(buffer);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		IClient *pClient = static_cast<IClient *>(pNetChan->GetMsgHandler());
 | 
							IClient *pClient = static_cast<IClient *>(pNetChan->GetMsgHandler());
 | 
				
			||||||
		pClient->Disconnect("%s", str);
 | 
							pClient->Disconnect("%s", str);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CPlayer::Authorize_Post()
 | 
					void CPlayer::Authorize_Post()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -200,7 +200,7 @@ static void ReplicateConVar(ConVar *pConVar)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if (pPlayer && pPlayer->IsInGame() && !pPlayer->IsFakeClient())
 | 
							if (pPlayer && pPlayer->IsInGame() && !pPlayer->IsFakeClient())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(i));
 | 
								if (INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(i)))
 | 
				
			||||||
				netchan->SendData(buffer);
 | 
									netchan->SendData(buffer);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -1319,6 +1319,11 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1]));
 | 
						INetChannel *netchan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(params[1]));
 | 
				
			||||||
 | 
						if (netchan == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	netchan->SendData(buffer);
 | 
						netchan->SendData(buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
 | 
				
			|||||||
@ -720,6 +720,10 @@ static cell_t GetTimeConnected(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return sp_ftoc(pInfo->GetTimeConnected());
 | 
						return sp_ftoc(pInfo->GetTimeConnected());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -739,6 +743,10 @@ static cell_t GetDataRate(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return pInfo->GetDataRate();
 | 
						return pInfo->GetDataRate();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -758,6 +766,10 @@ static cell_t IsTimingOut(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return pInfo->IsTimingOut() ? 1 : 0;
 | 
						return pInfo->IsTimingOut() ? 1 : 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -782,6 +794,10 @@ static cell_t GetLatency(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return sp_ftoc(-1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (params[2] == MAX_FLOWS)
 | 
						if (params[2] == MAX_FLOWS)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -815,6 +831,10 @@ static cell_t GetAvgLatency(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return sp_ftoc(-1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (params[2] == MAX_FLOWS)
 | 
						if (params[2] == MAX_FLOWS)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -848,6 +868,10 @@ static cell_t GetAvgLoss(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return sp_ftoc(-1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (params[2] == MAX_FLOWS)
 | 
						if (params[2] == MAX_FLOWS)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -881,6 +905,10 @@ static cell_t GetAvgChoke(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return sp_ftoc(-1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (params[2] == MAX_FLOWS)
 | 
						if (params[2] == MAX_FLOWS)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -914,6 +942,10 @@ static cell_t GetAvgData(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (params[2] == MAX_FLOWS)
 | 
						if (params[2] == MAX_FLOWS)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -948,6 +980,11 @@ static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
						INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (pInfo == NULL)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (params[2] == MAX_FLOWS)
 | 
						if (params[2] == MAX_FLOWS)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		value = pInfo->GetAvgPackets(FLOW_INCOMING) + pInfo->GetAvgPackets(FLOW_OUTGOING);
 | 
							value = pInfo->GetAvgPackets(FLOW_INCOMING) + pInfo->GetAvgPackets(FLOW_OUTGOING);
 | 
				
			||||||
 | 
				
			|||||||
@ -601,7 +601,7 @@ native Float:GetClientTime(client);
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @param client		Player's index.
 | 
					 * @param client		Player's index.
 | 
				
			||||||
 * @param flow			Traffic flowing direction.
 | 
					 * @param flow			Traffic flowing direction.
 | 
				
			||||||
 * @return				Latency.
 | 
					 * @return				Latency, or -1 if network info is not available.
 | 
				
			||||||
 * @error				Invalid client index, client not in game, or fake client.
 | 
					 * @error				Invalid client index, client not in game, or fake client.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
native Float:GetClientLatency(client, NetFlow:flow);
 | 
					native Float:GetClientLatency(client, NetFlow:flow);
 | 
				
			||||||
@ -611,7 +611,7 @@ native Float:GetClientLatency(client, NetFlow:flow);
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @param client		Player's index.
 | 
					 * @param client		Player's index.
 | 
				
			||||||
 * @param flow			Traffic flowing direction.
 | 
					 * @param flow			Traffic flowing direction.
 | 
				
			||||||
 * @return				Average latency.
 | 
					 * @return				Latency, or -1 if network info is not available.
 | 
				
			||||||
 * @error				Invalid client index, client not in game, or fake client.
 | 
					 * @error				Invalid client index, client not in game, or fake client.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
native Float:GetClientAvgLatency(client, NetFlow:flow);
 | 
					native Float:GetClientAvgLatency(client, NetFlow:flow);
 | 
				
			||||||
@ -621,7 +621,7 @@ native Float:GetClientAvgLatency(client, NetFlow:flow);
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @param client		Player's index.
 | 
					 * @param client		Player's index.
 | 
				
			||||||
 * @param flow			Traffic flowing direction.
 | 
					 * @param flow			Traffic flowing direction.
 | 
				
			||||||
 * @return				Average packet loss.
 | 
					 * @return				Average packet loss, or -1 if network info is not available.
 | 
				
			||||||
 * @error				Invalid client index, client not in game, or fake client.
 | 
					 * @error				Invalid client index, client not in game, or fake client.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
native Float:GetClientAvgLoss(client, NetFlow:flow);
 | 
					native Float:GetClientAvgLoss(client, NetFlow:flow);
 | 
				
			||||||
@ -631,7 +631,7 @@ native Float:GetClientAvgLoss(client, NetFlow:flow);
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @param client		Player's index.
 | 
					 * @param client		Player's index.
 | 
				
			||||||
 * @param flow			Traffic flowing direction.
 | 
					 * @param flow			Traffic flowing direction.
 | 
				
			||||||
 * @return				Average packet choke.
 | 
					 * @return				Average packet loss, or -1 if network info is not available.
 | 
				
			||||||
 * @error				Invalid client index, client not in game, or fake client.
 | 
					 * @error				Invalid client index, client not in game, or fake client.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
native Float:GetClientAvgChoke(client, NetFlow:flow);
 | 
					native Float:GetClientAvgChoke(client, NetFlow:flow);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user