Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

replaymapdisplay.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  ***************************************************************************/
00009 
00010 
00011 #include "replaymapdisplay.h"
00012 #include "spfst.h"
00013 #include "viewcalculation.h"
00014 #include "events.h"
00015 
00016 int ReplayMapDisplay :: checkMapPosition ( int x, int y )
00017 {
00018    mapDisplay->displayPosition(x,y);
00019    /*
00020 
00021    if ( x >= actmap->xsize )
00022       x = actmap->xsize - 1;
00023    if ( y >= actmap->ysize )
00024       y = actmap->ysize - 1;
00025 
00026    int a = actmap->xpos;
00027    int b = actmap->ypos;
00028    int xss = idisplaymap.getscreenxsize();
00029    int yss = idisplaymap.getscreenysize();
00030 
00031    if ((x < a) || (x >= a + xss )) {
00032       if (x >= xss / 2)
00033          actmap->xpos = (x - xss / 2);
00034       else
00035          actmap->xpos = 0;
00036 
00037    }
00038 
00039    if (y < b   ||   y >= b + yss  ) {
00040       if (y >= yss / 2)
00041          actmap->ypos = (y - yss / 2);
00042       else
00043          actmap->ypos = 0;
00044       if ( actmap->ypos & 1 )
00045          actmap->ypos--;
00046 
00047    }
00048 
00049    if (actmap->xpos + xss > actmap->xsize)
00050       actmap->xpos = actmap->xsize - xss ;
00051    if (actmap->ypos + yss  > actmap->ysize)
00052       actmap->ypos = actmap->ysize - yss ;
00053 
00054    if ((actmap->xpos != a) || (actmap->ypos != b))
00055       return 1;
00056    else
00057       return 0;
00058       */
00059       return 0;
00060 }
00061 
00062 
00063 int ReplayMapDisplay :: displayMovingUnit ( const MapCoordinate3D& start, const MapCoordinate3D& dest, Vehicle* vehicle, int fieldnum, int totalmove, SoundStartCallback startSound )
00064 {
00065    if ( actmap->getPlayerView() < 0 )
00066       return 0;
00067 
00068    
00069    bool view1 = fieldvisiblenow ( getfield ( start.x, start.y ), actmap->getPlayerView() );
00070    
00071    int view2;
00072    tfield* fld2 = actmap->getField ( dest );
00073    
00074    if ( actmap->player[actmap->getPlayerView()].diplomacy.sharesView( vehicle->getOwner() )) 
00075       view2 = fieldVisibility ( fld2, actmap->getPlayerView(), actmap );
00076    else {
00077       // This is a workaround to estimate if the target field will be visible or not once the units is there 
00078       view2 = calcvisibilityfield ( actmap, fld2, actmap->getPlayerView(), -1, actmap->getgameparameter ( cgp_initialMapVisibility ), vehicle->typ->jamming );
00079    }
00080 
00081    /*
00082    if ( vehicle->height >= chschwimmend && vehicle->height <= chhochfliegend ) {
00083       visibility = fieldvisiblenow ( getfield ( start.x, start.y ), actmap->playerView) || fieldvisiblenow ( getfield ( dest.x, dest.y ), actmap->playerView);
00084    } else {
00085       // visibility = (fieldVisibility ( getfield ( start.x, start.y ), actmap->playerView) >= visible_all) && (fieldVisibility ( getfield ( dest.x, dest.y ), actmap->playerView) >= visible_now);
00086       visibility = fieldvisiblenow ( getfield ( start.x, start.y ), actmap->playerView) || fieldvisiblenow ( getfield ( dest.x, dest.y ), actmap->playerView);
00087    }
00088    */
00089    
00090    if ( view1 || (view2 >= visible_now ) ) {
00091       if ( checkMapPosition  ( start.x, start.y ))
00092          displayMap();
00093 
00094       int fc = mapDisplay->displayMovingUnit ( start, dest, vehicle, fieldnum, totalmove, startSound );
00095       if ( fc == 1 ) {
00096          mapDisplay->resetMovement();
00097          mapDisplay->displayMap();
00098       }
00099 
00100       return fc;
00101    } else
00102       return 0;
00103 }
00104 
00105 void ReplayMapDisplay :: displayPosition ( int x, int y )
00106 {
00107    if ( fieldvisiblenow ( getfield ( x, y ), actmap->getPlayerView() )) {
00108       checkMapPosition  ( x, y );
00109       mapDisplay->displayPosition ( x, y );
00110    }
00111 }
00112 
00113 void ReplayMapDisplay :: removeActionCursor ( void )
00114 {
00115    mapDisplay->removeActionCursor();
00116  
00117 }
00118 
00119 void ReplayMapDisplay :: displayActionCursor ( int x1, int y1, int x2, int y2, int secondWait )
00120 {
00121    if ( x1 >= 0 && y1 >= 0 ) {
00122       int i = fieldvisiblenow ( getfield ( x1, y1 ), actmap->getPlayerView() );
00123       if( i ) {
00124          cursor_goto( MapCoordinate( x1, y1 ));
00125          
00126          if ( x2 >= 0 && y2 >= 0 )
00127             wait( 30 );
00128          else
00129             wait();
00130       }
00131    }
00132 
00133    if ( x2 >= 0 && y2 >= 0 ) {
00134       int i = fieldvisiblenow ( getfield ( x2, y2 ), actmap->getPlayerView() );
00135       if( i ) {
00136          cursor_goto( MapCoordinate( x2, y2 ));
00137          if ( secondWait )
00138             wait();
00139       }
00140    }
00141 }
00142 
00143 void ReplayMapDisplay :: wait ( int minTime )
00144 {
00145    int t = ticker;
00146    while ( ticker < t + max ( cursorDelay, minTime ) )
00147       releasetimeslice();
00148 }
00149 
00150 void ReplayMapDisplay :: playPositionalSound( const MapCoordinate& pos, Sound* snd )
00151 {
00152    if ( fieldvisiblenow ( actmap->getField ( pos ), actmap->getPlayerView() )) {
00153       mapDisplay->playPositionalSound( pos, snd );
00154    }
00155 }
00156 
00157 

Generated on Tue Jun 24 01:27:51 2008 for Advanced Strategic Command by  doxygen 1.4.2