Esempio n. 1
0
/*
 * G_Frame
 *
 * The main game module "think" function, called once per server frame.
 * Nothing would happen in Quake land if this weren't called.
 */
static void G_Frame(void) {
	int i;
	g_edict_t *ent;

	g_level.frame_num++;
	g_level.time = g_level.frame_num * gi.server_frame;

	// check for level change after running intermission
	if (g_level.intermission_time) {
		if (g_level.time > g_level.intermission_time + INTERMISSION) {
			G_ExitLevel();
			return;
		}
	}

	// treat each object in turn
	// even the world gets a chance to think
	ent = &g_game.edicts[0];
	for (i = 0; i < ge.num_edicts; i++, ent++) {

		if (!ent->in_use)
			continue;

		g_level.current_entity = ent;

		// update old origin for interpolation
		if (!(ent->s.effects & EF_LIGHTNING))
			VectorCopy(ent->s.origin, ent->s.old_origin);

		if (ent->ground_entity) {

			// check for ground entities going away
			if (ent->ground_entity->link_count != ent->ground_entity_link_count)
				ent->ground_entity = NULL;
		}

		if (i > 0 && i <= sv_max_clients->integer)
			G_ClientBeginFrame(ent);
		else
			G_RunEntity(ent);
	}

	// see if a vote has passed
	G_CheckVote();

	// inspect and enforce gameplay rules
	G_CheckRules();

	// see if a match should end
	G_CheckMatchEnd();

	// see if an arena round should start
	G_CheckRoundStart();

	// see if an arena round should end
	G_CheckRoundEnd();

	// build the player_state_t structures for all players
	G_EndClientFrames();
}
Esempio n. 2
0
static void Cmd_Admin_f(edict_t *ent)
{
    char *p;

    if (ent->client->pers.admin) {
        gi.bprintf(PRINT_HIGH, "%s is no longer an admin.\n",
                   ent->client->pers.netname);
        ent->client->pers.admin = false;
        return;
    }
    if (gi.argc() < 2) {
        gi.cprintf(ent, PRINT_HIGH, "Usage: %s <password>\n", gi.argv(0));
        return;
    }
    p = gi.argv(1);
    if (!g_admin_password->string[0] || strcmp(g_admin_password->string, p)) {
        gi.cprintf(ent, PRINT_HIGH, "Bad admin password.\n");
        if ((int)dedicated->value) {
            gi.dprintf("%s[%s] failed to become an admin.\n",
                       ent->client->pers.netname, ent->client->pers.ip);
        }
        return;
    }

    ent->client->pers.admin = true;
    gi.bprintf(PRINT_HIGH, "%s became an admin.\n",
               ent->client->pers.netname);

    G_CheckVote();
}