Пример #1
0
/*=============================================================================
*NAME		:TYSIniFile::WriteRect
			:
*MODULE		:YSIniFiles.cpp
			:
*FUNCTION	:四角形構造体書き込み処理関数です
			:
*PROCESS	:・四角形構造体書き込み処理です。
			:
*INPUT		:const CString section	:セクション名
*INPUT		:const CString iname	:Ident名
*INPUT		:const CRect& rect		:座標構造体
			:
*PROGRAMMED	:Y.Sasai
*HISTORY	:
*ID -- DATE ------- NOTE ------------------------------------------------------
*00 03.02.12 Y.Sasai Ver.0.90 初期作成
*/
void TYSIniFile::WriteRect( const CString section, const CString iname, const CRect& rect )
{
	CRect rc = rect;																			// 2003.02.12 Y.Sasai Ver.0.90 四角形取得

	rc.NormalizeRect();																			// 2003.02.12 Y.Sasai Ver.0.90 四角形の正規化
	WriteInteger( section, iname + LeftIdent, rc.left );										// 2003.02.12 Y.Sasai Ver.0.90 左座標書き込み
	WriteInteger( section, iname + TopIdent, rc.top );											// 2003.02.12 Y.Sasai Ver.0.90 上座標書き込み
	WriteInteger( section, iname + RightIdent, rc.right );										// 2003.02.12 Y.Sasai Ver.0.90 右座標書き込み
	WriteInteger( section, iname + BottomIdent, rc.bottom );									// 2003.02.12 Y.Sasai Ver.0.90 下座標書き込み
}
Пример #2
0
bool WriteIntegerVector(FILE *fs, const std::vector<int> &values) {
  int length = values.size();
  if (!WriteInteger(fs, length))
    return false;
  for (int i = 0; i < length; ++i) {
    int value = values[i];
    if (!WriteInteger(fs, value))
      return false;
  }
  return true;
}
Пример #3
0
void SalienceRangeError(
  Environment *theEnv,
  int min,
  int max)
  {
   PrintErrorID(theEnv,"PRNTUTIL",9,true);
   WriteString(theEnv,STDERR,"Salience value out of range ");
   WriteInteger(theEnv,STDERR,min);
   WriteString(theEnv,STDERR," to ");
   WriteInteger(theEnv,STDERR,max);
   WriteString(theEnv,STDERR,".\n");
  }
Пример #4
0
// Saves the alphabet to a file.
int Alphabet::Save(FILE* fs) const {
  bool success;
  success = WriteInteger(fs, num_entries_);
  CHECK(success);
  for (const_iterator iter = begin(); iter != end(); ++iter) {
    success = WriteString(fs, iter->first);
    CHECK(success);
    success = WriteInteger(fs, iter->second);
    CHECK(success);
  }
  return 0;
}
Пример #5
0
// -----------------------------------------------------------------------------------
// Write a single node in a binary dump
void WriteBinaryNode(const aiNode* node, FILE* out)
{
	WriteMagic("#ND",out);
	WriteAiString(node->mName,out);
	WriteMat4x4(node->mTransformation,out);

	WriteInteger(node->mNumMeshes,out);
	for (unsigned int i = 0; i < node->mNumMeshes;++i)
		WriteInteger(node->mMeshes[i],out);

	WriteInteger(node->mNumChildren,out);
	for (unsigned int i = 0; i < node->mNumChildren;++i)
		WriteBinaryNode(node->mChildren[i],out);
}
Пример #6
0
/**********************************************************************
  NAME         : WatchMethod
  DESCRIPTION  : Prints out a trace of the beginning or end
                   of the execution of a generic function
                   method
  INPUTS       : A string to indicate beginning or end of execution
  RETURNS      : Nothing useful
  SIDE EFFECTS : None
  NOTES        : Uses the globals CurrentGeneric, CurrentMethod,
                   ProcParamArraySize and ProcParamArray for
                   other trace info
 **********************************************************************/
static void WatchMethod(
  Environment *theEnv,
  const char *tstring)
  {
   if (ConstructData(theEnv)->ClearReadyInProgress ||
       ConstructData(theEnv)->ClearInProgress)
     { return; }

   WriteString(theEnv,STDOUT,"MTH ");
   WriteString(theEnv,STDOUT,tstring);
   WriteString(theEnv,STDOUT," ");
   if (DefgenericData(theEnv)->CurrentGeneric->header.whichModule->theModule != GetCurrentModule(theEnv))
     {
      WriteString(theEnv,STDOUT,DefgenericModule(DefgenericData(theEnv)->CurrentGeneric));
      WriteString(theEnv,STDOUT,"::");
     }
   WriteString(theEnv,STDOUT,DefgenericData(theEnv)->CurrentGeneric->header.name->contents);
   WriteString(theEnv,STDOUT,":#");
   if (DefgenericData(theEnv)->CurrentMethod->system)
     WriteString(theEnv,STDOUT,"SYS");
   PrintUnsignedInteger(theEnv,STDOUT,DefgenericData(theEnv)->CurrentMethod->index);
   WriteString(theEnv,STDOUT," ");
   WriteString(theEnv,STDOUT," ED:");
   WriteInteger(theEnv,STDOUT,EvaluationData(theEnv)->CurrentEvaluationDepth);
   PrintProcParamArray(theEnv,STDOUT);
  }
