Seriosk
Programmer;
- Oct 29, 2016
- 256
- 105
Why don't you instead of loading about 100+ fields like most emulators do, use a KeyValue pair and cache it? Also add the functionality to get it live from the database would be nice, here is something I coded not too long ago...
Or.. store it in a dictionary
Then get the string..
Only downside is your hard coding the column names everywhere, you should probably also code a system to sort that out. I'm not saying use this because this is pretty horrible but use is as a template on what you would go...
Id also probably use an extra bool (default to false) to maybe get it live from the database?
Or.. store it in a dictionary
Code:
private readonly Dictionary<string, string> _cachedData;
Then get the string..
Code:
public string GetString(string columnName)
{
if (_cachedData.ContainsKey(columnName) && _cacheEnabled)
{
return _cachedData[columnName];
}
else
{
var columnValue = SelectColumn(_player.GetHabbo().Id, columnName);
_cachedData[columnName] = columnValue;
return columnValue;
}
}
Only downside is your hard coding the column names everywhere, you should probably also code a system to sort that out. I'm not saying use this because this is pretty horrible but use is as a template on what you would go...
Id also probably use an extra bool (default to false) to maybe get it live from the database?