Beispiel #1
0
void MapCreationState::keyPressed(int key){
    if(key == 80){
        std::cout << "right" << std::endl;
        if(currentTexture < wH->getTiles().size()){
            currentTexture++;
        }else{
            currentTexture = 0;
        }
    }
    if(iH->getRIGHT()){
        wH->offSetby(1, 0, true);
    }
    if(iH->getLEFT()){
        wH->offSetby(-1, 0, true);
    }
    if(iH->getDOWN()){
        wH->offSetby(0, 1, true);
    }
    if(iH->getUP()){
        wH->offSetby(0, -1, true);
    }
    if(key == 84){
        saveMap();
    }
}
Beispiel #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    Ui_MainWindow()
{
    setupUi(this);
    connect(pushButton,SIGNAL(clicked()),this,SLOT(work()));
    connect(saveMapact,SIGNAL(triggered()),this,SLOT(saveMap()));
    connect(openMapact,SIGNAL(triggered()),this,SLOT(loadMap()));
    connect(openArract,SIGNAL(triggered()),this,SLOT(loadArr()));
    connect(saveArract,SIGNAL(triggered()),this,SLOT(saveArr()));
    nextBtn->setVisible(false);
    preBtn->setVisible(false);
    addBtn->setVisible(false);
    delBtn->setVisible(false);
    redoBtn->setVisible(false);
    findMBtn->setVisible(false);
    findSBtn->setVisible(false);
    listSBtn->setVisible(false);
    matchFBtn->setVisible(false);
    zinBtn->setVisible(false);
    zoutBtn->setVisible(false);
    for(int i=0;i<Hei;i++)
        for(int j=0;j<Wid;j++)
        {
            arrLayout->addWidget(&arrs[i][j],i,j,4,2);
        }
}
bool Hdf5Dataset::saveWorkspaceToMap(const map_generation::WorkSpace &ws)
{
  std::vector< std::vector< double > > pose_reach;
  std::vector<std::vector<double> > spheres;
  std::vector<double> ri;
  for(int i=0;i<ws.WsSpheres.size();++i)
  {
    std::vector<double> sphere_vec(3);
    reuleaux::pointToVector(ws.WsSpheres[i].point, sphere_vec);
    spheres.push_back(sphere_vec);
    ri.push_back(ws.WsSpheres[i].ri);
    std::vector< double > pose_and_sphere(10);
    for(int j=0;j<3;++j)
    {
      pose_and_sphere[j] = sphere_vec[j];
    }
    for(int k=0;k<ws.WsSpheres[i].poses.size();++k)
    {
      std::vector<double> pose_vec(7);
      reuleaux::poseToVector(ws.WsSpheres[i].poses[k], pose_vec);
      for(int l=0;l<7;++l)
      {
        pose_and_sphere[3+l] = pose_vec[l];
      }
      pose_reach.push_back(pose_and_sphere);
    }
  }
  saveMap(pose_reach, spheres, ri, ws.resolution);
}
Beispiel #4
0
void TerminateApplication (GL_Window* window)							// Terminate The Application
{
	//ShowCursor(TRUE);
	if ( MessageBox (HWND_DESKTOP, "Save map data?", "SAVE?", MB_YESNO | MB_ICONQUESTION) == IDYES)
		saveMap ();

	PostMessage (window->hWnd, WM_QUIT, 0, 0);							// Send A WM_QUIT Message
	g_isProgramLooping = FALSE;											// Stop Looping Of The Program
}
Beispiel #5
0
void MapCreationState::exitCalled(){
    //save the world
    saveMap();
    //reset the world data
    wH->resetData();
    //also reset the world saving stuff
    savedAlpha = 0;
    //set the new state!
    State::setState(STATES::menu);
}
Beispiel #6
0
bool Map::saveWholeMap()
{
#ifdef MSDBG
  printf("saveWholeMap()\n");
#endif

  for(std::map<uint32, sChunk>::const_iterator it = maps.begin(); it != maps.end(); ++it)
    saveMap(maps[it->first].x, maps[it->first].z);
  return true;
}
Beispiel #7
0
void Construction::events() {
	sf::Event e;
	while (target.pollEvent(e)) {
		switch (e.type) {
		case sf::Event::KeyPressed:
			if (e.key.code == sf::Keyboard::Up) {
				kafelki[cursorVector.x][cursorVector.y].setVisible(true);
				cursorVector.y -= 1;
				if (cursorVector.y < 0) cursorVector.y = 12;
				kafelki[cursorVector.x][cursorVector.y].setVisible(false);
			}
			else if (e.key.code == sf::Keyboard::Down) {
				kafelki[cursorVector.x][cursorVector.y].setVisible(true);
				cursorVector.y += 1;
				if (cursorVector.y > 12) cursorVector.y = 0;
				kafelki[cursorVector.x][cursorVector.y].setVisible(false);
			}
			else if (e.key.code == sf::Keyboard::Left) {
				kafelki[cursorVector.x][cursorVector.y].setVisible(true);
				cursorVector.x -= 1;
				if (cursorVector.x < 0) cursorVector.x = 12;
				kafelki[cursorVector.x][cursorVector.y].setVisible(false);
			}
			else if (e.key.code == sf::Keyboard::Right) {
				kafelki[cursorVector.x][cursorVector.y].setVisible(true);
				cursorVector.x += 1;
				if (cursorVector.x > 12) cursorVector.x = 0;
				kafelki[cursorVector.x][cursorVector.y].setVisible(false);
			}
			if (e.key.code == sf::Keyboard::Return) {
				saveMap();
				stillBuildingMap = false;
			}
			else if (e.key.code == sf::Keyboard::LAlt) {
				cursorVector.z++;
				if (cursorVector.z > 13) cursorVector.z = 0;
				kafelki[cursorVector.x][cursorVector.y].setVisible(false);
			}
			else if (e.key.code == sf::Keyboard::Escape) {
				stillBuildingMap = false;
			}
			else if (e.key.code == sf::Keyboard::Space) {
				kafelki[cursorVector.x][cursorVector.y] = elementy[cursorVector.z];
				kafelki[cursorVector.x][cursorVector.y].setPosition(cursor.getPosition().x, cursor.getPosition().y);
				if (cursorVector.z == 3 || cursorVector.z == 8) kafelki[cursorVector.x][cursorVector.y].move(27, 0);
				if (cursorVector.z == 5 || cursorVector.z == 10) kafelki[cursorVector.x][cursorVector.y].move(0, 24);
				kafelkiID[cursorVector.x][cursorVector.y] = cursorVector.z;
			}
			break;
		}
		if (e.type == sf::Event::Closed) target.close();
	}
}
Beispiel #8
0
/* MapEditorWindow::saveMapAs
 * Saves the current map to a new archive
 *******************************************************************/
