// TMsgCommPingReply::unpack
// Virtual method from TMessage.  Extracts data from message buffer.
void
TMsgCommQueryOptReply::Unpack(void)
{
	WTRACE("TMsgCommQueryOptReply::Unpack");
	mOptionMap.clear();
	TMessage::Unpack();

	if ((GetServiceType() != WONMsg::CommonService) ||
	    (GetMessageType() != WONMsg::CommQueryOptionsReply))
	{
		WDBG_AH("TMsgCommQueryOptReply::Unpack Not a CommQueryOptionsReply message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a CommQueryOptionsReply message.");
	}

	unsigned short aCt = ReadShort();
	WDBG_LL("TMsgCommQueryOptReply::Unpack reading " << aCt << " entries");

	for (int i=0; i < aCt; i++)
	{
		OptionDef aDef;
		string    anOpt;
		ReadString(anOpt);
		aDef.first  = static_cast<OptionStatus>(ReadByte());
		ReadWString(aDef.second);
		mOptionMap[anOpt] = aDef;
	}

	if (BytesLeftToRead() >= 2)
		mStatus = static_cast<WONMsg::ServerStatus>(static_cast<short>(ReadShort()));
}
static AudErrorCode MDReadAudibleCommonHeader( IAudibleInputStream *pFile, CAudibleCommonHeader *pCommonHead, long sectionSize )

