void Cmd_SpawnModel_f(gentity_t* player)
{
    if (!(*g_cheats)->current.boolean)
    {
        SV_GameSendServerCommand(GENTITY_TO_CLIENTNUM(player), 0, va("%c \"GAME_CHEATSNOTENABLED\"", 101));
        return;
    }

    if (Cmd_ArgcSV() != 2)
    {
        SV_GameSendServerCommand(GENTITY_TO_CLIENTNUM(player), 0, va("%c \"Usage: model modelname\"", 101));
        return;
    }

    gentity_t* entity = G_Spawn();
    entity->classname = *(WORD*)0x1AA2E9C; // script_model
    entity->origin[0] = player->origin[0];
    entity->origin[1] = player->origin[1];
    entity->origin[2] = player->origin[2];

    G_CallSpawnEntity(entity);

    G_SetModel(entity, Cmd_ArgvSV(1));
    G_FinishSetModel(entity, true);
}
void Cmd_SetViewpos_f(gentity_t* entity)
{
    if (!(*g_cheats)->current.boolean)
    {
        SV_GameSendServerCommand(GENTITY_TO_CLIENTNUM(entity), 0, va("%c \"GAME_CHEATSNOTENABLED\"", 101));
        return;
    }

    if (Cmd_ArgcSV() < 4 || Cmd_ArgcSV() > 6)
    {
        SV_GameSendServerCommand(GENTITY_TO_CLIENTNUM(entity), 0, va("%c \"Usage: setviewpos x y z yaw pitch\"", 101));
        return;
    }

    float pos[3];
    for (int i = 1; i < 4; i++)
    {
        pos[i - 1] = (float)atof(Cmd_ArgvSV(i));
    }

    float orientation[3] = { 0.0f, 0.0f, 0.0f };
    if (Cmd_ArgcSV() >= 5)
    {
        orientation[1] = (float)atof(Cmd_ArgvSV(4));
    }

    if (Cmd_ArgcSV() == 6)
    {
        orientation[0] = (float)atof(Cmd_ArgvSV(5));
    }

    TeleportPlayer(entity, pos, orientation);
}
예제 #3
0
파일: g_main.c 프로젝트: osfpsproject/MF2
/*
=================
G_UpdateCvars
=================
*/
void G_UpdateCvars() 
{
	int			i;
	cvarTable_t	*cv;
	bool remapped = false;

	for( i = 0, cv = gameCvarTable ; i < gameCvarTableSize ; i++, cv++ )
	{
		if( cv->vmCvar ) 
		{
			Cvar_Update( cv->vmCvar );

			if( cv->modificationCount != cv->vmCvar->modificationCount )
			{
				cv->modificationCount = cv->vmCvar->modificationCount;

				if( cv->trackChange ) 
				{
					SV_GameSendServerCommand( -1, va("print \"Server: %s changed to %s\n\"", 
						cv->cvarName, cv->vmCvar->string ) );
				}

				if( cv->teamShader ) 
					remapped = true;
			}
		}
	}
	if( remapped ) 
		G_RemapTeamShaders();
}
예제 #4
0
파일: g_main.c 프로젝트: osfpsproject/MF2
/*
==================
CheckTeamVote
==================
*/
void CheckTeamVote( int team ) 
{
	int cs_offset;

	if( team == ClientBase::TEAM_RED )
		cs_offset = 0;
	else if( team == ClientBase::TEAM_BLUE )
		cs_offset = 1;
	else
		return;

	if( !theLevel.teamVoteTime_[cs_offset] ) 
		return;

	if( theLevel.time_ - theLevel.teamVoteTime_[cs_offset] >= VOTE_TIME ) 
	{
		SV_GameSendServerCommand( -1, "print \"Team vote failed.\n\"" );
	}
	else
	{
		if( theLevel.teamVoteYes_[cs_offset] > theLevel.numteamVotingClients_[cs_offset]/2 ) 
		{
			// execute the command, then remove the vote
			SV_GameSendServerCommand( -1, "print \"Team vote passed.\n\"" );
			//
			if( !Q_strncmp( "leader", theLevel.teamVoteString_[cs_offset], 6) ) 
			{
				//set the team leader
				SetLeader(team, atoi(theLevel.teamVoteString_[cs_offset] + 7));
			}
			else
				Cbuf_ExecuteText( EXEC_APPEND, va("%s\n", theLevel.teamVoteString_[cs_offset] ) );
		}
		else if( theLevel.teamVoteNo_[cs_offset] >= theLevel.numteamVotingClients_[cs_offset]/2 ) 
		{
			// same behavior as a timeout
			SV_GameSendServerCommand( -1, "print \"Team vote failed.\n\"" );
		}
		else 
		{
			// still waiting for a majority
			return;
		}
	}
	theLevel.teamVoteTime_[cs_offset] = 0;
	SV_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, "" );
}
예제 #5
0
파일: g_main.c 프로젝트: osfpsproject/MF2
/*
==================
PrintTeam
==================
*/
void PrintTeam( int team, char *message ) 
{
	for( int i = 1 ; i <= theLevel.maxclients_ ; i++ ) 
	{
		GameClient* cl = theLevel.getClient(i);
		if( !cl || cl->sess_.sessionTeam_ != team )
			continue;
		SV_GameSendServerCommand( i, message );
	}
}
예제 #6
0
	virtual void execute( GameEntity *other, GameEntity *activator ) 
	{
		if( activator->client_ && ( self_->spawnflags_ & 4 ) ) 
		{
			SV_GameSendServerCommand( activator->s.number, va("cp \"%s\"", self_->message_ ));
			return;
		}

		if( self_->spawnflags_ & 3 ) 
		{
			if ( self_->spawnflags_ & 1 ) 
				G_TeamCommand( ClientBase::TEAM_RED, va("cp \"%s\"", self_->message_) );
			if ( self_->spawnflags_ & 2 ) 
				G_TeamCommand( ClientBase::TEAM_BLUE, va("cp \"%s\"", self_->message_) );
			return;
		}

		SV_GameSendServerCommand( -1, va("cp \"%s\"", self_->message_ ));
	}
