コード例 #1
0
ファイル: NET_MAIN.C プロジェクト: bsmr-games/Hexen2
void		NET_Shutdown (void)
{
	qsocket_t	*sock;

	SetNetTime();

	for (sock = net_activeSockets; sock; sock = sock->next)
		NET_Close(sock);

//
// shutdown the drivers
//
	for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
	{
		if (net_drivers[net_driverlevel].initialized == true)
		{
			net_drivers[net_driverlevel].Shutdown ();
			net_drivers[net_driverlevel].initialized = false;
		}
	}

	if (vcrFile != -1)
	{
		Con_Printf ("Closing vcrfile.\n");
		Sys_FileClose(vcrFile);
	}
}
コード例 #2
0
ファイル: cl_demo.c プロジェクト: atphalix/PSPCube
/*
==============
CL_StopPlayback

Called when a demo file runs out, or the user starts a game
==============
*/
void CL_StopPlayback (void)
{
	if (!cls.demoplayback)
		return;

	Sys_FileClose(cls.demofile);
	cls.demoplayback = false;
	cls.demofile = -1;
	cls.state = ca_disconnected;

	if (cls.timedemo)
		CL_FinishTimeDemo ();
}
コード例 #3
0
ファイル: host_cmd.c プロジェクト: ACIIL/Quakespasm-Rift
// Kill all the search packs until the game path is found. Kill it, then return
// the next path to it.
void KillGameDir(searchpath_t *search)
{
	searchpath_t *search_killer;
	while (search)
	{
		if (*search->filename)
		{
			com_searchpaths = search->next;
			Z_Free(search);
			return; //once you hit the dir, youve already freed the paks
		}
		Sys_FileClose (search->pack->handle); //johnfitz
		search_killer = search->next;
		Z_Free(search->pack->files);
		Z_Free(search->pack);
		Z_Free(search);
		search = search_killer;
	}
}
コード例 #4
0
ファイル: cl_demo.c プロジェクト: atphalix/PSPCube
/*
====================
CL_Stop_f

stop recording a demo
====================
*/
void CL_Stop_f (void)
{
	if (cmd_source != src_command)
		return;

	if (!cls.demorecording)
	{
		Con_Printf ("Not recording a demo.\n");
		return;
	}

// write a disconnect message to the demo file
	SZ_Clear (&net_message);
	MSG_WriteByte (&net_message, svc_disconnect);
	CL_WriteDemoMessage ();

// finish up
	Sys_FileClose(cls.demofile);
	cls.demofile = -1;
	cls.demorecording = false;
	Con_Printf ("Completed demo\n");
}
コード例 #5
0
ファイル: gl_screen.c プロジェクト: twinaphex/fxquake
/*
============
Image_WriteTGA -- writes RGB or RGBA data to a TGA file

returns true if successful

TODO: support BGRA and BGR formats (since opengl can return them, and we don't have to swap)
============
*/
qboolean Image_WriteTGA (char *name, byte *data, int width, int height, int bpp, qboolean upsidedown)
{
	int		handle, i, temp, size, bytes;
	char	pathname[MAX_OSPATH];
	byte	header[TARGAHEADERSIZE];

	sprintf (pathname, "%s/%s", com_gamedir, name);
	handle = Sys_FileOpenWrite (pathname);
	if (handle == -1)
		return false;

	memset (&header, 0, TARGAHEADERSIZE);
	header[2] = 2; // uncompressed type
	header[12] = width&255;
	header[13] = width>>8;
	header[14] = height&255;
	header[15] = height>>8;
	header[16] = bpp; // pixel size
	if (upsidedown)
		header[17] = 0x20; // upside-down attribute

	bytes = bpp/8;
	size = width*height*bytes;
	// swap red and blue bytes
	for (i=0; i<size; i+=bytes)
	{
		temp = data[i];
		data[i] = data[i+2];
		data[i+2] = temp;
	}

	Sys_FileWrite (handle, &header, TARGAHEADERSIZE);
	Sys_FileWrite (handle, data, size);
	Sys_FileClose (handle);

	return true;
}
コード例 #6
0
ファイル: main.cpp プロジェクト: BackupGGCode/quake-gamecube
		static void check_pak_file_exists()
		{
			int handle = -1;
			if (Sys_FileOpenRead(QUAKE_WII_BASEDIR"/id1/pak0.pak", &handle) < 0)
			{
				Sys_Error(
					QUAKE_WII_BASEDIR"/ID1/PAK0.PAK was not found.\n"
					"\n"
					"This file comes with the full or demo version of Quake\n"
					"and is necessary for the game to run.\n"
					"\n"
					"Please make sure it is on your SD card in the correct\n"
					"location.\n"
					"\n"
					"If you are absolutely sure the file is correct, your SD\n"
					"card may not be compatible with the SD card lib which\n"
					"Quake uses, or the Wii. Please check the issue tracker.");
				return;
			}
			else
			{
				Sys_FileClose(handle);
			}
		}
