Exemplo n.º 1
0
void LevelManager::freeLevel(unsigned int levelId, bool freeData)
{
	LEVEL_MAP::iterator itor = mLevelList.find(levelId);	
	if (itor != mLevelList.end())
	{
		sLevelPack* pack = (*itor).second;
		if (pack->levelLayer != NULL)
		{					
			//reset current level
			if (pack->levelLayer == mCurrentLevel)
			{
				removeLevelFromParent(mCurrentLevel);
				mCurrentLevel = NULL;
			}

			pack->levelLayer->destroyLayer();			
			pack->levelLayer = NULL;
			
		}

		if (freeData)
		{
			freeLevelData(levelId);

			//clean up
			SAFE_DEL(pack->levelData);
			SAFE_DEL(pack);
			mLevelList.erase(itor);
		}
	}
}
Exemplo n.º 2
0
int main()
{
	CWriterStream<CFileWin32Driver> *Fo = new CWriterStream<CFileWin32Driver> ("test.bin");
	Fo->WriteInt32(-100);
	Fo->Close();
	SAFE_DEL(Fo);

	CReaderStream<CFileWin32Driver> *F = new CReaderStream<CFileWin32Driver>("test.bin");
	int re;
	F->ReadInt32(re);
	printf("%d\n", re);
	F->Close();
	SAFE_DEL(F);

	SGameConfig cnf = {
		400,
		200,
		false,
		"Hello",
		CGLPipelineDriver::GetInstance(),
		new CExample(),
	};
	GameTutor::StartApp(cnf);
	GameTutor::FinalizeApp();

	while(true);
}
Exemplo n.º 3
0
		COpenGLRenderer::~COpenGLRenderer()
		{
			for (uint i = 0; i < m_vecBuffer.size(); ++i)
			{
				SAFE_DEL(m_vecBuffer[i]);
			}
			SAFE_DEL(m_pTerrainTextureGenerator);
		}
Exemplo n.º 4
0
void CStateOption::Exit()
{
	CSoundManagement::GetInstance()->Free((char*)"menu_background");
	CImageManager::GetInstance()->Free(PATH_GRAPHIC("WOT_Option.tga"));
	SAFE_DEL(but_Back2MainMenu);
	SAFE_DEL(but_SoundIsEnable);
	SAFE_DEL(but_SoundIsMuted);
	Log("State Option: Exit");	
}
Exemplo n.º 5
0
MessageWindow::~MessageWindow()
{
#define SAFE_DEL(p) if (p) { delete p; p = NULL; }
   SAFE_DEL(_pMessageWindow);
   for (size_t i=0; i<_buttons.size(); ++i) {
      SAFE_DEL(_buttons[i].pButton);
   }
#undef SAFE_DEL
}
Exemplo n.º 6
0
		CTerrainEntity::~CTerrainEntity()
		{
			SAFE_DEL(m_pHeightMap);
			if (m_pRenderer)
				m_pRenderer->DestroyGPUBuffer(m_pGPUBuffer);
			if (m_pTextureGenerator)
				m_pTextureGenerator->DestroyTexture(m_pTexture);
			SAFE_DEL(m_pMeshData);
		}