{ if ( sectionSize != 24 )
  { return AUD_AA_FILE_BAD_FORMAT;
  }
//-------------- Now read. 
  { BOOL readRes =  
      ReadShort( pFile, &pCommonHead->versionNumber    ) && 
      ReadShort( pFile, &pCommonHead->minVersionNumber ) &&
      ReadLong ( pFile, &pCommonHead->magicNumber      ) &&
  //------------ Read information if this is partial file from larger one.   
      ReadLong( pFile, &pCommonHead->IsPartialFile )     &&
      ReadLong( pFile, &pCommonHead->sizeOfOriginalAudio ) &&
      ReadLong( pFile, &pCommonHead->segmentStart )      &&
      ReadLong( pFile, &pCommonHead->segmentEnd );       
  //----------------  
    if ( !readRes )
    { return AUD_FILE_READ_FAIL;
    }
    if ( pCommonHead->magicNumber != 0x57907536 || pCommonHead->minVersionNumber != 0 )
    { return AUD_AA_FILE_BAD_FORMAT;
    }
  //----------- If version more than 1 - means some new future format
    if ( pCommonHead->versionNumber > 1 || pCommonHead->versionNumber < 0 )
    { return AUD_AA_FILE_UNSOPPORTED_FORMAT;
    }
    return AUD_NO_ERROR;
  }
}
Пример #3
0
void VFSPlugin_LWO::read_layr(long length)
{
	//	Read the layer number
	short layernumber = ReadShort();
	length-=sizeof(layernumber);

	//	Read the layer flags
	short layerflags = ReadShort();
	length-=sizeof(layerflags);

	//	Read the layer pivot axis
	Vertex3f *v = ReadVertex();
	length-=sizeof(Vertex3f);

	//	Read the layer name
	long stringlength;
	char *layername = ReadString(&stringlength);
	length-=stringlength;

	//	Read the parent layer number
	short parentid = -1;
	if(length>=sizeof(parentid)) parentid = ReadShort();

	//	Clean up any temporary memory
	delete v;
	delete layername;
}
void MMsgRoutingModifyDataObject::Unpack(void)
{
	WTRACE("MMsgRoutingModifyDataObject::Unpack");
	RoutingServerMessage::Unpack();

	if (GetServiceType() != WONMsg::MiniRoutingServer || 
        GetMessageType() != WONMsg::RoutingModifyDataObject)
	{
		WDBG_AH("MMsgRoutingModifyDataObject::Unpack Not a RoutingModifyDataObject message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__, "Not a RoutingModifyDataObject message.");
	}

	// read in the client/group id
	mLinkId = ReadClientOrGroupId();
	
	// read in the datatype size and then the datatype itself
	unsigned char aDataTypeSize = ReadByte();
	mDataType.assign((unsigned char*)ReadBytes(aDataTypeSize), aDataTypeSize);

	// read in the offset
	mOffset = ReadShort();

	// read in the IsInsert flag
	mIsInsert = ReadBool();
	
	// read in the data length followed by the data itself
	unsigned short aDataSize = ReadShort();
	mData.assign((unsigned char*)ReadBytes(aDataSize), aDataSize);

	WDBG_LL("MMsgRoutingModifyDataObject::Unpack Reading message data");
}
Пример #5
0
void BuildAndWriteHints(void)
{
   char * iWalker;
   unsigned int blkcount,elcnt,ityp,i,j,offset,tlength;
   iWalker = BufferIndex;
   blkcount = ReadShort(iWalker);
   WriteFile(iWalker,2);
   iWalker += 2;
   for (i=0; i < blkcount; i++) {

	  // number of elements in this block
	  elcnt = ReadShort(iWalker);
      WriteFile(iWalker,2);
      iWalker += 2;
      ityp = ReadShort(iWalker);
      WriteFile(iWalker,2);
      iWalker += 2;
      for (j=0; j < elcnt; j++) {
         offset = ReadShort(iWalker);
		 iWalker += 2;
   	     tlength = ReadShort( BufferTxt+offset );
         WriteFile(BufferTxt+offset,2);
		 WriteFile(BufferTxt+offset+2,tlength);
   	  }
      if (	ityp == 1 ) {
		  WriteFile(iWalker, elcnt*2);
		  iWalker += elcnt*2;
   	  }
	  WriteFile(iWalker, 2);
	  iWalker += 2;
   }
   
}
// TMsgDirGetDirContents::Unpack
// Virtual method from TMessage.  Extracts data from message buffer.
void
TMsgDirGetDirContentsReply::Unpack(void)
{
	WTRACE("TMsgDirGetDirContentsReply::Unpack");
	TMessage::Unpack();

	if ((GetServiceType() != WONMsg::DirServer) ||
	    (GetMessageType() != WONMsg::DirGetDirContentsReply))
	{
		WDBG_AH("TMsgDirGetDirContentsReply::Unpack Not a DirGetDirContentsReply message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a DirGetDirContentsReply message.");
	}

	WDBG_LL("TMsgDirGetDirContentsReply::Unpack Reading message data");
	mStatus = static_cast<ServerStatus>(static_cast<short>(ReadShort()));
	unsigned short anEntryCt = ReadShort();

	WDBG_LL("TMsgDirGetDirContentsReply::Unpack Reading " << anEntryCt << "entries.");
	mEntries.clear();
	for (int i=0; i < anEntryCt; i++)
	{
		DirServerEntry anEntry;
		UnpackEntry(anEntry);
		mEntries.push_back(anEntry);
	}
}
Пример #7
0
static BOOL ParseSurface(char **data, Mesh3D *mesh) {
  MeshSurfaceT *surface;
  WORD n;

  if (!(ReadShort(data, &n) && EndOfLine(data)))
    return FALSE;

  surface = &mesh->surface[n];

  while (NextLine(data) && !MatchString(data, "@end")) {
    if (MatchString(data, "color")) {
      if (!(ReadByte(data, &surface->r) && 
            ReadByte(data, &surface->g) &&
            ReadByte(data, &surface->b) &&
            EndOfLine(data)))
        return FALSE;
    } else if (MatchString(data, "side")) {
      if (!(ReadByte(data, &surface->sideness) && EndOfLine(data)))
        return FALSE;
    } else if (MatchString(data, "texture")) {
      if (!(ReadShort(data, &surface->texture) && EndOfLine(data)))
        return FALSE;
    } else {
      SkipLine(data);
    }
  }

  return TRUE;
}
Пример #8
0
int Compressor::LoadDecompressionTable(void * comp){
	unsigned short * compressed = (unsigned short *)comp;
	
	// load number of table entries 
	table_entries = ReadShort(compressed)+1;

	// load the values the entries decode to
	for ( int a=0;a<table_entries;a++){
		decoder_table[a].decoded_value = ReadShort(compressed+a+1);
	}
	if ( table_entries == 1){
		return 2*sizeof(unsigned short);
	}

	// store the probability of each entry
	ProbabilityCoder prob(&compressed[table_entries+1],FRACTIONAL_BITS);
	int cp=0;
	for (int a=0;a<table_entries;a++){
		decoder_table[a].cprobability = cp;
		int v = prob.ReadSymbol();
		assert(v);
		if ( v == 0 )
			return -1;
		cp += v;
	}

	assert(cp==(1<<FRACTIONAL_BITS));
	if ( cp != (1<<FRACTIONAL_BITS)){
		return -1;
	}
	decoder_table[table_entries].cprobability = 1<<FRACTIONAL_BITS;
	return (table_entries+1)*sizeof(unsigned short)+prob.GetBytesUsed();
}
// SMsgDirG2GetNumEntitiesReply::Unpack
// Virtual method from SmallMessage.  Extracts data from message buffer.
void
SMsgDirG2GetNumEntitiesReply::Unpack(void)
{
	WTRACE("SMsgDirG2GetNumEntitiesReply::Unpack");
	SmallMessage::Unpack();

	if ((GetServiceType() != WONMsg::SmallDirServerG2) ||
	    (GetMessageType() != WONMsg::DirG2GetNumEntitiesReply))
	{
		WDBG_AH("SMsgDirG2GetNumEntitiesReply::Unpack Not a DirG2GetNumEntitiesReply message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a DirG2GetNumEntitiesReply message.");
	}

	WDBG_LL("SMsgDirG2GetNumEntitiesReply::Unpack Reading message data");
	unsigned short anEntryCt = ReadShort();

	WDBG_LL("SMsgDirG2GetNumEntitiesReply::Unpack Reading " << anEntryCt << " entries.");
	mEntries.clear();
	for (int i=0; i < anEntryCt; i++)
	{
		NumEntriesData anEntry;
		mEntries.push_back(anEntry);
		mEntries.back().first  = static_cast<short>(ReadShort());
		mEntries.back().second = ReadShort();
	}
}
// SMsgDirG2GetNumEntities::Unpack
// Virtual method from SmallMessage.  Extracts data from message buffer.
void
SMsgDirG2GetNumEntities::Unpack(void)
{
	WTRACE("SMsgDirG2GetNumEntities::Unpack");
	SmallMessage::Unpack();

	if ((GetServiceType() != WONMsg::SmallDirServerG2) ||
	    (GetMessageType() != WONMsg::DirG2GetNumEntities))
	{
		WDBG_AH("SMsgDirG2GetNumEntities::Unpack Not a DirG2GetNumEntities message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a DirG2GetNumEntities message.");
	}

	WDBG_LL("SMsgDirG2GetNumEntities::Unpack Reading message data");
	unsigned short aPathCt = ReadShort();

	WDBG_LL("SMsgDirG2GetNumEntities::Unpack Reading " << aPathCt << " entries.");
	mPaths.clear();
	for (int i=0; i < aPathCt; i++)
	{
		DirPathData anEntry;
		mPaths.push_back(anEntry);
		ReadWString(mPaths.back().mPath);
		mPaths.back().mMode = static_cast<DirGetMode>(ReadShort());
	}
}
// TMsgDirFindServiceReply::Unpack
// Virtual method from TMessage.  Extracts data from message buffer.
void
TMsgDirFindServiceReply::Unpack(void)
{
	WTRACE("TMsgDirFindServiceReply::Unpack");
	TMessage::Unpack();

	if ((GetServiceType() != WONMsg::DirServer) ||
	    (GetMessageType() != WONMsg::DirFindServiceReply))
	{
		WDBG_AH("TMsgDirFindServiceReply::Unpack Not a DirFindServiceReply message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a DirFindServiceReply message.");
	}

	WDBG_LL("TMsgDirFindServiceReply::Unpack Reading message data");
	mStatus = static_cast<ServerStatus>(static_cast<short>(ReadShort()));

	// Service data only present if status is success
	if (mStatus == WONMsg::StatusCommon_Success)
	{
		mService.mType = DirServerEntry::EntryTypeService;
		ReadWString(mService.mPath);
		ReadWString(mService.mName);
		ReadWString(mService.mDisplayName);
		ReadWString(mService.mVersion);
		ReadWString(mService.mProtoName);
		ReadWString(mService.mProtoVersion);
		ReadWString(mService.mNetAddress);
		mService.mLifespan = ReadLong();
		mService.mCreated  = ReadLong();

		unsigned short aLen = ReadShort();
		mService.SetBlob(ReadBytes(aLen), aLen);
	}
}
Пример #12
0
//short
void NifStream( short & val, istream& in, const NifInfo & info ) {
	if ( info.endian == sys_endian ) {
		val = ReadShort( in );
	} else {
		val = SwapEndian( ReadShort( in ) );
	}
}
Пример #13
0
void MMsgRoutingGetUserListReply::Unpack(void)
{
	WTRACE("MMsgRoutingGetUserListReply::Unpack");
	RoutingServerMessage::Unpack();

	if (GetServiceType() != WONMsg::MiniRoutingServer || 
        GetMessageType() != WONMsg::RoutingGetUserListReply)
	{
		WDBG_AH("MMsgRoutingGetUserListReply::Unpack Not a RoutingGetUserListReply message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__, "Not a RoutingGetUserListReply message.");
	}

	WDBG_LL("MMsgRoutingGetUserListReply::Unpack Reading message data");

	// read in the status
	mStatus = ReadShort();

	// read in the user count
	unsigned short aNumUsers = ReadShort();

	// read in the user list
	mUserList.clear();
	for (int iUser = 0; iUser < aNumUsers; iUser++)
	{
		UserData aUser;
		ReadUserName(aUser.mUserName);

		mUserList.push_back(aUser);
	}
}
Пример #14
0
static BOOL ParseFaceUVs(char **data, Mesh3D *mesh) {
  IndexListT **faceUVs;
  WORD *index;
  WORD n, m;

  if (!(ReadShort(data, &n) && ReadShort(data, &m) && EndOfLine(data)))
    return FALSE;

  mesh->faceUV = MemAlloc(sizeof(IndexListT *) * (n + 1) +
                          sizeof(WORD) * (m + n), MEMF_PUBLIC|MEMF_CLEAR);

  faceUVs = mesh->faceUV;
  index = (WORD *)&mesh->faceUV[n + 1];

  while (NextLine(data) && !MatchString(data, "@end")) {
    IndexListT *faceUV = (IndexListT *)index++;

    while (!EndOfLine(data)) {
      if (!ReadShort(data, index++))
        return FALSE;
      faceUV->count++, m--;
    }

    *faceUVs++ = faceUV, n--;
  }

  return (n == 0) && (m == 0);
}
Пример #15
0
void LoadCPU(SAVESTATE_t* save, CPU_t* cpu) {
	CHUNK_t* chunk = FindChunk(save, CPU_tag);
	chunk->pnt = 0;
	
	cpu->a = ReadChar(chunk);
	cpu->f = ReadChar(chunk);
	cpu->b = ReadChar(chunk);
	cpu->c = ReadChar(chunk);
	cpu->d = ReadChar(chunk);
	cpu->e = ReadChar(chunk);
	cpu->h = ReadChar(chunk);
	cpu->l = ReadChar(chunk);
	
	cpu->ap = ReadChar(chunk);
	cpu->fp = ReadChar(chunk);
	cpu->bp = ReadChar(chunk);
	cpu->cp = ReadChar(chunk);
	cpu->dp = ReadChar(chunk);
	cpu->ep = ReadChar(chunk);
	cpu->hp = ReadChar(chunk);
	cpu->lp = ReadChar(chunk);

	cpu->ixl = ReadChar(chunk);
	cpu->ixh = ReadChar(chunk);
	cpu->iyl = ReadChar(chunk);
	cpu->iyh = ReadChar(chunk);
	
	cpu->pc = ReadShort(chunk);
	cpu->sp = ReadShort(chunk);

	cpu->i = ReadChar(chunk);
	cpu->r = ReadChar(chunk);
	cpu->bus = ReadChar(chunk);

	cpu->imode = ReadInt(chunk);

	cpu->interrupt = ReadInt(chunk);
	cpu->ei_block = ReadInt(chunk);
	cpu->iff1 = ReadInt(chunk);
	cpu->iff2 = ReadInt(chunk);
	cpu->halt = ReadInt(chunk);
	
	cpu->read = ReadInt(chunk);
	cpu->write = ReadInt(chunk);
	cpu->output = ReadInt(chunk);
	cpu->input = ReadInt(chunk);
	
	cpu->prefix = ReadInt(chunk);
	int i;
	for(i = 0; i < 256; i++) {
		interrupt_t *val = &cpu->pio.interrupt[i];
		val->interrupt_val = ReadInt(chunk);
		val->skip_factor = ReadInt(chunk);
		val->skip_count = ReadInt(chunk);
	}
	
}
Пример #16
0
XString ReadStream::ReadString()
{
	int len = ReadShort();
	XString s;
	s.SetLen(len, 0);
	for(int i = 0; i < len; i++)
	{
		s.SetChar(i, (TCHAR)ReadShort());
	}
	return s;
}
Пример #17
0
void
SMsgDirG2UpdateExtendBase::UnpackExtended(void)
{
	WTRACE("SMsgDirG2UpdateExtendBase::UnpackExtended");
	WDBG_LL("SMsgDirG2UpdateExtendBase::UnpackExtended enableDataObjects=" << mEnableDataObjects << " enableACLs=" << mEnableACLs);
	mDataObjects.clear();
	mACLs.clear();

	if (mEnableDataObjects)
	{
		unsigned short aCt = ReadShort();
		WDBG_LL("SMsgDirG2UpdateExtendBase::UnpackExtended Reading " << aCt << " data objects.");

		for (int i=0; i < aCt; i++)
		{
			DataObject anObj;
			unsigned char aTypeLen = ReadByte();
			if (aTypeLen > 0)
				anObj.GetDataType().assign(reinterpret_cast<const unsigned char*>(ReadBytes(aTypeLen)), aTypeLen);

			unsigned short aDataLen = ReadShort();
			if (aDataLen > 0)
				anObj.GetData().assign(reinterpret_cast<const unsigned char*>(ReadBytes(aDataLen)), aDataLen);

			mDataObjects.insert(anObj);
		}
	}

	if (mEnableACLs)
	{
		unsigned short aCt = ReadShort();
		WDBG_LL("SMsgDirG2UpdateExtendBase::UnpackExtended Reading " << aCt << " ACLs.");

		for (int i=0; i < aCt; i++)
		{
			DirACL anACL;
			anACL.mType = static_cast<WONMsg::DirG2ACLType>(ReadByte());

			unsigned short aPermCt = ReadShort();
			for (int j=0; j < aPermCt; j++)
			{
				Permission aPerm;
				aPerm.mUserId      = ReadLong();
				aPerm.mCommunityId = ReadLong();
				aPerm.mTrustLevel  = ReadShort();
				anACL.mACL.insert(aPerm);
			}

			mACLs.push_back(anACL);
		}
	}
}
Пример #18
0
/*
=================
idRestoreGame::ReadUsercmd
=================
*/
void idRestoreGame::ReadUsercmd( usercmd_t& usercmd )
{
	ReadByte( usercmd.buttons );
	ReadSignedChar( usercmd.forwardmove );
	ReadSignedChar( usercmd.rightmove );
	ReadShort( usercmd.angles[0] );
	ReadShort( usercmd.angles[1] );
	ReadShort( usercmd.angles[2] );
	ReadShort( usercmd.mx );
	ReadShort( usercmd.my );
	ReadByte( usercmd.impulse );
	ReadByte( usercmd.impulseSequence );
}
Пример #19
0
void UnpackPData(char *player)
/* 
 * Takes all planets out of the results and puts them in
 * ``pdata??.dat'' and ``pdata??.dis'' On the fly, some checksums are
 * computed (for ``control.dat'' and ``gen??.dat'')
 */
{
  FILE *pdata;
  unsigned long place=8,cs=0;
  int i,j,size=85;
  unsigned short noplanets,planetnr;
  unsigned char *buf;

  buf=rstremember+place;
  ReadLong(place,buf);
  place--; /* this sucks */
  buf=rstremember+place;
  ReadShort(noplanets,buf);
  fprintf(stdout,"%3d own planets found\n",noplanets);
  planetcs=(noplanets>>8)+(noplanets&255);
  for (i=0;i<noplanets;i++) {
#ifdef test
    fprintf(stderr,"%i",i%10);
#endif
    cs=0;
    for (j=0;j<size;j++) cs+=buf[j];
    buf+=2;
    ReadShort(planetnr,buf);
    planetnr--; /* this sucks */
    ctrlbuf=ctrlremember+2000+4*planetnr;
    WriteLong(cs,ctrlbuf);
    planetcs+=cs;
    buf+=(size-4);
  }
  planetcs*=2;
  for (j=0;j<10;j++) planetcs+=(dissig[j]+datsig[j]);
#ifdef test
  fprintf(stderr,"checksum for planets: 0x%lX\n",planetcs);
#endif

  pdata=OpenPlayerFile("pdata",player,"dis");
  fwrite(rstremember+place,2+size*noplanets,1,pdata);
  fwrite(dissig,10,1,pdata);
  fclose(pdata);

  pdata=OpenPlayerFile("pdata",player,"dat");
  fwrite(rstremember+place,2+size*noplanets,1,pdata);
  fwrite(datsig,10,1,pdata);
  fclose(pdata);
} /* UnpackPData */
Пример #20
0
void UnpackBData(char *player)
/* 
 * Takes all bases out of the results and puts them in ``bdata??.dat''
 * and ``bdata??.dis'' On the fly, some checksums are computed (for
 * ``control.dat'' and ``gen??.dat'')
 */
{
  FILE *bdata;
  unsigned long place=12,cs;
  int i,j,size=156;
  unsigned short nobases,basenr;
  unsigned char *buf;

  buf=rstremember+place;
  ReadLong(place,buf);
  place--; /* this sucks */
  buf=rstremember+place;
  ReadShort(nobases,buf);
  fprintf(stdout,"%3d own bases found\n",nobases);
  basecs=(nobases>>8)+(nobases&255);
  for (i=0;i<nobases;i++) {
#ifdef test
    fprintf(stderr,"%i",i%10);
#endif
    cs=0;
    for (j=0;j<size;j++) cs+=buf[j];
    ReadShort(basenr,buf);
    basenr--; /* this sucks */
    ctrlbuf=ctrlremember+4000+4*basenr;
    WriteLong(cs,ctrlbuf);
    basecs+=cs;
    buf+=(size-2);
  }
  basecs*=2;
  for (j=0;j<10;j++) basecs+=(dissig[j]+datsig[j]);
#ifdef test
  fprintf(stderr,"checksum for bases: 0x%lX\n",basecs);
#endif

  bdata=OpenPlayerFile("bdata",player,"dis");
  fwrite(rstremember+place,2+size*nobases,1,bdata);
  fwrite(dissig,10,1,bdata);
  fclose(bdata);

  bdata=OpenPlayerFile("bdata",player,"dat");
  fwrite(rstremember+place,2+size*nobases,1,bdata);
  fwrite(datsig,10,1,bdata);
  fclose(bdata);
} /* UnpackBData */
Пример #21
0
void UnpackMess(char *player)
/* 
 * Takes all messages from a result and puts them in ``mdata??.dat''.
 * Since messages are of unpredictable length, the place and size of
 * all messages are given at the beginning of the file. In the result,
 * however places (of course?) differ. So the messages are
 * "moved". Also, a file ``mess??.dat'' with 0 outgoing messages is
 * created.
 */
{
  FILE *mess;
  unsigned long place=16,dump;
  unsigned short nomess;
  unsigned char *buf;
  int i,total=0,size;

  buf=rstremember+place;
  ReadLong(place,buf);
  place--; /* this sucks */
  buf=rstremember+place;
  ReadShort(nomess,buf);
  fprintf(stdout,"%3d messages found\n",nomess);

  ReadLong(place,buf); /* place where first message starts */
  buf-=4;
  place--; /* this sucks */
  for (i=0;i<nomess;i++) {
#ifdef test
    fprintf(stderr,"%i",i%10);
#endif
    ReadLong(dump,buf);
    buf-=4; /* only disadvantage of my own macro */
    dump-=(place-(2+6*nomess)); /* ``move'' message */
    WriteLong(dump,buf);
    ReadShort(size,buf);
    total+=size;
  }

  mess=OpenPlayerFile("mdata",player,"dat");
  fwrite(buf-(2+6*nomess),2+6*nomess,1,mess);
  fwrite(rstremember+place,total,1,mess);
  /* datsig not needed */
  fclose(mess);

  mess=OpenPlayerFile("mess",player,"dat");
  i=0;
  fwrite(&i,2,1,mess);
  fclose(mess);
} /* UnpackMess */
Пример #22
0
void UnpackShip(char *player)
/* 
 * Takes all ships out of the results and puts them in ``ship??.dat''
 * and ``ship??.dis'' On the fly, some checksums are computed (for
 * ``control.dat'' and ``gen??.dat'')
 */
{
  FILE *ship;
  unsigned long place=0,cs;
  int i,j,size=107;
  unsigned short noships,shipnr;
  unsigned char *buf;

  buf=rstremember+place;
  ReadLong(place,buf);
  place--; /* this sucks */
  buf=rstremember+place;
  ReadShort(noships,buf);
  fprintf(stdout,"%3d own ships found\n",noships);
  shipcs=(noships>>8)+(noships&255);
  for (i=0;i<noships;i++) {
#ifdef test
    fprintf(stderr,"%i",i%10);
#endif
    cs=0;
    for (j=0;j<size;j++) cs+=buf[j];
    ReadShort(shipnr,buf);
    shipnr--; /* this sucks */
    ctrlbuf=ctrlremember+4*shipnr;
    WriteLong(cs,ctrlbuf);
    shipcs+=cs;
    buf+=size-2;
  }
  shipcs*=2;
  for (j=0;j<10;j++) shipcs+=(dissig[j]+datsig[j]);
#ifdef test
  fprintf(stderr,"checksum for ships: 0x%lX\n",shipcs);
#endif
  
  ship=OpenPlayerFile("ship",player,"dis");
  fwrite(rstremember+place,2+size*noships,1,ship);
  fwrite(dissig,10,1,ship);
  fclose(ship);

  ship=OpenPlayerFile("ship",player,"dat");
  fwrite(rstremember+place,2+size*noships,1,ship);
  fwrite(datsig,10,1,ship);
  fclose(ship);
} /* UnpackShip */
Пример #23
0
void VFSHandle_ZIP::ReadCD(void)
{
	memset(&m_cd,0,sizeof(CentralDir));

	m_cd.number_disk		=	ReadShort();
	m_cd.number_disk_start	=	ReadShort();
	m_cd.total_entries_disk	=	ReadShort();
	m_cd.total_entries		=	ReadShort();
	m_cd.size			=	ReadInt();
	m_cd.offset			=	ReadInt();
	m_cd.comment_length	=	ReadShort();
	m_cd.comment		=	ReadString(m_cd.comment_length);

	DEBUG_READCD;
}
Пример #24
0
void VFSPlugin_LWO::read_ptag(long length)
{
	//	Read what type the tags are	(SURF/PART/SMGP)
	long type = ReadLong();
	length-=sizeof(long);

	long polygonid;
	long tag;
	long vxlength;

	//	Read until there are no more tags
	while(length>0)
	{
		//	Read what polygon this tag belongs to and what tag to apply to the polygon
		polygonid	=	ReadVariableLength(&vxlength);
		tag				=	ReadShort();

		//	Store the polygon id and tag data
		polygontags.push_back(tag);
		polygontags.push_back(polygonid);

		length-=(vxlength+sizeof(short));

		//	types:
		//	SURF	Surface
		//	PART	Part
		//	SMGP	Smoothing Group
	}
}
Пример #25
0
long VFSPlugin_LWO::ReadSubChunk(void)
{
	long	id	= ReadLong();
	short	len	= ReadShort();

	switch(id)
	{
		case ID_STIL:	{	read_unkn(id,len);	}break;
		case ID_COLR:	{	read_colr(len);			}break;
		case ID_DIFF:	{	read_diff(len);			}break;
		case ID_LUMI:	{	read_lumi(len);			}break;
		case ID_SPEC:	{	read_spec(len);			}break;
		case ID_REFL:	{	read_refl(len);			}break;
		case ID_TRAN:	{	read_tran(len);			}break;
		case ID_TRNL:	{	read_trnl(len);			}break;
		case ID_GLOS:	{	read_glos(len);			}break;
		case ID_SHRP:	{	read_shrp(len);			}break;
		case ID_SMAN:	{	read_sman(len);			}break;
		case ID_BUMP:	{	read_bump(len);			}break;
		case ID_SIDE:	{	read_unkn(id,len);	}break;
		case ID_BLOK:	{	read_unkn(id,len);	}break;
		case ID_IMAP:	{	read_unkn(id,len);	}break;
		case ID_TMAP:	{	read_unkn(id,len);	}break;
		case ID_IMAG:	{	read_unkn(id,len);	}break;
		case ID_CHAN:	{	read_unkn(id,len);	}break;
		default:			{	read_unkn(id,len);	}break;

	};

	return len + 6;
}
void MMsgRoutingCreateGroup::Unpack(void)
{
	WTRACE("MMsgRoutingCreateGroup::Unpack");
	RoutingServerMessage::Unpack();

	if (GetServiceType() != WONMsg::MiniRoutingServer || 
        GetMessageType() != WONMsg::RoutingCreateGroup)
	{
		WDBG_AH("MMsgRoutingCreateGroup::Unpack Not a RoutingCreateGroup message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__, "Not a RoutingCreateGroup message.");
	}

	WDBG_LL("MMsgRoutingCreateGroup::Unpack Reading message data");

	// read in group name
	ReadGroupName(mGroupName);
	
	// read in flags
	unsigned char aFlags = ReadByte();
	mIsPublic             = ((aFlags & 0x01) != 0);
	mAnnounceGroupChanges = ((aFlags & 0x02) != 0);

	// read in client count
	unsigned short aNumClients = ReadShort();

	// read in client list
	mClientList.clear();
	for (int iClient = 0; iClient < aNumClients; iClient++)
		mClientList.push_back(ReadClientId());
}
Пример #27
0
void VFSPlugin_LWO::read_face(long length)
{
	short		numvertex;
	short		flags;
	short		mask		= 1023;
	TempPolygon	*p	= NULL;
	int			ctr			= 0;

	//	Read all the polygon indices
	while(length != 0){
		//	Read the polygon data
		numvertex			=		ReadShort();
		length				-=	sizeof(numvertex);
		
		//	extract the flags and numvertex from the polygon data
		flags					=		!mask & numvertex;
		numvertex			&=	mask;

		//	Create a temporary polygon, and an array of indices for this polygon
		p							=		new TempPolygon;		
		p->numvertex	=		numvertex;
		p->index			=		new int[p->numvertex];

		long vxlength;

		//	Read all the indices for this polygon
		for(int a=0;a<p->numvertex;a++){
			p->index[a] = (unsigned long)ReadVariableLength(&vxlength);
			length-=vxlength;
		}

		//	Store the polygon indices
		polygons.push_back(p);
	}
}
Пример #28
0
static BOOL ParseVertexUVs(char **data, Mesh3D *mesh) {
  FLOAT scale_u = SPFlt(16);
  FLOAT scale_v = SPFlt(16);
  UVCoord *uv;
  WORD n;

  if (!(ReadShort(data, &n) && EndOfLine(data)))
    return FALSE;

  Log("[3D] Mesh has %ld uv coordinates\n", (LONG)n);
  mesh->uv = MemAlloc(sizeof(Point2D) * n, MEMF_PUBLIC);

  uv = mesh->uv ;

  while (NextLine(data) && !MatchString(data, "@end")) {
    FLOAT u, v;

    if (!(ReadFloat(data, &u) && ReadFloat(data, &v) && EndOfLine(data)))
      return FALSE;

    uv->u = SPFix(SPMul(u, scale_u));
    uv->v = SPFix(SPMul(v, scale_v));
    uv++;
    n--;
  }

  return n == 0;
}
Пример #29
0
static BOOL ParseVertices(char **data, Mesh3D *mesh) {
  FLOAT scale = SPMul(mesh->scale, SPFlt(16));
  Point3D *vertex;
  WORD n;

  if (!(ReadShort(data, &n) && EndOfLine(data)))
    return FALSE;

  Log("[3D] Mesh has %ld points\n", (LONG)n);
  mesh->vertices = n;
  mesh->vertex = MemAlloc(sizeof(Point3D) * n, MEMF_PUBLIC);

  vertex = mesh->vertex;

  while (NextLine(data) && !MatchString(data, "@end") && n > 0) {
    FLOAT x, y, z;

    if (!(ReadFloat(data, &x) && ReadFloat(data, &y) && ReadFloat(data, &z) &&
          EndOfLine(data)))
      return FALSE;

    vertex->x = SPFix(SPMul(x, scale));
    vertex->y = SPFix(SPMul(y, scale));
    vertex->z = SPFix(SPMul(z, scale));
    vertex++;
    n--;
  }

  return n == 0;
}
Пример #30
0
void UnpackVcr(char *player)
/* Takes all vcr's from the result and puts them in ``vcr??.dat'' */
{
  FILE *vcr;
  unsigned long place=28;
  int size=100;
  unsigned short novcrs;
  unsigned char *buf;

  buf=rstremember+place;
  ReadLong(place,buf);
  place--; /* this sucks */
  /* check length; */
  if ((place+2)>rstsize) {
    fprintf(stderr,"This is not a (complete) result! (vcr)\n");
    exit(-1);
  }
  buf=rstremember+place;
  ReadShort(novcrs,buf);
  /* final length-test */
  if ((place+2+size*novcrs)!=rstsize) {
    if ((place+2+size*novcrs)<rstsize) {
      fprintf(stderr,"Result is bigger than expected, this might not be a result!\n");
    } else {
      fprintf(stderr,"Result is SHORTER than expected, may be your result has been chopped off!\n");
      exit(-1);
    }
  }
  fprintf(stdout,"%3d VCR's found\n",novcrs);

  vcr=OpenPlayerFile("vcr",player,"dat");
  fwrite(rstremember+place,2+size*novcrs,1,vcr);
  fwrite(datsig,10,1,vcr);
  fclose(vcr);
} /* UnpackVcr */