in atari_py/ale_interface/src/emucore/PropsSet.cxx [49:104]
void PropertiesSet::getMD5(const string& md5, Properties& properties,
bool useDefaults) const
{
properties.setDefaults();
bool found = false;
// First check our dynamic BST for the object
if(!useDefaults && myRoot != 0)
{
TreeNode* current = myRoot;
while(current)
{
const string& currentMd5 = current->props->get(Cartridge_MD5);
if(currentMd5 == md5)
{
// We only report a node as found if it's been marked as valid.
// Invalid nodes are those that should be removed, and are
// essentially treated as if they're not present.
found = current->valid;
break;
}
else if(md5 < currentMd5)
current = current->left;
else
current = current->right;
}
if(found)
properties = *(current->props);
}
// Otherwise, search the internal database using binary search
if(!found)
{
int low = 0, high = DEF_PROPS_SIZE - 1;
while(low <= high)
{
int i = (low + high) / 2;
int cmp = strncmp(md5.c_str(), DefProps[i][Cartridge_MD5], 32);
if(cmp == 0) // found it
{
for(int p = 0; p < LastPropType; ++p)
if(DefProps[i][p][0] != 0)
properties.set((PropertyType)p, DefProps[i][p]);
found = true;
break;
}
else if(cmp < 0)
high = i - 1; // look at lower range
else
low = i + 1; // look at upper range
}
}
}