Skip to content

Commit

Permalink
* And there was one whitespace fix to rule them all! (s/ *$//)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Jul 21, 2010
1 parent 42aa97e commit 8336ee7
Show file tree
Hide file tree
Showing 112 changed files with 853 additions and 853 deletions.
62 changes: 31 additions & 31 deletions src/ai.c
Expand Up @@ -27,7 +27,7 @@
*
* Specification
*
* - AI will follow basic tasks defined from Lua AI script.
* - AI will follow basic tasks defined from Lua AI script.
* - if Task is NULL, AI will run "control" task
* - Task is continued every frame
* - Tasks can have subtasks which will be closed when parent task is dead.
Expand All @@ -37,7 +37,7 @@
* - "control" task sets another task
* - "control" task is also run at a set rate (depending on Lua global "control_rate")
* to choose optimal behaviour (task)
*
*
* Memory
*
* The AI currently has per-pilot memory which is accessible as "mem". This
Expand Down Expand Up @@ -895,7 +895,7 @@ static void ai_create( Pilot* pilot, char *param )
L = equip_L;
lua_getglobal(L, "equip");
lp.pilot = cur_pilot->id;
lua_pushpilot(L,lp);
lua_pushpilot(L,lp);
lf.f = cur_pilot->faction;
lua_pushfaction(L,lf);
if (lua_pcall(L, 2, 0, 0)) { /* Error has occurred. */
Expand Down Expand Up @@ -939,7 +939,7 @@ static void ai_create( Pilot* pilot, char *param )
Task *ai_newtask( Pilot *p, const char *func, int subtask, int pos )
{
Task *t, *pointer;

/* Create the new task. */
t = malloc( sizeof(Task) );
t->next = NULL;
Expand Down Expand Up @@ -1328,9 +1328,9 @@ static int aiL_parmour( lua_State *L )
return 1;
}

/*
/*
* gets the pilot's shield in percent
*/
*/
static int aiL_pshield( lua_State *L )
{
double d;
Expand All @@ -1348,7 +1348,7 @@ static int aiL_pshield( lua_State *L )

lua_pushnumber(L, d);
return 1;
}
}

/*
* gets the distance from the pointer
Expand All @@ -1368,18 +1368,18 @@ static int aiL_getdistance( lua_State *L )

else if (lua_islightuserdata(L,1))
v = lua_touserdata(L,1);

/* pilot id as parameter */
else if (lua_isnumber(L,1)) {
n = (unsigned int) lua_tonumber(L,1);
pilot = pilot_get( (unsigned int) lua_tonumber(L,1) );
if (pilot==NULL) {
if (pilot==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
v = &pilot->solid->pos;
}

/* wrong parameter */
else
NLUA_INVALID_PARAMETER();
Expand All @@ -1397,7 +1397,7 @@ static int aiL_getpos( lua_State *L )

if (lua_isnumber(L,1)) {
p = pilot_get((unsigned int)lua_tonumber(L,1)); /* Pilot ID */
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand Down Expand Up @@ -1431,15 +1431,15 @@ static int aiL_minbrakedist( lua_State *L )
/* Get target. */
id = luaL_checklong(L,1);
p = pilot_get(id);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}

/* Set up the vectors. */
vect_cset( &vv, p->solid->vel.x - cur_pilot->solid->vel.x,
p->solid->vel.y - cur_pilot->solid->vel.y );

/* Run the same calculations. */
time = VMOD(vv) /
(cur_pilot->thrust / cur_pilot->solid->mass);
Expand Down Expand Up @@ -1493,7 +1493,7 @@ static int aiL_shipclass( lua_State *L )
if (lua_gettop(L) > 0) {
l = luaL_checklong(L,1);
p = pilot_get(l);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand All @@ -1517,7 +1517,7 @@ static int aiL_shipmass( lua_State *L )
if (lua_gettop(L) > 0) {
l = luaL_checklong(L,1);
p = pilot_get(l);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand Down Expand Up @@ -1556,7 +1556,7 @@ static int aiL_getstanding( lua_State *L )
/* Get parameters. */
id = luaL_checklong(L,1);
p = pilot_get(id);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand Down Expand Up @@ -1631,7 +1631,7 @@ static int aiL_isenemy( lua_State *L )
/* Get the pilot. */
id = luaL_checklong(L,1);
p = pilot_get(id);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand Down Expand Up @@ -1659,7 +1659,7 @@ static int aiL_isally( lua_State *L )
/* Get the pilot. */
id = luaL_checklong(L,1);
p = pilot_get(id);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand Down Expand Up @@ -1687,7 +1687,7 @@ static int aiL_incombat( lua_State *L )
if (lua_gettop(L) > 0) {
id = luaL_checklong(L,1);
p = pilot_get(id);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand All @@ -1714,7 +1714,7 @@ static int aiL_isdisabled( lua_State *L )

id = luaL_checklong(L, 1);
p = pilot_get(id);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand Down Expand Up @@ -1773,7 +1773,7 @@ static int aiL_turn( lua_State *L )
* @usage ai.face( a_pilot ) -- Face a pilot
* @usage ai.face( a_pilot, true ) -- Face away from a pilot
* @usage ai.face( a_pilot, nil, true ) -- Compensate velocity facing a pilot
*
*
* @param target Target to face.
* @param invert Invert away from target.
* @param compensate Compensate for velocity?
Expand All @@ -1797,7 +1797,7 @@ static int aiL_face( lua_State *L )
else {
id = (unsigned int)d;
p = pilot_get(id);
if (p==NULL) {
if (p==NULL) {
NLUA_ERROR(L, "Pilot ID does not belong to a pilot.");
return 0;
}
Expand Down Expand Up @@ -1848,7 +1848,7 @@ static int aiL_face( lua_State *L )
dx += -k_vel * vx;
dy += -k_vel * vy;
}

/* Compensate error and rotate. */
diff = angle_diff( cur_pilot->solid->dir, atan2( dy, dx ) );

Expand All @@ -1870,7 +1870,7 @@ static int aiL_brake( lua_State *L )

d = cur_pilot->solid->dir+M_PI;
if (d >= 2*M_PI) d = fmod(d, 2*M_PI);

diff = angle_diff(d,VANGLE(cur_pilot->solid->vel));
pilot_turn = 10*diff;

Expand Down Expand Up @@ -1966,7 +1966,7 @@ static int aiL_getlandplanet( lua_State *L )
continue;
else if (!only_friend && areEnemies(cur_pilot->faction,cur_system->planets[i]->faction))
continue;

/* Add it. */
ind[ nplanets++ ] = i;
}
Expand Down Expand Up @@ -2001,7 +2001,7 @@ static int aiL_land( lua_State *L )
{
int ret;
Planet *planet;

ret = 0;

if (cur_pilot->nav_planet < 0) {
Expand Down Expand Up @@ -2056,7 +2056,7 @@ static int aiL_takingoff( lua_State *L )
static int aiL_hyperspace( lua_State *L )
{
int dist;

dist = space_hyperspace(cur_pilot);
if (dist == 0.) {
pilot_shootStop( cur_pilot, 0 );
Expand Down Expand Up @@ -2175,7 +2175,7 @@ static int aiL_relvel( lua_State *L )
p->solid->pos.y - cur_pilot->solid->pos.y );
dot = vect_dot( &pv, &vv );
mod = MAX(VMOD(pv), 1.); /* Avoid /0. */

lua_pushnumber(L, dot / mod );
return 1;
}
Expand Down Expand Up @@ -2204,7 +2204,7 @@ static int aiL_e_attack( lua_State *L )
return 1;
}

/*
/*
* Tells the pilot's escorts to hold position.
*/
static int aiL_e_hold( lua_State *L )
Expand Down Expand Up @@ -2684,7 +2684,7 @@ static int aiL_comm( lua_State *L )
{
unsigned int p;
const char *s;

/* Get parameters. */
p = luaL_checklong(L,1);
s = luaL_checkstring(L,2);
Expand Down Expand Up @@ -2739,7 +2739,7 @@ static int aiL_credits( lua_State *L )
}

cur_pilot->credits = luaL_checklong(L,1);

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ai.h
Expand Up @@ -44,7 +44,7 @@ typedef struct Task_ {
char *name; /**< Task name. */

struct Task_* subtask; /**< Subtasks of the current task. */

TaskData dtype; /**< Data type. */
union {
unsigned int num; /**< Pilot ID, etc... */
Expand Down
16 changes: 8 additions & 8 deletions src/array.h
Expand Up @@ -2,11 +2,11 @@
* See Licensing and Copyright notice in naev.h
*/

/**
/**
* @file array.h
*
* @brief Provides macros to work with dynamic arrays.
*
*
* @note Except were noted, macros do not have side effects from
* expations.
*
Expand Down Expand Up @@ -83,7 +83,7 @@ __inline__ static void *_array_end_helper(void *a, size_t e_size)
return c->_array + c->_size * e_size;
}

/**
/**
* @brief Creates a new dynamic array of `basic_type'
*
* @param basic_type Type of the array to create.
Expand Down Expand Up @@ -119,7 +119,7 @@ __inline__ static void *_array_end_helper(void *a, size_t e_size)
do array_grow(ptr_array) = element; while (0)
/**
* @brief Erases elements in interval [first, last).
*
*
* @note Invalidates all iterators.
*
* @param ptr_array Array being manipulated.
Expand All @@ -137,17 +137,17 @@ __inline__ static void *_array_end_helper(void *a, size_t e_size)
*/
#define array_shrink(ptr_array) \
(_array_shrink_helper((void **)(ptr_array), sizeof((ptr_array)[0][0])))
/**
/**
* @brief Frees memory allocated and sets array to NULL.
*
*
* @note Invalidates all iterators.
*
* @param ptr_array Array being manipulated.
*/
#define array_free(ptr_array) \
_array_free_helper((void *)(ptr_array))

/**
/**
* @brief Returns number of elements in the array.
*
* @param ptr_array Array being manipulated.
Expand Down Expand Up @@ -182,7 +182,7 @@ __inline__ static void *_array_end_helper(void *a, size_t e_size)
* @return The first element in the array.
*/
#define array_front(ptr_array) (*array_begin(ptr_array))
/**
/**
* @brief Returns the last element in the array.
*
* @param ptr_array Array being manipulated.
Expand Down
8 changes: 4 additions & 4 deletions src/base64.c
Expand Up @@ -168,7 +168,7 @@ char* base64_encode( size_t *len, char *src, size_t sz )

/* setup padding */
pad = ((sz % 3) == 0) ? 0 : 3 - sz % 3;

/* time to do the bulk work */
i = 0;
for (c=0; c<sz; c+=3) {
Expand All @@ -181,7 +181,7 @@ char* base64_encode( size_t *len, char *src, size_t sz )
n = (src[c] << 16);
n += (c+1<sz) ? (src[c+1] << 8) : 0; /* may be out of range */
n += (c+2<sz) ? (src[c+2] << 0) : 0; /* may be out of range */

/* ch[0-3] are 6 bits each */
ch[0] = (n >> 18) & 63;
ch[1] = (n >> 12) & 63;
Expand Down Expand Up @@ -240,15 +240,15 @@ char* base64_decode( size_t *len, char *src, size_t sz )
n += (c+2<j) ? (dec_ch( dat[c+2] ) << 6) : 0;
n += (c+3<j) ? (dec_ch( dat[c+3] ) << 0) : 0;

/* convert the 24 bits of encoded data into 3 8 bit chunks */
/* convert the 24 bits of encoded data into 3 8 bit chunks */
r[i++] = (n >> 16) & 255;
r[i++] = (n >> 8) & 255;
r[i++] = (n >> 0) & 255;
}

/* cleanup */
free(dat);

(*len) = i - pad; /* must decount the padding */
return r;
}
Expand Down

0 comments on commit 8336ee7

Please sign in to comment.