[Fix] Fixed some valgrind errors.

This commit is contained in:
Allanis 2014-01-05 20:40:58 +00:00
parent 014b71e8d6
commit 8c4a7a045a
3 changed files with 10 additions and 6 deletions

3
README
View File

@ -76,7 +76,8 @@ Keys:
KEY_IDENTIFIER is the indetifier given below: KEY_IDENTIFIER is the indetifier given below:
KEY_TYPE can be one of keyboard, jaxis or jbutton. KEY_TYPE can be one of keyboard, jaxis or jbutton.
KEY_NUMBER is the number of the key (found with xev) KEY_NUMBER is the number of the key (found with xev usually, just
convert the keysym from hex to base 10).
KEY_REVERSE is whether it is reversed or not, which KEY_REVERSE is whether it is reversed or not, which
is only useful in the case of jaxis. is only useful in the case of jaxis.
MOD_IDENTIFIER is the modifier to take into account, can be on of: MOD_IDENTIFIER is the modifier to take into account, can be on of:

View File

@ -235,10 +235,11 @@ static int planetL_get(lua_State* L) {
/* Get a planet from faction list. */ /* Get a planet from faction list. */
else if(lua_istable(L, 1)) { else if(lua_istable(L, 1)) {
/* Get table length and preallocate. */
nfactions = (int) lua_objlen(L, 1);
factions = malloc(sizeof(int) * nfactions);
/* Load up the table. */ /* Load up the table. */
lua_pushnil(L); lua_pushnil(L);
nfactions = (int)lua_gettop(L);
factions = malloc(sizeof(int) * nfactions);
i = 0; i = 0;
while(lua_next(L, -2) != 0) { while(lua_next(L, -2) != 0) {
f = lua_tofaction(L, -1); f = lua_tofaction(L, -1);

View File

@ -1688,6 +1688,7 @@ void player_land(void) {
int i; int i;
int tp; int tp;
double td, d; double td, d;
Planet* planet;
if(landed) { if(landed) {
/* Player is already landed. */ /* Player is already landed. */
@ -1701,8 +1702,8 @@ void player_land(void) {
return; return;
} }
Planet* planet = cur_system->planets[planet_target];
if(planet_target >= 0) { if(planet_target >= 0) {
planet = cur_system->planets[planet_target];
if(!planet_hasService(planet, PLANET_SERVICE_LAND)) { if(!planet_hasService(planet, PLANET_SERVICE_LAND)) {
player_message("You can't land here."); player_message("You can't land here.");
return; return;
@ -1741,8 +1742,9 @@ void player_land(void) {
td = -1; /* Temp distance. */ td = -1; /* Temp distance. */
tp = -1; /* Temp planet. */ tp = -1; /* Temp planet. */
for(i = 0; i < cur_system->nplanets; i++) { for(i = 0; i < cur_system->nplanets; i++) {
d = vect_dist(&player->solid->pos, &cur_system->planets[i]->pos); planet = cur_system->planets[i];
if(planet_hasService(cur_system->planets[i], PLANET_SERVICE_LAND) && d = vect_dist(&player->solid->pos, &planet->pos);
if(planet_hasService(planet, PLANET_SERVICE_LAND) &&
((tp == -1) || ((td == -1) || (td > d)))) { ((tp == -1) || ((td == -1) || (td > d)))) {
tp = i; tp = i;
td = d; td = d;