// // Called in st_stuff module, which handles the input. // Returns a 1 if the cheat was successful, 0 if failed. // int cht_CheckCheat (cheatseq_t *cht, char key) { int i; int rc = 0; if (firsttime) { firsttime = 0; for (i = 0; i < 256; i++) cheat_xlate_table[i] = (unsigned char)SCRAMBLE(i); } if (!cht->p) cht->p = cht->sequence; // initialize if first time if (*cht->p == 0) *(cht->p++) = key; else if (cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++; else cht->p = cht->sequence; if (*cht->p == 1) cht->p++; else if (*cht->p == 0xff) // end of sequence character { cht->p = cht->sequence; rc = 1; } return rc; }
void cht_Init(void) { size_t i = 0; short pi = 0; for (; i < 256; i++, pi++) { const int cc = SCRAMBLE(pi); cheat_xlate_table[i] = (byte)cc; } }
static void fill_buffer(uint8_t *buf, size_t size) { size_t i; if (!buf) return; for (i = 0; i < size; i++) buf[i] = SCRAMBLE(i); }
void cht_Init(void) { size_t i = 0; INT16 pi = 0; for (; i < 256; i++, pi++) { const INT32 cc = SCRAMBLE(pi); cheat_xlate_table[i] = (UINT8)cc; } }
static TEE_Result verify_buffer(uint8_t *buf, size_t size) { size_t i; if (!buf) return TEE_ERROR_BAD_PARAMETERS; for (i = 0; i < size; i++) { uint8_t expect_data = SCRAMBLE(i); if (expect_data != buf[i]) { return TEE_ERROR_CORRUPT_OBJECT; } } return TEE_SUCCESS; }
static void get_options( void ) { static const struct option_info_s { const char *name; int *var, val; } option_info[] = { { "off", &nodebug, 1 }, { "noabort", &noabort, 1 }, { "noerror", &noerror, 1 }, { "nocount", &count, Count_no }, { "nosync", &nosync, 1 }, #if LDAP_THREAD_DEBUG_THREAD_ID +0 { "threadID", &threadID, 1 }, #endif #ifdef LDAP_THREAD_DEBUG_WRAP { "nomem", &nomem, 1 }, { "noreinit", &noreinit, 1 }, { "noalloc", &wraptype, Wrap_noalloc }, { "alloc", &wraptype, Wrap_alloc }, { "adjptr", &wraptype, Wrap_adjptr }, { "scramble", &wraptype, Wrap_scramble }, #endif { "tracethreads", &tracethreads, 1 }, { NULL, NULL, 0 } }; const char *s = getenv( "LDAP_THREAD_DEBUG" ); if( s != NULL ) { while( *(s += strspn( s, ", \t\r\n" )) != '\0' ) { size_t optlen = strcspn( s, ", \t\r\n" ); const struct option_info_s *oi = option_info; while( oi->name && (strncasecmp( oi->name, s, optlen ) || oi->name[optlen]) ) oi++; if( oi->name ) *oi->var = oi->val; else fprintf( stderr, "== thr_debug: Unknown $%s option '%.*s' ==\n", "LDAP_THREAD_DEBUG", (int) optlen, s ); s += optlen; } } if( nodebug ) { tracethreads = 0; nosync = noerror = 1; } if( nosync ) count = Count_no; if( noerror ) noabort = 1; #if LDAP_THREAD_DEBUG_THREAD_ID +0 if( nosync ) threadID = 0; #endif #ifdef LDAP_THREAD_DEBUG_WRAP if( noerror ) nomem = 1; if( !nomem ) { static const ldap_debug_usage_info_t usage; if( sizeof(LDAP_UINTPTR_T) < sizeof(unsigned char *) || sizeof(LDAP_UINTPTR_T) < sizeof(ldap_debug_usage_info_t *) || UNSCRAMBLE_usagep( SCRAMBLE( &usage ) ) != &usage || UNSCRAMBLE_dummyp( SCRAMBLE( (unsigned char *) 0 ) ) ) { fputs( "== thr_debug: Memory checks unsupported, " "adding nomem to $LDAP_THREAD_DEBUG ==\n", stderr ); nomem = 1; } } if( nomem ) { noreinit = 1; wraptype = Wrap_noalloc; } unwrap_offset = -(wrap_offset = (wraptype == Wrap_adjptr)); #endif wrap_threads = (tracethreads || threadID || count); options_done = 1; }
+ (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7)) typedef struct { byte *sequence; byte *p; } cheatseq_t; // ========================================================================== // CHEAT Structures // ========================================================================== // SRB2CBTODO: Make cool use of special cheats that are activated by sequence like this! static byte cheat_bulmer_seq[] = { SCRAMBLE('b'), SCRAMBLE('e'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('e'), 0xff }; static byte cheat_poksoc_seq[] = { SCRAMBLE('p'), SCRAMBLE('o'), SCRAMBLE('k'), SCRAMBLE('s'), SCRAMBLE('o'), SCRAMBLE('c'), 0xff }; static byte cheat_apl_seq[] = { SCRAMBLE('a'), SCRAMBLE('p'), SCRAMBLE('l'), 0xff }; static byte cheat_ultimate_seq[] = { SCRAMBLE('u'), SCRAMBLE('l'), SCRAMBLE('t'), SCRAMBLE('i'), SCRAMBLE('m'), SCRAMBLE('a'), SCRAMBLE('t'), SCRAMBLE('e'), 0xff