Пример #7
0
int WriteLinkString(LinkSocket *linkSocket, LinkString *str)
{
    int check = OK;
    /*Write number of characters in string*/
    check = check || WriteInteger(linkSocket, str->numberOfChars);
    check = check || WriteChars(linkSocket, str->text, str->numberOfChars);
    return check;
}
Пример #8
0
 void CXmlWriter::WriteNode(const std::wstring& strNodeName, int nValue, const std::wstring& strTextBeforeValue, const std::wstring& strTextAfterValue)
 {
     WriteNodeBegin(strNodeName);
     WriteString(strTextBeforeValue);
     WriteInteger(nValue);
     WriteString(strTextAfterValue);
     WriteNodeEnd(strNodeName);
 }
Пример #9
0
 void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, int nValue, const std::wstring& strTextBeforeValue, const std::wstring& strTextAfterValue)
 {
     WriteString(L" " + strAttributeName + L"=");
     WriteString(L"\"");
     WriteString(strTextBeforeValue);
     WriteInteger(nValue);
     WriteString(strTextAfterValue);
     WriteString(L"\"");
 }
Пример #10
0
void PDF::CloseStream()
   {
   int length = ftell(file) - stream_start;

   fprintf(file, "\nendstream");
   CloseObject();

   WriteInteger(length_index, length);
   }
Пример #11
0
void PDF::WriteArray(const IntArray & array)
   {
   fprintf(file, " [ ");

   for (int i = 0; i < array.Length(); i++)
      WriteInteger(array[i]);

   fprintf(file, " ] ");
   }
Пример #12
0
void  Interpret( void )
{
    INSTRUCTION current;
    int addr, nextaddr;

    current = Pmem[PC];
    nextaddr = PC+1;
    switch ( current.opcode )  {
        case  HALT:    WriteOut( "!! HALT encountered\n\n" );
                       Running = 0;                             break;
        case  ADD:     BinaryOp( ADD );                         break;
        case  SUB:     BinaryOp( SUB );                         break;
        case  MULT:    BinaryOp( MULT );                        break;
        case  DIV:     BinaryOp( DIV );                         break;
        case  NEG:     Dmem[SP] = -Dmem[SP];                    break;
        case  BR:      nextaddr = Branch( BR );                 break;
        case  BGZ:     nextaddr = Branch( BGZ );                break;
        case  BG:      nextaddr = Branch( BG );                 break;
        case  BLZ:     nextaddr = Branch( BLZ );                break;
        case  BL:      nextaddr = Branch( BL );                 break;
        case  BZ:      nextaddr = Branch( BZ );                 break;
        case  BNZ:     nextaddr = Branch( BNZ );                break;
        case  CALL:    Push( nextaddr );
                       nextaddr = CodeAddr( current.offset );   break;
        case  RET:     nextaddr = CodeAddr( Pop() );            break;
        case  BSF:     BuildStackFrame();                       break;
        case  RSF:     RemoveStackFrame();                      break;
        case  LDP:     LoadDisplayPointer();                    break;
        case  RDP:     RestoreDisplayPointer();                 break;
        case  INC:     SP = DataAddr( SP + current.offset );    break;
        case  DEC:     SP = Decrement( SP, current.offset );    break;    
        case  PUSHFP:  Push( FP );                              break;
        case  LOADI:   Push( current.offset );                  break;
        case  LOADA:   addr = DataAddr( current.offset );
                       Push( Dmem[addr] );                      break;
        case  LOADFP:  addr = DataAddr( FP + current.offset );
                       Push( Dmem[addr] );                      break;
        case  LOADSP:  addr = DataAddr( Dmem[SP] + current.offset );
                       Dmem[SP] = Dmem[addr];                   break;
        case  STOREA:  addr = DataAddr( current.offset );
                       Dmem[addr] = Pop();                      break;
        case  STOREFP: addr = DataAddr( FP + current.offset );
                       Dmem[addr] = Pop();                      break;
        case  STORESP: addr = DataAddr( Pop() );
                       addr = DataAddr( addr + current.offset );
                       Dmem[addr] = Pop();                      break;
        case  READ:    ReadInteger();                           break;
        case  WRITE:   WriteInteger();                          break;
        default:
            DisplayError( !FATAL, "Error, unknown opcode encountered\n" );
            DisplayError( FATAL,  "PC = %d, SP = %d, FP = %d, opcode = %d\n",
                          PC, SP, FP, current.opcode );
            break;
    }
    PC = nextaddr;
}
Пример #13
0
	void WriteRational(const Rational &x)
	{
		Rational temp = x;
		RatStd(temp);
		//debugger? assert
		#ifdef __DEBUG_MODE_ON_

		if (IntSmaller(temp.denom, IntZero))
			throw Debugger::DebugMessage("In function WriteRational, x.denom < 0\n");

		#endif

		WriteInteger(temp.numer);
		if (!IntEqual(temp.denom, IntOne))
		{
			std::cout << "/";
			WriteInteger(temp.denom);
		}
	}
