Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* You can now generate ship csv too.

  • Loading branch information...
commit e190dcf9eec5b8960ebb3ef9da925dad1aa6c85a 1 parent 532f060
@bobbens bobbens authored
View
2  src/Makefile.am
@@ -21,6 +21,7 @@ naev_SOURCES = \
dev.c \
dev_outfit.c \
dev_planet.c \
+ dev_ship.c \
dev_system.c \
dev_sysedit.c \
dev_uniedit.c \
@@ -123,6 +124,7 @@ naev_SOURCES = \
dev.h \
dev_outfit.h \
dev_planet.h \
+ dev_ship.h \
dev_system.h \
dev_sysedit.h \
dev_uniedit.h \
View
12 src/dev.c
@@ -14,18 +14,24 @@
#include "SDL.h"
+#include "log.h"
#include "dev_outfit.h"
+#include "dev_ship.h"
/**
*/
void dev_csv (void)
{
- printf("Generating CSV data...\n");
+ DEBUG("Generating CSV data...");
- printf(" bolt.csv...");
+ DEBUG(" bolt.csv...");
dout_csvBolt( "bolt.csv" );
- printf("done!\n");
+ DEBUG("\b done!");
+
+ DEBUG(" ship.csv...");
+ dship_csv( "ship.csv" );
+ DEBUG("\b done!");
}
View
65 src/dev_ship.c
@@ -0,0 +1,65 @@
+/*
+ * See Licensing and Copyright notice in naev.h
+ */
+
+/**
+ * @file dev_ship.c
+ *
+ * @brief Handles the ship developement routines.
+ */
+
+#include "dev_ship.h"
+
+#include "naev.h"
+
+#include "SDL.h"
+
+#include "ship.h"
+
+
+/**
+ * @brief Dumps ship data to csv.
+ */
+void dship_csv( const char *path )
+{
+ Ship *s, *s_all;
+ int i, n, l;
+ SDL_RWops *rw;
+ char buf[ 1024 ];
+
+ /* File to output to. */
+ rw = SDL_RWFromFile( path, "w" );
+
+ /* Write "header" */
+ l = snprintf( buf, sizeof(buf),
+ "name,base_type,price,license,fabricator,"
+ "thrust,turn,speed,"
+ "crew,mass,cpu,fuel,cargo,"
+ "armour,armour_regen,shield,shield_regen,energy,energy_regen,"
+ "slot high,slot med,slow low\n"
+ );
+ SDL_RWwrite( rw, buf, l, 1 );
+
+ s_all = ship_getAll( &n );
+ for (i=0; i<n; i++) {
+ s = &s_all[i];
+
+ l = snprintf( buf, sizeof(buf),
+ "%s,%s,%d,%s,%s,"
+ "%f,%f,%f,"
+ "%d,%f,%f,%d,%f,"
+ "%f,%f,%f,%f,%f,%f,"
+ "%d,%d,%d\n",
+ s->name, s->base_type, s->price, s->license, s->fabricator,
+ s->thrust, s->turn, s->speed,
+ s->crew, s->mass, s->cpu, s->fuel, s->cap_cargo,
+ s->armour, s->armour_regen, s->shield, s->shield_regen, s->energy, s->energy_regen,
+ s->outfit_nhigh, s->outfit_nmedium, s->outfit_nlow
+ );
+ SDL_RWwrite( rw, buf, l, 1 );
+ }
+
+ /* Close file. */
+ SDL_RWclose( rw );
+}
+
View
14 src/dev_ship.h
@@ -0,0 +1,14 @@
+/*
+ * See Licensing and Copyright notice in naev.h
+ */
+
+
+
+#ifndef DEV_SHIP_H
+# define DEV_SHIP_H
+
+
+void dship_csv( const char *path );
+
+
+#endif /* DEV_SHIP_H */
View
10 src/ship.c
@@ -100,6 +100,16 @@ Ship* ship_getW( const char* name )
/**
+ * @brief Gets all the ships.
+ */
+Ship* ship_getAll( int *n )
+{
+ *n = array_size(ship_stack);
+ return ship_stack;
+}
+
+
+/**
* @brief Comparison function for qsort().
*/
int ship_compareTech( const void *arg1, const void *arg2 )
View
1  src/ship.h
@@ -154,6 +154,7 @@ int ship_statsDesc( ShipStats *s, char *buf, int len, int newline, int pilot );
*/
Ship* ship_get( const char* name );
Ship* ship_getW( const char* name );
+Ship* ship_getAll( int *n );
Ship** ship_getTech( int *n, const int* tech, const int techmax );
char* ship_class( Ship* s );
ShipClass ship_classFromString( char* str );
Please sign in to comment.
Something went wrong with that request. Please try again.