Example #1
0
void G_KickFireTeamPlayer( int entityNum, int otherEntityNum ) {
	fireteamData_t *ft, *ft2;;

	if ( entityNum == otherEntityNum ) {
		return; // ok, stop being silly :p
	}

	if ( ( entityNum < 0 || entityNum >= MAX_CLIENTS ) || !g_entities[entityNum].client ) {
		G_Error( "G_KickFireTeamPlayer: invalid client" );
	}

	if ( ( otherEntityNum < 0 || otherEntityNum >= MAX_CLIENTS ) || !g_entities[otherEntityNum].client ) {
		G_Error( "G_KickFireTeamPlayer: invalid client" );
	}

	if ( !G_IsFireteamLeader( entityNum, &ft ) ) {
		G_ClientPrintAndReturn( entityNum, "You are not the leader of a fireteam" );
	}

	if ( ( !G_IsOnFireteam( otherEntityNum, &ft2 ) ) || ft != ft2 ) {
		G_ClientPrintAndReturn( entityNum, "You are not on the same Fireteam as the other player" );
	}


	G_RemoveClientFromFireteams( otherEntityNum, qtrue, qfalse );

	G_ClientPrintAndReturn( otherEntityNum, "You have been kicked from the fireteam" );
}
Example #2
0
void G_DestroyFireteam(int entityNum)
{
	fireteamData_t *ft;

	if ((entityNum < 0 || entityNum >= MAX_CLIENTS) || !g_entities[entityNum].client)
	{
		G_Error("G_DestroyFireteam: invalid client\n");
	}

	if (!G_IsFireteamLeader(entityNum, &ft))
	{
		G_ClientPrint(entityNum, "You are not the leader of a fireteam\n");
		return;
	}

	while (ft->joinOrder[0] != -1)
	{
		if (ft->joinOrder[0] != entityNum)
		{
#ifdef FEATURE_OMNIBOT
			Bot_Event_FireTeamDestroyed(ft->joinOrder[0]);
#endif
			trap_SendServerCommand(ft->joinOrder[0], "cpm \"The fireteam you are on has been disbanded\"");
		}

		G_RemoveClientFromFireteams(ft->joinOrder[0], qfalse, qfalse);
	}

	G_UpdateFireteamConfigString(ft);
}
Example #3
0
void G_WarnFireTeamPlayer( int entityNum, int otherEntityNum ) {
	fireteamData_t *ft, *ft2;

	if ( entityNum == otherEntityNum ) {
		return; // ok, stop being silly :p
	}

	if ( ( entityNum < 0 || entityNum >= MAX_CLIENTS ) || !g_entities[entityNum].client ) {
		G_Error( "G_WarnFireTeamPlayer: invalid client" );
	}

	if ( ( otherEntityNum < 0 || otherEntityNum >= MAX_CLIENTS ) || !g_entities[otherEntityNum].client ) {
		G_Error( "G_WarnFireTeamPlayer: invalid client" );
	}

	if ( !G_IsFireteamLeader( entityNum, &ft ) ) {
		G_ClientPrintAndReturn( entityNum, "You are not the leader of a fireteam" );
	}

	if ( ( !G_IsOnFireteam( otherEntityNum, &ft2 ) ) || ft != ft2 ) {
		G_ClientPrintAndReturn( entityNum, "You are not on the same Fireteam as the other player" );
	}

	trap_SendServerCommand( otherEntityNum, "cpm \"You have been warned by your Fireteam Commander\n\"" );
}
Example #4
0
// The only way a client should ever be invitied to join a team
void G_InviteToFireTeam( int entityNum, int otherEntityNum ) {
	fireteamData_t* ft;

	if ( ( entityNum < 0 || entityNum >= MAX_CLIENTS ) || !g_entities[entityNum].client ) {
		G_Error( "G_InviteToFireTeam: invalid client" );
	}

	if ( ( otherEntityNum < 0 || otherEntityNum >= MAX_CLIENTS ) || !g_entities[otherEntityNum].client ) {
		G_Error( "G_InviteToFireTeam: invalid client" );
	}

	if ( !G_IsFireteamLeader( entityNum, &ft ) ) {
		G_ClientPrintAndReturn( entityNum, "You are not the leader of a fireteam" );
	}

	if ( g_entities[entityNum].client->sess.sessionTeam != g_entities[otherEntityNum].client->sess.sessionTeam ) {
		G_ClientPrintAndReturn( entityNum, "You are not on the same team as the other player" );
	}

	if ( G_IsOnFireteam( otherEntityNum, NULL ) ) {
		G_ClientPrintAndReturn( entityNum, "The other player is already on a fireteam" );
	}

	if ( g_entities[otherEntityNum].r.svFlags & SVF_BOT ) {
		// Gordon: bots auto join
		G_AddClientToFireteam( otherEntityNum, entityNum );
	} else {
		trap_SendServerCommand( entityNum, va( "invitation -1" ) );
		trap_SendServerCommand( otherEntityNum, va( "invitation %i", entityNum ) );
		g_entities[otherEntityNum].client->pers.invitationClient =  entityNum;
		g_entities[otherEntityNum].client->pers.invitationEndTime = level.time + 20500;
	}
}
Example #5
0
// only way a client should ever join a fireteam, other than creating one
void G_AddClientToFireteam(int entityNum, int leaderNum)
{
	fireteamData_t *ft;
	int            i;

	if ((entityNum < 0 || entityNum >= MAX_CLIENTS) || !g_entities[entityNum].client)
	{
		G_Error("G_AddClientToFireteam: invalid client\n");
	}

	if ((leaderNum < 0 || leaderNum >= MAX_CLIENTS) || !g_entities[leaderNum].client)
	{
		G_Error("G_AddClientToFireteam: invalid client\n");
	}

	if (g_entities[leaderNum].client->sess.sessionTeam != g_entities[entityNum].client->sess.sessionTeam)
	{
		G_ClientPrint(entityNum, "You are not on the same team as that fireteam");
		return;
	}

	if (!G_IsFireteamLeader(leaderNum, &ft))
	{
		G_ClientPrint(entityNum, "The leader has now left the fireteam you applied to");
		return;
	}

	if (G_IsOnFireteam(entityNum, NULL))
	{
		G_ClientPrint(entityNum, "You are already on a fireteam");
		return;
	}

	if (G_CountFireteamMembers(ft) >= MAX_FIRETEAM_MEMBERS)
	{
		G_ClientPrint(entityNum, "Too many players already on this fireteam");
		return;
	}

	for (i = 0; i < MAX_CLIENTS; i++)
	{
		if (ft->joinOrder[i] == -1)
		{
			// found a free position
			ft->joinOrder[i] = entityNum;

#ifdef FEATURE_OMNIBOT
			Bot_Event_JoinedFireTeam(entityNum, &g_entities[leaderNum]);
#endif

			G_UpdateFireteamConfigString(ft);

			return;
		}
	}
}
Example #6
0
void G_GiveAdminOfFireTeam(int entityNum, int otherEntityNum)
{
	fireteamData_t *ft, *ft2;
	char           tempArray[MAX_CLIENTS];
	int            i, x;

	if (entityNum == otherEntityNum)
	{
		return;
	}

	if ((entityNum < 0 || entityNum >= MAX_CLIENTS) || !g_entities[entityNum].client)
	{
		G_Error("G_KickFireTeamPlayer: invalid client\n");
	}

	if ((otherEntityNum < 0 || otherEntityNum >= MAX_CLIENTS) || !g_entities[otherEntityNum].client)
	{
		G_Error("G_KickFireTeamPlayer: invalid client\n");
	}

	if (!G_IsFireteamLeader(entityNum, &ft))
	{
		G_ClientPrint(entityNum, "You must be a fireteam admin to give admin rights to someone else");
		return;
	}

	if ((!G_IsOnFireteam(otherEntityNum, &ft2)) || ft != ft2)
	{
		G_ClientPrint(entityNum, "The other player must be on the same fireteam for you to give admin rights to");
		return;
	}

	tempArray[0] = otherEntityNum;
	tempArray[1] = entityNum;
	x            = 2;
	for (i = 1; i < MAX_FIRETEAM_MEMBERS; i++)
	{
		if (ft->joinOrder[i] != otherEntityNum || ft->joinOrder[i] == -1)
		{
			tempArray[x++] = ft->joinOrder[i];
			continue;
		}
	}

	for (i = 0; i < MAX_FIRETEAM_MEMBERS; i++)
	{
		ft->joinOrder[i] = tempArray[i];
	}

	ft->leader = otherEntityNum;

	G_UpdateFireteamConfigString(ft);
	G_ClientPrint(otherEntityNum, "You have been given fireteam admin rights");
	G_ClientPrint(entityNum, "You have been been stripped of fireteam admin rights");
}
Example #7
0
// The only way a client should ever be invited to join a team
void G_InviteToFireTeam(int entityNum, int otherEntityNum)
{
	fireteamData_t *ft;

	if ((entityNum < 0 || entityNum >= MAX_CLIENTS) || !g_entities[entityNum].client)
	{
		G_Error("G_InviteToFireTeam: invalid client\n");
	}

	if ((otherEntityNum < 0 || otherEntityNum >= MAX_CLIENTS) || !g_entities[otherEntityNum].client)
	{
		G_Error("G_InviteToFireTeam: invalid client\n");
	}

	if (!G_IsFireteamLeader(entityNum, &ft))
	{
		G_ClientPrint(entityNum, "You are not the leader of a fireteam");
		return;
	}

	if (g_entities[entityNum].client->sess.sessionTeam != g_entities[otherEntityNum].client->sess.sessionTeam)
	{
		G_ClientPrint(entityNum, "You are not on the same team as the other player");
		return;
	}

	if (G_IsOnFireteam(otherEntityNum, NULL))
	{
		G_ClientPrint(entityNum, "The other player is already on a fireteam");
		return;
	}

	if (G_CountFireteamMembers(ft) >= MAX_FIRETEAM_MEMBERS)
	{
		G_ClientPrint(entityNum, "Too many players already on this fireteam");
		return;
	}

	if (g_entities[otherEntityNum].r.svFlags & SVF_BOT)
	{
		// bots auto join
		G_AddClientToFireteam(otherEntityNum, entityNum);
	}
	else
	{
		trap_SendServerCommand(entityNum, va("invitation -1"));
		trap_SendServerCommand(otherEntityNum, va("invitation %i", entityNum));
		g_entities[otherEntityNum].client->pers.invitationClient  = entityNum;
		g_entities[otherEntityNum].client->pers.invitationEndTime = level.time + 20500;
	}

#ifdef FEATURE_OMNIBOT
	Bot_Event_InviteFireTeam(entityNum, otherEntityNum);
#endif
}
Example #8
0
// only way a client should ever join a fireteam, other than creating one
void G_AddClientToFireteam(int entityNum, int leaderNum)
{
	fireteamData_t *ft;
	int             i;

	if((entityNum < 0 || entityNum >= MAX_CLIENTS) || !g_entities[entityNum].client)
	{
		G_Error("G_AddClientToFireteam: invalid client");
	}

	if((leaderNum < 0 || leaderNum >= MAX_CLIENTS) || !g_entities[leaderNum].client)
	{
		G_Error("G_AddClientToFireteam: invalid client");
	}

	if(g_entities[leaderNum].client->sess.sessionTeam != g_entities[entityNum].client->sess.sessionTeam)
	{
		G_ClientPrintAndReturn(entityNum, "You are not on the same team as that fireteam");
	}

	if(!G_IsFireteamLeader(leaderNum, &ft))
	{
		G_ClientPrintAndReturn(entityNum, "The leader has now left the Fireteam you applied to");
	}

	if(G_IsOnFireteam(entityNum, NULL))
	{
		G_ClientPrintAndReturn(entityNum, "You are already on a fireteam");
	}

	for(i = 0; i < MAX_CLIENTS; i++)
	{

		if(i >= 6)
		{
			G_ClientPrintAndReturn(entityNum, "Too many players already on this Fireteam");
			return;
		}

		if(ft->joinOrder[i] == -1)
		{
			// found a free position
			ft->joinOrder[i] = entityNum;

			// Omni-bot BEGIN
			Bot_Event_JoinedFireTeam(entityNum, &g_entities[leaderNum]);
			// Omni-bot END

			G_UpdateFireteamConfigString(ft);

			return;
		}
	}
}
Example #9
0
void G_DestroyFireteam( int entityNum ) {
	fireteamData_t* ft;

	if ( ( entityNum < 0 || entityNum >= MAX_CLIENTS ) || !g_entities[entityNum].client ) {
		G_Error( "G_DestroyFireteam: invalid client" );
	}

	if ( !G_IsFireteamLeader( entityNum, &ft ) ) {
		G_ClientPrintAndReturn( entityNum, "You are not the leader of a fireteam" );
	}

	while ( ft->joinOrder[0] != -1 ) {
		if ( ft->joinOrder[0] != entityNum ) {
			trap_SendServerCommand( ft->joinOrder[0], "cpm \"The Fireteam you are on has been disbanded\"\n" );
		}

		G_RemoveClientFromFireteams( ft->joinOrder[0], qfalse, qfalse );
	}

	G_UpdateFireteamConfigString( ft );
}
Example #10
0
void G_WarnFireTeamPlayer(int entityNum, int otherEntityNum)
{
	fireteamData_t *ft, *ft2;

	if (entityNum == otherEntityNum)
	{
		return; // stop being silly
	}

	if ((entityNum < 0 || entityNum >= MAX_CLIENTS) || !g_entities[entityNum].client)
	{
		G_Error("G_WarnFireTeamPlayer: invalid client\n");
	}

	if ((otherEntityNum < 0 || otherEntityNum >= MAX_CLIENTS) || !g_entities[otherEntityNum].client)
	{
		G_Error("G_WarnFireTeamPlayer: invalid client\n");
	}

	if (!G_IsFireteamLeader(entityNum, &ft))
	{
		G_ClientPrint(entityNum, "You are not the leader of a fireteam");
		return;
	}

	if ((!G_IsOnFireteam(otherEntityNum, &ft2)) || ft != ft2)
	{
		G_ClientPrint(entityNum, "You are not on the same fireteam as the other player");
		return;
	}

	trap_SendServerCommand(otherEntityNum, "cpm \"You have been warned by your fireteam leader\"");

#ifdef FEATURE_OMNIBOT
	Bot_Event_FireTeam_Warn(entityNum, otherEntityNum);
#endif
}
Example #11
0
// The only way a client should ever be invitied to join a team
void G_InviteToFireTeam(int entityNum, int otherEntityNum) {
	fireteamData_t *ft;

	if ((entityNum < 0 || entityNum >= MAX_CLIENTS) || !g_entities[entityNum].client) {
		G_Error("G_InviteToFireTeam: invalid client");
	}

	if ((otherEntityNum < 0 || otherEntityNum >= MAX_CLIENTS) || !g_entities[otherEntityNum].client) {
		G_Error("G_InviteToFireTeam: invalid client");
	}

	if (!G_IsFireteamLeader(entityNum, &ft)) {
		G_ClientPrintAndReturn(entityNum, "You are not the leader of a fireteam");
	}

	if (G_IsOnFireteam(otherEntityNum, NULL)) {
		G_ClientPrintAndReturn(entityNum, "The other player is already on a fireteam");
	}

	trap_SendServerCommand(entityNum, va("invitation -1"));
	trap_SendServerCommand(otherEntityNum, va("invitation %i", entityNum));
	g_entities[otherEntityNum].client->pers.invitationClient  = entityNum;
	g_entities[otherEntityNum].client->pers.invitationEndTime = level.time + 20500;
}
Example #12
0
// Command handler
void Cmd_FireTeam_MP_f(gentity_t *ent)
{
	char command[32];
	int  i;

	if (trap_Argc() < 2)
	{
		G_ClientPrint(ent - g_entities, "usage: fireteam <create|leave|apply|invite>");
		return;
	}

	trap_Argv(1, command, 32);

	if (!Q_stricmp(command, "create"))
	{
		G_RegisterFireteam(ent - g_entities);
	}
	else if (!Q_stricmp(command, "disband"))
	{
		G_DestroyFireteam(ent - g_entities);
	}
	else if (!Q_stricmp(command, "leave"))
	{
		G_RemoveClientFromFireteams(ent - g_entities, qtrue, qtrue);
	}
	else if (!Q_stricmp(command, "apply"))
	{
		char namebuffer[32];
		int  fireteam;

		if (trap_Argc() < 3)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam apply <fireteamname|fireteamnumber>");
			return;
		}

		trap_Argv(2, namebuffer, 32);
		fireteam = G_FireteamNumberForString(namebuffer, ent->client->sess.sessionTeam);

		if (fireteam <= 0)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam apply <fireteamname|fireteamnumber>");
			return;
		}

		G_ApplyToFireTeam(ent - g_entities, fireteam - 1);
	}
	else if (!Q_stricmp(command, "invite"))
	{
		char namebuffer[32];
		int  clientnum = 0;

		if (trap_Argc() < 3)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam invite <clientname|clientnumber>");
			return;
		}

		trap_Argv(2, namebuffer, 32);
		for (i = 0; i < MAX_CLIENTS; i++)
		{
			if (!g_entities[i].inuse || !g_entities[i].client)
			{
				continue;
			}

			if (!Q_stricmp(g_entities[i].client->pers.netname, namebuffer))
			{
				clientnum = i + 1;
			}
		}

		if (clientnum <= 0)
		{
			clientnum = atoi(namebuffer);

			if ((clientnum <= 0 || clientnum > MAX_CLIENTS) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client)
			{
				G_ClientPrint(ent - g_entities, "Invalid client selected");
				return;
			}
		}

		if (clientnum <= 0)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam invite <clientname|clientnumber>");
			return;
		}

		G_InviteToFireTeam(ent - g_entities, clientnum - 1);
	}
	else if (!Q_stricmp(command, "warn"))
	{
		char namebuffer[32];
		int  clientnum = 0;

		if (trap_Argc() < 3)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam warn <clientname|clientnumber>");
			return;
		}

		trap_Argv(2, namebuffer, 32);
		for (i = 0; i < MAX_CLIENTS; i++)
		{
			if (!g_entities[i].inuse || !g_entities[i].client)
			{
				continue;
			}

			if (!Q_stricmp(g_entities[i].client->pers.netname, namebuffer))
			{
				clientnum = i + 1;
			}
		}

		if (clientnum <= 0)
		{
			clientnum = atoi(namebuffer);

			if ((clientnum <= 0 || clientnum > MAX_CLIENTS) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client)
			{
				G_ClientPrint(ent - g_entities, "Invalid client selected");
				return;
			}
		}

		if (clientnum <= 0)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam warn <clientname|clientnumber>");
			return;
		}

		G_WarnFireTeamPlayer(ent - g_entities, clientnum - 1);
	}
	else if (!Q_stricmp(command, "kick"))
	{
		char namebuffer[32];
		int  clientnum = 0;

		if (trap_Argc() < 3)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam kick <clientname|clientnumber>");
			return;
		}

		trap_Argv(2, namebuffer, 32);
		for (i = 0; i < MAX_CLIENTS; i++)
		{
			if (!g_entities[i].inuse || !g_entities[i].client)
			{
				continue;
			}

			if (!Q_stricmp(g_entities[i].client->pers.netname, namebuffer))
			{
				clientnum = i + 1;
			}
		}

		if (clientnum <= 0)
		{
			clientnum = atoi(namebuffer);

			if ((clientnum <= 0 || clientnum > MAX_CLIENTS) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client)
			{
				G_ClientPrint(ent - g_entities, "Invalid client selected");
				return;
			}
		}

		if (clientnum <= 0)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam kick <clientname|clientnumber>");
			return;
		}

		G_KickFireTeamPlayer(ent - g_entities, clientnum - 1);
	}
	else if (!Q_stricmp(command, "propose"))
	{
		char namebuffer[32];
		int  clientnum = 0;

		if (trap_Argc() < 3)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam propose <clientname|clientnumber>");
			return;
		}

		trap_Argv(2, namebuffer, 32);
		for (i = 0; i < MAX_CLIENTS; i++)
		{
			if (!g_entities[i].inuse || !g_entities[i].client)
			{
				continue;
			}

			if (!Q_stricmp(g_entities[i].client->pers.netname, namebuffer))
			{
				clientnum = i + 1;
			}
		}

		if (clientnum <= 0)
		{
			clientnum = atoi(namebuffer);

			if ((clientnum <= 0 || clientnum > MAX_CLIENTS) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client)
			{
				G_ClientPrint(ent - g_entities, "Invalid client selected");
				return;
			}
		}

		if (clientnum <= 0)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam propose <clientname|clientnumber>");
			return;
		}

		G_ProposeFireTeamPlayer(ent - g_entities, clientnum - 1);
	}
	else if (!Q_stricmp(command, "privacy"))
	{
		fireteamData_t *ft;

		if (G_IsFireteamLeader(ent - g_entities, &ft))
		{
			if (ft->priv)
			{
				ft->priv = qfalse;
				G_UpdateFireteamConfigString(ft);
				G_ClientPrint(ent - g_entities, "Your fireteam is now public");
				return;
			}
			else
			{
				ft->priv = qtrue;
				G_UpdateFireteamConfigString(ft);
				G_ClientPrint(ent - g_entities, "Your fireteam is now private");
				return;
			}
		}
		else
		{
			G_ClientPrint(ent - g_entities, "You are not a fireteam admin");
			return;
		}
	}
	else if (!Q_stricmp(command, "admin"))
	{
		char namebuffer[32];
		int  clientnum = 0;

		if (trap_Argc() < 3)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam admin <clientname|clientnumber>");
			return;
		}

		trap_Argv(2, namebuffer, 32);
		for (i = 0; i < MAX_CLIENTS; i++)
		{
			if (!g_entities[i].inuse || !g_entities[i].client)
			{
				continue;
			}

			if (!Q_stricmp(g_entities[i].client->pers.netname, namebuffer))
			{
				clientnum = i + 1;
			}
		}

		if (clientnum <= 0)
		{
			clientnum = atoi(namebuffer);

			if ((clientnum <= 0 || clientnum > MAX_CLIENTS) || !g_entities[clientnum - 1].inuse || !g_entities[clientnum - 1].client)
			{
				G_ClientPrint(ent - g_entities, "Invalid client selected");
				return;
			}
		}

		if (clientnum <= 0)
		{
			G_ClientPrint(ent - g_entities, "usage: fireteam admin <clientname|clientnumber>");
			return;
		}

		G_GiveAdminOfFireTeam(ent - g_entities, clientnum - 1);
	}
}