static int WriteSelections(const AbstractQuestion&abstractQuestion,HANDLE hFile)
{
  int number_of_selections = abstractQuestion.mVectorSelections.size();
  WriteInteger(number_of_selections,hFile);
  int cbBytesWritten=4;
  for(int i=0;i<number_of_selections;i++)
  {
    int selection_text_length= abstractQuestion.mVectorSelections.at(i).text.size();
    int index                = abstractQuestion.mVectorSelections.at(i).index;
    int current_bytes_written;
    // write selection_text_length
    WriteInteger(selection_text_length,hFile);
    WriteByte(index,hFile);
    cbBytesWritten+=5;
    WriteFile(hFile,abstractQuestion.mVectorSelections.at(i).text.c_str(),selection_text_length,(DWORD*)current_bytes_written,NULL);
    cbBytesWritten+=current_bytes_written;
  }
  return cbBytesWritten;
}
Пример #15
0
BOOL CIniFile::WriteUnsignedInteger(LPCSTR pszSection, LPCSTR pszEntry, UINT uValue, UINT uDefault)
{
	if (uValue == uDefault)
	{
		return RemoveEntry(pszSection, pszEntry);
	}
	else
	{
		return WriteInteger(pszSection, pszEntry, uValue);
	}
}
Пример #16
0
BOOL CIniFile::WriteInteger(LPCSTR pszSection, LPCSTR pszEntry, int nValue, int nDefault)
{
	if (nValue == nDefault)
	{
		return RemoveEntry(pszSection, pszEntry);
	}
	else
	{
		return WriteInteger(pszSection, pszEntry, nValue);
	}
}
Пример #17
0
void PrintWarningID(
  Environment *theEnv,
  const char *module,
  int warningID,
  bool printCR)
  {
#if (! RUN_TIME) && (! BLOAD_ONLY)
   FlushParsingMessages(theEnv);
   SetWarningFileName(theEnv,GetParsingFileName(theEnv));
   ConstructData(theEnv)->WrnLineNumber = GetLineCount(theEnv);
#endif
   if (printCR) WriteString(theEnv,STDWRN,"\n");
   WriteString(theEnv,STDWRN,"[");
   WriteString(theEnv,STDWRN,module);
   WriteInteger(theEnv,STDWRN,warningID);
   WriteString(theEnv,STDWRN,"] ");

   /*==================================================*/
   /* Print the file name and line number if available */
   /* and there is no callback for errors/warnings.    */
   /*==================================================*/

#if (! RUN_TIME) && (! BLOAD_ONLY)
   if ((ConstructData(theEnv)->ParserErrorCallback == NULL) &&
       (GetLoadInProgress(theEnv) == true))
     {
      const char *fileName;

      fileName = GetParsingFileName(theEnv);
      if (fileName != NULL)
        {
         WriteString(theEnv,STDERR,fileName);
         WriteString(theEnv,STDERR,", Line ");
         WriteInteger(theEnv,STDERR,GetLineCount(theEnv));
         WriteString(theEnv,STDERR,", ");
        }
     }
#endif

   WriteString(theEnv,STDWRN,"WARNING: ");
  }
Пример #18
0
void ExpectedTypeError0(
  Environment *theEnv,
  const char *functionName,
  unsigned int whichArg)
  {
   PrintErrorID(theEnv,"ARGACCES",2,false);
   WriteString(theEnv,STDERR,"Function '");
   WriteString(theEnv,STDERR,functionName);
   WriteString(theEnv,STDERR,"' expected argument #");
   WriteInteger(theEnv,STDERR,whichArg);
   WriteString(theEnv,STDERR," to be of type ");
  }