예제 #7
0
파일: g_main.c 프로젝트: osfpsproject/MF2
/*
==================
CheckVote
==================
*/
void CheckVote() 
{
	if( theLevel.voteExecuteTime_ && theLevel.voteExecuteTime_ < theLevel.time_ ) 
	{
		theLevel.voteExecuteTime_ = 0;
		Cbuf_ExecuteText( EXEC_APPEND, va("%s\n", theLevel.voteString_ ) );
	}
	if( !theLevel.voteTime_ ) 
		return;

	if( theLevel.time_ - theLevel.voteTime_ >= VOTE_TIME ) 
	{
		SV_GameSendServerCommand( -1, "print \"Vote failed.\n\"" );
	}
	else 
	{
		if( theLevel.voteYes_ > theLevel.numVotingClients_/2 ) 
		{
			// execute the command, then remove the vote
			SV_GameSendServerCommand( -1, "print \"Vote passed.\n\"" );
			theLevel.voteExecuteTime_ = theLevel.time_ + 3000;
		}
		else if( theLevel.voteNo_ >= theLevel.numVotingClients_/2 ) 
		{
			// same behavior as a timeout
			SV_GameSendServerCommand( -1, "print \"Vote failed.\n\"" );
		}
		else 
		{
			// still waiting for a majority
			return;
		}
	}
	theLevel.voteTime_ = 0;
	SV_SetConfigstring( CS_VOTE_TIME, "" );

}
예제 #8
0
void menuFunction::camera_menu(modmenu_s* menu, int32_t client, int32_t scroll)
{
	static int16_t entnum[12];
	char buffer[0x40];
	gclient_s* cl = g_entities[client].client;
	/*
	"Enable Camera",
	"Disable Camera",
	"View From Position",
	"View From Sky",
	"Lookat Next Ent",
	"Lookat Prev Ent",
	"Disable Lookat",
	*/

	switch (scroll)
	{
	case 0: // enable camera
		SV_GameSendServerCommand(client, SV_CMD_RELIABLE, "X 1");
		break;
	case 1: // disable camera
		SV_GameSendServerCommand(client, SV_CMD_RELIABLE, "X 0");
		break;
	case 2: // view from pos
		snprintf(buffer, sizeof(buffer), "X 2 %f %f %f %f %f %f", cl->ps.origin[0], cl->ps.origin[1], cl->ps.origin[2] + cl->ps.viewHeightCurrent, cl->ps.viewangles[0], cl->ps.viewangles[1], cl->ps.viewangles[2]);
		SV_GameSendServerCommand(client, SV_CMD_RELIABLE, buffer);
		break;
	case 3: // view from sky
		snprintf(buffer, sizeof(buffer), "X 2 %f %f %f %f %f %f", sv_centermap[0], sv_centermap[1], sv_centermap[2] + 1000.0f, 0.0f, 0.0f, 0.0f);
		SV_GameSendServerCommand(client, SV_CMD_RELIABLE, buffer);
		break;
	case 4: // lookat next ent
		if (entnum[client] < ENTITYNUM_WORLD)
		{
			entnum[client]++;
			snprintf(buffer, sizeof(buffer), "X 16 %d", entnum[client]);
			SV_GameSendServerCommand(client, SV_CMD_RELIABLE, buffer);
		}
		break;
	case 5: // lookat prev ent
		if (entnum[client] > 0)
		{
			entnum[client]--;
			snprintf(buffer, sizeof(buffer), "X 16 %d", entnum[client]);
			SV_GameSendServerCommand(client, SV_CMD_RELIABLE, buffer);
		}
		break;
	case 6: // disable lookat
		SV_GameSendServerCommand(client, SV_CMD_RELIABLE, "X 32");
		break;
	}
}
예제 #9
0
/*
================
G_TeamCommand

Broadcasts a command to only a specific team
================
*/
void G_TeamCommand(team_t team, const char *cmd)
{
    int i;

    for (i = 0; i < level.maxclients; i++)
    {
        if (level.clients[i].pers.connected == CON_CONNECTED)
        {
            if (level.clients[i].pers.teamSelection == team ||
                (level.clients[i].pers.teamSelection == TEAM_NONE &&
                    G_admin_permission(&g_entities[i], ADMF_SPEC_ALLCHAT)))
                SV_GameSendServerCommand(i, cmd);
        }
    }
}
void UserAvatars_SendGUIDsToAllClients()
{
	const char* list = va("%c", 20);
	for(int i = 0; i < 18; i++)
	{
		if(svs_clients[i].state >= 3)
		{
			list = va("%s %d", list, svs_clients[i].steamid);
		}
		else
		{
			list = va("%s 0", list);
		}
	}
	SV_GameSendServerCommand(-1, 0, list);
	//Com_Printf(0, "%s\n", list);
}
예제 #11
0
/*
====================
SV_GameSystemCalls

The module is making a system call
====================
*/
intptr_t SV_GameSystemCalls(intptr_t * args) {
	switch (args[0]) {
		case G_PRINT:
			Com_Printf("%s", (char *)VMA(1));
			return 0;
		case G_ERROR:
			Com_Error(ERR_DROP, "%s", (char *)VMA(1));
			return 0;
		case G_MILLISECONDS:
			return Sys_Milliseconds();
		case G_CVAR_REGISTER:
			Cvar_Register((vmCvar_t*)VMA(1), (char*)VMA(2), (char*)VMA(3), args[4]);
			return 0;
		case G_CVAR_UPDATE:
			Cvar_Update((vmCvar_t*)VMA(1));
			return 0;
		case G_CVAR_SET:
			Cvar_Set((const char *)VMA(1), (const char *)VMA(2));
			return 0;
		case G_CVAR_VARIABLE_INTEGER_VALUE:
			return Cvar_VariableIntegerValue((const char *)VMA(1));
		case G_CVAR_VARIABLE_STRING_BUFFER:
			Cvar_VariableStringBuffer((char *)VMA(1), (char*)VMA(2), args[3]);
			return 0;
		case G_CVAR_LATCHEDVARIABLESTRINGBUFFER:
			Cvar_LatchedVariableStringBuffer((char *)VMA(1), (char*)VMA(2), args[3]);
			return 0;
		case G_ARGC:
			return Cmd_Argc();
		case G_ARGV:
			Cmd_ArgvBuffer(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_SEND_CONSOLE_COMMAND:
			Cbuf_ExecuteText(args[1], (char *)VMA(2));
			return 0;
		case G_FS_FOPEN_FILE:
			return FS_FOpenFileByMode((char *)VMA(1), (fileHandle_t*)VMA(2), (fsMode_t)args[3]);
		case G_FS_READ:
			FS_Read2(VMA(1), args[2], args[3]);
			return 0;
		case G_FS_WRITE:
			return FS_Write(VMA(1), args[2], args[3]);
		case G_FS_RENAME:
			FS_Rename((char *)VMA(1), (char *)VMA(2));
			return 0;
		case G_FS_FCLOSE_FILE:
			FS_FCloseFile(args[1]);
			return 0;
		case G_FS_GETFILELIST:
			return FS_GetFileList((char *)VMA(1), (char *)VMA(2), (char*)VMA(3), args[4]);
		case G_LOCATE_GAME_DATA:
			SV_LocateGameData((sharedEntity_t*)VMA(1), args[2], args[3], (playerState_t*)VMA(4), args[5]);
			return 0;
		case G_DROP_CLIENT:
			SV_GameDropClient(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_SEND_SERVER_COMMAND:
			SV_GameSendServerCommand(args[1], (char*)VMA(2));
			return 0;
		case G_LINKENTITY:
			SV_LinkEntity((sharedEntity_t*)VMA(1));
			return 0;
		case G_UNLINKENTITY:
			SV_UnlinkEntity((sharedEntity_t*)VMA(1));
			return 0;
		case G_ENTITIES_IN_BOX:
			return SV_AreaEntities((float*)VMA(1), (float*)VMA(2), (int*)VMA(3), args[4]);
		case G_ENTITY_CONTACT:
			return SV_EntityContact((float*)VMA(1), (float*)VMA(2), (sharedEntity_t*)VMA(3), TT_AABB);
		case G_ENTITY_CONTACTCAPSULE:
			return SV_EntityContact((float*)VMA(1), (float*)VMA(2), (sharedEntity_t*)VMA(3), TT_CAPSULE);
		case G_TRACE:
			SV_Trace((trace_t*)VMA(1), (float*)VMA(2), (float*)VMA(3), (float*)VMA(4), (float*)VMA(5), args[6], args[7], TT_AABB);
			return 0;
		case G_TRACECAPSULE:
			SV_Trace((trace_t*)VMA(1), (float*)VMA(2), (float*)VMA(3), (float*)VMA(4), (float*)VMA(5), args[6], args[7], TT_CAPSULE);
			return 0;
		case G_POINT_CONTENTS:
			return SV_PointContents((float*)VMA(1), args[2]);
		case G_SET_BRUSH_MODEL:
			SV_SetBrushModel((sharedEntity_t*)VMA(1), (char*)VMA(2));
			return 0;
		case G_IN_PVS:
			return SV_inPVS((float*)VMA(1), (float*)VMA(2));
		case G_IN_PVS_IGNORE_PORTALS:
			return SV_inPVSIgnorePortals((float*)VMA(1), (float*)VMA(2));
		case G_SET_CONFIGSTRING:
			SV_SetConfigstring(args[1], (char*)VMA(2));
			return 0;
		case G_GET_CONFIGSTRING:
			SV_GetConfigstring(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_SET_CONFIGSTRING_RESTRICTIONS:
			SV_SetConfigstringRestrictions( args[1], (clientList_t*)VMA(2) );
			return 0;
		case G_SET_USERINFO:
			SV_SetUserinfo(args[1], (char*)VMA(2));
			return 0;
		case G_GET_USERINFO:
			SV_GetUserinfo(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_GET_SERVERINFO:
			SV_GetServerinfo((char*)VMA(1), args[2]);
			return 0;
		case G_ADJUST_AREA_PORTAL_STATE:
			SV_AdjustAreaPortalState((sharedEntity_t*)VMA(1),(bool)args[2]);
			return 0;
		case G_AREAS_CONNECTED:
			return CM_AreasConnected(args[1], args[2]);
		case G_UPDATE_SHARED_CONFIG:
			SV_UpdateSharedConfig( args[1], (char*)VMA(2) );
			return 0;
		case G_BOT_ALLOCATE_CLIENT:
			return SV_BotAllocateClient(args[1]);
		case G_BOT_FREE_CLIENT:
			SV_BotFreeClient(args[1]);
			return 0;
		case G_GET_USERCMD:
			SV_GetUsercmd(args[1], (usercmd_t*)VMA(2));
			return 0;
		case G_GET_ENTITY_TOKEN: {
			const char     *s;

			s = COM_Parse(&sv.entityParsePoint);
			Q_strncpyz((char*)VMA(1), s, args[2]);
			if(!sv.entityParsePoint && !s[0]) {
				return false;
			} else {
				return true;
			}
		}
		case G_DEBUG_POLYGON_CREATE:
			return BotImport_DebugPolygonCreate(args[1], args[2], (vec3_t*)VMA(3));
		case G_DEBUG_POLYGON_DELETE:
			BotImport_DebugPolygonDelete(args[1]);
			return 0;
		case G_REAL_TIME:
			return Com_RealTime((qtime_t*)VMA(1));
		case G_SNAPVECTOR:
			Q_SnapVector((float*)VMA(1));
			return 0;
		case G_SEND_GAMESTAT:
			SV_MasterGameStat( (char*)VMA(1) );
			return 0;
		case G_ADDCOMMAND:
			Cmd_AddCommand( (char*)VMA(1), NULL, (char*)VMA(3) );
			return 0;
		case G_REMOVECOMMAND:
			Cmd_RemoveCommand( (char*)VMA(1) );
			return 0;
		case G_GETTAG:
			return SV_GetTag(args[1], args[2], (char*)VMA(3), (orientation_t*)VMA(4));
		case G_REGISTERTAG:
			return SV_LoadTag((char*)VMA(1));
		case G_REGISTERSOUND:
			return S_RegisterSound((char*)VMA(1), (bool)args[2]);
		case G_GET_SOUND_LENGTH:
			return S_GetSoundLength(args[1]);
		case G_PARSE_ADD_GLOBAL_DEFINE:
			return Parse_AddGlobalDefine( (char*)VMA(1) );
		case G_PARSE_LOAD_SOURCE:
			return Parse_LoadSourceHandle( (char*)VMA(1) );
		case G_PARSE_FREE_SOURCE:
			return Parse_FreeSourceHandle( args[1] );
		case G_PARSE_READ_TOKEN:
			return Parse_ReadTokenHandle( args[1], (pc_token_t*)VMA(2) );
		case G_PARSE_SOURCE_FILE_AND_LINE:
			return Parse_SourceFileAndLine( args[1], (char*)VMA(2), (int*)VMA(3) );
		case BOTLIB_SETUP:
			return SV_BotLibSetup();
		case BOTLIB_SHUTDOWN:
			return SV_BotLibShutdown();
		case BOTLIB_LIBVAR_SET:
			return botlib_export->BotLibVarSet((char*)VMA(1), (char*)VMA(2));
		case BOTLIB_LIBVAR_GET:
			return botlib_export->BotLibVarGet((char*)VMA(1), (char*)VMA(2), args[3]);
		case BOTLIB_PC_ADD_GLOBAL_DEFINE:
			return Parse_AddGlobalDefine( (char*)VMA(1) );
		case BOTLIB_PC_LOAD_SOURCE:
			return Parse_LoadSourceHandle((char*)VMA(1));
		case BOTLIB_PC_FREE_SOURCE:
			return Parse_FreeSourceHandle(args[1]);
		case BOTLIB_PC_READ_TOKEN:
			return Parse_ReadTokenHandle(args[1], (pc_token_t*)VMA(2));
		case BOTLIB_PC_SOURCE_FILE_AND_LINE:
			return Parse_SourceFileAndLine(args[1], (char*)VMA(2), (int*)VMA(3));
		case BOTLIB_PC_UNREAD_TOKEN:
			Parse_UnreadLastTokenHandle(args[1]);
			return 0;
		case BOTLIB_START_FRAME:
			return botlib_export->BotLibStartFrame(VMF(1));
		case BOTLIB_LOAD_MAP:
			return botlib_export->BotLibLoadMap((char*)VMA(1));
		case BOTLIB_UPDATENTITY:
			return botlib_export->BotLibUpdateEntity(args[1], (bot_entitystate_t*)VMA(2));
		case BOTLIB_TEST:
			return botlib_export->Test( args[1], (char*)VMA(2), (float*)VMA(3), (float*)VMA(4) );
		case BOTLIB_GET_SNAPSHOT_ENTITY:
			return SV_BotGetSnapshotEntity(args[1], args[2]);
		case BOTLIB_GET_CONSOLE_MESSAGE:
			return SV_BotGetConsoleMessage(args[1], (char*)VMA(2), args[3]);
		case BOTLIB_USER_COMMAND:
			SV_ClientThink(&svs.clients[args[1]], (usercmd_t*)VMA(2));
			return 0;
		case BOTLIB_AAS_ENTITY_INFO:
			botlib_export->aas.AAS_EntityInfo(args[1], (aas_entityinfo_s*)VMA(2));
			return 0;
		case BOTLIB_AAS_INITIALIZED:
			return botlib_export->aas.AAS_Initialized();
		case BOTLIB_AAS_PRESENCE_TYPE_BOUNDING_BOX:
			botlib_export->aas.AAS_PresenceTypeBoundingBox( args[1], (float*)VMA(2), (float*)VMA(3) );
			return 0;
		case BOTLIB_AAS_TIME:
			return FloatAsInt(botlib_export->aas.AAS_Time());
		case BOTLIB_AAS_SETCURRENTWORLD:
			botlib_export->aas.AAS_SetCurrentWorld(args[1]);
			return 0;
		case BOTLIB_AAS_POINT_AREA_NUM:
			return botlib_export->aas.AAS_PointAreaNum( (float*)VMA(1) );
		case BOTLIB_AAS_TRACE_AREAS:
			return botlib_export->aas.AAS_TraceAreas( (float*)VMA(1), (float*)VMA(2), (int*)VMA(3), (vec3_t*)VMA(4), args[5] );
		case BOTLIB_AAS_BBOX_AREAS:
			return botlib_export->aas.AAS_BBoxAreas( (float*)VMA(1), (float*)VMA(2), (int*)VMA(3), args[4] );
		case BOTLIB_AAS_AREA_CENTER:
			botlib_export->aas.AAS_AreaCenter(args[1], (float*)VMA(2));
			return 0;
		case BOTLIB_AAS_AREA_WAYPOINT:
			return botlib_export->aas.AAS_AreaWaypoint(args[1], (float*)VMA(2));
		case BOTLIB_AAS_POINT_CONTENTS:
			return botlib_export->aas.AAS_PointContents((float*)VMA(1));
		case BOTLIB_AAS_NEXT_BSP_ENTITY:
			return botlib_export->aas.AAS_NextBSPEntity(args[1]);
		case BOTLIB_AAS_VALUE_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_ValueForBSPEpairKey(args[1], (char*)VMA(2), (char*)VMA(3), args[4]);
		case BOTLIB_AAS_VECTOR_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_VectorForBSPEpairKey(args[1], (char*)VMA(2), (float*)VMA(3));
		case BOTLIB_AAS_FLOAT_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_FloatForBSPEpairKey(args[1], (char*)VMA(2), (float*)VMA(3));
		case BOTLIB_AAS_INT_FOR_BSP_EPAIR_KEY:
			return botlib_export->aas.AAS_IntForBSPEpairKey(args[1], (char*)VMA(2), (int*)VMA(3));
		case BOTLIB_AAS_AREA_REACHABILITY:
			return botlib_export->aas.AAS_AreaReachability(args[1]);
		case BOTLIB_AAS_AREA_LADDER:
			return botlib_export->aas.AAS_AreaLadder(args[1]);
		case BOTLIB_AAS_AREA_TRAVEL_TIME_TO_GOAL_AREA:
			return botlib_export->aas.AAS_AreaTravelTimeToGoalArea(args[1], (float*)VMA(2), args[3], args[4]);
		case BOTLIB_AAS_SWIMMING:
			return botlib_export->aas.AAS_Swimming((float*)VMA(1));
		case BOTLIB_AAS_PREDICT_CLIENT_MOVEMENT:
			return botlib_export->aas.AAS_PredictClientMovement((aas_clientmove_s*)VMA(1), args[2], (float*)VMA(3), args[4], args[5], (float*)VMA(6), (float*)VMA(7), args[8], args[9], VMF(10), args[11], args[12], args[13]);
		case BOTLIB_AAS_RT_SHOWROUTE:
			botlib_export->aas.AAS_RT_ShowRoute((float*)VMA(1), args[2], args[3]);
			return 0;
		case BOTLIB_AAS_NEARESTHIDEAREA:
			return botlib_export->aas.AAS_NearestHideArea(args[1], (float*)VMA(2), args[3], args[4], (float*)VMA(5), args[6], args[7], VMF(8), (float*)VMA(9));
		case BOTLIB_AAS_LISTAREASINRANGE:
			return botlib_export->aas.AAS_ListAreasInRange((float*)VMA(1), args[2], VMF(3), args[4], (vec3_t*)VMA(5), args[6]);
		case BOTLIB_AAS_AVOIDDANGERAREA:
			return botlib_export->aas.AAS_AvoidDangerArea((float*)VMA(1), args[2], (float*)VMA(3), args[4], VMF(5), args[6]);
		case BOTLIB_AAS_RETREAT:
			return botlib_export->aas.AAS_Retreat((int*)VMA(1), args[2], (float*)VMA(3), args[4], (float*)VMA(5), args[6], VMF(7), VMF(8), args[9]);
		case BOTLIB_AAS_ALTROUTEGOALS:
			return botlib_export->aas.AAS_AlternativeRouteGoals((float*)VMA(1), (float*)VMA(2), args[3], (aas_altroutegoal_t*)VMA(4), args[5], args[6]);
		case BOTLIB_AAS_SETAASBLOCKINGENTITY:
			botlib_export->aas.AAS_SetAASBlockingEntity((float*)VMA(1), (float*)VMA(2), args[3]);
			return 0;
		case BOTLIB_AAS_RECORDTEAMDEATHAREA:
			botlib_export->aas.AAS_RecordTeamDeathArea((float*)VMA(1), args[2], args[3], args[4], args[5]);
			return 0;
		case BOTLIB_EA_SAY:
			botlib_export->ea.EA_Say(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_SAY_TEAM:
			botlib_export->ea.EA_SayTeam(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_USE_ITEM:
			botlib_export->ea.EA_UseItem(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_DROP_ITEM:
			botlib_export->ea.EA_DropItem(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_USE_INV:
			botlib_export->ea.EA_UseInv(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_DROP_INV:
			botlib_export->ea.EA_DropInv(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_GESTURE:
			botlib_export->ea.EA_Gesture(args[1]);
			return 0;
		case BOTLIB_EA_COMMAND:
			botlib_export->ea.EA_Command(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_EA_SELECT_WEAPON:
			botlib_export->ea.EA_SelectWeapon(args[1], args[2]);
			return 0;
		case BOTLIB_EA_TALK:
			botlib_export->ea.EA_Talk(args[1]);
			return 0;
		case BOTLIB_EA_ATTACK:
			botlib_export->ea.EA_Attack(args[1]);
			return 0;
		case BOTLIB_EA_RELOAD:
			botlib_export->ea.EA_Reload(args[1]);
			return 0;
		case BOTLIB_EA_USE:
			botlib_export->ea.EA_Use(args[1]);
			return 0;
		case BOTLIB_EA_RESPAWN:
			botlib_export->ea.EA_Respawn(args[1]);
			return 0;
		case BOTLIB_EA_JUMP:
			botlib_export->ea.EA_Jump(args[1]);
			return 0;
		case BOTLIB_EA_DELAYED_JUMP:
			botlib_export->ea.EA_DelayedJump(args[1]);
			return 0;
		case BOTLIB_EA_CROUCH:
			botlib_export->ea.EA_Crouch(args[1]);
			return 0;
		case BOTLIB_EA_WALK:
			botlib_export->ea.EA_Walk(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_UP:
			botlib_export->ea.EA_MoveUp(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_DOWN:
			botlib_export->ea.EA_MoveDown(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_FORWARD:
			botlib_export->ea.EA_MoveForward(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_BACK:
			botlib_export->ea.EA_MoveBack(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_LEFT:
			botlib_export->ea.EA_MoveLeft(args[1]);
			return 0;
		case BOTLIB_EA_MOVE_RIGHT:
			botlib_export->ea.EA_MoveRight(args[1]);
			return 0;
		case BOTLIB_EA_MOVE:
			botlib_export->ea.EA_Move(args[1], (float*)VMA(2), VMF(3));
			return 0;
		case BOTLIB_EA_VIEW:
			botlib_export->ea.EA_View(args[1], (float*)VMA(2));
			return 0;
		case BOTLIB_EA_PRONE:
			botlib_export->ea.EA_Prone(args[1]);
			return 0;
		case BOTLIB_EA_END_REGULAR:
			botlib_export->ea.EA_EndRegular(args[1], VMF(2));
			return 0;
		case BOTLIB_EA_GET_INPUT:
			botlib_export->ea.EA_GetInput(args[1], VMF(2), (bot_input_t*)VMA(3));
			return 0;
		case BOTLIB_EA_RESET_INPUT:
			botlib_export->ea.EA_ResetInput(args[1], (bot_input_t*)VMA(2));
			return 0;
		case BOTLIB_AI_LOAD_CHARACTER:
			return botlib_export->ai.BotLoadCharacter((char*)VMA(1), args[2]);
		case BOTLIB_AI_FREE_CHARACTER:
			botlib_export->ai.BotFreeCharacter(args[1]);
			return 0;
		case BOTLIB_AI_CHARACTERISTIC_FLOAT:
			return FloatAsInt(botlib_export->ai.Characteristic_Float(args[1], args[2]));
		case BOTLIB_AI_CHARACTERISTIC_BFLOAT:
			return FloatAsInt(botlib_export->ai.Characteristic_BFloat(args[1], args[2], VMF(3), VMF(4)));
		case BOTLIB_AI_CHARACTERISTIC_INTEGER:
			return botlib_export->ai.Characteristic_Integer(args[1], args[2]);
		case BOTLIB_AI_CHARACTERISTIC_BINTEGER:
			return botlib_export->ai.Characteristic_BInteger(args[1], args[2], args[3], args[4]);
		case BOTLIB_AI_CHARACTERISTIC_STRING:
			botlib_export->ai.Characteristic_String(args[1], args[2], (char*)VMA(3), args[4]);
			return 0;
		case BOTLIB_AI_ALLOC_CHAT_STATE:
			return botlib_export->ai.BotAllocChatState();
		case BOTLIB_AI_FREE_CHAT_STATE:
			botlib_export->ai.BotFreeChatState(args[1]);
			return 0;
		case BOTLIB_AI_QUEUE_CONSOLE_MESSAGE:
			botlib_export->ai.BotQueueConsoleMessage(args[1], args[2], (char*)VMA(3));
			return 0;
		case BOTLIB_AI_REMOVE_CONSOLE_MESSAGE:
			botlib_export->ai.BotRemoveConsoleMessage(args[1], args[2]);
			return 0;
		case BOTLIB_AI_NEXT_CONSOLE_MESSAGE:
			return botlib_export->ai.BotNextConsoleMessage(args[1], (bot_consolemessage_s*)VMA(2));
		case BOTLIB_AI_NUM_CONSOLE_MESSAGE:
			return botlib_export->ai.BotNumConsoleMessages(args[1]);
		case BOTLIB_AI_INITIAL_CHAT:
			botlib_export->ai.BotInitialChat(args[1], (char*)VMA(2), args[3], (char*)VMA(4), (char*)VMA(5), (char*)VMA(6), (char*)VMA(7), (char*)VMA(8), (char*)VMA(9), (char*)VMA(10), (char*)VMA(11));
			return 0;
		case BOTLIB_AI_NUM_INITIAL_CHATS:
			return botlib_export->ai.BotNumInitialChats(args[1], (char*)VMA(2));
		case BOTLIB_AI_REPLY_CHAT:
			return botlib_export->ai.BotReplyChat(args[1], (char*)VMA(2), args[3], args[4], (char*)VMA(5), (char*)VMA(6), (char*)VMA(7), (char*)VMA(8), (char*)VMA(9), (char*)VMA(10), (char*)VMA(11), (char*)VMA(12));
		case BOTLIB_AI_CHAT_LENGTH:
			return botlib_export->ai.BotChatLength(args[1]);
		case BOTLIB_AI_ENTER_CHAT:
			botlib_export->ai.BotEnterChat(args[1], args[2], args[3]);
			return 0;
		case BOTLIB_AI_GET_CHAT_MESSAGE:
			botlib_export->ai.BotGetChatMessage(args[1], (char*)VMA(2), args[3]);
			return 0;
		case BOTLIB_AI_STRING_CONTAINS:
			return botlib_export->ai.StringContains((char*)VMA(1), (char*)VMA(2), args[3]);
		case BOTLIB_AI_FIND_MATCH:
			return botlib_export->ai.BotFindMatch((char*)VMA(1), (bot_match_s*)VMA(2), args[3]);
		case BOTLIB_AI_MATCH_VARIABLE:
			botlib_export->ai.BotMatchVariable((bot_match_s*)VMA(1), args[2], (char*)VMA(3), args[4]);
			return 0;
		case BOTLIB_AI_UNIFY_WHITE_SPACES:
			botlib_export->ai.UnifyWhiteSpaces((char*)VMA(1));
			return 0;
		case BOTLIB_AI_REPLACE_SYNONYMS:
			botlib_export->ai.BotReplaceSynonyms((char*)VMA(1), args[2]);
			return 0;
		case BOTLIB_AI_LOAD_CHAT_FILE:
			return botlib_export->ai.BotLoadChatFile(args[1], (char*)VMA(2), (char*)VMA(3));
		case BOTLIB_AI_SET_CHAT_GENDER:
			botlib_export->ai.BotSetChatGender(args[1], args[2]);
			return 0;
		case BOTLIB_AI_SET_CHAT_NAME:
			botlib_export->ai.BotSetChatName(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_AI_RESET_GOAL_STATE:
			botlib_export->ai.BotResetGoalState(args[1]);
			return 0;
		case BOTLIB_AI_RESET_AVOID_GOALS:
			botlib_export->ai.BotResetAvoidGoals(args[1]);
			return 0;
		case BOTLIB_AI_REMOVE_FROM_AVOID_GOALS:
			botlib_export->ai.BotRemoveFromAvoidGoals(args[1], args[2]);
			return 0;
		case BOTLIB_AI_PUSH_GOAL:
			botlib_export->ai.BotPushGoal(args[1], (bot_goal_s*)VMA(2));
			return 0;
		case BOTLIB_AI_POP_GOAL:
			botlib_export->ai.BotPopGoal(args[1]);
			return 0;
		case BOTLIB_AI_EMPTY_GOAL_STACK:
			botlib_export->ai.BotEmptyGoalStack(args[1]);
			return 0;
		case BOTLIB_AI_DUMP_AVOID_GOALS:
			botlib_export->ai.BotDumpAvoidGoals(args[1]);
			return 0;
		case BOTLIB_AI_DUMP_GOAL_STACK:
			botlib_export->ai.BotDumpGoalStack(args[1]);
			return 0;
		case BOTLIB_AI_GOAL_NAME:
			botlib_export->ai.BotGoalName(args[1], (char*)VMA(2), args[3]);
			return 0;
		case BOTLIB_AI_GET_TOP_GOAL:
			return botlib_export->ai.BotGetTopGoal(args[1], (bot_goal_s*)VMA(2));
		case BOTLIB_AI_GET_SECOND_GOAL:
			return botlib_export->ai.BotGetSecondGoal(args[1], (bot_goal_s*)VMA(2));
		case BOTLIB_AI_CHOOSE_LTG_ITEM:
			return botlib_export->ai.BotChooseLTGItem(args[1], (float*)VMA(2), (int*)VMA(3), args[4]);
		case BOTLIB_AI_CHOOSE_NBG_ITEM:
			return botlib_export->ai.BotChooseNBGItem(args[1], (float*)VMA(2), (int*)VMA(3), args[4], (bot_goal_s*)VMA(5), VMF(6));
		case BOTLIB_AI_TOUCHING_GOAL:
			return botlib_export->ai.BotTouchingGoal((float*)VMA(1), (bot_goal_s*)VMA(2));
		case BOTLIB_AI_ITEM_GOAL_IN_VIS_BUT_NOT_VISIBLE:
			return botlib_export->ai.BotItemGoalInVisButNotVisible(args[1], (float*)VMA(2), (float*)VMA(3), (bot_goal_s*)VMA(4));
		case BOTLIB_AI_GET_LEVEL_ITEM_GOAL:
			return botlib_export->ai.BotGetLevelItemGoal(args[1], (char*)VMA(2), (bot_goal_s*)VMA(3));
		case BOTLIB_AI_GET_NEXT_CAMP_SPOT_GOAL:
			return botlib_export->ai.BotGetNextCampSpotGoal(args[1], (bot_goal_s*)VMA(2));
		case BOTLIB_AI_GET_MAP_LOCATION_GOAL:
			return botlib_export->ai.BotGetMapLocationGoal((char*)VMA(1), (bot_goal_s*)VMA(2));
		case BOTLIB_AI_AVOID_GOAL_TIME:
			return FloatAsInt(botlib_export->ai.BotAvoidGoalTime(args[1], args[2]));
		case BOTLIB_AI_INIT_LEVEL_ITEMS:
			botlib_export->ai.BotInitLevelItems();
			return 0;
		case BOTLIB_AI_UPDATE_ENTITY_ITEMS:
			botlib_export->ai.BotUpdateEntityItems();
			return 0;
		case BOTLIB_AI_LOAD_ITEM_WEIGHTS:
			return botlib_export->ai.BotLoadItemWeights(args[1], (char*)VMA(2));
		case BOTLIB_AI_FREE_ITEM_WEIGHTS:
			botlib_export->ai.BotFreeItemWeights(args[1]);
			return 0;
		case BOTLIB_AI_INTERBREED_GOAL_FUZZY_LOGIC:
			botlib_export->ai.BotInterbreedGoalFuzzyLogic(args[1], args[2], args[3]);
			return 0;
		case BOTLIB_AI_SAVE_GOAL_FUZZY_LOGIC:
			botlib_export->ai.BotSaveGoalFuzzyLogic(args[1], (char*)VMA(2));
			return 0;
		case BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC:
			botlib_export->ai.BotMutateGoalFuzzyLogic(args[1], VMF(2));
			return 0;
		case BOTLIB_AI_ALLOC_GOAL_STATE:
			return botlib_export->ai.BotAllocGoalState(args[1]);
		case BOTLIB_AI_FREE_GOAL_STATE:
			botlib_export->ai.BotFreeGoalState(args[1]);
			return 0;
		case BOTLIB_AI_RESET_MOVE_STATE:
			botlib_export->ai.BotResetMoveState(args[1]);
			return 0;
		case BOTLIB_AI_MOVE_TO_GOAL:
			botlib_export->ai.BotMoveToGoal((bot_moveresult_s*)VMA(1), args[2], (bot_goal_s*)VMA(3), args[4]);
			return 0;
		case BOTLIB_AI_MOVE_IN_DIRECTION:
			return botlib_export->ai.BotMoveInDirection(args[1], (float*)VMA(2), VMF(3), args[4]);
		case BOTLIB_AI_RESET_AVOID_REACH:
			botlib_export->ai.BotResetAvoidReach(args[1]);
			return 0;
		case BOTLIB_AI_RESET_LAST_AVOID_REACH:
			botlib_export->ai.BotResetLastAvoidReach(args[1]);
			return 0;
		case BOTLIB_AI_REACHABILITY_AREA:
			return botlib_export->ai.BotReachabilityArea((float*)VMA(1), args[2]);
		case BOTLIB_AI_MOVEMENT_VIEW_TARGET:
			return botlib_export->ai.BotMovementViewTarget(args[1], (bot_goal_s*)VMA(2), args[3], VMF(4), (float*)VMA(5));
		case BOTLIB_AI_PREDICT_VISIBLE_POSITION:
			return botlib_export->ai.BotPredictVisiblePosition((float*)VMA(1), args[2], (bot_goal_s*)VMA(3), args[4], (vec_t*)VMA(5));
		case BOTLIB_AI_ALLOC_MOVE_STATE:
			return botlib_export->ai.BotAllocMoveState();
		case BOTLIB_AI_FREE_MOVE_STATE:
			botlib_export->ai.BotFreeMoveState(args[1]);
			return 0;
		case BOTLIB_AI_INIT_MOVE_STATE:
			botlib_export->ai.BotInitMoveState(args[1], (bot_initmove_s*)VMA(2));
			return 0;
		case BOTLIB_AI_INIT_AVOID_REACH:
			botlib_export->ai.BotInitAvoidReach(args[1]);
			return 0;
		case BOTLIB_AI_CHOOSE_BEST_FIGHT_WEAPON:
			return botlib_export->ai.BotChooseBestFightWeapon(args[1], (int*)VMA(2));
		case BOTLIB_AI_GET_WEAPON_INFO:
			botlib_export->ai.BotGetWeaponInfo(args[1], args[2], (weaponinfo_s*)VMA(3));
			return 0;
		case BOTLIB_AI_LOAD_WEAPON_WEIGHTS:
			return botlib_export->ai.BotLoadWeaponWeights(args[1], (char*)VMA(2));
		case BOTLIB_AI_ALLOC_WEAPON_STATE:
			return botlib_export->ai.BotAllocWeaponState();
		case BOTLIB_AI_FREE_WEAPON_STATE:
			botlib_export->ai.BotFreeWeaponState(args[1]);
			return 0;
		case BOTLIB_AI_RESET_WEAPON_STATE:
			botlib_export->ai.BotResetWeaponState(args[1]);
			return 0;
		case BOTLIB_AI_GENETIC_PARENTS_AND_CHILD_SELECTION:
			return botlib_export->ai.GeneticParentsAndChildSelection(args[1], (float*)VMA(2), (int*)VMA(3), (int*)VMA(4), (int*)VMA(5));
		case G_ADD_PHYSICS_ENTITY:
#ifdef USE_PHYSICS
			CMod_PhysicsAddEntity((sharedEntity_t*)VMA(1));
#endif
			return 0;
		case G_ADD_PHYSICS_STATIC:
#ifdef USE_PHYSICS
			CMod_PhysicsAddStatic((sharedEntity_t*)VMA(1));
#endif
			return 0;
		case TRAP_MEMSET:
			memset(VMA(1), args[2], args[3]);
			return 0;
		case TRAP_MEMCPY:
			memcpy(VMA(1), VMA(2), args[3]);
			return 0;
		case TRAP_STRNCPY:
			return (intptr_t)strncpy( (char*)VMA( 1 ), (char*)VMA( 2 ), args[3] );
		case TRAP_SIN:
			return FloatAsInt(sin(VMF(1)));
		case TRAP_COS:
			return FloatAsInt(cos(VMF(1)));
		case TRAP_ATAN2:
			return FloatAsInt(atan2(VMF(1), VMF(2)));
		case TRAP_SQRT:
			return FloatAsInt(sqrt(VMF(1)));
		case TRAP_MATRIXMULTIPLY:
			AxisMultiply((vec3_t*)VMA(1), (vec3_t*)VMA(2), (vec3_t*)VMA(3));
			return 0;
		case TRAP_ANGLEVECTORS:
			AngleVectors((vec_t*)VMA(1), (vec_t*)VMA(2), (vec_t*)VMA(3), (vec_t*)VMA(4));
			return 0;
		case TRAP_PERPENDICULARVECTOR:
			PerpendicularVector((vec_t*)VMA(1), (vec_t*)VMA(2));
			return 0;
		case TRAP_FLOOR:
			return FloatAsInt(floor(VMF(1)));
		case TRAP_CEIL:
			return FloatAsInt(ceil(VMF(1)));
		case G_SENDMESSAGE:
			SV_SendBinaryMessage(args[1], (char*)VMA(2), args[3]);
			return 0;
		case G_MESSAGESTATUS:
			return SV_BinaryMessageStatus(args[1]);
#if defined(ET_MYSQL)
        case G_SQL_RUNQUERY:
                return OW_RunQuery( (char*)VMA(1) );
        case G_SQL_FINISHQUERY:
                OW_FinishQuery( args[1] );
                return 0;
        case G_SQL_NEXTROW:
                return OW_NextRow( args[1] );
        case G_SQL_ROWCOUNT:
                return OW_RowCount( args[1] );
        case G_SQL_GETFIELDBYID:
                OW_GetFieldByID( args[1], args[2], (char*)VMA(3), args[4]  );
                return 0;
        case G_SQL_GETFIELDBYNAME:
                OW_GetFieldByName( args[1], (char*)VMA(2), (char*)VMA(3), args[4] );
                return 0;
        case G_SQL_GETFIELDBYID_INT:
                return OW_GetFieldByID_int( args[1], args[2] );
        case G_SQL_GETFIELDBYNAME_INT:
                return OW_GetFieldByName_int( args[1], (char*)VMA(2) );
        case G_SQL_FIELDCOUNT:
                return OW_FieldCount( args[1] );
        case G_SQL_CLEANSTRING:
                OW_CleanString( (char*)VMA(1), (char*)VMA(2), args[3] );
                return 0;
#endif
		case G_RSA_GENMSG:
			return SV_RSAGenMsg( (char*)VMA(1), (char*)VMA(2), (char*)VMA(3) );
		default:
			Com_Error( ERR_DROP, "Bad game system trap: %ld", (long int) args[0] );
	}
	return -1;
}
예제 #12
0
/*
==================
Cmd_CallVote_f
==================
*/
__cdecl void Cmd_CallVote_f( gentity_t *ent ) {
	int i, activePlayers;
	char arg1[MAX_STRING_TOKENS];
	char arg2[MAX_STRING_TOKENS];
	char arg3[MAX_STRING_TOKENS];
	char cleanName[64];    // JPW NERVE
	int mask = 0;
	mvabuf;


	if ( !g_allowVote->boolean ) {
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_VOTINGNOTENABLED\"\0", 0x65));
		return;
	}
	if ( level.voteTime ) {
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_VOTEALLREADYINPROGRESS\"\0", 0x65));
		return;
	}
	if ( ent->client->pers.voteCount >= g_voteMaxVotes->integer ) {
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"You have called too many votes\"\0", 0x65));
		return;
	}
	if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_NOSPECTATORCALLVOTE\"\0", 0x65));
		return;
	}

	// make sure it is a valid command to vote on
	SV_Cmd_ArgvBuffer( 1, arg1, sizeof( arg1 ) );
	SV_Cmd_ArgvBuffer( 2, arg2, sizeof( arg2 ) );
	SV_Cmd_ArgvBuffer( 3, arg3, sizeof( arg3 ) );

	if ( strchr( arg1, ';' ) || strchr( arg2, ';' ) || strchr( arg3, ';' ) ) {
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_INVALIDVOTESTRING\"\0", 0x65));
		return;
	}

	if ( !Q_stricmp( arg1, "map_restart" ) ) {
		mask = VOTEFLAGS_RESTART;
	} else if ( !Q_stricmp( arg1, "map_rotate" ) ) {
		mask = VOTEFLAGS_NEXTMAP;
	} else if ( !Q_stricmp( arg1, "map" ) ) {
		mask = VOTEFLAGS_MAP;
	} else if ( !Q_stricmp( arg1, "typemap" ) ) {
		mask = VOTEFLAGS_TYPE;
	} else if ( !Q_stricmp( arg1, "kick" ) ) {
		mask = VOTEFLAGS_KICK;
	} else if ( !Q_stricmp( arg1, "tempbanuser" ) ) {
		mask = VOTEFLAGS_KICK;
	} else if ( !Q_stricmp( arg1, "g_gametype" ) ) {        // NERVE - SMF
		mask = VOTEFLAGS_GAMETYPE;
// jpw
	} else {
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_INVALIDVOTESTRING\"\0", 0x65));
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_VOTECOMMANDSARE\x15 map_restart, map_rotate, map <mapname>, g_gametype <gametype>, kick <player or clientnum>, typemap <gametype> <map>\"\0", 0x65));
		return;
	}

	if ( !( g_voteFlags & mask ) ) {
		SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"Voting for %s is disabled on this server\"\0", 0x65, arg1 ) );
		return;
	}

	// if there is still a vote to be executed
	if ( level.voteExecuteTime ) {
		level.voteExecuteTime = 0;
		Cbuf_AddText( va( "%s\n", level.voteString ) );
	}

	// special case for g_gametype, check for bad values
	if ( !Q_stricmp( arg1, "typemap" ) ) {
	
		if(*g_voteVoteGametypes->string){
			if(!strstr(g_voteVoteGametypes->string, arg2)){
				SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"Voting for gametype %s is disabled on this server\"\0", 0x65, arg2));
				return;
			}
		}

		for( i = 0; i < g_gametypes->numGametypes; i++){
			if(!Q_stricmp( arg2, g_gametypes->gametype[i].gametypename) )
				break;
		}
		if ( i == g_gametypes->numGametypes) {
			SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_INVALIDGAMETYPE\"\0", 0x65));
			return;
		}

		if( !(g_voteFlags & VOTEFLAGS_ANYMAP) ){
			if(!strstr(SV_GetMapRotation(), va("map %s",arg3))){
				SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"Voting for map %s is disabled on this server\"\0", 0x65, arg3));
				return;
			}
		}
		Com_sprintf( level.voteString, sizeof( level.voteString ), "set g_votedGametype %s; set g_votedMapName %s\n", arg2, arg3);
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "Set next map to: %s and gametype to: \x14%s", arg3, g_gametypes->gametype[i].gametypereadable);
		
	} else if ( !Q_stricmp( arg1, "g_gametype" ) ) {
	
		if(*g_voteVoteGametypes->string){
			if(!strstr(g_voteVoteGametypes->string, arg2)){
				SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"Voting for gametype %s is disabled on this server\"\0", 0x65, arg2));
				return;
			}
		}

		for( i = 0; i < g_gametypes->numGametypes; i++){
			if(!Q_stricmp( arg2, g_gametypes->gametype[i].gametypename) )
				break;
		}
		if ( i == g_gametypes->numGametypes) {
			SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_INVALIDGAMETYPE\"\0", 0x65));
			return;
		}

		Com_sprintf( level.voteString, sizeof( level.voteString ), "set g_gametype %s; map_restart\n", arg2);
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "Set gametype to: \x15%s and restart", g_gametypes->gametype[i].gametypename);

	} else if ( !Q_stricmp( arg1, "map_restart" ) ) {
		// NERVE - SMF - do a warmup when we restart maps
		Com_sprintf( level.voteString, sizeof( level.voteString ), "map_restart\n");
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "Restart current game" );
	} else if ( !Q_stricmp( arg1, "map" ) ) {

		if( !(g_voteFlags & VOTEFLAGS_ANYMAP) ){
			if(!strstr(SV_GetMapRotation(), va("map %s", arg2))){
				SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"This server does not allow voting for maps which aren't part of map-rotation\"\0", 0x65));
				return;
			}
		}
		Com_sprintf( level.voteString, sizeof( level.voteString ), "set g_votedMapName %s\n", arg2 );
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "Set next map to: %s", arg2 );
	} else if ( !Q_stricmp( arg1, "map_rotate" ) ) {

		if(*g_votedMapName->string){
			if(*g_votedGametype->string)
				Com_sprintf( level.voteString, sizeof( level.voteString ), "set g_gametype %s; map %s; set g_votedGametype \"\"; set g_votedMapName \"\"\n", g_votedGametype->string, g_votedMapName->string);
			else
				Com_sprintf( level.voteString, sizeof( level.voteString ), "map %s; set g_votedMapName \"\"\n", g_votedMapName->string);
			//Com_sprintf( s, sizeof( s ), g_votedMapName->string);
		}else{
			Com_sprintf( level.voteString, sizeof( level.voteString ), "map_rotate\n" );
			//Com_sprintf( s, sizeof( s ), g_votedMapName->string);
		}
		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "Switch to next map now");
