Beispiel #1
0
void EditSelection::readSerialized(ObjectInputStream & in) throw (InputStreamException) {
	in.readObject("EditSelection");
	this->x = in.readDouble();
	this->y = in.readDouble();
	this->width = in.readDouble();
	this->height = in.readDouble();

	in >> this->contents;

	in.endObject();
}
Beispiel #2
0
void XojFont::readSerialized(ObjectInputStream& in) throw (
    InputStreamException)
{
	XOJ_CHECK_TYPE(XojFont);

	in.readObject("XojFont");

	this->name = in.readString();
	this->size = in.readDouble();

	in.endObject();
}
void Element::readSerializedElement(ObjectInputStream& in) throw (InputStreamException)
{
	XOJ_CHECK_TYPE(Element);

	in.readObject("Element");

	this->x = in.readDouble();
	this->y = in.readDouble();
	this->color = in.readInt();

	in.endObject();
}
Beispiel #4
0
void Text::readSerialized(ObjectInputStream & in) throw (InputStreamException) {
	XOJ_CHECK_TYPE(Text);

	in.readObject("Text");

	readSerializedElement(in);

	this->text = in.readString();

	font.readSerialized(in);

	in.endObject();
}
Beispiel #5
0
SceneObject* ObjectManager::cloneObject(SceneObject* object, bool makeTransient) {
	ObjectOutputStream objectData(500);

	(cast<ManagedObject*>(object))->writeObject(&objectData);
	objectData.reset();

	ObjectInputStream objectInput;
	objectData.copy(&objectInput, 0);
	objectInput.reset();

	uint32 serverCRC = object->getServerObjectCRC();

	SceneObject* clonedObject = NULL;

	ObjectDatabase* database = getTable(object->getObjectID());
	String databaseName;
	uint64 oid;

	if (database != NULL) {
		database->getDatabaseName(databaseName);

		oid = getNextObjectID(databaseName);
	} else
		oid = getNextFreeObjectID();


	clonedObject = instantiateSceneObject(serverCRC, oid, false);

	if (makeTransient || !object->isPersistent()) {
		//clonedObject = createObject(serverCRC, 0, databaseName);
		clonedObject->setPersistent(0);
	} else if (object->isPersistent()) {
		//clonedObject = createObject(serverCRC, object->getPersistenceLevel(), databaseName);
		clonedObject->setPersistent(object->getPersistenceLevel());
	}

	Locker locker(clonedObject);

	clonedObject->readObject(&objectInput);
	clonedObject->createComponents();
	clonedObject->setParent(NULL);

	if (clonedObject->isPersistent())
		updatePersistentObject(clonedObject);

	return clonedObject;
}
void ChatManagerImplementation::loadMailDatabase() {
	info("Checking mail for expiration...", true);

	ObjectDatabase* playerMailDatabase = ObjectDatabaseManager::instance()->loadObjectDatabase("mail", true);

	if (playerMailDatabase == NULL) {
		error("Could not load the player mail database.");
		return;
	}

	int i = 0;

	try {
		ObjectDatabaseIterator iterator(playerMailDatabase);

		uint64 objectID;
		uint32 timeStamp, currentTime = System::getTime();
		ObjectInputStream* objectData = new ObjectInputStream(2000);

		while (i < 25000 && iterator.getNextKeyAndValue(objectID, objectData)) {
			if (!Serializable::getVariable<uint32>(STRING_HASHCODE("PersistentMessage.timeStamp"), &timeStamp, objectData)) {
				objectData->clear();
				continue;
			}

			if (currentTime - timeStamp > PM_LIFESPAN) {
				Reference<PersistentMessage*> mail = Core::getObjectBroker()->lookUp(objectID).castTo<PersistentMessage*>();

				if (mail != NULL) {
					i++;

					ObjectManager::instance()->destroyObjectFromDatabase(objectID);
				}
			}

			objectData->clear();
		}

		delete objectData;
	} catch (DatabaseException& e) {
		error("Database exception in ChatManager::loadMailDatabase(): " + e.getMessage());
	}

	info("Deleted " + String::valueOf(i) + " mails due to expiration.", true);
}
Beispiel #7
0
void Image::readSerialized(ObjectInputStream & in) throw (InputStreamException) {
	XOJ_CHECK_TYPE(Image);

	in.readObject("Image");

	readSerializedElement(in);

	this->width = in.readDouble();
	this->height = in.readDouble();

	if (this->image) {
		cairo_surface_destroy(this->image);
		this->image = NULL;
	}

	this->image = in.readImage();

	in.endObject();
}
Beispiel #8
0
void TexImage::readSerialized(ObjectInputStream & in) throw (InputStreamException) {
	XOJ_CHECK_TYPE(TexImage);

	in.readObject("TexImage");

	readSerializedElement(in);

	this->width = in.readDouble();
	this->height = in.readDouble();
	String tmp = in.readString();
	//cast this
	char * tmpcstring = new char[tmp.size()];
	strcpy(tmpcstring,tmp.c_str());
	this->text = tmpcstring;

	if (this->image) {
		cairo_surface_destroy(this->image);
		this->image = NULL;
	}

	this->image = in.readImage();

	in.endObject();
}
Beispiel #9
0
void EntryRemovedEvent::readObject (ObjectInputStream& in)
{
    presents::dobj::EntryEvent::readObject(in);
    key = boost::static_pointer_cast<Streamable>(in.readObject());
}
Beispiel #10
0
void StructureManager::loadPlayerStructures(const String& zoneName) {

	info("Loading player structures from playerstructures.db");

	ObjectDatabaseManager* dbManager = ObjectDatabaseManager::instance();
	ObjectDatabase* playerStructuresDatabase =
			ObjectDatabaseManager::instance()->loadObjectDatabase(
					"playerstructures", true);

	if (playerStructuresDatabase == NULL) {
		error("Could not load the player structures database.");
		return;
	}

	int i = 0;

	try {
		ObjectDatabaseIterator iterator(playerStructuresDatabase);

		uint64 objectID;
		ObjectInputStream* objectData = new ObjectInputStream(2000);

		String zoneReference;

		while (iterator.getNextKeyAndValue(objectID, objectData)) {
			if (!Serializable::getVariable<String>(String("SceneObject.zone").hashCode(),
					&zoneReference, objectData)) {
				objectData->clear();
				continue;
			}

			if (zoneName != zoneReference) {
				objectData->clear();
				continue;
			}

			Reference<SceneObject*> object = server->getObject(objectID);

			if (object != NULL) {
				++i;

				if(object->isGCWBase()){
					Zone* zone = object->getZone();

					if(zone == NULL)
						return;

					GCWManager* gcwMan = zone->getGCWManager();
					if(gcwMan == NULL)
						return;

					gcwMan->registerGCWBase(cast<BuildingObject*>(object.get()),false);

				}

				if (ConfigManager::instance()->isProgressMonitorActivated())
					printf("\r\tLoading player structures [%d] / [?]\t", i);
			} else {
				error(
						"Failed to deserialize structure with objectID: "
								+ String::valueOf(objectID));
			}

			objectData->clear();
		}

		delete objectData;
	} catch (DatabaseException& e) {
		error(
				"Database exception in StructureManager::loadPlayerStructures(): "
						+ e.getMessage());
	}

	info(String::valueOf(i) + " player structures loaded for " + zoneName + ".",
			true);

}
Beispiel #11
0
void DObject::readObject (ObjectInputStream& in)
{
    oid = int32(in.readInt());
}
Beispiel #12
0
void BoxedShort::readObject (ObjectInputStream& in)
{
    value = in.readShort();
}
Beispiel #13
0
ArrayMask::ArrayMask (ObjectInputStream& in)
{
    _length = in.readShort();
    _mask = new uint8[_length];
    in.readBytes(_mask, _length);
}
Beispiel #14
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.";
	}