Пример #19
0
int WriteLinkArgString(LinkSocket *linkSocket, LinkString *str)
{
    int check = OK;
    /*Write number of characters in string*/
    
/*     if (Debug(LINKARGS)){ */
/*      printf("WriteLinkArgString: %d characters: %s\n", str->numberOfChars, str->text); */
/*     } */

    check = check || WriteInteger(linkSocket, str->numberOfChars / 2 );
    check = check || WriteUnicodeChars(linkSocket, str->text, str->numberOfChars);
    return check; /* Returns -1 if there was a memory allocation error */
}
Пример #20
0
// Save a window's position to the INI file.
void CIniFile::WriteWindowPosition(LPCSTR pszSection, CWnd* pWnd)
{
	if (!pWnd->IsIconic())
	{
		WriteInteger(pszSection, ENTRY_Maximized, pWnd->IsZoomed());

		CRect crBounds;
		pWnd->GetWindowRect(&crBounds);

		WriteInteger(pszSection, ENTRY_X0, crBounds.left);
		WriteInteger(pszSection, ENTRY_Y0, crBounds.top);
		WriteInteger(pszSection, ENTRY_Width, crBounds.Width());
		WriteInteger(pszSection, ENTRY_Height, crBounds.Height());
		WriteInteger(pszSection, ENTRY_ScreenWidth, GetSystemMetrics(SM_CXSCREEN));
		WriteInteger(pszSection, ENTRY_ScreenHeight, GetSystemMetrics(SM_CYSCREEN));
		WriteInteger(pszSection, ENTRY_Valid, TRUE);
	}
}
Пример #21
0
void SaveGrid (void)
{
	char	filename[255];
	FILE	*fptr;

	Com_sprintf(filename, sizeof(filename), "%s/settings/grd/%s.grd", game_path->string, level.mapname);

	if ((fptr = fopen(filename, "wb")) != NULL)
	{
		fwrite(&pathnode[0], sizeof(vec3_t), MAX_GRID_SIZE, fptr);
		WriteInteger(fptr, numnodes);
		fclose(fptr);
		gi.dprintf("Grid successfully saved.\n");
	}
	else
		gi.dprintf("Unable to save grid file: %s\n", filename);
}
Пример #22
0
int WriteLinkArgs(LinkSocket *linkSocket, LinkArgs *linkArgs)
{
    int i;
    int check = OK;
    LinkString *ls;

    if (Debug(LINKARGS)){
      printf("WriteLinkArgs: Writing args %d\n", linkArgs->numberOfArgs);
    }
    
    check = check || WriteInteger(linkSocket, linkArgs->numberOfArgs); 

    for (i = 0; i < linkArgs->numberOfArgs; i++){
        ls = (linkArgs->args) + i;
        check = check || WriteLinkArgString(linkSocket, ls);
        if (check == -1)
          return -1; /* Memory allocation error */
    }
    return check;
}
Пример #23
0
void SystemError(
  Environment *theEnv,
  const char *module,
  int errorID)
  {
   PrintErrorID(theEnv,"PRNTUTIL",3,true);

   WriteString(theEnv,STDERR,"\n*** ");
   WriteString(theEnv,STDERR,APPLICATION_NAME);
   WriteString(theEnv,STDERR," SYSTEM ERROR ***\n");

   WriteString(theEnv,STDERR,"ID = ");
   WriteString(theEnv,STDERR,module);
   WriteInteger(theEnv,STDERR,errorID);
   WriteString(theEnv,STDERR,"\n");

   WriteString(theEnv,STDERR,APPLICATION_NAME);
   WriteString(theEnv,STDERR," data structures are in an inconsistent or corrupted state.\n");
   WriteString(theEnv,STDERR,"This error may have occurred from errors in user defined code.\n");
   WriteString(theEnv,STDERR,"**************************\n");
  }
