Beispiel #1
0
//-------------------------------------------------------------------------------
int32_t Radio::init(PSTR fileName, uint32_t heapSize, PSTR movie)
{
	FullPathFileName pilotAudioPath;
	pilotAudioPath.init(CDsoundPath, fileName, ".pak");
	FullPathFileName noisePath;
	noisePath.init(CDsoundPath, "noise", ".pak");
	//--------------------------------------
	// Startup the packet file.
	radioID				  = currentRadio;
	messagesFile[radioID] = new PacketFile;
	gosASSERT(messagesFile[radioID] != nullptr);
	int32_t result = messagesFile[radioID]->open(pilotAudioPath);
	gosASSERT(result == NO_ERROR);
	if (!noiseFile)
	{
		//--------------------------------------
		// Startup the Noise packet file.
		noiseFile = new PacketFile;
		gosASSERT(noiseFile != nullptr);
		result = noiseFile->open(noisePath);
		gosASSERT(result == NO_ERROR);
	}
	// load message parameters
	if (!messageInfoLoaded)
	{
		if (loadMessageInfo() == NO_ERROR)
			messageInfoLoaded = TRUE;
		else
			Fatal(0, "Unable to load message info.");
	}
	radioList[currentRadio] = this;
	currentRadio++;
	return (NO_ERROR);
}
Beispiel #2
0
void Terrain::resetVisibleVertices (long maxVisibleVertices)
{
	terrainHeap->Free(vertexList);
	vertexList = NULL;

	terrainHeap->Free(quadList);
	quadList = NULL;

	visibleVerticesPerSide = maxVisibleVertices;
	//----------------------------------------------------------------------
	// Create the VertexList
	numberVertices = 0;
	vertexList = (VertexPtr)terrainHeap->Malloc(sizeof(Vertex) * visibleVerticesPerSide * visibleVerticesPerSide);
	gosASSERT(vertexList != NULL);
	memset(vertexList,0,sizeof(Vertex) * visibleVerticesPerSide * visibleVerticesPerSide);

	//----------------------------------------------------------------------
	// Create the QuadList
	numberQuads = 0;
	quadList = (TerrainQuadPtr)terrainHeap->Malloc(sizeof(TerrainQuad) * visibleVerticesPerSide * visibleVerticesPerSide);
	gosASSERT(quadList != NULL);
	memset(quadList,0,sizeof(TerrainQuad) * visibleVerticesPerSide * visibleVerticesPerSide);

	
}
Beispiel #3
0
//---------------------------------------------------------------------------
int32_t GameCamera::activate(void)
{
	//------------------------------------------
	// If camera is already active, just return
	if (ready && active)
		return (NO_ERROR);
	//---------------------------------------------------------
	// Camera always starts pointing at first mover in lists
	// CANNOT be infinite because we don't allow missions without at least 1
	// player mech!!
	MoverPtr firstMover = nullptr;
	if (ObjectManager->getNumMovers() > 0)
	{
		int32_t i  = 0;
		firstMover = ObjectManager->getMover(i);
		while (firstMover &&
			((firstMover->getCommander()->getId() != Commander::home->getId()) ||
				!firstMover->isOnGUI()))
		{
			i++;
			if (i == ObjectManager->getNumMovers())
				break;
			firstMover = ObjectManager->getMover(i);
		}
	}
	if (firstMover)
	{
		Stuff::Vector3D newPosition(firstMover->getPosition());
		setPosition(newPosition);
	}
	if (land)
	{
		land->update();
	}
	allNormal();
	// updateDaylight(true);
	lastShadowLightPitch = lightPitch;
	// Startup the SKYBox
	int32_t appearanceType					= (GENERIC_APPR_TYPE << 24);
	AppearanceTypePtr genericAppearanceType = nullptr;
	genericAppearanceType = appearanceTypeList->getAppearance(appearanceType, "skybox");
	if (!genericAppearanceType)
	{
		char msg[1024];
		sprintf(msg, "No Generic Appearance Named %s", "skybox");
		Fatal(0, msg);
	}
	theSky = new GenericAppearance;
	gosASSERT(theSky != nullptr);
	//--------------------------------------------------------------
	gosASSERT(genericAppearanceType->getAppearanceClass() == GENERIC_APPR_TYPE);
	theSky->init((GenericAppearanceType*)genericAppearanceType, nullptr);
	theSky->setSkyNumber(mission->theSkyNumber);
	return NO_ERROR;
}
Beispiel #4
0
bool Terrain::load( FitIniFile* fitFile )
{
	// write out the water info
	long result = fitFile->seekBlock( "Water" );
	gosASSERT( result == NO_ERR );

	result = fitFile->readIdFloat( "Elevation", mapData->waterDepth );
	gosASSERT( result == NO_ERR );
	waterElevation = mapData->waterDepth;
	result = fitFile->readIdFloat( "Frequency", waterFreq );
	gosASSERT( result == NO_ERR );
	result = fitFile->readIdFloat( "Ampliture", waterAmplitude );
	gosASSERT( result == NO_ERR );
	result = fitFile->readIdULong( "AlphaShallow", alphaEdge );
	gosASSERT( result == NO_ERR );
	result = fitFile->readIdULong( "AlphaMiddle", alphaMiddle );
	gosASSERT( result == NO_ERR );
	result = fitFile->readIdULong( "AlphaDeep", alphaDeep );
	gosASSERT( result == NO_ERR );
	result = fitFile->readIdFloat( "AlphaDepth", mapData->alphaDepth );
	gosASSERT( result == NO_ERR );
	result = fitFile->readIdFloat( "ShallowDepth", mapData->shallowDepth );
	gosASSERT( result == NO_ERR );

	fitFile->seekBlock( "Terrain" );
	fitFile->readIdLong( "UserMin", userMin );
	fitFile->readIdLong( "UserMax", userMax );

	fitFile->readIdUChar( "Noise", fractalNoise);
	fitFile->readIdUChar( "Threshold", fractalThreshold);

	return true;

}
Beispiel #5
0
//---------------------------------------------------------------------
// class CraterManager
long CraterManager::init (long numCraters, unsigned long craterTypeSize, char *craterFileName)
{
	init();
	
	//-----------------------------------------------------
	// Allocate Heap to store crater Info
	maxCraters = numCraters;
	craterPosHeapSize = numCraters * (sizeof(CraterData) + allocatedBlockSize);
	
	//-----------------------------------------------------
	// create Heaps
	craterPosHeap = new HeapManager;
	gosASSERT(craterPosHeap != NULL);
	
	long result = craterPosHeap->createHeap(craterPosHeapSize);
	gosASSERT(result == NO_ERR);
		
	result = craterPosHeap->commitHeap(craterPosHeapSize);
	gosASSERT(result == NO_ERR);

	numCraterTextures = MAX_CRATER_TEXTURES;
	//---------------------------------------------------------
	// Setup Crater Texture handles
	craterTextureHandles = (DWORD *)malloc(sizeof(DWORD) * numCraterTextures);
	memset((MemoryPtr)craterTextureHandles,0xff,sizeof(DWORD) * numCraterTextures);

	craterTextureIndices = (DWORD *)malloc(sizeof(DWORD) * numCraterTextures);
	memset((MemoryPtr)craterTextureIndices,0xff,sizeof(DWORD) * numCraterTextures);

	//-----------------------------------------------------
	// Preload all of the craters for the mission.
	// This should just be one texture with all of the craters on it
	// and a generic set of UVs to mark each one.
	for (long i=0;i<numCraterTextures;i++)
	{
		char craterName[1024];
		sprintf(craterName,"defaults\\feet%04d",i);
		
		FullPathFileName craterPath;
		craterPath.init(texturePath,craterName,".tga");

		if (!i)
			craterTextureIndices[i] = mcTextureManager->loadTexture(craterPath, gos_Texture_Keyed, gosHint_DisableMipmap);
		else
			craterTextureIndices[i] = mcTextureManager->loadTexture(craterPath, gos_Texture_Alpha, gosHint_DisableMipmap);
	}

	//-----------------------------------------------------
	// Setup pointer and initial values
	craterList = (CraterDataPtr)craterPosHeap->getHeapPtr();
	memset(craterPosHeap->getHeapPtr(),-1,craterPosHeapSize);

	return(NO_ERR);
}	
Beispiel #6
0
//---------------------------------------------------------------------------
void Terrain::initMapCellArrays (void)
{
	if (!tileRowToWorldCoord)
	{
		tileRowToWorldCoord = (float *)terrainHeap->Malloc(sizeof(float) * realVerticesMapSide);
		gosASSERT(tileRowToWorldCoord != NULL);
	}

	if (!tileColToWorldCoord)
	{
		tileColToWorldCoord = (float *)terrainHeap->Malloc(sizeof(float) * realVerticesMapSide); 
		gosASSERT(tileColToWorldCoord != NULL);
	}

	if (!cellToWorldCoord)
	{
		cellToWorldCoord = (float *)terrainHeap->Malloc(sizeof(float) * MAPCELL_DIM); 
		gosASSERT(cellToWorldCoord != NULL);
	}

	if (!cellColToWorldCoord)
	{
		cellColToWorldCoord = (float *)terrainHeap->Malloc(sizeof(float) * realVerticesMapSide * MAPCELL_DIM); 
		gosASSERT(cellColToWorldCoord != NULL);
	}

	if (!cellRowToWorldCoord)
	{
		cellRowToWorldCoord = (float *)terrainHeap->Malloc(sizeof(float) * realVerticesMapSide * MAPCELL_DIM); 
		gosASSERT(cellRowToWorldCoord != NULL);
	}

	long i=0;

	long height = realVerticesMapSide, width = height;
	for (i = 0; i < height; i++)
		tileRowToWorldCoord[i] = (worldUnitsMapSide / 2.0) - (i * worldUnitsPerVertex);

	for (i = 0; i < width; i++)
		tileColToWorldCoord[i] = (i * worldUnitsPerVertex) - (worldUnitsMapSide / 2.0);

	for (i = 0; i < MAPCELL_DIM; i++)
		cellToWorldCoord[i] = (worldUnitsPerVertex / (float)MAPCELL_DIM) * i;

	long maxCell = height * MAPCELL_DIM;
	for (i = 0; i < maxCell; i++)
		cellRowToWorldCoord[i] = (worldUnitsMapSide / 2.0) - (i * worldUnitsPerCell);

	maxCell = width * MAPCELL_DIM;
	for (i = 0; i < maxCell; i++)
		cellColToWorldCoord[i] = (i * worldUnitsPerCell) - (worldUnitsMapSide / 2.0);
}	
// if this doesn't want to link properly, this will have to become
// a macro.
/////////////////////////////////////////////////////////////////
inline	unsigned short*	EWCharString::ToUnicode( unsigned short* p_Buffer, 
								   const unsigned char* p_Str, 
								   int Num_Chars )
{
	gosASSERT( p_Buffer );
	gosASSERT( p_Str );

	p_Buffer[0] = 0;

	MultiByteToWideChar( CP_ACP, 0, (const char*)p_Str, -1, p_Buffer, Num_Chars );

	return p_Buffer;	
}
Beispiel #8
0
VertexInfo::VertexInfo( long newRow, long newColumn )
{
	gosASSERT( newRow > -1 && newColumn > -1 );
	gosASSERT( newRow < land->realVerticesMapSide && newColumn < land->realVerticesMapSide );

	row = newRow;
	column = newColumn;

	elevation = land->getTerrainElevation( row, column );
	terrainData = land->getTerrain( row, column );
	textureData = land->getTexture( row, column );

}
Beispiel #9
0
//************************************************************************
// Function:	c'tor
// ParamsIn:	none
// ParamsOut:	none
// Returns:		nothing	
// Description:
//************************************************************************
ActionUndoMgr::ActionUndoMgr() 
{
	m_CurrentPos = -1;
	m_PosOfLastSave = -1;
	gosASSERT( !instance );
	instance = this;
}
int LogisticsComponent::extractString( char*& pFileLine, char* pBuffer, int bufferLength )
{
	*pBuffer = 0;

	for ( int i = 0; i < 512; ++i )
	{
		if ( pFileLine[i] == '\n' )
			break;
		else if ( pFileLine[i] == ',' )
			break;
		else if ( pFileLine[i] == NULL )
			break;
	}

	if ( i == 512 )
		return false;

	gosASSERT( i < bufferLength );
	memcpy( pBuffer, pFileLine, i );
	pBuffer[i] = NULL;
	bufferLength = i + 1;
	pFileLine += i + 1;

	return i;

}
Beispiel #11
0
//---------------------------------------------------------------------------
void FullPathFileName::init (char * dir_path, const char * name, char * ext)
{
	destroy();

	size_t total_length = strlen(dir_path);
	total_length += strlen(name);
	total_length += strlen(ext);
	total_length++;


	fullName = (char *)systemHeap->Malloc(total_length);
	gosASSERT(fullName != NULL);
	if (fullName == NULL)
		return;
	fullName[0] = 0;

	if ( strstr( name, dir_path ) != name )
		strcpy_s(fullName, total_length, dir_path);

	if (name)
		strcat_s(fullName, total_length, name);

	// don't append if its already there
	if (ext && _stricmp( fullName + strlen( fullName ) - strlen( ext ), ext ) != 0)
		strcat_s(fullName, total_length, ext);

	// CharLowerA(fullName);
	_strlwr_s(fullName, total_length);
}
Beispiel #12
0
void aObject::removeChild(aObject* c)
{
	if (!c) // If this is nullptr, shouldn't we still remove it from the list?
		return;
	if ((c->getParent() == this) || (c->getParent() == nullptr)) // Normal situation
	{
		for (size_t cc = 0; cc < nNumberOfChildren; cc++)
		{
			if (pChildren[cc] == c)
			{
				// found the child, remove it and shift the rest of the children
				// up
				for (size_t sc = cc; sc < nNumberOfChildren - 1; sc++)
					pChildren[sc] = pChildren[sc + 1];
				pChildren[nNumberOfChildren] = nullptr;
				nNumberOfChildren--;
				c->setParent(nullptr);
				return;
			}
		}
	}
	else
	{
		gosASSERT(0);
	}
}
MechLabScreen::MechLabScreen(  ) 
{
	status = RUNNING;
	pVariant = NULL;
	helpTextArrayID = 14;
	pCurComponent = 0;
	gosASSERT( !s_instance );
	s_instance = this;
	pDragComponent = NULL;
	pSelectedComponent = NULL;
	selI = -1;
	selJ = -1;

	countDownTime = .5;
	curCount = 0.0;
	previousAmount = 0;

	oldCBillsAmount  =0;

	oldHeat = 0;
	heatTime = 0;

	oldArmor = 0;
	newArmor = 0;
	armorTime = 0;
	bDragLeft = 0;

	selRect = NULL;

}
Beispiel #14
0
//---------------------------------------------------------------------------
int32_t PacketFile::afterOpen(void)
{
	if(!numPackets && getLength() >= 12)
	{
		int32_t firstPacketOffset;
		int32_t firstCheck = readLong();
		if(firstCheck == PACKET_FILE_VERSION && !usesCheckSum)
		{
		}
		else
		{
			//---------------------------------------
			// This is probably a checksum.  Check it
			int32_t checkSum = checkSumFile();
			if(checkSum != firstCheck)
				return PACKET_OUT_OF_RANGE;
		}
		firstPacketOffset = readLong();
		numPackets = (firstPacketOffset / sizeof(int32_t)) - 2;
	}
	currentPacket = -1;
	if(fileMode == READ || fileMode == RDWRITE)
	{
		if(numPackets && !seekTable)
		{
			seekTable = (int32_t*)systemHeap->Malloc(numPackets * sizeof(int32_t));
			gosASSERT(seekTable != nullptr);
			seek(sizeof(int32_t) * 2);												//File Version & File Length
			read(puint8_t(seekTable), (numPackets * sizeof(int32_t)));
		}
	}
	return(NO_ERROR);
}
Beispiel #15
0
//-----------------------------------------------------
bool Terrain::save( FitIniFile* fitFile )
{
	// write out the water info
#ifdef _DEBUG
	long result = 
#endif
	fitFile->writeBlock( "Water" );
	gosASSERT( result > 0 );


	fitFile->writeIdFloat( "Elevation", mapData->waterDepth );
	fitFile->writeIdFloat( "Frequency", waterFreq );
	fitFile->writeIdFloat( "Ampliture", waterAmplitude );
	fitFile->writeIdULong( "AlphaShallow", alphaEdge );
	fitFile->writeIdULong( "AlphaMiddle", alphaMiddle );
	fitFile->writeIdULong( "AlphaDeep", alphaDeep );
	fitFile->writeIdFloat( "AlphaDepth", mapData->alphaDepth );
	fitFile->writeIdFloat( "ShallowDepth", mapData->shallowDepth );

	fitFile->writeBlock( "Terrain" );
	fitFile->writeIdLong( "UserMin", userMin );
	fitFile->writeIdLong( "UserMax", userMax );
	fitFile->writeIdFloat( "TerrainMinX", tileColToWorldCoord[0] );
	fitFile->writeIdFloat( "TerrainMinY", tileRowToWorldCoord[0] );
	fitFile->writeIdUChar( "Noise", fractalNoise);
	fitFile->writeIdUChar( "Threshold", fractalThreshold);

	if (terrainTextures2)
	{
		terrainTextures2->saveTilingFactors(fitFile);
	}
	return true;
}
Beispiel #16
0
//---------------------------------------------------------------------------
int32_t Building::update(void)
{
	if(getFlag(OBJECT_FLAG_JUSTCREATED))
	{
		setFlag(OBJECT_FLAG_JUSTCREATED, false);
		BuildingTypePtr type = (BuildingTypePtr)ObjectManager->getObjectType(typeHandle);
		//-------------------------------------------------------
		// OK, now use the sprite Bounds to calculate the extent
		// Radius so that nobody has to enter it!
		if(type->getExtentRadius() < 0.0)
		{
			Stuff::Vector4D diagonalSize;
			diagonalSize.Subtract(appearance->upperLeft, appearance->lowerRight);
			float actualSize = diagonalSize.GetLength();
			actualSize /= worldUnitsPerMeter;
			actualSize *= 1.25;
			type->setExtentRadius(actualSize);
		}
		if(type->getExtentRadius() != 0.0)
			setTangible(true);
		//-----------------------------------------------------
		// Check if ParentId is NOT 0xffffffff.
		// if not, find parent in ObjMgr and get its pointer.
		if((parentId != 0xffffffff) && (parentId != 0))
		{
			parent = ObjectManager->findByCellPosition((parentId >> 16), (parentId & 0x0000ffff))->getWatchID();
			if(ObjectManager->getByWatchID(parent)->canBeCaptured())
				ObjectManager->getByWatchID(parent)->setFlag(OBJECT_FLAG_CAPTURABLE, true);
			gosASSERT(parent != 0);
		}
	}
int32_t LogisticsVariant::init(CSVFile* file, LogisticsChassis* pChassis, int32_t Variant)
{
	bDesignerMech = true;
	int32_t offset = 97 * Variant;
	fileID = Variant;
	gosASSERT(pChassis);
	chassis = pChassis;
	ID = (pChassis->refCount << 16) | pChassis->ID;
	\
	pChassis->refCount++;
	file->readBoolean(21 + offset, 4, bHidden);
	char buffer[256];
	if(NO_ERROR == file->readString(23 + offset, 2, buffer, 256))
	{
		variantName = buffer;
	}
	LogisticsComponent*  pComps[128];
	int32_t xLocs[128];
	int32_t yLocs[128];
	memset(pComps, 0, sizeof(LogisticsComponent*) * 128);
	int32_t componentCount = 0;
	int32_t i, j, k;
	for(i = 26; i < 97; i++)
	{
		int32_t componentID;
		if(NO_ERROR == file->readLong(offset + i, 5, componentID) && componentID != 0xff)
		{
			LogisticsComponent* pComp = LogisticsData::instance->getComponent(componentID);
			if(pComp)
			{
				file->readLong(offset + i, 4, yLocs[componentCount]);
				file->readLong(offset + i, 3, xLocs[componentCount]);
				pComps[componentCount++] = pComp;
			}
		}
	}
	for(j = 4; j > 0; j--)
	{
		for(k = 3; k > 0; k--)
		{
			for(i = 0; i < componentCount; i++)
			{
				LogisticsComponent*
				pComponent = pComps[i];
				if(pComponent && pComponent->getComponentWidth() == k
						&& pComponent->getComponentHeight() == j)
				{
					if(!addComponent(pComps[i]->getID(), xLocs[i], yLocs[i]))
					{
						char errorString[256];
						sprintf(errorString, "Couldn't add component with id %ld",
								pComponent->getID());
					}
				}
			}
		}
	}
	return 0;
}
Beispiel #18
0
//
// Constructor
//
	inline FixedLengthString( int Length )
	{
		gosASSERT( Length!=0 );
		Text=(char*)malloc(Length);
		MaximumLength=Length;
		CurrentSize=0;
		*Text=0;
	}
Beispiel #19
0
//---------------------------------------------------------------------------
long SoundSystem::playBettySample (unsigned long bettySampleId)
{
	if (useSound && (bettySoundBite == NULL))	//Playing Betty takes precedence
	{

		if (bettySampleId >= numBettySamples)
			return(-1);
			
		long ourChannel = BETTY_CHANNEL;
	
		gosAudio_SetChannelSlider( ourChannel, gosAudio_Panning, 0.0f );
		float vol = 1.0;
		gosAudio_SetChannelSlider( ourChannel, gosAudio_Volume, digitalMasterVolume * vol * bettyVolume );
		gosAudio_SetChannelSlider( RADIO_CHANNEL, gosAudio_Volume, digitalMasterVolume * vol * radioVolume * 0.5f ); 
		lastBettyId = bettySampleId;
		channelInUse[ourChannel] = TRUE;


		long result = bettyDataFile->seekPacket(bettySampleId);
		if (result != NO_ERR)
			return(-1);
			
		long bettySize = bettyDataFile->getPacketSize();
		bettySoundBite = (MemoryPtr)soundHeap->Malloc(bettySize);
		gosASSERT(bettySoundBite != NULL);
		
		bettyDataFile->readPacket(bettySampleId,bettySoundBite);
		
		//--------------------------------------------------------------------
		// Hand GOS sound the data it needs to create the resource Handle
		gosAudio_Format soundFormat;
		soundFormat.wFormatTag = 1;				//PCM
		
		MC2_WAVEFORMATEX *waveFormat = NULL;
		MemoryPtr dataOffset = NULL;
		DWORD length = 0;
		DWORD bitsPerSec = 0;
		wave_ParseWaveMemory(bettySoundBite,&waveFormat,&dataOffset,&length);
		
		bitsPerSec = waveFormat->nBlockAlign / waveFormat->nChannels * 8;

		soundFormat.nChannels = waveFormat->nChannels;
		soundFormat.nSamplesPerSec = waveFormat->nSamplesPerSec;
		soundFormat.nAvgBytesPerSec = waveFormat->nAvgBytesPerSec;
		soundFormat.nBlockAlign = waveFormat->nBlockAlign;
		soundFormat.wBitsPerSample = bitsPerSec;
		soundFormat.cbSize = 0;

		gosAudio_CreateResource(&bettyHandle,gosAudio_UserMemory, NULL, &soundFormat,dataOffset,length);
		gosAudio_AssignResourceToChannel( ourChannel, bettyHandle );
		gosAudio_SetChannelPlayMode(ourChannel, gosAudio_PlayOnce);
			
		return(BETTY_CHANNEL);
	}

	return(-1);
}
int32_t LogisticsVehicle::getComponents(int32_t& count, LogisticsComponent** array)
{
	gosASSERT(componentCount <= count);
	for(size_t i = 0; i < componentCount; ++i)
	{
		array[i] = components[i].component;
	}
	count = componentCount;
	return count;
}
Beispiel #21
0
long	aListBox::InsertItem(aListItem* itemString, long where)
{
	if ( itemCount >= MAX_LIST_ITEMS )
		return -1;
	gosASSERT( itemString );
	if ( where >= itemCount )
		where = itemCount;
	for ( int i = itemCount - 1; i > where - 1; i-- )
	{
		items[i+1] = items[i];
		items[i+1]->move( 0, itemString->height() + skipAmount );
	}

	float lastX = x() + itemString->x();
	float lastY = y();

	items[where] = itemString;

	if ( itemCount > 0 )
	{
		if ( where - 1 > -1 )
			lastY = items[where-1]->bottom() + skipAmount;
		else
			lastY = items[where+1]->top() - skipAmount - itemString->height();
	}

	itemString->moveTo( lastX, lastY );
	itemString->showGUIWindow( true );

	if ( itemString->globalRight() > globalRight() ) // can't have it hanging over the edge
	{
		float shrink = globalRight() - itemString->globalRight();
		itemString->resize( itemString->width() +  shrink, itemString->height() );
	}

	itemCount++;


	if ( scrollBar )
	{
		int itemsTotalHeight = 0;
		if ( items )
			itemsTotalHeight = items[itemCount-1]->bottom() - items[0]->top();

			if ( itemsTotalHeight > scrollBar->height() )
				scrollBar->SetScrollMax( itemsTotalHeight - scrollBar->height() );
			else
				scrollBar->SetScrollMax( 0 );
			
	}


	return where;
}
Beispiel #22
0
//************************************************************************
// Function:	Redo
// ParamsIn:	none
// ParamsOut;	none
// Returns:		success of operation
// Description:	gets the action at the front of the redo list, performs
//				it and adds it to the undo list
//************************************************************************
bool ActionUndoMgr::Redo()
{
	gosASSERT( HaveRedo() );

	m_CurrentPos++;
	ACTION_LIST::EIterator iter = m_listUndoActions.Iterator( m_CurrentPos );

	return (*iter)->redo();


}
Beispiel #23
0
long File::createWithCase( char* fName )
{
	gosASSERT( !isOpen() );
	//-------------------------------------------------------------
	long fNameLength = strlen(fName);
	
	fileName = (char *)systemHeap->Malloc(fNameLength+1);
	gosASSERT(fileName != NULL);
		
	strncpy(fileName,fName,fNameLength+1);
	fileMode = CREATE;
	_fmode = _O_BINARY;

	handle = _creat(fileName,_S_IWRITE);
	if (handle == INVALID_HANDLE_VALUE)
	{
		lastError = errno;
		return lastError;
	}

	return 0;
}
Beispiel #24
0
//************************************************************************
// Function:	Undo
// ParamsIn:	none
// ParamsOut;	none
// Returns:		success of operation
// Description:	gets the action at the front of the undo list, performs
//				it and adds it to the redo list
//************************************************************************
bool ActionUndoMgr::Undo()
{
	bool bRetVal = false;

	gosASSERT( HaveUndo() );


	ACTION_LIST::EIterator iter = m_listUndoActions.Iterator( m_CurrentPos );
	bRetVal = (*iter)->undo();
	m_CurrentPos --;

	return bRetVal;
}
Beispiel #25
0
bool ModifyBuildingAction::doRedo()
{
	bool bRetVal = true;

	OBJ_INFO_PTR_LIST::EIterator iter2 = buildingPtrs.Begin();
	OBJ_APPEAR_LIST::EIterator iter3 = buildingAppearanceCopies.Begin();
	OBJ_ID_LIST::EIterator iter4 = buildingIDs.Begin();
	for ( OBJ_INFO_PTR_LIST::EIterator iter = buildingCopyPtrs.Begin();
		!iter.IsDone(); iter++)
		{
			//EditorObject *pBuilding = (*iter2);
			EditorObject *pBuilding = EditorObjectMgr::instance()->getObjectAtLocation((*iter4).x, (*iter4).y);
			if (pBuilding)
			{
				EditorObject *pBuildingSwap = (*iter)->Clone();
				ObjectAppearance AppearanceSwap = (*iter3);

				(*iter)->CastAndCopy(*pBuilding);
				(*iter3) = (*(pBuilding->appearance()));

				(*pBuilding).CastAndCopy(*pBuildingSwap);
				(*(pBuilding->appearance())) = AppearanceSwap;

				delete pBuildingSwap;

				{
					/*this is just to make sure the visuals are up-to-date*/
					bool d = pBuilding->getDamage();
					pBuilding->setDamage(!d);
					pBuilding->setDamage(d);
				}

				long row, column;
				pBuilding->getCells(row, column);
				EditorObjectMgr::instance()->moveBuilding(pBuilding, row, column);

				(*iter4).x = pBuilding->getPosition().x;
				(*iter4).y = pBuilding->getPosition().y;
			}
			else 
			{
				gosASSERT(false);
			}

			iter2++;
			iter3++;
			iter4++;
		}

	return bRetVal;
}
Beispiel #26
0
void Mission::initBareMinimum()
{

	long result = 0;

	if ( !mcTextureManager )
	{
		mcTextureManager = new MC_TextureManager;
		mcTextureManager->start();

	}

	//Startup the vertex array pool
	mcTextureManager->startVertices(g_maxVertexCount);

	initTGLForLogistics();

	//----------------------------------------------
	// Start Appearance Type Lists.
	if ( !appearanceTypeList )
	{
		appearanceTypeList = new AppearanceTypeList;
		gosASSERT(appearanceTypeList != NULL);
		appearanceTypeList->init(g_spriteHeapSize);
		gosASSERT(result == NO_ERR);
	}

	if ( !weaponEffects )
	{
		weaponEffects = new WeaponEffects;
		weaponEffects->init("Effects");
	}

	if ( statisticsInitialized == 0 )
	{
		initializeStatistics();
	}
}
Beispiel #27
0
//---------------------------------------------------------------------------
void VFXShapeElement::init (MemoryPtr _shape, long _x, long _y, long frame, bool rev, unsigned long *fTable, float _z, float tZ)
{
	gosASSERT(_shape != NULL);

	long i=0;
	while (shapeTable[i] != NULL)
		i++;

	gosASSERT(i < MAX_ELEMENT_SHAPES);

	shapeTable[i] = _shape;
	frameNum[i] = frame;
	reverse[i] = rev;

	if (!i)
	{
		x = _x;
		y = _y;
		fadeTable = fTable;
		z = _z;
		topZ = tZ;
	}
}
bool ForceGroupBar::addVehicle( Mover* pMover )
{
	if ( iconCount >= MAX_ICONS )
	{
		gosASSERT( false );
		return 0;
	}
	
	VehicleIcon* pIcon = new VehicleIcon;
	bool bRetVal = pIcon->init( pMover );

	icons[iconCount++] = pIcon;

	return bRetVal;
}
Beispiel #29
0
long PriorityQueue::init (long max, long keyMinValue) {

	//-------------------------
	// Create the queue list...
	pqList = (PQNode*)systemHeap->Malloc(sizeof(PQNode) * (max + 2));
	gosASSERT (pqList != NULL);

	//----------------------------------------------------------------------
	// Note that two additional nodes are added, as the first and last nodes
	// of the queue list are used as sentinels (to assist implementation
	// execution speed)...
	maxItems = max + 2;
	keyMin = keyMinValue;
	return(0);
}
void DlgFileOpen::OnSelchangeFileopenFilelist()
{
	CListBox* m_pList = (CListBox*)GetDlgItem(IDC_FILEOPEN_FILELIST);
	gosASSERT(m_pList);
	int32_t nSelectionIndex = m_pList->GetCurSel();
	int32_t nStringLength = m_pList->GetTextLen(nSelectionIndex);
	if(0 < nStringLength)
	{
		PSTR pszSelectionString = new char[nStringLength + 1];
		m_pList->GetText(nSelectionIndex, pszSelectionString);
		CEdit* m_pEntry = (CEdit*)GetDlgItem(IDC_FILEOPEN_EDITBOX);
		m_pEntry->SetWindowText(pszSelectionString);
		delete pszSelectionString;
	}
}