[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.83,1.84 tcMapData.cpp,1.7,1.8 tcMapView.cpp,1.22,1.23
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-06-19 22:00:38
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26484/src/sim Modified Files: Game.cpp tcMapData.cpp tcMapView.cpp Log Message: Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMapView.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcMapView.cpp 3 Apr 2004 20:24:33 -0000 1.22 --- tcMapView.cpp 19 Jun 2004 22:00:28 -0000 1.23 *************** *** 242,245 **** --- 242,246 ---- tcWindow::SetActive(abActive); terrainView->SetActive(abActive); + wxWindow::Raise(); // without this, the world map view wasn't receiving mouse cmds } /***********************************************************************************/ *************** *** 1967,1971 **** } /***********************************************************************************/ ! void tcWorldMapView::Init() { tcPoint p; --- 1968,1973 ---- } /***********************************************************************************/ ! void tcWorldMapView::Init() ! { tcPoint p; *************** *** 1977,1981 **** mpMapData->GetWorldArea(mrectViewBounds); // restrict view to theater area mpMapData->GetTheaterArea(mrectTheater); // for box to indicate theater area ! SetView(p,C_PIOVER180*340.0f); } /***********************************************************************************/ --- 1979,1983 ---- mpMapData->GetWorldArea(mrectViewBounds); // restrict view to theater area mpMapData->GetTheaterArea(mrectTheater); // for box to indicate theater area ! SetView(p, C_PIOVER180*340.0f); } /***********************************************************************************/ *************** *** 2025,2028 **** --- 2027,2031 ---- if (!terrainView) {wxMessageBox("terrainView init failed\n");} + tcWindow::MoveToTop(); // so that color elevation map is underneath mnCounter = 0; ClearMapObjects(); Index: tcMapData.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMapData.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcMapData.cpp 19 Nov 2003 01:36:14 -0000 1.7 --- tcMapData.cpp 19 Jun 2004 22:00:28 -0000 1.8 *************** *** 442,446 **** void tcMapData::SetDemInfo() { ! mzDemPath = "C:\\PROJECTS\\GLOBE\\DEM\\"; for (int i=0;i<16;i++) { --- 442,447 ---- void tcMapData::SetDemInfo() { ! // mzDemPath = "C:\\PROJECTS\\GLOBE\\DEM\\"; ! mzDemPath = "maps\\tiles\\"; for (int i=0;i<16;i++) { *************** *** 799,803 **** /********************************************************************/ ! int tcMapData::LoadHighRes(float afStartLon_deg, float afStartLat_deg) { int nMainTile,nEastTile,nSouthTile,nSouthEastTile; int bFound=0; --- 800,809 ---- /********************************************************************/ ! /** ! * Loads high res data (theater area) specified by northwest point ! * (afStartLon_deg, afStartLat_deg) ! */ ! int tcMapData::LoadHighRes(float afStartLon_deg, float afStartLat_deg) ! { int nMainTile,nEastTile,nSouthTile,nSouthEastTile; int bFound=0; *************** *** 1247,1266 **** } /********************************************************************/ ! tsTileData* tcMapData::GetTile(unsigned mtile, unsigned ntile, double afStatusTime) { unsigned short nTileIndex; tsTileData *pTileData; ! if ((mtile >= M_TILE_LOOKUP)||(ntile >= N_TILE_LOOKUP)) { return NULL; } nTileIndex = maTileLookup[mtile][ntile]; ! if (nTileIndex == NULL_TILE) { pTileData = LoadTile(mtile,ntile); } ! else { pTileData = &maTile[nTileIndex]; } ! if (pTileData != NULL) { pTileData->mfLastAccessTime = afStatusTime; } --- 1253,1277 ---- } /********************************************************************/ ! tsTileData* tcMapData::GetTile(unsigned mtile, unsigned ntile, double afStatusTime) ! { unsigned short nTileIndex; tsTileData *pTileData; ! if ((mtile >= M_TILE_LOOKUP)||(ntile >= N_TILE_LOOKUP)) ! { return NULL; } nTileIndex = maTileLookup[mtile][ntile]; ! if (nTileIndex == NULL_TILE) ! { pTileData = LoadTile(mtile,ntile); } ! else ! { pTileData = &maTile[nTileIndex]; } ! if (pTileData != NULL) ! { pTileData->mfLastAccessTime = afStatusTime; } *************** *** 1289,1301 **** } /********************************************************************/ ! void tcMapData::InitTiles() { unsigned int m,n,k; ! for(m=0;m<M_TILE_LOOKUP;m++) { ! for(n=0;n<N_TILE_LOOKUP;n++) { maTileLookup[m][n] = NULL_TILE; } } ! for(k=0;k<MAX_TILES;k++) { maTile[k].m_lat = 0; maTile[k].n_lon = 0; --- 1300,1316 ---- } /********************************************************************/ ! void tcMapData::InitTiles() ! { unsigned int m,n,k; ! for(m=0;m<M_TILE_LOOKUP;m++) ! { ! for(n=0;n<N_TILE_LOOKUP;n++) ! { maTileLookup[m][n] = NULL_TILE; } } ! for(k=0;k<MAX_TILES;k++) ! { maTile[k].m_lat = 0; maTile[k].n_lon = 0; *************** *** 1308,1313 **** mnTilesUsed = 0; } ! /********************************************************************/ ! tsTileData* tcMapData::LoadTile(unsigned mtile, unsigned ntile) { int nMainTile; int bFound=0; --- 1323,1332 ---- mnTilesUsed = 0; } ! /** ! * Loads 0.5 x 0.5 deg (default) tile from larger DEM tiles ! * @return populated tsTileData* or NULL if missing DEM data ! */ ! tsTileData* tcMapData::LoadTile(unsigned mtile, unsigned ntile) ! { int nMainTile; int bFound=0; *************** *** 1321,1334 **** fStartLon_deg = (float)ntile*SCALE_LOOKUP - 180.0f; ! for (k=0;(k<N_DEMFILES)&&(!bFound);k++) { ! if ((fStartLat_deg > maDemInfo[k].mfLatMin)&&(fStartLat_deg <= maDemInfo[k].mfLatMax)&& ! (fStartLon_deg >= maDemInfo[k].mfLonMin)&&(fStartLon_deg < maDemInfo[k].mfLonMax)) { ! nMainTile = k; ! bFound = 1; ! } ! } if (!bFound) {return NULL;} ! if (!mbUseDefaultMap) { if (fMain.Open(maDemInfo[nMainTile].mzFileName,tcFile::modeRead)==0) { --- 1340,1358 ---- fStartLon_deg = (float)ntile*SCALE_LOOKUP - 180.0f; ! for (k=0;(k<N_DEMFILES)&&(!bFound);k++) ! { ! if ((fStartLat_deg > maDemInfo[k].mfLatMin)&& ! (fStartLat_deg <= maDemInfo[k].mfLatMax)&& ! (fStartLon_deg >= maDemInfo[k].mfLonMin)&& ! (fStartLon_deg < maDemInfo[k].mfLonMax)) ! { ! nMainTile = k; ! bFound = 1; ! } ! } if (!bFound) {return NULL;} ! if (!mbUseDefaultMap) ! { if (fMain.Open(maDemInfo[nMainTile].mzFileName,tcFile::modeRead)==0) { *************** *** 1423,1426 **** --- 1447,1565 ---- } + /** + * Loads 0.5 x 0.5 deg (default) tile from 10 x 10 DEM tiles + * This is the newer version that uses smaller DEM tiles to allow + * the user to play without downloading the full earth map data. + * + * @return populated tsTileData* or NULL if missing DEM data + */ + tsTileData* tcMapData::LoadTileB(unsigned mtile, unsigned ntile) + { + static errorReports = 0; + tcFile demTile; + + int lat_val = 90 - 10 * (mtile / 20); + int lon_val = -180 + 10 * (ntile / 20); + int lat_offset = (mtile % 20) * M_TILE; // offsets into DEM tile for this tile + int lon_offset = (ntile % 20) * N_TILE; + + wxASSERT(lat_val > -90); + wxASSERT(lat_val <= 90); + wxASSERT(lon_val >= -180); + wxASSERT(lon_val < 180); + + float fStartLat_deg = 90.0f - (float)mtile*SCALE_LOOKUP; + float fStartLon_deg = (float)ntile*SCALE_LOOKUP - 180.0f; + + wxString demTileName = mzDemPath.GetBuffer(); + demTileName += wxString::Format("%dx%d.dat", lat_val, lon_val); + + if (demTile.Open(demTileName.c_str(), tcFile::modeRead) ==0) + { + if (errorReports++ % 100 == 0) + { + fprintf(stderr, "Map tile not found: %s\n", demTileName.c_str()); + } + return NULL; + } + + // checkout new tile + if (mnTilesUsed >= MAX_TILES) {return NULL;} + unsigned int nNewIndex = maAvailableTiles[mnCheckoutIndex++]; + if (mnCheckoutIndex >= MAX_TILES) {mnCheckoutIndex = 0;} + maTileLookup[mtile][ntile] = nNewIndex; + mnTilesUsed++; + tsTileData *pTileData = &maTile[nNewIndex]; + pTileData->m_lat = mtile; + pTileData->n_lon = ntile; + pTileData->mbActive = 1; + // end checkout new tile + + // copy appropriate section of 10 x 10 DEM tile to 0.5 x 0.5 tsTileData + + + + + if ((lat_offset >= M_DEMTILE)||(lon_offset >= N_DEMTILE)) + { + memset(pTileData->maMapData, 0, M_TILE*N_TILE*sizeof(short)); + tcString s; + s.Format("tcMapData - LoadTile (lon %.1f,lat %.1f) (m %d n %d) " + "idx:%d - out of bounds tile", + fStartLon_deg, fStartLat_deg, mtile, ntile, nNewIndex); + fprintf(stderr,"%s\n", s.GetBuffer()); + return pTileData; + } + + + // seek to first row of data in DEM tile + demTile.Seek(lat_offset * N_DEMTILE * sizeof(short), tcFile::current); + + if ((lon_offset+N_TILE) > N_DEMTILE) + { + ME(ME_TILE_STRUCTURE) + } + + int m_src = lat_offset; // row index for source data + int m_dest = 0; // row index for destination data + + int pre_read_offset = lon_offset * sizeof(short); + int read_count = N_TILE*sizeof(short); + int post_read_offset = (N_DEMTILE-N_TILE-lon_offset)*sizeof(short); + + while (m_dest < M_TILE) + { + if (m_src < M_DEMTILE) + { + // seek to first column of data + demTile.Seek(pre_read_offset, tcFile::current); + + demTile.Read((void*)pTileData->maMapData[m_dest], read_count); + + // seek to first column of next row of data + demTile.Seek(post_read_offset, tcFile::current); + } + else + { + ME(ME_TILE_STRUCTURE) + } + m_src++; + m_dest++; + } + demTile.Close(); + + tcString s; + s.Format("tcMapData - LoadTile (lon %.1f,lat %.1f) (m %d n %d) idx:%d - success", + fStartLon_deg, fStartLat_deg, mtile, ntile, nNewIndex); + WTL(s.GetBuffer()); + + if ((pTileData->maMapData[0][0] == 0)&&(pTileData->maMapData[10][10]==0)) + { + WTLC("bad tile data"); + } + + return pTileData; + } + /********************************************************************/ *************** *** 1451,1455 **** /********************************************************************/ ! tcMapData::tcMapData() { mbUseDefaultMap = false; SetDemInfo(); --- 1590,1595 ---- /********************************************************************/ ! tcMapData::tcMapData() ! { mbUseDefaultMap = false; SetDemInfo(); *************** *** 1458,1462 **** ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH|FF_MODERN,"Arial"); ! if (mhFontDefault == NULL) { WTL("mhFontDefault creation failed\n"); } --- 1598,1603 ---- ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH|FF_MODERN,"Arial"); ! if (mhFontDefault == NULL) ! { WTL("mhFontDefault creation failed\n"); } *************** *** 1465,1479 **** ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY, DEFAULT_PITCH|FF_MODERN,"Arial"); ! if (mhFontCountry == NULL) { WTL("mhFontCountry creation failed\n"); } mhPenBox = CreatePen(PS_SOLID,1,RGB(255,255,255)); ! if (mhPenBox == NULL) { WTL("mhPenBox creation failed\n"); } { ! for(int m=0;m<M_LOWRES;m++) { for(int n=0;n<N_LOWRES;n++) { maGlobal[m][n] = 0; --- 1606,1623 ---- ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY, DEFAULT_PITCH|FF_MODERN,"Arial"); ! if (mhFontCountry == NULL) ! { WTL("mhFontCountry creation failed\n"); } mhPenBox = CreatePen(PS_SOLID,1,RGB(255,255,255)); ! if (mhPenBox == NULL) ! { WTL("mhPenBox creation failed\n"); } { ! for(int m=0;m<M_LOWRES;m++) ! { for(int n=0;n<N_LOWRES;n++) { maGlobal[m][n] = 0; *************** *** 1482,1487 **** } { ! for(int m=0;m<M_HIGHRES;m++) { ! for(int n=0;n<N_HIGHRES;n++) { maTheater[m][n] = 0; } --- 1626,1633 ---- } { ! for(int m=0;m<M_HIGHRES;m++) ! { ! for(int n=0;n<N_HIGHRES;n++) ! { maTheater[m][n] = 0; } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** Game.cpp 14 Jun 2004 22:37:12 -0000 1.83 --- Game.cpp 19 Jun 2004 22:00:28 -0000 1.84 *************** *** 111,114 **** --- 111,115 ---- briefingConsoleBottom = NULL; tacticalMap = NULL; + worldMap = NULL; editControl = NULL; optionsView = NULL; *************** *** 231,234 **** --- 232,236 ---- optionsView->SetActive(false); tacticalMap->SetActive(false); + worldMap->SetActive(false); infoConsole->SetActive(false); hookInfo->SetActive(false); *************** *** 454,457 **** --- 456,460 ---- */ InitializeTacticalMap(); + InitializeWorldMap(); InitializeBriefingConsoles(); InitializeDirector(); *************** *** 706,709 **** --- 709,738 ---- } + void tcGame::InitializeWorldMap() + { + mrectWorldMap = mrectMap; + mrectWorldMap.left = mrectWorldMap.right - 256; + mrectWorldMap.top = mrectWorldMap.bottom - 128; + + worldMap = new tcWorldMapView(glCanvas, wxPoint(mrectWorldMap.left, mrectWorldMap.top), + wxSize(mrectWorldMap.right - mrectWorldMap.left, + mrectWorldMap.bottom - mrectWorldMap.top)); + + if (!worldMap) + { + cerr << "worldMap init failed\n"; + throw "worldMap init failed\n"; + } + + + worldMap->AttachMapData(&mcMapData); + worldMap->AttachOptions(tcOptions::Get()); + worldMap->AttachCommandInterface(&mcCommandQueue); + worldMap->Init(); + worldMap->SetActive(false); + worldMap->SetBlend(true); + worldMap->RefreshTerrainView(); + } + bool tcGame::InitGame() { *************** *** 807,826 **** #if 0 ! / * ** Initialize world map * **/ ! mrectWorldMap = mrectMap; ! mrectWorldMap.left = mrectWorldMap.right - 256; ! mrectWorldMap.top = mrectWorldMap.bottom - 128; ! mcWorldMap.SetWindow(mrectWorldMap); ! mcWorldMap.AttachMapData(&mcMapData); ! mcWorldMap.AttachOptions(&mcOptions); ! mcWorldMap.AttachCommandInterface(&mcCommandQueue); ! ! if(!mcWorldMap.CreateSurfaces(mpGraphicsEngine)) ! { ! return false; ! } ! ! mcWorldMap.Init(); ! mcWorldMap.SetActive(false); / * ** Console init * **/ --- 836,840 ---- #if 0 ! / * ** Console init * **/ *************** *** 1222,1225 **** --- 1236,1240 ---- displaySettingsView->SetActive(false); tacticalMap->SetActive(drawTacticalMap); + worldMap->SetActive(drawTacticalMap); infoConsole->SetActive(drawEdgeWindows); hookInfo->SetActive(drawEdgeWindows); *************** *** 1231,1234 **** --- 1246,1250 ---- { tacticalMap->Draw(); + worldMap->Draw(); } if (drawEdgeWindows) *************** *** 1254,1257 **** --- 1270,1274 ---- displaySettingsView->SetActive(false); tacticalMap->SetActive(drawTacticalMap); + worldMap->SetActive(drawTacticalMap); infoConsole->SetActive(false); hookInfo->SetActive(false); *************** *** 1262,1265 **** --- 1279,1283 ---- { tacticalMap->Draw(); + worldMap->Draw(); } if (drawEdgeWindows) *************** *** 1281,1284 **** --- 1299,1303 ---- //displaySettingsView->SetActive(false); tacticalMap->SetActive(false); + worldMap->SetActive(false); infoConsole->SetActive(false); hookInfo->SetActive(false); *************** *** 1297,1300 **** --- 1316,1320 ---- // displaySettingsView->SetActive(false); tacticalMap->SetActive(false); + worldMap->SetActive(false); infoConsole->SetActive(false); hookInfo->SetActive(false); *************** *** 1313,1316 **** --- 1333,1337 ---- displaySettingsView->SetActive(true); tacticalMap->SetActive(false); + worldMap->SetActive(false); infoConsole->SetActive(false); hookInfo->SetActive(false); |