Пример #24
0
/*=============================================================================
*NAME		:TYSIniFile::WriteBool
			:
*MODULE		:YSIniFiles.cpp
			:
*FUNCTION	:bool値書き込み処理関数です
			:
*PROCESS	:・bool値書き込み処理です。
			:
*INPUT		:const CString section	:セクション名
*INPUT		:const CString iname	:Ident名
*INPUT		:const bool ival		:値
			:
*PROGRAMMED	:Y.Sasai
*HISTORY	:
*ID -- DATE ------- NOTE ------------------------------------------------------
*00 03.02.10 Y.Sasai Ver.0.90 初期作成
*/
void TYSIniFile::WriteBool( const CString section, const CString iname, const bool ival )
{
	WriteInteger( section, iname, (int)ival );
}
Пример #25
0
//----------------------------------------------------------------------------
void TCustomIniFile::WriteBool(const AnsiString & Section, const AnsiString & Ident, bool Value)
{
	WriteInteger(Section, Ident, (int) Value);
}
Пример #26
0
//---------------------------------------------------------------------------
void TMYIniFile::WriteInteger(char * Section, char * Ident, int Value)
{
  WriteInteger(String(Section), String(Ident), Value);
}
Пример #27
0
//***********************************************************************
//	Save player v 1.0
//***********************************************************************
void WritePlayer_v1(FILE * fWrite, char *playername, edict_t *player)
{
	int i;
	int numAbilities = CountAbilities(player);
	int numWeapons = CountWeapons(player);
	int numRunes = CountRunes(player);

	//save header
	WriteString(fWrite, "Vortex Player File v1.0");
	//player's title
	WriteString(fWrite, player->myskills.title);
	//player's in-game name
	WriteString(fWrite, playername);
	//password
	WriteString(fWrite, player->myskills.password);
	//email address
	WriteString(fWrite, player->myskills.email);
	//owner
	WriteString(fWrite, player->myskills.owner);
	//creation date
	WriteString(fWrite, player->myskills.member_since);
	//last played date
	WriteString(fWrite, player->myskills.last_played);
	//playing time total
	WriteInteger(fWrite, player->myskills.total_playtime);
	//playing time today
	WriteInteger(fWrite, player->myskills.playingtime);

	//begin talents
	WriteInteger(fWrite, player->myskills.talents.count);
	for (i = 0; i < player->myskills.talents.count; ++i)
	{
		WriteInteger(fWrite, player->myskills.talents.talent[i].id);
		WriteInteger(fWrite, player->myskills.talents.talent[i].upgradeLevel);
		WriteInteger(fWrite, player->myskills.talents.talent[i].maxLevel);
	}
	//end talents

	//begin abilities
	WriteInteger(fWrite, numAbilities);
	for (i = 0; i < numAbilities; ++i)
	{
		int index = FindAbilityIndex(i+1, player);
		if (index != -1)
		{
			WriteInteger(fWrite, index);
			WriteInteger(fWrite, player->myskills.abilities[index].level);
			WriteInteger(fWrite, player->myskills.abilities[index].max_level);
			WriteInteger(fWrite, player->myskills.abilities[index].hard_max);
			WriteInteger(fWrite, player->myskills.abilities[index].modifier);
			WriteInteger(fWrite, (int)player->myskills.abilities[index].disable);
			WriteInteger(fWrite, (int)player->myskills.abilities[index].general_skill);
		}
	}
	//end abilities

	//begin weapons
    WriteInteger(fWrite, numWeapons);
	for (i = 0; i < numWeapons; ++i)
	{
		int index = FindWeaponIndex(i+1, player);
		if (index != -1)
		{
			int j;
			WriteInteger(fWrite, index);
			WriteInteger(fWrite, player->myskills.weapons[index].disable);

			for (j = 0; j < MAX_WEAPONMODS; ++j)
			{
				WriteInteger(fWrite, player->myskills.weapons[index].mods[j].level);
				WriteInteger(fWrite, player->myskills.weapons[index].mods[j].soft_max);
				WriteInteger(fWrite, player->myskills.weapons[index].mods[j].hard_max);
			}
		}
	}
	//end weapons

	//begin runes
    WriteInteger(fWrite, numRunes);
	for (i = 0; i < numRunes; ++i)
	{
		int index = FindRuneIndex(i+1, player);
		if (index != -1)
		{
			int j;
			WriteInteger(fWrite, index);
			WriteInteger(fWrite, player->myskills.items[index].itemtype);
			WriteInteger(fWrite, player->myskills.items[index].itemLevel);
			WriteInteger(fWrite, player->myskills.items[index].quantity);
			WriteInteger(fWrite, player->myskills.items[index].untradeable);
			WriteString(fWrite, player->myskills.items[index].id);
			WriteString(fWrite, player->myskills.items[index].name);
			WriteInteger(fWrite, player->myskills.items[index].numMods);
			WriteInteger(fWrite, player->myskills.items[index].setCode);
			WriteInteger(fWrite, player->myskills.items[index].classNum);

			for (j = 0; j < MAX_VRXITEMMODS; ++j)
			{
				WriteInteger(fWrite, player->myskills.items[index].modifiers[j].type);
				WriteInteger(fWrite, player->myskills.items[index].modifiers[j].index);
				WriteInteger(fWrite, player->myskills.items[index].modifiers[j].value);
				WriteInteger(fWrite, player->myskills.items[index].modifiers[j].set);
			}
		}
	}
	//end runes

	//*****************************
	//standard stats
	//*****************************

	//Exp
	WriteLong(fWrite, player->myskills.experience);
	//next_level
	WriteLong(fWrite, player->myskills.next_level);
	//Level
	WriteInteger(fWrite, player->myskills.level);
	//Class number
	WriteInteger(fWrite, player->myskills.class_num);
	//skill points
	WriteInteger(fWrite, player->myskills.speciality_points);
	//credits
	WriteInteger(fWrite, player->myskills.credits);
	//weapon points
	WriteInteger(fWrite, player->myskills.weapon_points);
	//respawn weapon
	WriteInteger(fWrite, player->myskills.respawn_weapon);
	//talent points
	WriteInteger(fWrite, player->myskills.talents.talentPoints);

	//*****************************
	//in-game stats
	//*****************************
	//respawns
	WriteInteger(fWrite, player->myskills.respawns);
	//health
	WriteInteger(fWrite, player->myskills.current_health);
	//max health
	WriteInteger(fWrite, MAX_HEALTH(player));
	//armour
	WriteInteger(fWrite, player->client->pers.inventory[body_armor_index]);
	//max armour
	WriteInteger(fWrite, MAX_ARMOR(player));
	//nerfme			(cursing a player maybe?)
	WriteInteger(fWrite, player->myskills.nerfme);

	//*****************************
	//flags
	//*****************************
	//admin flag
	WriteInteger(fWrite, player->myskills.administrator);
	//boss flag
	WriteInteger(fWrite, player->myskills.boss);

	//*****************************
	//stats
	//*****************************
	//shots fired
	WriteInteger(fWrite, player->myskills.shots);
	//shots hit
	WriteInteger(fWrite, player->myskills.shots_hit);
	//frags
	WriteInteger(fWrite, player->myskills.frags);
	//deaths
	WriteInteger(fWrite, player->myskills.fragged);
	//number of sprees
	WriteInteger(fWrite, player->myskills.num_sprees);
	//max spree
	WriteInteger(fWrite, player->myskills.max_streak);
	//number of wars
	WriteInteger(fWrite, player->myskills.spree_wars);
	//number of sprees broken
	WriteInteger(fWrite, player->myskills.break_sprees);
	//number of wars broken
	WriteInteger(fWrite, player->myskills.break_spree_wars);
	//suicides
	WriteInteger(fWrite, player->myskills.suicides);
	//teleports			(link this to "use tball self" maybe?)
	WriteInteger(fWrite, player->myskills.teleports);
	//number of 2fers
	WriteInteger(fWrite, player->myskills.num_2fers);

	//CTF statistics
	WriteInteger(fWrite, player->myskills.flag_pickups);
	WriteInteger(fWrite, player->myskills.flag_captures);
	WriteInteger(fWrite, player->myskills.flag_returns);
	WriteInteger(fWrite, player->myskills.flag_kills);
	WriteInteger(fWrite, player->myskills.offense_kills);
	WriteInteger(fWrite, player->myskills.defense_kills);
	WriteInteger(fWrite, player->myskills.assists);
	//End CTF

	//Don't let the player have > max cubes
	if (player->client->pers.inventory[power_cube_index] > player->client->pers.max_powercubes)
		player->client->pers.inventory[power_cube_index] = player->client->pers.max_powercubes;

	//standard iD inventory
	fwrite(player->client->pers.inventory, sizeof(int), MAX_ITEMS, fWrite);
}
Пример #28
0
   size_t BeaconHeader::Serialize(unsigned char* buffer, size_t numBytes) const
   {
      bool success = true;

      size_t position = 0;

      assert(mData.mNameLength < 63);

      if (success = success && (position + sizeof(mData.mZero)       <= numBytes)) { position += WriteInteger(&buffer[position], mData.mZero);       }
      if (success = success && (position + sizeof(mData.mProtocolID) <= numBytes)) { position += WriteInteger(&buffer[position], mData.mProtocolID); }
      if (success = success && (position + sizeof(mData.mServerPort) <= numBytes)) { position += WriteInteger(&buffer[position], mData.mServerPort); }
      if (success = success && (position + sizeof(mData.mNameLength) <= numBytes)) { position += WriteByte(&buffer[position], mData.mNameLength);    }
      if (success = success && (position +        mData.mNameLength  <= numBytes)) { memcpy(&buffer[position], &mData.mName[0], mData.mNameLength); position += mData.mNameLength; }

      return position;
   }
