void model_collide_parse_bsp_flatpoly(bsp_collision_leaf *leaf, SCP_vector<model_tmap_vert> *vert_buffer, void *model_ptr)
{
	ubyte *p = (ubyte *)model_ptr;

	int i;
	int nv;
	short *verts;

	nv = w(p+36);

	if ( nv < 0 ) return;

	if ( nv > TMAP_MAX_VERTS ) {
		Int3();
		return;
	}

	verts = (short *)(p+44);

	leaf->tmap_num = 255;
	leaf->num_verts = (ubyte)nv;
	leaf->vert_start = vert_buffer->size();

	vec3d *plane_pnt = vp(p+20);
	float face_rad = fl(p+32);
	vec3d *plane_norm = vp(p+8);

	leaf->plane_pnt = *plane_pnt;
	leaf->face_rad = face_rad;
	leaf->plane_norm = *plane_norm;

	model_tmap_vert vert;

	for ( i = 0; i < nv; ++i ) {
		vert.vertnum = verts[i*2];
		vert.normnum = 0;
		vert.u = 0.0f;
		vert.v = 0.0f;

		vert_buffer->push_back(vert);
	}
}
int event_editor::handler(int code, int node, char *str)
{
	int i, index;

	switch (code) {
		case ROOT_DELETED:
			for (i=0; i<m_num_events; i++)
				if (m_events[i].formula == node)
					break;

			Assert(i < m_num_events);
			index = i;
			while (i < m_num_events - 1) {
				m_events[i] = m_events[i + 1];
				m_sig[i] = m_sig[i + 1];
				i++;
			}

			m_num_events--;
			GetDlgItem(IDC_BUTTON_NEW_EVENT)->EnableWindow(TRUE);

			cur_event = index;
			update_cur_event();

			return node;

		case ROOT_RENAMED:
			for (i=0; i<m_num_events; i++)
				if (m_events[i].formula == node)
					break;

			Assert(i < m_num_events);
			Assert(strlen(str) < NAME_LENGTH);
			strcpy_s(m_events[i].name, str);
			return node;

		default:
			Int3();
	}

	return -1;
}
Example #3
0
void batching_add_volume_bitmap_rotated(int texture, vertex *pnt, float angle, float rad, float alpha, float depth)
{
    if ( texture < 0 ) {
        Int3();
        return;
    }

    primitive_batch *batch;

    if ( gr_is_capable(CAPABILITY_SOFT_PARTICLES) ) {
        batch = batching_find_batch(texture, batch_info::VOLUME_EMISSIVE);
    } else {
        batch = batching_find_batch(texture, batch_info::FLAT_EMISSIVE);
    }

    color clr;
    batching_determine_blend_color(&clr, texture, alpha);

    batching_add_bitmap_rotated_internal(batch, pnt, angle, rad, &clr, depth);
}
Example #4
0
//version of dump for unsigned values
static void dump_fix_as_ushort( fix value, int nbits, PHYSFS_File *SaveFile )
{
        uint int_value=0;
	ushort short_value;

	if (value < 0) {
		Int3();		//hey---show this to Matt
		value = 0;
	}
	else
		int_value = value >> nbits;

	if( int_value > 0xffff ) {
		short_value = 0xffff;
	}
	else
		short_value = int_value;

	PHYSFS_writeULE16(SaveFile, short_value);
}
// Open a stream for real-time voice output
int rtvoice_create_playback_buffer()
{
	int			index;
	rtv_format	*rtvf=NULL;

	rtvf = &Rtv_formats[Rtv_playback_format];
	index = rtvoice_find_free_output_buffer();

	if ( index == -1 ) {
		Int3();
		return -1;
	}
	
	Rtv_output_buffers[index].ds_handle = ds_create_buffer(rtvf->frequency, rtvf->bits_per_sample, 1, RTV_BUFFER_TIME);
	if ( Rtv_output_buffers[index].ds_handle == -1 ) {
		return -1;
	}

	return index;
}
Example #6
0
//------------------------------------------------------------
//	Trigger (enable) the materialization center in segment segnum
void trigger_matcen(int segnum)
{
	// -- segment		*segp = &Segments[segnum];
	segment2		*seg2p = &Segment2s[segnum];
	vms_vector	pos, delta;
	FuelCenter	*robotcen;
	int			objnum;

	Assert(seg2p->special == SEGMENT_IS_ROBOTMAKER);
	Assert(seg2p->matcen_num < Num_fuelcenters);
	Assert((seg2p->matcen_num >= 0) && (seg2p->matcen_num <= Highest_segment_index));

	robotcen = &Station[RobotCenters[seg2p->matcen_num].fuelcen_num];

	if (robotcen->Enabled == 1)
		return;

	if (!robotcen->Lives)
		return;

	//	MK: 11/18/95, At insane, matcens work forever!
	if (Difficulty_level+1 < NDL)
		robotcen->Lives--;

	robotcen->Timer = F1_0*1000;	//	Make sure the first robot gets emitted right away.
	robotcen->Enabled = 1;			//	Say this center is enabled, it can create robots.
	robotcen->Capacity = i2f(Difficulty_level + 3);
	robotcen->Disable_time = MATCEN_LIFE;

	//	Create a bright object in the segment.
	pos = robotcen->Center;
	vm_vec_sub(&delta, &Vertices[Segments[segnum].verts[0]], &robotcen->Center);
	vm_vec_scale_add2(&pos, &delta, F1_0/2);
	objnum = obj_create( OBJ_LIGHT, 0, segnum, &pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
	if (objnum != -1) {
		Objects[objnum].lifeleft = MATCEN_LIFE;
		Objects[objnum].ctype.light_info.intensity = i2f(8);	//	Light cast by a fuelcen.
	} else {
		Int3();
	}
}
Example #7
0
int anim_save_init(char *file, int width, int height, int frames)
{
	Assert(file);
	anim_save_filename = file;
	anim_fp = fopen(file, "wb");
	if (!anim_fp)
		return -1;

	Anim.version = ANIM_VERSION;
	Anim.fps = Default_fps;
	Anim.width = width;
	Anim.height = height;
	Anim.packer_code = PACKER_CODE;
	Anim.xparent_r = Xparent_color.r;
	Anim.xparent_g = Xparent_color.g;
	Anim.xparent_b = Xparent_color.b;
	Anim.total_frames = frames;
	anim_offset = 0;
	cur_frame_num = 0;
	total_key_frames = allocate_key_frames(frames);
	fseek(anim_fp, ANIM_HEADER_SIZE + total_key_frames * 6, SEEK_SET);

	switch ( Compression_type ) {
		case CUSTOM_DELTA_RLE:
			Key_frame_compression = PACKING_METHOD_RLE_KEY;
			Regular_frame_compression = PACKING_METHOD_RLE;
			break;

		case STD_DELTA_RLE:
			Key_frame_compression = PACKING_METHOD_STD_RLE_KEY;
			Regular_frame_compression = PACKING_METHOD_STD_RLE;
			break;

		default:
			Int3();
			return -1;
			break;
	} // end switch

	return 0;
}
Example #8
0
// -----------------------------------------------------------------------------
//go through all triggers, killing unused ones
static void CheckAndFixTriggers (void)
{
	int	i, j;
	short	nSegment, nSide, nWall;

for (i = 0; i < gameData.trigs.m_nTriggers; ) {
	//	Find which CWall this CTrigger is connected to.
	for (j = 0; j < gameData.walls.nWalls; j++)
		if (WALLS [j].nTrigger == i)
			break;
		i++;
	}

for (i = 0; i < gameData.walls.nWalls; i++)
	WALLS [i].controllingTrigger = -1;

//	MK, 10/17/95: Make walls point back at the triggers that control them.
//	Go through all triggers, stuffing controllingTrigger field in WALLS.

CTrigger* trigP = TRIGGERS.Buffer ();
for (i = 0; i < gameData.trigs.m_nTriggers; i++, trigP++) {
	for (j = 0; j < trigP->m_info.nLinks; j++) {
		nSegment = trigP->m_info.segments [j];
		nSide = trigP->m_info.sides [j];
		nWall = SEGMENTS [nSegment].WallNum (nSide);
		//check to see that if a CTrigger requires a CWall that it has one,
		//and if it requires a botGen that it has one
		if (trigP->m_info.nType == TT_MATCEN) {
			if (SEGMENTS [nSegment].m_nType != SEGMENT_IS_ROBOTMAKER)
				continue;		//botGen CTrigger doesn'i point to botGen
			}
		else if ((trigP->m_info.nType != TT_LIGHT_OFF) && (trigP->m_info.nType != TT_LIGHT_ON)) { //light triggers don't require walls
			if (IS_WALL (nWall))
				WALLS [nWall].controllingTrigger = i;
			else {
				Int3();	//	This is illegal.  This ttrigger requires a CWall
				}
			}
		}
	}
}
int batch_add_bitmap(int texture, int tmap_flags, vertex *pnt, int orient, float rad, float alpha, float depth)
{
	if (texture < 0) {
		Int3();
		return 1;
	}

	if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || GLSL_version <= 120 ) ) {
		// don't render this as a soft particle if we don't support soft particles
		tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
	}

	if ( GLSL_version > 120 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && Is_Extension_Enabled(OGL_EXT_GEOMETRY_SHADER4) && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
		geometry_batch_add_bitmap(texture, tmap_flags, pnt, orient, rad, alpha, depth);
		return 0;
	} else if ( tmap_flags & TMAP_FLAG_VERTEX_GEN ) {
		tmap_flags &= ~(TMAP_FLAG_VERTEX_GEN);
	}

	batch_item *item = NULL;

	SCP_map<int, batch_item>::iterator it = geometry_map.find(texture);

	if ( !geometry_map.empty() && it != geometry_map.end() ) {
		item = &it->second;
	} else {
		item = &geometry_map[texture];
		item->texture = texture;
	}

	Assertion( (item->laser == false), "Particle effect %s used as laser glow or laser bitmap\n", bm_get_filename(texture) );

	item->tmap_flags = tmap_flags;
	item->alpha = alpha;

	item->batch.add_allocate(1);

	item->batch.draw_bitmap(pnt, orient, rad, depth);

	return 0;
}
Example #10
0
void StopTime (void)
{
if (pfnTIRStop)
	pfnTIRStop ();
if (++gameData.time.nPaused == 1) {
	fix xTime = TimerGetFixedSeconds ();
	gameData.time.xSlack = xTime - gameData.time.xLast;
	if (gameData.time.xSlack < 0) {
#if defined (TIMER_TEST) && defined (_DEBUG)
		Int3 ();		//get Matt!!!!
#endif
		gameData.time.xLast = 0;
		}
#if defined (TIMER_TEST) && defined (_DEBUG)
	gameData.time.xStopped = xTime;
	#endif
	}
#if defined (TIMER_TEST) && defined (_DEBUG)
gameData.time.xStops++;
#endif
}
Example #11
0
int vga_vesa_setmode( short mode )
{
	int retcode;

#if defined(POLY_ACC)
	Int3();
    mprintf((0, "vga_vesa_setmode %d\n"));
    return 0;
#endif

	if (VesaInit (mode))  // if there is an error with linear support
	 {
		LinearSVGABuffer=1;
		return(0);
	 }
	
   LinearSVGABuffer=0;
	retcode=gr_vesa_checkmode( mode );		// do the old banking way
	if ( retcode ) return retcode;
	return gr_vesa_setmodea( mode );
}
Example #12
0
File: error.c Project: paud/d2x-xl
//------------------------------------------------------------------------------
//terminates with error code 1, printing message
void _CDECL_ Error (char *fmt,...)
{
	va_list arglist;

#ifndef _DEBUG
strcpy (szExitMsg, TXT_TITLE_ERROR); // don't put the new line in for dialog output
#else
sprintf (szExitMsg, "\n%s", TXT_TITLE_ERROR);
#endif
va_start (arglist,fmt);
vsprintf (szExitMsg + strlen (szExitMsg), fmt, arglist);
va_end(arglist);
LogErr ("ERROR: %s\n", szExitMsg);
D2MsgBox (szExitMsg, MB_ICONERROR);
Int3();
if (!err_initialized) 
	print_exit_message();
#ifndef _DEBUG
exit (1);
#endif
}
Example #13
0
//------------------------------------------------------------
//	Trigger (enable) the materialization center in segment segnum
void trigger_matcen(const vsegptridx_t segnum)
{
	const auto &segp = segnum;
	FuelCenter	*robotcen;

	Assert(segp->special == SEGMENT_IS_ROBOTMAKER);
	Assert(segp->matcen_num < Num_fuelcenters);
	Assert((segp->matcen_num >= 0) && (segp->matcen_num <= Highest_segment_index));

	robotcen = &Station[RobotCenters[segp->matcen_num].fuelcen_num];

	if (robotcen->Enabled == 1)
		return;

	if (!robotcen->Lives)
		return;

#if defined(DXX_BUILD_DESCENT_II)
	//	MK: 11/18/95, At insane, matcens work forever!
	if (Difficulty_level+1 < NDL)
#endif
		robotcen->Lives--;

	robotcen->Timer = F1_0*1000;	//	Make sure the first robot gets emitted right away.
	robotcen->Enabled = 1;			//	Say this center is enabled, it can create robots.
	robotcen->Capacity = i2f(Difficulty_level + 3);
	robotcen->Disable_time = MATCEN_LIFE;

	//	Create a bright object in the segment.
	auto pos = compute_segment_center(segp);
	const auto delta = vm_vec_sub(Vertices[segnum->verts[0]], pos);
	vm_vec_scale_add2(pos, delta, F1_0/2);
	auto objnum = obj_create( OBJ_LIGHT, 0, segnum, pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
	if (objnum != object_none) {
		objnum->lifeleft = MATCEN_LIFE;
		objnum->ctype.light_info.intensity = i2f(8);	//	Light cast by a fuelcen.
	} else {
		Int3();
	}
}
//calls the object interpreter to render an object.  The object renderer
//is really a seperate pipeline. returns true if drew
int model_collide_sub(void *model_ptr )
{
	ubyte *p = (ubyte *)model_ptr;
	int chunk_type, chunk_size;
	vec3d hitpos;

	chunk_type = w(p);
	chunk_size = w(p+4);

	while (chunk_type != OP_EOF)	{

//		mprintf(( "Processing chunk type %d, len=%d\n", chunk_type, chunk_size ));

		switch (chunk_type) {
		case OP_EOF: return 1;
		case OP_DEFPOINTS:	model_collide_defpoints(p); break;
		case OP_FLATPOLY:		model_collide_flatpoly(p); break;
		case OP_TMAPPOLY:		model_collide_tmappoly(p); break;
		case OP_SORTNORM:		model_collide_sortnorm(p); break;
		case OP_BOUNDBOX:	
			if ( mc_ray_boundingbox( vp(p+8), vp(p+20), &Mc_p0, &Mc_direction, &hitpos ) )	{
				if ( !(Mc->flags & MC_CHECK_RAY) && (vm_vec_dist(&hitpos, &Mc_p0) > Mc_mag) ) {
					// The ray isn't long enough to intersect the bounding box
					return 1;
				}
			} else {
				return 1;
			}
			break;
		default:
			mprintf(( "Bad chunk type %d, len=%d in model_collide_sub\n", chunk_type, chunk_size ));
			Int3();		// Bad chunk type!
			return 0;
		}
		p += chunk_size;
		chunk_type = w(p);
		chunk_size = w(p+4);
	}
	return 1;
}
// Textured Poly
// +0      int         id
// +4      int         size 
// +8      vec3d      normal
// +20     vec3d      normal_point
// +32     int         tmp = 0
// +36     int         nverts
// +40     int         tmap_num
// +44     nverts*(model_tmap_vert) vertlist (n,u,v)
void model_collide_tmappoly(ubyte * p)
{
	int i;
	int nv;
	uv_pair uvlist[TMAP_MAX_VERTS];
	vec3d *points[TMAP_MAX_VERTS];
	model_tmap_vert *verts;

	nv = w(p+36);
	if ( nv < 0 ) return;

	if ( nv > TMAP_MAX_VERTS ) {
		Int3();
		return;
	}

	int tmap_num = w(p+40);
	Assert(tmap_num >= 0 && tmap_num < MAX_MODEL_TEXTURES);	// Goober5000

	if ( (!(Mc->flags & MC_CHECK_INVISIBLE_FACES)) && (Mc_pm->maps[tmap_num].textures[TM_BASE_TYPE].GetTexture() < 0) )	{
		// Don't check invisible polygons.
		//SUSHI: Unless $collide_invisible is set.
		if (!(Mc_pm->submodel[Mc_submodel].collide_invisible))
			return;
	}

	verts = (model_tmap_vert *)(p+44);

	for (i=0;i<nv;i++)	{
		points[i] = Mc_point_list[verts[i].vertnum];
		uvlist[i].u = verts[i].u;
		uvlist[i].v = verts[i].v;
	}

	if ( Mc->flags & MC_CHECK_SPHERELINE )	{
		mc_check_sphereline_face(nv, points, vp(p+20), fl(p+32), vp(p+8), uvlist, tmap_num, p, NULL);
	} else {
		mc_check_face(nv, points, vp(p+20), fl(p+32), vp(p+8), uvlist, tmap_num, p, NULL);
	}
}
Example #16
0
void add_builtin_mission_to_list(int *count)
{
gameData.missions.nBuiltinHogSize = CFSize("descent2.hog", gameFolders.szDataDir, 0);
if (gameData.missions.nBuiltinHogSize == -1)
	gameData.missions.nBuiltinHogSize = CFSize("d2demo.hog", gameFolders.szDataDir, 0);

retry:

switch (gameData.missions.nBuiltinHogSize) {
	case SHAREWARE_MISSION_HOGSIZE:
	case MAC_SHARE_MISSION_HOGSIZE:
		strcpy(gameData.missions.list [*count].filename,SHAREWARE_MISSION_FILENAME);
		strcpy(gameData.missions.list [*count].mission_name,SHAREWARE_MISSION_NAME);
		gameData.missions.list [*count].anarchy_only_flag = 0;
		break;
	case OEM_MISSION_HOGSIZE:
		strcpy(gameData.missions.list [*count].filename,OEM_MISSION_FILENAME);
		strcpy(gameData.missions.list [*count].mission_name,OEM_MISSION_NAME);
		gameData.missions.list [*count].anarchy_only_flag = 0;
		break;
	case FULL_MISSION_HOGSIZE:
	case FULL_10_MISSION_HOGSIZE:
	case MAC_FULL_MISSION_HOGSIZE:
		if (!ReadMissionFile(FULL_MISSION_FILENAME ".mn2", 0, ML_CURDIR))
			Error("Could not find required mission file <%s>", FULL_MISSION_FILENAME ".mn2");
		break;
	default:
#if 0//def _DEBUG
		Warning(TXT_HOGSIZE, gameData.missions.nBuiltinHogSize, FULL_MISSION_FILENAME ".mn2");
#endif
		gameData.missions.nBuiltinHogSize = FULL_MISSION_HOGSIZE;
		Int3(); //fall through
		goto retry;
	}
strcpy(gameData.missions.szBuiltinMissionFilename, gameData.missions.list [*count].filename);
gameData.missions.list [*count].descent_version = 2;
gameData.missions.list [*count].anarchy_only_flag = 0;
gameData.missions.list [*count].location = ML_DATADIR;
++(*count);
}
Example #17
0
//-----------------------------------------------------------------
// Closes a door
void CSegment::CloseDoor (int nSide)
{
	CWall*	wallP;

if (!(wallP = Wall (nSide)))
	return;
if ((wallP->state == WALL_DOOR_CLOSING) ||		//already closing
	 (wallP->state == WALL_DOOR_WAITING) ||		//open, waiting to close
	 (wallP->state == WALL_DOOR_CLOSED))			//closed
	return;
if (DoorIsBlocked (nSide))
	return;

	CActiveDoor*	doorP;

if (!(doorP = wallP->CloseDoor ()))
	return;

	CSegment*		connSegP;
	short				nConnSide, nConnWall;

connSegP = SEGMENTS + m_children [nSide];
nConnSide = ConnectedSide (connSegP);
nConnWall = connSegP->WallNum (nConnSide);
if (IS_WALL (nConnWall))
	WALLS [nConnWall].state = WALL_DOOR_CLOSING;
doorP->nFrontWall [0] = WallNum (nSide);
doorP->nBackWall [0] = nConnWall;
Assert(SEG_IDX (this) != -1);
if (gameData.demo.nState == ND_STATE_RECORDING)
	NDRecordDoorOpening (SEG_IDX (this), nSide);
if (IS_WALL (wallP->nLinkedWall))
	Int3();		//don't think we ever used linked walls
else
	doorP->nPartCount = 1;
if (gameData.demo.nState != ND_STATE_PLAYBACK) {
	if (gameData.walls.animP [wallP->nClip].openSound > -1)
		CreateSound (gameData.walls.animP [wallP->nClip].openSound, nSide);
	}
}
Example #18
0
// Open a digital sound file for streaming
//
// input:	filename	=>	disk filename of sound file
//				type		=> what type of audio stream do we want to open:
//									ASF_SOUNDFX
//									ASF_EVENTMUSIC
//									ASF_VOICE
//	
// returns:	success => handle to identify streaming sound
//				failure => -1
int audiostream_open( char * filename, int type )
{
	int i, rc;
	if (!Audiostream_inited || !snd_is_inited())
		return -1;

	for ( i = 0; i < MAX_AUDIO_STREAMS; i++ ) {
		if ( Audio_streams[i].status == ASF_FREE ) {
			Audio_streams[i].status = ASF_USED;
			Audio_streams[i].type = type;
			break;
		}
	}

	if ( i == MAX_AUDIO_STREAMS ) {
		nprintf(("Sound", "SOUND => No more audio streams available!\n"));
		return -1;
	}

	switch(type) {
	case ASF_VOICE:
	case ASF_SOUNDFX:
		Audio_streams[i].m_bits_per_sample_uncompressed = 8;
		break;
	case ASF_EVENTMUSIC:
		Audio_streams[i].m_bits_per_sample_uncompressed = 16;
		break;
	default:
		Int3();
		return -1;
	}
	
	rc = Audio_streams[i].Create(filename, m_pass);
	if ( rc == 0 ) {
		Audio_streams[i].status = ASF_FREE;
		return -1;
	}
	else
		return i;
}
void gr_opengl_bm_save_render_target(int n)
{
	Assert( (n >= 0) && (n < MAX_BITMAPS) );

	if ( !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) || Cmdline_no_fbo ) {
		return;
	}

	bitmap_entry *be = &bm_bitmaps[n];
	bitmap *bmp = &be->bm;

	size_t rc = opengl_export_render_target( n, bmp->w, bmp->h, (bmp->true_bpp == 32), be->num_mipmaps, (ubyte*)bmp->data );

	if (rc != be->mem_taken) {
		Int3();
		return;
	}

	if (Cmdline_save_render_targets) {
		dds_save_image(bmp->w, bmp->h, bmp->true_bpp, be->num_mipmaps, (ubyte*)bmp->data, (bmp->flags & BMP_FLAG_CUBEMAP));
	}
}
Example #20
0
void gr_opengl_delete_buffer(int handle)
{
	if (GL_buffer_objects.size() == 0) return;

	GR_DEBUG_SCOPE("Deleting buffer");

	Assert(handle >= 0);
	Assert((size_t)handle < GL_buffer_objects.size());

	opengl_buffer_object &buffer_obj = GL_buffer_objects[handle];

	// de-bind the buffer point so we can clear the recorded state.
	switch ( buffer_obj.type ) {
	case GL_ARRAY_BUFFER:
		GL_state.Array.BindArrayBuffer(0);
		break;
	case GL_ELEMENT_ARRAY_BUFFER:
		GL_state.Array.BindElementBuffer(0);
		break;
	case GL_TEXTURE_BUFFER:
		GL_state.Array.BindTextureBuffer(0);
		break;
	case GL_UNIFORM_BUFFER:
		GL_state.Array.BindUniformBuffer(0);
		break;
	default:
		Int3();
		return;
		break;
	}

	if ( buffer_obj.type == GL_TEXTURE_BUFFER ) {
		glDeleteTextures(1, &buffer_obj.texture);
	}

	GL_vertex_data_in -= buffer_obj.size;

	glDeleteBuffers(1, &buffer_obj.buffer_id);
}
Example #21
0
//version of dump for unsigned values
void dump_fix_as_ushort( fix value, int nbits, CFILE * SaveFile )
{
	uint int_value;
	ushort short_value;

	if (value < 0) {
		mprintf((1, "Warning: fix (%8x) is signed...setting to zero.\n", value));
		Int3();		//hey---show this to Matt
		value = 0;
	}
	else
		int_value = value >> nbits;

	if( int_value > 0xffff ) {
		short_value = 0xffff;
		mprintf((1, "Warning: Fix (%8x) won't fit in unsigned short.  Saturating to %8x.\n", int_value, short_value<<nbits));
	}
	else
		short_value = int_value;

	cfwrite( &short_value, sizeof(short_value), 1, SaveFile );
}
Example #22
0
//------------- Called once when a hostage is rescued ------------------------------------------
void hostage_rescue( int hostage_number )
{
	if ( (hostage_number<0) || (hostage_number>=MAX_HOSTAGES) )	{
			Int3();		// Get John!
			return;
	}

	PALETTE_FLASH_ADD(0,0,25);		//small blue flash

	Players[Player_num].hostages_on_board++;

	// Do an audio effect
	if ( Newdemo_state != ND_STATE_PLAYBACK )
		digi_play_sample( SOUND_HOSTAGE_RESCUED, F1_0 );

 #ifndef HOSTAGE_FACES

	HUD_init_message(HM_DEFAULT, TXT_HOSTAGE_RESCUED);

 #else

	// Show the text message
	if ( strlen(Hostages[hostage_number].text) ) 
		gauge_message("%s", Hostages[hostage_number].text );
	else	{
		if ( Hostage_num_globals > 0 )	{
			int mn;
                        mn = (d_rand()*Hostage_num_globals)/D_RAND_MAX;
			if ( mn>=0 && mn < Hostage_num_globals )
				gauge_message("%s", &Hostage_global_message[mn][0] );
		}
	}

	if ( Newdemo_state == ND_STATE_RECORDING )
		newdemo_record_hostage_rescued( hostage_number );

	queue_hostage_clip(hostage_number);
 #endif
}
/**
 * Add a message to the queue to be sent later
 */
