/*
================================================================================
H_HashCode () : returns hash code
================================================================================
*/
int H_HashCode::hash (char s[]) {
this->n = strlen (this->s);
do {
this->hashValue += this->s[this->x]*31^(this->n-(this->x+1));
this->x++;
} while (this->x < this->n);
return hashValue;
}
/*
================================================================================
ReadCFG () : Read all important data from CFG File
================================================================================
*/
void GL_ReadCFG::ReadCFG (void) {
if ((this->f = fopen ("mpark.txt", "r")) != NULL) {
while ((fscanf(f, "%d.%s", &this->value, this->var)) != EOF) {
int myHash = 0;
myHash = this->hash->hash (this->var);
switch (myHash) {
case this->hash->hash ("width"):
this->width = this->value;
break;
case this->hash->hash ("height"):
this->height = this->value;
break;
case this->hash->hash ("bpp"):
this->bpp = this->value;
break;
default:
break;
}
}
} else {
this->CreateCFG ();
}
}