rename function in orange with prefix

This commit is contained in:
Lendemor 2015-01-19 15:54:52 +01:00
parent 0bda0053a9
commit 9b6cbe6aad

View File

@ -17,7 +17,7 @@ enum{
typedef struct{
char type; //the type of ressource that was found
t_coord pos; // pos where ressource was found
} t_ressource_spot;
} t_orange_ressource_spot;
typedef struct{
char name; // name of the dude
@ -25,32 +25,32 @@ typedef struct{
char hatched;
char job;
char aim;
t_ressource_spot res_spot;
t_orange_ressource_spot res_spot;
char last_action;
char last_dir;
} t_info_data;
} t_orange_info_data;
typedef union{
t_ressource_spot res_spot;
}t_message;
t_orange_ressource_spot res_spot;
}t_orange_message;
typedef struct{
char name_sender;
char type_message;
t_message message;
} t_com_custom;
t_orange_message message;
} t_orange_com;
//check function
void checkActionSuccess(t_info_data*, int);
void orangeCheckActionSuccess(t_info_data*, int);
//tools functions
int newDir(t_info_data*);
int orangeNewDir(t_info_data*);
t_coord orangeNewPos(t_coord, int);
int distance(t_coord,t_coord);
int orangeDistance(t_coord,t_coord);
//jobs function
void searchJob(t_action*, t_info_data*, int);
void gatherFood(t_action*, t_info_data*, int);
void orangeSearchJob(t_action*, t_info_data*, int);
void orangeGatherFood(t_action*, t_info_data*, int);
t_action orange_update(void* my_info, t_com* communication_data, int success){
t_info_data* data = (t_info_data*)my_info;
@ -65,9 +65,9 @@ t_action orange_update(void* my_info, t_com* communication_data, int success){
data->pos.y=0;
}
checkActionSuccess(data,success);
orangeCheckActionSuccess(data,success);
//searchJob(&action, data, success);
//orangeSearchJob(&action, data, success);
switch(data->job){
case JOBLESS:
action.type = WAIT;
@ -79,7 +79,7 @@ t_action orange_update(void* my_info, t_com* communication_data, int success){
action.dir=0;
break;
case GATHERER:
gatherFood(&action,data,success);
orangeGatherFood(&action,data,success);
break;
case WOODCUTTER:
case MINER:
@ -89,7 +89,7 @@ t_action orange_update(void* my_info, t_com* communication_data, int success){
data->last_dir = action.dir;
return action;
}
void checkActionSuccess(t_info_data* data, int success){
void orangeCheckActionSuccess(t_info_data* data, int success){
if (!success) return;
t_coord aim_pos;
@ -99,13 +99,13 @@ void checkActionSuccess(t_info_data* data, int success){
data->pos=orangeNewPos(data->pos, data->last_dir);
//update aim
if (getInventory() == -1){
if (distance(data->pos,data->res_spot.pos) == 0){
if (orangeDistance(data->pos,data->res_spot.pos) == 0){
data->aim = NO_AIM;
}
}else{
aim_pos.x = 0;
aim_pos.y = 0;
if(distance(data->pos, aim_pos) == 1){
if(orangeDistance(data->pos, aim_pos) == 1){
data->aim=AIM_SPOT;
}
}
@ -126,10 +126,12 @@ void checkActionSuccess(t_info_data* data, int success){
break;
}
}
void searchJob(t_action* action, t_info_data* data, int success){
// job functions
void orangeSearchJob(t_action* action, t_info_data* data, int success){
return;
}
void gatherFood(t_action* action, t_info_data* data, int success){
void orangeGatherFood(t_action* action, t_info_data* data, int success){
int i,t;
//action choice
for(i=0;i<4;i++){
@ -158,12 +160,12 @@ void gatherFood(t_action* action, t_info_data* data, int success){
}
}
action->type= MOVE;
action->dir = newDir(data);
action->dir = orangeNewDir(data);
return;
}
//orange tools
int newDir(t_info_data* data){
int orangeNewDir(t_info_data* data){
int dir;
int current_dist,new_dist;
t_coord aim_pos;
@ -178,12 +180,11 @@ int newDir(t_info_data* data){
aim_pos=data->res_spot.pos;
break;
}
// printf("[%d : %d] [%d : %d]",data->pos.x,data->pos.y,aim_pos.x,aim_pos.y);
current_dist = distance(data->pos,aim_pos);
current_dist = orangeDistance(data->pos,aim_pos);
if (current_dist == 0) return 0;
do{
dir= rand()%4;
new_dist = distance(orangeNewPos(data->pos,dir),aim_pos);
new_dist = orangeDistance(orangeNewPos(data->pos,dir),aim_pos);
}while(current_dist <= new_dist);
if (getNear(dir) == DUDE || getNear(dir) == TREE || getNear(dir) == ROCK || getNear(dir) == IRON_ORE){
@ -211,6 +212,6 @@ t_coord orangeNewPos(t_coord pos, int dir){
}
return new_pos;
}
int distance(t_coord p1, t_coord p2){
int orangeDistance(t_coord p1, t_coord p2){
return abs(p2.x-p1.x) + abs(p2.y-p1.y);
}