// created this function because it is called from client.qc as well // was originally part of PlayerDie() and hasn't been altered void StartDie () { if ( self->s.v.weapon == IT_AXE ) { player_die_ax1(); return; } // if ( k_yawnmode ) // qqshka: this way it better if ( 1 ) { // Yawnmode: exclude diea1 and diec1 so the respawn time is always 900 ms switch( i_rnd(1, 3) ) { case 1: player_dieb1(); break; case 2: player_died1(); break; default: player_diee1(); break; } } else { // Note that this generates random values in 1..6 range, so player_diee1 is // executed twice as often as other death sequences. Dunno if this should be fixed -- Tonik int i = 1 + floor( g_random() * 6 ); switch( i ) { case 1: player_diea1(); break; case 2: player_dieb1(); break; case 3: player_diec1(); break; case 4: player_died1(); break; default: player_diee1(); break; } } }
void a_shuffle(Array array) { Byte *tmp = xmalloc(array->s); for (int i = array->n - 1; i > 0; i--) { int r = i_rnd(i + 1); // random number between [0,i] // swap indices i and r memcpy(tmp, (Byte*)array->a + r * array->s, array->s); memcpy((Byte*)array->a + r * array->s, (Byte*)array->a + i * array->s, array->s); memcpy((Byte*)array->a + i * array->s, tmp, array->s); } free(tmp); }
WIN32DLL_DEFINE void _mcrypt_decrypt(cast256_key * key, word32 * blk) { word32 t, u; #ifdef WORDS_BIGENDIAN blk[0] = byteswap32(blk[0]); blk[1] = byteswap32(blk[1]); blk[2] = byteswap32(blk[2]); blk[3] = byteswap32(blk[3]); #endif f_rnd(blk, 88); f_rnd(blk, 80); f_rnd(blk, 72); f_rnd(blk, 64); f_rnd(blk, 56); f_rnd(blk, 48); i_rnd(blk, 40); i_rnd(blk, 32); i_rnd(blk, 24); i_rnd(blk, 16); i_rnd(blk, 8); i_rnd(blk, 0); #ifdef WORDS_BIGENDIAN blk[0] = byteswap32(blk[0]); blk[1] = byteswap32(blk[1]); blk[2] = byteswap32(blk[2]); blk[3] = byteswap32(blk[3]); #endif }
void decrypt (const u4byte in_blk[4], u4byte out_blk[4]) { u4byte t, u, blk[4]; blk[0] = io_swap (in_blk[0]); blk[1] = io_swap (in_blk[1]); blk[2] = io_swap (in_blk[2]); blk[3] = io_swap (in_blk[3]); f_rnd (blk, 88); f_rnd (blk, 80); f_rnd (blk, 72); f_rnd (blk, 64); f_rnd (blk, 56); f_rnd (blk, 48); i_rnd (blk, 40); i_rnd (blk, 32); i_rnd (blk, 24); i_rnd (blk, 16); i_rnd (blk, 8); i_rnd (blk, 0); out_blk[0] = io_swap (blk[0]); out_blk[1] = io_swap (blk[1]); out_blk[2] = io_swap (blk[2]); out_blk[3] = io_swap (blk[3]); }
int ia_rnd(int index, int maximum) { return i_rnd(maximum); // index not used }
int rc6_decrypt(struct cipher_context *cx, const u8 *in, u8 *out, int size, int atomic) { u32 *l_key = cx->keyinfo; u32 *in_blk = (u32 *)in; u32 *out_blk = (u32 *)out; u32 a,b,c,d,t,u; d = in_blk[3]; c = in_blk[2] - l_key[43]; b = in_blk[1]; a = in_blk[0] - l_key[42]; i_rnd(40,d,a,b,c); i_rnd(38,c,d,a,b); i_rnd(36,b,c,d,a); i_rnd(34,a,b,c,d); i_rnd(32,d,a,b,c); i_rnd(30,c,d,a,b); i_rnd(28,b,c,d,a); i_rnd(26,a,b,c,d); i_rnd(24,d,a,b,c); i_rnd(22,c,d,a,b); i_rnd(20,b,c,d,a); i_rnd(18,a,b,c,d); i_rnd(16,d,a,b,c); i_rnd(14,c,d,a,b); i_rnd(12,b,c,d,a); i_rnd(10,a,b,c,d); i_rnd( 8,d,a,b,c); i_rnd( 6,c,d,a,b); i_rnd( 4,b,c,d,a); i_rnd( 2,a,b,c,d); out_blk[3] = d - l_key[1]; out_blk[2] = c; out_blk[1] = b - l_key[0]; out_blk[0] = a; return 0; };