コード例 #1
0
ファイル: ipx_udp.c プロジェクト: paud/d2x-xl
static int ResendData (struct sockaddr_in *fromAddr, ubyte *buf)
{
	int				i, j, nFirst, nLast, nDrop;
	tDestListEntry	*pdl;
	tPacketProps	*ppp;
	time_t			t;

//if (!extraGameInfo [1].bSafeUDP)
//	return 0;
if (strncmp ((char *) buf, RESEND_ID, RESEND_ID_LEN))
	return 0;
if (destAddrNum <= (i = FindDestInList (fromAddr)))
	return 1;
nFirst = * ((int *) (buf + RESEND_ID_LEN));
nFirst = INTEL_INT (nFirst);
nLast = * ((int *) (buf + RESEND_ID_LEN + 4));
nLast = INTEL_INT (nLast);
pdl = destList + i;
if (!pdl->numPackets)
	return 1;
ppp = pdl->packetProps + pdl->firstPacket;
if (nFirst < (nDrop = ppp->id)) {
	DropData (pdl, nDrop);	//have the receiver 'forget' data not buffered any more
	if (nDrop > nLast)
		return 1;
	nFirst = nDrop;
	}
nDrop = -1;
t = SDL_GetTicks ();
#ifdef _DEBUG
//LogErr ("resending packets %d - %d to", nFirst, nLast); dumpaddr (&pdl->addr); //LogErr ("\n");
#endif
for (i = pdl->numPackets, j = pdl->firstPacket; i; i--, j++) {
	j %= MAX_BUF_PACKETS;
	ppp = pdl->packetProps + j;
	if (ppp->id > nLast)
		break;
	if (ppp->id < nFirst)
		continue;
	if (t - ppp->timeStamp > 3000) {
		nDrop = ppp->id;
		continue;
		}
	if (nDrop >= 0) {	//have the receiver 'forget' outdated data
		DropData (pdl, nDrop);
		nDrop = -1;
		}
//	nDrop = * ((int *) (ppp->data + ppp->len - 4));
//	nDrop = INTEL_INT (nDrop);
//LogErr ("   resending packet %d (%d)\n", ppp - pdl->packetProps, pdl->numPackets);
	sendto (pdl->fd, ppp->data, ppp->len, 0, (struct sockaddr *) &pdl->addr, sizeof (pdl->addr));
	}
return 1;
}
コード例 #2
0
// get data from multi_local_options struct
void get_local_options(ubyte *data, int *size, multi_local_options *mlo)
{
	int offset = *size;

	GET_DATA(*mlo);

	mlo->flags = INTEL_INT(mlo->flags); //-V570
	mlo->obj_update_level = INTEL_INT(mlo->obj_update_level); //-V570

	*size = offset;
}
コード例 #3
0
ファイル: pcxutils.cpp プロジェクト: lubomyr/freespace2
// reads header information from the PCX file into the bitmap pointer
int pcx_read_header(char *real_filename, int *w, int *h, ubyte *pal )
{
	PCXHeader header;
	CFILE * PCXfile;
	char filename[MAX_FILENAME_LEN];
		
	strcpy( filename, real_filename );
	char *p = strchr( filename, '.' );
	if ( p ) *p = 0;
	strcat( filename, ".pcx" );

	PCXfile = cfopen( filename , "rb" );
	if ( !PCXfile )
		return PCX_ERROR_OPENING;

	// read 128 char PCX header
	if (cfread( &header, sizeof(PCXHeader), 1, PCXfile )!=1)	{
		cfclose( PCXfile );
		return PCX_ERROR_NO_HEADER;
	}
        header.Xmin = INTEL_SHORT( header.Xmin );
        header.Ymin = INTEL_SHORT( header.Ymin );
        header.Xmax = INTEL_SHORT( header.Xmax );
        header.Ymax = INTEL_SHORT( header.Ymax );
        header.Hdpi = INTEL_SHORT( header.Hdpi );
        header.Vdpi = INTEL_SHORT( header.Vdpi );
        for ( int i=0; i<16; i++ ){
            for ( int j=0; j<3; j++){
                header.ColorMap[i][j] = INTEL_INT( header.ColorMap[i][j] );
            }
        }
        header.BytesPerLine = INTEL_SHORT( header.BytesPerLine );
        for ( int i=0; i<60; i++ ){
            header.filler[i] = INTEL_INT( header.filler[i] );
        }

	// Is it a 256 color PCX file?
	if ((header.Manufacturer != 10)||(header.Encoding != 1)||(header.Nplanes != 1)||(header.BitsPerPixel != 8)||(header.Version != 5))	{
		cfclose( PCXfile );
		return PCX_ERROR_WRONG_VERSION;
	}

	if (w) *w = header.Xmax - header.Xmin + 1;
	if (h) *h = header.Ymax - header.Ymin + 1;
	
	if ( pal ) {
		cfseek( PCXfile, -768, CF_SEEK_END );
		cfread( pal, 3, 256, PCXfile );
	}

	cfclose(PCXfile);
	return PCX_ERROR_NONE;
}
コード例 #4
0
// add data from a multi_local_options struct
void add_local_options(ubyte *data, int *size, multi_local_options *mlo)
{
	int packet_size = *size;
	multi_local_options mlo_tmp;

	memcpy(&mlo_tmp, mlo, sizeof(multi_local_options));

	mlo_tmp.flags = INTEL_INT(mlo->flags);
	mlo_tmp.obj_update_level = INTEL_INT(mlo->obj_update_level);

	ADD_DATA(mlo_tmp);

	*size = packet_size;
}
コード例 #5
0
// get data from multi_server_options struct
void get_server_options(ubyte *data, int *size, multi_server_options *mso)
{
	int offset = *size;

	GET_DATA(*mso);

	mso->flags = INTEL_INT(mso->flags); //-V570
	mso->respawn = INTEL_INT(mso->respawn); //-V570
	mso->voice_token_wait = INTEL_INT(mso->voice_token_wait); //-V570
	mso->voice_record_time = INTEL_INT(mso->voice_record_time); //-V570
//	mso->mission_time_limit = INTEL_INT(mso->mission_time_limit);
	mso->kill_limit = INTEL_INT(mso->kill_limit); //-V570

	*size = offset;
}
コード例 #6
0
ファイル: netmisc-old.c プロジェクト: paud/d2x-xl
void BESendNetPlayersPacket(ubyte *server, ubyte *node)
{
	int i, tmpi;
	int loc = 0;
	short tmps;

	memset(out_buffer, 0, sizeof(out_buffer));
	out_buffer[0] = netPlayers.type;                            loc++;
	tmpi = INTEL_INT(netPlayers.Security);
	memcpy(out_buffer + loc, &tmpi, 4);                       loc += 4;
	for (i = 0; i < MAX_PLAYERS+4; i++) {
		memcpy(out_buffer + loc, netPlayers.players[i].callsign, CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1;
		memcpy(out_buffer + loc, netPlayers.players[i].network.ipx.server, 4);    loc += 4;
		memcpy(out_buffer + loc, netPlayers.players[i].network.ipx.node, 6);      loc += 6;
		memcpy(out_buffer + loc, &(netPlayers.players[i].version_major), 1);      loc++;
		memcpy(out_buffer + loc, &(netPlayers.players[i].version_minor), 1);      loc++;
		memcpy(out_buffer + loc, &(netPlayers.players[i].computer_type), 1);      loc++;
		memcpy(out_buffer + loc, &(netPlayers.players[i].connected), 1);          loc++;
		tmps = INTEL_SHORT(netPlayers.players[i].socket);
		memcpy(out_buffer + loc, &tmps, 2);                                       loc += 2;
		memcpy(out_buffer + loc, &(netPlayers.players[i].rank), 1);               loc++;
	}

	if ((server == NULL) && (node == NULL))
		IPXSendBroadcastData(out_buffer, loc);
	else
		IPXSendInternetPacketData(out_buffer, loc, server, node);

}
コード例 #7
0
ファイル: cfile.cpp プロジェクト: paud/d2x-xl
int CFReadInt (CFILE *file)
{
	int32_t i;

CFCriticalError (CFRead (&i, sizeof (i), 1, file) != 1);
//Error ("Error reading int in CFReadInt ()");
return INTEL_INT (i);
}
コード例 #8
0
ファイル: cfile.cpp プロジェクト: paud/d2x-xl
uint CFile::ReadUInt (void)
{
	uint32_t i;

Read (&i, sizeof (i), 1);
//Error ("Error reading int in CFile::ReadInt ()");
return INTEL_INT (i);
}
コード例 #9
0
// add data from a multi_server_options struct
void add_server_options(ubyte *data, int *size, multi_server_options *mso)
{
	int packet_size = *size;
	multi_server_options mso_tmp;

	memcpy(&mso_tmp, mso, sizeof(multi_server_options));

	mso_tmp.flags = INTEL_INT(mso->flags);
	mso_tmp.respawn = INTEL_INT(mso->respawn);
	mso_tmp.voice_token_wait = INTEL_INT(mso->voice_token_wait);
	mso_tmp.voice_record_time = INTEL_INT(mso->voice_record_time);
//	mso_tmp.mission_time_limit = INTEL_INT(mso->mission_time_limit);
	mso_tmp.kill_limit = INTEL_INT(mso->kill_limit);

	ADD_DATA(mso_tmp);

	*size = packet_size;
}
コード例 #10
0
ファイル: cfile.c プロジェクト: paud/d2x-xl
int CFReadInt (CFILE *file)
{
    int32_t i;

    if (CFRead (&i, sizeof (i), 1, file) != 1)
        return nCFileError;
//Error ("Error reading int in CFReadInt()");
    return INTEL_INT (i);
}
コード例 #11
0
ファイル: ipx_udp.cpp プロジェクト: paud/d2x-xl
static int DropData (tDestListEntry *pdl, int nDrop)
{
	ubyte	buf [40];

memcpy (buf, FORGET_ID, FORGET_ID_LEN);
* ((int *) (buf + FORGET_ID_LEN)) = INTEL_INT (nDrop);
sendto (pdl->fd, buf, FORGET_ID_LEN + 4, 0, (struct sockaddr *) &pdl->addr, sizeof (pdl->addr));
return 1;
}
コード例 #12
0
ファイル: netmisc-old.c プロジェクト: paud/d2x-xl
void BEReceiveSequencePacket(ubyte *data, sequence_packet *seq)
{
	int loc = 0;

	seq->type = data[0];                        loc++;
	memcpy(&(seq->Security), data + loc, 4);  loc += 4;   loc += 3;   // +3 for pad byte
	seq->Security = INTEL_INT(seq->Security);
	BEReceiveNetPlayerInfo(data + loc, &(seq->player));
}
コード例 #13
0
ファイル: cfile.cpp プロジェクト: paud/d2x-xl
fix CFReadFix (CFILE *file)
{
	fix f;

CFCriticalError (CFRead (&f, sizeof (f), 1, file) != 1);
//Error ("Error reading fix in CFReadFix ()");
return (fix) INTEL_INT ((int) f);
return f;
}
コード例 #14
0
ファイル: cfile.cpp プロジェクト: paud/d2x-xl
fix CFile::ReadFix (void)
{
	fix f;

Read (&f, sizeof (f), 1) ;
//Error ("Error reading fix in CFile::ReadFix ()");
return (fix) INTEL_INT ((int) f);
return f;
}
コード例 #15
0
ushort mac_calc_segment_checksum()
{
	int i, j, k;
	unsigned int sum1,sum2;
	short s;
	int t;

	sum1 = sum2 = 0;
	for (i = 0; i < Highest_segment_index + 1; i++) {
		for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) {
			mac_do_checksum_calc((unsigned char *)&(Segments[i].sides[j].type), 1, &sum1, &sum2);
			mac_do_checksum_calc(&(Segments[i].sides[j].pad), 1, &sum1, &sum2);
			s = INTEL_SHORT(Segments[i].sides[j].wall_num);
			mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
			s = INTEL_SHORT(Segments[i].sides[j].tmap_num);
			mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
			s = INTEL_SHORT(Segments[i].sides[j].tmap_num2);
			mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
			for (k = 0; k < 4; k++) {
				t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].u));
				mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].v));
				mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].l));
				mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
			}
			for (k = 0; k < 2; k++) {
				t = INTEL_INT(((int)Segments[i].sides[j].normals[k].x));
				mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].normals[k].y));
				mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].normals[k].z));
				mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
			}
		}
		for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) {
			s = INTEL_SHORT(Segments[i].children[j]);
			mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		}
		for (j = 0; j < MAX_VERTICES_PER_SEGMENT; j++) {
			s = INTEL_SHORT(Segments[i].verts[j]);
			mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		}
		s = INTEL_SHORT(Segments[i].objects);
		mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		mac_do_checksum_calc((unsigned char *)&(Segments[i].special), 1, &sum1, &sum2);
		mac_do_checksum_calc((unsigned char *)&(Segments[i].matcen_num), 1, &sum1, &sum2);
		s = INTEL_SHORT(Segments[i].value);
		mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		t = INTEL_INT(((int)Segments[i].static_light));
		mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
