Exemplo n.º 1
0
bool IOMapSerialize::saveMapRelational(Map*)
{
	Database* db = Database::getInstance();
	//Start the transaction
	DBTransaction trans(db);
	if(!trans.begin())
		return false;

	//clear old tile data
	DBQuery query;
	query << "DELETE FROM `tile_items` WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
	if(!db->executeQuery(query.str()))
		return false;

	query.str("");
	query << "DELETE FROM `tiles` WHERE `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID);
	if(!db->executeQuery(query.str()))
		return false;

	uint32_t tileId = 0;
	for(HouseMap::iterator it = Houses::getInstance()->getHouseBegin(); it != Houses::getInstance()->getHouseEnd(); ++it)
	{
		//save house items
		for(HouseTileList::iterator tit = it->second->getHouseTileBegin(); tit != it->second->getHouseTileEnd(); ++tit)
			saveItems(db, tileId, it->second->getId(), (*tit));
	}

	//End the transaction
	return trans.commit();
}
Exemplo n.º 2
0
bool Ingridients::saveData(QString& fileName) {
    QJsonObject saveObj;
    QFile saveFile(fileName);

    PRINT_DEBUG("Saving all ingridients");

    if ( !saveFile.open(QIODevice::WriteOnly) ) {
        PRINT_WARN("Couldn't open save file.");

        return false;
    }

    saveItems(saveObj);
    saveFood(saveObj);
    saveDish(saveObj);

    QJsonDocument saveDoc(saveObj);

    if ( !fileName.right(5).compare(".json") ) {
        saveFile.write(saveDoc.toJson());
    } else {
        saveFile.write(saveDoc.toBinaryData());
    }

    return true;
}
Exemplo n.º 3
0
bool IOMapSerialize::saveHouseRelational(Database* db, House* house, uint32_t& tileId)
{
	for(HouseTileList::iterator tit = house->getHouseTileBegin(); tit != house->getHouseTileEnd(); ++tit)
		saveItems(db, tileId, house->getId(), (*tit));

	return true;
}
Exemplo n.º 4
0
void addItem(LinkedList<Item> *listOfItems)
{
	clearScreen();
	displayLogo();

	Item item;
	Location location;
	Source source;
	Seller seller;
	Address sellerAddress;
	int serialNumber;
	double price;
	string name, type, club = "SGA", sellerName, building, room, shelfSlot, sellerURL, junk;
	bool status = true;

	cout << "Enter the serial number of the new item: ";
	cin >> serialNumber;
	getline(cin, junk);
	cout << "What is the name of the item you wish to add? ";
	getline(cin, name);
	cout << "What is the type of the item you wish to add? ";
	getline(cin, type);
	cout << "Where was the item bought? ";
	getline(cin, sellerName);
	cout << "What is the URL of the store? ";
	getline(cin, sellerURL);
	cout << "What is the price of the item you wish to add? ";
	cin >> price;
	getline(cin, junk);
	cout << "What building is the item being stored in? ";
	getline(cin, building);
	cout << "What room is the item being stored in? ";
	getline(cin, room);
	cout << "What shelf slot is the item being stored in? ";
	getline(cin, shelfSlot);

	location.setBuilding(building);
	location.setRoom(room);
	location.setCode(shelfSlot);  // Sets the information for location

	seller.setName(sellerName);
	seller.setAddress(sellerAddress);
	seller.setURL(sellerURL);     // Sets the information for seller

	source.setSeller(seller);
	source.setUnitPrice(price);   // Sets the information for Source

	item.setSerial(serialNumber);
	item.setName(name);
	item.setNameType(type);
	item.setLocation(location);
	item.setSource(source);
	item.setStatus(status);    //Sets all the Data for tmp

	listOfItems->append(item);  //Adds new item to the end of the list

	saveItems(listOfItems);
	//itemsOutput(serialNumber, name, type, club, sellerName, price, building, room, shelfSlot, status);  // File Output
}
Exemplo n.º 5
0
void removeItem(LinkedList<Item> *listOfItems)
{
	int serialNumber;

	//The user is prompted for the serial number of the item that they want removed
	cout << "Please enter the serial no. of the item to remove:\n\n";
	cin >> serialNumber;

	removeByItem_Serial(listOfItems, serialNumber); //This function passes the list of items and serial no. of the item to be removed
	saveItems(listOfItems);
}
Exemplo n.º 6
0
ToolManager::~ToolManager()
{
	unloadJSEngine(true);

	safe_delete(m_pToolThread);

	m_MapLock.lock();
	safe_delete(m_mTransactions);
	m_MapLock.unlock();

	saveItems();
}
Exemplo n.º 7
0
void ToolManager::onToolDLComplete(DesuraId id)
{
	eraseDownload(id);

	{
		::Thread::AutoLock al(&m_MapLock);
		for_each([id](Misc::ToolTransInfo* info){
			info->onDLComplete(id);
		});
	}

	saveItems();
}
Exemplo n.º 8
0
/** Initializes the view of this widget. */
void CSearchResultView::initView() {
    setToolTip(tr("Search result of the selected work"));
    setHeaderLabel(tr("Results"));
    setDragEnabled(true);
    setRootIsDecorated( false );
    setSelectionMode(QAbstractItemView::ExtendedSelection);

    //setup the popup menu
    m_popup = new QMenu(this);

    m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
    m_actions.copyMenu->setIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon());

    m_actions.copy.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.copy.result, SIGNAL(triggered()),
               this,                  SLOT(copyItems()));
    m_actions.copyMenu->addAction(m_actions.copy.result);

    m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.copy.resultWithText, SIGNAL(triggered()),
               this,                          SLOT(copyItemsWithText()));
    m_actions.copyMenu->addAction(m_actions.copy.resultWithText);

    m_popup->addMenu(m_actions.copyMenu);

    m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
    m_actions.saveMenu->setIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon());

    m_actions.save.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.save.result, SIGNAL(triggered()),
               this,                  SLOT(saveItems()) );
    m_actions.saveMenu->addAction(m_actions.save.result);

    m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
    m_actions.saveMenu->addAction(m_actions.save.resultWithText);
    BT_CONNECT(m_actions.save.resultWithText, SIGNAL(triggered()),
               this,                          SLOT(saveItemsWithText()));
    m_popup->addMenu(m_actions.saveMenu);

    m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
    m_actions.printMenu->setIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon());

    m_actions.print.result = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.print.result, SIGNAL(triggered()),
               this,                   SLOT(printItems()));
    m_actions.printMenu->addAction(m_actions.print.result);
    m_popup->addMenu(m_actions.printMenu);
}
Exemplo n.º 9
0
ClipboardBrowser::ClipboardBrowser(QWidget *parent, const ClipboardBrowserSharedPtr &sharedData)
    : QListView(parent)
    , m_itemLoader()
    , m_tabName()
    , m_lastFiltered(-1)
    , m(this)
    , d(this)
    , m_invalidateCache(false)
    , m_expireAfterEditing(false)
    , m_editor(NULL)
    , m_sharedData(sharedData ? sharedData : ClipboardBrowserSharedPtr(new ClipboardBrowserShared))
    , m_loadButton(NULL)
    , m_searchProgress(NULL)
    , m_dragTargetRow(-1)
    , m_dragStartPosition()
    , m_spinLock(0)
    , m_scrollSaver()
{
    setLayoutMode(QListView::Batched);
    setBatchSize(1);
    setFrameShape(QFrame::NoFrame);
    setTabKeyNavigation(false);
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setWrapping(false);
    setLayoutMode(QListView::SinglePass);
    setEditTriggers(QAbstractItemView::NoEditTriggers);
    setAlternatingRowColors(true);

    initSingleShotTimer( &m_timerSave, 30000, this, SLOT(saveItems()) );
    initSingleShotTimer( &m_timerScroll, 50 );
    initSingleShotTimer( &m_timerUpdate, 10, this, SLOT(doUpdateCurrentPage()) );
    initSingleShotTimer( &m_timerFilter, 10, this, SLOT(filterItems()) );
    initSingleShotTimer( &m_timerExpire, 0, this, SLOT(expire()) );

    // ScrollPerItem doesn't work well with hidden items
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    connect( verticalScrollBar(), SIGNAL(valueChanged(int)),
             SLOT(updateCurrentPage()) );

    setAttribute(Qt::WA_MacShowFocusRect, 0);

    setAcceptDrops(true);

    connectModelAndDelegate();
}
Exemplo n.º 10
0
/**
 * Recursively writes tree items to a file.
 * Given an item, the method writes this item and all of its siblings.
 * Child items are written recursively.
 * @param	pItem	The first item to write
 * @param	str		An initialised text stream to use for writing
 * @param	enc		An encoder for free-text strings
 */
