Exemplo n.º 1
0
	void SetUp() {
		// Perform setup of common constructs here.
		lootGroupMap->initialize();

		ASSERT_TRUE( templateManager != NULL );
		if( templateManager->loadedTemplatesCount == 0 ) {
			templateManager->loadLuaTemplates();
		}

		commandConfigManager->registerSpecialCommands(list);
		commandConfigManager->loadSlashCommandsFile();

		Vector<String> files;
		files.add("string/en/mob/creature_names.stf");
		files.add("string/en/npc_name.stf");
		files.add("string/en/monster_name.stf");
		files.add("string/en/droid_name.stf");
		files.add("string/en/npc_spawner_n.stf");
		files.add("string/en/theme_park_name.stf");
		files.add("string/en/event_perk.stf");
		files.add("string/en/bestine.stf");
		files.add("string/en/theme_park/warren/warren_system_messages.stf");
		files.add("string/en/newbie_tutorial/system_messages.stf");
		files.add("string/en/chassis_npc.stf");

		int count = 0;

		for (int i = 0; i < files.size(); i++) {
			String file = files.get(i);
			ObjectInputStream* stream = templateManager->openTreFile(file);

			if (stream != NULL) {

				if (stream->size() > 4) {
					StringFile stringFile;
					if (stringFile.load(stream)) {
						file = file.replaceFirst("string/en/","");
						file = file.replaceFirst(".stf","");

						HashTable<String, UnicodeString>* hashTable = stringFile.getStringMap();

						HashTableIterator<String, UnicodeString> iterator = hashTable->iterator();

						while (iterator.hasNext()) {
							String name;
							UnicodeString value;

							iterator.getNextKeyAndValue(name, value);

							String full = "@" + file + ":" + name;

							mobNames.add(full);
							count++;
						}
					}

				}

				delete stream;

			}

		}

		ASSERT_TRUE( count > 0 ) << "Could not load creature names.";
	}
Exemplo n.º 2
0
void StringIdManager::populateDatabase() {
	int count = 0;

	TemplateManager::instance();
	TreeArchive* treeArchive = DataArchiveStore::instance()->getTreeArchive();

	Vector<String>* files = treeArchive->getFilesAndSubDirectoryFiles("string/en");

	if (files == NULL) {
		error("string/en directory missing");

		ObjectDatabaseManager::instance()->commitLocalTransaction();
		return;
	}

	for (int i = 0; i < files->size(); ++i) {
		String file = files->get(i);

		ObjectInputStream* stream = TemplateManager::instance()->openTreFile(files->get(i));

		if (stream == NULL) {
			//error("could not open file " + files->get(i));

			continue;
		} else {
			if (stream->size() > 4) {
				//info("opening " + files->get(i), true);

				StringFile stringFile;
				if (!stringFile.load(stream)) {
					delete stream;

					error("could not parse " + files->get(i));
					continue;
				}

				file = file.replaceFirst("string/en/","");
				file = file.replaceFirst(".stf","");

				HashTable<String, UnicodeString>* hashTable = stringFile.getStringMap();

				HashTableIterator<String, UnicodeString> iterator = hashTable->iterator();

				while (iterator.hasNext()) {
					String name;
					UnicodeString value;

					iterator.getNextKeyAndValue(name, value);

					String full = "@" + file + ":" + name;

					//info("key = " + full + " value = " + value.toString(), true);

					ObjectOutputStream* data = new ObjectOutputStream();
					value.toBinaryStream(data);

					uint64 longKey = (uint64)full.hashCode();

					ObjectOutputStream* key = new ObjectOutputStream();
					TypeInfo<uint64>::toBinaryStream(&longKey, key);

					stringsDatabase->putData(key, data);
					++count;
				}

			}

			delete stream;
		}
	}

	delete files;

	info("writing to the db " + String::valueOf(count) + " strings", true);
}