Esempio n. 1
0
bool ItemProperty::getIsItemPropertyValid() const {
	// Load the item properties row
	const Aurora::TwoDAFile &twoDA = TwoDAReg.get2DA("itempropdef");
	const size_t count = twoDA.getRowCount();
	if (_type >= count)
		return false;

	// Check the item type
	const Aurora::TwoDARow &row = twoDA.getRow(_type);
	Common::UString name = row.getString("Name");
	if (name.empty() || name.equalsIgnoreCase("padding"))
		return false;

	// Check the subtype
	Common::UString subTypeResRef = row.getString("SubTypeResRef");
	if (!subTypeResRef.empty()) {
		const Aurora::TwoDAFile &twoDAsubType = TwoDAReg.get2DA(subTypeResRef);
		const size_t subTypeCount = twoDAsubType.getRowCount();
		if (_subtype >= subTypeCount)
			return false;

		// "Name" column seems common to these tables
		const Aurora::TwoDARow &rowSubType = twoDA.getRow(_subtype);
		Common::UString nameSubTyle = rowSubType.getString("Name");
		if (name.empty())
			return false;
	}

	// TODO: Check the param1 data and price tables
	return true;
}
Esempio n. 2
0
static bool setOption(Common::UString &key, const Common::UString &value) {
	if (key.equalsIgnoreCase("config")) {
		ConfigMan.setConfigFile(value);
		if (!ConfigMan.load()) {
			if (!ConfigMan.fileExists())
				warning("No such config file \"%s\"", value.c_str());
			return false;
		}

		key.clear();
		return true;
	}

	ConfigMan.setCommandlineKey(key, value);
	key.clear();
	return true;
}
Esempio n. 3
0
void Creature::loadModel() {
	if (_model)
		return;

	if (_appearanceID == Aurora::kFieldIDInvalid) {
		warning("Creature \"%s\" has no appearance", _tag.c_str());
		return;
	}

	const Aurora::TwoDARow &appearance = TwoDAReg.get2DA("appearance").getRow(_appearanceID);

	if (_portrait.empty())
		_portrait = appearance.getString("PORTRAIT");

	_environmentMap = appearance.getString("ENVMAP");

	if (appearance.getString("MODELTYPE") == "P") {
		getArmorModels();
		getPartModels();
		_model = loadModelObject(_partsSuperModelName);

		for (size_t i = 0; i < kBodyPartMAX; i++) {
			if (_bodyParts[i].modelName.empty())
				continue;

			TextureMan.startRecordNewTextures();

			// Try to load in the corresponding part model
			Graphics::Aurora::Model *partModel = loadModelObject(_bodyParts[i].modelName, _bodyParts[i].textureName);
			if (!partModel)
				continue;

			// Add the loaded model to the appropriate part node
			Graphics::Aurora::ModelNode *partNode = _model->getNode(kBodyPartNodes[i]);
			if (partNode)
				partNode->addChild(partModel);

			std::list<Common::UString> newTextures;
			TextureMan.stopRecordNewTextures(newTextures);

			for (std::list<Common::UString>::const_iterator t = newTextures.begin(); t != newTextures.end(); ++t) {
				Graphics::Aurora::TextureHandle texture = TextureMan.getIfExist(*t);
				if (texture.empty())
					continue;

				_bodyParts[i].textures.push_back(texture);
			}

			finishPLTs(_bodyParts[i].textures);
		}

	} else
		_model = loadModelObject(appearance.getString("RACE"));

	// Positioning

	float x, y, z, angle;

	getPosition(x, y, z);
	setPosition(x, y, z);

	getOrientation(x, y, z, angle);
	setOrientation(x, y, z, angle);

	// Clickable

	if (_model) {
		_model->setTag(_tag);
		_model->setClickable(isClickable());

		_ids.push_back(_model->getID());

		if (!_environmentMap.empty()) {
			Common::UString environmentMap = _environmentMap;
			if (environmentMap.equalsIgnoreCase("default"))
				environmentMap = _area ? _area->getEnvironmentMap() : "";

			_model->setEnvironmentMap(environmentMap);
		}
	}
}