void message_training_queue(char *text, int timestamp, int length)
{
	int m;
	char temp_buf[TRAINING_MESSAGE_LENGTH];

	Assert(Training_message_queue_count < TRAINING_MESSAGE_QUEUE_MAX);
	if (Training_message_queue_count < TRAINING_MESSAGE_QUEUE_MAX) {
		if (!stricmp(text, NOX("none"))) {
			m = -1;
		} else {
			for (m=0; m<Num_messages; m++)
				if (!stricmp(text, Messages[m].name))
					break;

			Assert(m < Num_messages);
			if (m >= Num_messages)
				return;
		}

		Training_message_queue[Training_message_queue_count].num = m;
		Training_message_queue[Training_message_queue_count].timestamp = timestamp;
		Training_message_queue[Training_message_queue_count].length = length;

		// Goober5000 - this shouldn't happen, but let's be safe
		if (Training_message_queue[Training_message_queue_count].special_message != NULL)
		{
			Int3();
			vm_free(Training_message_queue[Training_message_queue_count].special_message);
			Training_message_queue[Training_message_queue_count].special_message = NULL;
		}

		// Goober5000 - replace variables if necessary
		strcpy_s(temp_buf, Messages[m].message);
		if (sexp_replace_variable_names_with_values(temp_buf, MESSAGE_LENGTH))
			Training_message_queue[Training_message_queue_count].special_message = vm_strdup(temp_buf);

		Training_message_queue_count++;
	}
}
void model_collide_parse_bsp_tmappoly(bsp_collision_leaf *leaf, SCP_vector<model_tmap_vert> *vert_buffer, void *model_ptr)
{
	ubyte *p = (ubyte *)model_ptr;

	int i;
	int nv;
	model_tmap_vert *verts;

	nv = w(p+36);

	if ( nv < 0 ) return;

	if ( nv > TMAP_MAX_VERTS ) {
		Int3();
		return;
	}

	int tmap_num = w(p+40);

	Assert(tmap_num >= 0 && tmap_num < MAX_MODEL_TEXTURES);

	verts = (model_tmap_vert *)(p+44);

	leaf->tmap_num = (ubyte)tmap_num;
	leaf->num_verts = (ubyte)nv;
	leaf->vert_start = (int)vert_buffer->size();

	vec3d *plane_pnt = vp(p+20);
	float face_rad = fl(p+32);
	vec3d *plane_norm = vp(p+8);

	leaf->plane_pnt = *plane_pnt;
	leaf->face_rad = face_rad;
	leaf->plane_norm = *plane_norm;

	for ( i = 0; i < nv; ++i ) {
		vert_buffer->push_back(verts[i]);
	}
}
/**
 * Initialize a shader uniform. Requires that the Current_shader global variable is valid.
 *
 * @param uniform_text		Name of the uniform to be initialized
 */