Beispiel #15
0
SceneObject* ObjectManager::cloneObject(SceneObject* object, bool makeTransient) {
	
	ObjectOutputStream objectData(500);

	(cast<ManagedObject*>(object))->writeObject(&objectData);
	objectData.reset();

	ObjectInputStream objectInput;
	objectData.copy(&objectInput, 0);
	objectInput.reset();

	uint32 serverCRC = object->getServerObjectCRC();

	SceneObject* clonedObject = NULL;

	ObjectDatabase* database = getTable(object->getObjectID());
	String databaseName;
	uint64 oid;

	if (database != NULL) {
		database->getDatabaseName(databaseName);

		oid = getNextObjectID(databaseName);
	} else
		oid = getNextFreeObjectID();


	clonedObject = instantiateSceneObject(serverCRC, oid, false);

	if (makeTransient || !object->isPersistent()) {
		//clonedObject = createObject(serverCRC, 0, databaseName);
		clonedObject->setPersistent(0);
	} else if (object->isPersistent()) {
		//clonedObject = createObject(serverCRC, object->getPersistenceLevel(), databaseName);
		clonedObject->setPersistent(object->getPersistenceLevel());
	}

	Locker locker(clonedObject);

	clonedObject->readObject(&objectInput);
	clonedObject->createComponents();
	clonedObject->setParent(NULL);
    
	VectorMap<String, ManagedReference<SceneObject*> > slottedObjects;
	clonedObject->getSlottedObjects(slottedObjects);
    
	for (int i=slottedObjects.size()-1; i>=0; i--) {
		String key = slottedObjects.elementAt(i).getKey();
        
		Reference<SceneObject*> obj = slottedObjects.elementAt(i).getValue();
        
		clonedObject->removeSlottedObject(i);
        
		Reference<SceneObject*> clonedChild = cloneObject(obj, makeTransient);
		clonedChild->setParent(object);
        
		slottedObjects.put(key, clonedChild);
        
	}
	
	VectorMap<uint64, ManagedReference<SceneObject*> > objects;
	clonedObject->getContainerObjects(objects);
	
	for (int i=objects.size()-1; i>=0; i--) {
		uint64 key = objects.elementAt(i).getKey();
		
		Reference<SceneObject*> obj = objects.elementAt(i).getValue();
		
		objects.remove(i);
		
		Reference<SceneObject*> clonedChild = cloneObject(obj, makeTransient);
		clonedChild->setParent(object);
		
		objects.put(key, clonedChild);
	}
	
	clonedObject->onCloneObject(object);

	if (clonedObject->isPersistent())
		updatePersistentObject(clonedObject);

	return clonedObject;
}
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);
}