Skip to content
Browse files

* Finished local map implementation.

* Added local map.
  • Loading branch information...
1 parent df38052 commit 8e09219edeeccce40a643146dfe95a441a5056d6 @bobbens committed Mar 25, 2012
Showing with 74 additions and 7 deletions.
  1. +12 −0 dat/outfits/maps/localmap.xml
  2. +2 −0 dat/tech.xml
  3. +6 −5 src/land_outfits.c
  4. +44 −0 src/map.c
  5. +4 −0 src/map.h
  6. +6 −2 src/player.c
View
12 dat/outfits/maps/localmap.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<outfit name="Local System Map">
+ <general>
+ <mass>0</mass>
+ <price>25000</price>
+ <description>This map contains information about the local system.</description>
+ <gfx_store>map</gfx_store>
+ </general>
+ <specific type="localmap">
+ <hide>0.5</hide>
+ </specific>
+</outfit>
View
2 dat/tech.xml
@@ -128,6 +128,7 @@
<item>Map: Dvaered Core</item>
<item>Map: Empire Core</item>
<item>Map: Pirate strongholds</item>
+ <item>Local System Map</item>
<item>Unicorp Scrambler</item>
<item>Milspec Scrambler</item>
<item>Unicorp Jammer</item>
@@ -431,6 +432,7 @@
<item>Map: Sol</item>
<item>Map: Dvaered Core</item>
<item>Map: Empire Core</item>
+ <item>Local System Map</item>
</tech>
<!-- Ships -->
View
11 src/land_outfits.c
@@ -343,9 +343,9 @@ int outfit_canBuy( char *name )
char buf[ECON_CRED_STRLEN];
failure = 0;
- q = outfits_getMod();
- outfit = outfit_get(name);
- price = outfit->price * q;
+ q = outfits_getMod();
+ outfit = outfit_get(name);
+ price = outfit->price * q;
/* takes away cargo space but you don't have any */
if (outfit_isMod(outfit) && (outfit->u.mod.cargo < 0)
@@ -354,7 +354,8 @@ int outfit_canBuy( char *name )
failure = 1;
}
/* Map already mapped */
- if (outfit_isMap(outfit) && map_isMapped(outfit)) {
+ if ((outfit_isMap(outfit) && map_isMapped(outfit)) ||
+ (outfit_isLocalMap(outfit) && localmap_isMapped(outfit))) {
land_errDialogueBuild( "You already own this map." );
failure = 1;
return 0;
@@ -436,7 +437,7 @@ int outfit_canSell( char *name )
outfit = outfit_get(name);
/* Map check. */
- if (outfit_isMap(outfit)) {
+ if (outfit_isMap(outfit) || outfit_isLocalMap(outfit)) {
land_errDialogueBuild("You can't sell a map.");
failure = 1;
}
View
44 src/map.c
@@ -1652,6 +1652,50 @@ int map_isMapped( const Outfit* map )
/**
+ * @brief Maps a local map.
+ */
+int localmap_map( const Outfit *lmap )
+{
+ int i;
+ JumpPoint *jp;
+ double hide;
+
+ if (cur_system==NULL)
+ return 0;
+
+ hide = lmap->u.lmap.hide;
+ for (i=0; i<cur_system->njumps; i++) {
+ jp = &cur_system->jumps[i];
+ if (jp->hide >= hide)
+ jp_setFlag( jp, JP_KNOWN );
+ }
+ return 0;
+}
+
+/**
+ * @brief Checks to see if the local map is mapped.
+ */
+int localmap_isMapped( const Outfit *lmap )
+{
+ int i;
+ JumpPoint *jp;
+ double hide;
+
+ if (cur_system==NULL)
+ return 0;
+
+ hide = lmap->u.lmap.hide;
+ for (i=0; i<cur_system->njumps; i++) {
+ jp = &cur_system->jumps[i];
+ if ((jp->hide < hide) || jp_isKnown( jp ))
+ continue;
+ return 0;
+ }
+ return 1;
+}
+
+
+/**
* @brief Shows a map at x, y (relative to wid) with size w,h.
*
* @param wid Window to show map on.
View
4 src/map.h
@@ -34,6 +34,10 @@ StarSystem** map_getJumpPath( int* njumps, const char* sysstart,
int map_map( const Outfit *map );
int map_isMapped( const Outfit* map );
+/* Local map stuff. */
+int localmap_map( const Outfit *lmap );
+int localmap_isMapped( const Outfit *lmap );
+
/* shows a map at x, y (relative to wid) with size w,h */
void map_show( int wid, int x, int y, int w, int h, double zoom );
int map_center( const char *sys );
View
8 src/player.c
@@ -2301,8 +2301,8 @@ int player_outfitOwned( const Outfit* o )
int i;
/* Special case map. */
- if ((outfit_isMap(o)) &&
- map_isMapped(o))
+ if ((outfit_isMap(o) && map_isMapped(o)) ||
+ (outfit_isLocalMap(o) && localmap_isMapped(o)))
return 1;
/* Special case license. */
@@ -2405,6 +2405,10 @@ int player_addOutfit( const Outfit *o, int quantity )
map_map(o);
return 1; /* Success. */
}
+ else if (outfit_isLocalMap(o)) {
+ localmap_map(o);
+ return 1;
+ }
/* special case if it's an outfit */
else if (outfit_isGUI(o)) {
player_guiAdd(o->u.gui.gui);

0 comments on commit 8e09219

Please sign in to comment.
Something went wrong with that request. Please try again.