コード例 #7
0
void R_ReadPointFile_f (void)
{
	int		f;
	vec3_t	org;
	int		r, c;
	particle_t	*p;
	char	name[MAX_OSPATH];

	snprintf(name, sizeof(name), "maps/%s.pts", sv.name);

	COM_FOpenFile (name, &f);
	if (f < 0)
	{
		Con_Printf ("couldn't open %s\n", name);
		return;
	}

	Con_Printf ("Reading %s...\n", name);
	c = 0;
	for ( ;; )
	{
		// Read the line into a string.
		char line[128];
		int chars = 0;
		do
		{
			if (chars >= (sizeof(line) - 2))
			{
				Sys_Error("Line buffer overflow when reading point file");
			}

			if (!Sys_FileRead(f, &line[chars++], 1) != 1)
			{
				break;
			}
		}
		while (line[chars - 1] != '\n');
		line[chars] = '\0';

		r = sscanf (line, "%f %f %f\n", &org[0], &org[1], &org[2]);
		if (r != 3)
			break;
		c++;

		if (!free_particles)
		{
			Con_Printf ("Not enough free particles\n");
			break;
		}
		p = free_particles;
		free_particles = p->next;
		p->next = active_particles;
		active_particles = p;

		p->die = 99999;
		p->color = (-c)&15;
		p->type = pt_static;
		VectorCopy (vec3_origin, p->vel);
		VectorCopy (org, p->org);
	}

	Sys_FileClose(f);
	Con_Printf ("%i points read\n", c);
}
コード例 #8
0
ファイル: cd_revol.c プロジェクト: Izhido/qrevpak
void CDAudio_Play(byte track, qboolean looping)
{
	int i, lf;
	trackinfo_t* tnod;
	int trackHdl;
	int newTrackDataLength;
	byte* newTrackData;

	if (!enabled)
		return;
	
	if (!cdValid)
	{
		CDAudio_GetAudioDiskInfo();
		if (!cdValid)
			return;
	}

	track = remap[track];

	if (track < 1 || track > maxTrack)
	{
		Con_DPrintf("CDAudio: Bad track number %u.\n", track);
		return;
	}

	i = track;

	if(cd_nofirst.value)
		i--;
	
	if (playing)
	{
		if (playTrack == track)
			return;
		CDAudio_Stop();
	}

	lf = -1;
	tnod = CDAudio_GetTrack(trackList, i - 1, &lf); 

	if(tnod == NULL)
	{
		Con_Printf("CDAudio: Can't locate track %i\n", track);
		return;
	}

	newTrackDataLength = Sys_FileOpenRead(tnod->track, &trackHdl);
	if(newTrackDataLength <= 0)
	{
		Con_Printf("CDAudio: Can't open track %i\n", track);
		return;
	};

	if(trackData == NULL)
	{
		trackData = Sys_Malloc(newTrackDataLength, "CDAudio_Play");
		trackDataSize = newTrackDataLength;
	} else if(trackDataSize < newTrackDataLength)
	{
		newTrackData = realloc(trackData, newTrackDataLength);
		if(newTrackData == NULL)
		{
			free(trackData);
			trackData = Sys_Malloc(newTrackDataLength, "CDAudio_Play");
		} else
		{
			trackData = newTrackData;
		};
		trackDataSize = newTrackDataLength;
	};
	trackDataLength = newTrackDataLength;

	Sys_FileRead(trackHdl, trackData, trackDataLength);
	Sys_FileClose(trackHdl);

	if(PlayOgg(trackData, trackDataLength, 0, looping ? OGG_INFINITE_TIME : OGG_ONE_TIME))
	{
		Con_Printf("CDAudio: Can't play track %i\n", track);
		return;
	};

	playLooping = looping;
	playTrack = track;
	playing = true;

	//Con_Printf("Now playing: %s\n", tnod->track);

	if (cdvolume == 0.0)
		CDAudio_Pause ();
}