From 3fc4cb88df46eb0640b0223040f90b5938d4b4e4 Mon Sep 17 00:00:00 2001 From: Allanis Date: Thu, 7 Mar 2013 15:28:35 +0000 Subject: [PATCH] [Add] You can buy ships. :) Free of charge until offer lasts. --- src/land.c | 4 ++-- src/player.c | 25 +++++++++++++++++-------- src/player.h | 2 ++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/land.c b/src/land.c index d1f6217..b4c0be0 100644 --- a/src/land.c +++ b/src/land.c @@ -199,8 +199,8 @@ static void shipyard_buy(char* str) { shipname = toolkit_getList(secondary_wid, "lstShipyard"); ship = ship_get(shipname); - - //Vec2 v; + + player_newShip(ship); } // Spaceport bar. diff --git a/src/player.c b/src/player.c index b656a1f..397b4a6 100644 --- a/src/player.c +++ b/src/player.c @@ -115,8 +115,7 @@ void player_new(void) { uint32_t bufsize; char* buf = pack_readfile(DATA, START_DATA, &bufsize); int l, h; - double x, y, d; - Vec2 v; + double x, y; xmlNodePtr node, cur, tmp; xmlDocPtr doc = xmlParseMemory(buf, bufsize); @@ -169,19 +168,29 @@ void player_new(void) { // Money. credits = RNG(l, h); - // Position and direction. - vect_cset(&v, x, y); - d = RNG(0, 359)/180.*M_PI; - - pilot_create(ship, "Player", faction_get("Player"), NULL, d, &v, NULL, PILOT_PLAYER); - gl_bindCamera(&player->solid->pos); // Set opengl camers. + player_newShip(ship); space_init(system); + // Position and direction. + player_warp(x, y); + player->solid->dir = RNG(0, 359) / 180.*M_PI; + // Welcome message. player_message("Welcome to "APPNAME"!"); player_message("v%d.%d.%d", VMAJOR, VMINOR, VREV); } +// Change the players ship. +void player_newShip(Ship* ship) { + if(player) + pilot_destroy(player); + + pilot_create(ship, "Player", faction_get("Player"), NULL, + 0., NULL, NULL, PILOT_PLAYER); + + gl_bindCamera(&player->solid->pos); // Set opengl camera. +} + void player_message(const char* fmt, ...) { va_list ap; int i; diff --git a/src/player.h b/src/player.h index 41b5f06..b01a2e2 100644 --- a/src/player.h +++ b/src/player.h @@ -21,10 +21,12 @@ extern unsigned int player_flags; extern unsigned int credits; extern unsigned int combat_rating; +// Enums. typedef enum RadarShape_ { RADAR_RECT, RADAR_CIRCLE } RadarShape; // For render functions. // Creation. void player_new(void); +void player_newShip(Ship* ship); // Render. int gui_init(void);