View | Details | Raw Unified | Return to bug 204543 | Differences between
and this patch

Collapse All | Expand All

(-)naev/Makefile (-2 / +1 lines)
Lines 2-9 Link Here
2
# $FreeBSD: head/games/naev/Makefile 395464 2015-08-28 10:48:41Z makc $
2
# $FreeBSD: head/games/naev/Makefile 395464 2015-08-28 10:48:41Z makc $
3
3
4
PORTNAME=	naev
4
PORTNAME=	naev
5
PORTVERSION=	0.6.0
5
PORTVERSION=	0.6.1
6
PORTREVISION=	1
7
CATEGORIES=	games
6
CATEGORIES=	games
8
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-${PORTVERSION}/
7
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-${PORTVERSION}/
9
DIST_SUBDIR=	${PORTNAME}
8
DIST_SUBDIR=	${PORTNAME}
(-)naev/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (naev/naev-0.6.0.tar.bz2) = 0f0b498c7642e36dfaa15f284e13b9aa2d20e4aa01ed812fb7854583e7161cac
1
SHA256 (naev/naev-0.6.1.tar.bz2) = 71d4cf06d2af1a1b84dfb9ed0fd5e4b9b2295f119fc65079d8d36f102ba00b4b
2
SIZE (naev/naev-0.6.0.tar.bz2) = 1054649
2
SIZE (naev/naev-0.6.1.tar.bz2) = 1047908
(-)naev/files/patch-src_board.c (-38 lines)
Lines 1-38 Link Here
1
# Origin: https://github.com/naev/naev/commit/8b4ceb3c5db7171b65f918f278e2d3a0685bf0f2
2
# Subject: Correctly pass boarding ship to pilot board hook
3
# Origin: https://github.com/naev/naev/commit/0b545ee49f33632e892e242807543d6b386a02af
4
# Subject: Run pilot board hook for all pilot, not just player
5
6
--- src/board.c.orig	2015-02-16 17:49:03 UTC
7
+++ src/board.c
8
@@ -143,7 +143,8 @@ void player_board (void)
9
    hparam[0].u.lp.pilot = p->id;
10
    hparam[1].type       = HOOK_PARAM_SENTINEL;
11
    hooks_runParam( "board", hparam );
12
-   pilot_runHook(p, PILOT_HOOK_BOARD);
13
+   hparam[0].u.lp.pilot = PLAYER_ID;
14
+   pilot_runHookParam(p, PILOT_HOOK_BOARD, hparam, 1);
15
 