Пример #29
0
// -----------------------------------------------------------------------------------
// Write a binary model dump
void WriteBinaryDump(const aiScene* scene, FILE* out, const char* src, const char* cmd, 
	bool shortened, bool compressed, ImportData& imp)
{
	time_t tt = ::time(NULL);
	tm* p     = ::gmtime(&tt);

	// header
	::fprintf(out,"ASSIMP.binary-dump.%s.",::asctime(p));
	// == 45 bytes

	WriteInteger(aiGetVersionMajor(),out);
	WriteInteger(aiGetVersionMinor(),out);
	WriteInteger(aiGetVersionRevision(),out);
	WriteInteger(aiGetCompileFlags(),out);
	WriteShort(shortened,out);
	WriteShort(compressed,out);
	// ==  20 bytes

	char buff[256]; 
	::strncpy(buff,src,256);
	::fwrite(buff,256,1,out);

	::strncpy(buff,cmd,128);
	::fwrite(buff,128,1,out);

	// leave 41 bytes free for future extensions
	::memset(buff,0xcd,41);
	::fwrite(buff,32,1,out);
	// == 435 bytes

	// ==== total header size: 500 bytes
	// Up to here the data is uncompressed. For compressed files, the rest
	// is compressed using standard DEFLATE from zlib.
	
	// basic scene information
	WriteInteger(scene->mFlags,out);
	WriteInteger(scene->mNumAnimations,out);
	WriteInteger(scene->mNumTextures,out);
	WriteInteger(scene->mNumMaterials,out);
	WriteInteger(scene->mNumCameras,out);
	WriteInteger(scene->mNumLights,out);
	WriteInteger(scene->mNumMeshes,out);

	// write node graph
	WriteBinaryNode(scene->mRootNode,out);

	// write materials
	for (unsigned int i = 0; i< scene->mNumMaterials; ++i) {
		const aiMaterial* mat = scene->mMaterials[i];

		WriteMagic("#MA",out);
		WriteInteger(mat->mNumProperties,out);

		for (unsigned int a = 0; a < mat->mNumProperties;++a) {
			const aiMaterialProperty* prop = mat->mProperties[a];
			
			WriteMagic("#MP",out);
			WriteAiString(prop->mKey,out);
			WriteInteger(prop->mSemantic,out);
			WriteInteger(prop->mIndex,out);

			WriteInteger(prop->mDataLength,out);
			::fwrite(prop->mData,prop->mDataLength,1,out);
		}
	}

	// write cameras
	for (unsigned int i = 0; i < scene->mNumCameras;++i) {
		const aiCamera* cam = scene->mCameras[i];

		WriteMagic("#CA",out);
		WriteAiString(cam->mName,out);
		WriteVec3(cam->mPosition,out);
		WriteVec3(cam->mLookAt,out);
		WriteVec3(cam->mUp,out);
		WriteFloat(cam->mClipPlaneNear,out);
		WriteFloat(cam->mClipPlaneFar,out);
		WriteFloat(cam->mHorizontalFOV,out);
		WriteFloat(cam->mAspect,out);
	}

	// write lights
	for (unsigned int i = 0; i < scene->mNumLights;++i) {
		const aiLight* l = scene->mLights[i];

		WriteMagic("#LI",out);
		WriteAiString(l->mName,out);
		WriteInteger(l->mType,out);

		WriteVec3((const aiVector3D&)l->mColorDiffuse,out);
		WriteVec3((const aiVector3D&)l->mColorSpecular,out);
		WriteVec3((const aiVector3D&)l->mColorAmbient,out);

		if (l->mType != aiLightSource_DIRECTIONAL) { 
			WriteVec3(l->mPosition,out);
			WriteFloat(l->mAttenuationLinear,out);
			WriteFloat(l->mAttenuationConstant,out);
			WriteFloat(l->mAttenuationQuadratic,out);
		}

		if (l->mType != aiLightSource_POINT) {
			WriteVec3(l->mDirection,out);
		}

		if (l->mType == aiLightSource_SPOT) {
			WriteFloat(l->mAttenuationConstant,out);
			WriteFloat(l->mAttenuationQuadratic,out);
		}
	}

	// write all animations
	for (unsigned int i = 0; i < scene->mNumAnimations;++i) {
		const aiAnimation* anim = scene->mAnimations[i];
		
		WriteMagic("#AN",out);
		WriteAiString (anim->mName,out);
		WriteDouble (anim->mTicksPerSecond,out);
		WriteDouble (anim->mDuration,out);
		WriteInteger(anim->mNumChannels,out);

		for (unsigned int a = 0; a < anim->mNumChannels;++a) {
			const aiNodeAnim* nd = anim->mChannels[a];

			WriteMagic("#NA",out);
			WriteAiString(nd->mNodeName,out);
			WriteInteger(nd->mPreState,out);
			WriteInteger(nd->mPostState,out);
			WriteInteger(nd->mNumPositionKeys,out);
			WriteInteger(nd->mNumRotationKeys,out);
			WriteInteger(nd->mNumScalingKeys,out);

			if (nd->mPositionKeys) {
				if (shortened) {
					WriteBounds(nd->mPositionKeys,nd->mNumPositionKeys,out);

				} // else write as usual
				else ::fwrite(nd->mPositionKeys,sizeof(aiVectorKey),nd->mNumPositionKeys,out);
			}
			if (nd->mRotationKeys) {
				if (shortened) {
					WriteBounds(nd->mRotationKeys,nd->mNumRotationKeys,out);

				} // else write as usual
				else ::fwrite(nd->mRotationKeys,sizeof(aiQuatKey),nd->mNumRotationKeys,out);
			}
			if (nd->mScalingKeys) {
				if (shortened) {
					WriteBounds(nd->mScalingKeys,nd->mNumScalingKeys,out);

				} // else write as usual
				else ::fwrite(nd->mScalingKeys,sizeof(aiVectorKey),nd->mNumScalingKeys,out);
			}
		}
	}

	// write all meshes
	for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
		const aiMesh* mesh = scene->mMeshes[i];

		WriteMagic("#ME",out);
		WriteInteger(mesh->mPrimitiveTypes,out);
		WriteInteger(mesh->mNumBones,out);
		WriteInteger(mesh->mNumFaces,out);
		WriteInteger(mesh->mNumVertices,out);

		// write bones
		if (mesh->mNumBones) {
			for (unsigned int a = 0; a < mesh->mNumBones;++a) {
				const aiBone* b = mesh->mBones[a];

				WriteMagic("#BN",out);
				WriteAiString(b->mName,out);
				WriteMat4x4(b->mOffsetMatrix,out);
				WriteInteger(b->mNumWeights,out);

				// for the moment we write dumb min/max values for the bones, too.
				// maybe I'll add a better, hash-like solution later
				if (shortened) {
					WriteBounds(b->mWeights,b->mNumWeights,out);
				} // else write as usual
				else ::fwrite(b->mWeights,sizeof(aiVertexWeight),b->mNumWeights,out);
			}
		}

		// write faces. There are no floating-point calculations involved
		// in these, so we can write a simple hash over the face data
		// to the dump file. We generate a single 32 Bit hash for 512 faces
		// using Assimp's standard hashing function.
		if (shortened) {
			unsigned int processed = 0;
			for (unsigned int job;job = std::min(mesh->mNumFaces-processed,512u);processed += job) {

				unsigned int hash = 0;
				for (unsigned int a = 0; a < job;++a) {

					const aiFace& f = mesh->mFaces[processed+a];
					hash = SuperFastHash((const char*)&f.mNumIndices,sizeof(unsigned int),hash);
					hash = SuperFastHash((const char*) f.mIndices,f.mNumIndices*sizeof(unsigned int),hash);
				}
				WriteInteger(hash,out);
			}
		}
		else // else write as usual
		{
			for (unsigned int i = 0; i < mesh->mNumFaces;++i) {
				const aiFace& f = mesh->mFaces[i];

				WriteInteger(f.mNumIndices,out);
				for (unsigned int a = 0; a < f.mNumIndices;++a)
					WriteInteger(f.mIndices[a],out);
			}
		}

		// first of all, write bits for all existent vertex components
		unsigned int c = 0;
		if (mesh->mVertices) 
			c |= 1;
		if (mesh->mNormals)
			c |= 2;
		if (mesh->mTangents && mesh->mBitangents) 
			c |= 4;
		for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
			if (!mesh->mTextureCoords[n])break;
			c |= (8 << n);
		}
		for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
			if (!mesh->mColors[n])break;
			c |= (16 << n);
		}
		WriteInteger(c,out);
		
		aiVector3D minVec, maxVec;
		if (mesh->mVertices) {
			if (shortened) {
				WriteBounds(mesh->mVertices,mesh->mNumVertices,out);
			} // else write as usual
			else ::fwrite(mesh->mVertices,12*mesh->mNumVertices,1,out);
		}
		if (mesh->mNormals) {
			if (shortened) {
				WriteBounds(mesh->mNormals,mesh->mNumVertices,out);
			} // else write as usual
			else ::fwrite(mesh->mNormals,12*mesh->mNumVertices,1,out);
		}
		if (mesh->mTangents && mesh->mBitangents) {
			if (shortened) {
				WriteBounds(mesh->mTangents,mesh->mNumVertices,out);
				WriteBounds(mesh->mBitangents,mesh->mNumVertices,out);
			} // else write as usual
			else {
				::fwrite(mesh->mTangents,12*mesh->mNumVertices,1,out);
				::fwrite(mesh->mBitangents,12*mesh->mNumVertices,1,out);
			}
		}
		for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
			if (!mesh->mTextureCoords[n])break;

			// write number of UV components
			WriteInteger(mesh->mNumUVComponents[n],out);

			if (shortened) {
				WriteBounds(mesh->mTextureCoords[n],mesh->mNumVertices,out);
			} // else write as usual
			else ::fwrite(mesh->mTextureCoords[n],12*mesh->mNumVertices,1,out);
		}
		for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_COLOR_SETS;++n) {
			if (!mesh->mColors[n])
				break;

			if (shortened) {
				WriteBounds(mesh->mColors[n],mesh->mNumVertices,out);
			} // else write as usual
			else ::fwrite(mesh->mColors[n],16*mesh->mNumVertices,1,out);
		}
	}
}
Пример #30
0
/*=============================================================================
*NAME		:TYSIniFile::WritePoint
			:
*MODULE		:YSIniFiles.cpp
			:
*FUNCTION	:座標構造体書き込み処理関数です
			:
*PROCESS	:・座標構造体書き込み処理です。
			:
*INPUT		:const CString section		:セクション名
*INPUT		:const CString iname		:Ident名
*INPUT		:const CPoint& point		:座標構造体
			:
*PROGRAMMED	:Y.Sasai
*HISTORY	:
*ID -- DATE ------- NOTE ------------------------------------------------------
*00 03.02.12 Y.Sasai Ver.0.90 初期作成
*/
void TYSIniFile::WritePoint( const CString section, const CString iname, const CPoint& point )
{
	WriteInteger( section, iname + XIdent, point.x );											// 2003.02.12 Y.Sasai Ver.0.90 x座標書き込み
	WriteInteger( section, iname + YIdent, point.y );											// 2003.02.12 Y.Sasai Ver.0.90 y座標書き込み
}