Exemplo n.º 7
0
FileWindow::~FileWindow()
{
#define SAFE_DEL(p) if (p) { delete p; p = NULL; }
   SAFE_DEL(_pFileList);
   SAFE_DEL(_pDirBox);
   SAFE_DEL(_pSelectBox);
   SAFE_DEL(_pCancelButton);
   SAFE_DEL(_pOkButton);
#undef SAFE_DEL
}
Exemplo n.º 8
0
void CStateChooseLevel::Exit()
{
	CSoundManagement::GetInstance()->Free((char*)"chooseLevel_background");
	CImageManager::GetInstance()->Get(PATH_GRAPHIC("WOT_ChooseLevel.tga"));
	for (int i = 0; i< 9; i++)
	{
		SAFE_DEL(but_Level[i]);
	}
	SAFE_DEL(but_MainMenu);
	Log("State ChooseLevel: Exit");
}
Exemplo n.º 9
0
Kylin::PhyX::PhysicalSystem::~PhysicalSystem()
{
	SAFE_CALL(m_pMotionSimulator,Destroy());
	SAFE_DEL(m_pMotionSimulator);
	//-------------------------------------------------------------------------
	SAFE_CALL(m_pCollisionMonitor,Destroy());
	SAFE_DEL(m_pCollisionMonitor);
	//-------------------------------------------------------------------------
	SAFE_CALL(m_pCoverMonitor,Destroy());
	SAFE_DEL(m_pCoverMonitor);
}
Exemplo n.º 10
0
LevelLayer::~LevelLayer()
{		
	GameAudioManager::sharedManager()->stopAllEffect();
	//
	SAFE_DEL(m_levelBuilder);

	//
	m_othersPlayerInfo.clear();

	SAFE_DEL(m_pPhysicsLayer);

	ItemUpdateManager::Get()->resetData();
}
Exemplo n.º 11
0
KVOID Kylin::ActionDispatcher::DestroyAllAction()
{
	for ( ActionList::iterator it = m_kActionList.begin(); 
		it != m_kActionList.end(); 
		it++ 
		)
	{
		(*it)->Destroy();
		SAFE_DEL(*it);
	}
	m_kActionList.clear();
	//////////////////////////////////////////////////////////////////////////
	SAFE_DEL(m_pActionFactory);
}
Exemplo n.º 12
0
void SessionMgr::delConn(Session* sesn)
{
	if(sesn != NULL)
	{
		SAFE_DEL(sesn);
	}
}
Exemplo n.º 13
0
/**
	Destructor.
**/
FileSearchThread::~FileSearchThread()
{
	if (debugFlag)
		logger->debug("FileSearchThread::~FileSearchThread -- START\n");
	stop = true;

	if (started)
	{
		while (!completed)
		{
			Sleep(1);
			Yield();
		}
	}

	ARRAY_DEL(files, fileCount);
	ARRAY_DEL_SINGLE(fileSearchForTextThreads, fileSearchForTextThreadCount);

	SAFE_DEL(m_FileSearchResultForm);

	if (searchText)
		delete [] searchText;
	searchText = NULL;

	m_form = NULL;

	files = NULL;
	fileCount = 0;

	totalFileCount = 0;

	if (debugFlag)
		logger->debug("FileSearchThread::~FileSearchThread -- DONE\n");
}
Exemplo n.º 14
0
void bgMatrixIndex::Release()
{
	for (int iSub = 0; iSub < m_Mesh.pSubMeshes.size(); iSub++)
		SAFE_DEL(m_Mesh.pSubMeshes[iSub]);

	m_Mesh.pSubMeshes.clear();
}
Exemplo n.º 15
0
KBOOL Kylin::Kitbag::AddItem( ItemCell* pItem )
{
	if (m_kItemArray.size() >= m_uUpperLimit)
	{
		SAFE_DEL(pItem);
		return false;
	}

	if (pItem->GetStorageType() == ItemCell::ST_ALONE)
		m_kItemArray.push_back(pItem);
	else
	{
		KINT n = HasItem(pItem->GetGID());
		if (n != -1)
		{
			m_kItemArray[n]->m_nCount++;
		}
		else
		{
			m_kItemArray.push_back(pItem);
		}
	}

	return true;
}
Exemplo n.º 16
0
Kylin::Kitbag::~Kitbag()
{
	for (KUINT i = 0; i < m_kItemArray.size(); i++)
	{
		SAFE_DEL(m_kItemArray[i]);
	}
	m_kItemArray.clear();
}
Exemplo n.º 17
0
KVOID Kylin::Kitbag::RemoveAndDestroyItem( KINT nIndex )
{
	if (nIndex < m_kItemArray.size() && nIndex >= 0)
	{
		SAFE_DEL(m_kItemArray[nIndex]);
		m_kItemArray.erase(m_kItemArray.begin() + nIndex);
	}
}
Exemplo n.º 18
0
void InGameState::RemoveList()
{
	for (positionIterator iterator = position.begin(); iterator != position.end(); iterator++)
    {
        SAFE_DEL(*iterator);
    }
	position.clear();
}
Exemplo n.º 19
0
LevelManager::~LevelManager()
{
	for (LEVEL_MAP::iterator itor = mLevelList.begin(); itor != mLevelList.end();)
	{
		int levelId = (*itor).first;
		freeLevelData(levelId);

		//clean up
		sLevelPack*	pack = (*itor).second;
		SAFE_DEL(pack->levelData);
		SAFE_DEL(pack);
		mLevelList.erase(itor++);
	}

	// destroy all the map data
	MapDataManager::Destroy();
	MonsterData::Destroy();
}
Exemplo n.º 20
0
		COpenGLGPUBuffer::~COpenGLGPUBuffer()
		{
			GLDebug(glDeleteVertexArrays(1, &m_hVAO));
			for (uint i = 0; i < m_vecRenderableObject.size(); ++i)
			{
				SAFE_DEL(m_vecRenderableObject[i]);
			}
			
		}
