00001
00002
00003
00004
00005
00006
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
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
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
00078 view2 = calcvisibilityfield ( actmap, fld2, actmap->getPlayerView(), -1, actmap->getgameparameter ( cgp_initialMapVisibility ), vehicle->typ->jamming );
00079 }
00080
00081
00082
00083
00084
00085
00086
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