void TreeWidget::saveItems(QListViewItem* pItem, QTextStream& str, Encoder& enc)
{
	// Iterate over all items in this level
	for (; pItem != NULL; pItem = pItem->nextSibling()) {
		// Write function parameters
		str << pItem->text(0) << " [ "
			<< "kscope_file=\"" << pItem->text(1) << "\", "
			<< "kscope_line=" << pItem->text(2) << ", "
			<< "kscope_text=\"" << enc.encode(pItem->text(3)) << "\""
			<< "]" << endl;
		
		// Write child items
		str << "{" << endl;
		saveItems(pItem->firstChild(), str, enc);
		str << "}" << endl;
	}
}
Exemplo n.º 11
0
/**
 * Stores the tree contents in the given file.
 * @param	pFile	An open file to write to
 */
void TreeWidget::save(FILE* pFile)
{
	QTextStream str(pFile, IO_WriteOnly);
	QListViewItem* pRoot;
	Encoder enc;
	
	if (m_nQueryType == CscopeFrontend::Called)
		str << "calltree {" << endl;
	else
		str << "callingtree {" << endl;

	// Write the tree to the file
	pRoot = firstChild();
	str << pRoot->text(0) << endl;
	str << '{' << endl;
	saveItems(pRoot->firstChild(), str, enc);
	str << '}' << endl;
	str << '}' << endl;
}
Exemplo n.º 12
0
void SavegameManager::saveTrainer() {
	//Character* hero;
	std::ofstream of("./Data/Saves/" + m_pathname + "/trainer.ini");

	if(of.fail()) {
		ska::FileUtils::createDirectory("./Data/Saves/" + m_pathname);
		ska::FileUtils::createDirectory("./Data/Saves/" + m_pathname + "/Team");

		of.open("./Data/Saves/" + m_pathname + "/trainer.ini");
	}

	/*ska::IniReader reader("." FILE_SEPARATOR "Data" FILE_SEPARATOR "Saves" FILE_SEPARATOR + m_pathname + FILE_SEPARATOR "trainer.ini");

	hero = wScreen.getEntityFactory().getTrainer();
	reader.set("Trainer start_posx", hero->getHitboxCenterPos().x/TAILLEBLOC);
	reader.set("Trainer start_posy", hero->getHitboxCenterPos().y/TAILLEBLOC);
	reader.set("Trainer start_map_name", wScreen.getWorld().getName());
	reader.save("." FILE_SEPARATOR "Data" FILE_SEPARATOR "Saves" FILE_SEPARATOR + m_pathname + FILE_SEPARATOR "trainer.ini");*/

	saveItems();
}
Exemplo n.º 13
0
//---------------------------------------------------------------------------
void customActionsDialog::readItems()
{
    QSettings settings;
    settings.beginGroup("customActions");

    QStringList keys = settings.childKeys();
    for(int i = 0; i < keys.count(); ++i)
    {
        QStringList temp = settings.value(keys.at(i)).toStringList();
        bool setChecked = 0;
        QString cmd = temp.at(3);
        if(cmd.at(0) == '|')
        {
            cmd.remove(0,1);
            setChecked = 1;
        }

        QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget,QStringList() << temp.at(0) << temp.at(1) << temp.at(2) << cmd,0);
        item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsUserCheckable);
	
        if(setChecked) item->setCheckState(3,Qt::Checked);
        else item->setCheckState(3,Qt::Unchecked);
    }
    settings.endGroup();

    if(keys.count()==0)
    {
        QTreeWidgetItem *item1 = new QTreeWidgetItem(treeWidget, QStringList() << "gz,bz2" << tr("Extract here") << "package-x-generic" << "tar xf %f",0);
        QTreeWidgetItem *item2 = new QTreeWidgetItem(treeWidget, QStringList() << "folder" << tr("Term here") << "terminal" << "urxvt -cd %F",0);
        QTreeWidgetItem *item3 = new QTreeWidgetItem(treeWidget, QStringList() << "*" << tr("Compress") << "filesave" << "tar czf %n.tar.gz %f",0);
        item1->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsUserCheckable);
        item2->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsUserCheckable);
        item3->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsUserCheckable);

        saveItems();
    }

    for(int x = 0;x < treeWidget->topLevelItemCount();x++)
	treeWidget->topLevelItem(x)->setIcon(2,QIcon::fromTheme(treeWidget->topLevelItem(x)->text(2)));
}
Exemplo n.º 14
0
void DBManager::save() {
	char command[MAX_STR_LENGTH];
	sprintf(command, "mkdir .\\%s", DATA_PATH);
	if (system(NULL))
		system(command);

	savePlayers();
	saveEnemies();
	saveNPCs();
	saveTools();
	saveItems();
	savePowUps();
	saveBosses();
	saveBlocks();
	savePigeon();
	saveKeyObj();
	saveFinalElem(),
	savePuzzleElems();

	// Creamos el archivo de Log
	char file_path[MAX_STR_LENGTH];
	sprintf(file_path, ".\\%sLog", DATA_PATH);
	FILE* file =fopen(file_path, "wb");
	fclose(file);

	// Estos métodos además se encargan de copiar los respectivos archivos a la carpeta del juego
	saveGfx();
	saveEssentialElems();
	saveTileSets();
	saveSfx();
	saveDoors();

	sprintf(command, "del \".\\%sLog\"", DATA_PATH);
	if (system(NULL))
		system(command);
}
Exemplo n.º 15
0
bool IOPlayer::savePlayer(Player* player)
{
	player->preSave();

	Database* db = Database::instance();
	DBQuery query;
	DBResult* result;

	//check if the player have to be saved or not
	query << "SELECT `save` FROM `players` WHERE `id` = " << player->getGUID();

	if(!(result = db->storeQuery(query.str()))){
		return false;
	}

	if(result->getDataInt("save") == 0){
		db->freeResult(result);

		query.str("");
		query << "UPDATE `players` SET `lastlogin` = " << player->lastLoginSaved
		        << ", `lastip` = " << player->lastip
				<< " WHERE `id` = " << player->getGUID();

		DBTransaction transaction(db);
		if(!transaction.begin()){
			return false;
		}

		if(!db->executeQuery(query.str())){
			return false;
		}

		transaction.commit();

		return true;
	}
	db->freeResult(result);

	//serialize conditions
	PropWriteStream propWriteStream;

	for(ConditionList::const_iterator it = player->conditions.begin(); it != player->conditions.end(); ++it){
		if((*it)->isPersistent()){
			if(!(*it)->serialize(propWriteStream)){
				return false;
			}

			propWriteStream.ADD_UCHAR(CONDITIONATTR_END);
		}
	}

	uint32_t conditionsSize;
	const char* conditions = propWriteStream.getStream(conditionsSize);

	//First, an UPDATE query to write the player itself
	query.str("");
	query << "UPDATE `players` SET `level` = " << player->level
    << ", `vocation` = " << (int)player->getVocationId()
	<< ", `health` = " << player->health
	<< ", `healthmax` = " << player->healthMax
	<< ", `direction` = " << (int)player->getDirection()
	<< ", `experience` = " << player->experience
	<< ", `lookbody` = " << (int)player->defaultOutfit.lookBody
	<< ", `lookfeet` = " << (int)player->defaultOutfit.lookFeet
	<< ", `lookhead` = " << (int)player->defaultOutfit.lookHead
	<< ", `looklegs` = " << (int)player->defaultOutfit.lookLegs
	<< ", `looktype` = " << (int)player->defaultOutfit.lookType
	<< ", `maglevel` = " << player->magLevel
	<< ", `mana` = " << player->mana
	<< ", `manamax` = " << player->manaMax
	<< ", `manaspent` = " << player->manaSpent
	<< ", `soul` = " << player->soul
	<< ", `town_id` = " << player->town
	<< ", `posx` = " << player->getLoginPosition().x
	<< ", `posy` = " << player->getLoginPosition().y
	<< ", `posz` = " << player->getLoginPosition().z
	<< ", `cap` = " << player->getCapacity()
	<< ", `sex` = " << player->sex
	<< ", `lastlogin` = " << player->lastLoginSaved
	<< ", `lastip` = " << player->lastip
	<< ", `conditions` = " << db->escapeBlob(conditions, conditionsSize)
	<< ", `loss_experience` = " << (int)player->getLossPercent(LOSS_EXPERIENCE)
	<< ", `loss_mana` = " << (int)player->getLossPercent(LOSS_MANASPENT)
	<< ", `loss_skills` = " << (int)player->getLossPercent(LOSS_SKILLTRIES)
	<< ", `loss_items` = " << (int)player->getLossPercent(LOSS_ITEMS)
	<< ", `balance` = " << player->balance;

#ifdef __SKULLSYSTEM__
	int32_t redSkullTime = 0;
	if(player->redSkullTicks > 0){
		redSkullTime = std::time(NULL) + player->redSkullTicks/1000;
	}

	query << ", `redskulltime` = " << redSkullTime;

	int32_t redSkull = 0;
	if(player->skull == SKULL_RED){
		redSkull = 1;
	}

	query << ", `redskull` = " << redSkull;
#endif

	query << " WHERE `id` = " << player->getGUID();

	DBTransaction transaction(db);
	if(!transaction.begin()){
		return false;
	}

	if(!db->executeQuery(query.str())){
		return false;
	}
	query.str("");

	//skills
	for(int i = 0; i <= 6; i++){
		query << "UPDATE `player_skills` SET `value` = " << player->skills[i][SKILL_LEVEL] << ", `count` = " << player->skills[i][SKILL_TRIES] << " WHERE `player_id` = " << player->getGUID() << " AND `skillid` = " << i;

		if(!db->executeQuery(query.str())){
			return false;
		}
		query.str("");
	}

	// deletes all player-related stuff

	query << "DELETE FROM `player_spells` WHERE `player_id` = " << player->getGUID();

	if(!db->executeQuery(query.str())){
		return false;
	}
	query.str("");

	query << "DELETE FROM `player_items` WHERE `player_id` = " << player->getGUID();

	if(!db->executeQuery(query.str())){
		return false;
	}
	query.str("");

	query << "DELETE FROM `player_depotitems` WHERE `player_id` = " << player->getGUID();

	if(!db->executeQuery(query.str())){
		return false;
	}
	query.str("");

	query << "DELETE FROM `player_storage` WHERE `player_id` = " << player->getGUID();

	if(!db->executeQuery(query.str())){
		return false;
	}
	query.str("");

	query << "DELETE FROM `player_viplist` WHERE `player_id` = " << player->getGUID();

	if(!db->executeQuery(query.str())){
		return false;
	}
	query.str("");

	DBInsert stmt(db);

	//learned spells
	stmt.setQuery("INSERT INTO `player_spells` (`player_id`, `name`) VALUES ");

	for(LearnedInstantSpellList::const_iterator it = player->learnedInstantSpellList.begin();
			it != player->learnedInstantSpellList.end(); ++it){
		query << player->getGUID() << ", " << db->escapeString(*it);

		if(!stmt.addRow(query)){
			return false;
		}
	}

	if(!stmt.execute()){
		return false;
	}

	ItemBlockList itemList;

	Item* item;
	for(int32_t slotId = 1; slotId <= 10; ++slotId){
		if((item = player->inventory[slotId])){
			itemList.push_back(itemBlock(slotId, item));
		}
	}

	//item saving
	stmt.setQuery("INSERT INTO `player_items` (`player_id` , `pid` , `sid` , `itemtype` , `count` , `attributes` ) VALUES ");

	if(!(saveItems(player, itemList, stmt) && stmt.execute())){
		return false;
	}

	itemList.clear();
	for(DepotMap::iterator it = player->depots.begin(); it != player->depots.end(); ++it){
		itemList.push_back(itemBlock(it->first, it->second));
	}

	//save depot items
	stmt.setQuery("INSERT INTO `player_depotitems` (`player_id` , `pid` , `sid` , `itemtype` , `count` , `attributes` ) VALUES ");

	if(!(saveItems(player, itemList, stmt) && stmt.execute())){
		return false;
	}

	stmt.setQuery("INSERT INTO `player_storage` (`player_id` , `key` , `value` ) VALUES ");

	for(StorageMap::const_iterator cit = player->getStorageIteratorBegin(); cit != player->getStorageIteratorEnd();cit++){
		query << player->getGUID() << ", " << cit->first << ", " << cit->second;

		if(!stmt.addRow(query)){
			return false;
		}
	}

	if(!stmt.execute()){
		return false;
	}

	//save vip list
	if(!player->VIPList.empty()){
		std::stringstream ss;
		ss << "INSERT INTO `player_viplist` (`player_id`, `vip_id`) SELECT " << player->getGUID()
			<< ", `id` FROM `players` WHERE `id` IN";

		stmt.setQuery(ss.str());
		ss.str("");

		for(VIPListSet::iterator it = player->VIPList.begin(); it != player->VIPList.end();){
			ss << (*it);
			++it;
			
			if(it != player->VIPList.end()){
				ss << ",";
			}
		}

		stmt.addRow(ss);

		if(!stmt.execute()){
			return false;
		}
	}

	//End the transaction
	return transaction.commit();
}
Exemplo n.º 16
0
bool IOLoginData::savePlayer(Player* player)
{
	if (player->getHealth() <= 0) {
		player->changeHealth(1);
	}

	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `save` FROM `players` WHERE `id` = " << player->getGUID();
	DBResult_ptr result = db->storeQuery(query.str());
	if (!result) {
		return false;
	}

	if (result->getDataInt("save") == 0) {
		query.str("");
		query << "UPDATE `players` SET `lastlogin` = " << player->lastLoginSaved << ", `lastip` = " << player->lastIP << " WHERE `id` = " << player->getGUID();
		return db->executeQuery(query.str());
	}

	//serialize conditions
	PropWriteStream propWriteStream;
	for (Condition* condition : player->conditions) {
		if (condition->isPersistent()) {
			condition->serialize(propWriteStream);
			propWriteStream.write<uint8_t>(CONDITIONATTR_END);
		}
	}

	size_t conditionsSize;
	const char* conditions = propWriteStream.getStream(conditionsSize);

	//First, an UPDATE query to write the player itself
	query.str("");
	query << "UPDATE `players` SET ";
	query << "`level` = " << player->level << ',';
	query << "`group_id` = " << player->group->id << ',';
	query << "`vocation` = " << player->getVocationId() << ',';
	query << "`health` = " << player->health << ',';
	query << "`healthmax` = " << player->healthMax << ',';
	query << "`experience` = " << player->experience << ',';
	query << "`lookbody` = " << static_cast<uint32_t>(player->defaultOutfit.lookBody) << ',';
	query << "`lookfeet` = " << static_cast<uint32_t>(player->defaultOutfit.lookFeet) << ',';
	query << "`lookhead` = " << static_cast<uint32_t>(player->defaultOutfit.lookHead) << ',';
	query << "`looklegs` = " << static_cast<uint32_t>(player->defaultOutfit.lookLegs) << ',';
	query << "`looktype` = " << player->defaultOutfit.lookType << ',';
	query << "`lookaddons` = " << static_cast<uint32_t>(player->defaultOutfit.lookAddons) << ',';
	query << "`maglevel` = " << player->magLevel << ',';
	query << "`mana` = " << player->mana << ',';
	query << "`manamax` = " << player->manaMax << ',';
	query << "`manaspent` = " << player->manaSpent << ',';
	query << "`soul` = " << player->soul << ',';
	query << "`town_id` = " << player->town->getID() << ',';

	const Position& loginPosition = player->getLoginPosition();
	query << "`posx` = " << loginPosition.getX() << ',';
	query << "`posy` = " << loginPosition.getY() << ',';
	query << "`posz` = " << loginPosition.getZ() << ',';

	query << "`cap` = " << (player->capacity / 100) << ',';
	query << "`sex` = " << player->sex << ',';

	if (player->lastLoginSaved != 0) {
		query << "`lastlogin` = " << player->lastLoginSaved << ',';
	}

	if (player->lastIP != 0) {
		query << "`lastip` = " << player->lastIP << ',';
	}

	query << "`conditions` = " << db->escapeBlob(conditions, conditionsSize) << ',';

	if (g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) {
		int32_t skullTime = 0;

		if (player->skullTicks > 0) {
			skullTime = time(nullptr) + player->skullTicks / 1000;
		}

		query << "`skulltime` = " << skullTime << ',';

		Skulls_t skull = SKULL_NONE;
		if (player->skull == SKULL_RED) {
			skull = SKULL_RED;
		} else if (player->skull == SKULL_BLACK) {
			skull = SKULL_BLACK;
		}
		query << "`skull` = " << static_cast<uint32_t>(skull) << ',';
	}

	query << "`lastlogout` = " << player->getLastLogout() << ',';
	query << "`balance` = " << player->bankBalance << ',';
	query << "`offlinetraining_time` = " << player->getOfflineTrainingTime() / 1000 << ',';
	query << "`offlinetraining_skill` = " << player->getOfflineTrainingSkill() << ',';
	query << "`stamina` = " << player->getStaminaMinutes() << ',';

	query << "`skill_fist` = " << player->skills[SKILL_FIST].level << ',';
	query << "`skill_fist_tries` = " << player->skills[SKILL_FIST].tries << ',';
	query << "`skill_club` = " << player->skills[SKILL_CLUB].level << ',';
	query << "`skill_club_tries` = " << player->skills[SKILL_CLUB].tries << ',';
	query << "`skill_sword` = " << player->skills[SKILL_SWORD].level << ',';
	query << "`skill_sword_tries` = " << player->skills[SKILL_SWORD].tries << ',';
	query << "`skill_axe` = " << player->skills[SKILL_AXE].level << ',';
	query << "`skill_axe_tries` = " << player->skills[SKILL_AXE].tries << ',';
	query << "`skill_dist` = " << player->skills[SKILL_DISTANCE].level << ',';
	query << "`skill_dist_tries` = " << player->skills[SKILL_DISTANCE].tries << ',';
	query << "`skill_shielding` = " << player->skills[SKILL_SHIELD].level << ',';
	query << "`skill_shielding_tries` = " << player->skills[SKILL_SHIELD].tries << ',';
	query << "`skill_fishing` = " << player->skills[SKILL_FISHING].level << ',';
	query << "`skill_fishing_tries` = " << player->skills[SKILL_FISHING].tries << ',';

	if (!player->isOffline()) {
		query << "`onlinetime` = `onlinetime` + " << (time(nullptr) - player->lastLoginSaved) << ',';
	}
	query << "`blessings` = " << static_cast<uint32_t>(player->blessings);
	query << " WHERE `id` = " << player->getGUID();

	DBTransaction transaction;
	if (!transaction.begin()) {
		return false;
	}

	if (!db->executeQuery(query.str())) {
		return false;
	}

	// learned spells
	query.str("");
	query << "DELETE FROM `player_spells` WHERE `player_id` = " << player->getGUID();
	if (!db->executeQuery(query.str())) {
		return false;
	}

	query.str("");

	DBInsert spellsQuery("INSERT INTO `player_spells` (`player_id`, `name` ) VALUES ");
	for (const std::string& spellName : player->learnedInstantSpellList) {
		query << player->getGUID() << ',' << db->escapeString(spellName);
		if (!spellsQuery.addRow(query)) {
			return false;
		}
	}

	if (!spellsQuery.execute()) {
		return false;
	}

	//item saving
	query << "DELETE FROM `player_items` WHERE `player_id` = " << player->getGUID();
	if (!db->executeQuery(query.str())) {
		return false;
	}

	DBInsert itemsQuery("INSERT INTO `player_items` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`) VALUES ");

	ItemBlockList itemList;
	for (int32_t slotId = 1; slotId <= 10; ++slotId) {
		Item* item = player->inventory[slotId];
		if (item) {
			itemList.emplace_back(slotId, item);
		}
	}

	if (!saveItems(player, itemList, itemsQuery, propWriteStream)) {
		return false;
	}

	if (player->lastDepotId != -1) {
		//save depot items
		query.str("");
		query << "DELETE FROM `player_depotitems` WHERE `player_id` = " << player->getGUID();

		if (!db->executeQuery(query.str())) {
			return false;
		}

		DBInsert depotQuery("INSERT INTO `player_depotitems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`) VALUES ");
		itemList.clear();

		for (const auto& it : player->depotChests) {
			DepotChest* depotChest = it.second;
			for (Item* item : depotChest->getItemList()) {
				itemList.emplace_back(it.first, item);
			}
		}

		if (!saveItems(player, itemList, depotQuery, propWriteStream)) {
			return false;
		}
	}

	//save inbox items
	query.str("");
	query << "DELETE FROM `player_inboxitems` WHERE `player_id` = " << player->getGUID();
	if (!db->executeQuery(query.str())) {
		return false;
	}

	DBInsert inboxQuery("INSERT INTO `player_inboxitems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`) VALUES ");
	itemList.clear();

	for (Item* item : player->getInbox()->getItemList()) {
		itemList.emplace_back(0, item);
	}

	if (!saveItems(player, itemList, inboxQuery, propWriteStream)) {
		return false;
	}

	query.str("");
	query << "DELETE FROM `player_storage` WHERE `player_id` = " << player->getGUID();
	if (!db->executeQuery(query.str())) {
		return false;
	}

	query.str("");

	DBInsert storageQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES ");
	player->genReservedStorageRange();

	for (const auto& it : player->storageMap) {
		query << player->getGUID() << ',' << it.first << ',' << it.second;
		if (!storageQuery.addRow(query)) {
			return false;
		}
	}

	if (!storageQuery.execute()) {
		return false;
	}

	//End the transaction
	return transaction.commit();
}
Exemplo n.º 17
0
bool IOLoginData::savePlayer(Player* player)
{
	if (player->getHealth() <= 0) {
		player->changeHealth(1);
	}

	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `save` FROM `players` WHERE `id` = " << player->getGUID();

	DBResult* result = db->storeQuery(query.str());

	if (!result) {
		return false;
	}

	if (result->getDataInt("save") == 0) {
		db->freeResult(result);
		query.str("");
		query << "UPDATE `players` SET `lastlogin` = " << player->lastLoginSaved << ", `lastip` = " << player->lastIP << " WHERE `id` = " << player->getGUID();
		return db->executeQuery(query.str());
	}

	db->freeResult(result);

	//serialize conditions
	PropWriteStream propWriteStream;

	for (ConditionList::const_iterator it = player->conditions.begin(); it != player->conditions.end(); ++it) {
		Condition* condition = *it;

		if (condition->isPersistent()) {
			if (!condition->serialize(propWriteStream)) {
				return false;
			}

			propWriteStream.ADD_UCHAR(CONDITIONATTR_END);
		}
	}

	uint32_t conditionsSize = 0;
	const char* conditions = propWriteStream.getStream(conditionsSize);

	//First, an UPDATE query to write the player itself
	query.str("");
	query << "UPDATE `players` SET ";
	query << "`level` = " << player->level << ", ";
	query << "`group_id` = " << player->groupId << ", ";
	query << "`vocation` = " << (int32_t)player->getVocationId() << ", ";
	query << "`health` = " << player->health << ", ";
	query << "`healthmax` = " << player->healthMax << ", ";
	query << "`experience` = " << player->experience << ", ";
	query << "`lookbody` = " << (int32_t)player->defaultOutfit.lookBody << ", ";
	query << "`lookfeet` = " << (int32_t)player->defaultOutfit.lookFeet << ", ";
	query << "`lookhead` = " << (int32_t)player->defaultOutfit.lookHead << ", ";
	query << "`looklegs` = " << (int32_t)player->defaultOutfit.lookLegs << ", ";
	query << "`looktype` = " << (int32_t)player->defaultOutfit.lookType << ", ";
	query << "`lookaddons` = " << (int32_t)player->defaultOutfit.lookAddons << ", ";
	query << "`maglevel` = " << player->magLevel << ", ";
	query << "`mana` = " << player->mana << ", ";
	query << "`manamax` = " << player->manaMax << ", ";
	query << "`manaspent` = " << player->manaSpent << ", ";
	query << "`soul` = " << player->soul << ", ";
	query << "`town_id` = " << player->town << ", ";

	const Position& loginPosition = player->getLoginPosition();
	query << "`posx` = " << loginPosition.x << ", ";
	query << "`posy` = " << loginPosition.y << ", ";
	query << "`posz` = " << loginPosition.z << ", ";

	query << "`cap` = " << player->getCapacity() << ", ";
	query << "`sex` = " << player->sex << ", ";

	if (player->lastLoginSaved != 0) {
		query << "`lastlogin` = " << player->lastLoginSaved << ", ";
	}

	if (player->lastIP != 0) {
		query << "`lastip` = " << player->lastIP << ", ";
	}

	query << "`conditions` = " << db->escapeBlob(conditions, conditionsSize) << ", ";

	if (g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) {
		int32_t skullTime = 0;

		if (player->skullTicks > 0) {
			skullTime = time(NULL) + player->skullTicks / 1000;
		}

		query << "`skulltime` = " << skullTime << ", ";
		int32_t skull = 0;

		if (player->skull == SKULL_RED) {
			skull = SKULL_RED;
		} else if (player->skull == SKULL_BLACK) {
			skull = SKULL_BLACK;
		}

		query << "`skull` = " << skull << ", ";
	}

	query << "`lastlogout` = " << player->getLastLogout() << ", ";
	query << "`balance` = " << player->bankBalance << ", ";
	query << "`offlinetraining_time` = " << player->getOfflineTrainingTime() / 1000 << ", ";
	query << "`offlinetraining_skill` = " << player->getOfflineTrainingSkill() << ", ";
	query << "`stamina` = " << player->getStaminaMinutes() << ", ";
	if (!player->isOffline()) {
		query << "`onlinetime` = `onlinetime` + " << (time(NULL) - player->lastLoginSaved) << ", ";
	}
	query << "`blessings` = " << player->blessings;
	query << " WHERE `id` = " << player->getGUID();

	DBTransaction transaction;
	if (!transaction.begin()) {
		return false;
	}

	if (!db->executeQuery(query.str())) {
		return false;
	}

	// skills
	for (int32_t i = SKILL_FIRST; i <= SKILL_LAST; i++) {
		query.str("");
		query << "UPDATE `player_skills` SET `value` = " << player->skills[i][SKILL_LEVEL] << ", `count` = " << player->skills[i][SKILL_TRIES] << " WHERE `player_id` = " << player->getGUID() << " AND `skillid` = " << i;

		if (!db->executeQuery(query.str())) {
			return false;
		}
	}

	// learned spells
	query.str("");
	query << "DELETE FROM `player_spells` WHERE `player_id` = " << player->getGUID();

	if (!db->executeQuery(query.str())) {
		return false;
	}

	query.str("");

	DBInsert stmt(db);
	stmt.setQuery("INSERT INTO `player_spells` (`player_id`, `name` ) VALUES ");

	for (LearnedInstantSpellList::const_iterator it = player->learnedInstantSpellList.begin();
	        it != player->learnedInstantSpellList.end(); ++it) {
		query << player->getGUID() << "," << db->escapeString(*it);

		if (!stmt.addRow(query)) {
			return false;
		}
	}

	if (!stmt.execute()) {
		return false;
	}

	//item saving
	query << "DELETE FROM `player_items` WHERE `player_id` = " << player->getGUID();

	if (!db->executeQuery(query.str())) {
		return false;
	}

	stmt.setQuery("INSERT INTO `player_items` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`) VALUES ");

	ItemBlockList itemList;
	for (int32_t slotId = 1; slotId <= 10; ++slotId) {
		Item* item = player->inventory[slotId];
		if (item) {
			itemList.push_back(itemBlock(slotId, item));
		}
	}

	if (!saveItems(player, itemList, stmt)) {
		return false;
	}

	if (player->depotChange) {
		//save depot items
		query.str("");
		query << "DELETE FROM `player_depotitems` WHERE `player_id` = " << player->getGUID();

		if (!db->executeQuery(query.str())) {
			return false;
		}

		stmt.setQuery("INSERT INTO `player_depotitems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`) VALUES ");
		itemList.clear();

		for (DepotMap::iterator it = player->depotChests.begin(); it != player->depotChests.end() ; ++it) {
			DepotChest* depotChest = it->second;

			for (ItemDeque::const_iterator iit = depotChest->getItems(), end = depotChest->getEnd(); iit != end; ++iit) {
				itemList.push_back(itemBlock(it->first, *iit));
			}
		}

		if (!saveItems(player, itemList, stmt)) {
			return false;
		}
	}

	//save inbox items
	query.str("");
	query << "DELETE FROM `player_inboxitems` WHERE `player_id` = " << player->getGUID();

	if (!db->executeQuery(query.str())) {
		return false;
	}

	stmt.setQuery("INSERT INTO `player_inboxitems` (`player_id`, `pid`, `sid`, `itemtype`, `count`, `attributes`) VALUES ");
	itemList.clear();

	for (ItemDeque::const_iterator it = player->getInbox()->getItems(), end = player->getInbox()->getEnd(); it != end; ++it) {
		itemList.push_back(itemBlock(0, *it));
	}

	if (!saveItems(player, itemList, stmt)) {
		return false;
	}

	query.str("");
	query << "DELETE FROM `player_storage` WHERE `player_id` = " << player->getGUID();

	if (!db->executeQuery(query.str())) {
		return false;
	}

	query.str("");

	stmt.setQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES ");
	player->genReservedStorageRange();

	for (StorageMap::const_iterator cit = player->getStorageIteratorBegin(), end = player->getStorageIteratorEnd(); cit != end; ++cit) {
		query << player->getGUID() << "," << cit->first << "," << cit->second;

		if (!stmt.addRow(query)) {
			return false;
		}
	}

	if (!stmt.execute()) {
		return false;
	}

	//End the transaction
	return transaction.commit();
}
Exemplo n.º 18
0
ClipboardBrowser::~ClipboardBrowser()
{
    d.invalidateCache();
    if ( m_timerSave.isActive() )
        saveItems();
}
Exemplo n.º 19
0
//---------------------------------------------------------------------------
void customActionsDialog::accept()
{
    saveItems();
    this->done(1);
}
Exemplo n.º 20
0
ClipboardBrowser::~ClipboardBrowser()
{
    if ( m_timerSave->isActive() )
        saveItems();
}
Exemplo n.º 21
0
ClipboardBrowser::ClipboardBrowser(QWidget *parent, const ClipboardBrowserSharedPtr &sharedData)
    : QListView(parent)
    , m_loaded(false)
    , m_id()
    , m_lastFilter()
    , m_update(false)
    , m( new ClipboardModel(this) )
    , d( new ItemDelegate(viewport()) )
    , m_timerSave( new QTimer(this) )
    , m_timerScroll( new QTimer(this) )
    , m_menu( new QMenu(this) )
    , m_sharedData(sharedData ? sharedData : ClipboardBrowserSharedPtr(new ClipboardBrowserShared))
{
    setLayoutMode(QListView::Batched);
    setBatchSize(1);
    setFrameShadow(QFrame::Sunken);
    setTabKeyNavigation(false);
    setAlternatingRowColors(true);
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setWrapping(false);
    setLayoutMode(QListView::SinglePass);
    setEditTriggers(QAbstractItemView::EditKeyPressed);
    setSpacing(5);

    m_timerSave->setSingleShot(true);
    connect( m_timerSave, SIGNAL(timeout()),
             this, SLOT(saveItems()) );

    m_timerScroll->setSingleShot(true);
    m_timerScroll->setInterval(50);

    // delegate for rendering and editing items
    setItemDelegate(d);

    // set new model
    QItemSelectionModel *old_model = selectionModel();
    setModel(m);
    delete old_model;

    connect( d, SIGNAL(editingActive(bool)),
             SIGNAL(editingActive(bool)) );

    connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)),
             d, SLOT(rowsRemoved(QModelIndex,int,int)) );
    connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)),
             d, SLOT(rowsInserted(QModelIndex, int, int)) );
    connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
             d, SLOT(rowsMoved(QModelIndex, int, int, QModelIndex, int)) );

    // save if data in model changed
    connect( m, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
             SLOT(onDataChanged(QModelIndex,QModelIndex)) );
    connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)),
             SLOT(delayedSaveItems()) );
    connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)),
             SLOT(delayedSaveItems()) );
    connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
             SLOT(delayedSaveItems()) );

    // update on change
    connect( d, SIGNAL(rowSizeChanged(int)),
             SLOT(onRowSizeChanged(int)) );
    connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)),
             SLOT(updateCurrentPage()) );
    connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)),
             SLOT(updateCurrentPage()) );
    connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
             SLOT(updateCurrentPage()) );
    connect( verticalScrollBar(), SIGNAL(valueChanged(int)),
             SLOT(updateCurrentPage()) );
    connect( verticalScrollBar(), SIGNAL(rangeChanged(int,int)),
             SLOT(updateCurrentPage()), Qt::QueuedConnection );

    // ScrollPerItem doesn't work well with hidden items
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    setAttribute(Qt::WA_MacShowFocusRect, 0);
}
Exemplo n.º 22
0
int main(int argc, char** argv)
{
	if (argc < 2)
		return usage(argc, argv);

	parent = pthread_self();
	sigset_t original, masking;
	sigemptyset(&original);
	sigemptyset(&masking);
	sigaddset(&masking, SIGUSR1);
	pthread_sigmask(SIG_SETMASK, &masking, &original);

	int wakeupThreads = 0;
	try
	{
		wakeupThreads = lexicalCast<int>(argv[argc-1]);
		if (wakeupThreads < 1)
			return usage(argc, argv);

		std::cout << "wakeup threads of " << wakeupThreads << std::endl;
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
		return usage(argc, argv);
	}

	void* handle = WWWInit();
	std::vector<Item> items = loadItems();
	resetItems(items);
	void* filterManagerContext = FilterManagerCreate(NULL);

	std::map<void*, void*> contextMap;
	

	// create threads.
	for (int count = 0; count != wakeupThreads; ++count)
	{
		std::vector<Item>::iterator itor = find_uncheck_item(items);
		if (itor == items.end())
			break;

		itor->check_flg = true;
		void* thread = ThreadCreate();
		void* httpContext = HTTPCreateContext(itor->url_check.c_str(),
											  NULL, NULL, 20);
		contextMap[thread] = httpContext;
		std::cout << "thread: " << thread <<
			"   context: " << httpContext << std::endl;
		ThreadStart(thread, httpContext, handler);
	}

	try
	{
		std::vector<Item>::iterator itor;
		while ((itor = find_uncheck_item(items)) != items.end())
		{
			itor->check_flg = true;
			
			int signalNum = 0;
			sigwait(&masking, &signalNum);
			if (signalNum == SIGUSR1)
			{
				// signal一回で複数の待ちハンドラを処理した方が良さそう
				ScopedLock<Mutex> lock(syncObject);
				assert (idleThreads.size() > 0);
				void* thread = idleThreads.back();
				idleThreads.pop_back();
				ThreadJoin(thread);

				void* httpContext = contextMap[thread];
				assert(httpContext != NULL);
				contextMap[thread] = NULL;

				{
					char url[2048];
					url[HTTPGetURL(httpContext, url, sizeof(url))] = 0;
					std::vector<Item>::iterator item_itor =
						find_item_from_url(items, url);

					if (item_itor == items.end())
						throw std::runtime_error((std::string("unfind URL: ") +
												  url).c_str());

					char date[256];
					date[HTTPGetLastModified(httpContext,
											 date, sizeof(date))] = 0;
					item_itor->last_updated = date;

					item_itor->crc32 = HTTPGetFilteredCRC32(httpContext,
													   filterManagerContext);
				
					item_itor->content_length =
						HTTPGetContentsLength(httpContext);

					HTTPClose(httpContext);
				}
				HTTPCreateContext(itor->url_check.c_str(),
								  NULL, NULL, 20);
				contextMap[thread] = httpContext;
				std::cout << "thread: " << thread <<
					"   context: " << httpContext << std::endl;
				ThreadStart(thread, httpContext, handler);
			}
		}

		// 稼働中のスレッドがwakeupThreads個存在する
		for (int count = 0; count != wakeupThreads; ++count)
		{
			int signalNum = 0;
			// signal一回で複数の待ちハンドラを処理した方が良さそう
			sigwait(&masking, &signalNum);
			ScopedLock<Mutex> lock(syncObject);
			ThreadClose(idleThreads.back());
			idleThreads.pop_back();
		}
	}
	catch (std::exception& e)
	{
		std::cerr << "raise exception: " << e.what() << std::endl;
	}
	catch (...)
	{
		std::cerr << "unknown exception raised." << std::endl;
	}

	saveItems(items);
	FilterManagerTerminate(filterManagerContext);
	WWWTerminate(handle);
	pthread_sigmask(SIG_SETMASK, &original, NULL);

	return 0;
}
Exemplo n.º 23
0
void checkInOut(LinkedList<Item> *listOfItems)
{
	bool valid = false;
	int input;
	string junk;
	Node<Item> *tmp;

	while (valid == false)
	{
		cout << "Please enter the serial number of the item to check in or check out (-1 to quit):\n\n"
			 << "Item: ";
		cin >> input;
		getline(cin, junk);
		
		if (input < 0) return;
		
		// find item in list
		tmp = listOfItems->mHead; //Set tmp to the first element of the list
		while (tmp != NULL) //Check the entire list until the item is found
		{
			//If found, exist from the loop and perform appropriate action
			//As long as it isn't found, check the next item
			if (tmp->mData.getSerial() == input)
			{
				valid = true;
				break;
			}
			else
			{
				tmp = tmp->mNext;
			}
		}
		
		if (!valid) cout << "The item with with serial '" << input << "' does not exist...\n";
		
	}

	// item is now at tmp->mData
	
	cout << "The item with serial '" << input << "' is checked ";
	
	if (tmp->mData.isCheckedIn())
	{
		cout << "in.\n";
	}
	else {
		cout << "out.\n";
	}
	
	do {
		if (tmp->mData.isCheckedIn())
			cout << "Do you want to check this item out (-1 to cancel, 1 to continue)? ";
		else
			cout << "Do you want to check this item in  (-1 to cancel, 1 to continue)? ";
		cin >> input;
		getline(cin, junk);
		if (input < -1 || input == 0 || input > 1)
			cout << "Invalid input...\n";
	} while (input < -1 || input == 0 || input > 1);
	
	if (input <= 0) return;
	else {
		if (tmp->mData.isCheckedIn() == true) //If the item is checked in, check it out
		{
			tmp->mData.checkOut();
			cout << "The item has been checked out.\n\n";
		}
		else //If the item is checked out, check it back in
		{
			tmp->mData.checkIn();
			cout << "The item has been checked in.\n\n";
		}
	}
	
	saveItems(listOfItems);
	
	pause();
}