@nite Hi,
On the local sdkbox_config.json I have typing error (bad achievement id aa11 with name A1).
In method onAchievementsLoaded we get the info about real achievement state(hidden) and id aa1, that’s great.
So I know that I have hidden achievement with realid aa1, and try to reveal it.
I parsed the sdkbox_config.json and trying to find aa1 and his name to unlock it with method reveal( const std::string& achievement_name ), nothig found (remember I have a typing error (aa11)).
No problem we have live ops. I made the correction (to aa1) and published to the cloud.
Game restarted twice to be sure that new sdkbox_config.json is downloaded.
Question is how to read the updated config to find the name for realid aa1. Don’t tell me unlock the name A1
Updated config is encypted and name is “config” and there is some config_hash. How to read them?
Edit1:
File is base64, which contains xxtea encrypted string. To decrypt “config” with secret: base64 decode and xxtea decrypt with secret from live ops page.
Too complicated There is no method to get the updated config? Let me know.
My goal is to take the full advantage with liveops editing and read the onAchievementsLoaded info and unlock them with game logic.
Thank you for your time and help
Edit2:
Here is the method to read the updated config.
void decryptXxtea(std::string &value, std::string &secret){
xxtea_long retLength = 0;
unsigned char * decryptedData = xxtea_decrypt((unsigned char*)value.c_str(), (xxtea_long) value.size(), (unsigned char*)secret.c_str(), (xxtea_long)secret.size(), &retLength);
value.clear();
value.append(reinterpret_cast<char*>(decryptedData), retLength);
free(decryptedData);
}
auto fu = cocos2d::FileUtils::getInstance();
std::string remoteFile = fu->getWritablePath()+"config";
bool remoteConfigExist = fu->isFileExist(remoteFile);
if(remoteConfigExist){
auto remoteSdkBoxConfig = fu->getStringFromFile(remoteFile);
unsigned char * data = nullptr;
int dataLen = cocos2d::base64Decode(reinterpret_cast<const unsigned char*>(remoteSdkBoxConfig.c_str()), (unsigned int)remoteSdkBoxConfig.size(), &data);
remoteSdkBoxConfig.clear();
remoteSdkBoxConfig.append(reinterpret_cast<const char*>(data), dataLen);
free(data);
std::string secret = "CHANGEYOURSECRET";
decryptXxtea(remoteSdkBoxConfig, secret);
CCLOG("remote config:%s" ,remoteSdkBoxConfig.c_str());
}