void opengl_shader_init_uniform_block(const char *uniform_text)
{
	opengl_shader_uniform_t new_uniform_block;

	if ( (Current_shader == NULL) || (uniform_text == NULL) ) {
		Int3();
		return;
	}

	new_uniform_block.text_id = uniform_text;
#ifdef __APPLE__
	new_uniform_block.location = vglGetUniformBlockIndexARB((long)Current_shader->program_id, uniform_text);
#else
	new_uniform_block.location = vglGetUniformBlockIndexARB(Current_shader->program_id, uniform_text);
#endif
	if (new_uniform_block.location < 0) {
		nprintf(("SHADER-DEBUG", "WARNING: Unable to get shader uniform block location for \"%s\"!\n", uniform_text));
		return;
	}

	Current_shader->uniform_blocks.push_back( new_uniform_block );
}
Example #26
0
void NetworkReadEndLevelShortPacket (ubyte *dataP)
{
    // Special packet for end of level syncing

    int nPlayer;
    tEndLevelInfoShort *end;

    end = reinterpret_cast<tEndLevelInfoShort*> (dataP);
    nPlayer = end->nPlayer;
    Assert (nPlayer != gameData.multiplayer.nLocalPlayer);
    if (nPlayer >= gameData.multiplayer.nPlayers) {
        Int3 (); // weird, but it can happen in a coop restore game
        return; // if it happens in a coop restore, don't worry about it
    }

    if ((networkData.nStatus == NETSTAT_PLAYING) && (end->connected != 0))
        return; // Only accept disconnect packets if we're not out of the level yet
    gameData.multiplayer.players [nPlayer].connected = end->connected;
    if ((gameData.multiplayer.players [nPlayer].connected == 1) && (end->seconds_left < gameData.reactor.countdown.nSecsLeft))
        gameData.reactor.countdown.nSecsLeft = end->seconds_left;
    ResetPlayerTimeout (nPlayer, -1);
}
int campaign_editor::handler(int code, int node, char *str)
{
	int i;

	switch (code) {
	case ROOT_DELETED:
		for (i=0; i<Total_links; i++){
			if ((Links[i].from == Cur_campaign_mission) && (Links[i].node == node)){
				break;
			}
		}

		Campaign_tree_viewp->delete_link(i);
		m_num_links--;
		return node;

	default:
		Int3();
	}

	return -1;
}
// deal with buttons being pressed on the gameplay help screen
void gameplay_help_button_pressed(int n)
{
	switch (n) {

	case PREVIOUS_PAGE_BUTTON:
		gameplay_help_goto_prev_screen();
		break;

	case NEXT_PAGE_BUTTON:
		gameplay_help_goto_next_screen();
		break;

	case CONTINUE_BUTTON:
		gameplay_help_leave();
		gamesnd_play_iface(SND_COMMIT_PRESSED);
		break;

	default:
		Int3();
		break;
	}
}
Example #29
0
 void initModel(Object& obj, float data[][3], unsigned indices[][3], unsigned vsize, unsigned fsize, 
                const Color3& color,real scale) {
     obj.colors_.reserve(vsize);
     for (unsigned i=0;i<vsize;i++) {
         obj.colors_.push_back(color);
     }
     obj.tvx_.resize(vsize);
     obj.vx_.reserve(vsize);
     for (unsigned i=0;i<vsize;i++) {
         obj.vx_.push_back(scale*Real3(data[i][0],data[i][1],data[i][2]));
     }
     
     obj.faces_.reserve(fsize);
     for (unsigned i=0;i<fsize;++i) {
         obj.faces_.push_back(Int3(indices[i][0],indices[i][1],indices[i][2]));
     }
     obj.tnormals_.resize(vsize);
     obj.normals_.reserve(vsize);
     for (unsigned i = 0; i < vsize; i++) {
         obj.normals_[i]+=Real3(0.);
     }
     for (unsigned i = 0; i < fsize; i++) {
         unsigned ia=indices[i][0];
         unsigned ib=indices[i][1];
         unsigned ic=indices[i][2];
         
         Real3 a = obj.vx_[ia];
         Real3 b = obj.vx_[ib];
         Real3 c = obj.vx_[ic];
         Real3 n = normalize( crossProd( b-a, c-a) );
         
         obj.normals_[ia]+=n;
         obj.normals_[ib]+=n;
         obj.normals_[ic]+=n;
     }
     for (unsigned i = 0; i < vsize; i++) {
         obj.normals_[i]=normalize( obj.normals_[i] );
     }
 }
