void PlayerDetails::fromXml(XML& xml){ mMesh = xml.getString("ship", "mesh"); mDll = xml.getString("ship", "dll"); mShield = xml.getFloat("ship", "shield"); mShieldRegen = xml.getFloat("ship", "shield_regen"); mArmour = xml.getFloat("ship", "armour"); mEnergy = xml.getFloat("ship", "energy"); mEnergyRegen = xml.getFloat("ship", "energy_regen"); mAmmo = xml.getInt("ship", "ammo"); mSpeed = xml.getFloat("ship", "speed"); mDeathFX = xml.getString("death_fx"); if (xml.getError() != XML_OK){ mDeathFX = ""; } { XMLIterator it(&xml); it.setElemName("ship>weaponchain"); it.gotoZero(); while(it.gotoNext()==true){ WeaponChain wc(it.getElem()); mWeaponChain.push_back(wc); } }{ XMLIterator it(&xml); it.setElemName("ship>reactor"); it.gotoZero(); while(it.gotoNext()==true){ mReactorNodes.push_back(it.getElem().getString("childName")); } } /* XMLIterator it(&xml); it.setElemName(""); it.gotoZero(); it.gotoNext(); XML elem; if (it.gotoNext() == false){ throw("Ship Definition File Missing 3 Weapon Chain"); } elem = it.getElem(); if (it.gotoNext() == false){ throw("Ship Definition File Missing 2 Weapon Chain"); } elem = it.getElem(); mSecondaryWeapon.fromXml(elem); if (it.gotoNext() == false){ throw("Ship Definition File Missing 1 Weapon Chain"); } elem = it.getElem(); mSuperWeapon.fromXml(elem);*/ int g=0; }
void WeaponChain::fromXml(XML& xml){ mTimeBetweenShots = xml.getFloat("time_between_shots"); XMLIterator it(&xml); it.setElemName("weaponchain>weapon"); it.gotoZero(); while(it.gotoNext()==true){ WeaponInfo wi(&it.getElem()); /*wd.DLL = it.getElem().getString("dll"); wd.XML = it.getElem().getString("xml"); wd.mount = it.getElem().getString("mount"); mWeapon.push_back(wd);*/ mWeapon.push_back(wi); } }
void DroneDBE::init(XML& dronestatXml, XML& objectMovementXml){ /*File f(getId()+".xml", "media/drones"); if (f.error() != FILE_OK){ throw("Drone without an XML file ("+getId()+")"); } XML* xml; xml = new XML(); xml->setContent((char*)f.content());*/ //XML* xml = new XML(getId()+".xml", "media/drones"); mMaxTime = dronestatXml.getFloat("maxtime"); std::string s; s = dronestatXml.getString("class"); if (dronestatXml.getError() != XML_OK){ throw("Drone class undefined ("+getId()+")"); } /*File file(s+".xml", "media/drones/classes"); if (file.error() != FILE_OK){ throw("Drone without an XML class file ("+getId()+")"); } XML* classXml; classXml = new XML(); classXml->setContent((char*)file.content());*/ XML* classXml = new XML(s+".xml", "media/drones/classes"); mScale = vector3FromString(classXml->getString("drone", "scale")); if (classXml->getError() != XML_OK){ mScale = Ogre::Vector3(1,1,1); }/*else{ int g=0; }*/ mMaxLife = classXml->getFloat("drone", "life"); if (classXml->getError() != XML_OK) throw("Class File Missing Argument : "+getId()+" (life)"); mScore= classXml->getInt("drone", "score"); if (classXml->getError() != XML_OK) throw("Class File Missing Argument : "+getId()+" (score)"); string dllName= classXml->getString("drone", "dll"); if (classXml->getError() == XML_OK){ #ifdef _DEBUG string name = dllName+"d"; mDll = LoadLibrary(name.c_str()); #else mDll = LoadLibrary(dllName.c_str()); #endif //mDllCallback = (DLLCallback)::GetProcAddress(weaponModule, "getInstance"); }else{ mDll = NULL; //mDllCallback = NULL; } { XMLIterator it(classXml); it.setElemName("drone>death"); it.gotoZero(); while(it.gotoNext() != false){ DEATH_BEHAVIOUR db; XML dbxml = it.getElem(); db.mFX = dbxml.getString("fx"); if (dbxml.getError() != XML_OK) db.mFX = ""; db.mDLLCustomCode = dbxml.getString("dll"); if (dbxml.getError() != XML_OK) db.mDLLCustomCode = ""; db.mTime = dbxml.getFloat("time"); if (dbxml.getError() != XML_OK) db.mTime = 0; #if 0 XMLIterator dit(&dbxml); dit.setElemName("death>debris"); dit.gotoZero(); while(dit.gotoNext() != false){ db.mDebris.push_back(dit.getElem()); /*DEBRIS_DETAIL dd; XML ditElem = dit.getElem(); string dir = ditElem.getString("direction"); if (dir == "forward"){ dd.mDirection = DEBRIS_DIRECTION_FORWARD; }else if (dir == "random"){ dd.mDirection = DEBRIS_DIRECTION_RANDOM; }else{ throw("Unsupported debris direction : "+dir); } dd.mSpinMultiplier = ditElem.getFloat("spin"); dd.mMesh = ditElem.getString("mesh"); dd.mPython = ditElem.getString("python"); if (ditElem.getError() != XML_OK){ dd.mPython = ""; } db.mDebris.push_back(dd);*/ }; #endif mDeath.push_back(db); } } { XMLIterator it(classXml); it.setElemName("drone>child"); it.gotoZero(); while(it.gotoNext() != false){ DRONE_CHILD dc; XML xml = it.getElem(); dc.mName = xml.getString("drone"); dc.mBone = xml.getString("bone"); if (xml.getError() != XML_OK){ dc.mBone = ""; } dc.mLabel = xml.getString("label"); int f = xml.getInt("forwardhits"); if (f == 1){ dc.mForward = true; }else{ dc.mForward = false; } Ogre::Vector3 v = vector3FromString(xml.getString("delta")); if (xml.getError() != XML_OK){ dc.mDelta = Ogre::Vector3(0,0,0); }else{ dc.mDelta = v; } mChild.push_back(dc); } } //if (classXml->getError() != XML_OK) throw("Class File Missing Argument : "+getId()+" (deathtime)"); string resource = classXml->getString("drone", "resource_path"); /*if (classXml->getError() == XML_OK){ this->addResourceContext(resource,"models"); }*/ string cn = classXml->getString("drone", "children"); if (classXml->getError() == XML_OK){ setChildrenName(cn); }else{ setChildrenName("."); } setMeshName(classXml->getString("drone", "mesh")); if (classXml->getError() != XML_OK){ throw("class without drone mesh"); } mResourceContext = classXml->getString("drone", "resource_path"); if (classXml->getError() != XML_OK){ mResourceContext = mMeshName; } { XMLIterator it(classXml); it.setElemName("drone>weapon"); it.gotoZero(); //FIRING_TIME ft; while(it.gotoNext() != false){ addWeaponInfo(&it.getElem()); }; } XMLIterator it(classXml); it.setElemName("drone>resource"); it.gotoZero(); //FIRING_TIME ft; while(it.gotoNext() != false){ /*if (it.getElem().getString("type") != "meshmaterial"){ addResource(it.getElem().getString("name"), it.getElem().getString("type")); }else{ addMeshResources(it.getElem().getString("name")); }*/ if (it.getElem().getError() != XML_OK){ throw("Class File Resource Missing Argument : "+getId()+" (name)"); } }; it.setElemName("drone>resourcecontext"); it.gotoZero(); while(it.gotoNext() != false){ string s = it.getElem().getString("path"); if (it.getElem().getError() != XML_OK){ throw("Class File Resource Content Missing Argument : "+getId()+" (path)"); } //addResourceContext(s); }; }
void Level::init(string filename){ _resetStdVar(); mViewport= NULL; //mProgressBar->draw(Core::getSingleton()->getWindow()); //File::setLoadCallback(mProgressBar); ResourceGroupManager::getSingleton().createResourceGroup("Level"); //File* lf; XML* lx; /*lf = new File(filename, "media\\levels"); if (lf->error() != FILE_OK){ throw((string)("Level file not found : "+filename)); } lx = new XML(lf->getStrContent());*/ lx = new XML(filename, "media\\levels"); string loadingSoundString; loadingSoundString = lx->getString("level","loadingsound"); if (lx->getError() == XML_OK){ mLoadingSound = SoundManager::getSingleton()->createSound(loadingSoundString+".ogg", true); mLoadingSound->play(); }else{ mLoadingSound = NULL; } mTimer = 0; /*mContainer->setSolid(false); mContainer->setType(OBJ_TYPE_CONTAINER); mContainer->build();*/ //openLevelFile(filename); //Util::Log("Loading World..."); XMLIterator XMLIt(lx); XMLIt.setElemName("level>segment"); XMLIt.gotoZero(); //LevelSegment* seg; while(XMLIt.gotoNext()==true){ XML elem = XMLIt.getElem(); addSegment( elem.getString("name"), "media\\levels", elem.getString("name").substr(0,elem.getString("name").length()-4), elem.getFloat("length"), elem.getString("append")=="1"); /*File* f; XML elem = XMLIt.getElem(); f = new File(elem.getString("name"),"levels"); Util::Log("Loading : "+elem.getString("name"), 4); if (f->error() != FILE_OK){ throw((string)("Level file not found : "+(string)filename)); }else{ XML xml; xml.setContent(f->getStrContent()); addSegment( xml, elem.getString("name").substr(0,elem.getString("name").length()-4), elem.getFloat("length")); //mCurrentSegment = new LevelSegment(); //mCurrentSegment->build(&xml, elem.getString("name").substr(0,elem.getString("name").length()-4), elem.getFloat("length")); //mSegment.push_back(mCurrentSegment); } delete f;*/ } if (mSegment.size() == 0) throw ("Your level has 0 segments."); delete lx; //delete lf; // closeLevelFile(); }