Example #1
0
File: g_api.c Project: ETrun/ETrun
/**
 * Record handler
 */
static void *recordHandler(void *data) {
	int            code;
	struct query_s *queryStruct = (struct query_s *)data;
	gentity_t      *ent         = queryStruct->ent;
	int            timerunNum;

	code = API_query(queryStruct->cmd, queryStruct->result, queryStruct->query, sizeof (queryStruct->query));

	timerunNum = ent->client->sess.currentTimerunNum;

	switch (code) {
	case 1001: // PB
		if (ent->client->sess.timerunCheckpointWereLoaded[timerunNum]) {
			memcpy(ent->client->sess.timerunBestCheckpointTimes[timerunNum], ent->client->sess.timerunCheckpointTimes, sizeof (ent->client->sess.timerunCheckpointTimes));
		}
		AP(va("print \"%s^w: %s\n\"", GAME_VERSION_COLORED, queryStruct->result));

		// Nico, keep this demo if autodemo is enabled
		if (ent->client->pers.autoDemo) {
			saveDemo(ent);
		}
		break;

	case 1002: // SB
	case 1003: // SB but player was already rec holder
	case 1004: // SB was tied
		if (ent->client->sess.timerunCheckpointWereLoaded[timerunNum]) {
			memcpy(ent->client->sess.timerunBestCheckpointTimes[timerunNum], ent->client->sess.timerunCheckpointTimes, sizeof (ent->client->sess.timerunCheckpointTimes));
		}
		AP(va("bp \"^w%s\n\"", queryStruct->result));

		// Nico, keep this demo if autodemo is enabled
		if (ent->client->pers.autoDemo) {
			saveDemo(ent);
		}
		break;

	case 1005: // Slow time
		CP(va("print \"%s^w: %s\n\"", GAME_VERSION_COLORED, queryStruct->result));

		// Nico, check player keepDemo setting to see if we keep this one or not
		if (ent->client->pers.autoDemo && ent->client->pers.keepAllDemos) {
			saveDemo(ent);
		}
		break;

	default: // Error
		CP(va("print \"%s^w: error: %s\n\"", GAME_VERSION_COLORED, queryStruct->result));
		break;
	}

	free(queryStruct->result);
	free(queryStruct);

	// Decrease global active thread counter
	activeThreadsCounter--;
	G_DPrintf("%s: decreasing threads counter to %d\n", GAME_VERSION, activeThreadsCounter);

	return NULL;
}
Example #2
0
/* QUAKED target_stopTimer (1 0 0) (-8 -8 -8) (8 8 8)
 * timer stop
 *
 * "name"				timerun name
 * "minCheckpoints"		minimal passed checkpoints to activate this stoptimer
 */
void target_stoptimer_use(gentity_t *self, gentity_t *other, gentity_t *activator) {
	int       time;
	gclient_t *client = activator->client;
	int       timerunNum;

	// Nico, silent GCC
	(void)other;

	if (!client->sess.timerunActive) {
		return;
	}

	// don't stop the time if this isn't a corresponding stoptimer
	if (Q_stricmp(self->timerunName, client->sess.currentTimerun)) {
		return;
	}

	timerunNum = client->sess.currentTimerunNum;

	// required number of checkpoints passed?
	if (client->sess.timerunCheckpointsPassed < self->count) {
		CPx(activator - g_entities, va("cpm \"^d%s^f:^1 Minimum checkpoints not passed (%d/%d)\n\"", client->sess.currentTimerun, client->sess.timerunCheckpointsPassed, self->count));
		notify_timerun_stop(activator, 0);
		client->sess.timerunActive = qfalse;

		return;
	}

	time = client->sess.timerunLastTime[timerunNum] = client->ps.commandTime - client->sess.timerunStartTime;

	if (!client->sess.timerunBestTime[timerunNum] || time < client->sess.timerunBestTime[timerunNum]) {
		// best personal for this session
		if (client->sess.logged) {
			client->sess.timerunBestTime[timerunNum] = time;

			// Nico, update best speed of run
			client->sess.timerunBestSpeed[timerunNum] = client->sess.maxSpeed;

			// Nico, set score so that xfire can see it (only if cup mode is DISABLED)
			if (g_cupMode.integer != 1) {
				client->ps.persistant[PERS_SCORE] = client->sess.timerunLastTime[timerunNum];
			}
		}

		// CP are updated here if API is not used or if CP were note loaded
		if (!g_useAPI.integer || client->sess.timerunCheckpointWereLoaded[timerunNum] == 0) {
			memcpy(client->sess.timerunBestCheckpointTimes[timerunNum], client->sess.timerunCheckpointTimes, sizeof (client->sess.timerunCheckpointTimes));
		}
	}

	// Nico, stop speed
	client->sess.stopSpeed = (int)sqrt(client->ps.velocity[0] * client->ps.velocity[0] + client->ps.velocity[1] * client->ps.velocity[1]);

	// Nico, send record if needed
	if (g_useAPI.integer && client->sess.logged) {
		Cmd_SendRecord_f(activator, client->sess.currentTimerun, client->pers.authToken,
		                 time, client->sess.startSpeed, client->sess.stopSpeed, client->sess.maxSpeed,
		                 client->ps.identifyClientHealth, // Nico, this is used as a jumps counter
		                 client->pers.ip, client->pers.maxFPS,
		                 client->pers.clientTimeNudge, client->pers.rate, client->pers.clientMaxPackets, client->pers.snaps,
		                 g_strictSaveLoad.integer, g_disableDrowning.integer, g_holdDoorsOpen.integer, g_enableMapEntities.integer);
	} else {
		// Nico, API is not used and/or client is not logged,
		// we cannnot know if his last time his SB/PB or something
		// else. So we keep his last demo.
		saveDemo(activator);
	}

	// Nico, notify the client and its spectators the timerun has stopped
	notify_timerun_stop(activator, client->sess.timerunLastTime[timerunNum]);

	client->sess.timerunActive = qfalse;
}
Example #3
0
/*--------------------------------------------*/
void SaveLoad_Class::saveRoutine()
{
  saveDemo();
}