[Change] Everything now conforms to last nights cleanups.
This commit is contained in:
parent
5a42e63e4a
commit
25660ff7d1
14
src/ai.c
14
src/ai.c
@ -862,8 +862,8 @@ static int ai_getnearestplanet(lua_State* L) {
|
|||||||
|
|
||||||
/* Cycle through planets. */
|
/* Cycle through planets. */
|
||||||
for(dist = 0., j = -1, i = 0; i < cur_system->nplanets; i++) {
|
for(dist = 0., j = -1, i = 0; i < cur_system->nplanets; i++) {
|
||||||
d = vect_dist(&cur_system->planets[i].pos, &cur_pilot->solid->pos);
|
d = vect_dist(&cur_system->planets[i]->pos, &cur_pilot->solid->pos);
|
||||||
if((!areEnemies(cur_pilot->faction, cur_system->planets[i].faction)) &&
|
if((!areEnemies(cur_pilot->faction, cur_system->planets[i]->faction)) &&
|
||||||
(d < dist)) {
|
(d < dist)) {
|
||||||
/* Closer friendly planet. */
|
/* Closer friendly planet. */
|
||||||
j = i;
|
j = i;
|
||||||
@ -874,7 +874,7 @@ static int ai_getnearestplanet(lua_State* L) {
|
|||||||
/* No friendly planet found. */
|
/* No friendly planet found. */
|
||||||
if(j == -1) return 0;
|
if(j == -1) return 0;
|
||||||
|
|
||||||
lua_pushlightuserdata(L, &cur_system->planets[j].pos);
|
lua_pushlightuserdata(L, &cur_system->planets[j]->pos);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,7 +889,7 @@ static int ai_getrndplanet(lua_State* L) {
|
|||||||
p = RNG(0, cur_system->nplanets-1);
|
p = RNG(0, cur_system->nplanets-1);
|
||||||
|
|
||||||
/* Copy the data into a vector. */
|
/* Copy the data into a vector. */
|
||||||
vectcpy(&v, &cur_system->planets[p].pos);
|
vectcpy(&v, &cur_system->planets[p]->pos);
|
||||||
lua_pushlightuserdata(L, &v);
|
lua_pushlightuserdata(L, &v);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -905,9 +905,9 @@ static int ai_getlandplanet(lua_State* L) {
|
|||||||
if(cur_system->nplanets == 0) return 0; /* No planets. */
|
if(cur_system->nplanets == 0) return 0; /* No planets. */
|
||||||
|
|
||||||
for(nplanets = 0, i = 0; i < cur_system->nplanets; i++)
|
for(nplanets = 0, i = 0; i < cur_system->nplanets; i++)
|
||||||
if(planet_hasService(&cur_system->planets[i], PLANET_SERVICE_BASIC) &&
|
if(planet_hasService(cur_system->planets[i], PLANET_SERVICE_BASIC) &&
|
||||||
!areEnemies(cur_pilot->faction, cur_system->planets[i].faction))
|
!areEnemies(cur_pilot->faction, cur_system->planets[i]->faction))
|
||||||
planets[nplanets++] = &cur_system->planets[i];
|
planets[nplanets++] = cur_system->planets[i];
|
||||||
|
|
||||||
/* No planet to land on found. */
|
/* No planet to land on found. */
|
||||||
if(nplanets == 0) {
|
if(nplanets == 0) {
|
||||||
|
@ -426,9 +426,9 @@ static int systemL_faction(lua_State* L) {
|
|||||||
/* Return result in table. */
|
/* Return result in table. */
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
for(i = 0; i < sys->s->nplanets; i++) {
|
for(i = 0; i < sys->s->nplanets; i++) {
|
||||||
if(sys->s->planets[i].faction > 0) { /* Faction must be valid. */
|
if(sys->s->planets[i]->faction > 0) { /* Faction must be valid. */
|
||||||
lua_pushboolean(L, 1); /* Value. */
|
lua_pushboolean(L, 1); /* Value. */
|
||||||
lua_setfield(L, -2, faction_name(sys->s->planets[i].faction)); /* Key. */
|
lua_setfield(L, -2, faction_name(sys->s->planets[i]->faction)); /* Key. */
|
||||||
/* Allows syntax foo = space.faction("foo"); if foo["bar"] then ... end */
|
/* Allows syntax foo = space.faction("foo"); if foo["bar"] then ... end */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
src/map.c
14
src/map.c
@ -197,13 +197,13 @@ static void map_update(void) {
|
|||||||
nstanding = 0;
|
nstanding = 0;
|
||||||
f = -1;
|
f = -1;
|
||||||
for(i = 0; i < sys->nplanets; i++) {
|
for(i = 0; i < sys->nplanets; i++) {
|
||||||
if((f == -1) && (sys->planets[i].faction > 0)) {
|
if((f == -1) && (sys->planets[i]->faction > 0)) {
|
||||||
f = sys->planets[i].faction;
|
f = sys->planets[i]->faction;
|
||||||
standing += faction_getPlayer(f);
|
standing += faction_getPlayer(f);
|
||||||
nstanding++;
|
nstanding++;
|
||||||
}
|
}
|
||||||
else if(f != sys->planets[i].faction &&
|
else if(f != sys->planets[i]->faction &&
|
||||||
(sys->planets[i].faction>0)) {
|
(sys->planets[i]->faction > 0)) {
|
||||||
/* @todo More verbosity. */
|
/* @todo More verbosity. */
|
||||||
snprintf(buf, 100, "Multiple");
|
snprintf(buf, 100, "Multiple");
|
||||||
break;
|
break;
|
||||||
@ -231,10 +231,10 @@ static void map_update(void) {
|
|||||||
else {
|
else {
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
if(sys->nplanets > 0)
|
if(sys->nplanets > 0)
|
||||||
strcat(buf, sys->planets[0].name);
|
strcat(buf, sys->planets[0]->name);
|
||||||
for(i = 1; i < sys->nplanets; i++) {
|
for(i = 1; i < sys->nplanets; i++) {
|
||||||
strcat(buf, ",\n");
|
strcat(buf, ",\n");
|
||||||
strcat(buf, sys->planets[i].name);
|
strcat(buf, sys->planets[i]->name);
|
||||||
}
|
}
|
||||||
window_modifyText(map_wid, "txtPlanets", buf);
|
window_modifyText(map_wid, "txtPlanets", buf);
|
||||||
}
|
}
|
||||||
@ -249,7 +249,7 @@ static void map_update(void) {
|
|||||||
window_moveWidget(map_wid, "txtServices", -20, y-gl_smallFont.h-5);
|
window_moveWidget(map_wid, "txtServices", -20, y-gl_smallFont.h-5);
|
||||||
services = 0;
|
services = 0;
|
||||||
for(i = 0; i < sys->nplanets; i++)
|
for(i = 0; i < sys->nplanets; i++)
|
||||||
services |= sys->planets[i].services;
|
services |= sys->planets[i]->services;
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
if(services & PLANET_SERVICE_COMMODITY)
|
if(services & PLANET_SERVICE_COMMODITY)
|
||||||
strcat(buf, "Commodity\n");
|
strcat(buf, "Commodity\n");
|
||||||
|
13
src/player.c
13
src/player.c
@ -763,7 +763,7 @@ void player_renderBG(void) {
|
|||||||
pilot_isFlag(player, PLAYER_DESTROYED)) return;
|
pilot_isFlag(player, PLAYER_DESTROYED)) return;
|
||||||
|
|
||||||
if(planet_target >= 0) {
|
if(planet_target >= 0) {
|
||||||
planet = &cur_system->planets[planet_target];
|
planet = cur_system->planets[planet_target];
|
||||||
|
|
||||||
c = faction_getColour(planet->faction);
|
c = faction_getColour(planet->faction);
|
||||||
|
|
||||||
@ -915,7 +915,7 @@ void player_renderGUI(void) {
|
|||||||
|
|
||||||
gl_printMid(&gl_smallFont, (int)gui.nav.w, gui.nav.x,
|
gl_printMid(&gl_smallFont, (int)gui.nav.w, gui.nav.x,
|
||||||
gui.nav.y - 10 - gl_smallFont.h, NULL, "%s",
|
gui.nav.y - 10 - gl_smallFont.h, NULL, "%s",
|
||||||
cur_system->planets[planet_target].name);
|
cur_system->planets[planet_target]->name);
|
||||||
}
|
}
|
||||||
else if(hyperspace_target >= 0) {
|
else if(hyperspace_target >= 0) {
|
||||||
/* Hyperspace target. */
|
/* Hyperspace target. */
|
||||||
@ -1488,7 +1488,7 @@ void player_think(Pilot* pplayer) {
|
|||||||
else if(planet_target != -1)
|
else if(planet_target != -1)
|
||||||
pilot_face(pplayer,
|
pilot_face(pplayer,
|
||||||
vect_angle(&player->solid->pos,
|
vect_angle(&player->solid->pos,
|
||||||
&cur_system->planets[planet_target].pos));
|
&cur_system->planets[planet_target]->pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PLAYER_REVERSE will take over navigation. */
|
/* PLAYER_REVERSE will take over navigation. */
|
||||||
@ -1630,7 +1630,8 @@ void player_land(void) {
|
|||||||
takeoff();
|
takeoff();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Planet* planet = &cur_system->planets[planet_target];
|
|
||||||
|
Planet* planet = cur_system->planets[planet_target];
|
||||||
if(planet_target >= 0) {
|
if(planet_target >= 0) {
|
||||||
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.");
|
||||||
@ -1670,8 +1671,8 @@ 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);
|
d = vect_dist(&player->solid->pos, &cur_system->planets[i]->pos);
|
||||||
if(planet_hasService(&cur_system->planets[i], PLANET_SERVICE_LAND) &&
|
if(planet_hasService(cur_system->planets[i], PLANET_SERVICE_LAND) &&
|
||||||
((tp == -1) || ((td == -1) || (td > d)))) {
|
((tp == -1) || ((td == -1) || (td > d)))) {
|
||||||
tp = i;
|
tp = i;
|
||||||
td = d;
|
td = d;
|
||||||
|
Loading…
Reference in New Issue
Block a user