// JPW NERVE
	} else if ( !Q_stricmp( arg1,"tempbanuser") || !Q_stricmp( arg1,"kick")) {

		int i, kicknum = MAX_CLIENTS;

		for ( i = 0, activePlayers = 0; i < level.maxclients; i++ ) {
			if ( level.clients[i].pers.connected != CON_CONNECTED || level.clients[i].sess.sessionTeam == TEAM_SPECTATOR) {
				continue;
			}
			activePlayers++;
		}
		if(activePlayers < g_voteKickMinPlayers->integer){
			SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_VOTINGNOTENOUGHPLAYERS\"\0", 0x65));
			return;
		}
		for ( i = 0; i < MAX_CLIENTS; i++ ) {
			if ( level.clients[i].pers.connected != CON_CONNECTED ) {
				continue;
			}
			// strip the color crap out
			Q_strncpyz( cleanName, level.clients[i].pers.netname, sizeof( cleanName ) );
			Q_CleanStr( cleanName );
			if ( !Q_stricmp( cleanName, arg2 ) ) {
				kicknum = i;
			}
		}

		if ( kicknum != MAX_CLIENTS ) { // found a client # to kick, so override votestring with better one

			Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s wants to kick and tempban: %s", ent->client->pers.netname ,level.clients[kicknum].pers.netname );

			if(svs.clients[kicknum].power > 5)
			{
				SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"Can not call a vote against a protected player\"\0", 0x65));
				level.voteDisplayString[0] = 0;
				return;
			}else{
				Com_sprintf( level.voteString, sizeof( level.voteString ),"tempban \"%d\" %im Vote kick; kick \"%d\" Vote kick\n", kicknum, g_voteBanTime->integer, kicknum);
			}

		} else { // if it can't do a name match, don't allow kick (to prevent votekick text spam wars)
			SV_GameSendServerCommand( ent - g_entities, 0, va("%c \"GAME_CLIENTNOTONSERVER\"\0", 0x65));
			level.voteDisplayString[0] = 0;
			return;
		}
