Example #1
0
File: Log.cpp Project: Xide/Corewar
Logger::Logger(std::string const& path, enum severity floor) {
  _log.open(path.c_str(), std::ofstream::out | std::ofstream::app);

  if (!_log.is_open()) throw LogException("Could not open log file : " + path);
  setFloor(floor);
  (*this)(NOTICE) << "Logger started on file " << path << "\n";
}
Example #2
0
bool FloorManager::load(Common::SeekableReadStream *stream) {
	if (stream->readByte()) {
		if (!setFloor(stream->readUint16BE()))
			return false;
	} else {
		setFloorNull();
	}
	return true;
}
Example #3
0
/**
 * sets a Tile as the goal for the players
 */
bool Tile::setGoal(bool goal)
{
	isGoal= goal;

	if (!goal)
	{
		setFloor(0);
	}

	return isGoal;
}
Example #4
0
void House::removeFloorTop() {
    for (int i = 0; i < getWidth() * getHeight(); i++) {
        SAFE_DELETE(floors[floors.size() - 1][i]);
    }
    SAFE_DELETE_ARRAY(floors[floors.size() - 1]);
    for (Room * room : rooms[rooms.size() - 1]) {
        SAFE_DELETE(room);
    }
    floors.pop_back();
    rooms.pop_back();
    setFloor(floorIndex - 1);
}
Example #5
0
void House::removeFloorBottom() {
    for (int i = 0; i < getWidth() * getHeight(); i++) {
        SAFE_DELETE(floors[0][i]);
    }
    SAFE_DELETE_ARRAY(floors[0]);
    for (Room * room : rooms[0]) {
        SAFE_DELETE(room);
    }
    floors.erase(floors.begin());
    rooms.erase(rooms.begin());
    middleIndex--;
    setFloor(0);
}
void SludgeFloorMaker::button1Release(int local_pointx, int local_pointy)
{
		int xx, yy;

		awaitButton1Release = FALSE;

		selx2 = xx = (local_pointx+x)*zmul;
		sely2 = yy = (local_pointy-y)*zmul;

		lit = snapToClosest(&xx, &yy, getFloor());
		litX = xx; 
		litY = yy;
						
		if (lit && (xx != selx1 || yy != sely1)) {
			selx2 = xx;
			sely2 = yy;
		}
												
		selection = 0;

		switch (mode) {
			case 1: // Move vertices
				if (moveVertices(selx1, sely1, selx2, sely2, getFloor())) {
					setFileChanged();
				} else {
					errorBox("Can't move vertex", "Sorry - that vertex is already contained in one or more of the polygons you're changing.");
					return;
				}
			
				break;

			case 4: // Split lines
				splitLine(selx1, sely1, selx2, sely2, getFloor());
				setFileChanged();
				break;
			case 5: // Split segments
				struct polyList * firstPoly = getFloor();
				splitPoly(selx1, sely1, selx2, sely2, &firstPoly);
				setFloor(firstPoly);
				setFileChanged();
				break;
		}
}
Example #7
0
bool loadGame(const Common::String &fname) {
	Common::InSaveFile *fp = g_system->getSavefileManager()->openForLoading(fname);
	FILETIME savedGameTime;

	while (allRunningFunctions)
		finishFunction(allRunningFunctions);

	if (fp == NULL)
		return false;

	bool headerBad = false;
	if (fp->readByte() != 'S')
		headerBad = true;
	if (fp->readByte() != 'L')
		headerBad = true;
	if (fp->readByte() != 'U')
		headerBad = true;
	if (fp->readByte() != 'D')
		headerBad = true;
	if (fp->readByte() != 'S')
		headerBad = true;
	if (fp->readByte() != 'A')
		headerBad = true;
	if (headerBad) {
		fatal(ERROR_GAME_LOAD_NO, fname);
		return NULL;
	}
	char c;
	c = fp->readByte();
	while ((c = fp->readByte()))
		;

	int majVersion = fp->readByte();
	int minVersion = fp->readByte();
	ssgVersion = VERSION(majVersion, minVersion);

	if (ssgVersion >= VERSION(1, 4)) {
		if (!g_sludge->_gfxMan->skipThumbnail(fp))
			return fatal(ERROR_GAME_LOAD_CORRUPT, fname);
	}

	uint32 bytes_read = fp->read(&savedGameTime, sizeof(FILETIME));
	if (bytes_read != sizeof(FILETIME) && fp->err()) {
		warning("Reading error in loadGame.");
	}

	if (savedGameTime.dwLowDateTime != fileTime.dwLowDateTime || savedGameTime.dwHighDateTime != fileTime.dwHighDateTime) {
		return fatal(ERROR_GAME_LOAD_WRONG, fname);
	}

	// DON'T ADD ANYTHING NEW BEFORE THIS POINT!

	if (ssgVersion >= VERSION(1, 4)) {
		allowAnyFilename = fp->readByte();
	}
	captureAllKeys = fp->readByte();
	fp->readByte();  // updateDisplay (part of movie playing)

	g_sludge->_txtMan->loadFont(ssgVersion, fp);

	killAllPeople();
	killAllRegions();

	int camerX = fp->readUint16BE();
	int camerY = fp->readUint16BE();
	float camerZ;
	if (ssgVersion >= VERSION(2, 0)) {
		camerZ = fp->readFloatLE();
	} else {
		camerZ = 1.0;
	}

	brightnessLevel = fp->readByte();

	g_sludge->_gfxMan->loadHSI(fp, 0, 0, true);
	g_sludge->_evtMan->loadHandlers(fp);
	loadRegions(fp);

	if (!g_sludge->_cursorMan->loadCursor(fp)) {
		return false;
	}

	LoadedFunction *rFunc;
	LoadedFunction **buildList = &allRunningFunctions;

	int countFunctions = fp->readUint16BE();
	while (countFunctions--) {
		rFunc = loadFunction(fp);
		rFunc->next = NULL;
		(*buildList) = rFunc;
		buildList = &(rFunc->next);
	}

	for (int a = 0; a < numGlobals; a++) {
		unlinkVar(globalVars[a]);
		loadVariable(&globalVars[a], fp);
	}

	loadPeople(fp);

	if (fp->readByte()) {
		if (!setFloor(fp->readUint16BE()))
			return false;
	} else
		setFloorNull();

	if (!g_sludge->_gfxMan->loadZBuffer(fp))
		return false;

	if (!g_sludge->_gfxMan->loadLightMap(ssgVersion, fp)) {
		return false;
	}

	fadeMode = fp->readByte();
	g_sludge->_speechMan->load(fp);
	loadStatusBars(fp);
	g_sludge->_soundMan->loadSounds(fp);

	saveEncoding = fp->readUint16BE();

	if (ssgVersion >= VERSION(1, 6)) {
		if (ssgVersion < VERSION(2, 0)) {
			// aaLoad
			fp->readByte();
			fp->readFloatLE();
			fp->readFloatLE();
		}

		blur_loadSettings(fp);
	}

	if (ssgVersion >= VERSION(1, 3)) {
		g_sludge->_gfxMan->loadColors(fp);

		// Read parallax layers
		while (fp->readByte()) {
			int im = fp->readUint16BE();
			int fx = fp->readUint16BE();
			int fy = fp->readUint16BE();

			if (!g_sludge->_gfxMan->loadParallax(im, fx, fy))
				return false;
		}

		g_sludge->_languageMan->loadLanguageSetting(fp);
	}

	g_sludge->_gfxMan->nosnapshot();
	if (ssgVersion >= VERSION(1, 4)) {
		if (fp->readByte()) {
			if (!g_sludge->_gfxMan->restoreSnapshot(fp))
				return false;
		}
	}

	delete fp;

	g_sludge->_gfxMan->setCamera(camerX, camerY, camerZ);

	clearStackLib();
	return true;
}
Example #8
0
void House::setFloorMiddle() {
    setFloor(middleIndex);
}
Example #9
0
bool House::floorDown() {
    return setFloor(floorIndex - 1);
}
Example #10
0
bool House::floorUp() {
    return setFloor(floorIndex + 1);
}
void FloorLocator::detach ( void )
{
	setFloor(NULL);
	setId(-1);
}
void SludgeFloorMaker::button1Press(int local_pointx, int local_pointy)
{
    	gboolean keepOn = TRUE;
		int i, xx, yy;

		mouseLoc1x = local_pointx;
		mouseLoc1y = local_pointy;

		xx = (local_pointx+x)*zmul;
		yy = (local_pointy-y)*zmul;
		
		switch (mode) {
		case 0: // Define floor border
			snapToClosest(&xx, &yy, getFloor());
			while (keepOn) {
				keepOn = FALSE;
				i = addVertex(xx, yy, getFloor());
				switch (i) {
					case 1:
						setFileChanged();
						return;
					case 0:
						errorBox("Can't add vertex", "Out of memory.");
						return;
						
					case 3:
						errorBox("Can't add vertex", "That vertex is already used in this polygon, but isn't the start point.");
						return;
						
					case 2:
						if ( askAQuestion("Can't add vertex", "Can't add another vertex as the floor is already complete... do you want to start a NEW polygon at this point?") ) { 
							setFloor( addPoly(getFloor()) );
							keepOn = TRUE;
							setFileChanged();
						} else {
							return;
						}
						break;
				}
			}
			break;
		case 1: // Move vertices
		case 4: // Split lines
		case 5: // Split segments
			if (! snapToClosest(&xx, &yy, getFloor()))
				return;
			
			selx1 = xx;
			sely1 = yy;
			selection = 1;
			awaitButton1Release = TRUE;
				
			break;
		case 2: // Remove vertices
			if (! snapToClosest(&xx, &yy, getFloor()))
				return;
			struct polyList * firstPoly = getFloor();
			
			killVertex(xx, yy, &firstPoly);
			setFloor(firstPoly);
			setFileChanged();
			break;
		}
		lit = snapToClosest(&xx, &yy, getFloor());
		litX = xx; litY = yy;
}