#pragma once //#include //#include "ScriptDefine.h" //#include #include "EnvironmentInfo.h" //#include "X2DPolygon.h" class CTerrainLocationInfoForMap { private: std::string m_strLocationFileName; int m_nMapX; int m_nMapY; public: #ifdef _EDIT_MAP_FILE_ std::string GetFileName() { return m_strLocationFileName; } int GetMapX() { return m_nMapX; } int GetMapY() { return m_nMapY; } #endif bool CheckMap( int nMapX, int nMapY ) { if( nMapX != m_nMapX || nMapY != m_nMapY ) return true; return false; } public: CTerrainLocationInfoForMap( CTerrainMapEngine *pTerrainMapEngine, const char* szLocationFileName, int nMapX, int nMapY ) : m_nMapX( 0 ) , m_nMapY( 0 ) { // 파일 열기 KStream* pStream = KFileManager::Instance().CreateStreamFromResource( szLocationFileName, true ); if( NULL == pStream ) { // assert( false && "로케이션 파일이 없음." ); return; } const CTerrainSeamlessWorldInfo* pSeamlessWorldInfo = pTerrainMapEngine->GetSeamlessWorldInfo(); if(pSeamlessWorldInfo == NULL) { // assert( false && "pSeamlessWorldInfo == NULL 이네" ); delete pStream; return; } float fMapLen = (float)( pSeamlessWorldInfo->GetTileCountPerSegment() * pSeamlessWorldInfo->GetSegmentCountPerMap() ) * (float)pSeamlessWorldInfo->GetTileLength(); float fAttrLength = pSeamlessWorldInfo->GetTileLength() / (float)c_nAttrCountPerTile; m_strLocationFileName = szLocationFileName; m_nMapX = nMapX; m_nMapY = nMapY; int nLocalSize = 0; pStream->Read( &nLocalSize, sizeof( nLocalSize ) ); for( int nLocalCount = 0; nLocalCount < nLocalSize; nLocalCount++ ) { CTerrainMapEngine::EventPolygon EvPolygon; LOCAL_INFO_HEADER sLocalInfoHeader; pStream->Read( &sLocalInfoHeader, sizeof( sLocalInfoHeader ) ); EvPolygon.nPriority = sLocalInfoHeader.nPriority; int nCharSize = 0; pStream->Read( &nCharSize, sizeof( nCharSize ) ); if( nCharSize > 1 ) pStream->Seek( nCharSize, KStream::seekCur ); pStream->Read( &nCharSize, sizeof( nCharSize ) ); if( nCharSize > 1 ) { char* pScript = new char[nCharSize]; pStream->Read( pScript, nCharSize ); EvPolygon.strScript = pScript; SAFE_DELETE_ARRAY( pScript ); } int nPolygonSize = 0; pStream->Read( &nPolygonSize, sizeof( nPolygonSize ) ); for( int nPolygonCount = 0; nPolygonCount < nPolygonSize ; nPolygonCount++ ) { int nPointCount = 0; pStream->Read( &nPointCount, sizeof( nPointCount ) ); if( nPointCount ) { X2D::Point *pPoints = new X2D::Point[nPointCount]; pStream->Read( pPoints, sizeof( X2D::Point ) * nPointCount ); for( int nPointIdx = 0; nPointIdx < nPointCount; ++nPointIdx ) { pPoints[nPointIdx].x *= fAttrLength; //형 변환 하지 마셈!!! pPoints[nPointIdx].y *= fAttrLength; //형 변환 하지 마셈!!! // * 맨날 컴파일할때마다 warning보는 다른 사람: 아악~~~ 형 변환 하고 싶어~~~~~ 이런 ambiguous한 코드를 그냥 두다니~~~~~~~~ pPoints[nPointIdx].x += (int)( (float)nMapX * fMapLen ); pPoints[nPointIdx].y += (int)( (float)nMapY * fMapLen ); } EvPolygon.Set( pPoints, pPoints + (nPointCount-1) ); delete [] pPoints; pTerrainMapEngine->SetEventPolygon( &EvPolygon ); } } } delete pStream; } }; class CTerrainEventAreaInfoForMap { private: std::string m_strEventAreaFileName; int m_nMapX; int m_nMapY; public: bool CheckMap( int nMapX, int nMapY ) { if( nMapX != m_nMapX || nMapY != m_nMapY ) return true; return false; } public: CTerrainEventAreaInfoForMap( CTerrainMapEngine *pTerrainMapEngine, const char* szEventAreaFileName, int nMapX, int nMapY ) : m_nMapX( 0 ) , m_nMapY( 0 ) { // 파일 열기 KStream* pStream = KFileManager::Instance().CreateStreamFromResource( szEventAreaFileName, true ); if( NULL == pStream ) { return; } const CTerrainSeamlessWorldInfo* pSeamlessWorldInfo = pTerrainMapEngine->GetSeamlessWorldInfo(); if(pSeamlessWorldInfo == NULL) { delete pStream; return; } float fMapLen = (float)( pSeamlessWorldInfo->GetTileCountPerSegment() * pSeamlessWorldInfo->GetSegmentCountPerMap() ) * (float)pSeamlessWorldInfo->GetTileLength(); float fAttrLength = pSeamlessWorldInfo->GetTileLength() / (float)c_nAttrCountPerTile; m_strEventAreaFileName = szEventAreaFileName; m_nMapX = nMapX; m_nMapY = nMapY; int eventAreaCount; pStream->Read( &eventAreaCount, sizeof( eventAreaCount ) ); for (int i=0; iRead( &id, sizeof( id ) ); pStream->Read( &polyCount, sizeof( polyCount ) ); for (int j=0; jRead( &nPointCount, sizeof( nPointCount ) ); X2D::Point* pPoints = new X2D::Point[ nPointCount ]; pStream->Read( pPoints, sizeof(X2D::Point) * nPointCount ); for( int nPointIdx = 0; nPointIdx < nPointCount; ++nPointIdx ) { pPoints[nPointIdx].x *= fAttrLength; //형 변환 하지 마셈!!! pPoints[nPointIdx].y *= fAttrLength; //형 변환 하지 마셈!!! pPoints[nPointIdx].x += (int)( (float)nMapX * fMapLen ); pPoints[nPointIdx].y += (int)( (float)nMapY * fMapLen ); } CTerrainMapEngine::EventAreaPolygon poly; poly.Set( pPoints, pPoints + nPointCount ); poly.nID = id; poly.nPolygonNum = j; pTerrainMapEngine->SetEventAreaPolygon( &poly ); delete[] pPoints; } } //for( int nLocalCount = 0; nLocalCount < nLocalSize; nLocalCount++ ) //{ // CTerrainMapEngine::EventPolygon EvPolygon; // // LOCAL_INFO_HEADER sLocalInfoHeader; // pStream->Read( &sLocalInfoHeader, sizeof( sLocalInfoHeader ) ); // EvPolygon.nPriority = sLocalInfoHeader.nPriority; // int nCharSize = 0; // pStream->Read( &nCharSize, sizeof( nCharSize ) ); // if( nCharSize > 1 ) pStream->Seek( nCharSize, KStream::seekCur ); // pStream->Read( &nCharSize, sizeof( nCharSize ) ); // if( nCharSize > 1 ) // { // char* pScript = new char[nCharSize]; // pStream->Read( pScript, nCharSize ); // EvPolygon.strScript = pScript; // SAFE_DELETE_ARRAY( pScript ); // } // int nPolygonSize = 0; // pStream->Read( &nPolygonSize, sizeof( nPolygonSize ) ); // for( int nPolygonCount = 0; nPolygonCount < nPolygonSize ; nPolygonCount++ ) // { // int nPointCount = 0; // pStream->Read( &nPointCount, sizeof( nPointCount ) ); // if( nPointCount ) // { // X2D::Point *pPoints = new X2D::Point[nPointCount]; // pStream->Read( pPoints, sizeof( X2D::Point ) * nPointCount ); // for( int nPointIdx = 0; nPointIdx < nPointCount; ++nPointIdx ) // { // pPoints[nPointIdx].x *= fAttrLength; //형 변환 하지 마셈!!! // pPoints[nPointIdx].y *= fAttrLength; //형 변환 하지 마셈!!! // // * 맨날 컴파일할때마다 warning보는 다른 사람: 아악~~~ 형 변환 하고 싶어~~~~~ 이런 ambiguous한 코드를 그냥 두다니~~~~~~~~ // pPoints[nPointIdx].x += (int)( (float)nMapX * fMapLen ); // pPoints[nPointIdx].y += (int)( (float)nMapY * fMapLen ); // } // EvPolygon.Set( pPoints, pPoints + (nPointCount-1) ); // // // delete [] pPoints; // pTerrainMapEngine->SetEventPolygon( &EvPolygon ); // } // } //} delete pStream; } };