void ObjectVersionUpdateManager::updateCityTreasuryToDouble(){ info("---------------MOdifying City Treasury---------------------",true); info("Converting treasury to double for all cities ", true); ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("cityregions", true); ObjectInputStream objectData(2000); String className; ObjectDatabaseIterator iterator(database); uint64 objectID = 0; int count = 0; try { while (iterator.getNextKeyAndValue(objectID, &objectData)) { String className; try { if (!Serializable::getVariable<String>(STRING_HASHCODE("_className"), &className, &objectData)) { objectData.clear(); continue; } } catch (...) { objectData.clear(); continue; } float funds; double floatFunds = 5; if (className == "CityRegion") { count++; printf("\r\tUpdating city treasury [%d] / [?]\t", count); if ( Serializable::getVariable<float>(STRING_HASHCODE("CityRegion.cityTreasury"), &funds, &objectData)){ floatFunds = funds; ObjectOutputStream newFunds; TypeInfo<double>::toBinaryStream(&floatFunds, &newFunds ); ObjectOutputStream* test = changeVariableData(STRING_HASHCODE("CityRegion.cityTreasury"), &objectData, &newFunds); test->reset(); database->putData(objectID, test, NULL); } else { info("Error... city " + String::valueOf(objectID) + " doesn't have cityTreasury variable",true); } } objectData.clear(); } } catch (Exception& e) { error(e.getMessage()); e.printStackTrace(); } }
void XojFont::serialize(ObjectOutputStream& out) { XOJ_CHECK_TYPE(XojFont); out.writeObject("XojFont"); out.writeString(this->name); out.writeDouble(this->size); out.endObject(); }
void Element::serializeElement(ObjectOutputStream& out) { XOJ_CHECK_TYPE(Element); out.writeObject("Element"); out.writeDouble(this->x); out.writeDouble(this->y); out.writeInt(this->color); out.endObject(); }
void Text::serialize(ObjectOutputStream & out) { XOJ_CHECK_TYPE(Text); out.writeObject("Text"); serializeElement(out); out.writeString(this->text); font.serialize(out); out.endObject(); }
void Image::serialize(ObjectOutputStream & out) { XOJ_CHECK_TYPE(Image); out.writeObject("Image"); serializeElement(out); out.writeDouble(this->width); out.writeDouble(this->height); out.writeImage(this->image); out.endObject(); }
void LocationInfo::write(ObjectOutputStream& os, Pool& p) const { if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD) { os.writeNull(p); } else { unsigned char prolog[] = { 0x72, 0x00, 0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E, 0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99, 0xBB, 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02, 0x00, 0x01, 0x4C, 0x00, 0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, 0x6E, 0x66, 0x6F, 0x74, 0x00, 0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70 }; os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char*) prolog, sizeof(prolog), p); char* line = p.itoa(lineNumber); // // construct Java-like fullInfo (replace "::" with ".") // std::string fullInfo(methodName); size_t openParen = fullInfo.find('('); if (openParen != std::string::npos) { size_t space = fullInfo.find(' '); if (space != std::string::npos && space < openParen) { fullInfo.erase(0, space + 1); } } openParen = fullInfo.find('('); if (openParen != std::string::npos) { size_t classSep = fullInfo.rfind("::", openParen); if (classSep != std::string::npos) { fullInfo.replace(classSep, 2, "."); } else { fullInfo.insert(0, "."); } } fullInfo.append(1, '('); fullInfo.append(fileName); fullInfo.append(1, ':'); fullInfo.append(line); fullInfo.append(1, ')'); os.writeUTFString(fullInfo, p); } }
ObjectOutputStream* ObjectVersionUpdateManager::changeVariableData(const uint32& variableHashCode, ObjectInputStream* object, Stream* newVariableData) { int offset = getVariableDataOffset(variableHashCode, object); if (offset == -1) return NULL; ObjectOutputStream* newData = new ObjectOutputStream(object->size()); object->copy(newData); object->reset(); newData->reset(); object->shiftOffset(offset - 4); uint32 dataSize = object->readInt(); newData->shiftOffset(offset); //we go data length if (dataSize > 0) newData->removeRange(offset, offset + dataSize); newData->writeInt(offset - 4, newVariableData->size()); newData->insertStream(newVariableData, newVariableData->size(), offset); object->reset(); //newData->reset(); return newData; }
void ObjectVersionUpdateManager::setResidence(uint64 buildingID, bool isResidence){ ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("playerstructures", true); ObjectInputStream objectData(2000); bool res = isResidence; String className; ObjectOutputStream newResidenceValue; TypeInfo<bool>::toBinaryStream(&res, &newResidenceValue ); if(!database->getData(buildingID,&objectData)){ if ( Serializable::getVariable<String>(STRING_HASHCODE("_className"), &className, &objectData)){ if(className == "BuildingObject"){ if ( !Serializable::getVariable<bool>(STRING_HASHCODE("BuildingObject.isOwnerResidence"), &isResidence, &objectData)){ //info("setResidence() adding the variable",true); ObjectOutputStream* newVariableData = addVariable("BuildingObject.isOwnerResidence", &objectData, &newResidenceValue); database->putData(buildingID, newVariableData, NULL); } else { //info("setResidence() has variable and value = " + String::valueOf(isResidence) + " ... changing it",true); ObjectOutputStream* test = changeVariableData(STRING_HASHCODE("BuildingObject.isOwnerResidence"), &objectData, &newResidenceValue); test->reset(); database->putData(buildingID, test, NULL); } } } else { info("ERROR couldn't get object " + String::valueOf(buildingID),true); } } }
void EditSelection::serialize(ObjectOutputStream & out) { out.writeObject("EditSelection"); out.writeDouble(this->x); out.writeDouble(this->y); out.writeDouble(this->width); out.writeDouble(this->height); out << this->contents; out.endObject(); ListIterator<Element *> it = this->getElements(); int count = it.getLength(); out.writeInt(count); while (it.hasNext()) { Element * e = it.next(); out << e; } }
ObjectOutputStream* ObjectVersionUpdateManager::addVariable(String variableName, ObjectInputStream* object, Stream* newVariableData){ object->reset(); uint16 oldVariableCount = object->readShort(); //info("first variable count is " + String::valueOf(oldVariableCount),true); ObjectOutputStream* newData = new ObjectOutputStream(object->size()); object->copy(newData, 0); newData->writeShort(0, oldVariableCount + 1); newData->setOffset(newData->size()); uint32 _nameHashCode = variableName.hashCode(); TypeInfo<uint32>::toBinaryStream(&_nameHashCode, newData); newData->writeInt(newVariableData->size()); newData->writeStream(newVariableData); return newData; }
void EntryRemovedEvent::writeObject (ObjectOutputStream& out) const { presents::dobj::EntryEvent::writeObject(out); out.writeObject(key); }
void DObject::writeObject (ObjectOutputStream& out) const { out.writeInt(oid); }
void BoxedShort::writeObject (ObjectOutputStream& out) const { out.writeShort(value); }
void ArrayMask::writeTo (ObjectOutputStream& out) { out.writeShort((int16) _length); out.writeBytes(_mask, _length); }
void ObjectVersionUpdateManager::updateStructurePermissionLists() { ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("playerstructures", true); ObjectDatabaseIterator iterator(database); ObjectInputStream objectData(2000); uint64 objectID = 0; int count = 0; info("Setting owner on structure permission lists",true); try { while (iterator.getNextKeyAndValue(objectID, &objectData)) { String className; try { if (!Serializable::getVariable<String>(STRING_HASHCODE("_className"), &className, &objectData)) { objectData.clear(); continue; } } catch (...) { objectData.clear(); continue; } if (className == "BuildingObject" || className == "InstallationObject" || className == "GarageInstallation" || className == "ShuttleInstallation") { uint64 ownerID = 0; String ownerName; count ++; printf("\r\tUpdating structure owners [%d] / [?]\t", count); if( Serializable::getVariable<uint64>(STRING_HASHCODE("StructureObject.ownerObjectID"), &ownerID, &objectData)) { StructurePermissionList permissionList; if ( Serializable::getVariable<StructurePermissionList>(STRING_HASHCODE("StructureObject.structurePermissionList"), &permissionList, &objectData)){ ObjectOutputStream newOutputStream; permissionList.setOwner(ownerID); permissionList.toBinaryStream(&newOutputStream); ObjectOutputStream* test = changeVariableData(STRING_HASHCODE("StructureObject.structurePermissionList"), &objectData, &newOutputStream); test->reset(); database->putData(objectID, test, NULL); } else { info("ERROR unable to get structurePermissionList for structure " + String::valueOf(objectID),true); } } else { info("ERROR unable to get ownerObjectID for structure " + String::valueOf(objectID),true); } } objectData.clear(); } } catch (Exception& e) { error(e.getMessage()); e.printStackTrace(); } info("Done updating owner on structure permission lists\n",true); }
void ObjectVersionUpdateManager::updateWeaponsDots() { ObjectDatabase* database = ObjectDatabaseManager::instance()->loadObjectDatabase("sceneobjects", true); ObjectDatabaseIterator iterator(database); ObjectInputStream objectData(2000); uint64 objectID = 0; info("update database weapon dots", true); int count = 0; uint32 classNameHashCode = STRING_HASHCODE("_className"); try { while (iterator.getNextKeyAndValue(objectID, &objectData)) { String className; int oldType = 0; try { if (!Serializable::getVariable<String>(classNameHashCode, &className, &objectData) || !Serializable::getVariable<int>(STRING_HASHCODE("WeaponObject.dotType"), &oldType, &objectData)) { objectData.clear(); continue; } } catch (...) { objectData.clear(); continue; } if (className == "WeaponObject") { Vector<int> dots; ObjectOutputStream newDotsValue; TypeInfo<Vector<int> >::toBinaryStream(&dots, &newDotsValue); // info("we found a Player " + String::valueOf(objectID) + " with residence " + String::valueOf(residence),true); ObjectOutputStream* newData = changeVariableData(STRING_HASHCODE("WeaponObject.dotType"), &objectData, &newDotsValue); newData->reset(); ObjectInputStream* inputStream = new ObjectInputStream(newData->getBuffer(), newData->size()); delete newData; ObjectOutputStream* newNextData = changeVariableData(STRING_HASHCODE("WeaponObject.dotAttribute"), inputStream, &newDotsValue); newNextData->reset(); delete inputStream; inputStream = new ObjectInputStream(newNextData->getBuffer(), newNextData->size()); delete newNextData; newData = changeVariableData(STRING_HASHCODE("WeaponObject.dotStrength"), inputStream, &newDotsValue); newData->reset(); delete inputStream; inputStream = new ObjectInputStream(newData->getBuffer(), newData->size()); delete newData; newNextData = changeVariableData(STRING_HASHCODE("WeaponObject.dotDuration"), inputStream, &newDotsValue); newNextData->reset(); delete inputStream; inputStream = new ObjectInputStream(newNextData->getBuffer(), newNextData->size()); delete newNextData; newData = changeVariableData(STRING_HASHCODE("WeaponObject.dotPotency"), inputStream, &newDotsValue); newData->reset(); delete inputStream; inputStream = new ObjectInputStream(newData->getBuffer(), newData->size()); delete newData; newNextData = changeVariableData(STRING_HASHCODE("WeaponObject.dotUses"), inputStream, &newDotsValue); newNextData->reset(); delete inputStream; database->putData(objectID, newNextData, NULL); } objectData.clear(); } } catch (Exception& e) { error(e.getMessage()); e.printStackTrace(); } info("done updating databse weapon dots\n", true); }