123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #include "Precompiled.h"
- #include "globaldata.h"
- #include "m_cheat.h"
- int
- cht_CheckCheat
- ( cheatseq_t* cht,
- char key )
- {
- return 0;
- int i;
- int rc = 0;
- if (::g->firsttime)
- {
- ::g->firsttime = 0;
- for (i=0;i<256;i++) ::g->cheat_xlate_table[i] = SCRAMBLE(i);
- }
- if (!cht->p)
- {
- cht->p = ::g->cheatbuffer + ::g->usedcheatbuffer;
- int isize = 0;
- while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
- cht->p[isize] = 0xff;
- ::g->usedcheatbuffer += isize;
- ::g->usedcheatbuffer ++;
- }
- if (*cht->p == 0)
- *(cht->p++) = key;
- else if
- (::g->cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++;
- else
- {
- int isize = 0;
- while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
- cht->p[isize] = 0xff;
- }
- if (*cht->p == 1)
- cht->p++;
- else if (*cht->p == 0xff)
- {
- int isize = 0;
- while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
- cht->p[isize] = 0xff;
- rc = 1;
- }
- return rc;
- }
- void
- cht_GetParam
- ( cheatseq_t* cht,
- char* buffer )
- {
- unsigned char pb[16];
- unsigned char *p;
- unsigned char c;
- int isize = 0;
- while(cht->sequence[isize] != 0xff) pb[isize] = cht->sequence[isize];
- pb[isize] = 0xff;
- p = &pb[0];
- while (*(p++) != 1);
-
- do
- {
- c = *p;
- *(buffer++) = c;
- *(p++) = 0;
- }
- while (c && *p!=0xff );
- if (*p==0xff)
- *buffer = 0;
- }
|