Example #30
0
// Check if the mouse is over the gadget's area or not,
//
int UI_GADGET::is_mouse_on()
{
	int offset, pixel_val;
	ubyte *mask_data;
	int mask_w, mask_h;

	// if linked to a hotspot, use the mask for determination
	if (linked_to_hotspot) {
		mask_data = (ubyte*)my_wnd->get_mask_data(&mask_w, &mask_h);
		if ( mask_data == NULL ) {
			nprintf(("Warning", "No mask defined, but control is linked to hotspot\n"));
			Int3();
			return 0;
		}

		// if the mouse values are out of range of the bitmap
		// NOTE : this happens when using smaller mask bitmaps than the screen resolution (during development)
		if((ui_mouse.x >= mask_w) || (ui_mouse.y >= mask_h)){
			return 0;
		}

		// check the pixel value under the mouse
		offset = ui_mouse.y * mask_w + ui_mouse.x;
		pixel_val = *(mask_data + offset);
		if (pixel_val == hotspot_num){
			return 1;
		} else {
			return 0;
		}
	// otherwise, we just check the bounding box area
	} else {
		if ((ui_mouse.x >= x) && (ui_mouse.x < x + w) && (ui_mouse.y >= y) && (ui_mouse.y < y + h) ){
			return 1;
		} else {
			return 0;
		}
	}
}