Example #1
0
Maze* MazeGame::CreateMaze () {
    Maze* aMaze = MakeMaze();
/*
*/
    Room* r1 = MakeRoom(1);
    Room* r2 = MakeRoom(2);
    Door* theDoor = MakeDoor(r1, r2);
/*
*/
    aMaze->AddRoom(r1);
    aMaze->AddRoom(r2);
/*
*/
    r1->SetSide(North, MakeWall());
    r1->SetSide(East, theDoor);
    r1->SetSide(South, MakeWall());
    r1->SetSide(West, MakeWall());
/*
*/
    r2->SetSide(North, MakeWall());
    r2->SetSide(East, MakeWall());
    r2->SetSide(South, MakeWall());
    r2->SetSide(West, theDoor);
/*
*/
    return aMaze;
}
void CNscPStackEntry::PushConstantVector (float x, float y, float z)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeConstantVector);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeConstantVector *p = (NscPCodeConstantVector *)
		&m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Constant;
	p ->nType = NscType_Vector;
	p ->v [0] = x;
	p ->v [1] = y;
	p ->v [2] = z;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushConstantObject (UINT32 uid)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeConstantObject);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeConstantObject *p = (NscPCodeConstantObject *) 
		&m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Constant;
	p ->nType = NscType_Object;
	p ->ulid = uid;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushConstantFloat (float fValue)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeConstantFloat);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeConstantFloat *p = (NscPCodeConstantFloat *) 
		&m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Constant;
	p ->nType = NscType_Float;
	p ->fValue = fValue;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushConstantInteger (int nValue)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeConstantInteger);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeConstantInteger *p = (NscPCodeConstantInteger *) 
		&m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Constant;
	p ->nType = NscType_Integer;
	p ->lValue = nValue;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushStatement (int nLocals,
	const unsigned char *pauchData, size_t nDataSize)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeStatement) + nDataSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeStatement *p = (NscPCodeStatement *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Statement;
	p ->nType = NscType_Unknown;
	p ->nLocals = nLocals;
	p ->nDataOffset = sizeof (NscPCodeStatement);
	p ->nDataSize = nDataSize;
	memcpy (&pauchPCode [p ->nDataOffset], pauchData, nDataSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushConstantStructure (NscType nType)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeConstantStructure);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeConstantStructure *p = (NscPCodeConstantStructure *) 
		&m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Constant;
	p ->nType = nType;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void MysteryDungeonMaker::CreateDungeon()
{
	ResetMap();

	std::vector<Component> section_components;
	const size_t sectionRowNum = dungeonSize->DungeonRowNum();
	const size_t sectionColumnNum = dungeonSize->DungeonColumnNum();
	for (size_t i = 0; i < sectionRowNum; i++)
	{
		for (size_t j = 0; j < sectionColumnNum; j++)
		{
			section_components.push_back(Component(i, j));
			this->sections[i][j].SetComponent(i, j);
		}
	}

	std::random_device rd;
	shuffle(section_components.begin(), section_components.end(), std::mt19937_64(rd()));

	for (int i = 0; i < roomNum; i++)
	{
		int i_section = section_components[i].i;
		int j_section = section_components[i].j;

		int width = GetRandInRange(minRoomWidth, sectionColumnNum - 4);
		int height = GetRandInRange(minRoomHeight, sectionRowNum - 4);
		MakeRoom(Component(i_section, j_section), width, height);
	}
	MakePath();
}
void CNscPStackEntry::PushLogicalOp (NscPCode nCode, 
	unsigned char *pauchLhs, size_t nLhsSize,
	unsigned char *pauchRhs, size_t nRhsSize)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeLogicalOp) + nLhsSize + nRhsSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeLogicalOp *p = (NscPCodeLogicalOp *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = nCode;
	p ->nType = NscType_Integer;
	p ->nLhsOffset = sizeof (NscPCodeLogicalOp);
	p ->nLhsSize = nLhsSize;
	p ->nRhsOffset = p ->nLhsOffset + nLhsSize;
	p ->nRhsSize = nRhsSize;
	memcpy (&pauchPCode [p ->nLhsOffset], pauchLhs, nLhsSize);
	memcpy (&pauchPCode [p ->nRhsOffset], pauchRhs, nRhsSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushCall (NscType nType, size_t nFnSymbol, 
	size_t nArgCount, const unsigned char *pauchData, size_t nDataSize)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeCall) + nDataSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeCall *p = (NscPCodeCall *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Call;
	p ->nType = nType;
	p ->nFnSymbol = nFnSymbol;
	p ->nArgCount = nArgCount;
	p ->nDataSize = nDataSize;
	p ->nDataOffset = sizeof (NscPCodeCall);
	memcpy (&pauchPCode [p ->nDataOffset], pauchData, nDataSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushBinaryOp (NscPCode nOpCode, NscType nOutType, 
	NscType nLhsType, NscType nRhsType)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeBinaryOp);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeBinaryOp *p = (NscPCodeBinaryOp *) &m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = nOpCode;
	p ->nType = nOutType;
	p ->nLhsType = nLhsType;
	p ->nRhsType = nRhsType;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushCase (NscPCode nCode, 
	unsigned char *pauchCase, size_t nCaseSize, int nFile, int nLine)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeCase) + nCaseSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeCase *p = (NscPCodeCase *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = nCode;
	p ->nType = NscType_Unknown;
	p ->szLabel [0] = 0;
	p ->nCaseSize = nCaseSize;
	p ->nCaseOffset = sizeof (NscPCodeCase);
	p ->nFile = nFile;
	p ->nLine = nLine;
	memcpy (&pauchPCode [p ->nCaseOffset], pauchCase, nCaseSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void *MakeLevs(void *ThreadNum){
	int *NumPointer = (int *)ThreadNum;
	int LoopStart = *NumPointer * (NumLevs/NumThreads);
	int i = 0;
	uint32_t *Pgen= &gens[*NumPointer];
	//printf("The *gen of thread %d is:%d \n",*NumPointer,*Pgen);
	for (i=LoopStart; i<LoopStart+NumLevs/NumThreads; i++) {
		struct Room rs[100];
		int lenrs=0;
		int *Plenrs = &lenrs;
		int ii;
		for (ii=0;ii<50000;ii++){
			MakeRoom(rs,Plenrs,Pgen);
			if(lenrs==99){ 
				break;
			}
		}
		struct Tile ts[2500];
		for (ii=0;ii<2500;ii++){
			ts[ii].X=ii%TileDim;
			ts[ii].Y=ii/TileDim;
			ts[ii].T=0;
		}
		for (ii=0;ii<lenrs;ii++){
			Room2Tiles(&(rs[ii]),ts);
		}
		struct Lev l;
		memcpy(l.rs,rs,sizeof(rs));
		memcpy(l.ts,ts,sizeof(ts));
		l.lenrs=lenrs;
		ls[i]=l;
		//lenLS++;				
	}
}
Example #14
0
		void Vector<T>::Append(const T& value)
		{
			if (size == capacity)
				MakeRoom( (size + 1) * 2 );

			Allocator::Copy( data[size++], value );
		}
void CNscPStackEntry::PushSimpleOp (NscPCode nOpCode, NscType nType)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeHeader);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeHeader *p = (NscPCodeHeader *) &m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = nOpCode;
	p ->nType = nType;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushReturn (NscType nType, 
	unsigned char *pauchData, size_t nDataSize)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeReturn) + nDataSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeReturn *p = (NscPCodeReturn *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Return;
	p ->nType = nType;
	p ->nDataSize = nDataSize;
	p ->nDataOffset = sizeof (NscPCodeReturn);
	memcpy (&pauchPCode [p ->nDataOffset], pauchData, nDataSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushElement (NscType nType, NscType nLhsType, 
	int nElement, unsigned char *pauchData, size_t nDataSize)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeElement) + nDataSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeElement *p = (NscPCodeElement *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Element;
	p ->nType = nType;
	p ->nLhsType = nLhsType;
	p ->nElement = nElement;
	p ->nDataSize = nDataSize;
	p ->nDataOffset = sizeof (NscPCodeElement);
	memcpy (&pauchPCode [p ->nDataOffset], pauchData, nDataSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushLine (int nFile, int nLine)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeLine);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeLine *p = (NscPCodeLine *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Line;
	p ->nType = NscType_Unknown;
	p ->nFile = nFile;
	p ->nLine = nLine;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushVariable (NscType nType, NscType nSourceType,
	size_t nSymbol, int nElement, int nStackOffset, 
	UINT32 ulFlags)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeVariable);
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeVariable *p = (NscPCodeVariable *) &m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Variable;
	p ->nType = nType;
	p ->nSourceType = nSourceType;
	p ->nSymbol = nSymbol;
	p ->nElement = nElement;
	p ->nStackOffset = nStackOffset;
	p ->ulFlags = ulFlags;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::Push5Block (NscPCode nOpCode, NscType nType,
	const unsigned char *pauchBlock1, size_t nBlock1Size, int nFile1, int nLine1, 
	const unsigned char *pauchBlock2, size_t nBlock2Size, int nFile2, int nLine2,
	const unsigned char *pauchBlock3, size_t nBlock3Size, int nFile3, int nLine3,
	const unsigned char *pauchBlock4, size_t nBlock4Size, int nFile4, int nLine4,
	const unsigned char *pauchBlock5, size_t nBlock5Size, int nFile5, int nLine5)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCode5Block) + nBlock1Size + 
		nBlock2Size + nBlock3Size + nBlock4Size + nBlock5Size;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCode5Block *p = (NscPCode5Block *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = nOpCode;
	p ->nType = nType;
	p ->anSize [0] = nBlock1Size;
	p ->anSize [1] = nBlock2Size;
	p ->anSize [2] = nBlock3Size;
	p ->anSize [3] = nBlock4Size;
	p ->anSize [4] = nBlock5Size;
	p ->anOffset [0] = sizeof (NscPCode5Block);
	p ->anOffset [1] = p ->anOffset [0] + nBlock1Size;
	p ->anOffset [2] = p ->anOffset [1] + nBlock2Size;
	p ->anOffset [3] = p ->anOffset [2] + nBlock3Size;
	p ->anOffset [4] = p ->anOffset [3] + nBlock4Size;
	p ->anFile [0] = nFile1;
	p ->anFile [1] = nFile2;
	p ->anFile [2] = nFile3;
	p ->anFile [3] = nFile4;
	p ->anFile [4] = nFile5;
	p ->anLine [0] = nLine1;
	p ->anLine [1] = nLine2;
	p ->anLine [2] = nLine3;
	p ->anLine [3] = nLine4;
	p ->anLine [4] = nLine5;
	memcpy (&pauchPCode [p ->anOffset [0]], pauchBlock1, nBlock1Size);
	memcpy (&pauchPCode [p ->anOffset [1]], pauchBlock2, nBlock2Size);
	memcpy (&pauchPCode [p ->anOffset [2]], pauchBlock3, nBlock3Size);
	memcpy (&pauchPCode [p ->anOffset [3]], pauchBlock4, nBlock4Size);
	memcpy (&pauchPCode [p ->anOffset [4]], pauchBlock5, nBlock5Size);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
Example #21
0
char* ResourceCache::Allocate(unsigned int uSize)
{
	if (!MakeRoom(uSize))
		return nullptr;

	char* pMemory = new char[uSize];
	if (pMemory)
		m_uAllocated += uSize;

	return pMemory;
}
Example #22
0
	char* ResCache::Allocate(unsigned int size)
	{
		if (!MakeRoom(size))
			return NULL;

		char *mem = new char[size];
		if (mem)
		{
			m_allocated += size;
		}

		return mem;
	}
Example #23
0
//************************************
// Method:    Allocate
// FullName:  ResCache::Allocate
// Access:    protected 
// Returns:   char*
// Qualifier:
// Parameter: unsigned int  size
//************************************
char* ResCache::Allocate(unsigned int size)
{
	if(!MakeRoom(size))
	{
		return NULL;
	}

	char* mem = DEBUG_CLIENTBLOCK char[size];
	if(mem)
		m_allocated += size;

	return mem;
}
Example #24
0
char *ResourceManager::Allocate(unsigned int size)
{
    if (!MakeRoom(size))
    {
        return NULL;
    }

    char *mem = TG_NEW char[size];
    if (mem)
    {
        this->allocatedSize += size;
    }
    return mem;
}
Example #25
0
int main(int argc, char* argv[]) {
	clock_t start, stop;
	start = clock();
	int v = atoi(argv[1]);
	printf("The random seed is: %d \n", v);
	srand(v);
	uint32_t gen = v;
	uint32_t *Pgen= &gen;
	int i;
	struct Lev ls[100];
	int lenLS=0;
    	for (i=0; i<100; i++) {
		struct Room rs[100];
		int lenrs=0;
		int *Plenrs = &lenrs;
		int ii;
		for (ii=0;ii<50000;ii++){
			MakeRoom(rs,Plenrs,Pgen);
			if(lenrs==99){ 
				break;
			}
		}
		struct Tile ts[2500];
		for (ii=0;ii<2500;ii++){
			ts[ii].X=ii%TileDim;
			ts[ii].Y=ii/TileDim;
			ts[ii].T=0;
		}
		for (ii=0;ii<lenrs;ii++){
			Room2Tiles(&(rs[ii]),ts);
		}
		struct Lev l;
		memcpy(l.rs,rs,sizeof(rs));
		memcpy(l.ts,ts,sizeof(ts));
		l.lenrs=lenrs;
		ls[lenLS]=l;
		lenLS++;				
	}
	struct Lev templ;
	templ.lenrs=0;
	for(i=0;i<100;i++){
		if(ls[i].lenrs>templ.lenrs) templ=ls[i];
	}
	PrintLev(&templ);
	stop = clock();
	long clocks_per_ms = CLOCKS_PER_SEC/1000;
        printf("%ld\n", (stop - start)/clocks_per_ms);

    return 0;
}
Example #26
0
int Clone_Room(ITEM *i, ITEM *j)
{
	ROOM *r,*s;
	if(MakeRoom(i)==-1)
		return(-1);
	r=(ROOM *)FindSub(i,KEY_ROOM);
	s=(ROOM *)FindSub(j,KEY_ROOM);
	if((!r)||(!s))
		Error("CloneRoom: Not Room!");
	FreeText(r->rm_Short);
	FreeText(r->rm_Long);
	r->rm_Flags=s->rm_Flags;
	r->rm_Short=AllocText(TextOf(s->rm_Short));
	r->rm_Long=AllocText(TextOf(s->rm_Long));
	return(0);
}
Example #27
0
    char* ResourceCache::Alloc(uint size)
    {

        if(!MakeRoom(size))
        {
            return NULL;
        }

        char* buffer = new char[size];

        if(!buffer)
        {
            return NULL;
        }

        AllocSilent(size);

        return buffer;
    }
void CNscPStackEntry::PushDeclaration (const char *pszIdentifier, 
	NscType nType, const unsigned char *pauchInit, size_t nInitSize,
	int nFile, int nLine, UINT32 ulSymFlags)
{

	//
	// Make room for the pcode block
	//

	size_t nLength = strlen (pszIdentifier);
	size_t nSize = sizeof (NscPCodeDeclaration) + nLength + nInitSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeDeclaration *p = (NscPCodeDeclaration *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Declaration;
	p ->nType = nType;
	p ->nIdLength = nLength;
	p ->nDataOffset = sizeof (NscPCodeDeclaration) + nLength;
	p ->nDataSize = nInitSize;
	p ->nAltStringOffset = 0;
	p ->nFile = nFile;
	p ->nLine = nLine;
	p ->ulSymFlags = ulSymFlags;
	memcpy (p ->szString, pszIdentifier, nLength);
	p ->szString [nLength] = 0;
	memcpy (&pauchPCode [p ->nDataOffset], pauchInit, nInitSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushAssignment (NscPCode nOpCode, NscType nType, 
	NscType nSourceType, NscType nRhsType, size_t nSymbol, int nElement, 
	int nStackOffset, UINT32 ulFlags, unsigned char *pauchData, 
	size_t nDataSize)
{

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeAssignment) + nDataSize;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	unsigned char *pauchPCode = &m_pauchData [m_nDataSize];
	NscPCodeAssignment *p = (NscPCodeAssignment *) pauchPCode;
	p ->nOpSize = nSize;
	p ->nOpCode = nOpCode;
	p ->nType = nType;
	p ->nSourceType = nSourceType;
	p ->nRhsType = nRhsType;
	p ->nSymbol = nSymbol;
	p ->nElement = nElement;
	p ->nStackOffset = nStackOffset;
	p ->ulFlags = ulFlags;
	p ->nDataSize = nDataSize;
	p ->nDataOffset = sizeof (NscPCodeAssignment);
	memcpy (&pauchPCode [p ->nDataOffset], pauchData, nDataSize);

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}
void CNscPStackEntry::PushConstantString (const char *pszString, int nLength)
{

	//
	// If need be, get the string length
	//

	if (nLength == -1)
		nLength = (int) strlen (pszString);

	//
	// Make room for the pcode block
	//

	size_t nSize = sizeof (NscPCodeConstantString) + nLength;
	MakeRoom (nSize);

	//
	// Initialize the block
	//

	NscPCodeConstantString *p = (NscPCodeConstantString *) 
		&m_pauchData [m_nDataSize];
	p ->nOpSize = nSize;
	p ->nOpCode = NscPCode_Constant;
	p ->nType = NscType_String;
	p ->nLength = nLength;
	if (pszString)
        memcpy (p ->szString, pszString, nLength);
	p ->szString [nLength] = 0;

	//
	// Adjust the size of the entry
	//

	m_nDataSize += nSize;
}