// jpw
	} else {
//		Com_sprintf( level.voteString, sizeof( level.voteString ), "%s \"%s\"", arg1, arg2 );
//		Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
	}

	SV_GameSendServerCommand( -1, 0, va("%c \"GAME_CALLEDAVOTE\x15%s\"\0", 0x65, ent->client->pers.netname));
	ent->client->pers.voteCount++;

	// start the voting, the caller autoamtically votes yes
	level.voteTime = level.time + 1000*g_voteTime->integer;
	level.voteYes = 1;
	level.voteNo = 0;

	for ( i = 0 ; i < level.maxclients ; i++ ) {
		level.clients[i].ps.eFlags &= ~EF_VOTED;
	}
	ent->client->ps.eFlags |= EF_VOTED;

	SV_SetConfigstring( CS_VOTE_TIME, va( "%i %i", level.voteTime, sv_serverid->integer) );
	SV_SetConfigstring( CS_VOTE_STRING, level.voteDisplayString );
	SV_SetConfigstring( CS_VOTE_YES, va( "%i", level.voteYes ) );
	SV_SetConfigstring( CS_VOTE_NO, va( "%i", level.voteNo ) );
}
예제 #13
0
void CheckTeamStatus(void)
{
    int i;
    gentity_t *loc, *ent;

    if (level.time - level.lastTeamLocationTime > TEAM_LOCATION_UPDATE_TIME)
    {
        level.lastTeamLocationTime = level.time;

        for (i = 0; i < g_maxclients.integer; i++)
        {
            ent = g_entities + i;
            if (ent->client->pers.connected != CON_CONNECTED)
                continue;

            if (ent->inuse &&
                (ent->client->ps.stats[STAT_TEAM] == TEAM_HUMANS || ent->client->ps.stats[STAT_TEAM] == TEAM_ALIENS))
            {
                loc = Team_GetLocation(ent);

                if (loc)
                {
                    if (ent->client->pers.location != loc->s.generic1)
                    {
                        ent->client->pers.infoChangeTime = level.time;
                        ent->client->pers.location = loc->s.generic1;
                    }
                }
                else if (ent->client->pers.location != 0)
                {
                    ent->client->pers.infoChangeTime = level.time;
                    ent->client->pers.location = 0;
                }
            }
        }

        for (i = 0; i < g_maxclients.integer; i++)
        {
            ent = g_entities + i;
            if (ent->client->pers.connected != CON_CONNECTED)
                continue;

            if (ent->inuse)
                TeamplayInfoMessage(ent);
        }
    }

    // Warn on imbalanced teams
    if (g_teamImbalanceWarnings.integer && !level.intermissiontime &&
        (level.time - level.lastTeamImbalancedTime > (g_teamImbalanceWarnings.integer * 1000)) &&
        level.numTeamImbalanceWarnings < 3 && !level.restarted)
    {
        level.lastTeamImbalancedTime = level.time;
        if (level.numAlienSpawns > 0 && level.numHumanClients - level.numAlienClients > 2)
        {
            SV_GameSendServerCommand(-1,
                "print \"Teams are imbalanced. "
                "Humans have more players.\n\"");
            level.numTeamImbalanceWarnings++;
        }
        else if (level.numHumanSpawns > 0 && level.numAlienClients - level.numHumanClients > 2)
        {
            SV_GameSendServerCommand(-1,
                "print \"Teams are imbalanced. "
                "Aliens have more players.\n\"");
            level.numTeamImbalanceWarnings++;
        }
        else
        {
            level.numTeamImbalanceWarnings = 0;
        }
    }
}
예제 #14
0
/*
==================
TeamplayInfoMessage

Format:
  clientNum location health weapon upgrade

==================
*/
void TeamplayInfoMessage(gentity_t *ent)
{
    char entry[17], string[(MAX_CLIENTS - 1) * (sizeof(entry) - 1) + 1];
    int i, j;
    int team, stringlength;
    gentity_t *player;
    gclient_t *cl;
    upgrade_t upgrade = UP_NONE;
    int curWeaponClass = WP_NONE;  // sends weapon for humans, class for aliens
    const char *format;

    if (!g_allowTeamOverlay.integer)
        return;

    if (!ent->client->pers.teamInfo)
        return;

    if (ent->client->pers.teamSelection == TEAM_NONE)
    {
        if (ent->client->sess.spectatorState == SPECTATOR_FREE || ent->client->sess.spectatorClient < 0)
            return;
        team = g_entities[ent->client->sess.spectatorClient].client->pers.teamSelection;
    }
    else
        team = ent->client->pers.teamSelection;

    if (team == TEAM_ALIENS)
        format = " %i %i %i %i";  // aliens don't have upgrades
    else
        format = " %i %i %i %i %i";

    string[0] = '\0';
    stringlength = 0;

    for (i = 0; i < level.maxclients; i++)
    {
        player = g_entities + i;
        cl = player->client;

        if (ent == player || !cl || team != cl->pers.teamSelection || !player->inuse)
            continue;

        // only update if changed since last time
        if (cl->pers.infoChangeTime <= ent->client->pers.teamInfo)
            continue;

        if (cl->sess.spectatorState != SPECTATOR_NOT)
        {
            curWeaponClass = WP_NONE;
            upgrade = UP_NONE;
        }
        else if (cl->pers.teamSelection == TEAM_HUMANS)
        {
            curWeaponClass = cl->ps.weapon;

            if (BG_InventoryContainsUpgrade(UP_BATTLESUIT, cl->ps.stats))
                upgrade = UP_BATTLESUIT;
            else if (BG_InventoryContainsUpgrade(UP_JETPACK, cl->ps.stats))
                upgrade = UP_JETPACK;
            else if (BG_InventoryContainsUpgrade(UP_BATTPACK, cl->ps.stats))
                upgrade = UP_BATTPACK;
            else if (BG_InventoryContainsUpgrade(UP_HELMET, cl->ps.stats))
                upgrade = UP_HELMET;
            else if (BG_InventoryContainsUpgrade(UP_LIGHTARMOUR, cl->ps.stats))
                upgrade = UP_LIGHTARMOUR;
            else
                upgrade = UP_NONE;
        }
        else if (cl->pers.teamSelection == TEAM_ALIENS)
        {
            curWeaponClass = cl->ps.stats[STAT_CLASS];
            upgrade = UP_NONE;
        }

        Com_sprintf(entry, sizeof(entry), format, i, cl->pers.location,
            cl->ps.stats[STAT_HEALTH] < 1 ? 0 : cl->ps.stats[STAT_HEALTH], curWeaponClass, upgrade);

        j = strlen(entry);

        // this should not happen if entry and string sizes are correct
        if (stringlength + j >= sizeof(string))
            break;

        strcpy(string + stringlength, entry);
        stringlength += j;
    }

    if (string[0])
    {
        SV_GameSendServerCommand(ent - g_entities, va("tinfo%s", string));
        ent->client->pers.teamInfo = level.time;
    }
}
예제 #15
0
파일: g_main.c 프로젝트: osfpsproject/MF2
/*
=================
CheckExitRules

There will be a delay between the time the exit is qualified for
and the time everyone is moved to the intermission spot, so you
can see the last frag.
=================
*/
void CheckExitRules() 
{
	// if at the intermission, wait for all non-bots to
	// signal ready, then go to next level
	if( theLevel.intermissiontime_ ) 
	{
		CheckIntermissionExit ();
		return;
	}

	if( theLevel.intermissionQueued_ ) 
	{
		if ( theLevel.time_ - theLevel.intermissionQueued_ >= INTERMISSION_DELAY_TIME ) 
		{
			theLevel.intermissionQueued_ = 0;
			BeginIntermission();
		}
		return;
	}

	// check for sudden death
	if( ScoreIsTied() )
	{
		// always wait for sudden death
		return;
	}

	if( g_timelimit.integer && !theLevel.warmupTime_ ) 
	{
		if( theLevel.time_ - theLevel.startTime_ >= g_timelimit.integer*60000 ) 
		{
			SV_GameSendServerCommand( -1, "print \"Timelimit hit.\n\" \"<scoreboard>\"");
			LogExit( "Timelimit hit." );
			return;
		}
	}

	if( theLevel.numPlayingClients_ < 2 ) 
		return;

	if( g_gametype.integer < GT_CTF && g_fraglimit.integer ) 
	{
		if( theLevel.teamScores_[ClientBase::TEAM_RED] >= g_fraglimit.integer ) 
		{
			SV_GameSendServerCommand( -1, "print \"Red hit the fraglimit.\n\" \"<scoreboard>\"" );
			LogExit( "Fraglimit hit." );
			return;
		}

		if( theLevel.teamScores_[ClientBase::TEAM_BLUE] >= g_fraglimit.integer ) 
		{
			SV_GameSendServerCommand( -1, "print \"Blue hit the fraglimit.\n\" \"<scoreboard>\"" );
			LogExit( "Fraglimit hit." );
			return;
		}

		for( int i=1 ; i<= g_maxclients.integer ; i++ ) 
		{
			GameClient *cl = theLevel.getClient(i);
			if( !cl || cl->pers_.connected_ != GameClient::ClientPersistant::CON_CONNECTED ) 
				continue;

			if( cl->sess_.sessionTeam_ != ClientBase::TEAM_FREE ) 
				continue;

			if( cl->ps_.persistant[PERS_SCORE] >= g_fraglimit.integer )
			{
				LogExit( "Fraglimit hit." );
				SV_GameSendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " hit the fraglimit.\n\" \"<scoreboard>\"",
					cl->pers_.netname_ ) );
				return;
			}
		}
	}

	if( g_gametype.integer >= GT_CTF && g_capturelimit.integer )
	{

		if( theLevel.teamScores_[ClientBase::TEAM_RED] >= g_capturelimit.integer )
		{
			SV_GameSendServerCommand( -1, "print \"Red hit the capturelimit.\n\" \"<scoreboard>\"" );
			LogExit( "Capturelimit hit." );
			return;
		}

		if( theLevel.teamScores_[ClientBase::TEAM_BLUE] >= g_capturelimit.integer )
		{
			SV_GameSendServerCommand( -1, "print \"Blue hit the capturelimit.\n\" \"<scoreboard>\"" );
			LogExit( "Capturelimit hit." );
			return;
		}
	}
}