Code: Select all
int get_id(string game, string name)
{
name = to_upper(name); // convert to uppercase
if (game != game_ts)
{ // for TD and RA
int i = 0;
unsigned int id = 0;
int l = name.length(); // length of the filename
while (i < l)
{
unsigned int a = 0;
for (int j = 0; j < 4; j++)
{
a >>= 8;
if (i < l)
a += static_cast<unsigned int>(name[i]) << 24; // I donot know how to convert this to autohotkey
i++;
}
id = (id << 1 | id >> 31) + a;
}
return id;
}
else
{ // for TS
const int l = name.length();
int a = l >> 2;
if (l & 3)
{
name += static_cast<char>(l - (a << 2)); // I donot know how to convert this to autohotkey
int i = 3 - (l & 3);
while (i--)
name += name[a << 2];
}
return name;
}
}