core/ConCmdManager.cpp
changeset 1119 9e3486386c04
parent 978 54782a83a1ef
child 1231 17badaf66ce4
     1.1 --- a/core/ConCmdManager.cpp	Sun Jul 15 17:22:47 2007 +0000
     1.2 +++ b/core/ConCmdManager.cpp	Sun Jul 15 18:51:25 2007 +0000
     1.3 @@ -306,9 +306,8 @@
     1.4  	}
     1.5  }
     1.6  
     1.7 -bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
     1.8 +bool ConCmdManager::CheckCommandAccess(int client, const char *cmd, FlagBits cmdflags)
     1.9  {
    1.10 -	FlagBits cmdflags = pAdmin->eflags;
    1.11  	if (cmdflags == 0)
    1.12  	{
    1.13  		return true;
    1.14 @@ -321,7 +320,9 @@
    1.15  	}
    1.16  
    1.17  	CPlayer *player = g_Players.GetPlayerByIndex(client);
    1.18 -	if (!player)
    1.19 +	if (!player 
    1.20 +		|| player->GetEdict() == NULL
    1.21 +		|| player->IsFakeClient())
    1.22  	{
    1.23  		return false;
    1.24  	}
    1.25 @@ -370,11 +371,17 @@
    1.26  		}
    1.27  	}
    1.28  
    1.29 -	if (player->IsFakeClient()
    1.30 -		|| player->GetEdict() == NULL)
    1.31 +	return false;
    1.32 +}
    1.33 +
    1.34 +bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
    1.35 +{
    1.36 +	if (CheckCommandAccess(client, cmd, pAdmin->eflags))
    1.37  	{
    1.38 -		return false;
    1.39 +		return true;
    1.40  	}
    1.41 +
    1.42 +	edict_t *pEdict = engine->PEntityOfEntIndex(client);
    1.43  	
    1.44  	/* If we got here, the command failed... */
    1.45  	char buffer[128];
    1.46 @@ -389,7 +396,7 @@
    1.47  	{
    1.48  		char fullbuffer[192];
    1.49  		snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
    1.50 -		engine->ClientPrintf(player->GetEdict(), fullbuffer);
    1.51 +		engine->ClientPrintf(pEdict, fullbuffer);
    1.52  	} else if (replyto == SM_REPLY_CHAT) {
    1.53  		char fullbuffer[192];
    1.54  		snprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.", buffer);
    1.55 @@ -495,6 +502,7 @@
    1.56  
    1.57  	/* Finally, add the hook */
    1.58  	pInfo->conhooks.push_back(pHook);
    1.59 +	pInfo->admin = *(pHook->pAdmin);
    1.60  
    1.61  	/* Now add to the plugin */
    1.62  	CmdList *pList;
    1.63 @@ -636,6 +644,7 @@
    1.64  				} else {
    1.65  					pHook->pAdmin->eflags = pHook->pAdmin->flags;
    1.66  				}
    1.67 +				pInfo->admin = *(pHook->pAdmin);
    1.68  			}
    1.69  		}
    1.70  	} else if (type == Override_CommandGroup) {
    1.71 @@ -665,6 +674,7 @@
    1.72  					} else {
    1.73  						pHook->pAdmin->eflags = pHook->pAdmin->flags;
    1.74  					}
    1.75 +					pInfo->admin = *(pHook->pAdmin);
    1.76  				}
    1.77  			}
    1.78  		}