bool MapEditorWindow::saveMapAs()
{
	// Show dialog
	SFileDialog::fd_info_t info;
	if (!SFileDialog::saveFile(info, "Save Map As", "Wad Archives (*.wad)|*.wad", this))
		return false;

	// Create new, empty wad
	WadArchive wad;
	ArchiveEntry* head = wad.addNewEntry(mdesc_current.name);
	ArchiveEntry* end = NULL;
	if (mdesc_current.format == MAP_UDMF)
	{
		wad.addNewEntry("TEXTMAP");
		end = wad.addNewEntry("ENDMAP");
	}
	else
	{
		wad.addNewEntry("THINGS");
		wad.addNewEntry("LINEDEFS");
		wad.addNewEntry("SIDEDEFS");
		wad.addNewEntry("VERTEXES");
		end = wad.addNewEntry("SECTORS");
	}

	// Save map data
	mdesc_current.head = head;
	mdesc_current.archive = false;
	mdesc_current.end = end;
	saveMap();

	// Write wad to file
	wad.save(info.filenames[0]);
	Archive* archive = theArchiveManager->openArchive(info.filenames[0], true, true);
	theArchiveManager->addRecentFile(info.filenames[0]);

	// Update current map description
	vector<Archive::mapdesc_t> maps = archive->detectMaps();
	if (!maps.empty())
	{
		mdesc_current.head = maps[0].head;
		mdesc_current.archive = false;
		mdesc_current.end = maps[0].end;
	}

	// Set window title
	SetTitle(S_FMT("SLADE - %s of %s", mdesc_current.name, wad.getFilename(false)));

	return true;
}
Beispiel #9
0
bool IOMapOTMM::saveMap(Map& map, const FileName& identifier, bool showdialog) {
	DiskNodeFileWriteHandle f(std::string(identifier.GetFullPath().mb_str(wxConvUTF8)));
	
	if(f.isOk() == false){
		error(wxT("Can not open file %s for writing"), (const char*)identifier.GetFullPath().mb_str(wxConvUTF8));
		return false;
	}

	if(showdialog) gui.CreateLoadBar(wxT("Saving OTMM map..."));
	bool ret = saveMap(map, f, identifier, showdialog);
	if(showdialog) gui.DestroyLoadBar();

	return ret;
}
Beispiel #10
0
/* MapEditorWindow::tryClose
 * Checks if the currently open map is modified and prompts to save.
 * If 'Cancel' is clicked then this will return false (ie. we don't
 * want to close the window)
 *******************************************************************/
