void ResourceHandler::add(std::string fileRef) { if(mLoadables.count(fileRef) < 1) { switch(type(fileRef)) { case Resource_Type::TEXTURE: mLoadables.insert(std::pair<std::string, Loadable&>(fileRef, mTexStore.add(fileRef))); break; case Resource_Type::AUDIO: mLoadables.insert(std::pair<std::string, Loadable&>(fileRef, mSBufStore.add(fileRef))); break; case Resource_Type::BUNDLE: addResources(fileRef); break; case Resource_Type::UNKNOWN: SError("fileRef check failed", "fileRef was UNKNOWN with type: " + fileRef); break; default: SError("fileRef check failed", "type not in list!"); break; } } else { // TODO add warning } }
EntityImp* entFac::createPowerUpRandom(b2World& world, float x, float y) { std::string bodyData("res/conf/powerUpBody.cfg"); int totalChance = spawnRates.getValue<int>("LHydrogen") + spawnRates.getValue<int>("EnergyTorpedo") + spawnRates.getValue<int>("EMP"); int previous = 0; int rand_val = rand() % totalChance; if(rand_val < spawnRates.getValue<int>("LHydrogen")) { return new LHydrogen(world, bodyData, x, y); } else previous += spawnRates.getValue<int>("LHydrogen"); if(rand_val < previous + spawnRates.getValue<int>("EnergyTorpedo")) { return new ETorpedoPickup(world, bodyData, x, y); } else previous += spawnRates.getValue<int>("EnergyTorpedo"); if(rand_val < previous + spawnRates.getValue<int>("EMP")) { return new EMP(world, bodyData, x, y); } else previous += spawnRates.getValue<int>("EMP"); SError("Random value out of bounds", "The Randomization value for powerup spawn is not in the desired range" + rand_val); return 0; }
Histogram &Histogram::operator+=(Histogram &gram) { if(!same(gram)) { SError("histogram is not same!"); return *this; } int i,j; for(i=0;i<rowNum;++i) { for(j=0;j<colNum;++j) { cells[i][j] += *(gram.getCell(i,j)); } } return *this; }
bool Config::getValue(std::string option) { std::map<std::string, std::string>::iterator it = mConfData.find(option); SAssert( it != mConfData.end(), "Key: " + option + " not found in " + mFilePath); if(it->second == "false") { return false; } else if(it->second == "true") { return true; } else { SError("Conversion Error" , "Cannot convert " + it->second + " to bool" ); #ifdef NDEBUG return false; #endif } }
void CErrorStack::Push(const CErrorStack::ECode eCode, const CString &cMessage) { TStack *cStack = m_cErrors.get(); cStack->push(SError(eCode, cMessage)); }