Exemplo n.º 21
0
	void Phy2dWorld::reloadWorld()
	{
		SAFE_DEL(m_world);

		releaseActors();

		createPhyWorld();

		loadFromXMLFile(m_xmlFileName.c_str());
	}
Exemplo n.º 22
0
	void Phy2dWorld::resetToInitial()
	{
		SAFE_DEL(m_world);		

		createPhyWorld();

		for(int i=0, is=(int)m_actors.size(); i<is; i++)
		{
			m_actors[i]->resetToInitial();		
		}	
	}
Exemplo n.º 23
0
		void COpenGLRenderer::DestroyGPUBuffer(IGPUBuffer *gpuBuffer)
		{
			for (uint i = 0; i < m_vecBuffer.size(); ++i)
			{
				if (m_vecBuffer[i] == gpuBuffer)
				{
					m_vecBuffer.erase(i + m_vecBuffer.begin());
					SAFE_DEL(gpuBuffer);
				}
			}
		}
Exemplo n.º 24
0
GTextureMgr::~GTextureMgr(void)
{
	GTexture *pPoint;
	for (TemplateMapItor itor = TMap.begin(); itor != TMap.end(); itor++)
	{
		pPoint = (GTexture *)(*itor).second;
		pPoint->Release();
		SAFE_DEL(pPoint);
	}
	TMap.clear();
	m_iCurIndex = 0;
}
Exemplo n.º 25
0
KVOID Kylin::Kitbag::RemoveItem( ItemCell* pCell )
{
	for (KUINT i = 0; i < m_kItemArray.size(); i++)
	{
		if (m_kItemArray[i] == pCell)
		{
			SAFE_DEL(m_kItemArray[i]);
			m_kItemArray.erase(m_kItemArray.begin() + i);
			break;
		}
	}
}
Exemplo n.º 26
0
KVOID Kylin::DataManager::Destroy()
{
	LoaderMap::iterator beg = m_kLoaderMap.begin();
	LoaderMap::iterator end = m_kLoaderMap.end();

	for (LoaderMap::iterator it = beg; it != end; it++)
	{
		SAFE_DEL(it->second);
	}

	m_kLoaderMap.clear();
}
Exemplo n.º 27
0
bool CMapObject::CalculateEnemyPath(int* ObjectMap, int* DirectionMap)
{
	int* TraceMap = new int[data->Width*data->Height];
	memset(TraceMap, 0, (data->Width)*(data->Height)*sizeof(int));
	TraceMap[data->DestinationPosition.y*data->Width+data->DestinationPosition.x] = 1;

	
	

	LogicPosition* Queue = new LogicPosition[(data->Width)*(data->Height)];	//allocate queue
	int cur = 0;	//current index of queue
	int last = 0;	//last index of queue
	Queue[0] = data->DestinationPosition;	//add destination to queue
	while (cur<=last)
	{
		LogicPosition curpos = Queue[cur];
		for (int i=1; i<=4; i++)
		{
			LogicPosition nextpos = curpos + OppositeMove[i];
			if (	(nextpos.x>=0) && (nextpos.x<data->Width) && (nextpos.y>=0) && (nextpos.y<data->Height) 
					&&(ObjectMap[nextpos.y*data->Width+nextpos.x]!=E_OBJ_TOWER)
					&& (ObjectMap[nextpos.y*data->Width+nextpos.x]!=E_OBJ_OBSTACLE)
					&& (TraceMap[nextpos.y*data->Width+nextpos.x]== 0))
			{
				TraceMap[nextpos.y*data->Width+nextpos.x] = TraceMap[curpos.y*data->Width+curpos.x] + 1;
				DirectionMap[nextpos.y*data->Width+nextpos.x] = i;
				Queue[++last] = nextpos;
			}
		}
		cur++;
	}

	bool isValid = true;

	for (int i=0; i<data->Width; i++)
	{
		for (int j=0; j<data->Height; j++)
		{
			LogicPosition curpos(i,j);
			if (	(curpos.x>=0) && (curpos.x<data->Width) && (curpos.y>=0) && (curpos.y<data->Height) 
					&&(ObjectMap[curpos.y*data->Width+curpos.x]!=E_OBJ_TOWER)
					&& (ObjectMap[curpos.y*data->Width+curpos.x]!=E_OBJ_OBSTACLE)
					&& (TraceMap[curpos.y*data->Width+curpos.x]==0))
			{
				isValid = false;
				break;
			}
		}
		if (!isValid) break;
	}
	SAFE_DEL(TraceMap);
	return isValid;
}
Exemplo n.º 28
0
int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
	logger = new AlCLogger(L".\\alclipboard.log", bDebug);
	alClipboard = new AlClipboard();

	keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);


	//keybd_event((byte) 'P', 0, 0, 0);
	//Sleep(10);
	//keybd_event((byte) 'P', 0, KEYEVENTF_KEYUP, 0);

	g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0);

	MSG msg;
	int bRet = 0;
	while (!quit && (bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
	{
		Sleep(1);

		if (bRet == -1)
		{
			// handle the error and possibly exit
		}
		else
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	ShowCursor(TRUE);

	if (g_hKeyboardHook) UnhookWindowsHookEx(g_hKeyboardHook);

	SAFE_DEL(alClipboard);
	SAFE_DEL(logger);
	return 0;

}
Exemplo n.º 29
0
bool GSpriteMgr::Release()
{
	GSprite *pPoint;
	for (TemplateMapItor itor = TMap.begin(); itor != TMap.end(); itor++)
	{
		pPoint = (GSprite *)(*itor).second;
		pPoint->Release();
		SAFE_DEL(pPoint);
	}
	TMap.clear();
	m_iCurIndex = 0;
	return true;
}
Exemplo n.º 30
0
void CMapObject::BuildTower(STowerData* data, LogicPosition position)
{
	CTowerObject* tower = new CTowerObject(data);
	int* NewObjectMap = new int[this->data->Width* this->data->Height];
	memcpy(NewObjectMap, this->ObjectMap, sizeof(int)*this->data->Width* this->data->Height);
	NewObjectMap[position.y *this->data->Width + position.x] = E_OBJ_TOWER;
	NewObjectMap[(position.y+1) *this->data->Width + position.x] = E_OBJ_TOWER;
	NewObjectMap[position.y *this->data->Width + (position.x+1)] = E_OBJ_TOWER;
	NewObjectMap[(position.y+1) *this->data->Width + (position.x+1)] = E_OBJ_TOWER;
	int* NewDirectionMap = new int[this->data->Width* this->data->Height];
	memset(NewDirectionMap, 0, sizeof(int)*this->data->Width* this->data->Height);
	if (CalculateEnemyPath(NewObjectMap, NewDirectionMap))
	{
		tower->logicposition = position;
		tower->position = Position(position.x+1, position.y+1, 0);
		CObjectManager::CurrentObjectManager->AddObject(tower);
		SAFE_DEL(ObjectMap);
		this->ObjectMap = NewObjectMap;
		SAFE_DEL(DirectionMap);
		this->DirectionMap = NewDirectionMap;
	}	
}