bool MapEditorWindow::tryClose()
{
	if (editor.getMap().isModified())
	{
		wxMessageDialog md(this, S_FMT("Save changes to map %s?", currentMapDesc().name), "Unsaved Changes", wxYES_NO | wxCANCEL);
		int answer = md.ShowModal();
		if (answer == wxID_YES)
			return saveMap();
		else if (answer == wxID_CANCEL)
			return false;
	}

	return true;
}
Beispiel #11
0
bool MapInfo::saveFile(QString filePath){
    //save file
    QFile saveMap(filePath);
    //control if can save
    if(!saveMap.open(QFile::WriteOnly | QFile::Text))
        return false;
    //save text
    QTextStream out(&saveMap);
    out << mapToString();
    out << backgroundToString();
    out << itemsToString();
    saveMap.close();
    //return true if everything is OK
    return true;

}
Beispiel #12
0
bool MapEditor::saveCheck()
{
    if(!needSave())
        return false;

    QMessageBox::StandardButton ret = QMessageBox::warning(this, tr("Attention"), tr("Tout travail non sauvegardé sera perdu.\nQue faire ?"), QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel);
    if(ret == QMessageBox::Cancel)
        return true;

    if(ret == QMessageBox::Discard)
        return false;

    if(ret == QMessageBox::Save)
        return saveMap();

    return true;
}
Beispiel #13
0
//--------------------------------------------------------------
void testApp::exit(){
    //kinect.setCameraTiltAngle(0);
	kinect.close();

     for(int i=0;i<people.size();i++){
        delete people[i];
    }

    gui->saveSettings("GUI/guiSettings.xml");

    saveMap();
    saveZones();

    delete tmpMapMask;
    delete tmpZonesMask;

    delete gui;
}
Beispiel #14
0
int EditorArea::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: changeTile(); break;
        case 1: saveGame((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: saveMap((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 3: addNpcToMap((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: addObjectToMap((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Beispiel #15
0
//save encoding-result to outputfile
void Huffman::saveToFile()
{
	outFile_.open(outFilename_.c_str(),ios::out);
	outFile_.clear();
	saveBitSize();// output the number of bits
	saveMap();// output mapping-data
	string str;
	inFile_.open(inFileName_.c_str(),ios::in);
	inFile_.clear();
	unsigned char c = inFile_.get();
	while(!inFile_.eof())
	{
		str += nodeArray_[c]->code_;
		c = inFile_.get();
	}
	inFile_.close();
	//output encoding-codes, the unit is byte
	unsigned char buffer = 0;
	int k = 0;
	long long bitCount = 0;
	for(int i=0;i<str.length();i++)
	{
		if(str[i] == '1')
			buffer++;
		k++;
		if(k == 8)
		{
			outFile_ << buffer;
			bitCount += 8;
			buffer = 0;
			k = 0;
			continue;
		}
		buffer <<= 1;
	}
	if(bitCount != bitSize_)
	{
		for (int i = 0; i < 7-bitSize_+bitCount; ++i)
			buffer <<= 1;
		outFile_ << buffer;
	}
	outFile_.close();
}
void Config(ptam::PTAMVisualizerParamsConfig& config, uint32_t level)
{
  show_pc_ = true;//config.ShowPC;
  show_kfs_ = true;//config.ShowKFs;
  show_all_kfs_ = true;//config.ShowAllKFs;
  kf_lifetime_ = config.KFLifetime;
  show_path_ = true;//config.ShowPath;
  KFFlags_ = config.KFFlags;
  path_length_ = config.PathLength;
  if(config.ExportPC)
  {
    config.ExportPC=false;
    exportPC(config.ExportPrefix);
  }
  if(config.SaveMap)
  {
    config.SaveMap=false;
    saveMap(config.ExportPrefix);
  }
}
void CorrelateMain::update()
{
	if (bangLoad->getBang())
		loadData();
	
	if (bangEvaluate->getBang())
		evaluate();
	
	if (bangLoadCalibration->getBang())
	{
		calibration.load();
		bangEvaluate->enabled = true;
	}
	
	if (bangSave3DScan->getBang())
		saveScan();

	if (bangSaveMap->getBang())
		saveMap();
    
    if (bangAddToImage->getBang())
        addToImage();
    
    if (bangSaveImage->getBang())
        saveImage();
    
    if (bangClearImage->getBang())
        clearImage();
	
	ofVec3f& lbf(scanSet.lbf);
    ofVec3f& rtb(scanSet.rtb);
	
	if (rtb.x < lbf.x)
		rtb.x = lbf.x;
	if (rtb.y < lbf.y)
		rtb.y = lbf.y;
	if (rtb.z < lbf.z)
		rtb.z = lbf.z;
	
}
Beispiel #18
0
/* MapEditorWindow::openMap
 * Opens [map] in the editor
 *******************************************************************/
bool MapEditorWindow::openMap(Archive::mapdesc_t map)
{
	// If a map is currently open and modified, prompt to save changes
	if (editor.getMap().isModified())
	{
		wxMessageDialog md(this, S_FMT("Save changes to map %s?", currentMapDesc().name), "Unsaved Changes", wxYES_NO | wxCANCEL);
		int answer = md.ShowModal();
		if (answer == wxID_YES)
			saveMap();
		else if (answer == wxID_CANCEL)
			return true;
	}

	// Show blank map
	this->Show(true);
	map_canvas->Refresh();
	Layout();
	Update();
	Refresh();

	// Clear current map data
	for (unsigned a = 0; a < map_data.size(); a++)
		delete map_data[a];
	map_data.clear();

	// Get map parent archive
	Archive* archive = NULL;
	if (map.head)
	{
		archive = map.head->getParent();

		// Load map data
		if (map.archive)
		{
			WadArchive temp;
			temp.open(map.head->getMCData());
			for (unsigned a = 0; a < temp.numEntries(); a++)
				map_data.push_back(new ArchiveEntry(*(temp.getEntry(a))));
		}
		else
		{
			ArchiveEntry* entry = map.head;
			while (entry)
			{
				bool end = (entry == map.end);
				map_data.push_back(new ArchiveEntry(*entry));
				entry = entry->nextEntry();
				if (end)
					break;
			}
		}
	}

	// Set texture manager archive
	tex_man.setArchive(archive);

	// Clear current map
	closeMap();

	// Attempt to open map
	theSplashWindow->show("Loading Map", true, this);
	bool ok = editor.openMap(map);
	theSplashWindow->hide();

	// Show window if opened ok
	if (ok)
	{
		mdesc_current = map;

		// Read DECORATE definitions if any
		theGameConfiguration->parseDecorateDefs(theArchiveManager->baseResourceArchive());
		for (int i = 0; i < theArchiveManager->numArchives(); ++i)
			theGameConfiguration->parseDecorateDefs(theArchiveManager->getArchive(i));

		// Load scripts if any
		loadMapScripts(map);

		// Lock map entries
		lockMapEntries();

		// Reset map checks panel
		panel_checks->reset();

		map_canvas->viewFitToMap(true);
		map_canvas->Refresh();

		// Set window title
		if (archive)
			SetTitle(S_FMT("SLADE - %s of %s", map.name, archive->getFilename(false)));
		else
			SetTitle(S_FMT("SLADE - %s (UNSAVED)", map.name));

		// Create backup
		if (map.head && !backup_manager->writeBackup(map_data, map.head->getTopParent()->getFilename(false), map.head->getName(true)))
			LOG_MESSAGE(1, "Warning: Failed to backup map data");
	}

	return ok;
}
Beispiel #19
0
static void eventHandler(objectKey key, windowEvent *event)
{
	int status = 0;
	int selected = 0;
	char *fullName = NULL;
	char *dirName = NULL;

	// Check for window events.
	if (key == window)
	{
		// Check for window refresh
		if (event->type == EVENT_WINDOW_REFRESH)
			refreshWindow();

		// Check for the window being closed
		else if (event->type == EVENT_WINDOW_CLOSE)
			windowGuiStop();
	}

	else if ((key == mapList) && (event->type & EVENT_SELECTION) &&
		(event->type & EVENT_MOUSE_DOWN))
	{
		if (windowComponentGetSelected(mapList, &selected) < 0)
			return;
		if (loadMap(mapListParams[selected].text) < 0)
			return;
		makeKeyArray(selectedMap);
		updateKeyDiag(selectedMap);
	}

	else if ((key == saveButton) && (event->type == EVENT_MOUSE_LEFTUP))
	{
		fullName = malloc(MAX_PATH_NAME_LENGTH);
		if (!fullName)
			return;

		findMapFile(selectedMap->name, fullName);

		status = windowNewFileDialog(window, _("Save as"),
			_("Choose the output file:"), cwd, fullName, MAX_PATH_NAME_LENGTH,
			0);
		if (status != 1)
		{
			free(fullName);
			return;
		}

		status = saveMap(fullName);
		if (status < 0)
		{
			free(fullName);
			return;
		}

		// Are we working in a new directory?
		dirName = dirname(fullName);
		if (dirName)
		{
			strncpy(cwd, dirName, MAX_PATH_LENGTH);
			free(dirName);
		}

		free(fullName);

		if (getMapNameParams() < 0)
			return;

		windowComponentSetData(mapList, mapListParams, numMapNames,
			1 /* redraw */);

		selectMap(selectedMap->name);

		windowNewInfoDialog(window, _("Saved"), _("Map saved"));
	}

	else if ((key == defaultButton) && (event->type == EVENT_MOUSE_LEFTUP))
	{
		if (windowComponentGetSelected(mapList, &selected) < 0)
			return;
		if (setMap(mapListParams[selected].text) < 0)
			return;
		windowComponentSetData(currentNameLabel, mapListParams[selected].text,
			strlen(mapListParams[selected].text), 1 /* redraw */);
	}

	// Check for the window being closed by a GUI event.
	else if ((key == closeButton) && (event->type == EVENT_MOUSE_LEFTUP))
		windowGuiStop();
}
Beispiel #20
0
void doCursor()
{
	char name[MAX_VALUE_LENGTH];
	int x, y;

	cursor.x = input.mouseX;
	cursor.y = input.mouseY;

	if (cursor.type == TILES || cursor.snapToGrid == 1)
	{
		cursor.x /= TILE_SIZE;
		cursor.y /= TILE_SIZE;

		cursor.x *= TILE_SIZE;
		cursor.y *= TILE_SIZE;
	}

	if (cursor.y >= SCREEN_HEIGHT - TILE_SIZE)
	{
		cursor.y = SCREEN_HEIGHT - TILE_SIZE * 2;
	}

	if (input.left == 1)
	{
		mapStartXNext(-TILE_SIZE);
	}

	else if (input.right == 1)
	{
		mapStartXNext(TILE_SIZE);
	}

	if (input.up == 1)
	{
		mapStartYNext(-TILE_SIZE);
	}

	else if (input.down == 1)
	{
		mapStartYNext(TILE_SIZE);
	}

	if (input.snap == 1)
	{
		cursor.snapToGrid = 1 - cursor.snapToGrid;

		input.snap = 0;
	}

	if (input.activate == 1)
	{
		cursor.entity.face = (cursor.entity.face == RIGHT ? LEFT : RIGHT);

		input.activate = 0;
	}

	if (input.block == 1)
	{
		if (cursor.type == TILES)
		{
			x = (getMapStartX() + cursor.x) / TILE_SIZE;
			y = (getMapStartY() + cursor.y) / TILE_SIZE;

			while (mapTileAt(x, y) == BLANK_TILE && x >= 0)
			{
				setTileAt(x, y, cursor.tileID);

				x--;
			}

			x = (getMapStartX() + cursor.x) / TILE_SIZE;

			x++;

			while (mapTileAt(x, y) == BLANK_TILE && x < MAX_MAP_X)
			{
				setTileAt(x, y, cursor.tileID);

				x++;
			}
		}
	}

	if (input.add == 1)
	{
		if (cursor.type == TILES)
		{
			setTileAt((getMapStartX() + cursor.x) / TILE_SIZE, (getMapStartY() + cursor.y) / TILE_SIZE, cursor.tileID);
		}

		else
		{
			/* Entities can only be placed in blank spaces */

			if (isValidOnMap(&cursor.entity) == 1 && isSpaceEmpty(&cursor.entity) == NULL)
			{
				if (cursor.entityType == 0)
				{
					setPlayerLocation(getMapStartX() + cursor.x, getMapStartY() + cursor.y);
				}

				else
				{
					if (strcmpignorecase(cursor.entity.name, "lift/lift_target") == 0)
					{
						snprintf(name, sizeof(name), "NEW_TARGET_%03d", targetID);

						addTarget(getMapStartX() + cursor.x, getMapStartY() + cursor.y, name);

						targetID++;
					}

					else
					{
						cursor.entity.startX = getMapStartX() + cursor.x;
						cursor.entity.startY = getMapStartY() + cursor.y;

						cursor.entity.endX = getMapStartX() + cursor.x;
						cursor.entity.endY = getMapStartY() + cursor.y;

						addEntity(cursor.entity, getMapStartX() + cursor.x, getMapStartY() + cursor.y);
					}
				}
			}

			input.add = 0;
		}
	}

	else if (input.remove == 1)
	{
		if (cursor.type == TILES)
		{
			setTileAt((getMapStartX() + cursor.x) / TILE_SIZE, (getMapStartY() + cursor.y) / TILE_SIZE, BLANK_TILE);
		}

		else
		{
			self = isSpaceEmpty(&cursor.entity);

			if (self != NULL)
			{
				self->inUse = FALSE;
			}
		}
	}

	if (input.cut == 1)
	{
		if (cursor.type != TILES)
		{
			self = isSpaceEmpty(&cursor.entity);

			if (self != NULL)
			{
				cursor.entity = *self;

				self->inUse = FALSE;
			}
		}

		input.cut = 0;
	}

	if (input.previous == 1)
	{
		if (cursor.type == TILES)
		{
			cursor.tileID = prevTile(cursor.tileID);
		}

		else
		{
			cursor.entityType--;

			if (cursor.entityType < 0)
			{
				cursor.entityType = entityNamesLength - 1;
			}

			memset(&cursor.entity, 0, sizeof(Entity));

			cursor.entity.draw = &drawLoopingAnimationToMap;

			cursor.entity.weight = 0;

			cursor.entity.originalWeight = 0;

			cursor.entity.inUse = TRUE;

			loadProperties(entityNames[cursor.entityType], &cursor.entity);

			cursor.entity.active = TRUE;

			cursor.entity.alpha = 255;

			if (cursor.entity.weight == 0)
			{
				cursor.entity.weight = 1;

				cursor.entity.originalWeight = 1;
			}
		}

		input.previous = 0;
	}

	else if (input.next == 1)
	{
		if (cursor.type == TILES)
		{
			cursor.tileID = nextTile(cursor.tileID);
		}

		else
		{
			cursor.entityType++;

			if (cursor.entityType >= entityNamesLength)
			{
				cursor.entityType = 0;
			}

			memset(&cursor.entity, 0, sizeof(Entity));

			cursor.entity.draw = &drawLoopingAnimationToMap;

			cursor.entity.weight = 0;

			cursor.entity.originalWeight = 1;

			cursor.entity.inUse = TRUE;

			loadProperties(entityNames[cursor.entityType], &cursor.entity);

			cursor.entity.active = TRUE;

			cursor.entity.alpha = 255;

			if (cursor.entity.weight == 0)
			{
				cursor.entity.weight = 1;

				cursor.entity.originalWeight = 1;
			}
		}

		input.next = 0;
	}

	if (input.save == 1)
	{
		if (saveMap() == TRUE)
		{
			setStatusPanelMessage("Saved");
		}

		else
		{
			setStatusPanelMessage("Saving Failed");
		}

		input.save = 0;
	}
	/*
	if (input.load == 1)
	{
		loadMap(map.filename);

		printf("Loaded\n");

		input.load = 0;
	}
	*/
	if (input.left == 1 || input.right == 1 || input.up == 1 || input.down == 1)
	{
		SDL_Delay(30);
	}

	if (input.toggle == 1)
	{
		if (cursor.type == TILES)
		{
			cursor.type = ENTITIES;
		}

		else
		{
			cursor.type = TILES;
		}

		input.toggle = 0;
	}

	centerMapOnEntity(NULL);
}
Beispiel #21
0
void initDB(){
    openDb();
    createStateTabl();
    createMapTable();
    saveMap(getTest().graph, "firstMap");
}
Beispiel #22
0
/* MapEditorWindow::handleAction
 * Handles the action [id]. Returns true if the action was handled,
 * false otherwise
 *******************************************************************/
bool MapEditorWindow::handleAction(string id)
{
	// Don't handle actions if hidden
	if (!IsShown())
		return false;

	// Map->Save
	if (id == "mapw_save")
	{
		// Save map
		if (saveMap())
		{
			// Save archive
			Archive* a = currentMapDesc().head->getParent();
			if (a && save_archive_with_map) a->save();
		}

		return true;
	}

	// Map->Save As
	if (id == "mapw_saveas")
	{
		saveMapAs();
		return true;
	}

	// Map->Restore Backup
	if (id == "mapw_backup")
	{
		if (mdesc_current.head)
		{
			Archive* data = backup_manager->openBackup(mdesc_current.head->getTopParent()->getFilename(false), mdesc_current.name);
			if (data)
			{
				vector<Archive::mapdesc_t> maps = data->detectMaps();
				if (!maps.empty())
				{
					editor.getMap().clearMap();
					editor.openMap(maps[0]);
					loadMapScripts(maps[0]);
				}
			}
		}

		return true;
	}

	// Edit->Undo
	if (id == "mapw_undo")
	{
		editor.doUndo();
		return true;
	}

	// Edit->Redo
	if (id == "mapw_redo")
	{
		editor.doRedo();
		return true;
	}

	// Editor->Set Base Resource Archive
	if (id == "mapw_setbra")
	{
		wxDialog dialog_ebr(this, -1, "Edit Base Resource Archives", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
		BaseResourceArchivesPanel brap(&dialog_ebr);

		wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
		sizer->Add(&brap, 1, wxEXPAND|wxALL, 4);

		sizer->Add(dialog_ebr.CreateButtonSizer(wxOK|wxCANCEL), 0, wxEXPAND|wxLEFT|wxRIGHT|wxDOWN, 4);

		dialog_ebr.SetSizer(sizer);
		dialog_ebr.Layout();
		dialog_ebr.SetInitialSize(wxSize(500, 300));
		dialog_ebr.CenterOnParent();
		if (dialog_ebr.ShowModal() == wxID_OK)
			theArchiveManager->openBaseResource(brap.getSelectedPath());

		return true;
	}

	// Editor->Preferences
	if (id == "mapw_preferences")
	{
		PreferencesDialog::openPreferences(this);

		return true;
	}

	// View->Item Properties
	if (id == "mapw_showproperties")
	{
		wxAuiManager* m_mgr = wxAuiManager::GetManager(this);
		wxAuiPaneInfo& p_inf = m_mgr->GetPane("item_props");

		// Toggle window and focus
		p_inf.Show(!p_inf.IsShown());
		map_canvas->SetFocus();

		m_mgr->Update();
		return true;
	}

	// View->Console
	else if (id == "mapw_showconsole")
	{
		wxAuiManager* m_mgr = wxAuiManager::GetManager(this);
		wxAuiPaneInfo& p_inf = m_mgr->GetPane("console");

		// Toggle window and focus
		if (p_inf.IsShown())
		{
			p_inf.Show(false);
			map_canvas->SetFocus();
		}
		else
		{
			p_inf.Show(true);
			p_inf.window->SetFocus();
		}

		p_inf.MinSize(200, 128);
		m_mgr->Update();
		return true;
	}

	// View->Script Editor
	else if (id == "mapw_showscripteditor")
	{
		wxAuiManager* m_mgr = wxAuiManager::GetManager(this);
		wxAuiPaneInfo& p_inf = m_mgr->GetPane("script_editor");

		// Toggle window and focus
		if (p_inf.IsShown())
		{
			p_inf.Show(false);
			map_canvas->SetFocus();
		}
		else if (!theGameConfiguration->scriptLanguage().IsEmpty())
		{
			p_inf.Show(true);
			p_inf.window->SetFocus();
		}

		p_inf.MinSize(200, 128);
		m_mgr->Update();
		return true;
	}

	// View->Map Checks
	else if (id == "mapw_showchecks")
	{
		wxAuiManager* m_mgr = wxAuiManager::GetManager(this);
		wxAuiPaneInfo& p_inf = m_mgr->GetPane("map_checks");

		// Toggle window and focus
		if (p_inf.IsShown())
		{
			p_inf.Show(false);
			map_canvas->SetFocus();
		}
		else
		{
			p_inf.Show(true);
			p_inf.window->SetFocus();
		}

		//p_inf.MinSize(200, 128);
		m_mgr->Update();
		return true;
	}

	// View->Undo History
	else if (id == "mapw_showundohistory")
	{
		wxAuiManager* m_mgr = wxAuiManager::GetManager(this);
		wxAuiPaneInfo& p_inf = m_mgr->GetPane("undo_history");

		// Toggle window
		p_inf.Show(!p_inf.IsShown());

		m_mgr->Update();
		return true;
	}

	// Run Map
	else if (id == "mapw_run_map")
	{
		Archive* archive = NULL;
		if (mdesc_current.head)
			archive = mdesc_current.head->getParent();
		RunDialog dlg(this, archive);
		if (dlg.ShowModal() == wxID_OK)
		{
			WadArchive* wad = writeMap(mdesc_current.name);
			if (wad)
				wad->save(appPath("sladetemp_run.wad", DIR_TEMP));

			string command = dlg.getSelectedCommandLine(archive, mdesc_current.name, wad->getFilename());
			if (!command.IsEmpty())
			{
				// Set working directory
				string wd = wxGetCwd();
				wxSetWorkingDirectory(dlg.getSelectedExeDir());

				// Run
				wxExecute(command, wxEXEC_ASYNC);

				// Restore working directory
				wxSetWorkingDirectory(wd);
			}
		}

		return true;
	}
	
	return false;
}
Beispiel #23
0
MapEditor::MapEditor(QWidget* par, const QString& map, const QString& ressourceList):QMainWindow(par)
{
    m_mapWidget = NULL; m_currentItemIndex=0;

    pgrdia=new QProgressDialog(tr("Chargement en cours..."), tr("Veuillez patienter.."), 0, 100, this);
    pgrdia->setWindowModality(Qt::WindowModal);
    pgrdia->setMinimumDuration(100);
    pgrdia->hide();

    setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
    setDockNestingEnabled(true);

    m_rsRegExp.setPatternSyntax(QRegExp::Wildcard);

    setWindowTitle(tr("Éditeur de carte"));

    { ///MAP PROPERTIES DOCK
    QDockWidget* dw_mapProperties = new QDockWidget(tr("Propriétés de la carte"), this);
    dw_mapProperties->setWhatsThis(tr("Un dock regroupant quelques propriétés de la carte"));
    dw_mapProperties->setFeatures(QDockWidget::NoDockWidgetFeatures);
    dw_mapProperties->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    QWidget *w_mapProperties = new QWidget(dw_mapProperties);
    dw_mapProperties->setWidget(w_mapProperties);

    addDockWidget(Qt::TopDockWidgetArea, dw_mapProperties);

    QVBoxLayout *l_mapProperties = new QVBoxLayout(w_mapProperties);
    w_mapProperties->setLayout(l_mapProperties);

    {
        QHBoxLayout *lay=new QHBoxLayout();
        l_mapProperties->addLayout(lay);
        m_mapSizeX = new QSpinBox(this);
        m_mapSizeX->setRange(0,MAP_MAX_SIZE);
        m_mapSizeX->setEnabled(false);
        lay->addWidget(m_mapSizeX);


        m_mapSizeY = new QSpinBox(this);
        m_mapSizeY->setRange(0,MAP_MAX_SIZE);
        m_mapSizeY->setEnabled(false);
        lay->addWidget(m_mapSizeY);
    }
    {
        m_mapNameLabel=new QLabel(this);
        l_mapProperties->addWidget(m_mapNameLabel);
        m_sendingBtn=new QPushButton(tr("(MJ) Envoyer la carte au serveur"), this);
        l_mapProperties->addWidget(m_sendingBtn);
        setSendingButtonEnabled(false);
        connect(m_sendingBtn, SIGNAL(pressed()), this, SLOT(btnMapSend()));
    }
    }

    { ///CASE PROPERTIES DOCK
    QDockWidget* dw_caseProperties = new QDockWidget(tr("Propriétés de la case"), this);
    dw_caseProperties->setWhatsThis(tr("Un dock regroupant quelques propriétés de la case sélectionnée"));
    dw_caseProperties->setFeatures(QDockWidget::NoDockWidgetFeatures);
    dw_caseProperties->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    QWidget *w_caseProperties = new QWidget(dw_caseProperties);
    dw_caseProperties->setWidget(w_caseProperties);

    addDockWidget(Qt::RightDockWidgetArea, dw_caseProperties);

    QVBoxLayout *l_caseProperties = new QVBoxLayout(w_caseProperties);
    w_caseProperties->setLayout(l_caseProperties);

    {

        m_selectedCaseLabel = new QLabel(this);
        l_caseProperties->addWidget(m_selectedCaseLabel);

        m_selectedCaseRSID = new QSpinBox(this);
        m_selectedCaseRSID->setRange(0,MAX_LOADED_RESSOURCES);
        m_selectedCaseRSID->setEnabled(false);
        l_caseProperties->addWidget(m_selectedCaseRSID);
        connect(m_selectedCaseRSID, SIGNAL(valueChanged(int)), this, SLOT(changeCurrentCaseRSID(int)));

        {
            QGroupBox* gb = new QGroupBox(tr("Objets sur la case :"), this);
            m_mapCaseItemList = new QListWidget(this);
            connect(m_mapCaseItemList, SIGNAL(clicked(const QModelIndex&)), this, SLOT(selectMapItem(const QModelIndex&)));
            m_addItem = new QPushButton(tr("Ajouter un objet"), this);
            m_addItem->setEnabled(false);
            connect(m_addItem, SIGNAL(pressed()), this, SLOT(addMapObject()));
            QVBoxLayout* lyt = new QVBoxLayout();
            gb->setLayout(lyt); lyt->addWidget(m_mapCaseItemList); lyt->addWidget(m_addItem);
            l_caseProperties->addWidget(gb);
        }
    }
    }

    { ///MAPITEMS DOCK
    QDockWidget* dw_mapItems = new QDockWidget(tr("Objets de la carte"), this);
    dw_mapItems->setWhatsThis(tr("Un dock permettant la gestion des objets de la carte"));
    dw_mapItems->setFeatures(QDockWidget::NoDockWidgetFeatures);
    dw_mapItems->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    QWidget *w_mapItems = new QWidget(dw_mapItems);
    dw_mapItems->setWidget(w_mapItems);

    addDockWidget(Qt::RightDockWidgetArea, dw_mapItems);

    QVBoxLayout *l_mapItems = new QVBoxLayout(w_mapItems);
    w_mapItems->setLayout(l_mapItems);
    {
        m_mapItemList = new QListWidget(this);
        connect(m_mapItemList, SIGNAL(clicked(const QModelIndex&)), this, SLOT(selectMapItem(const QModelIndex&)));
        l_mapItems->addWidget(m_mapItemList);
        m_mapItemName = new QLabel(this);
        l_mapItems->addWidget(m_mapItemName);
        m_mapItemRSID = new QSpinBox(this); m_mapItemRSID->setRange(0,MAX_LOADED_RESSOURCES); m_mapItemRSID->setPrefix(tr("RSID : ")); m_mapItemRSID->setEnabled(false);
        l_mapItems->addWidget(m_mapItemRSID);
        m_mapItemPos = new QLabel(this);
        l_mapItems->addWidget(m_mapItemPos);
        l_mapItems->addWidget(new QLabel(tr("Teinte :"), this));
        m_mapItemColorViewer = new QColorViewer(this);
        l_mapItems->addWidget(m_mapItemColorViewer);
        m_removeItem = new QPushButton(tr("Supprimer l'objet"), this);
        l_mapItems->addWidget(m_removeItem);
        connect(m_removeItem, SIGNAL(pressed()), this, SLOT(removeMapObject()));
    }

    }

    { ///RSSMNGR PROPERTIES DOCK
    QDockWidget* dw_rssMngrProperties = new QDockWidget(tr("Gestionnaire de ressources"), this);
    dw_rssMngrProperties->setWhatsThis(tr("Un dock regroupant les différentes ressources chargées dans l'éditeur"));
    dw_rssMngrProperties->setFeatures(QDockWidget::NoDockWidgetFeatures);
    dw_rssMngrProperties->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    QWidget *w_rssMngrProperties = new QWidget(dw_rssMngrProperties);
    dw_rssMngrProperties->setWidget(w_rssMngrProperties);

    addDockWidget(Qt::RightDockWidgetArea, dw_rssMngrProperties);
    QVBoxLayout *l_rssMngrProperties = new QVBoxLayout(w_rssMngrProperties);
    w_rssMngrProperties->setLayout(l_rssMngrProperties);
    {
        m_rsMngrFilter = new QLineEdit(this); m_rsMngrFilter->setPlaceholderText(tr("Filtre..."));
        connect(m_rsMngrFilter, SIGNAL(textEdited(const QString&)),this, SLOT(changeRsMngrFilter(const QString&)));
        l_rssMngrProperties->addWidget(m_rsMngrFilter);

        m_rsMngrWidget = new QTableWidget(0,2, this);
        m_rsMngrWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
        m_rsMngrWidget->setSelectionMode(QAbstractItemView::SingleSelection);
        m_rsMngrWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
        m_rsMngrWidget->setSortingEnabled(true);
        m_rsMngrWidget->verticalHeader()->hide();
        l_rssMngrProperties->addWidget(m_rsMngrWidget);

        m_rsMngrEdit = new QPushButton(tr("Modifier..."), this);
        m_rsMngrEdit->setEnabled(false);
        l_rssMngrProperties->addWidget(m_rsMngrEdit);

        connect(m_rsMngrEdit, SIGNAL(pressed()), this, SLOT(modifyRssMngr()));

        m_rsMngrAdd = new QPushButton(tr("Ajouter..."), this);
        m_rsMngrAdd->setEnabled(false);
        l_rssMngrProperties->addWidget(m_rsMngrAdd);

        connect(m_rsMngrAdd, SIGNAL(pressed()), this, SLOT(addRssMngr()));
    }
    }

    QMenu *fileMenu = menuBar()->addMenu(tr("&Fichier"));

    QAction *ac_new= fileMenu->addAction(tr("&Nouvelle carte..."));
    connect(ac_new, SIGNAL(triggered()), this, SLOT(newMap()));

    QAction *ac_open= fileMenu->addAction(tr("&Charger une carte..."));
    connect(ac_open, SIGNAL(triggered()), this, SLOT(loadMap()));

    QAction *ac_save = fileMenu->addAction(tr("Sauvegarder &la carte..."));
    connect(ac_save, SIGNAL(triggered()), this, SLOT(saveMap()));

    QAction *ac_saveAs = fileMenu->addAction(tr("Sa&uvegarder la carte sous..."));
    connect(ac_saveAs, SIGNAL(triggered()), this, SLOT(saveMapAs()));

    QAction *ac_quit = fileMenu->addAction(tr("&Quitter..."));
    connect(ac_quit, SIGNAL(triggered()), this, SLOT(close()));


    QMenu *toolMenu = menuBar()->addMenu(tr("&Outils"));
    QAction *ac_replace= toolMenu->addAction(tr("&Remplacer..."));
    connect(ac_replace, SIGNAL(triggered()), this, SLOT(replaceRSID()));
    QAction *ac_copy= toolMenu->addAction(tr("Copier...")); ac_copy->setShortcut(QKeySequence::Copy);
    connect(ac_copy, SIGNAL(triggered()), this, SLOT(copy()));
    QAction *ac_paste= toolMenu->addAction(tr("Coller...")); ac_paste->setShortcut(QKeySequence::Paste);
    connect(ac_paste, SIGNAL(triggered()), this, SLOT(paste()));

    QMenu *exportMenu = menuBar()->addMenu(tr("&Export"));
    QAction *ac_ex_rss= exportMenu->addAction(tr("... la liste de ressources"));
    connect(ac_ex_rss,SIGNAL(triggered()),this,SLOT(exportRss()));
    QAction *ac_ex_map= exportMenu->addAction(tr("... la matrice de la carte"));
    connect(ac_ex_map,SIGNAL(triggered()),this,SLOT(exportMap()));


    m_hoveredCaseLabel = new QLabel(this);
    statusBar()->addWidget(m_hoveredCaseLabel);

    m_mapName=map;
    m_ressourcePackName=ressourceList;
    if(!map.isEmpty())
    {
        loadMap(map,m_ressourcePackName);
    }

    enableMapSystem(false);
}
Beispiel #24
0
int main(int argc, char *argv[])
{
	int status = 0;
	int print = 0;
	char *mapName = NULL;
	char *saveName = NULL;
	char *dirName = NULL;
	char opt;
	int count;

	setlocale(LC_ALL, getenv(ENV_LANG));
	textdomain("keymap");

	// Graphics enabled?
	graphics = graphicsAreEnabled();

	// Check options
	while (strchr("psT:?", (opt = getopt(argc, argv, "ps:T"))))
	{
		switch (opt)
		{
			case 'p':
				// Just print out the map, if we're in text mode
				print = 1;
				break;

			case 's':
				// Save the map to a file
				if (!optarg)
				{
					fprintf(stderr, "%s", _("Missing filename argument for -s "
						"option\n"));
					usage(argv[0]);
					return (status = ERR_NULLPARAMETER);
				}
				saveName = optarg;
				break;

			case 'T':
				// Force text mode
				graphics = 0;
				break;

			case ':':
				fprintf(stderr, _("Missing parameter for %s option\n"),
					argv[optind - 1]);
				usage(argv[0]);
				return (status = ERR_NULLPARAMETER);

			default:
				fprintf(stderr, _("Unknown option '%c'\n"), optopt);
				usage(argv[0]);
				return (status = ERR_INVALID);
		}
	}

	cwd = malloc(MAX_PATH_LENGTH);
	selectedMap = malloc(sizeof(keyMap));
	if (!cwd || !selectedMap)
	{
		status = ERR_MEMORY;
		goto out;
	}

	strncpy(cwd, PATH_SYSTEM_KEYMAPS, MAX_PATH_LENGTH);

	// Get the current map
	status = keyboardGetMap(selectedMap);
	if (status < 0)
		goto out;

	strncpy(currentName, selectedMap->name, KEYMAP_NAMELEN);
	mapName = selectedMap->name;

	// Did the user supply either a map name or a key map file name?
	if ((argc > 1) && (optind < argc))
	{
		// Is it a file name?
		status = fileFind(argv[optind], NULL);
		if (status >= 0)
		{
			status = readMap(argv[optind], selectedMap);
			if (status < 0)
				goto out;

			mapName = selectedMap->name;

			dirName = dirname(argv[optind]);
			if (dirName)
			{
				strncpy(cwd, dirName, MAX_PATH_LENGTH);
				free(dirName);
			}
		}
		else
		{
			// Assume we've been given a map name.
			mapName = argv[optind];
		}

		if (!graphics && !saveName && !print)
		{
			// The user wants to set the current keyboard map to the supplied
			// name.
			status = setMap(mapName);
			goto out;
		}

		// Load the supplied map name
		status = loadMap(mapName);
		if (status < 0)
			goto out;
	}

	keyArray = malloc(KEYBOARD_SCAN_CODES * sizeof(scanKey));
	if (!keyArray)
	{
		status = ERR_MEMORY;
		goto out;
	}

	// Make the initial key array based on the current map.
	makeKeyArray(selectedMap);

	if (saveName)
	{
		// The user wants to save the current keyboard map to the supplied
		// file name.
		status = saveMap(saveName);
		goto out;
	}

	status = getMapNameParams();
	if (status < 0)
		goto out;

	if (graphics)
	{
		// Make our window
		constructWindow();

		// Run the GUI
		windowGuiRun();

		// ...and when we come back...
		windowDestroy(window);
	}
	else
	{
		if (print)
		{
			// Print out the whole keyboard for the selected map
			printKeyboard();
		}
		else
		{
			// Just print the list of map names
			printf("\n");

			for (count = 0; count < numMapNames; count ++)
				printf("%s%s\n", mapListParams[count].text,
					(!strcmp(mapListParams[count].text, selectedMap->name)?
						_(" (current)") : ""));
		}
	}

	status = 0;

out:
	if (cwd)
		free(cwd);
	if (selectedMap)
		free(selectedMap);
	if (mapListParams)
		free(mapListParams);
	if (keyArray)
		free(keyArray);

	return (status);
}
Beispiel #25
0
void consoleCommand(char *command_str) {
	node_t *node;
	Entity *entity;
	char name[64];
	int c;
	
	if( !command_str )
		return;

	if( !strncmp(command_str,"/ping",5) ) {
		if( multiplayer != CLIENT ) {
			messagePlayer(clientnum,language[1117],0);
		} else {
			strcpy((char *)net_packet->data,"PING");
			net_packet->data[4] = clientnum;
			net_packet->address.host = net_server.host;
			net_packet->address.port = net_server.port;
			net_packet->len = 5;
			sendPacketSafe(net_sock, -1, net_packet, 0);
			pingtime = SDL_GetTicks();
		}
	}
	else if (!strncmp(command_str, "/fov", 4)) {
		fov = atoi(&command_str[5]);
		fov = std::min(std::max<Uint32>(40,fov),100u);
	}
	else if (!strncmp(command_str, "/svflags ", 9)) {
		if( multiplayer==CLIENT ) {
			messagePlayer(clientnum,language[275]);
		} else {
			svFlags = atoi(&command_str[9]);
			messagePlayer(clientnum,language[276]);

			if( multiplayer==SERVER ) {
				// update client flags
				strcpy((char *)net_packet->data,"SVFL");
				SDLNet_Write32(svFlags,&net_packet->data[4]);
				net_packet->len = 8;

				int c;
				for( c=1; c<MAXPLAYERS; c++ ) {
					if( client_disconnected[c] )
						continue;
					net_packet->address.host = net_clients[c-1].host;
					net_packet->address.port = net_clients[c-1].port;
					sendPacketSafe(net_sock, -1, net_packet, c-1);
					messagePlayer(c,language[276]);
				}
			}
		}
	}
	else if( !strncmp(command_str,"/spawnitem ",11) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		strcpy(name,command_str+11);
		for( c=0; c<NUMITEMS; c++ ) {
			if( strstr(items[c].name_identified, name) ) {
				dropItem(newItem(static_cast<ItemType>(c),EXCELLENT,0,1,rand(),TRUE,&stats[clientnum].inventory),0);
				break;
			}
		}
		if( c==NUMITEMS ) {
			messagePlayer(clientnum,language[278],name);
		}
	}
	else if( !strncmp(command_str,"/spawncursed ",13) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		strcpy(name,command_str+13);
		for( c=0; c<NUMITEMS; c++ ) {
			if( strstr(items[c].name_identified, name) ) {
				dropItem(newItem(static_cast<ItemType>(c),WORN,-2,1,rand(),FALSE,&stats[clientnum].inventory),0);
				break;
			}
		}
		if( c==NUMITEMS ) {
			messagePlayer(clientnum,language[278],name);
		}
	}
	else if( !strncmp(command_str,"/kick ",6) ) {
		strcpy(name,command_str+6);
		if( multiplayer==SERVER ) {
			for( c=1; c<MAXPLAYERS; c++ ) {
				if( !client_disconnected[c] && !strncmp(name,stats[c].name,128) ) {
					client_disconnected[c] = TRUE;
					strcpy((char *)net_packet->data,"KICK");
					net_packet->address.host = net_clients[c-1].host;
					net_packet->address.port = net_clients[c-1].port;
					net_packet->len = 4;
					sendPacketSafe(net_sock, -1, net_packet, c-1);
					int i;
					for( i=0; i<MAXPLAYERS; i++ ) {
						messagePlayer(i,language[279],c,stats[c].name);
					}
					break;
				}
			}
			if( c==MAXPLAYERS ) {
				messagePlayer(clientnum,language[280]);
			}
		} else if( multiplayer==CLIENT ) {
			messagePlayer(clientnum,language[281]);
		} else {
			messagePlayer(clientnum,language[282]);
		}
	}
	else if( !strncmp(command_str,"/spawnbook ",11) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		strcpy(name,command_str+11);
		dropItem(newItem(READABLE_BOOK,EXCELLENT,0,1,getBook(name),TRUE,&stats[clientnum].inventory),0);
	}
	else if( !strncmp(command_str,"/savemap ",9) ) {
		if( command_str[9]!=0 ) {
			saveMap(command_str+9);
			messagePlayer(clientnum,language[283],command_str+9);
		}
	}
	else if( !strncmp(command_str,"/nextlevel",10) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		if( multiplayer==CLIENT ) {
			messagePlayer(clientnum,language[284]);
		} else {
			messagePlayer(clientnum,language[285]);
			loadnextlevel=TRUE;
		}
	}
	else if( !strncmp(command_str,"/pos",4) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		messagePlayer(clientnum,language[286],(int)camera.x,(int)camera.y,(int)camera.z,camera.ang,camera.vang);
	}
	else if( !strncmp(command_str,"/pathmap",4) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		if( players[clientnum] ) {
			int x = std::min<int>(std::max(0.0,floor(players[clientnum]->x/16)),map.width-1);
			int y = std::min<int>(std::max(0.0,floor(players[clientnum]->y/16)),map.height-1);
			messagePlayer(clientnum,"pathMapGrounded value: %d",pathMapGrounded[y+x*map.height]);
			messagePlayer(clientnum,"pathMapFlying value: %d",pathMapFlying[y+x*map.height]);
		}
	}
	else if( !strncmp(command_str,"/exit",5) ) {
		mainloop=0;
	}
	else if( !strncmp(command_str,"/showfps",8) ) {
		showfps=(showfps==FALSE);
	}
	else if( !strncmp(command_str,"/noclip",7) ) {
		if( multiplayer!=SINGLE ) {
			messagePlayer(clientnum,language[287]);
		} else {
			noclip=(noclip==FALSE);
			if( noclip )
				messagePlayer(clientnum,language[288]);
			else
				messagePlayer(clientnum,language[289]);
		}
	}
	else if( !strncmp(command_str,"/god",4) ) {
		if( multiplayer!=SINGLE ) {
			messagePlayer(clientnum,language[290]);
		} else {
			godmode=(godmode==FALSE);
			if( godmode )
				messagePlayer(clientnum,language[291]);
			else
				messagePlayer(clientnum,language[292]);
		}
	}
	else if( !strncmp(command_str,"/buddha",7) ) {
		if( multiplayer!=SINGLE ) {
			messagePlayer(clientnum,language[293]);
		} else {
			buddhamode=(buddhamode==FALSE);
			if( buddhamode )
				messagePlayer(clientnum,language[294]);
			else
				messagePlayer(clientnum,language[295]);
		}
	}
	else if( !strncmp(command_str,"/friendly",9) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		if( multiplayer==CLIENT ) {
			messagePlayer(clientnum,language[284]);
			return;
		}
		everybodyfriendly=(everybodyfriendly==FALSE);
		if( everybodyfriendly )
			messagePlayer(clientnum,language[296]);
		else
			messagePlayer(clientnum,language[297]);
	}
	else if( !strncmp(command_str,"/dowse",6) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		for( node=map.entities->first; node!=NULL; node=node->next ) {
			entity = (Entity *)node->element;
			if( entity->behavior == &actLadder )
				messagePlayer(clientnum,language[298],(int)(entity->x/16),(int)(entity->y/16));
		}
	}
	else if( !strncmp(command_str,"/thirdperson",12) ) {
		if( !(svFlags&SV_FLAG_CHEATS) ) {
			messagePlayer(clientnum,language[277]);
			return;
		}
		if( players[clientnum] != NULL ) {
			players[clientnum]->skill[3]=(players[clientnum]->skill[3]==0);
			if( players[clientnum]->skill[3]==1 )
				messagePlayer(clientnum,"thirdperson ON");
			else
				messagePlayer(clientnum,"thirdperson OFF");
		}
	}
	else if( !strncmp(command_str,"/res ",5) ) {
		xres = atoi(&command_str[5]);
		for( c=0; c<strlen(command_str); c++ ) {
			if( command_str[c] == 'x' ) {
				yres = atoi(&command_str[c+1]);
				break;
			}
		}
	}
	else if( !strncmp(command_str,"/rscale",7) ) {
		rscale = atoi(&command_str[8]);
	}
	else if( !strncmp(command_str,"/smoothlighting",15) ) {
		smoothlighting = (smoothlighting==0);
	}
	else if( !strncmp(command_str,"/fullscreen",11) ) {
		fullscreen = (fullscreen==0);
	}
	else if( !strncmp(command_str,"/shaking",8) ) {
		shaking = (shaking==0);
	}
	else if( !strncmp(command_str,"/bobbing",8) ) {
		bobbing = (bobbing==0);
	}
	else if( !strncmp(command_str,"/sfxvolume",10) ) {
		sfxvolume = atoi(&command_str[11]);
	}
	else if( !strncmp(command_str,"/musvolume",10) ) {
		musvolume = atoi(&command_str[11]);
	}
	else if( !strncmp(command_str,"/bind",5) ) {
		if( strstr(command_str,"IN_FORWARD") ) {
			impulses[IN_FORWARD] = atoi(&command_str[6]);
			printlog("Bound IN_FORWARD: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_LEFT") ) {
			impulses[IN_LEFT] = atoi(&command_str[6]);
			printlog("Bound IN_LEFT: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_BACK") ) {
			impulses[IN_BACK] = atoi(&command_str[6]);
			printlog("Bound IN_BACK: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_RIGHT") ) {
			impulses[IN_RIGHT] = atoi(&command_str[6]);
			printlog("Bound IN_RIGHT: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_TURNL") ) {
			impulses[IN_TURNL] = atoi(&command_str[6]);
			printlog("Bound IN_TURNL: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_TURNR") ) {
			impulses[IN_TURNR] = atoi(&command_str[6]);
			printlog("Bound IN_TURNR: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_UP") ) {
			impulses[IN_UP] = atoi(&command_str[6]);
			printlog("Bound IN_UP: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_DOWN") ) {
			impulses[IN_DOWN] = atoi(&command_str[6]);
			printlog("Bound IN_DOWN: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_CHAT") ) {
			impulses[IN_CHAT] = atoi(&command_str[6]);
			printlog("Bound IN_CHAT: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_COMMAND") ) {
			impulses[IN_COMMAND] = atoi(&command_str[6]);
			printlog("Bound IN_COMMAND: %d\n",atoi(&command_str[6]));
		} else if( strstr(command_str,"IN_STATUS") ) {
			impulses[IN_STATUS] = atoi(&command_str[6]);
			printlog("Bound IN_STATUS: %d\n",atoi(&command_str[6]));
		} else if (strstr(command_str, "IN_SPELL_LIST")) {
			impulses[IN_SPELL_LIST] = atoi(&command_str[6]);
			printlog( "Bound IN_SPELL_LIST: %d\n", atoi(&command_str[6]));
		} else if (strstr(command_str, "IN_CAST_SPELL")) {
			impulses[IN_CAST_SPELL] = atoi(&command_str[6]);
			printlog( "Bound IN_CAST_SPELL: %d\n", atoi(&command_str[6]));
		} else if (strstr(command_str, "IN_DEFEND")) {
			impulses[IN_DEFEND] = atoi(&command_str[6]);
			printlog( "Bound IN_DEFEND: %d\n", atoi(&command_str[6]));
		} else if (strstr(command_str, "IN_ATTACK")) {
			impulses[IN_ATTACK] = atoi(&command_str[6]);
			printlog( "Bound IN_ATTACK: %d\n", atoi(&command_str[6]));
		} else if (strstr(command_str, "IN_USE")) {
			impulses[IN_USE] = atoi(&command_str[6]);
			printlog( "Bound IN_USE: %d\n", atoi(&command_str[6]));
		} else {
			messagePlayer(clientnum,"Invalid binding.");
		}
	}
	else if( !strncmp(command_str,"/mousespeed",11) ) {
		mousespeed = atoi(&command_str[12]);
	}
	else if( !strncmp(command_str,"/reversemouse",13) ) {
		reversemouse = (reversemouse==0);
	}
	else if( !strncmp(command_str,"/smoothmouse",12) ) {
		smoothmouse = (smoothmouse==FALSE);
	}
	else if( !strncmp(command_str,"/mana", 4) ) {
		if( multiplayer == SINGLE ) {
			stats[clientnum].MP = stats[clientnum].MAXMP;
		} else {
			messagePlayer(clientnum,language[299]);
		}
	}
	else if( !strncmp(command_str,"/heal", 4) ) {
		if( multiplayer == SINGLE ) {
			stats[clientnum].HP = stats[clientnum].MAXHP;
		} else {
			messagePlayer(clientnum,language[299]);
		}
	}
	else if (!strncmp(command_str, "/ip ", 4)) {
		if( command_str[4]!=0 ) {
			strcpy(last_ip, command_str + 4);
			last_ip[strlen(last_ip)-1]=0;
		}
	}
	else if (!strncmp(command_str, "/port ", 6)) {
		if (command_str[6] != 0) {
			strcpy(last_port, command_str + 6);
			last_port[strlen(last_port)-1]=0;
		}
	}
	else if (!strncmp(command_str, "/noblood", 8)) {
		spawn_blood = (spawn_blood==FALSE);
	}
	else if(!strncmp(command_str, "/colorblind", 11)) {
		colorblind = (colorblind==FALSE);
	}
	else if (!strncmp(command_str, "/gamma", 6)) {
		std::stringstream ss;
		ss << command_str + 7;
		ss >> vidgamma;
	}