[Change] Cleaned up some variable/function names, also added -Wshadow CFLAG.

This commit is contained in:
Allanis 2013-06-28 16:08:56 +01:00
parent 5eff5317c6
commit 185039ae62
12 changed files with 140 additions and 128 deletions

View File

@ -29,7 +29,7 @@ ifeq ($(OS),LINUX)
CFLAGS += -D_POSIX_SOURCE
endif
ifdef DEBUG
CFLAGS += -W -Wall -Wextra -Wpointer-arith -Wmissing-prototypes -Winline -Wcast-align \
CFLAGS += -W -Wall -Wextra -Wshadow -Wpointer-arith -Wmissing-prototypes -Winline -Wcast-align \
-Wmissing-declarations -fno-inline -g3 -DDEBUG -DLUA_USE_APICHECK -std=c99
else
CFLAGS += -O2 -funroll-loops -pipe -std=c99

View File

@ -68,8 +68,6 @@
/* AI profiles. */
static AI_Profile* profiles = NULL;
static int nprofiles = 0;
/* Current AI Lua interpreter. */
static lua_State* L = NULL;
/* Extern pilot hacks. */
extern Pilot** pilot_stack;
@ -79,7 +77,7 @@ static int ai_minbrakedist(lua_State* L); /* Minimal breaking distance. */
static int ai_accel(lua_State* L); /* Accelerate. */
/* Internal C routines. */
static void ai_run(const char* funcname);
static void ai_run(lua_State* L, const char* funcname);
static int ai_loadProfile(char* filename);
static void ai_freetask(Task* t);
/* External C routines. */
@ -208,7 +206,7 @@ static int pilot_target = 0;
static int ai_status = AI_STATUS_NORMAL;
/* Attempt to run a function. */
static void ai_run(const char* funcname) {
static void ai_run(lua_State* L, const char* funcname) {
lua_getglobal(L, funcname);
if(lua_pcall(L, 0, 0, 0))
/* Errors accured. */
@ -252,6 +250,7 @@ int ai_init(void) {
static int ai_loadProfile(char* filename) {
char* buf = NULL;
uint32_t bufsize = 0;
lua_State* L;
profiles = realloc(profiles, sizeof(AI_Profile)*(++nprofiles));
@ -321,6 +320,8 @@ void ai_exit(void) {
/* Heart of hearts of the ai!! Brains of the pilot. */
void ai_think(Pilot* pilot) {
lua_State* L;
cur_pilot = pilot; /* Set current pilot being processed. */
L = cur_pilot->ai->L; /* Set the AI profile to the current pilot's. */
@ -332,13 +333,13 @@ void ai_think(Pilot* pilot) {
/* Control function if pilot is idle or tick is up. */
if((cur_pilot->tcontrol < SDL_GetTicks()) || (cur_pilot->task == NULL)) {
ai_run("control"); /* Run control. */
ai_run(L, "control"); /* Run control. */
lua_getglobal(L, "control_rate");
cur_pilot->tcontrol = SDL_GetTicks() + 1000*(int)lua_tonumber(L, -1);
}
if(cur_pilot->task)
/* Pilot has a currently running task. */
ai_run(cur_pilot->task->name);
ai_run(L, cur_pilot->task->name);
/* Make sure pilot_acc and pilot_turn are legal moves. */
if(pilot_acc > 1.) pilot_acc = 1.; /* Value must be <= 1. */
@ -358,6 +359,8 @@ void ai_think(Pilot* pilot) {
/* Pilot is attacked. */
void ai_attacked(Pilot* attacked, const unsigned int attacker) {
lua_State* L;
cur_pilot = attacked;
L = cur_pilot->ai->L;
lua_getglobal(L, "attacked");
@ -367,10 +370,12 @@ void ai_attacked(Pilot* attacked, const unsigned int attacker) {
/* Pilot was just created. */
void ai_create(Pilot* pilot) {
lua_State* L;
cur_pilot = pilot;
L = cur_pilot->ai->L;
ai_status = AI_STATUS_CREATE;
ai_run("create");
ai_run(L, "create");
ai_status = AI_STATUS_NORMAL;
}

View File

@ -138,12 +138,12 @@ int input_getKeybind(char* keybind, KeybindType* type, int* reverse) {
(player && !pilot_isFlag(player, PILOT_HYP_PREP) && \
!pilot_isFlag(player, PILOT_HYP_BEGIN) && \
!pilot_isFlag(player, PILOT_HYPERSPACE))
static void input_key(int keynum, double value, int abs) {
static void input_key(int keynum, double value, int kabs) {
unsigned int t;
/* Accelerating. */
if(KEY("accel")) {
if(abs)player_accel(value);
if(kabs)player_accel(value);
else {
/* Prevent it from getting stuck. */
if(value == KEY_PRESS) player_accel(1.);
@ -166,7 +166,7 @@ static void input_key(int keynum, double value, int abs) {
if(value == KEY_PRESS) { player_setFlag(PLAYER_TURN_LEFT); }
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_LEFT); }
if(abs) { player_turn = -value; }
if(kabs) { player_turn = -value; }
else { player_turn -= value; }
if(player_turn < -1.) { player_turn = -1.; }/* Make sure value is sane. */
}
@ -176,7 +176,7 @@ static void input_key(int keynum, double value, int abs) {
if(value == KEY_PRESS) { player_setFlag(PLAYER_TURN_RIGHT); }
else if(value == KEY_RELEASE) { player_rmFlag(PLAYER_TURN_RIGHT); }
if(abs) { player_turn = value; }
if(kabs) { player_turn = value; }
else { player_turn += value; }
if(player_turn < -1.) { player_turn = -1.; } /* Make sure value is sane. */

View File

@ -75,13 +75,13 @@ static int secondary_wid = 0;
static int terciary_wid = 0; /* For fancy things like news, your ship etc.. */
/* Commodity excahnge. */
static void commodity_exchange(void);
static void commodity_exchange_open(void);
static void commodity_exchange_close(char* str);
static void commodity_update(char* str);
static void commodity_buy(char* str);
static void commodity_sell(char* str);
/* Outfits. */
static void outfits(void);
static void outfits_open(void);
static void outfits_close(char* str);
static void outfits_update(char* str);
static int outfit_canBuy(Outfit* outfit, int q, int errmsg);
@ -91,26 +91,26 @@ static void outfits_sell(char* str);
static int outfits_getMod(void);
static void outfits_renderMod(double bx, double by, double w, double h);
/* Shipyard. */
static void shipyard(void);
static void shipyard_open(void);
static void shipyard_close(char* str);
static void shipyard_update(char* str);
static void shipyard_info(char* str);
static void shipyard_buy(char* str);
/* Your ship. */
static void shipyard_yours(char* str);
static void shipyard_yoursClose(char* str);
static void shipyard_yours_open(char* str);
static void shipyard_yours_close(char* str);
static void shipyard_yoursUpdate(char* str);
static void shipyard_yoursChange(char* str);
static void shipyard_yoursTransport(char* str);
static int shipyard_yoursTransportPrice(char* shipname);
/* Spaceport bar. */
static void spaceport_bar(void);
static void spaceport_bar_open(void);
static void spaceport_bar_close(char* str);
/* News. */
static void news(void);
static void news_open(void);
static void news_close(char* str);
/* Mission computer. */
static void misn(void);
static void misn_open(void);
static void misn_close(char* str);
static void misn_accept(char* str);
static void misn_genList(int first);
@ -120,7 +120,7 @@ static int refuel_price(void);
static void spaceport_refuel(char* str);
/* The local market. */
static void commodity_exchange(void) {
static void commodity_exchange_open(void) {
int i;
char** goods;
secondary_wid = window_create("Commodity Exchange", -1, -1,
@ -236,8 +236,8 @@ static void commodity_sell(char* str) {
commodity_update(NULL);
}
static void outfits(void) {
char** outfits;
static void outfits_open(void) {
char** soutfits;
int noutfits;
char buf[128];
@ -289,10 +289,10 @@ static void outfits(void) {
&gl_smallFont, NULL, NULL);
/* Set up the outfits to buy/sell. */
outfits = outfit_getTech(&noutfits, land_planet->tech, PLANET_TECH_MAX);
soutfits = outfit_getTech(&noutfits, land_planet->tech, PLANET_TECH_MAX);
window_addList(secondary_wid, 20, 40,
200, OUTFITS_HEIGHT-80, "lstOutfits",
outfits, noutfits, 0, outfits_update);
soutfits, noutfits, 0, outfits_update);
/* Write the outfits stuff. */
outfits_update(NULL);
@ -483,7 +483,7 @@ static void outfits_renderMod(double bx, double by, double w, double h) {
&cBlack, buf);
}
static void shipyard(void) {
static void shipyard_open(void) {
char** ships;
int nships;
char buf[128];
@ -498,7 +498,7 @@ static void shipyard(void) {
window_addButton(secondary_wid, -20, 40+BUTTON_HEIGHT,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnYourShips",
"Your Ships", shipyard_yours);
"Your Ships", shipyard_yours_open);
window_addButton(secondary_wid, -40-BUTTON_WIDTH, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBuyShip",
@ -624,7 +624,7 @@ static void shipyard_buy(char* str) {
shipyard_update(NULL);
}
static void shipyard_yours(char* str) {
static void shipyard_yours_open(char* str) {
(void)str;
char** ships;
int nships;
@ -634,7 +634,7 @@ static void shipyard_yours(char* str) {
window_addButton(terciary_wid, -20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnCloseYourShips",
"Shipyard", shipyard_yoursClose);
"Shipyard", shipyard_yours_close);
window_addButton(terciary_wid, -40-BUTTON_WIDTH, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnChangeShip",
@ -682,7 +682,7 @@ static void shipyard_yours(char* str) {
shipyard_yoursUpdate(NULL);
}
static void shipyard_yoursClose(char* str) {
static void shipyard_yours_close(char* str) {
(void)str;
window_destroy(terciary_wid);
terciary_wid = 0;
@ -781,8 +781,8 @@ static void shipyard_yoursChange(char* str) {
player_swapShip(shipname);
/* Recreate the window. */
shipyard_yoursClose(NULL);
shipyard_yours(NULL);
shipyard_yours_close(NULL);
shipyard_yours_open(NULL);
}
static void shipyard_yoursTransport(char* str) {
@ -834,7 +834,7 @@ static int shipyard_yoursTransportPrice(char* shipname) {
}
/* Spaceport bar. */
static void spaceport_bar(void) {
static void spaceport_bar_open(void) {
secondary_wid = window_create("SpacePort Bar", -1, -1, BAR_WIDTH, BAR_HEIGHT);
window_addButton(secondary_wid, -20, 20, BUTTON_WIDTH, BUTTON_HEIGHT,
@ -842,7 +842,7 @@ static void spaceport_bar(void) {
window_addButton(secondary_wid, 20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnNews",
"News", (void(*)(char*))news);
"News", (void(*)(char*))news_open);
window_addText(secondary_wid, 20, -30,
BAR_WIDTH-40, BAR_HEIGHT - 40 - BUTTON_HEIGHT, 0,
@ -862,7 +862,7 @@ static void spaceport_bar_close(char* str) {
}
/* Planet news reports. */
static void news(void) {
static void news_open(void) {
terciary_wid = window_create("News Reports",
-1, -1, NEWS_WIDTH, NEWS_HEIGHT);
@ -883,7 +883,7 @@ static void news_close(char* str) {
}
/* Mission computer, cos' missions rule! */
static void misn(void) {
static void misn_open(void) {
secondary_wid = window_create("Mission Computer",
-1, -1, MISSION_WIDTH, MISSION_HEIGHT);
@ -1035,27 +1035,27 @@ void land(Planet* p) {
if(planet_hasService(land_planet, PLANET_SERVICE_COMMODITY))
window_addButton(land_wid, -20, 20 + BUTTON_HEIGHT + 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnCommodity",
"Commodity Exchange", (void(*)(char*))commodity_exchange);
"Commodity Exchange", (void(*)(char*))commodity_exchange_open);
if(planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD))
window_addButton(land_wid, -20 - BUTTON_WIDTH - 20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnShipyard",
"Shipyard", (void(*)(char*))shipyard);
"Shipyard", (void(*)(char*))shipyard_open);
if(planet_hasService(land_planet, PLANET_SERVICE_OUTFITS))
window_addButton(land_wid, -20 - BUTTON_WIDTH - 20, 20 + BUTTON_HEIGHT + 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnOutfits",
"Outfits", (void(*)(char*))outfits);
"Outfits", (void(*)(char*))outfits_open);
/* Third column. */
if(planet_hasService(land_planet, PLANET_SERVICE_BASIC)) {
window_addButton(land_wid, 20, 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnNews",
"Mission Terminal", (void(*)(char*))misn);
"Mission Terminal", (void(*)(char*))misn_open);
window_addButton(land_wid, 20, 20 + BUTTON_HEIGHT + 20,
BUTTON_WIDTH, BUTTON_HEIGHT, "btnBar",
"Spaceport Bar", (void(*)(char*))spaceport_bar);
"Spaceport Bar", (void(*)(char*))spaceport_bar_open);
if(player->fuel < player->fuel_max) {
credits2str(cred, refuel_price(), 2);

View File

@ -269,7 +269,7 @@ void main_loop(void) {
}
static double fps_dt = 1.;
static double dt = 0.;
static double cur_dt = 0.;
/**
* @brief Controls the FPS.
*/
@ -278,14 +278,14 @@ static void fps_control(void) {
/* dt in ms/1000. */
t = SDL_GetTicks();
dt = (double)(t-gtime)/1000.;
cur_dt = (double)(t-gtime)/1000.;
gtime = t;
if(paused) SDL_Delay(10); /* Drop paused FPS to be nice to the CPU. */
/* If the fps is limited.. */
if((max_fps != 0) && (dt < 1./max_fps)) {
double delay = 1./max_fps - dt;
if((max_fps != 0) && (cur_dt < 1./max_fps)) {
double delay = 1./max_fps - cur_dt;
SDL_Delay(delay);
fps_dt += delay; /* Make sure it displays the propper FPS. */
}
@ -298,13 +298,13 @@ const double fps_min = 1./50.0;
static void update_all(void) {
double tmpdt;
if(dt > 0.25) { /* Slow timers down and rerun calculations */
pause_delay((unsigned int)dt*1000.);
if(cur_dt > 0.25) { /* Slow timers down and rerun calculations */
pause_delay((unsigned int)cur_dt*1000.);
return;
}
/* We'll force a minimum of 50 FPS. */
else if(dt > fps_min) {
tmpdt = dt - fps_min;
else if(cur_dt > fps_min) {
tmpdt = cur_dt - fps_min;
pause_delay((unsigned int)(tmpdt*1000));
update_routine(fps_min);
@ -315,7 +315,7 @@ static void update_all(void) {
tmpdt -= fps_min;
}
}
update_routine(dt);
update_routine(cur_dt);
}
/**
@ -348,9 +348,9 @@ static void update_routine(double dt) {
*/
static void render_all(void) {
/* Setup. */
spfx_start(dt);
spfx_start(cur_dt);
/* BG. */
space_render(dt);
space_render(cur_dt);
planets_render();
player_renderBG();
weapons_render(WEAPON_LAYER_BG);
@ -361,7 +361,7 @@ static void render_all(void) {
/* FG. */
player_render();
spfx_render(SPFX_LAYER_FRONT);
display_fps(dt);
display_fps(cur_dt);
}

View File

@ -153,13 +153,13 @@ static int space_getPlanet(lua_State* L) {
static int space_getSystem(lua_State* L) {
LLUA_MIN_ARGS(1);
char* planetname, *system;
char* planetname, *sysname;
if(lua_isstring(L, -1)) planetname = (char*) lua_tostring(L, -1);
else return 0;
system = planet_getSystem(planetname);
lua_pushstring(L, system);
sysname = planet_getSystem(planetname);
lua_pushstring(L, sysname);
return 1;
}

View File

@ -43,7 +43,7 @@ static int mission_init(Mission* mission, MissionData* misn, int load);
static void mission_freeData(MissionData* mission);
static int mission_alreadyRunning(MissionData* misn);
static int mission_meetCond(MissionData* misn);
static int mission_meetReq(int mission, int faction, char* planet, char* system);
static int mission_meetReq(int mission, int faction, char* planet, char* sysname);
static int mission_matchFaction(MissionData* misn, int faction);
static int mission_location(char* loc);
static MissionData* mission_parse(const xmlNodePtr parent);
@ -199,14 +199,14 @@ static int mission_meetCond(MissionData* misn) {
}
/* Does the mission meet the minimum requirements? */
static int mission_meetReq(int mission, int faction, char* planet, char* system) {
static int mission_meetReq(int mission, int faction, char* planet, char* sysname) {
MissionData* misn;
misn = &mission_stack[mission];
/* Must match planet, system or faction. */
if(!(((misn->avail.planet && strcmp(misn->avail.planet, planet)==0)) ||
(misn->avail.system && (strcmp(misn->avail.system, system)==0)) ||
(misn->avail.system && (strcmp(misn->avail.system, sysname)==0)) ||
mission_matchFaction(misn, faction)))
return 0;
@ -223,7 +223,7 @@ static int mission_meetReq(int mission, int faction, char* planet, char* system)
}
/* Runs bar missions, all lua side and one-shot. */
void missions_bar(int faction, char* planet, char* system) {
void missions_bar(int faction, char* planet, char* sysname) {
MissionData* misn;
Mission mission;
int i;
@ -232,7 +232,7 @@ void missions_bar(int faction, char* planet, char* system) {
for(i = 0; i < mission_nstack; i++) {
misn = &mission_stack[i];
if(misn->avail.loc == MIS_AVAIL_BAR) {
if(!mission_meetReq(i, faction, planet, system))
if(!mission_meetReq(i, faction, planet, sysname))
continue;
chance = (double)(misn->avail.chance % 100)/100.;
@ -350,7 +350,7 @@ static int mission_matchFaction(MissionData* misn, int faction) {
}
/* Generate missions for the computer - special case. */
Mission* missions_computer(int* n, int faction, char* planet, char* system) {
Mission* missions_computer(int* n, int faction, char* planet, char* sysname) {
int i, j, m;
double chance;
int rep;
@ -362,7 +362,7 @@ Mission* missions_computer(int* n, int faction, char* planet, char* system) {
for(i = 0; i < mission_nstack; i++) {
misn = &mission_stack[i];
if(misn->avail.loc == MIS_AVAIL_COMPUTER) {
if(!mission_meetReq(i, faction, planet, system))
if(!mission_meetReq(i, faction, planet, sysname))
continue;
chance = (double)(misn->avail.chance % 100)/100.;

View File

@ -64,10 +64,10 @@ typedef struct Mission_ {
extern Mission player_missions[MISSION_MAX];
/* For mission computer. */
Mission* missions_computer(int* n, int faction, char* planet, char* system);
Mission* missions_computer(int* n, int faction, char* planet, char* sysname);
/* Player accepted mission - mission computer. */
int mission_accept(Mission* mission);
void missions_bar(int faction, char* planet, char* system);
void missions_bar(int faction, char* planet, char* sysname);
/* Misc. */
int mission_getID(char* name);

View File

@ -102,7 +102,7 @@ int music_thread(void* unused) {
(void)unused;
int active; /* Active buffer. */
ALint stat;
ALint state;
/* Main loop. */
while(!music_is(MUSIC_KILL)) {
@ -134,8 +134,9 @@ int music_thread(void* unused) {
while(music_is(MUSIC_PLAYING)) {
soundLock();
alGetSourcei(music_source, AL_BUFFERS_PROCESSED, &stat);
if(stat > 0) {
alGetSourcei(music_source, AL_BUFFERS_PROCESSED, &state);
if(state > 0) {
/* Refill active buffer. */
alSourceUnqueueBuffers(music_source, 1, &music_buffer[active]);
if(stream_loadBuffer(music_buffer[active])) music_rm(MUSIC_PLAYING);
@ -163,14 +164,14 @@ int music_thread(void* unused) {
static int stream_loadBuffer(ALuint buffer) {
int size, section, result;
char data[BUFFER_SIZE]; /* Buffer to hold the data. */
char dat[BUFFER_SIZE]; /* Buffer to hold the data. */
size = 0;
while(size < BUFFER_SIZE) {
/* Fill up the entire data buffer. */
result = ov_read(
&music_vorbis.stream, /* Stream. */
data + size, /* Data. */
dat + size, /* Data. */
BUFFER_SIZE - size, /* Amount to read. */
0, /* Big endian?. */
2, /* 16 bit. */
@ -191,7 +192,7 @@ static int stream_loadBuffer(ALuint buffer) {
if(size == BUFFER_SIZE) break; /* Buffer is full. */
}
/* Load the buffer. */
alBufferData(buffer, music_vorbis.format, data, BUFFER_SIZE,
alBufferData(buffer, music_vorbis.format, dat, BUFFER_SIZE,
music_vorbis.info->rate);
return 0;

View File

@ -208,12 +208,16 @@ void player_new(void) {
/* Create a new player. */
static void player_newMake(void) {
Ship* ship;
char system[20];
char* sysname;
uint32_t bufsize;
char* buf = pack_readfile(DATA, START_DATA, &bufsize);
char* buf;
int l, h, tl, th;
double x, y;
sysname = NULL;
buf = pack_readfile(DATA, START_DATA, &bufsize);
xmlNodePtr node, cur, tmp;
xmlDocPtr doc = xmlParseMemory(buf, bufsize);
@ -246,7 +250,8 @@ static void player_newMake(void) {
tmp = cur->children;
do {
/* System name. TODO: Chance based on percentage. */
if(xml_isNode(tmp, "name")) snprintf(system, 20, xml_get(tmp));
if(xml_isNode(tmp, "name"))
sysname = strdup(xml_get(tmp));
/* Position. */
xmlr_float(tmp, "x", x);
xmlr_float(tmp, "y", y);
@ -280,7 +285,8 @@ static void player_newMake(void) {
/* Create the player and start the game. */
player_newShip(ship, x, y, 0., 0., RNG(0, 359)/180.*M_PI);
space_init(system);
space_init(sysname);
free(sysname);
/* Clear the map. */
map_clear();
@ -1156,11 +1162,11 @@ void gui_free(void) {
/* Used in pilot.c */
/* Basically uses keyboard input instead of AI input. */
void player_think(Pilot* player) {
void player_think(Pilot* pplayer) {
/* Last I checked, the dead didn't think.. */
if(pilot_isFlag(player, PILOT_DEAD)) {
if(pilot_isFlag(pplayer, PILOT_DEAD)) {
/* No point in accelerating or turning. */
player->solid->dir_vel = 0.;
pplayer->solid->dir_vel = 0.;
vect_pset(&player->solid->force, 0., 0.);
return;
}
@ -1168,42 +1174,42 @@ void player_think(Pilot* player) {
/* PLAYER_FACE will take over navigation. */
if(player_isFlag(PLAYER_FACE)) {
if(player_target != PLAYER_ID)
pilot_face(player,
pilot_face(pplayer,
vect_angle(&player->solid->pos,
&pilot_get(player_target)->solid->pos));
else if(planet_target != -1)
pilot_face(player,
pilot_face(pplayer,
vect_angle(&player->solid->pos,
&cur_system->planets[planet_target].pos));
}
/* PLAYER_REVERSE will take over navigation. */
else if(player_isFlag(PLAYER_REVERSE) && (VMOD(player->solid->vel) > 0.))
pilot_face(player, VANGLE(player->solid->vel) + M_PI);
else if(player_isFlag(PLAYER_REVERSE) && (VMOD(pplayer->solid->vel) > 0.))
pilot_face(pplayer, VANGLE(player->solid->vel) + M_PI);
/* Normal navigation sheme. */
else {
player->solid->dir_vel = 0.;
pplayer->solid->dir_vel = 0.;
if(player_turn)
player->solid->dir_vel -= player->turn * player_turn;
pplayer->solid->dir_vel -= player->turn * player_turn;
}
if(player_isFlag(PLAYER_PRIMARY)) pilot_shoot(player, player_target, 0);
if(player_isFlag(PLAYER_PRIMARY)) pilot_shoot(pplayer, player_target, 0);
if(player_isFlag(PLAYER_SECONDARY)) /* Needs a target. */
pilot_shoot(player, player_target, 1);
pilot_shoot(pplayer, player_target, 1);
if(player_isFlag(PLAYER_AFTERBURNER))
vect_pset(&player->solid->force,
player->thrust * player->afterburner->outfit->u.afb.thrust_perc +
player->afterburner->outfit->u.afb.thrust_abs, player->solid->dir);
vect_pset(&pplayer->solid->force,
pplayer->thrust * pplayer->afterburner->outfit->u.afb.thrust_perc +
pplayer->afterburner->outfit->u.afb.thrust_abs, pplayer->solid->dir);
else
vect_pset(&player->solid->force, player->thrust * player_acc,
player->solid->dir);
vect_pset(&pplayer->solid->force, pplayer->thrust * player_acc,
pplayer->solid->dir);
/* Set the listener stuff. */
sound_listener(player->solid->dir,
player->solid->pos.x, player->solid->pos.y,
player->solid->vel.x, player->solid->vel.y);
sound_listener(pplayer->solid->dir,
pplayer->solid->pos.x, pplayer->solid->pos.y,
pplayer->solid->vel.x, pplayer->solid->vel.y);
}
/* Modify the radar resolution. */

View File

@ -368,7 +368,7 @@ static void sound_free(alSound* snd) {
/* Update the sounds and prioritize them. */
void sound_update(void) {
ALint stat;
ALint state;
alVoice* voice, *prev, *next;
if(sound_lock == NULL) return; /* Sound system is off. */
@ -383,9 +383,9 @@ void sound_update(void) {
next = voice->next;
/* Get status. */
stat = -1;
state = -1;
if(voice->source != 0)
alGetSourcei(voice->source, AL_SOURCE_STATE, &stat);
alGetSourcei(voice->source, AL_SOURCE_STATE, &state);
if(!voice_is(voice, VOICE_DONE)) { /* Still working. */
/* Voice has a source. */
@ -401,7 +401,7 @@ void sound_update(void) {
prev = voice;
}else {
/* Delete them. */
if(stat != AL_PLAYING)
if(state != AL_PLAYING)
voice_rm(prev, voice); /* Do not set prev to voice. */
else
prev = voice;
@ -414,12 +414,12 @@ void sound_update(void) {
/* Remove a voice. */
static void voice_rm(alVoice* prev, alVoice* voice) {
ALint stat;
ALint state;
if(voice->source != 0) { /* Source must exist. */
/* Stop it if playing. */
alGetSourcei(voice->source, AL_SOURCE_STATE, &stat);
if(stat == AL_PLAYING) alSourceStop(voice->source);
alGetSourcei(voice->source, AL_SOURCE_STATE, &state);
if(state == AL_PLAYING) alSourceStop(voice->source);
/* Clear it and get rid of it. */
source_stack[source_nstack++] = voice->source; /* Throw it back. */
@ -588,12 +588,12 @@ static void voice_parseFlags(alVoice* voice, const unsigned int flags) {
/* Make a voice play. Must lock before calling. */
static int voice_play(alVoice* voice) {
ALenum err;
ALint stat;
ALint state;
/* Must have buffer. */
if(voice->buffer != 0) {
alGetSourcei(voice->source, AL_SOURCE_STATE, &stat);
if(stat == AL_PLAYING)
alGetSourcei(voice->source, AL_SOURCE_STATE, &state);
if(state == AL_PLAYING)
alSourceStop(voice->source);
/* Set buffer. */
alSourcei(voice->source, AL_BUFFER, voice->buffer);

View File

@ -51,7 +51,7 @@ static int spacename_nstack = 0;
/* Star system stack and co. */
StarSystem* systems_stack = NULL; /* Star system stack. */
int systems_nstack = 0; /* Number of star systems. */
static int nplanets = 0; /* Total number of loaded planets - A little silly. */
static int total_planets = 0; /* Total number of loaded planets - A little silly. */
StarSystem* cur_system = NULL; /* Current star system. */
/* Fleet spawn rate. */
@ -309,15 +309,15 @@ char* planet_getSystem(char* planetname) {
/* Get a planet based on it's name. */
Planet* planet_get(char* planetname) {
int i;
char* sys;
StarSystem* system;
char* sysname;
StarSystem* sys;
sys = planet_getSystem(planetname);
system = system_get(sys);
sysname = planet_getSystem(planetname);
sys = system_get(sysname);
for(i = 0; i < system->nplanets; i++)
if(strcmp(planetname, system->planets[i].name)==0)
return &system->planets[i];
for(i = 0; i < sys->nplanets; i++)
if(strcmp(planetname, sys->planets[i].name)==0)
return &sys->planets[i];
DEBUG("Planet '%s' not found in the universe", planetname);
return NULL;
}
@ -640,7 +640,7 @@ static StarSystem* system_parse(const xmlNodePtr parent) {
do {
if(cur && xml_isNode(cur, "planet")) {
/* Add planet to system. */
nplanets++; /* Increase planet counter. */
total_planets++; /* Increase planet counter. */
planet = planet_pull(xml_get(cur));
tmp->planets = realloc(tmp->planets, sizeof(Planet)*(++tmp->nplanets));
memcpy(tmp->planets+(tmp->nplanets-1), planet, sizeof(Planet));
@ -701,14 +701,14 @@ static StarSystem* system_parse(const xmlNodePtr parent) {
/* Load the jumps into a system. */
static void system_parseJumps(const xmlNodePtr parent) {
int i;
StarSystem* system;
StarSystem* sys;
char* name;
xmlNodePtr cur, node;
name = xml_nodeProp(parent, "name"); /* Already mallocs. */
for(i = 0; i < systems_nstack; i++)
if(strcmp(systems_stack[i].name, name)==0) {
system = &systems_stack[i];
sys = &systems_stack[i];
break;
}
if(i == systems_nstack)
@ -725,9 +725,9 @@ static void system_parseJumps(const xmlNodePtr parent) {
if(xml_isNode(cur, "jump")) {
for(i = 0; i < systems_nstack; i++)
if(strcmp(systems_stack[i].name, xml_get(cur))==0) {
system->njumps++;
system->jumps = realloc(system->jumps, system->njumps*sizeof(int));
system->jumps[system->njumps-1] = i;
sys->njumps++;
sys->jumps = realloc(sys->jumps, sys->njumps*sizeof(int));
sys->jumps[sys->njumps-1] = i;
break;
}
if(i == systems_nstack)
@ -783,7 +783,7 @@ int space_load(void) {
DEBUG("Loaded %d star system%s with %d planet%s",
systems_nstack, (systems_nstack==1) ? "" : "s",
nplanets, (nplanets==1) ? "" : "s");
total_planets, (total_planets==1) ? "" : "s");
return 0;
}