From 010220ea258f42220599493adf6f974f45f58760 Mon Sep 17 00:00:00 2001 From: SystematicMania Date: Thu, 27 Mar 2014 22:52:16 -0400 Subject: [PATCH] No longer require clients to be ingame for INetChannelInfo natives (bug 5775, r=psychonic). --- core/smn_player.cpp | 55 ++++++++++++++++++++++--------------- plugins/include/clients.inc | 18 ++++++------ 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/core/smn_player.cpp b/core/smn_player.cpp index 14c447e4..1afae29c 100644 --- a/core/smn_player.cpp +++ b/core/smn_player.cpp @@ -788,9 +788,13 @@ static cell_t GetTimeConnected(IPluginContext *pContext, const cell_t *params) if (!pPlayer) { return pContext->ThrowNativeError("Client index %d is invalid", client); - } else if (!pPlayer->IsInGame()) { - return pContext->ThrowNativeError("Client %d is not in game", client); - } else if (pPlayer->IsFakeClient()) { + } + else if (!pPlayer->IsConnected()) + { + return pContext->ThrowNativeError("Client %d is not connected", client); + } + else if (pPlayer->IsFakeClient()) + { return pContext->ThrowNativeError("Client %d is a bot", client); } @@ -811,9 +815,13 @@ static cell_t GetDataRate(IPluginContext *pContext, const cell_t *params) if (!pPlayer) { return pContext->ThrowNativeError("Client index %d is invalid", client); - } else if (!pPlayer->IsInGame()) { - return pContext->ThrowNativeError("Client %d is not in game", client); - } else if (pPlayer->IsFakeClient()) { + } + else if (!pPlayer->IsConnected()) + { + return pContext->ThrowNativeError("Client %d is not connected", client); + } + else if (pPlayer->IsFakeClient()) + { return pContext->ThrowNativeError("Client %d is a bot", client); } @@ -834,9 +842,13 @@ static cell_t IsTimingOut(IPluginContext *pContext, const cell_t *params) if (!pPlayer) { return pContext->ThrowNativeError("Client index %d is invalid", client); - } else if (!pPlayer->IsInGame()) { - return pContext->ThrowNativeError("Client %d is not in game", client); - } else if (pPlayer->IsFakeClient()) { + } + else if (!pPlayer->IsConnected()) + { + return pContext->ThrowNativeError("Client %d is not connected", client); + } + else if (pPlayer->IsFakeClient()) + { return pContext->ThrowNativeError("Client %d is a bot", client); } @@ -859,9 +871,9 @@ static cell_t GetLatency(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("Client index %d is invalid", client); } - else if (!pPlayer->IsInGame()) + else if (!pPlayer->IsConnected()) { - return pContext->ThrowNativeError("Client %d is not in game", client); + return pContext->ThrowNativeError("Client %d is not connected", client); } else if (pPlayer->IsFakeClient()) { @@ -896,9 +908,9 @@ static cell_t GetAvgLatency(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("Client index %d is invalid", client); } - else if (!pPlayer->IsInGame()) + else if (!pPlayer->IsConnected()) { - return pContext->ThrowNativeError("Client %d is not in game", client); + return pContext->ThrowNativeError("Client %d is not connected", client); } else if (pPlayer->IsFakeClient()) { @@ -933,9 +945,9 @@ static cell_t GetAvgLoss(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("Client index %d is invalid", client); } - else if (!pPlayer->IsInGame()) + else if (!pPlayer->IsConnected()) { - return pContext->ThrowNativeError("Client %d is not in game", client); + return pContext->ThrowNativeError("Client %d is not connected", client); } else if (pPlayer->IsFakeClient()) { @@ -970,9 +982,9 @@ static cell_t GetAvgChoke(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("Client index %d is invalid", client); } - else if (!pPlayer->IsInGame()) + else if (!pPlayer->IsConnected()) { - return pContext->ThrowNativeError("Client %d is not in game", client); + return pContext->ThrowNativeError("Client %d is not connected", client); } else if (pPlayer->IsFakeClient()) { @@ -1007,9 +1019,9 @@ static cell_t GetAvgData(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("Client index %d is invalid", client); } - else if (!pPlayer->IsInGame()) + else if (!pPlayer->IsConnected()) { - return pContext->ThrowNativeError("Client %d is not in game", client); + return pContext->ThrowNativeError("Client %d is not connected", client); } else if (pPlayer->IsFakeClient()) { @@ -1044,9 +1056,9 @@ static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params) { return pContext->ThrowNativeError("Client index %d is invalid", client); } - else if (!pPlayer->IsInGame()) + else if (!pPlayer->IsConnected()) { - return pContext->ThrowNativeError("Client %d is not in game", client); + return pContext->ThrowNativeError("Client %d is not connected", client); } else if (pPlayer->IsFakeClient()) { @@ -1054,7 +1066,6 @@ static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params) } INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client); - if (pInfo == NULL) { return 0; diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index 111da2f7..3627e971 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -620,7 +620,7 @@ native GetClientFrags(client); * * @param client Player's index. * @return Data rate. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native GetClientDataRate(client); @@ -629,7 +629,7 @@ native GetClientDataRate(client); * * @param client Player's index. * @return True if client is timing out, false otherwise. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native bool:IsClientTimingOut(client); @@ -638,7 +638,7 @@ native bool:IsClientTimingOut(client); * * @param client Player's index. * @return Connection time. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientTime(client); @@ -648,7 +648,7 @@ native Float:GetClientTime(client); * @param client Player's index. * @param flow Traffic flowing direction. * @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 connected, or fake client. */ native Float:GetClientLatency(client, NetFlow:flow); @@ -658,7 +658,7 @@ native Float:GetClientLatency(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @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 connected, or fake client. */ native Float:GetClientAvgLatency(client, NetFlow:flow); @@ -668,7 +668,7 @@ native Float:GetClientAvgLatency(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @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 connected, or fake client. */ native Float:GetClientAvgLoss(client, NetFlow:flow); @@ -678,7 +678,7 @@ native Float:GetClientAvgLoss(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @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 connected, or fake client. */ native Float:GetClientAvgChoke(client, NetFlow:flow); @@ -688,7 +688,7 @@ native Float:GetClientAvgChoke(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @return Data flow. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientAvgData(client, NetFlow:flow); @@ -698,7 +698,7 @@ native Float:GetClientAvgData(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @return Packet frequency. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientAvgPackets(client, NetFlow:flow);