Valhalla Legends Forums Archive | Battle.net Bot Development | Why isn't this CheckRevision code working?

AuthorMessageTime
cibula2008
I was trying to make this work for some time now, but it always turned up wrong value.  :'(

I am sure that I have made some retarded mistake tho.

[Code]int ExtractMPQNumber(char* mpqName)
{


if (((mpqName[0] == 'l') || (mpqName[0] == 'L')) && ((mpqName[1] == 'o') || (mpqName[1] == 'O')) && ((mpqName[2] == 'c') || (mpqName[2] == 'C')))
{return -1;}

if (strlen(mpqName) < 7)
{return -1;}

char Number[2];
Number[1]='\0';

if (((mpqName[0] == 'v') || (mpqName[0] == 'V')) && ((mpqName[1] == 'e') || (mpqName[1] == 'E')) && ((mpqName[2] == 'r') || (mpqName[2] == 'R')))
{
Number[0]=mpqName[9];
}
else  // IX86VerX.mpq
{
Number[0]=mpqName[7];
}

return atoi(Number);
}
int DoCheckRevision(char* valueString,char* fileA,char* fileB,char* fileC,int mpqNumber)
{

printf("%d\n",mpqNumber);

unsigned int values[4] = {0};

int opValueDest[4] = {0};
int opValueSrc1[4] = {0};
char operation[4] = {0};
int opValueSrc2[4] = {0};

int currentFormula = 0;

char tokens[12][16];

int AtToken = 0;
int AtTokenChar = 0;
int AtNow = 0;
while (valueString[AtNow] != '\0')
{
if (valueString[AtNow] == ' ')
{
tokens[AtToken++][AtTokenChar++] = '\0';
AtTokenChar = 0;
}
else
{
tokens[AtToken][AtTokenChar++] = valueString[AtNow];
}
AtNow++;
}

tokens[AtToken++][AtTokenChar] = '\0';


for (int i = 0; i < AtToken; i++)
{
printf("TokenSTR %s\n",tokens[i]);
char LeftStr[16];
char RightStr[16];
bool HasEqualSign = false;
int RightStrAt=0;

for (int ii = 0; ii < 32; ii++)
{
if (tokens[i][ii]=='\0')
{break;}
else if (tokens[i][ii]=='=')
{LeftStr[ii] = '\0';HasEqualSign=true;}
else if (HasEqualSign == true)
{RightStr[RightStrAt++] = tokens[i][ii];}
else {LeftStr[ii] = tokens[i][ii];}
}
RightStr[RightStrAt++] = '\0';

printf("Left STR: %s Right STR: %s HasEqual %d\n",LeftStr,RightStr,HasEqualSign);
             
if (HasEqualSign == true)
{
int variable = getNum(LeftStr[0]);

if ((RightStr[0]=='a')||(RightStr[0]=='A')||(RightStr[0]=='b')||(RightStr[0]=='B')||(RightStr[0]=='c')||(RightStr[0]=='C')||(RightStr[0]=='s')||(RightStr[0]=='S'))
{
opValueDest[currentFormula] = variable;

opValueSrc1[currentFormula] = getNum(RightStr[0]);
operation[currentFormula] = RightStr[1];
opValueSrc2[currentFormula] = getNum(RightStr[2]);

currentFormula++;
}
else
{
char lastnum[2];lastnum[1]='\0';lastnum[0]=RightStr[strlen(RightStr)-1];RightStr[strlen(RightStr)-1]='\0';
values[variable] = (atoi(RightStr)*10)+atoi(lastnum);
}
                   
}
}

printf("Var0 %u Var1 %u Var2 %u Var3 %u\n",values[0],values[1],values[2],values[3]);

// Now we actually do the hashing for each file
// Start by hashing A by the hashcode
values[0] ^= hashcodes[mpqNumber];

ifstream::pos_type size;
unsigned char * memblock[3];
int FileSize[3] = {0};
int BufferSize[3] ={0};

for (int i = 0; i < 3; i++)
{
ifstream file;
if (i==0)
{file.open(fileA, ios::in|ios::binary|ios::ate);}
if (i==1)
{file.open(fileB, ios::in|ios::binary|ios::ate);}
if (i==2)
{file.open(fileC, ios::in|ios::binary|ios::ate);}
if (file.is_open())
{
size = file.tellg();
memblock[i] = new unsigned char [(int)size+1025];
file.seekg (0, ios::beg);
file.read ((char *)memblock[i], (int)size);
FileSize[i] = (int)size;
printf("the complete file content is in memory %u\n",FileSize[i]);
}

if ((FileSize[i] % 1024) == 0)
{
BufferSize[i] = FileSize[i];
}
else
{
int paddingBytes = (1024 - (FileSize[i] % 1024));
BufferSize[i] = FileSize[i] + paddingBytes;

unsigned char currentPaddingByte = 0xff;
for (int j = FileSize[i]; j < BufferSize[i]; j++)
{
memblock[i][j] = currentPaddingByte--;
}
}

for (int j = 0; j < BufferSize[i]; j += 4)
{
values[3] = ((int)memblock[i][3+j])+(((int)memblock[i][2+j])*256)+(((int)memblock[i][1+j])*65536)+(((int)memblock[i][0+j])*16777216);

for (int k = 0; k < currentFormula; k++)
{
switch (operation[k])
{
case '+':
values[opValueDest[k]] = values[opValueSrc1[k]] + values[opValueSrc2[k]];
break;

case '-':
values[opValueDest[k]] = values[opValueSrc1[k]] - values[opValueSrc2[k]];
break;

case '^':
values[opValueDest[k]] = values[opValueSrc1[k]] ^ values[opValueSrc2[k]];
break;

case '*':
values[opValueDest[k]] = values[opValueSrc1[k]] * values[opValueSrc2[k]];
break;

case '/':
values[opValueDest[k]] = values[opValueSrc1[k]] / values[opValueSrc2[k]];
break;
}
}
}

file.close();
}

return (int)values[2];
}

int getNum(char c)
{
if (c == 'S')
{return 3;}
else
{return c - 'A';}
}[/Code]
July 17, 2008, 10:19 PM
UserLoser
that version of checkrevision isn't used no more
July 17, 2008, 11:46 PM
cibula2008
[quote author=UserLoser link=topic=17576.msg178974#msg178974 date=1216338373]
that version of checkrevision isn't used no more
[/quote]

Where would I find one that is used?
July 17, 2008, 11:48 PM

Search