Update of /cvsroot/sserver/rcsoccersim/rcssserver/src
In directory sc8-pr-cvs1:/tmp/cvs-serv17257/src
Modified Files:
field.C field.h netif.C object.C param.h player.cc referee.cc
referee.h serverparam.h types.h
Log Message:
2002-11-22 Tom Howard <tomhoward@...>
* ./src/field.C
* ./src/field.h
* ./src/netif.C
* ./src/object.C
* ./src/param.h
* ./src/player.cc
* ./src/referee.cc
* ./src/referee.h
* ./src/serverparam.h
* ./src/types.h
Added new catch dynamics and FIFA zone checks
Index: field.C
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/field.C,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** field.C 19 Nov 2002 14:54:40 -0000 1.87
--- field.C 22 Nov 2002 19:23:36 -0000 1.88
***************
*** 91,94 ****
--- 91,95 ----
: team_l ( NULL ),
team_r ( NULL ),
+ m_indirect( false ),
M_last_playon_start( 0 ),
M_last_back_passer( 0 ),
***************
*** 103,106 ****
--- 104,108 ----
M_referees.push_back( new FreeKickRef( *this ) );
M_referees.push_back( new TouchRef( *this ) );
+ M_referees.push_back( new CatchRef( *this ) );
M_referees.push_back( new KeepawayRef( *this ) );
}
***************
*** 1174,1177 ****
--- 1176,1201 ----
for_each( M_referees.begin(), M_referees.end(), &Referee::doAnalyse );
}
+ else if( mode == PM_CatchFault_Left )
+ {
+ M_caught_ball = NULL;
+ motable._inc( mode );
+ clearPlayersFromBall( LEFT );
+ if( ++m_after_catch_fault_time > AFTER_CATCH_FAULT_WAIT )
+ {
+ change_play_mode(PM_IndFreeKick_Right) ;
+ }
+ for_each( M_referees.begin(), M_referees.end(), &Referee::doAnalyse );
+ }
+ else if( mode == PM_CatchFault_Right )
+ {
+ M_caught_ball = NULL;
+ motable._inc( mode );
+ clearPlayersFromBall( RIGHT );
+ if( ++m_after_catch_fault_time > AFTER_CATCH_FAULT_WAIT )
+ {
+ change_play_mode(PM_IndFreeKick_Right) ;
+ }
+ for_each( M_referees.begin(), M_referees.end(), &Referee::doAnalyse );
+ }
else if (mode != PM_BeforeKickOff && mode != PM_TimeOver)
{
***************
*** 1214,1220 ****
prev_ball_pos = ball->pos ;
if( M_caught_ball && mode != PM_BeforeKickOff )
! {
! move_caught_ball() ;
! }
/* pfr 7/26/2000 */
--- 1238,1244 ----
prev_ball_pos = ball->pos ;
if( M_caught_ball && mode != PM_BeforeKickOff )
! {
! move_caught_ball() ;
! }
/* pfr 7/26/2000 */
***************
*** 1594,1603 ****
}
! void Stadium::check_goalie_while_catch(Player *goalie)
{
! RArea pta(PVector((-PITCH_LENGTH/2+PENALTY_AREA_LENGTH/2.0) * goalie->team->side, 0.0),
! PVector(PENALTY_AREA_LENGTH, PENALTY_AREA_WIDTH)) ;
! if (!(pta.inArea(goalie->pos)))
! goalie->pos = pta.nearestEdge(goalie->pos) ;
}
--- 1618,1629 ----
}
! void Stadium::check_goalie_while_catch(Player *)
{
! // not longer used. Instead the ref awards an infringement if the goalie moves the ball outside of the penalty area
!
! // RArea pta(PVector((-PITCH_LENGTH/2+PENALTY_AREA_LENGTH/2.0) * goalie->team->side, 0.0),
! // PVector(PENALTY_AREA_LENGTH, PENALTY_AREA_WIDTH)) ;
! // if (!(pta.inArea(goalie->pos)))
! // goalie->pos = pta.nearestEdge(goalie->pos) ;
}
***************
*** 1686,1704 ****
void Stadium::announce_goal(Team& tm)
{
! static char buf[MaxStringSize] ;
!
! sprintf(buf,"goal_%s_%d",SideStr(tm.side),tm.point) ;
! say(buf) ;
}
BallPosInfo Stadium::check_ball_pos()
{
! static RArea g_l(PVector((-PITCH_LENGTH-GOAL_DEPTH)/2.0,0.0),
! PVector(GOAL_DEPTH,ServerParam::instance().gwidth)) ;
! static RArea g_r(PVector((+PITCH_LENGTH+GOAL_DEPTH)/2.0,0.0),
! PVector(GOAL_DEPTH,ServerParam::instance().gwidth)) ;
! static RArea pt(PVector(0.0,0.0),
! PVector(PITCH_LENGTH,PITCH_WIDTH)) ;
if(g_l.inArea(ball->pos)) return BPI_GoalL ;
--- 1712,1738 ----
void Stadium::announce_goal(Team& tm)
{
! std::ostringstream msg;
! msg << "goal_" << SideStr(tm.side) << "_" << tm.point;
! say( msg.str().c_str() );
}
BallPosInfo Stadium::check_ball_pos()
{
! static RArea g_l( PVector( ( -PITCH_LENGTH-GOAL_DEPTH )*0.5
! - ServerParam::instance().bsize,
! 0.0 ),
! PVector( GOAL_DEPTH , ServerParam::instance().gwidth
! + ServerParam::instance().goalPostRadius() ) );
! static RArea g_r( PVector( ( +PITCH_LENGTH+GOAL_DEPTH )*0.5
! + ServerParam::instance().bsize,
! 0.0 ),
! PVector( GOAL_DEPTH, ServerParam::instance().gwidth
! + ServerParam::instance().goalPostRadius() ) ) ;
! static RArea pt( PVector( 0.0, 0.0 ),
! PVector( PITCH_LENGTH
! + ServerParam::instance().bsize * 2 ,
! PITCH_WIDTH
! + ServerParam::instance().bsize * 2) );
if(g_l.inArea(ball->pos)) return BPI_GoalL ;
***************
*** 1710,1732 ****
Logical Stadium::cross_gline(Side side)
{
! static double tmp ;
! if (prev_ball_pos.x == ball->pos.x)
! return FALSE ;
! if (fabs(ball->pos.x) < PITCH_LENGTH/2.0)
! return FALSE ;
! if ((side * ball->pos.x) >= 0)
! return FALSE ;
! tmp = ((prev_ball_pos.y - ball->pos.y) * (PITCH_LENGTH/2.0) * (-side)
! + prev_ball_pos.x * ball->pos.y - ball->pos.x * prev_ball_pos.y)
! / (prev_ball_pos.x - ball->pos.x) ;
! if (tmp >= -ServerParam::instance().gwidth/2 && tmp <= ServerParam::instance().gwidth/2)
! return TRUE ;
! else
! return FALSE ;
}
--- 1744,1795 ----
Logical Stadium::cross_gline(Side side)
{
! // static double tmp ;
! if( prev_ball_pos.x == ball->pos.x )
! {
! return false ;
! }
! if( fabs( ball->pos.x ) <= PITCH_LENGTH*0.5 + ServerParam::instance().bsize )
! {
! return false;
! }
! if( ( side * ball->pos.x ) >= 0 )
! {
! return false;
! }
! if( fabs( prev_ball_pos.y ) > ( ServerParam::instance().gwidth*0.5
! + ServerParam::instance().goalPostRadius() )
! && fabs( prev_ball_pos.x ) > PITCH_LENGTH*0.5 )
! {
! // then the only goal that could have been scored would be
! // from going behind the goal post. I'm pretty sure that
! // isn't possible anyway, but just in case this function acts
! // as a double check
! return false;
! }
! // this calculation determines the y co-ordinate where the ball actually crosses the goal line
! // tmp = ( ( ( prev_ball_pos.y - ball->pos.y )
! // * ( PITCH_LENGTH/2.0 + ServerParam::instance().bsize )
! // * ( -side )
! // + prev_ball_pos.x * ball->pos.y - ball->pos.x * prev_ball_pos.y )
! // / ( prev_ball_pos.x - ball->pos.x ) ) ;
! // new more readable (thus maintainable) version of the same calc
!
! double delta_x = ball->pos.x - prev_ball_pos.x;
! double delta_y = ball->pos.y - prev_ball_pos.y;
! double dist_to_goal = prev_ball_pos.x - ( PITCH_LENGTH*0.5 + ServerParam::instance().bsize ) * -side;
! double y_intercept = prev_ball_pos.y + dist_to_goal * delta_y / delta_x;
!
! return fabs( y_intercept ) <= ( ServerParam::instance().gwidth*0.5
! + ServerParam::instance().goalPostRadius() );
!
! // if( tmp >= -ServerParam::instance().gwidth/2 && tmp <= ServerParam::instance().gwidth/2 )
! // return TRUE ;
! // else
! // return false ;
}
***************
*** 1735,1743 ****
Stadium::check_goal()
{
! static RArea pt(PVector(0.0,0.0),
! PVector(PITCH_LENGTH,PITCH_WIDTH)) ;
! if ((pt.inArea(ball->pos)))
return false;
if( cross_gline( LEFT ) )
--- 1798,1825 ----
Stadium::check_goal()
{
! if( mode == PM_AfterGoal_Left
! || mode == PM_AfterGoal_Right
! || mode == PM_TimeOver )
! {
! return false;
! }
! if( m_indirect )
! {
! return false;
! }
!
! // FIFA rules: Ball has to be completely outside of the pitch to be considered out
! // static RArea pt( PVector(0.0,0.0),
! // PVector( PITCH_LENGTH
! // + ServerParam::instance().bsize * 2,
! // PITCH_WIDTH
! // + ServerParam::instance().bsize * 2 ) );
! if( fabs( ball->pos.x ) <= PITCH_LENGTH * 0.5 + ServerParam::instance().bsize )
! {
return false;
+ }
+
+
if( cross_gline( LEFT ) )
***************
*** 1858,1871 ****
dinfo2.body.show.pmode = (char)pm ;
! for_each( M_referees.begin(), M_referees.end(),
! Referee::doPlayModeChange( pm ) );
if( pm == PM_Free_Kick_Fault_Left
|| pm == PM_Free_Kick_Fault_Right )
! M_after_free_kick_fault_time = 0;
if (pm == PM_KickOff_Left ||
pm == PM_KickIn_Left ||
pm == PM_FreeKick_Left ||
pm == PM_CornerKick_Left ||
pm == PM_GoalKick_Left)
--- 1940,1958 ----
dinfo2.body.show.pmode = (char)pm ;
! for_each( M_referees.begin(), M_referees.end(),
! Referee::doPlayModeChange( pm ) );
if( pm == PM_Free_Kick_Fault_Left
|| pm == PM_Free_Kick_Fault_Right )
! M_after_free_kick_fault_time = 0;
+ if( pm == PM_CatchFault_Left
+ || pm == PM_CatchFault_Right )
+ m_after_catch_fault_time = 0;
+
if (pm == PM_KickOff_Left ||
pm == PM_KickIn_Left ||
pm == PM_FreeKick_Left ||
+ pm == PM_IndFreeKick_Left ||
pm == PM_CornerKick_Left ||
pm == PM_GoalKick_Left)
***************
*** 1879,1882 ****
--- 1966,1970 ----
pm == PM_KickIn_Right ||
pm == PM_FreeKick_Right ||
+ pm == PM_IndFreeKick_Right ||
pm == PM_CornerKick_Right ||
pm == PM_GoalKick_Right)
***************
*** 1906,1911 ****
else
M_last_playon_start = time;
!
!
say( PlayModeString[pm] );
}
--- 1994,1998 ----
else
M_last_playon_start = time;
!
say( PlayModeString[pm] );
}
***************
*** 1914,1937 ****
Stadium::drop_ball()
{
! static RArea lga(PVector(-PITCH_LENGTH/2 + PENALTY_AREA_LENGTH/2, 0),
! PVector(PENALTY_AREA_LENGTH, PENALTY_AREA_WIDTH));
! static RArea rga(PVector(+PITCH_LENGTH/2 - PENALTY_AREA_LENGTH/2, 0),
! PVector(PENALTY_AREA_LENGTH, PENALTY_AREA_WIDTH));
! if (lga.inArea(ball->pos)) {
! ball->pos.x = -PITCH_LENGTH/2 + PENALTY_AREA_LENGTH;
! if (ball->pos.y > 0) {
! ball->pos.y = +PENALTY_AREA_WIDTH/2;
! } else {
! ball->pos.y = -PENALTY_AREA_WIDTH/2;
! }
}
! else if (rga.inArea(ball->pos)) {
! ball->pos.x = +PITCH_LENGTH/2 - PENALTY_AREA_LENGTH;
! if (ball->pos.y > 0) {
! ball->pos.y = +PENALTY_AREA_WIDTH/2;
! } else {
! ball->pos.y = -PENALTY_AREA_WIDTH/2;
! }
}
referee_drop_ball(ball->pos.x, ball->pos.y, NEUTRAL);
--- 2001,2030 ----
Stadium::drop_ball()
{
! static RArea lga( PVector( -PITCH_LENGTH*0.5
! + PENALTY_AREA_LENGTH*0.5,
! 0 ),
! PVector( PENALTY_AREA_LENGTH,
! PENALTY_AREA_WIDTH ) );
! static RArea rga( PVector( +PITCH_LENGTH*0.5
! - PENALTY_AREA_LENGTH*0.5,
! 0 ),
! PVector( PENALTY_AREA_LENGTH,
! PENALTY_AREA_WIDTH ) );
! if( lga.inArea( ball->pos ) )
! {
! ball->pos.x = -PITCH_LENGTH*0.5 + PENALTY_AREA_LENGTH;
! if( ball->pos.y > 0 )
! ball->pos.y = +PENALTY_AREA_WIDTH*0.5;
! else
! ball->pos.y = -PENALTY_AREA_WIDTH*0.5;
}
! else if( rga.inArea( ball->pos ) )
! {
! ball->pos.x = +PITCH_LENGTH*0.5 - PENALTY_AREA_LENGTH;
! if( ball->pos.y > 0 )
! ball->pos.y = +PENALTY_AREA_WIDTH*0.5;
! else
! ball->pos.y = -PENALTY_AREA_WIDTH*0.5;
}
referee_drop_ball(ball->pos.x, ball->pos.y, NEUTRAL);
***************
*** 1982,1997 ****
void Stadium::goalie_catch(Player *goalie)
{
! char msg[32] ;
- sprintf(msg,"goalie_catch_ball_%s", SideStr(goalie->team->side)) ;
- say(msg) ;
- (goalie->team->side == LEFT) ?
- change_play_mode(PM_FreeKick_Left) : change_play_mode(PM_FreeKick_Right) ;
- set_ball(ball->pos, goalie->team->side) ;
M_caught_ball = goalie;
//last_touch = goalie ;
! for_each( M_referees.begin(), M_referees.end(),
! Referee::doBallTouched( *goalie ) );
! check_player_in_field() ;
}
--- 2075,2112 ----
void Stadium::goalie_catch(Player *goalie)
{
! // char msg[32] ;
!
! // sprintf(msg,"goalie_catch_ball_%s", SideStr(goalie->team->side)) ;
! std::ostringstream msg;
! msg << "goalie_catch_ball_" << SideStr(goalie->team->side);
! say( msg.str().c_str() );
!
! if( goalie->team->side == LEFT )
! change_play_mode(PM_FreeKick_Left);
! else
! change_play_mode(PM_FreeKick_Right);
!
! set_ball(ball->pos, goalie->team->side) ;
!
! PVector new_pos = ball->pos - goalie->pos;
! double mag = new_pos.r();
!
! // I would much prefer to cache the message of the catch command
! // to the end of the cycle and then do all the movements and
! // playmode changes there, but I feel that would be too much of a
! // depature from the current behaviour.
! mag -= ServerParam::instance().bsize + goalie->player_type->playerSize();
! new_pos.r( mag );
! goalie->pos += new_pos;
! goalie->angle_body = new_pos.th();
! goalie->vel = PVector();
!
! collisions();
M_caught_ball = goalie;
//last_touch = goalie ;
! for_each( M_referees.begin(), M_referees.end(),
! Referee::doBallTouched( *goalie ) );
! // check_player_in_field() ;
}
***************
*** 2105,2113 ****
static RArea pt(PVector(0.0,0.0),
! PVector(PITCH_LENGTH - 2.0*ServerParam::instance().ckmargin , PITCH_WIDTH - 2.0*ServerParam::instance().ckmargin)) ;
static RArea g_l(PVector(-PITCH_LENGTH/2.0+GOAL_AREA_LENGTH/2.0, 0.0),
! PVector(GOAL_AREA_LENGTH, GOAL_AREA_WIDTH)) ;
static RArea g_r(PVector(+PITCH_LENGTH/2.0-GOAL_AREA_LENGTH/2.0, 0.0),
! PVector(GOAL_AREA_LENGTH, GOAL_AREA_WIDTH)) ;
after_offside_time = 0 ;
--- 2220,2229 ----
static RArea pt(PVector(0.0,0.0),
! PVector(PITCH_LENGTH - 2.0*ServerParam::instance().ckmargin ,
! PITCH_WIDTH - 2.0*ServerParam::instance().ckmargin)) ;
static RArea g_l(PVector(-PITCH_LENGTH/2.0+GOAL_AREA_LENGTH/2.0, 0.0),
! PVector(GOAL_AREA_LENGTH, GOAL_AREA_WIDTH)) ;
static RArea g_r(PVector(+PITCH_LENGTH/2.0-GOAL_AREA_LENGTH/2.0, 0.0),
! PVector(GOAL_AREA_LENGTH, GOAL_AREA_WIDTH)) ;
after_offside_time = 0 ;
Index: field.h
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/field.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** field.h 19 Nov 2002 14:54:40 -0000 1.60
--- field.h 22 Nov 2002 19:23:36 -0000 1.61
***************
*** 371,377 ****
--- 371,382 ----
TheNumber after_back_pass_time ;
TheNumber M_after_free_kick_fault_time ;
+ TheNumber m_after_catch_fault_time ;
+
// Player *last_touch ;
Player *last_kicker ;
+
+ // should be moved to GoalRef
+ bool m_indirect;
Side kick_off_side ;
***************
*** 538,542 ****
sendPlayerAudio( const Player& player, const std::string& msg );
! void say(char *message, bool ref = true );
Logical coachp() { return coach->assignedp ; } ;
--- 543,547 ----
sendPlayerAudio( const Player& player, const std::string& msg );
! void say( const char *message, bool ref = true );
Logical coachp() { return coach->assignedp ; } ;
***************
*** 590,604 ****
public:
inline void move_caught_ball()
! {
! if( M_caught_ball )
! {
! PVector temp( M_caught_ball->relative_ball_ang.x,
! M_caught_ball->relative_ball_ang.y );
! check_goalie_while_catch( M_caught_ball ) ;
! temp *= ( M_caught_ball->player_type->playerSize ()
! + ServerParam::instance().bsize );
! ball->pos = M_caught_ball->pos + temp;
! clearPlayersFromBall( -M_caught_ball->team->side );
! }
};
--- 595,617 ----
public:
inline void move_caught_ball()
! {
! if( M_caught_ball )
! {
! // old version of move the ball to the player, which doesn't keep it in front of the player
! // PVector temp( M_caught_ball->relative_ball_ang.x,
! // M_caught_ball->relative_ball_ang.y );
! // check_goalie_while_catch( M_caught_ball ) ;
! // temp *= ( M_caught_ball->player_type->playerSize ()
! // + ServerParam::instance().bsize );
! // ball->pos = M_caught_ball->pos + temp;
! // clearPlayersFromBall( -M_caught_ball->team->side );
!
! // new version that keeps the caught ball infront of the player
! PVector temp = Polar2PVector( M_caught_ball->player_type->playerSize()
! + ServerParam::instance().bsize,
! M_caught_ball->angle );
! ball->pos = M_caught_ball->pos + temp;
! clearPlayersFromBall( -M_caught_ball->team->side );
! }
};
***************
*** 628,631 ****
--- 641,645 ----
Player* M_free_kicker;
bool M_free_kicker_dashed;
+
public:
void
***************
*** 736,740 ****
int M_left_child;
int M_right_child;
-
private:
--- 750,753 ----
Index: netif.C
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/netif.C,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** netif.C 19 Nov 2002 14:54:40 -0000 1.74
--- netif.C 22 Nov 2002 19:23:36 -0000 1.75
***************
*** 453,457 ****
}
! void Stadium::say(char *message, bool ref )
{
if ( ref )
--- 453,457 ----
}
! void Stadium::say( const char *message, bool ref )
{
if ( ref )
Index: object.C
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/object.C,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** object.C 19 Nov 2002 14:54:41 -0000 1.38
--- object.C 22 Nov 2002 19:23:36 -0000 1.39
***************
*** 650,657 ****
&& a->pos.distance ( b->pos ) < a->size + b->size )
{
! if (a->type == MPO_Ball && b->type == MPO_Player)
{
Player* player = (Player *)b;
!
// the player that has caught the ball cannot collide with the ball.
if( player == player->stadium->M_caught_ball )
--- 650,657 ----
&& a->pos.distance ( b->pos ) < a->size + b->size )
{
! if( a->type == MPO_Ball && b->type == MPO_Player )
{
Player* player = (Player *)b;
!
// the player that has caught the ball cannot collide with the ball.
if( player == player->stadium->M_caught_ball )
Index: param.h
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/param.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** param.h 29 Oct 2002 20:21:21 -0000 1.13
--- param.h 22 Nov 2002 19:23:36 -0000 1.14
***************
*** 418,421 ****
--- 418,422 ----
#define AFTER_BACKPASS_WAIT 30
#define AFTER_FREE_KICK_FAULT_WAIT 30
+ #define AFTER_CATCH_FAULT_WAIT 30
//#define MaxStringSize 4096
Index: player.cc
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/player.cc,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** player.cc 19 Nov 2002 14:54:41 -0000 1.54
--- player.cc 22 Nov 2002 19:23:36 -0000 1.55
***************
*** 302,305 ****
--- 302,306 ----
static RArea p_r( PVector( +PITCH_LENGTH/2-PENALTY_AREA_LENGTH/2.0, 0.0 ),
PVector( PENALTY_AREA_LENGTH, PENALTY_AREA_WIDTH ) ) ;
+
double cal = ServerParam::instance().catch_area_l;
RArea catchable( PVector( cal/2.0, 0.0 ),
***************
*** 332,354 ****
}
! switch (this->team->side)
! {
! case LEFT:
! if ( !(p_l.inArea(this->pos)) ){
! alive |= CATCH_FAULT;
! return;
! }
! break;
! case RIGHT:
! if ( !(p_r.inArea(this->pos)) ){
! alive |= CATCH_FAULT;
! return;
! }
! break ;
! }
!
tmp = ball->pos - this->pos;
tmp.rotate( -(this->angle + NormalizeMoment(dir)) );
if ( !(catchable.inArea(tmp) ) ||
( drand(1,0) >= goalie_catch_probability) )
--- 333,356 ----
}
! // Tom: Catches can now occur an any position, but the ref will award and infringement if the ball is outside of the penalty area
! // switch (this->team->side)
! // {
! // case LEFT:
! // if ( !(p_l.inArea(this->pos)) ){
! // alive |= CATCH_FAULT;
! // return;
! // }
! // break;
! // case RIGHT:
! // if ( !(p_r.inArea(this->pos)) ){
! // alive |= CATCH_FAULT;
! // return;
! // }
! // break ;
! // }
tmp = ball->pos - this->pos;
tmp.rotate( -(this->angle + NormalizeMoment(dir)) );
+
if ( !(catchable.inArea(tmp) ) ||
( drand(1,0) >= goalie_catch_probability) )
***************
*** 367,377 ****
stadium->backPass( team->side );
}
! else{
! this->goalie_catch_ban = ServerParam::instance().cban_cycle;
! relative_ball_ang = ball->pos - this->pos;
! relative_ball_ang /= relative_ball_ang.r();
! goalie_moves_since_catch = 0;
! // reset the number of times the goalie moved
! stadium->goalie_catch(this) ;
}
--- 369,380 ----
stadium->backPass( team->side );
}
! else
! {
! this->goalie_catch_ban = ServerParam::instance().cban_cycle;
! relative_ball_ang = ball->pos - this->pos;
! relative_ball_ang /= relative_ball_ang.r();
! goalie_moves_since_catch = 0;
! // reset the number of times the goalie moved
! stadium->goalie_catch(this) ;
}
Index: referee.cc
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/referee.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** referee.cc 19 Nov 2002 14:54:41 -0000 1.8
--- referee.cc 22 Nov 2002 19:23:36 -0000 1.9
***************
*** 29,41 ****
Referee::truncateToPitch( PVector pos )
{
! if( pos.y > PITCH_WIDTH * 0.5 )
! pos.y = PITCH_WIDTH * 0.5;
! else if( pos.y < -PITCH_WIDTH * 0.5 )
! pos.y = -PITCH_WIDTH * 0.5;
! if( pos.x > PITCH_LENGTH * 0.5 )
! pos.x = PITCH_LENGTH * 0.5;
! else if( pos.x < -PITCH_LENGTH * 0.5 )
! pos.x = -PITCH_LENGTH * 0.5;
return pos;
--- 29,41 ----
Referee::truncateToPitch( PVector pos )
{
! if( pos.y > PITCH_WIDTH * 0.5 + ServerParam::instance().bsize )
! pos.y = PITCH_WIDTH * 0.5 + ServerParam::instance().bsize;
! else if( pos.y < -PITCH_WIDTH * 0.5 - ServerParam::instance().bsize )
! pos.y = -PITCH_WIDTH * 0.5 - ServerParam::instance().bsize;
! if( pos.x > PITCH_LENGTH * 0.5 + ServerParam::instance().bsize )
! pos.x = PITCH_LENGTH * 0.5 + ServerParam::instance().bsize;
! else if( pos.x < -PITCH_LENGTH * 0.5 - ServerParam::instance().bsize)
! pos.x = -PITCH_LENGTH * 0.5 - ServerParam::instance().bsize;
return pos;
***************
*** 47,70 ****
if( side != RIGHT )
{
! if( pos.x < -PITCH_LENGTH * 0.5 + PENALTY_AREA_LENGTH
! && fabs( pos.y ) < PENALTY_AREA_WIDTH * 0.5 )
{
! pos.x = -PITCH_LENGTH * 0.5 + PENALTY_AREA_LENGTH;
if( pos.y > 0 )
! pos.y = PENALTY_AREA_WIDTH * 0.5;
else
! pos.y = -PENALTY_AREA_WIDTH * 0.5;
}
}
if( side != LEFT )
{
! if( pos.x > PITCH_LENGTH * 0.5 - PENALTY_AREA_LENGTH
! && fabs( pos.y ) < PENALTY_AREA_WIDTH * 0.5 )
{
! pos.x = PITCH_LENGTH * 0.5 - PENALTY_AREA_LENGTH;
if( pos.y > 0 )
! pos.y = PENALTY_AREA_WIDTH * 0.5;
else
! pos.y = -PENALTY_AREA_WIDTH * 0.5;
}
}
--- 47,70 ----
if( side != RIGHT )
{
! if( pos.x < -PITCH_LENGTH * 0.5 + PENALTY_AREA_LENGTH + ServerParam::instance().bsize
! && fabs( pos.y ) < PENALTY_AREA_WIDTH * 0.5 + ServerParam::instance().bsize )
{
! pos.x = -PITCH_LENGTH * 0.5 + PENALTY_AREA_LENGTH + ServerParam::instance().bsize;
if( pos.y > 0 )
! pos.y = PENALTY_AREA_WIDTH * 0.5 + ServerParam::instance().bsize;
else
! pos.y = -PENALTY_AREA_WIDTH * 0.5 - ServerParam::instance().bsize;
}
}
if( side != LEFT )
{
! if( pos.x > PITCH_LENGTH * 0.5 - PENALTY_AREA_LENGTH - ServerParam::instance().bsize
! && fabs( pos.y ) < PENALTY_AREA_WIDTH * 0.5 + ServerParam::instance().bsize )
{
! pos.x = PITCH_LENGTH * 0.5 - PENALTY_AREA_LENGTH - ServerParam::instance().bsize;
if( pos.y > 0 )
! pos.y = PENALTY_AREA_WIDTH * 0.5 + ServerParam::instance().bsize;
else
! pos.y = -PENALTY_AREA_WIDTH * 0.5 - ServerParam::instance().bsize;
}
}
***************
*** 86,89 ****
--- 86,101 ----
void
+ Referee::callCatchFault( Side side, PVector pos )
+ {
+ pos = truncateToPitch( pos );
+ // pos = moveOutOfPenalty( -side, pos );
+
+ if( side == LEFT )
+ M_stadium.placeBall( PM_CatchFault_Right, LEFT, pos );
+ else if( side == RIGHT )
+ M_stadium.placeBall( PM_CatchFault_Left, RIGHT, pos );
+ }
+
+ void
Referee::callFreeKickFault( Side side, PVector pos )
{
***************
*** 207,211 ****
{
if( M_kick_taker != &kicker )
! M_kick_taken = false;
else if( M_kick_taker->count_dash > M_kick_taker_dashes
&& ServerParam::instance().freeKickFaults() )
--- 219,226 ----
{
if( M_kick_taker != &kicker )
! {
! M_kick_taken = false;
! M_stadium.m_indirect = false;
! }
else if( M_kick_taker->count_dash > M_kick_taker_dashes
&& ServerParam::instance().freeKickFaults() )
***************
*** 225,229 ****
callFreeKickFault( M_kick_taker->team->side, M_stadium.ball->pos );
else
! M_kick_taken = false;
}
}
--- 240,247 ----
callFreeKickFault( M_kick_taker->team->side, M_stadium.ball->pos );
else
! {
! M_kick_taken = false;
! M_stadium.m_indirect = false;
! }
}
}
***************
*** 276,282 ****
{
if( pm != PM_PlayOn )
! M_kick_taken = false;
! if ( goalKick( pm ) )
{
M_timer = ServerParam::instance().drop_time;
--- 294,300 ----
{
if( pm != PM_PlayOn )
! M_kick_taken = false;
! if( goalKick( pm ) )
{
M_timer = ServerParam::instance().drop_time;
***************
*** 293,296 ****
--- 311,319 ----
M_timer = ServerParam::instance().drop_time;
+ if( indirectFreeKick( pm ) )
+ M_stadium.m_indirect = true;
+ else if( pm != PM_PlayOn )
+ M_stadium.m_indirect = false;
+
if( !freeKick( pm ) && !goalKick( pm ) )
M_timer = -1;
***************
*** 314,321 ****
--- 337,346 ----
case PM_FreeKick_Right:
case PM_CornerKick_Right:
+ case PM_IndFreeKick_Right:
case PM_KickOff_Left:
case PM_KickIn_Left:
case PM_FreeKick_Left:
case PM_CornerKick_Left:
+ case PM_IndFreeKick_Left:
return true;
default:
***************
*** 325,330 ****
bool
FreeKickRef::ballStopped()
! { return M_stadium.ball->vel.r() < ServerParam::instance().stoppedBallVel();}
bool
--- 350,368 ----
bool
+ FreeKickRef::indirectFreeKick( PlayMode pm )
+ {
+ switch( pm )
+ {
+ case PM_IndFreeKick_Right:
+ case PM_IndFreeKick_Left:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ bool
FreeKickRef::ballStopped()
! { return M_stadium.ball->vel.r() < ServerParam::instance().stoppedBallVel(); }
bool
***************
*** 332,338 ****
{
PVector ball_pos = M_stadium.ball->pos;
! return ( fabs( ball_pos.x ) > PITCH_LENGTH * 0.5 - PENALTY_AREA_LENGTH
! && fabs( ball_pos.x ) < PITCH_LENGTH * 0.5
! && fabs( ball_pos.y ) < PENALTY_AREA_WIDTH * 0.5 );
}
--- 370,377 ----
{
PVector ball_pos = M_stadium.ball->pos;
! return ( fabs( ball_pos.x ) > ( PITCH_LENGTH * 0.5 - PENALTY_AREA_LENGTH
! + ServerParam::instance().bsize )
! && fabs( ball_pos.x ) < PITCH_LENGTH * 0.5 + ServerParam::instance().bsize
! && fabs( ball_pos.y ) < PENALTY_AREA_WIDTH * 0.5 + ServerParam::instance().bsize );
}
***************
*** 356,360 ****
&& M_stadium.mode != PM_TimeOver )
{
! if( fabs( M_stadium.ball->pos.x ) > PITCH_LENGTH * 0.5 )
{
// check for goal kick or corner kick
--- 395,399 ----
&& M_stadium.mode != PM_TimeOver )
{
! if( fabs( M_stadium.ball->pos.x ) > PITCH_LENGTH * 0.5 + ServerParam::instance().bsize )
{
// check for goal kick or corner kick
***************
*** 363,367 ****
side = M_last->team->side;
! if( M_stadium.ball->pos.x > PITCH_LENGTH * 0.5 )
{
if( side == RIGHT )
--- 402,406 ----
side = M_last->team->side;
! if( M_stadium.ball->pos.x > PITCH_LENGTH * 0.5 + ServerParam::instance().bsize )
{
if( side == RIGHT )
***************
*** 370,374 ****
awardGoalKick( RIGHT, M_stadium.ball->pos );
}
! else if( M_stadium.ball->pos.x < PITCH_LENGTH * 0.5 )
{
if( side == LEFT )
--- 409,413 ----
awardGoalKick( RIGHT, M_stadium.ball->pos );
}
! else if( M_stadium.ball->pos.x < PITCH_LENGTH * 0.5 - ServerParam::instance().bsize )
{
if( side == LEFT )
***************
*** 378,382 ****
}
}
! else if( fabs( M_stadium.ball->pos.y ) > PITCH_WIDTH * 0.5 )
{
// check for kick in.
--- 417,421 ----
}
}
! else if( fabs( M_stadium.ball->pos.y ) > PITCH_WIDTH * 0.5 + ServerParam::instance().bsize )
{
// check for kick in.
***************
*** 615,621 ****
!
!
--- 654,700 ----
+ //************
+ // CatchRef
+ //************
! void
! CatchRef::analyse()
! {
! if( M_stadium.M_caught_ball
! && !M_stadium.check_goal()
! && M_stadium.mode != PM_AfterGoal_Left
! && M_stadium.mode != PM_AfterGoal_Right
! && M_stadium.mode != PM_TimeOver )
! {
! if( M_stadium.M_caught_ball->team->side == LEFT )
! {
! // according to FIFA the ball is catchable if it is at
! // least partly within the penalty area, thus we add ball size
! static RArea pen_area( PVector( -PITCH_LENGTH/2+PENALTY_AREA_LENGTH/2.0, 0.0 ),
! PVector( PENALTY_AREA_LENGTH
! + ServerParam::instance().bsize * 2,
! PENALTY_AREA_WIDTH
! + ServerParam::instance().bsize * 2 ) ) ;
! if( !pen_area.inArea( M_stadium.ball->pos ) )
! {
! callCatchFault( RIGHT, M_stadium.ball->pos );
! }
! }
! else if( M_stadium.M_caught_ball->team->side == RIGHT )
! {
! // according to FIFA the ball is catchable if it is at
! // least partly within the penalty area, thus we add ball size
! static RArea pen_area( PVector( +PITCH_LENGTH/2-PENALTY_AREA_LENGTH/2.0, 0.0 ),
! PVector( PENALTY_AREA_LENGTH
! + ServerParam::instance().bsize * 2,
! PENALTY_AREA_WIDTH
! + ServerParam::instance().bsize * 2 ) ) ;
! if( !pen_area.inArea( M_stadium.ball->pos ) )
! {
! callCatchFault( LEFT, M_stadium.ball->pos );
! }
! }
! }
! }
Index: referee.h
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/referee.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** referee.h 19 Nov 2002 14:54:41 -0000 1.4
--- referee.h 22 Nov 2002 19:23:36 -0000 1.5
***************
*** 128,131 ****
--- 128,134 ----
void
+ callCatchFault( Side side, PVector pos );
+
+ void
callFreeKickFault( Side side, PVector pos );
***************
*** 190,193 ****
--- 193,199 ----
bool
+ indirectFreeKick( PlayMode pm );
+
+ bool
ballStopped();
***************
*** 289,292 ****
--- 295,315 ----
void
resetField();
+ };
+
+ class CatchRef
+ : public Referee
+ {
+ public:
+ CatchRef( Stadium& stadium )
+ : Referee( stadium )
+ {}
+
+ virtual
+ ~CatchRef()
+ {}
+
+ virtual
+ void
+ analyse();
};
Index: serverparam.h
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/serverparam.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** serverparam.h 19 Nov 2002 14:54:41 -0000 1.26
--- serverparam.h 22 Nov 2002 19:23:36 -0000 1.27
***************
*** 539,542 ****
--- 539,546 ----
teamRightStart() const
{ return M_team_r_start; }
+
+ double
+ goalPostRadius() const
+ { return 0.06; }
};
Index: types.h
===================================================================
RCS file: /cvsroot/sserver/rcsoccersim/rcssserver/src/types.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** types.h 19 Nov 2002 14:54:41 -0000 1.12
--- types.h 22 Nov 2002 19:23:36 -0000 1.13
***************
*** 126,161 ****
"back_pass_r", \
"free_kick_fault_l", \
! "free_kick_fault_r" \
! }
!
! #define PLAYMODE_STRINGS_SHORT {"",\
! "bko",\
! "to",\
! "play",\
! "kol",\
! "kor",\
! "kil",\
! "kir",\
! "fkl",\
! "fkr",\
! "ckl",\
! "ckr",\
! "gkl",\
! "gkr",\
! "gl",\
! "gr",\
! "db",\
! "ol",\
! "or",\
! "ps",\
! "hj",\
! "flcl",\
! "flcr",\
! "flpl",\
! "flpur",\
! "flml",\
! "flmr",\
! "flbl",\
! "flbr",\
}
--- 126,134 ----
"back_pass_r", \
"free_kick_fault_l", \
! "free_kick_fault_r", \
! "catch_fault_l", \
! "cacth_fault_r", \
! "indirect_free_kick_l", \
! "indirect_free_kick_r" \
}
***************
*** 194,202 ****
PM_Foul_BallOut_Left,
PM_Foul_BallOut_Right,
! PM_Back_Pass_Left,
! PM_Back_Pass_Right,
! PM_Free_Kick_Fault_Left,
! PM_Free_Kick_Fault_Right,
! PM_MAX
} PlayMode ;
--- 167,179 ----
PM_Foul_BallOut_Left,
PM_Foul_BallOut_Right,
! PM_Back_Pass_Left,
! PM_Back_Pass_Right,
! PM_Free_Kick_Fault_Left,
! PM_Free_Kick_Fault_Right,
! PM_CatchFault_Left,
! PM_CatchFault_Right,
! PM_IndFreeKick_Left,
! PM_IndFreeKick_Right,
! PM_MAX
} PlayMode ;
|