Ejemplo n.º 1
0
static void loadChallenges(cJSON *missionsJSON)
{
	Mission *mission;
	Challenge *challenge;
	cJSON *missionJSON, *challengeJSON;
	int type, value;

	if (missionsJSON)
	{
		for (missionJSON = missionsJSON->child ; missionJSON != NULL ; missionJSON = missionJSON->next)
		{
			mission = getMission(cJSON_GetObjectItem(missionJSON, "filename")->valuestring);

			for (challengeJSON = cJSON_GetObjectItem(missionJSON, "challenges")->child ; challengeJSON != NULL ; challengeJSON = challengeJSON->next)
			{
				type = lookup(cJSON_GetObjectItem(challengeJSON, "type")->valuestring);
				value = cJSON_GetObjectItem(challengeJSON, "value")->valueint;

				challenge = getChallenge(mission, type, value);

				if (challenge)
				{
					challenge->passed = cJSON_GetObjectItem(challengeJSON, "passed")->valueint;
				}
			}
		}
	}
}
Ejemplo n.º 2
0
Archivo: load.c Proyecto: nnesse/tbftss
static void loadChallenges(Mission *mission, cJSON *challengesCJSON)
{
	Challenge *challenge;
	cJSON *challengeCJSON;
	
	for (challengeCJSON = challengesCJSON->child ; challengeCJSON != NULL ; challengeCJSON = challengeCJSON->next)
	{
		challenge = getChallenge(mission, lookup(cJSON_GetObjectItem(challengeCJSON, "type")->valuestring));
		
		if (!challenge)
		{
			printf("Couldn't find challenge to update\n");
			continue;
		}
		
		challenge->passed = cJSON_GetObjectItem(challengeCJSON, "passed")->valueint;
	}
}
Ejemplo n.º 3
0
QVariantList Communicator::authParams()
{
    QVariantList params;
    QByteArray challenge = getChallenge();
    if (challenge.size() == 0)
        return params;

    // Encode user credentials.
    // From LJ docs: "For your response, you then build a MD5 hex digest of the
    // formula (challenge + MD5_hex(password))...".
    QByteArray passMd5 = QCryptographicHash::hash(m_password.toUtf8(),
                                                  QCryptographicHash::Md5).toHex();
    QByteArray authStr = QCryptographicHash::hash(challenge + passMd5,
                                                  QCryptographicHash::Md5).toHex();

    QMap<QString, QVariant> requestStruct;
    requestStruct["username"] = m_userName;
    requestStruct["auth_method"] = "challenge";
    requestStruct["auth_challenge"] = challenge;
    requestStruct["auth_response"] = authStr;

    params.push_back(requestStruct);
    return params;
}
Ejemplo n.º 4
0
/** Set the current challenge (or NULL if no challenge is done).
 *  \param challenge Pointer to the challenge (or NULL)
 */
void GameSlot::setCurrentChallenge(const std::string &challenge_id)
{
    m_current_challenge = challenge_id=="" ? NULL
                                           : getChallenge(challenge_id);
}   // setCurrentChallenge