[Fix] Uninitailized code error.
This commit is contained in:
parent
127e76c542
commit
5e68d64085
26
src/ai.c
26
src/ai.c
@ -331,9 +331,10 @@ void ai_think(Pilot* pilot) {
|
||||
L = cur_pilot->ai->L; // Set the AI profile to the current pilot's.
|
||||
|
||||
// Clean up some variables.
|
||||
pilot_acc = pilot_turn = 0.;
|
||||
pilot_flags = 0;
|
||||
pilot_target = 0;
|
||||
pilot_acc = 0.;
|
||||
pilot_turn = 0.;
|
||||
pilot_flags = 0;
|
||||
pilot_target = 0;
|
||||
|
||||
// Control function if pilot is idle or tick is up.
|
||||
if((cur_pilot->tcontrol < SDL_GetTicks()) || (cur_pilot->task == NULL)) {
|
||||
@ -341,7 +342,7 @@ void ai_think(Pilot* pilot) {
|
||||
lua_getglobal(L, "control_rate");
|
||||
cur_pilot->tcontrol = SDL_GetTicks() + 1000*(int)lua_tonumber(L, -1);
|
||||
}
|
||||
if(cur_pilot->task != NULL)
|
||||
if(cur_pilot->task)
|
||||
// Pilot has a currently running task.
|
||||
ai_run(cur_pilot->task->name);
|
||||
|
||||
@ -535,8 +536,11 @@ static int ai_pshield(lua_State* L) {
|
||||
|
||||
// Get the distance from the pointer.
|
||||
static int ai_getdistance(lua_State* L) {
|
||||
Vec2* vect;
|
||||
|
||||
MIN_ARGS(1);
|
||||
Vec2* vect = (Vec2*)lua_topointer(L,1);
|
||||
vect = (lua_islightuserdata(L,1)) ?
|
||||
(Vec2*)lua_topointer(L,1) : NULL;
|
||||
lua_pushnumber(L, vect_dist(vect, &cur_pilot->solid->pos));
|
||||
return 1;
|
||||
}
|
||||
@ -672,16 +676,16 @@ static int ai_face(lua_State* L) {
|
||||
vect_cset(&sv, VX(cur_pilot->solid->pos) + FACE_WVEL*VX(cur_pilot->solid->vel),
|
||||
VY(cur_pilot->solid->pos) + FACE_WVEL*VY(cur_pilot->solid->vel));
|
||||
|
||||
if(v != NULL)
|
||||
// Target is static.
|
||||
diff = angle_diff(cur_pilot->solid->dir,
|
||||
(n==-1) ? VANGLE(cur_pilot->solid->pos) :
|
||||
vect_angle(&cur_pilot->solid->pos, v));
|
||||
else
|
||||
if(v == NULL)
|
||||
// Target is dynamic.
|
||||
diff = angle_diff(cur_pilot->solid->dir,
|
||||
(n==-1) ? VANGLE(sv) :
|
||||
vect_angle(&sv, &tv));
|
||||
else
|
||||
// Target is static.
|
||||
diff = angle_diff(cur_pilot->solid->dir,
|
||||
(n==-1) ? VANGLE(cur_pilot->solid->pos) :
|
||||
vect_angle(&cur_pilot->solid->pos, v));
|
||||
|
||||
pilot_turn = mod*diff;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user