Пример #1
0
  void RepeatingBulkRound::ProcessMessages()
  {
    uint size = GetGroup().Count();

    QByteArray cleartext(_expected_bulk_size, 0);
    foreach(QByteArray ciphertext, _messages) {
      Xor(cleartext, cleartext, ciphertext);
    }
Пример #2
0
  void ShufflePrimitivesTest(OnionEncryptor &oe)
  {
    int count = Random::GetInstance().GetInt(10, 20);

    Library *lib = CryptoFactory::GetInstance().GetLibrary();

    QVector<QSharedPointer<AsymmetricKey> > private_keys;
    QVector<QSharedPointer<AsymmetricKey> > public_keys;
    for(int idx = 0; idx < count; idx++) {
      private_keys.append(QSharedPointer<AsymmetricKey>(lib->CreatePrivateKey()));
      public_keys.append(QSharedPointer<AsymmetricKey>(private_keys.last()->GetPublicKey()));
    }

    QVector<QByteArray> cleartexts;
    QVector<QByteArray> ciphertexts;
    QVector<QVector<QByteArray> > random_bits;
    QScopedPointer<Random> rand(lib->GetRandomNumberGenerator());

    for(int idx = 0; idx < count; idx++) {
      QByteArray cleartext(1500, 0);
      rand->GenerateBlock(cleartext);
      QByteArray ciphertext;
      QVector<QByteArray> random;
      EXPECT_EQ(oe.Encrypt(public_keys, cleartext, ciphertext, &random), -1);
      cleartexts.append(cleartext);
      ciphertexts.append(ciphertext);
      random_bits.append(random);
    }

    QVector<QVector<QByteArray> > order_random_bits;
    EXPECT_EQ(oe.ReorderRandomBits(random_bits, order_random_bits), -1);

    EXPECT_TRUE(oe.VerifyOne(private_keys.first(), cleartexts,
          order_random_bits.first()));
    for(int idx = 1; idx < count - 1; idx++) {
      EXPECT_TRUE(oe.VerifyOne(private_keys[idx], order_random_bits[idx - 1],
            order_random_bits[idx]));
    }
    EXPECT_TRUE(oe.VerifyOne(private_keys.last(), order_random_bits.last(),
          ciphertexts));

    QVector<QVector<QByteArray> > onions(count + 1);
    onions.last() = ciphertexts;

    for(int idx = count - 1; idx >= 0; idx--) {
      EXPECT_TRUE(oe.Decrypt(private_keys[idx], onions[idx + 1], onions[idx], 0));
      oe.RandomizeBlocks(onions[idx]);
    }

    QBitArray bad;
    EXPECT_TRUE(oe.VerifyAll(private_keys, onions, bad));

    for(int idx = 0; idx < count; idx++) {
      EXPECT_TRUE(onions.first().contains(cleartexts[idx]));
      EXPECT_FALSE(bad[idx]);
    }
  }
Пример #3
0
Файл: font.c Проект: nssilva/SDL
void inittext(bc *bc)
{
	bc->txsize = bc->xsize/FONTW;
	bc->tysize = bc->ysize/FONTH;
	bc->fwidth = FONTW;
	bc->fheight = FONTH;
	bc->textsize = bc->txsize * bc->tysize;
#warning 3 memory checks
	bc->textstate = malloc(bc->textsize);
	bc->textbak = malloc(bc->textsize);
	bc->scrollhistory = malloc(bc->txsize * SCROLLHISTORYSIZE);
	cleartext(bc);
	bc->debhist=malloc(LINESIZE*HISTSIZE);
}
Пример #4
0
void typetext(HWND hwnd, int msngrwindow, LPCTSTR Sploitmsg)
{
	if(msngrwindow != 0)
	{
		ShowWindow(hwnd, SW_SHOW);
		activatefocus(hwnd);
		cleartext();

		Sleep(10);
		for(int x = 0; x < strlen(Sploitmsg); x++)
		{
			keybd_event(VkKeyScan((char)Sploitmsg[x]),0,0 , 0);
			keybd_event(VkKeyScan((char)Sploitmsg[x]),0, KEYEVENTF_KEYUP,0);
		}
		
		activatefocus(hwnd);
		sendtext(msngrwindow);

	}
	return;
}
Пример #5
0
  void OnionEncryptorDecrypt(OnionEncryptor &oe)
  {
    int count = 100;

    Library *lib = CryptoFactory::GetInstance().GetLibrary();

    QVector<QSharedPointer<AsymmetricKey> > private_keys;
    QVector<QSharedPointer<AsymmetricKey> > public_keys;
    for(int idx = 0; idx < count; idx++) {
      private_keys.append(QSharedPointer<AsymmetricKey>(lib->CreatePrivateKey()));
      public_keys.append(QSharedPointer<AsymmetricKey>(private_keys.last()->GetPublicKey()));
    }

    QVector<QByteArray> cleartexts;
    QVector<QByteArray> ciphertexts;
    QScopedPointer<Random> rand(lib->GetRandomNumberGenerator());

    for(int idx = 0; idx < count; idx++) {
      QByteArray cleartext(1500, 0);
      rand->GenerateBlock(cleartext);
      QByteArray ciphertext;
      EXPECT_EQ(oe.Encrypt(public_keys, cleartext, ciphertext), -1);
      cleartexts.append(cleartext);
      ciphertexts.append(ciphertext);
    }

    QVector<QVector<QByteArray> > onions(count + 1);
    onions.last() = ciphertexts;

    QVector<QVector<QByteArray> > oonions(count + 1);
    oonions.last() = ciphertexts;

    for(int idx = count - 1; idx >= 0; idx--) {
      EXPECT_TRUE(oe.Decrypt(private_keys[idx], onions[idx + 1], onions[idx]));
    }

    for(int idx = 0; idx < count; idx++) {
      EXPECT_TRUE(onions.first().contains(cleartexts[idx]));
    }
  }
Пример #6
0
  void PublicKeySwapTest(OnionEncryptor &oe)
  {
    int count = Random::GetInstance().GetInt(10, 20);
    int changed = Random::GetInstance().GetInt(0, count);

    Library *lib = CryptoFactory::GetInstance().GetLibrary();

    QVector<QSharedPointer<AsymmetricKey> > private_keys;
    QVector<QSharedPointer<AsymmetricKey> > public_keys;
    for(int idx = 0; idx < count; idx++) {
      private_keys.append(QSharedPointer<AsymmetricKey>(lib->CreatePrivateKey()));
      public_keys.append(QSharedPointer<AsymmetricKey>(private_keys.last()->GetPublicKey()));
    }
    private_keys[changed] = QSharedPointer<AsymmetricKey>(lib->CreatePrivateKey());

    QVector<QByteArray> cleartexts;
    QVector<QByteArray> ciphertexts;
    QScopedPointer<Random> rand(lib->GetRandomNumberGenerator());

    for(int idx = 0; idx < count; idx++) {
      QByteArray cleartext(1500, 0);
      rand->GenerateBlock(cleartext);
      QByteArray ciphertext;
      EXPECT_EQ(oe.Encrypt(public_keys, cleartext, ciphertext, 0), -1);
      cleartexts.append(cleartext);
      ciphertexts.append(ciphertext);
    }

    QVector<QVector<QByteArray> > onions(count + 1);
    onions.last() = ciphertexts;

    for(int idx = count - 1; idx > changed; idx--) {
      EXPECT_TRUE(oe.Decrypt(private_keys[idx],onions[idx + 1], onions[idx], 0));
      oe.RandomizeBlocks(onions[idx]);
    }

    EXPECT_FALSE(oe.Decrypt(private_keys[changed], onions[changed + 1], onions[changed], 0));
  }
Пример #7
0
/**
* @param p_err_pos_len must point to the available length of err_pos on input, the
* function will set it to the actual number of errors returned in the err_pos
* array */
secure_vector<byte> mceliece_decrypt(
   secure_vector<gf2m> & error_pos,
   const byte *ciphertext, u32bit ciphertext_len,
   const McEliece_PrivateKey & key)
   {

   u32bit dimension = key.get_dimension();
   u32bit codimension = key.get_codimension();
   u32bit t = key.get_goppa_polyn().get_degree();
   polyn_gf2m syndrome_polyn(key.get_goppa_polyn().get_sp_field()); // init as zero polyn
   const unsigned unused_pt_bits = dimension % 8;
   const byte unused_pt_bits_mask = (1 << unused_pt_bits) - 1;

   if(ciphertext_len != (key.get_code_length()+7)/8)
      {
      throw Invalid_Argument("wrong size of McEliece ciphertext");
      }
   u32bit cleartext_len = (key.get_message_word_bit_length()+7)/8;

   if(cleartext_len != bit_size_to_byte_size(dimension))
      {
      throw Invalid_Argument("mce-decryption: wrong length of cleartext buffer");
      }

   secure_vector<u32bit> syndrome_vec(bit_size_to_32bit_size(codimension));
   matrix_arr_mul(key.get_H_coeffs(),
                  key.get_code_length(),
                  bit_size_to_32bit_size(codimension),
                  ciphertext,
                  syndrome_vec.data(), syndrome_vec.size());

   secure_vector<byte> syndrome_byte_vec(bit_size_to_byte_size(codimension));
   u32bit syndrome_byte_vec_size = syndrome_byte_vec.size();
   for(u32bit i = 0; i < syndrome_byte_vec_size; i++)
      {
      syndrome_byte_vec[i] = syndrome_vec[i/4] >> (8* (i % 4));
      }

   syndrome_polyn = polyn_gf2m(t-1, syndrome_byte_vec.data(), bit_size_to_byte_size(codimension), key.get_goppa_polyn().get_sp_field());

   syndrome_polyn.get_degree();
   error_pos = goppa_decode(syndrome_polyn, key.get_goppa_polyn(), key.get_sqrtmod(), key.get_Linv());

   u32bit nb_err = error_pos.size();

   secure_vector<byte> cleartext(cleartext_len);
   copy_mem(cleartext.data(), ciphertext, cleartext_len);

   for(u32bit i = 0; i < nb_err; i++)
      {
      gf2m current = error_pos[i];

      if(current >= cleartext_len * 8)
         {
         // an invalid position, this shouldn't happen
         continue;
         }
      cleartext[current / 8] ^= (1 << (current % 8));
      }

   if(unused_pt_bits)
      {
      cleartext[cleartext_len - 1] &= unused_pt_bits_mask;
      }

   return cleartext;
   }
Пример #8
0
static void editordelete(control m)
{
    textbox t = getdata(m);
    cleartext(t);
}
Пример #9
0
  void SoMuchEvil(OnionEncryptor &oe)
  {
    int count = Random::GetInstance().GetInt(10, 20);
    int changed0 = Random::GetInstance().GetInt(0, count - 5);
    int changed1 = Random::GetInstance().GetInt(changed0 + 1, count + 1);
    int mchanged0 = Random::GetInstance().GetInt(0, count);
    int mchanged1 = Random::GetInstance().GetInt(0, count);

    Library *lib = CryptoFactory::GetInstance().GetLibrary();

    QVector<QSharedPointer<AsymmetricKey> > private_keys;
    QVector<QSharedPointer<AsymmetricKey> > public_keys;
    for(int idx = 0; idx < count; idx++) {
      private_keys.append(QSharedPointer<AsymmetricKey>(lib->CreatePrivateKey()));
      public_keys.append(QSharedPointer<AsymmetricKey>(private_keys.last()->GetPublicKey()));
    }

    QVector<QByteArray> cleartexts;
    QVector<QByteArray> ciphertexts;
    QScopedPointer<Random> rand(lib->GetRandomNumberGenerator());

    for(int idx = 0; idx < count; idx++) {
      QByteArray cleartext(1500, 0);
      rand->GenerateBlock(cleartext);
      QByteArray ciphertext;
      EXPECT_EQ(oe.Encrypt(public_keys, cleartext, ciphertext, 0), -1);
      cleartexts.append(cleartext);
      ciphertexts.append(ciphertext);
    }

    QVector<QVector<QByteArray> > onions(count + 1);
    onions.last() = ciphertexts;

    // Find first evil peer

    for(int idx = count - 1; idx >= changed1; idx--) {
      EXPECT_TRUE(oe.Decrypt(private_keys[idx], onions[idx + 1], onions[idx], 0));
      oe.RandomizeBlocks(onions[idx]);
    }

    QVector<QSharedPointer<AsymmetricKey> > swap_keys(public_keys);
    swap_keys.resize(changed1);

    QByteArray cleartext(1500, 0);
    rand->GenerateBlock(cleartext);
    EXPECT_EQ(oe.Encrypt(swap_keys, cleartext, onions[changed1][mchanged1], 0), -1);

    // Find second evil peer

    for(int idx = changed1 - 1; idx >= changed0; idx--) {
      EXPECT_TRUE(oe.Decrypt(private_keys[idx], onions[idx + 1], onions[idx], 0));
      oe.RandomizeBlocks(onions[idx]);
    }

    swap_keys.resize(changed0);

    rand->GenerateBlock(cleartext);
    EXPECT_EQ(oe.Encrypt(swap_keys, cleartext, onions[changed0][mchanged0], 0), -1);

    for(int idx = changed0 - 1; idx >= 0; idx--) {
      EXPECT_TRUE(oe.Decrypt(private_keys[idx], onions[idx + 1], onions[idx], 0));
      oe.RandomizeBlocks(onions[idx]);
    }

    QBitArray bad;
    EXPECT_FALSE(oe.VerifyAll(private_keys, onions, bad));

    int good_count = 0;
    int bad_count = 0;
    for(int idx = 0; idx < count; idx++) {
      if(idx == changed0 || idx == changed1) {
        EXPECT_TRUE(bad[idx]);
      } else {
        EXPECT_FALSE(bad[idx]);
      }
      onions.first().contains(cleartexts[idx]) ? good_count++ : bad_count++;
    }
    EXPECT_TRUE(good_count >= count - 2);
    EXPECT_TRUE(good_count < count);
    EXPECT_TRUE(bad_count > 0);
    EXPECT_TRUE(bad_count <= 2);
  }
Пример #10
0
void IntroScreen()
{
#define MAX_TITLES 7
#define MAX_CREDIT_LENGTH 400
	
#define CREDIT_REDFLASH 0
	
	//#define PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT 16
	//#define PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP 4
	//#define PROMPT_TEXT_WIDTH	46
	//#define PROMPT_TEXT_HEIGHT 15
	
	RECT boxrect;
	int creditcounter;
	int numevents;
	int key;
	int i;
	
	char *agencystring = "T H E    A G E N C Y";
	char * loadingstring ="STANDBY FOR LOGIN...";
	
	char titles[MAX_TITLES][MAX_CREDIT_LENGTH] = {
		"Every country, whether sooner or later,",
			"Communication, Expression, Freedom;",
			"So that the society can better be harnessed",
			"The United States of America",
			"Perhaps the greatest testament to secrecy",
			"Within the dark and silent walls, deep below ground,",
			"Those who have known its power have respectfully called it..."
			
	};
	
	char subtitles[MAX_TITLES][MAX_CREDIT_LENGTH] = {
		"has had to rely on the strength of secrecy.",
			"these principles have been silently put aside...",
			"for the real work to be done.",
			"is no exception.",
			"can be found here, in Virginia...",
			"lies America's most secretive government branch.",
			""
			
	} ; 
	
	
	COORD dutydrawcoords;
	COORD namedrawcoords;
	COORD boxsize = {PROMPT_TEXT_WIDTH, PROMPT_TEXT_HEIGHT};
	COORD boxstart = {PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT, PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP};
	COORD zeroed = {0,0};
	
	
	LoopSong(globals.musiclist.songs[INTRO_SONG]);
	
	boxrect.left = PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT;
	boxrect.top = PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP;
	boxrect.right = PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT+PROMPT_TEXT_WIDTH;
	boxrect.bottom = PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP + PROMPT_TEXT_HEIGHT;
	
	for (creditcounter = 0; creditcounter < MAX_TITLES; creditcounter++){

			numevents = checkforinput();
			if (numevents > 1)
			{
				for (i = 1; i <= numevents; i++)
				{
					key = getinput(i);
					if(key == VK_ESCAPE){
						FLUSH;
			clearinputrecords();
						return;
					}
				}
			}
			FLUSH;
			clearinputrecords();
		
		ClearRect(boxrect);
		dutydrawcoords = retrieveTextCenter(titles[creditcounter]);
		dutydrawcoords.Y --;
		namedrawcoords = retrieveTextCenter(subtitles[creditcounter]);
		RED;
		setcursor(dutydrawcoords.X, dutydrawcoords.Y);
		bufferprint(1, titles[creditcounter]);
		setcursor(dutydrawcoords.X, dutydrawcoords.Y);
		LRED;
		bufferprint(1, titles[creditcounter]);
		Sleep(1000);
		RED;
		setcursor(namedrawcoords.X, namedrawcoords.Y);
		bufferprint(1, subtitles[creditcounter]);
		setcursor(namedrawcoords.X, namedrawcoords.Y);
		LRED;
		bufferprint(1, subtitles[creditcounter]);
		
		Sleep(3500);
		
		RED;
		setcursor(dutydrawcoords.X, dutydrawcoords.Y);
		printf(titles[creditcounter]);
		setcursor(dutydrawcoords.X, dutydrawcoords.Y);
		RED;
		setcursor(namedrawcoords.X, namedrawcoords.Y);
		printf(subtitles[creditcounter]);
		setcursor(namedrawcoords.X, namedrawcoords.Y);
		Sleep(80);
		setcursor(namedrawcoords.X, namedrawcoords.Y);
		cleartext(subtitles[creditcounter]);
		setcursor(dutydrawcoords.X, dutydrawcoords.Y);
		cleartext(titles[creditcounter]);
		Sleep(1000);
		
	}
	
	dutydrawcoords = retrieveTextCenter(agencystring);
	RED;
	setcursor(dutydrawcoords.X, dutydrawcoords.Y);
	printf(agencystring);
	LRED;
	Sleep(150);
	setcursor(dutydrawcoords.X, dutydrawcoords.Y);
	printf(agencystring);
	Sleep(2000);
	RED;
	setcursor(dutydrawcoords.X, dutydrawcoords.Y);
	printf(agencystring);
	Sleep(150);
	cls();
		dutydrawcoords = retrieveTextCenter(loadingstring);
	RED;
	setcursor(dutydrawcoords.X, dutydrawcoords.Y);
	printf(loadingstring);
	LRED;
	Sleep(150);
	setcursor(dutydrawcoords.X, dutydrawcoords.Y);
	printf(loadingstring);
	Sleep(2000);
	RED;
	setcursor(dutydrawcoords.X, dutydrawcoords.Y);
	printf(loadingstring);
	Sleep(150);
	cls();
}
Пример #11
0
void CreditScreen()
{
#define MAX_DUTIES 21
#define MAX_CREDIT_LENGTH 400
	
#define CREDIT_REDFLASH 0
#define CREDIT_GREENFADE 1
	
	//#define PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT 16
	//#define PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP 4
	//#define PROMPT_TEXT_WIDTH	46
	//#define PROMPT_TEXT_HEIGHT 15
	
	RECT boxrect;
	int creditcounter;
	char duties[MAX_DUTIES][MAX_CREDIT_LENGTH] = {
		"THE AGENCY",
			"Based On \"The Agency\" Espionage Universe", 
			"Designer",
			"Lead Programmer",
			"Glamour Model",
			"Box / Manual Design",
			"Special Thanks To:", 
			"Special Thanks To:",
			"We Extend A Special Thank You To:",
			"We Extend A Special Thank You To:",
			"We Extend A Special Thank You To:",
			"Vorpal Design Group is a small west-coast game design group centered around the intelligence and military gaming enthusiast.",
			"The Agency is an original concept created by Charles Cox. For franchising information, and for info on how you can become a part of The Agency Universe, please contact Charles Cox, President of VDG at: [email protected]",
			"We will be bringing The Agency : Razor One to you in full 3d very soon. Please stay tuned to the company that brings the intelligence and military world to your computer:",
			"Vorpal",
			"VDG   ",
			"Charles Cox",
			"Wyatt Jackson",
			"Eddy Irwin",
			"Jennifer Dygert",
			"THANKS FOR PLAYING!"
	};
	
	char names[MAX_DUTIES][MAX_CREDIT_LENGTH] = {
		"RAZOR ONE",
			"By Charles Cox", 
			"Charles Cox",
			"Charles Cox",
			"Charlie \"Flowers\" From Jersey City",
			"Charles Cox",
			"Wyatt Jackson (Dr. J)",
			"\"Fast\" Eddy Irwin From Jersey City",
			"\"Big\" Bird",
			"Big \"Bird\"",
			"Bert \"and\" Ernie",
			"",
			"",
			"",
			"Design Group",
			"   IS",
			"President, CEO, Lead Designer",
			"Programmer",
			"Programmer / Designer",
			"Craft Services",
			"PRESS A KEY TO RETURN."
	} ; 
	
	int styles[MAX_DUTIES] = {
		CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_GREENFADE,
			CREDIT_GREENFADE,
			CREDIT_GREENFADE,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
	};
	
	COORD dutydrawcoords;
	COORD namedrawcoords;
	COORD boxsize = {PROMPT_TEXT_WIDTH, PROMPT_TEXT_HEIGHT};
	COORD boxstart = {PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT, PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP};
	COORD zeroed = {0,0};
	
	
	boxrect.left = PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT;
	boxrect.top = PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP;
	boxrect.right = PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT+PROMPT_TEXT_WIDTH;
	boxrect.bottom = PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP + PROMPT_TEXT_HEIGHT;
	
	
	LoopSong(globals.musiclist.songs[CREDITS_SONG]);
	
	styles[MAX_DUTIES - 1] = CREDIT_REDFLASH; //THE LAST CREDIT MUST ALWAYS BE REDFLASH.
	
	GREEN;
	printgraphic(globals.graphicslist, zeroed,  PROMPT_GRAPHIC_ID);
	for (creditcounter = 0; creditcounter < MAX_DUTIES; creditcounter++){
		if (styles[creditcounter] == CREDIT_REDFLASH)
		{
			ClearRect(boxrect);
			dutydrawcoords = retrieveTextCenter(duties[creditcounter]);
			dutydrawcoords.Y --;
			namedrawcoords = retrieveTextCenter(names[creditcounter]);
			RED;
			setcursor(dutydrawcoords.X, dutydrawcoords.Y);
			bufferprint(1, duties[creditcounter]);
			setcursor(dutydrawcoords.X, dutydrawcoords.Y);
			LRED;
			bufferprint(1, duties[creditcounter]);
			Sleep(200);
			RED;
			setcursor(namedrawcoords.X, namedrawcoords.Y);
			bufferprint(1, names[creditcounter]);
			setcursor(namedrawcoords.X, namedrawcoords.Y);
			LRED;
			bufferprint(1, names[creditcounter]);
			if (creditcounter < MAX_DUTIES - 1)
			{
				Sleep(3500);
				
				RED;
				setcursor(dutydrawcoords.X, dutydrawcoords.Y);
				printf(duties[creditcounter]);
				setcursor(dutydrawcoords.X, dutydrawcoords.Y);
				RED;
				setcursor(namedrawcoords.X, namedrawcoords.Y);
				printf(names[creditcounter]);
				setcursor(namedrawcoords.X, namedrawcoords.Y);
				Sleep(80);
				setcursor(namedrawcoords.X, namedrawcoords.Y);
				cleartext(names[creditcounter]);
				setcursor(dutydrawcoords.X, dutydrawcoords.Y);
				cleartext(duties[creditcounter]);
				Sleep(1000);
			}
			else{
				FLUSH;
				clearinputrecords();
				waitforkey();
				StopSong();
				cls();
				return;
			}
		}
		else if (styles[creditcounter] == CREDIT_GREENFADE)
		{
			ClearRect(boxrect);
			GREEN;
			
			printwordwrapcoordinate(duties[creditcounter], boxsize, boxstart);
			Sleep(80);
			LGREEN;
			
			printwordwrapcoordinate(duties[creditcounter], boxsize, boxstart);
			Sleep(10000);
			GREEN;
			
			printwordwrapcoordinate(duties[creditcounter], boxsize, boxstart);
			Sleep(80);
			ClearRect(boxrect);
			Sleep(1000);
		}
	}
	
}
Пример #12
0
void SynchronizeChronoSequence(PCHRONOSTRUCT chrono, PMISSIONCHRONO mchrono)
{
	CHRONOSTRUCT localchron;
	MISSIONCHRONO localmchron;
	COORD mcdrawcoords;
	COORD cdrawcoords;
	COORD synccoords;
	char ctimebuf[80];
	char mctimebuf[80];
	unsigned int iterations = 0;
	int velocity = 1;
	int velocitycounter = 0;
	char* synctext = "S Y N C H R O N I Z I N G";
	char* syncdonetext = "S Y N C H R O N I Z E D";
	int speed = 1;
	
	memset(&localchron, 0, sizeof(CHRONOSTRUCT));
	memset(&localmchron, 0, sizeof(MISSIONCHRONO));
	localmchron.countdown = FALSE;
	
	SPrintMissionChrono(mctimebuf, &localmchron);
	SPrintChrono(ctimebuf, &localchron);
	
	cdrawcoords = retrieveTextCenter(ctimebuf);
	mcdrawcoords = retrieveTextCenter(mctimebuf);
	synccoords = retrieveTextCenter(synctext);
	
	cdrawcoords.Y++; //SPLIT THEM UP
	mcdrawcoords.Y--; 
	
	setcursor(synccoords.X, synccoords.Y);
	RED;
	printf(synctext);
	
	while(iterations < 2000000){
		iterations++;
		if (localmchron.hours < mchrono->hours || localmchron.minutes < mchrono->minutes || localmchron.seconds < mchrono->seconds || localmchron.split <= mchrono->split)
		{
			localmchron.split ++;
			calibratemissionchrono(&localmchron);
		}
		else{
			localmchron = *mchrono;
		}
		if (localchron.hour < chrono->hour || localchron.minute < chrono->minute || localchron.second < chrono->second){
			localchron.second ++;
			calibratechrono(&localchron);
		}
		else
		{
			localchron = *chrono;
		}
		
		speed++;
		
		if (speed % velocity == 0)
		{
			SPrintChrono(ctimebuf, &localchron);
			SPrintMissionChrono(mctimebuf, &localmchron);
			LRED;
			setcursor(mcdrawcoords.X, mcdrawcoords.Y);
			printf(mctimebuf);
			LGREEN;
			setcursor(cdrawcoords.X, cdrawcoords.Y);
			printf(ctimebuf);
			
		}
		
		velocitycounter++;
		if (velocitycounter > 400){
			velocitycounter = 0;
			velocity++;
		}
		
		
		
		if (localmchron.hours >= mchrono->hours && localmchron.minutes >= mchrono->minutes && localmchron.seconds >= mchrono->seconds && localmchron.split >= mchrono->split && localchron.hour >= chrono->hour && localchron.minute >= chrono->minute && localchron.second >= chrono->second){
			SPrintChrono(ctimebuf, &localchron);
			SPrintMissionChrono(mctimebuf, &localmchron);
			LRED;
			setcursor(mcdrawcoords.X, mcdrawcoords.Y);
			printf(mctimebuf);
			LGREEN;
			setcursor(cdrawcoords.X, cdrawcoords.Y);
			printf(ctimebuf);
			WHITE;
			setcursor(synccoords.X, synccoords.Y);
			cleartext(synctext);
			synccoords = retrieveTextCenter(syncdonetext);
			setcursor(synccoords.X, synccoords.Y);
			printf(syncdonetext);
			
			break;
		}
	}
	Sleep(2000);
	GRAY;
	setcursor(synccoords.X, synccoords.Y);
	printf(syncdonetext);
	RED;
	setcursor(mcdrawcoords.X, mcdrawcoords.Y);
	printf(mctimebuf);
	GREEN;
	setcursor(cdrawcoords.X, cdrawcoords.Y);
	printf(ctimebuf);
	Sleep(80);
	cls();
}