#ifndef EDITOR
		s = INTEL_SHORT(Segments[i].pad);	// necessary? If this isn't set to 0 it won't work Intel-Intel anyway.
		mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
#endif
	}
	sum2 %= 255;
	return ((sum1<<8)+ sum2);
}
コード例 #16
0
ファイル: cfile.cpp プロジェクト: paud/d2x-xl
// ----------------------------------------------------------------------------
//returns 1 if file loaded with no errors
int CFInitHogFile (const char *pszFile, const char *folder, tHogFile *hogFiles, int *nFiles) 
{
	char	id [4];
	FILE	*fp;
	int	i, len;
	char	fn [FILENAME_LEN];
	const char  *psz;

CFCriticalError (0);
if (*folder) {
	sprintf (fn, "%s/%s", folder, pszFile);
	pszFile = fn;
	}
*nFiles = 0;
if (! (fp = CFGetFileHandle (pszFile, "", "rb")))
	return 0;
if ((psz = strstr (pszFile, ".rdl")) || (psz = strstr (pszFile, ".rl2"))) {
	while ((psz >= pszFile) && (*psz != '\\') && (*psz != '/') && (*psz != ':'))
		psz--;
	*nFiles = 1;
	strncpy (hogFiles [0].name, psz + 1, 13);
	hogFiles [0].offset = 0;
	hogFiles [0].length = -1;
	return 1;
	}

fread (id, 3, 1, fp);
if (strncmp (id, "DHF", 3)) {
	fclose (fp);
	return 0;
	}

for (;;) {
	if (*nFiles >= MAX_HOGFILES) {
		fclose (fp);
		Error ("HOGFILE is limited to %d files.\n",  MAX_HOGFILES);
		}
	i = (int) fread (hogFiles [*nFiles].name, 13, 1, fp);
	if (i != 1)	{		//eof here is ok
		fclose (fp);
		return 1;
		}
	hogFiles [*nFiles].name [12] = '\0';
	i = (int) fread (&len, 4, 1, fp);
	if (i != 1)	{
		fclose (fp);
		return 0;
		}
	len = INTEL_INT (len);
	hogFiles [*nFiles].length = len;
	hogFiles [*nFiles].offset = ftell (fp);
	 (*nFiles)++;
	// Skip over
	i = fseek (fp, len, SEEK_CUR);
	}
}
コード例 #17
0
ファイル: cfile.c プロジェクト: gameplayer22/d2x-1
fix cfile_read_fix(CFILE *file)
{
	fix f;

	if (cfread( &f, sizeof(f), 1, file) != 1)
		Error( "Error reading fix in cfile_read_fix()" );

	f = (fix)INTEL_INT((int)f);
	return f;
}
コード例 #18
0
ファイル: cfile.c プロジェクト: gameplayer22/d2x-1
int cfile_read_int(CFILE *file)
{
	int32_t i;

	if (cfread( &i, sizeof(i), 1, file) != 1)
		Error( "Error reading int in cfile_read_int()" );

	i = INTEL_INT(i);
	return i;
}
コード例 #19
0
ファイル: cfile.c プロジェクト: paud/d2x-xl
fix CFReadFix (CFILE *file)
{
    fix f;

    if (CFRead (&f, sizeof (f), 1, file) != 1)
        return nCFileError;
//Error ("Error reading fix in CFReadFix()");
    return (fix) INTEL_INT ((int) f);
    return f;
}
コード例 #20
0
ファイル: GAMEMINE.C プロジェクト: NonCreature0714/descent2
static fix read_fix(CFILE *file)
{
	fix f;

	if (cfread( &f, sizeof(f), 1, file) != 1)
		Error( "Error reading fix in gamesave.c" );

	f = (fix)INTEL_INT((int)f);
	return f;
}
コード例 #21
0
ファイル: gameseq.c プロジェクト: Mako88/DXX-Retro
ushort netmisc_calc_checksum()
{
	int i, j, k;
	unsigned int sum1,sum2;
	short s;
	int t;

	sum1 = sum2 = 0;
	for (i = 0; i < Highest_segment_index + 1; i++) {
		for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) {
			do_checksum_calc((unsigned char *)&(Segments[i].sides[j].type), 1, &sum1, &sum2);
			do_checksum_calc(&(Segments[i].sides[j].pad), 1, &sum1, &sum2);
			s = INTEL_SHORT(Segments[i].sides[j].wall_num);
			do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
			s = INTEL_SHORT(Segments[i].sides[j].tmap_num);
			do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
			s = INTEL_SHORT(Segments[i].sides[j].tmap_num2);
			do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
			for (k = 0; k < 4; k++) {
				t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].u));
				do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].v));
				do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].l));
				do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
			}
			for (k = 0; k < 2; k++) {
				t = INTEL_INT(((int)Segments[i].sides[j].normals[k].x));
				do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].normals[k].y));
				do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
				t = INTEL_INT(((int)Segments[i].sides[j].normals[k].z));
				do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
			}
		}
		for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) {
			s = INTEL_SHORT(Segments[i].children[j]);
			do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		}
		for (j = 0; j < MAX_VERTICES_PER_SEGMENT; j++) {
			s = INTEL_SHORT(Segments[i].verts[j]);
			do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		}
		s = INTEL_SHORT(Segments[i].objects);
		do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		do_checksum_calc((unsigned char *)&(Segments[i].special), 1, &sum1, &sum2);
		do_checksum_calc((unsigned char *)&(Segments[i].matcen_num), 1, &sum1, &sum2);
		s = INTEL_SHORT(Segments[i].value);
		do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
		t = INTEL_INT(((int)Segments[i].static_light));
		do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2);
		s = INTEL_SHORT(0); // no matter if we need alignment on our platform, if we have editor we MUST consider this integer to get the same checksum as non-editor games calculate
		do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2);
	}
	sum2 %= 255;
	return ((sum1<<8)+ sum2);
}
コード例 #22
0
static int audiostr_read_uint(HMMIO rw, uint *i)
{
	int rc = mmioRead( rw, (char *)i, sizeof(uint) );

	if (rc != sizeof(uint))
		return 0;

	*i = INTEL_INT(*i); //-V570

	return 1;
}
コード例 #23
0
static int audiostr_read_dword(HMMIO rw, DWORD *i)
{
	int rc = mmioRead( rw, (char *)i, sizeof(DWORD) );

	if (rc != sizeof(DWORD))
		return 0;

	*i = INTEL_INT(*i); //-V570

	return 1;
}
コード例 #24
0
ファイル: cfile.c プロジェクト: gameplayer22/d2x-1
//returns 1 if file loaded with no errors
int cfile_init_hogfile(char *fname, hogfile * hog_files, int * nfiles )
{
	char id[4];
	FILE * fp;
	int i, len;

	*nfiles = 0;

	fp = cfile_get_filehandle( fname, "rb" );
	if ( fp == NULL ) return 0;

	fread( id, 3, 1, fp );
	if ( strncmp( id, "DHF", 3 ) )	{
		fclose(fp);
		return 0;
	}

	while( 1 )
	{
		if ( *nfiles >= MAX_HOGFILES ) {
			fclose(fp);
			Error( "HOGFILE is limited to %d files.\n",  MAX_HOGFILES );
		}
		i = fread( hog_files[*nfiles].name, 13, 1, fp );
		if ( i != 1 )	{		//eof here is ok
			fclose(fp);
			return 1;
		}
		i = fread( &len, 4, 1, fp );
		if ( i != 1 )	{
			fclose(fp);
			return 0;
		}
		hog_files[*nfiles].length = INTEL_INT(len);
		hog_files[*nfiles].offset = ftell( fp );
		*nfiles = (*nfiles) + 1;
		// Skip over
		i = fseek( fp, INTEL_INT(len), SEEK_CUR );
	}
}
コード例 #25
0
ファイル: polyobj.cpp プロジェクト: btb/dxx-rebirth
static int pof_read_int(ubyte *bufp)
{
	int i;

	i = *(reinterpret_cast<int *>(&bufp[Pof_addr]));
	Pof_addr += 4;
	return INTEL_INT(i);

//	if (PHYSFS_read(f,&i,sizeof(i),1) != 1)
//		Error("Unexpected end-of-file while reading object");
//
//	return i;
}
コード例 #26
0
int pof_read_int(ubyte *bufp)
{
	int i;

	i = *((int *) &bufp[Pof_addr]);
	Pof_addr += 4;
	return INTEL_INT(i);

//	if (cfread(&i,sizeof(i),1,f) != 1)
//		Error("Unexpected end-of-file while reading object");
//
//	return i;
}
コード例 #27
0
ファイル: netmisc-old.c プロジェクト: paud/d2x-xl
void BEReceiveNetPlayersPacket(ubyte *data, allNetPlayers_info *pinfo)
{
	int i, loc = 0;

	pinfo->type = data[loc];                            
	loc++;
	memcpy(&(pinfo->Security), data + loc, 4);        
	loc += 4;
	pinfo->Security = INTEL_INT(pinfo->Security);
	for (i = 0; i < MAX_PLAYERS+4; i++) {
		BEReceiveNetPlayerInfo(data + loc, &(pinfo->players[i]));
		loc += 26;          // sizeof(netplayer_info) on the PC
	}
}
コード例 #28
0
ファイル: netmisc-new.cpp プロジェクト: paud/d2x-xl
ushort BECalcSegmentCheckSum (void)
{
	int				i, j, k, t;
	unsigned int	sum1,sum2;
	short				s;
	tSegment			*segP;
	tSide				*sideP;
	tUVL				*uvlP;
	vmsVector		*normP;

sum1 = sum2 = 0;
for (i = 0, segP = gameData.segs.segments; i < gameData.segs.nSegments; i++, segP++) {
	for (j = 0, sideP = segP->sides; j < MAX_SIDES_PER_SEGMENT; j++, sideP++) {
		BEDoCheckSumCalc ((ubyte *) &(sideP->nType), 1, &sum1, &sum2);
		BEDoCheckSumCalc ((ubyte *) &(sideP->nFrame), 1, &sum1, &sum2);
		s = INTEL_SHORT (WallNumI (i, j));
		BEDoCheckSumCalc ((ubyte *) &s, 2, &sum1, &sum2);
		s = INTEL_SHORT (sideP->nBaseTex);
		BEDoCheckSumCalc ((ubyte *) &s, 2, &sum1, &sum2);
		s = INTEL_SHORT (sideP->nOvlOrient + (((short) sideP->nOvlTex) << 2));
		BEDoCheckSumCalc ((ubyte *) &s, 2, &sum1, &sum2);
		for (k = 0, uvlP = sideP->uvls; k < 4; k++, uvlP++) {
			t = INTEL_INT (((int) uvlP->u));
			BEDoCheckSumCalc ((ubyte *) &t, 4, &sum1, &sum2);
			t = INTEL_INT (((int) uvlP->v));
			BEDoCheckSumCalc ((ubyte *) &t, 4, &sum1, &sum2);
			t = INTEL_INT (((int) uvlP->l));
			BEDoCheckSumCalc ((ubyte *) &t, 4, &sum1, &sum2);
			}
		for (k = 0, normP = sideP->normals; k < 2; k++, normP++) {
			t = INTEL_INT ((int) (*normP) [X]);
			BEDoCheckSumCalc ((ubyte *) &t, 4, &sum1, &sum2);
			t = INTEL_INT ((int) (*normP) [Y]);
			BEDoCheckSumCalc ((ubyte *) &t, 4, &sum1, &sum2);
			t = INTEL_INT ((int) (*normP) [Z]);
			BEDoCheckSumCalc ((ubyte *) &t, 4, &sum1, &sum2);
			}
		}
	for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) {
		s = INTEL_SHORT (segP->children [j]);
		BEDoCheckSumCalc ((ubyte *) &s, 2, &sum1, &sum2);
	}
	for (j = 0; j < MAX_VERTICES_PER_SEGMENT; j++) {
		s = INTEL_SHORT (segP->verts [j]);
		BEDoCheckSumCalc ((ubyte *) &s, 2, &sum1, &sum2);
	}
	t = INTEL_INT (segP->objects);
	BEDoCheckSumCalc((ubyte *) &t, 4, &sum1, &sum2);
}
sum2 %= 255;
return ((sum1<<8)+ sum2);
}
コード例 #29
0
ファイル: ipx_udp.cpp プロジェクト: paud/d2x-xl
static int ForgetData (struct sockaddr_in *fromAddr, ubyte *buf)
{
	int				i, nDrop;
	tDestListEntry	*pdl;

if (!extraGameInfo [0].bSafeUDP)
	return 0;
if (strncmp ((char *) buf, FORGET_ID, FORGET_ID_LEN))
	return 0;
if (destAddrNum <= (i = FindDestInList (fromAddr)))
	return 1;
pdl = destList + i;
nDrop = * ((int *) (buf + FORGET_ID_LEN));
pdl->nReceived = INTEL_INT (nDrop);
return 1;
}
コード例 #30
0
ファイル: loadgamedata.cpp プロジェクト: paud/d2x-xl
void LoadTextureBrightness (const char *pszLevel, int *brightnessP)
{
	CFile		cf;
	char		szFile [FILENAME_LEN];
	int		i, *pb;

if (!brightnessP)
	brightnessP = gameData.pig.tex.brightness.Buffer ();
CFile::ChangeFilenameExtension (szFile, pszLevel, ".lgt");
if (cf.Open (szFile, gameFolders.szDataDir, "rb", 0) &&
	 (cf.Read (brightnessP, sizeof (*brightnessP) * MAX_WALL_TEXTURES, 1) == 1)) {
	for (i = MAX_WALL_TEXTURES, pb = gameData.pig.tex.brightness.Buffer (); i; i--, pb++)
		*pb = INTEL_INT (*pb);
	cf.Close ();
	}
}