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 #include "gameoptions.h"
00016 #include "spfst-legacy.h"
00017
00018 int ReplayMapDisplay :: checkMapPosition ( int x, int y )
00019 {
00020 mapDisplay->displayPosition(x,y);
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
00060
00061 return 0;
00062 }
00063
00064
00065 int ReplayMapDisplay :: displayMovingUnit ( const MapCoordinate3D& start, const MapCoordinate3D& dest, Vehicle* vehicle, int fieldnum, int totalmove, SoundStartCallback startSound, int duration )
00066 {
00067 if ( actmap->getPlayerView() < 0 )
00068 return 0;
00069
00070
00071 bool view1 = fieldvisiblenow ( getfield ( start.x, start.y ), actmap->getPlayerView() );
00072
00073 int view2;
00074 MapField* fld2 = actmap->getField ( dest );
00075
00076 if ( actmap->player[actmap->getPlayerView()].diplomacy.sharesView( vehicle->getOwner() ))
00077 view2 = fieldVisibility ( fld2, actmap->getPlayerView() );
00078 else {
00079
00080 view2 = calcvisibilityfield ( actmap, fld2, actmap->getPlayerView(), -1, actmap->getgameparameter ( cgp_initialMapVisibility ), vehicle->typ->jamming );
00081 }
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 if ( view1 || (view2 >= visible_now ) ) {
00093 if ( checkMapPosition ( start.x, start.y ))
00094 displayMap();
00095
00096 int fc = mapDisplay->displayMovingUnit ( start, dest, vehicle, fieldnum, totalmove, startSound, duration );
00097 if ( fc == 1 ) {
00098 mapDisplay->resetMovement();
00099 mapDisplay->displayMap();
00100 }
00101
00102 return fc;
00103 } else
00104 return 0;
00105 }
00106
00107 void ReplayMapDisplay :: displayPosition ( int x, int y )
00108 {
00109 if ( fieldvisiblenow ( getfield ( x, y ), actmap->getPlayerView() )) {
00110 checkMapPosition ( x, y );
00111 mapDisplay->displayPosition ( x, y );
00112 }
00113 }
00114
00115 void ReplayMapDisplay :: removeActionCursor ( void )
00116 {
00117 mapDisplay->removeActionCursor();
00118
00119 }
00120
00121 void ReplayMapDisplay :: displayActionCursor ( int x1, int y1, int x2, int y2, int secondWait )
00122 {
00123 if ( x1 >= 0 && y1 >= 0 ) {
00124 int i = fieldvisiblenow ( getfield ( x1, y1 ), actmap->getPlayerView() );
00125 if( i ) {
00126 cursor_goto( MapCoordinate( x1, y1 ));
00127
00128 if ( x2 >= 0 && y2 >= 0 )
00129 wait( 30 );
00130 else
00131 wait();
00132 }
00133 }
00134
00135 if ( x2 >= 0 && y2 >= 0 ) {
00136 int i = fieldvisiblenow ( getfield ( x2, y2 ), actmap->getPlayerView() );
00137 if( i ) {
00138 cursor_goto( MapCoordinate( x2, y2 ));
00139 if ( secondWait )
00140 wait();
00141 }
00142 }
00143 }
00144
00145 void ReplayMapDisplay :: wait ( int minTime )
00146 {
00147 int t = ticker;
00148 while ( ticker < t + max ( cursorDelay, minTime ) )
00149 releasetimeslice();
00150 }
00151
00152 void ReplayMapDisplay :: playPositionalSound( const MapCoordinate& pos, Sound* snd )
00153 {
00154 if ( fieldvisiblenow ( actmap->getField ( pos ), actmap->getPlayerView() )) {
00155 mapDisplay->playPositionalSound( pos, snd );
00156 }
00157 }
00158
00159
00160 int ReplayMapDisplay :: getUnitMovementDuration() const
00161 {
00162 int speed = CGameOptions::Instance()->movespeed;
00163 int factor = max( 10, CGameOptions::Instance()->replayMoveSpeedFactor );
00164 return speed * 100 / factor;
00165 }
00166