16
    if (board_stopboard) {
17
       board_boarded = 0;
18
@@ -526,6 +527,7 @@ static void board_update( unsigned int w
19
 int pilot_board( Pilot *p )
20
 {
21
    Pilot *target;
22
+   HookParam hparam[2];
23
 
24
    /* Make sure target is sane. */
25
    target = pilot_get(p->target);
26
@@ -554,6 +556,12 @@ int pilot_board( Pilot *p )
27
    /* Set time it takes to board. */
28
    p->ptimer = 3.;
29
 
30
+   /* Run pilot board hook. */
31
+   hparam[0].type       = HOOK_PARAM_PILOT;
32
+   hparam[0].u.lp.pilot = p->id;
33
+   hparam[1].type       = HOOK_PARAM_SENTINEL;
34
+   pilot_runHookParam(target, PILOT_HOOK_BOARD, hparam, 1);
35
+
36
    return 1;
37
 }
38
 
(-)naev/files/patch-src_equipment.c (-15 lines)
Lines 1-15 Link Here
1
# Origin: https://github.com/naev/naev/commit/9fd2a7dcb3690bc1befe7f9a05d02e204dcfe8a1
2
# Subject: Avoid regenerating the land tabs over top of themselves
3
4
--- src/equipment.c.orig	2015-03-18 02:22:35 UTC
5
+++ src/equipment.c
6
@@ -234,6 +234,9 @@ void equipment_open( unsigned int wid )
7
    GLfloat colour[4*4];
8
    const char *buf;
9
 
10
+   /* Mark as generated. */
11
+   land_tabGenerate(LAND_WINDOW_EQUIPMENT);
12
+
13
    /* Set global WID. */
14
    equipment_wid = wid;
15
 
(-)naev/files/patch-src_hook.c (-16 lines)
Lines 1-16 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
4
--- src/hook.c.orig	2015-02-16 17:49:03 UTC
5
+++ src/hook.c
6
@@ -837,8 +837,8 @@ static Mission *hook_getMission( Hook *h
7
 {
8
    int i;
9
    for (i=0; i<MISSION_MAX; i++)
10
-      if (player_missions[i].id == hook->u.misn.parent)
11
-         return &player_missions[i];
12
+      if (player_missions[i]->id == hook->u.misn.parent)
13
+         return player_missions[i];
14
 
15
    return NULL;
16
 }
(-)naev/files/patch-src_info.c (-87 lines)
Lines 1-87 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
4
--- src/info.c.orig	2015-02-16 17:49:03 UTC
5
+++ src/info.c
6
@@ -785,8 +785,8 @@ static void cargo_jettison( unsigned int
7
       /* Get the mission. */
8
       f = 0;
9
       for (i=0; i<MISSION_MAX; i++) {
10
-         for (j=0; j<player_missions[i].ncargo; j++) {
11
-            if (player_missions[i].cargo[j] == player.p->commodities[pos].id) {
12
+         for (j=0; j<player_missions[i]->ncargo; j++) {
13
+            if (player_missions[i]->cargo[j] == player.p->commodities[pos].id) {
14
                f = 1;
15
                break;
16
             }
17
@@ -799,7 +799,7 @@ static void cargo_jettison( unsigned int
18
                player.p->commodities[pos].id);
19
          return;
20
       }
21
-      misn = &player_missions[i];
22
+      misn = player_missions[i];
23
 
24
       /* We run the "abort" function if it's found. */
25
       ret = misn_tryRun( misn, "abort" );
26
@@ -807,9 +807,7 @@ static void cargo_jettison( unsigned int
27
       /* Now clean up mission. */
28
       if (ret != 2) {
29
          mission_cleanup( misn );
30
-         memmove( misn, &player_missions[i+1],
31
-               sizeof(Mission) * (MISSION_MAX-i-1) );
32
-         memset( &player_missions[MISSION_MAX-1], 0, sizeof(Mission) );
33
+         mission_shift(pos);
34
       }
35
 
36
       /* Reset markers. */
37
@@ -1005,8 +1003,10 @@ static void mission_menu_genList( unsign
38
    misn_names = malloc(sizeof(char*) * MISSION_MAX);
39
    j = 0;
40
    for (i=0; i<MISSION_MAX; i++)
41
-      if (player_missions[i].id != 0)
42
-         misn_names[j++] = (player_missions[i].title!=NULL) ? strdup(player_missions[i].title) : NULL;
43
+      if (player_missions[i]->id != 0)
44
+         misn_names[j++] = (player_missions[i]->title != NULL) ?
45
+               strdup(player_missions[i]->title) : NULL;
46
+
47
    if (j==0) { /* no missions */
48
       misn_names[0] = strdup("No Missions");
49
       j = 1;
50
@@ -1035,7 +1035,7 @@ static void mission_menu_update( unsigne
51
    }
52
 
53
    /* Modify the text. */
54
-   misn = &player_missions[ toolkit_getListPos(wid, "lstMission" ) ];
55
+   misn = player_missions[ toolkit_getListPos(wid, "lstMission" ) ];
56
    window_modifyText( wid, "txtReward", misn->reward );
57
    window_modifyText( wid, "txtDesc", misn->desc );
58
    window_enableButton( wid, "btnAbortMission" );
59
@@ -1052,7 +1052,7 @@ static void mission_menu_abort( unsigned
60
 {
61
    (void)str;
62
    int pos;
63
-   Mission* misn;
64
+   Mission *misn;
65
    int ret;
66
 
67
    if (dialogue_YesNo( "Abort Mission",
68
@@ -1060,7 +1060,7 @@ static void mission_menu_abort( unsigned
69
 
70
       /* Get the mission. */
71
       pos = toolkit_getListPos(wid, "lstMission" );
72
-      misn = &player_missions[pos];
73
+      misn = player_missions[pos];
74
 
75
       /* We run the "abort" function if it's found. */
76
       ret = misn_tryRun( misn, "abort" );
77
@@ -1068,9 +1068,7 @@ static void mission_menu_abort( unsigned
78
       /* Now clean up mission. */
79
       if (ret != 2) {
80
          mission_cleanup( misn );
81
-         memmove( misn, &player_missions[pos+1],
82
-               sizeof(Mission) * (MISSION_MAX-pos-1) );
83
-         memset( &player_missions[MISSION_MAX-1], 0, sizeof(Mission) );
84
+         mission_shift(pos);
85
       }
86
 
87
       /* Reset markers. */
(-)naev/files/patch-src_land.c (-137 lines)
Lines 1-137 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
# Origin: https://github.com/naev/naev/commit/9fd2a7dcb3690bc1befe7f9a05d02e204dcfe8a1
4
# Subject: Avoid regenerating the land tabs over top of themselves
5
# Origin: https://github.com/naev/naev/commit/b9bad809027529c0b0e95d9b8a011cb880229a5d
6
# Subject: Fixed "buy map" button not showing up until after land hooks.
7
8
--- src/land.c.orig	2015-03-05 22:11:11 UTC
9
+++ src/land.c
10
@@ -69,6 +69,8 @@
11
 #define has_visited(f)        (land_visited & (f)) /**< Check if player has visited. */
12
 static unsigned int land_visited = 0; /**< Contains what the player visited. */
13
 
14
+/* Which tabs have been generated by their respective open functions. */
15
+unsigned int land_generated = 0;
16
 
17
 /*
18
  * land variables
19
@@ -187,6 +189,9 @@ static void commodity_exchange_open( uns
20
    char **goods;
21
    int w, h;
22
 
23
+   /* Mark as generated. */
24
+   land_tabGenerate(LAND_WINDOW_COMMODITY);
25
+
26
    /* Get window dimensions. */
27
    window_dimWindow( wid, &w, &h );
28
 
29
@@ -566,6 +571,9 @@ static void bar_open( unsigned int wid )
30
 {
31
    int w, h, iw, ih, bw, bh, dh, th;
32
 
33
+   /* Mark as generated. */
34
+   land_tabGenerate(LAND_WINDOW_BAR);
35
+
36
    /* Set window functions. */
37
    window_onClose( wid, bar_close );
38
 
39
@@ -822,6 +830,9 @@ static void misn_open( unsigned int wid 
40
    int w, h;
41
    int y;
42
 
43
+   /* Mark as generated. */
44
+   land_tabGenerate(LAND_WINDOW_MISSION);
45
+
46
    /* Get window dimensions. */
47
    window_dimWindow( wid, &w, &h );
48
 
49
@@ -900,7 +911,7 @@ static void misn_accept( unsigned int wi
50
 
51
    /* Make sure player can accept the mission. */
52
    for (i=0; i<MISSION_MAX; i++)
53
-      if (player_missions[i].data == NULL) break;
54
+      if (player_missions[i]->data == NULL) break;
55
    if (i >= MISSION_MAX) {
56
       dialogue_alert("You have too many active missions.");
57
       return;
58
@@ -1180,6 +1191,9 @@ void land_genWindows( int load, int chan
59
    if (land_wid > 0) {
60
       land_regen = 2; /* Mark we're regenning. */
61
       window_destroy(land_wid);
62
+
63
+      /* Mark tabs as not generated. */
64
+      land_generated = 0;
65
    }
66
    land_loaded = 0;
67
 
68
@@ -1255,6 +1269,9 @@ void land_genWindows( int load, int chan
69
    /* 1) Create main tab. */
70
    land_createMainTab( land_getWid(LAND_WINDOW_MAIN) );
71
 
72
+   /* Add local system map button. */
73
+   land_checkAddMap();
74
+
75
    /* 2) Set as landed and run hooks. */
76
    if (!regen) {
77
       landed = 1;
78
@@ -1274,24 +1291,34 @@ void land_genWindows( int load, int chan
79
    }
80
 
81
    /* 4) Create other tabs. */
82
+#define should_open(s, w) \
83
+   (planet_hasService(land_planet, s) && (!land_tabGenerated(w)))
84
+
85
+   /* Things get a bit hairy here. Hooks may have triggered a GUI reload via
86
+    * e.g. player.swapShip, so the land tabs may have been generated already
87
+    * and we need to check that before regenerating them.
88
+    */
89
+
90
    /* Basic - bar + missions */
91
-   if (planet_hasService(land_planet, PLANET_SERVICE_BAR))
92
+   if (should_open( PLANET_SERVICE_BAR, LAND_WINDOW_BAR ))
93
       bar_open( land_getWid(LAND_WINDOW_BAR) );
94
-   if (planet_hasService(land_planet, PLANET_SERVICE_MISSIONS))
95
+   if (should_open( PLANET_SERVICE_MISSIONS, LAND_WINDOW_MISSION ))
96
       misn_open( land_getWid(LAND_WINDOW_MISSION) );
97
    /* Outfits. */
98
-   if (planet_hasService(land_planet, PLANET_SERVICE_OUTFITS))
99
+   if (should_open( PLANET_SERVICE_OUTFITS, LAND_WINDOW_OUTFITS ))
100
       outfits_open( land_getWid(LAND_WINDOW_OUTFITS) );
101
    /* Shipyard. */
102
-   if (planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD))
103
+   if (should_open( PLANET_SERVICE_SHIPYARD, LAND_WINDOW_SHIPYARD ))
104
       shipyard_open( land_getWid(LAND_WINDOW_SHIPYARD) );
105
    /* Equipment. */
106
-   if (planet_hasService(land_planet, PLANET_SERVICE_OUTFITS) ||
107
-         planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD))
108
+   if ((planet_hasService(land_planet, PLANET_SERVICE_OUTFITS) ||
109
+         planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD)) &&
110
+         !land_tabGenerated( LAND_WINDOW_EQUIPMENT ))
111
       equipment_open( land_getWid(LAND_WINDOW_EQUIPMENT) );
112
    /* Commodity. */
113
-   if (planet_hasService(land_planet, PLANET_SERVICE_COMMODITY))
114
+   if (should_open( PLANET_SERVICE_COMMODITY, LAND_WINDOW_COMMODITY ))
115
       commodity_exchange_open( land_getWid(LAND_WINDOW_COMMODITY) );
116
+#undef should_open
117
 
118
    if (!regen) {
119
       /* Reset markers if needed. */
120
@@ -1310,9 +1337,6 @@ void land_genWindows( int load, int chan
121
    if (changetab && land_windowsMap[ last_window ] != -1)
122
       window_tabWinSetActive( land_wid, "tabLand", land_windowsMap[ last_window ] );
123
 
124
-   /* Add local system map button. */
125
-   land_checkAddMap();
126
-
127
    /* Refuel if necessary. */
128
    land_refuel();
129
 
130
@@ -1689,6 +1713,7 @@ void land_cleanup (void)
131
    land_planet    = NULL;
132
    landed         = 0;
133
    land_visited   = 0;
134
+   land_generated = 0;
135
 
136
    /* Destroy window. */
137
    if (land_wid > 0)
(-)naev/files/patch-src_land.h (-18 lines)
Lines 1-18 Link Here
1
# Origin: https://github.com/naev/naev/commit/9fd2a7dcb3690bc1befe7f9a05d02e204dcfe8a1
2
# Subject: Avoid regenerating the land tabs over top of themselves
3
4
--- src/land.h.orig	2015-03-05 22:11:11 UTC
5
+++ src/land.h
6
@@ -46,6 +46,12 @@ extern int landed;
7
 extern Planet* land_planet;
8
 
9
 
10
+/* Tracking for which tabs have been generated. */
11
+#define land_tabGenerate(w)       (land_generated |= (1 << w)) /**< Mark tab generated. */
12
+#define land_tabGenerated(w)     (land_generated & (1 << w)) /**< Check if tab has been generated. */
13
+extern unsigned int land_generated;
14
+
15
+
16
 /*
17
  * Main interface.
18
  */
(-)naev/files/patch-src_land__outfits.c (-15 lines)
Lines 1-15 Link Here
1
# Origin: https://github.com/naev/naev/commit/9fd2a7dcb3690bc1befe7f9a05d02e204dcfe8a1
2
# Subject: Avoid regenerating the land tabs over top of themselves
3
4
--- src/land_outfits.c.orig	2015-03-05 22:11:11 UTC
5
+++ src/land_outfits.c
6
@@ -95,6 +95,9 @@ void outfits_open( unsigned int wid )
7
 {
8
    int w, h, iw, ih, bw, bh, off;
9
 
10
+   /* Mark as generated. */
11
+   land_tabGenerate(LAND_WINDOW_OUTFITS);
12
+
13
    /* Get dimensions. */
14
    outfits_getSize( wid, &w, &h, &iw, &ih, &bw, &bh );
15
 
(-)naev/files/patch-src_land__shipyard.c (-15 lines)
Lines 1-15 Link Here
1
# Origin: https://github.com/naev/naev/commit/9fd2a7dcb3690bc1befe7f9a05d02e204dcfe8a1
2
# Subject: Avoid regenerating the land tabs over top of themselves
3
4
--- src/land_shipyard.c.orig	2015-03-05 22:11:11 UTC
5
+++ src/land_shipyard.c
6
@@ -61,6 +61,9 @@ void shipyard_open( unsigned int wid )
7
    int y;
8
    const char *buf;
9
 
10
+   /* Mark as generated. */
11
+   land_tabGenerate(LAND_WINDOW_SHIPYARD);
12
+
13
    /* Init vars. */
14
    shipyard_selected = NULL;
15
 
(-)naev/files/patch-src_mission.c (-219 lines)
Lines 1-219 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
4
--- src/mission.c.orig	2015-02-16 17:49:03 UTC
5
+++ src/mission.c
6
@@ -50,7 +50,7 @@
7
  * current player missions
8
  */
9
 static unsigned int mission_id = 0; /**< Mission ID generator. */
10
-Mission player_missions[MISSION_MAX]; /**< Player's active missions. */
11
+Mission *player_missions[MISSION_MAX]; /**< Player's active missions. */
12
 
13
 
14
 /*
15
@@ -95,7 +95,7 @@ static unsigned int mission_genID (void)
16
 
17
    /* we save mission ids, so check for collisions with player's missions */
18
    for (i=0; i<MISSION_MAX; i++)
19
-      if (id == player_missions[i].id) /* mission id was loaded from save */
20
+      if (id == player_missions[i]->id) /* mission id was loaded from save */
21
          return mission_genID(); /* recursively try again */
22
    return id;
23
 }
24
@@ -240,7 +240,7 @@ int mission_alreadyRunning( MissionData*
25
 {
26
    int i;
27
    for (i=0; i<MISSION_MAX; i++)
28
-      if (player_missions[i].data==misn)
29
+      if (player_missions[i]->data == misn)
30
          return 1;
31
    return 0;
32
 }
33
@@ -416,15 +416,15 @@ void mission_sysMark (void)
34
 
35
    for (i=0; i<MISSION_MAX; i++) {
36
       /* Must be a valid player mission. */
37
-      if (player_missions[i].id == 0)
38
+      if (player_missions[i]->id == 0)
39
          continue;
40
       /* Must have markers. */
41
-      if (player_missions[i].markers == NULL)
42
+      if (player_missions[i]->markers == NULL)
43
          continue;
44
 
45
-      n = array_size( player_missions[i].markers );
46
+      n = array_size( player_missions[i]->markers );
47
       for (j=0; j<n; j++) {
48
-         m = &player_missions[i].markers[j];
49
+         m = &player_missions[i]->markers[j];
50
 
51
          /* Add the individual markers. */
52
          space_addMarker( m->sys, m->type );
53
@@ -562,6 +562,30 @@ void mission_cleanup( Mission* misn )
54
 
55
 
56
 /**
57
+ * @brief Puts the specified mission at the end of the player_missions array.
58
+ *
59
+ *    @param pos Mission's position within player_missions
60
+ */
61
+void mission_shift( int pos )
62
+{
63
+   Mission *misn;
64
+
65
+   if (pos >= (MISSION_MAX-1))
66
+      return;
67
+
68
+   /* Store specified mission. */
69
+   misn = player_missions[pos];
70
+
71
+   /* Move other missions down. */
72
+   memmove( &player_missions[pos], &player_missions[pos+1],
73
+      sizeof(Mission*) * (MISSION_MAX - pos - 1) );
74
+
75
+   /* Put the specified mission at the end of the array. */
76
+   player_missions[MISSION_MAX - 1] = misn;
77
+}
78
+
79
+
80
+/**
81
  * @brief Frees MissionData.
82
  *
83
  *    @param mission MissionData to free.
84
@@ -622,8 +646,8 @@ void missions_activateClaims (void)
85
    int i;
86
 
87
    for (i=0; i<MISSION_MAX; i++)
88
-      if (player_missions[i].claims != NULL)
89
-         claim_activate( player_missions[i].claims );
90
+      if (player_missions[i]->claims != NULL)
91
+         claim_activate( player_missions[i]->claims );
92
 }
93
 
94
 
95
@@ -869,9 +893,14 @@ static int mission_parse( MissionData* t
96
  */
97
 int missions_load (void)
98
 {
99
-   int m;
100
+   int i, m;
101
    uint32_t bufsize;
102
-   char *buf = ndata_read( MISSION_DATA_PATH, &bufsize );
103
+   char *buf;
104
+
105
+   for (i=0; i<MISSION_MAX; i++)
106
+      player_missions[i] = calloc(1, sizeof(Mission));
107
+
108
+   buf = ndata_read( MISSION_DATA_PATH, &bufsize );
109
 
110
    xmlNodePtr node;
111
    xmlDocPtr doc = xmlParseMemory( buf, bufsize );
112
@@ -933,6 +962,10 @@ void missions_free (void)
113
    free( mission_stack );
114
    mission_stack = NULL;
115
    mission_nstack = 0;
116
+
117
+   /* Free the player mission stack. */
118
+   for (i=0; i<MISSION_MAX; i++)
119
+      free(player_missions[i]);
120
 }
121
 
122
 
123
@@ -944,7 +977,7 @@ void missions_cleanup (void)
124
    int i;
125
 
126
    for (i=0; i<MISSION_MAX; i++)
127
-      mission_cleanup( &player_missions[i] );
128
+      mission_cleanup( player_missions[i] );
129
 }
130
 
131
 
132
@@ -963,26 +996,26 @@ int missions_saveActive( xmlTextWriterPt
133
    xmlw_startElem(writer,"missions");
134
 
135
    for (i=0; i<MISSION_MAX; i++) {
136
-      if (player_missions[i].id != 0) {
137
+      if (player_missions[i]->id != 0) {
138
          xmlw_startElem(writer,"mission");
139
 
140
          /* data and id are attributes because they must be loaded first */
141
-         xmlw_attr(writer,"data","%s",player_missions[i].data->name);
142
-         xmlw_attr(writer,"id","%u",player_missions[i].id);
143
+         xmlw_attr(writer,"data","%s",player_missions[i]->data->name);
144
+         xmlw_attr(writer,"id","%u",player_missions[i]->id);
145
 
146
-         xmlw_elem(writer,"title","%s",player_missions[i].title);
147
-         xmlw_elem(writer,"desc","%s",player_missions[i].desc);
148
-         xmlw_elem(writer,"reward","%s",player_missions[i].reward);
149
+         xmlw_elem(writer,"title","%s",player_missions[i]->title);
150
+         xmlw_elem(writer,"desc","%s",player_missions[i]->desc);
151
+         xmlw_elem(writer,"reward","%s",player_missions[i]->reward);
152
 
153
          /* Markers. */
154
          xmlw_startElem( writer, "markers" );
155
-         if (player_missions[i].markers != NULL) {
156
-            n = array_size( player_missions[i].markers );
157
+         if (player_missions[i]->markers != NULL) {
158
+            n = array_size( player_missions[i]->markers );
159
             for (j=0; j<n; j++) {
160
                xmlw_startElem(writer,"marker");
161
-               xmlw_attr(writer,"id","%d",player_missions[i].markers[j].id);
162
-               xmlw_attr(writer,"type","%d",player_missions[i].markers[j].type);
163
-               xmlw_str(writer,"%s", system_getIndex(player_missions[i].markers[j].sys)->name);
164
+               xmlw_attr(writer,"id","%d",player_missions[i]->markers[j].id);
165
+               xmlw_attr(writer,"type","%d",player_missions[i]->markers[j].type);
166
+               xmlw_str(writer,"%s", system_getIndex(player_missions[i]->markers[j].sys)->name);
167
                xmlw_endElem(writer); /* "marker" */
168
             }
169
          }
170
@@ -990,19 +1023,19 @@ int missions_saveActive( xmlTextWriterPt
171
 
172
          /* Cargo */
173
          xmlw_startElem(writer,"cargos");
174
-         for (j=0; j<player_missions[i].ncargo; j++)
175
-            xmlw_elem(writer,"cargo","%u", player_missions[i].cargo[j]);
176
+         for (j=0; j<player_missions[i]->ncargo; j++)
177
+            xmlw_elem(writer,"cargo","%u", player_missions[i]->cargo[j]);
178
          xmlw_endElem(writer); /* "cargos" */
179
 
180
          /* OSD. */
181
-         if (player_missions[i].osd > 0) {
182
+         if (player_missions[i]->osd > 0) {
183
             xmlw_startElem(writer,"osd");
184
 
185
             /* Save attributes. */
186
-            items = osd_getItems(player_missions[i].osd, &nitems);
187
-            xmlw_attr(writer,"title","%s",osd_getTitle(player_missions[i].osd));
188
+            items = osd_getItems(player_missions[i]->osd, &nitems);
189
+            xmlw_attr(writer,"title","%s",osd_getTitle(player_missions[i]->osd));
190
             xmlw_attr(writer,"nitems","%d",nitems);
191
-            xmlw_attr(writer,"active","%d",osd_getActive(player_missions[i].osd));
192
+            xmlw_attr(writer,"active","%d",osd_getActive(player_missions[i]->osd));
193
 
194
             /* Save messages. */
195
             for (j=0; j<nitems; j++)
196
@@ -1013,12 +1046,12 @@ int missions_saveActive( xmlTextWriterPt
197
 
198
          /* Claims. */
199
          xmlw_startElem(writer,"claims");
200
-         claim_xmlSave( writer, player_missions[i].claims );
201
+         claim_xmlSave( writer, player_missions[i]->claims );
202
          xmlw_endElem(writer); /* "claims" */
203
 
204
          /* Write Lua magic */
205
          xmlw_startElem(writer,"lua");
206
-         nxml_persistLua( player_missions[i].L, writer );
207
+         nxml_persistLua( player_missions[i]->L, writer );
208
          xmlw_endElem(writer); /* "lua" */
209
 
210
          xmlw_endElem(writer); /* "mission" */
211
@@ -1078,7 +1111,7 @@ static int missions_parseActive( xmlNode
212
    node = parent->xmlChildrenNode;
213
    do {
214
       if (xml_isNode(node,"mission")) {
215
-         misn = &player_missions[m];
216
+         misn = player_missions[m];
217
 
218
          /* process the attributes to create the mission */
219
          xmlr_attr(node,"data",buf);
(-)naev/files/patch-src_mission.h (-22 lines)
Lines 1-22 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
4
--- src/mission.h.orig	2015-02-16 17:49:03 UTC
5
+++ src/mission.h
6
@@ -129,7 +129,7 @@ typedef struct Mission_ {
7
  * current player missions
8
  */
9
 #define MISSION_MAX  12 /**< No sense in allowing the player have infinite missions. */
10
-extern Mission player_missions[MISSION_MAX]; /**< Player's active missions. */
11
+extern Mission *player_missions[MISSION_MAX]; /**< Player's active missions. */
12
 
13
 
14
 /*
15
@@ -165,6 +165,7 @@ int mission_unlinkCargo( Mission* misn, 
16
  */
17
 int missions_load (void);
18
 void mission_cleanup( Mission* misn );
19
+void mission_shift( int pos );
20
 void missions_free (void);
21
 void missions_cleanup (void);
22
 
(-)naev/files/patch-src_nlua__hook.c (-14 lines)
Lines 1-14 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
4
--- src/nlua_hook.c.orig	2015-03-17 16:29:43 UTC
5
+++ src/nlua_hook.c
6
@@ -246,7 +246,7 @@ static unsigned int hook_generic( lua_St
7
    if (running_mission != NULL) {
8
       /* make sure mission is a player mission */
9
       for (i=0; i<MISSION_MAX; i++)
10
-         if (player_missions[i].id == running_mission->id)
11
+         if (player_missions[i]->id == running_mission->id)
12
             break;
13
       if (i>=MISSION_MAX) {
14
          WARN("Mission not in stack trying to hook, forgot to run misn.accept()?");
(-)naev/files/patch-src_nlua__misn.c (-49 lines)
Lines 1-49 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
# Origin: https://github.com/naev/naev/commit/155a7fdaf07e1b5549e6314a433425b4187bb33f
4
# Subject: Don't use a pointer to a pointer
5
6
--- src/nlua_misn.c.orig	2015-02-16 17:49:03 UTC
7
+++ src/nlua_misn.c
8
@@ -283,13 +283,13 @@ int misn_runFunc( Mission *misn, const c
9
    if (misn_delete) {
10
       ret = 2;
11
       mission_cleanup( cur_mission );
12
-      for (i=0; i<MISSION_MAX; i++)
13
-         if (cur_mission == &player_missions[i]) {
14
-            memmove( &player_missions[i], &player_missions[i+1],
15
-                  sizeof(Mission) * (MISSION_MAX-i-1) );
16
-            memset( &player_missions[MISSION_MAX-1], 0, sizeof(Mission) );
17
-            break;
18
-         }
19
+      for (i=0; i<MISSION_MAX; i++) {
20
+         if (cur_mission != player_missions[i])
21
+            continue;
22
+
23
+         mission_shift(i);
24
+         break;
25
+      }
26
    }
27
 
28
    return ret;
29
@@ -609,7 +609,7 @@ static int misn_accept( lua_State *L )
30
 
31
    /* find last mission */
32
    for (i=0; i<MISSION_MAX; i++)
33
-      if (player_missions[i].data == NULL)
34
+      if (player_missions[i]->data == NULL)
35
          break;
36
 
37
    cur_mission = misn_getFromLua(L);
38
@@ -620,9 +620,9 @@ static int misn_accept( lua_State *L )
39
    else if (i>=MISSION_MAX)
40
       ret = 1;
41
    else { /* copy it over */
42
-      memcpy( &player_missions[i], cur_mission, sizeof(Mission) );
43
+      memcpy( player_missions[i], cur_mission, sizeof(Mission) );
44
       memset( cur_mission, 0, sizeof(Mission) );
45
-      cur_mission = &player_missions[i];
46
+      cur_mission = player_missions[i];
47
       cur_mission->accepted = 1; /* Mark as accepted. */
48
 
49
       /* Need to change pointer. */
(-)naev/files/patch-src_npc.c (-14 lines)
Lines 1-14 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
4
--- src/npc.c.orig	2015-02-16 17:49:03 UTC
5
+++ src/npc.c
6
@@ -559,7 +559,7 @@ static int npc_approach_giver( NPC_t *np
7
 
8
    /* Make sure player can accept the mission. */
9
    for (i=0; i<MISSION_MAX; i++)
10
-      if (player_missions[i].data == NULL)
11
+      if (player_missions[i]->data == NULL)
12
          break;
13
    if (i >= MISSION_MAX) {
14
       dialogue_alert("You have too many active missions.");
(-)naev/files/patch-src_pilot__hook.c (-44 lines)
Lines 1-44 Link Here
1
# Origin: https://github.com/naev/naev/commit/6f4005f921650c1a8930721bbd1c0eab163673f8
2
# Subject: * Hook param off by one.
3
# https://github.com/naev/naev/commit/3ba9cafb369f94115c897717b6f38415348f4c8f
4
# Subject: * Too many bugs in the code, should fix bugs with pilot hooks when using >1 parameter.
5
6
--- src/pilot_hook.c.orig	2015-02-16 17:49:03 UTC
7
+++ src/pilot_hook.c
8
@@ -39,26 +39,26 @@ static int pilot_hookCleanup = 0; /**< A
9
 int pilot_runHookParam( Pilot* p, int hook_type, HookParam* param, int nparam )
10
 {
11
    int n, i, run, ret;
12
-   HookParam hparam[3], *hdynparam;
13
+   HookParam hstaparam[5], *hdynparam, *hparam;
14
 
15
    /* Set up hook parameters. */
16
-   if (nparam <= 1) {
17
-      hparam[0].type       = HOOK_PARAM_PILOT;
18
-      hparam[0].u.lp.pilot = p->id;
19
+   if (nparam <= 3) {
20
+      hstaparam[0].type       = HOOK_PARAM_PILOT;
21
+      hstaparam[0].u.lp.pilot = p->id;
22
       n  = 1;
23
-      if (nparam == 1) {
24
-         memcpy( &hparam[n], param, sizeof(HookParam) );
25
-         n++;
26
-      }
27
-      hparam[n].type    = HOOK_PARAM_SENTINEL;
28
+      memcpy( &hstaparam[n], param, sizeof(HookParam)*nparam );
29
+      n += nparam;
30
+      hstaparam[n].type = HOOK_PARAM_SENTINEL;
31
       hdynparam         = NULL;
32
+      hparam            = hstaparam;
33
    }
34
    else {
35
       hdynparam   = malloc( sizeof(HookParam) * (nparam+2) );
36
       hdynparam[0].type       = HOOK_PARAM_PILOT;
37
       hdynparam[0].u.lp.pilot = p->id;
38
       memcpy( &hdynparam[1], param, sizeof(HookParam)*nparam );
39
-      hdynparam[nparam].type  = HOOK_PARAM_SENTINEL;
40
+      hdynparam[nparam+1].type  = HOOK_PARAM_SENTINEL;
41
+      hparam                  = hdynparam;
42
    }
43
 
44
    /* Run pilot specific hooks. */
(-)naev/files/patch-src_player.c (-44 lines)
Lines 1-44 Link Here
1
# Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
# Subject: Turn player_missions in an array of pointers
3
# Origin: https://github.com/naev/naev/commit/34651062f0f26b43489214137862148c7cf842c1
4
# Subject: Regenerate the player's ship list when removing a ship
5
6
--- src/player.c.orig	2015-03-05 22:11:11 UTC
7
+++ src/player.c
8
@@ -665,7 +665,7 @@ credits_t player_shipPrice( char* shipna
9
  */
10
 void player_rmShip( char* shipname )
11
 {
12
-   int i;
13
+   int i, w;
14
 
15
    for (i=0; i<player_nstack; i++) {
16
       /* Not the ship we are looking for. */
17
@@ -684,6 +684,12 @@ void player_rmShip( char* shipname )
18
       player_stack = realloc( player_stack,
19
             sizeof(PlayerShip_t) * (player_nstack) );
20
    }
21
+
22
+   /* Update ship list if landed. */
23
+   if (landed) {
24
+      w = land_getWid( LAND_WINDOW_EQUIPMENT );
25
+      equipment_regenLists( w, 0, 1 );
26
+   }
27
 }
28
 
29
 
30
@@ -3011,11 +3017,11 @@ static int player_saveShip( xmlTextWrite
31
          found = 0;
32
          for (j=0; j<MISSION_MAX; j++) {
33
             /* Only check active missions. */
34
-            if (player_missions[j].id > 0) {
35
+            if (player_missions[j]->id > 0) {
36
                /* Now check if it's in the cargo list. */
37
-               for (k=0; k<player_missions[j].ncargo; k++) {
38
+               for (k=0; k<player_missions[j]->ncargo; k++) {
39
                   /* See if it matches a cargo. */
40
-                  if (player_missions[j].cargo[k] == ship->commodities[i].id) {
41
+                  if (player_missions[j]->cargo[k] == ship->commodities[i].id) {
42
                      found = 1;
43
                      break;
44
                   }
(-)naev/files/patch-src_space.c (-13 lines)
Lines 1-13 Link Here
1
# Origin: https://github.com/naev/naev/commit/173bad4a7bab85903575798a51259ff6f3dd42c8
2
# Subject: Memory leak fix
3
4
--- src/space.c.orig	2015-02-16 17:49:03 UTC
5
+++ src/space.c
6
@@ -2978,6 +2978,7 @@ void space_exit (void)
7
       free(pnt->land_func);
8
       free(pnt->land_msg);
9
       free(pnt->bribe_msg);
10
+      free(pnt->bribe_ack_msg);
11
 
12
       /* tech */
13
       if (pnt->tech != NULL)

Return to bug 204543