Beispiel #1
0
void Waypoint::loadProperties(const Aurora::GFFStruct &gff) {
	// Tag

	_tag = gff.getString("Tag", _tag);

	// Map note

	_hasMapNote = gff.getBool("MapNoteEnabled", _hasMapNote);
	if (gff.hasField("MapNote")) {
		Aurora::LocString mapNote;
		gff.getLocString("MapNote", mapNote);

		_mapNote = mapNote.getString();
	}
}
Beispiel #2
0
GTEST_TEST_F(LocString, wrongEncodingNonUTF8) {
	if (!Common::hasSupportEncoding(Common::kEncodingCP1252)) {
		const ::testing::TestInfo* const testInfo = ::testing::UnitTest::GetInstance()->current_test_info();

		std::fprintf(stderr, "Skipping %s.%s\n", testInfo->test_case_name(),  testInfo->name());
		return;
	}

	static const byte kData[] = { 0x04, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81 };
	Common::MemoryReadStream stream(kData);

	Aurora::LocString locString;
	locString.readString(2, stream);

	EXPECT_STREQ(locString.getString().c_str(), "[!?!]");
}
Beispiel #3
0
GTEST_TEST_F(LocString, readLocStringSetGender) {
	static const byte kData[] = { 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
	                              0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00,
	                              0x46, 0xC3, 0xB6, 0xC3, 0xB6, 0x62, 0xC3, 0xA4,
	                              0x72, 0x30, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x00,
	                              0x00, 0x00, 0x46, 0xC3, 0xB6, 0xC3, 0xB6, 0x62,
	                              0xC3, 0xA4, 0x72, 0x31 };
	Common::MemoryReadStream stream(kData);

	Aurora::LocString locString;
	locString.readLocString(stream);

	LangMan.setCurrentLanguage(Aurora::kLanguageEnglish);

	LangMan.setCurrentGender(Aurora::kLanguageGenderMale);
	EXPECT_STREQ(locString.getString().c_str(), kUTF8String0);

	LangMan.setCurrentGender(Aurora::kLanguageGenderFemale);
	EXPECT_STREQ(locString.getString().c_str(), kUTF8String1);
}
Beispiel #4
0
void Situated::loadProperties(const Aurora::GFFStruct &gff) {
	// Tag
	_tag = gff.getString("Tag", _tag);

	// Name
	if (gff.hasField("LocName")) {
		Aurora::LocString name;
		gff.getLocString("LocName", name);

		_name = name.getString();
	}

	// Description
	if (gff.hasField("Description")) {
		Aurora::LocString description;
		gff.getLocString("Description", description);

		_description = description.getString();
	}

	// Portrait
	loadPortrait(gff);

	// Appearance
	_appearanceID = gff.getUint("Appearance", _appearanceID);

	// Conversation
	_conversation = gff.getString("Conversation", _conversation);

	// Static
	_static = gff.getBool("Static", _static);

	// Usable
	_usable = gff.getBool("Useable", _usable);

	// Locked
	_locked = gff.getBool("Locked", _locked);

	// Scripts
	readScripts(gff);
}
Beispiel #5
0
void Creature::loadProperties(const Aurora::GFF3Struct &gff) {
	// Tag
	_tag = gff.getString("Tag", _tag);

	// Name

	Aurora::LocString firstName;
	gff.getLocString("FirstName", firstName);
	Aurora::LocString lastName;
	gff.getLocString("LastName", lastName);

	if (!firstName.empty()) {
		_name = firstName.getString();
		if (!lastName.empty())
			_name += " " + lastName.getString();
	}


	// Description
	_description = gff.getString("Description", _description);

	// Portrait
	loadPortrait(gff);

	// Equipment
	loadEquipment(gff);

	// Appearance
	_appearance = gff.getUint("Appearance_Type", _appearance);

	// Static
	_static = gff.getBool("Static", _static);

	// Usable
	_usable = gff.getBool("Useable", _usable);

	// PC
	_isPC = gff.getBool("IsPC", _isPC);

	// Gender
	_gender = Gender(gff.getUint("Gender"));

	// Race
	_race = Race(gff.getSint("Race", _race));
	_subRace = SubRace(gff.getSint("SubraceIndex", _subRace));

	// Hit Points
	_currentHitPoints = gff.getSint("CurrentHitPoints", _maxHitPoints);
	_maxHitPoints = gff.getSint("MaxHitPoints", _currentHitPoints);

	_minOneHitPoint = gff.getBool("Min1HP", _minOneHitPoint);

	// Faction
	_faction = Faction(gff.getUint("FactionID"));

	// Scripts
	readScripts(gff);

	_conversation = gff.getString("Conversation", _conversation);
}
Beispiel #6
0
void Item::loadProperties(const Aurora::GFF3Struct &gff) {
	// Tag
	_tag = gff.getString("Tag", _tag);

	// Name
	if (gff.hasField("LocalizedName")) {
		Aurora::LocString name;
		gff.getLocString("LocalizedName", name);

		_name = name.getString();
	}

	// Description
	if (gff.hasField("Description")) {
		Aurora::LocString description;
		gff.getLocString("Description", description);

		_description = description.getString();
	}

	// This is an index into basitem.2da which contains inventory slot info
	_baseitem = gff.getUint("BaseItem", _baseitem);

	// TODO: Are these armor only?
	_colorMetal1 = gff.getUint("Metal1Color", _colorMetal1);
	_colorMetal2  = gff.getUint("Metal2Color", _colorMetal2);
	_colorLeather1 = gff.getUint("Leather1Color", _colorLeather1);
	_colorLeather2 = gff.getUint("Leather2Color", _colorLeather2);
	_colorCloth1 = gff.getUint("Cloth1Color", _colorCloth1);
	_colorCloth2 = gff.getUint("Cloth2Color", _colorCloth2);

	// Armor parts
	loadArmorParts(gff);

	// Portrait
	loadPortrait(gff);

	// Scripts
	readScripts(gff);
}
Beispiel #7
0
GTEST_TEST_F(LocString, write) {
	Aurora::LocString locString;
	locString.setString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderMale, "String to test");
	locString.setString(Aurora::kLanguageFrench, Aurora::kLanguageGenderMale, "String pour tester");

	Common::MemoryWriteStreamDynamic *writeStream = new Common::MemoryWriteStreamDynamic(true);
	locString.writeLocString(*writeStream);

	Aurora::LocString locString2;
	Common::MemoryReadStream readStream(writeStream->getData(), writeStream->size());
	EXPECT_EQ(readStream.readUint32LE(), 0);
	EXPECT_EQ(readStream.readUint32LE(), 14);
	Common::UString englishString = Common::readStringFixed(readStream, Common::kEncodingASCII, 14);
	EXPECT_STREQ(englishString.c_str(), "String to test");

	EXPECT_EQ(readStream.readUint32LE(), 2);
	EXPECT_EQ(readStream.readUint32LE(), 18);
	Common::UString frenchString = Common::readStringFixed(readStream, Common::kEncodingASCII, 18);
	EXPECT_STREQ(frenchString.c_str(), "String pour tester");

	delete writeStream;
}
Beispiel #8
0
GTEST_TEST_F(LocString, setStringGender) {
	Aurora::LocString locString;

	locString.setString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderFemale, kUTF8String);

	EXPECT_FALSE(locString.hasString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderMale  ));
	EXPECT_TRUE(locString.hasString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderFemale));

	EXPECT_STREQ(locString.getString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderMale  ).c_str(),
	             "");
	EXPECT_STREQ(locString.getString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderFemale).c_str(),
	             kUTF8String);

	EXPECT_STREQ(locString.getFirstString().c_str(), kUTF8String);

	EXPECT_STREQ(locString.getString().c_str(), kUTF8String);
}
Beispiel #9
0
void GFF3Dumper::dumpLocString(const Aurora::LocString &locString) {
	std::vector<Aurora::LocString::SubLocString> str;
	locString.getStrings(str);

	if (!str.empty())
		_xml->breakLine();

	for (std::vector<Aurora::LocString::SubLocString>::iterator s = str.begin(); s != str.end(); ++s) {
		_xml->openTag("string");
		_xml->addProperty("language", Common::composeString(s->language));

		_xml->setContents(s->str);
		_xml->closeTag();
		_xml->breakLine();
	}
}
Beispiel #10
0
GTEST_TEST_F(LocString, readString) {
	static const byte kData[] = { 0x09, 0x00, 0x00, 0x00, 0x46, 0xC3, 0xB6, 0xC3,
	                              0xB6, 0x62, 0xC3, 0xA4, 0x72 };
	Common::MemoryReadStream stream(kData);

	Aurora::LocString locString;
	locString.readString(1, stream);

	EXPECT_FALSE(locString.hasString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderMale  ));
	EXPECT_TRUE (locString.hasString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderFemale));

	EXPECT_STREQ(locString.getString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderMale  ).c_str(),
	             "");
	EXPECT_STREQ(locString.getString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderFemale).c_str(),
	             kUTF8String);

	EXPECT_STREQ(locString.getFirstString().c_str(), kUTF8String);

	EXPECT_STREQ(locString.getString().c_str(), kUTF8String);
}
Beispiel #11
0
GTEST_TEST_F(LocString, getStrRefString) {
	const Aurora::LocString locString;

	EXPECT_STREQ(locString.getStrRefString().c_str(), "");
}
Beispiel #12
0
GTEST_TEST_F(LocString, empty) {
	const Aurora::LocString locString;

	EXPECT_TRUE(locString.empty());
}
Beispiel #13
0
void GFF3Dumper::dumpField(const Aurora::GFF3Struct &strct, const Common::UString &field) {
	Aurora::GFF3Struct::FieldType type = strct.getType(field);

	Common::UString typeName;
	if (((size_t) type) < ARRAYSIZE(kGFF3FieldTypeNames))
		typeName = kGFF3FieldTypeNames[(int)type];
	else
		typeName = "filetype" + Common::composeString((uint64) type);

	Common::UString label = field;

	// Structs already open their own tag
	if (type != Aurora::GFF3Struct::kFieldTypeStruct) {
		_xml->openTag(typeName);
		_xml->addProperty("label", label);
	}

	switch (type) {
		case Aurora::GFF3Struct::kFieldTypeChar:
			_xml->setContents(Common::composeString(strct.getUint(field)));
			break;

		case Aurora::GFF3Struct::kFieldTypeByte:
		case Aurora::GFF3Struct::kFieldTypeUint16:
		case Aurora::GFF3Struct::kFieldTypeUint32:
		case Aurora::GFF3Struct::kFieldTypeUint64:
			_xml->setContents(Common::composeString(strct.getUint(field)));
			break;

		case Aurora::GFF3Struct::kFieldTypeSint16:
		case Aurora::GFF3Struct::kFieldTypeSint32:
		case Aurora::GFF3Struct::kFieldTypeSint64:
			_xml->setContents(Common::composeString(strct.getSint(field)));
			break;

		case Aurora::GFF3Struct::kFieldTypeFloat:
		case Aurora::GFF3Struct::kFieldTypeDouble:
			_xml->setContents(Common::UString::format("%.6f", strct.getDouble(field)));
			break;

		case Aurora::GFF3Struct::kFieldTypeStrRef:
			_xml->setContents(strct.getString(field));
			break;

		case Aurora::GFF3Struct::kFieldTypeExoString:
		case Aurora::GFF3Struct::kFieldTypeResRef:
			try {
				_xml->setContents(strct.getString(field));
			} catch (...) {
				_xml->addProperty("base64", "true");

				Common::SeekableReadStream *data = strct.getData(field);
				_xml->setContents(*data);
				delete data;
			}
			break;

		case Aurora::GFF3Struct::kFieldTypeLocString:
			{
				Aurora::LocString locString;

				strct.getLocString(field, locString);
				_xml->addProperty("strref", Common::composeString(locString.getID()));

				dumpLocString(locString);
			}
			break;

		case Aurora::GFF3Struct::kFieldTypeVoid:
			_xml->setContents(*strct.getData(field));
			break;

		case Aurora::GFF3Struct::kFieldTypeStruct:
			dumpStruct(strct.getStruct(field), label);
			break;

		case Aurora::GFF3Struct::kFieldTypeList:
			dumpList(strct.getList(field));
			break;

		case Aurora::GFF3Struct::kFieldTypeOrientation:
			{
				double a = 0.0, b = 0.0, c = 0.0, d = 0.0;

				strct.getOrientation(field, a, b, c, d);

				_xml->breakLine();

				_xml->openTag("double");
				_xml->setContents(Common::UString::format("%.6f", a));
				_xml->closeTag();
				_xml->breakLine();

				_xml->openTag("double");
				_xml->setContents(Common::UString::format("%.6f", b));
				_xml->closeTag();
				_xml->breakLine();

				_xml->openTag("double");
				_xml->setContents(Common::UString::format("%.6f", c));
				_xml->closeTag();
				_xml->breakLine();

				_xml->openTag("double");
				_xml->setContents(Common::UString::format("%.6f", d));
				_xml->closeTag();
				_xml->breakLine();
			}
			break;

		case Aurora::GFF3Struct::kFieldTypeVector:
			{
				double x = 0.0, y = 0.0, z = 0.0;

				strct.getVector(field, x, y, z);

				_xml->breakLine();

				_xml->openTag("double");
				_xml->setContents(Common::UString::format("%.6f", x));
				_xml->closeTag();
				_xml->breakLine();

				_xml->openTag("double");
				_xml->setContents(Common::UString::format("%.6f", y));
				_xml->closeTag();
				_xml->breakLine();

				_xml->openTag("double");
				_xml->setContents(Common::UString::format("%.6f", z));
				_xml->closeTag();
				_xml->breakLine();
			}
			break;

		default:
			break;
	}

	// Structs already close their own tag
	if (type != Aurora::GFF3Struct::kFieldTypeStruct) {
		_xml->closeTag();
		_xml->breakLine();
	}
}