Beispiel #1
0
void KGameChat::addMessage(int fromId, const QString& text)
{
 if (!d->mGame) {
	qCWarning(GAMES_PRIVATE_KGAME) << "no KGame object has been set";
	addMessage(i18n("Player %1", fromId), text);
 } else {
	KPlayer* p = d->mGame->findPlayer(fromId);
	if (p) {
		qCDebug(GAMES_PRIVATE_KGAME) << "adding message of player" << p->name() << "id=" << fromId;
		addMessage(p->name(), text);
	} else {
		qCWarning(GAMES_PRIVATE_KGAME) << "Could not find player id" << fromId;
		addMessage(i18nc("Unknown player", "Unknown"), text);
	}
 }
}
Beispiel #2
0
KPlayer* KAccount::getPlayer(const char* serverName, const char* player)
{
    ServerMap::iterator it = m_serverMap.find(serverName);
    if(it == m_serverMap.end())
        return NULL;

    KServer* pServer = it->second;
    int n = pServer->playerCount();
    for(int i=0; i<n; i++)
    {
        KPlayer* p = pServer->playerAt(i);
        if(stricmp(p->name(), player) == 0)
            return p;
    }
    return NULL;
}