[Change] Some code cleanup.
This commit is contained in:
		
							parent
							
								
									5ae72bcacd
								
							
						
					
					
						commit
						bafed15cdc
					
				
							
								
								
									
										43
									
								
								src/player.c
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								src/player.c
									
									
									
									
									
								
							| @ -33,6 +33,7 @@ | ||||
| #include "comm.h" | ||||
| #include "intro.h" | ||||
| #include "perlin.h" | ||||
| #include "ai.h" | ||||
| #include "player.h" | ||||
| 
 | ||||
| #define XML_GUI_ID    "GUIs"    /**< XML section identifier for GUI document. */ | ||||
| @ -1801,6 +1802,9 @@ void player_abortAutonav(char* reason) { | ||||
|  *    @param pplayer Player to think. | ||||
|  */ | ||||
| void player_think(Pilot* pplayer) { | ||||
|   Pilot* target; | ||||
|   double d; | ||||
| 
 | ||||
|   /* Last I checked, the dead didn't think.. */ | ||||
|   if(pilot_isFlag(pplayer, PILOT_DEAD)) { | ||||
|     /* No point in accelerating or turning. */ | ||||
| @ -1811,24 +1815,31 @@ void player_think(Pilot* pplayer) { | ||||
| 
 | ||||
|   /* Autonav takes over normal controls. */ | ||||
|   if(player_isFlag(PLAYER_AUTONAV)) { | ||||
|     /* Abort if lockons detected. */ | ||||
|     if(pplayer->lockons > 0) | ||||
|       player_abortAutonav("Missile Lockon Detected"); | ||||
| 
 | ||||
|     if(space_canHyperspace(pplayer)) { | ||||
|     /* Try to jump. */ | ||||
|     if(space_canHyperspace(pplayer)) | ||||
|       player_jump(); | ||||
|     }	else { | ||||
|       pilot_face(pplayer, VANGLE(pplayer->solid->pos)); | ||||
|       if(player_acc < 1.) | ||||
|     else { /* Keep on moving. */ | ||||
|       /* Only accelerate if facing move dir. */ | ||||
|       d = pilot_face(pplayer, VANGLE(pplayer->solid->pos)); | ||||
|       if((player_acc < 1.) && (d < MIN_DIR_ERR)) | ||||
|         player_accel(1.); | ||||
|   	} | ||||
|   } | ||||
| 
 | ||||
|   /* PLAYER_FACE will take over navigation. */ | ||||
|   else if(player_isFlag(PLAYER_FACE)) { | ||||
|     if(player->target != PLAYER_ID) | ||||
|       pilot_face(pplayer, | ||||
|                  vect_angle(&player->solid->pos, | ||||
|                             &pilot_get(player->target)->solid->pos)); | ||||
|     /* Try to face pilot target */ | ||||
|     if(player->target != PLAYER_ID) { | ||||
|       target = pilot_get(player->target); | ||||
|       if(target != NULL) | ||||
|         pilot_face(pplayer, | ||||
|             vect_angle(&player->solid->pos, &target->solid->pos)); | ||||
|     } | ||||
|     /* If not try to face planet target. */ | ||||
|     else if(planet_target != -1) | ||||
|       pilot_face(pplayer, | ||||
|           vect_angle(&player->solid->pos, | ||||
| @ -1836,8 +1847,22 @@ void player_think(Pilot* pplayer) { | ||||
|   } | ||||
| 
 | ||||
|   /* PLAYER_REVERSE will take over navigation. */ | ||||
|   else if(player_isFlag(PLAYER_REVERSE) && (VMOD(pplayer->solid->vel) > 0.)) | ||||
|   else if(player_isFlag(PLAYER_REVERSE)) { | ||||
|     /* Check to see if already stopped. */ | ||||
| #if 0 | ||||
|     if(VMOD(pplayer->solid->vel) < MIN_VEL_ERR) | ||||
|       player_accel(0.); | ||||
|     else { | ||||
|       d = pilot_face(pplayer, VANGLE(player->solid->vel) + M_PI); | ||||
|       if((player_acc < 1.) && (d < MAX_DIR_ERR)) | ||||
|         player_accel(1.); | ||||
|     } | ||||
| #endif | ||||
|     /*
 | ||||
|      * Hm, I don't think automatic braking is amy good. | ||||
|      */ | ||||
|     pilot_face(pplayer, VANGLE(player->solid->vel) + M_PI); | ||||
|   } | ||||
| 
 | ||||
|   /* Normal navigation sheme. */ | ||||
|   else { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis