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

Collapse All | Expand All

(-)naev/Makefile (-26 / +33 lines)
Lines 2-57 Link Here
2
# $FreeBSD: head/games/naev/Makefile 375598 2014-12-25 20:54:41Z bapt $
2
# $FreeBSD: head/games/naev/Makefile 375598 2014-12-25 20:54:41Z bapt $
3
3
4
PORTNAME=	naev
4
PORTNAME=	naev
5
PORTVERSION=	0.5.3
5
PORTVERSION=	0.6.0
6
PORTREVISION=	4
7
CATEGORIES=	games
6
CATEGORIES=	games
8
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-${PORTVERSION} \
7
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-${PORTVERSION}/
9
		${MASTER_SITE_GOOGLE_CODE}
10
DIST_SUBDIR=	${PORTNAME}
8
DIST_SUBDIR=	${PORTNAME}
11
9
12
MAINTAINER=	acm@FreeBSD.org
10
MAINTAINER=	acm@FreeBSD.org
13
COMMENT=	2D action/RPG space game
11
COMMENT=	2D action/RPG space game
14
12
13
LICENSE=	GPLv3
14
LICENSE_FILE=	${WRKSRC}/LICENSE
15
15
LIB_DEPENDS=	libpng.so:${PORTSDIR}/graphics/png \
16
LIB_DEPENDS=	libpng.so:${PORTSDIR}/graphics/png \
16
		libfreetype.so:${PORTSDIR}/print/freetype2 \
17
		libfreetype.so:${PORTSDIR}/print/freetype2 \
17
		libvorbisfile.so:${PORTSDIR}/audio/libvorbis
18
		libvorbisfile.so:${PORTSDIR}/audio/libvorbis \
18
RUN_DEPENDS=	${LOCALBASE}/share/${PORTNAME}/ndata-${PORTVERSION}:${PORTSDIR}/games/naev-data
19
		libzip.so:${PORTSDIR}/archivers/libzip \
20
		libcsparse.so:${PORTSDIR}/math/suitesparse
21
RUN_DEPENDS=	${DATADIR}/ndata-${PORTVERSION}.zip:${PORTSDIR}/games/naev-data
19
22
20
USES=		gmake pkgconfig tar:bzip2
23
USES=		gmake pkgconfig tar:bzip2
21
USE_AUTOTOOLS=	automake:env aclocal:env autoconf:env
24
USE_AUTOTOOLS=	automake:env aclocal:env autoconf:env
22
GNU_CONFIGURE=	yes
25
GNU_CONFIGURE=	yes
23
USE_GL=		glu
26
USE_GL=		glu
24
USE_GNOME=	libxml2
27
USE_GNOME=	libxml2
25
USE_SDL=	sdl image
26
28
27
CONFIGURE_ARGS=	--with-ndata-path=${DATADIR}/ndata-${PORTVERSION}
29
CONFIGURE_ARGS=	--with-ndata-path="${DATADIR}/ndata-${PORTVERSION}.zip" \
30
		--enable-debug=no
28
CPPFLAGS+=	-I${LOCALBASE}/include
31
CPPFLAGS+=	-I${LOCALBASE}/include
29
LIBS+=		-L${LOCALBASE}/lib -lm
32
LIBS+=		-L${LOCALBASE}/lib -lm
30
33
31
PLIST_FILES=	bin/${PORTNAME} man/man6/naev.6.gz
34
PORTDATA=	*
32
SUB_FILES=	pkg-message
35
PORTDOCS=	*
36
37
PLIST_FILES=	bin/${PORTNAME} man/man6/naev.6.gz \
38
		share/applications/${PORTNAME}.desktop \
39
		share/appdata/${PORTNAME}.appdata.xml \
40
		share/pixmaps/${PORTNAME}.png
41
42
OPTIONS_DEFINE=	DOCS OPENAL SDL2 SDL_MIXER
43
OPTIONS_DEFAULT=	OPENAL SDL2 SDL_MIXER
33
44
34
OPTIONS_DEFINE=	OPENAL SDL_MIXER
45
OPENAL_USES=	openal
46
OPENAL_CONFIGURE_WITH=	openal
35
SDL_MIXER_DESC=	SDL_mixer sound backend
47
SDL_MIXER_DESC=	SDL_mixer sound backend
48
SDL_MIXER_CONFIGURE_WITH=	sdlmixer
49
SDL2_DESC=	Use SDL2 instead of SDL
50
SDL2_CONFIGURE_WITH=	sdl2
51
SDL2_USE=	SDL=sdl2
52
SDL2_USE_OFF=	SDL=sdl
36
53
37
.include <bsd.port.options.mk>
54
.include <bsd.port.options.mk>
38
55
39
.if ${PORT_OPTIONS:MOPENAL}
40
USES+=			openal
41
CONFIGURE_ARGS+=	--with-openal=yes
42
.else
43
CONFIGURE_ARGS+=	--with-openal=no
44
.endif
45
46
.if ${PORT_OPTIONS:MSDL_MIXER}
56
.if ${PORT_OPTIONS:MSDL_MIXER}
47
USE_SDL+=		mixer
57
.	if ${PORT_OPTIONS:MSDL2}
48
CONFIGURE_ARGS+=	--with-sdlmixer=yes
58
USE_SDL+=	mixer2
49
.else
59
.	else
50
CONFIGURE_ARGS+=	--with-sdlmixer=no
60
USE_SDL+=	mixer
61
.	endif
51
.endif
62
.endif
52
63
53
do-install:
54
	${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin
55
	${INSTALL_MAN} ${WRKSRC}/${PORTNAME}.6 ${STAGEDIR}${MAN6PREFIX}/man/man6
56
57
.include <bsd.port.mk>
64
.include <bsd.port.mk>
(-)naev/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (naev/naev-0.5.3.tar.bz2) = b2d026abb099bcb884e13a26b1bce4273f094830690340468f752a3b9b64c719
1
SHA256 (naev/naev-0.6.0.tar.bz2) = 0f0b498c7642e36dfaa15f284e13b9aa2d20e4aa01ed812fb7854583e7161cac
2
SIZE (naev/naev-0.5.3.tar.bz2) = 997522
2
SIZE (naev/naev-0.6.0.tar.bz2) = 1054649
(-)naev/files/patch-src.diff (+662 lines)
Line 0 Link Here
1
Origin: https://github.com/naev/naev/commit/74b9a086a20f80f21ce2f3866b31318e651a6235
2
From: Deiz <silverwraithii@gmail.com>
3
Date: Wed, 18 Mar 2015 20:20:35 -0400
4
Subject: Turn player_missions in an array of pointers
5
6
Origin: https://github.com/naev/naev/commit/155a7fdaf07e1b5549e6314a433425b4187bb33f
7
From: Deiz <silverwraithii@gmail.com>
8
Date: Fri, 20 Mar 2015 16:00:37 -0400
9
Subject: Don't use a pointer to a pointer
10
11
Origin: https://github.com/naev/naev/commit/9fd2a7dcb3690bc1befe7f9a05d02e204dcfe8a1
12
From: Deiz <silverwraithii@gmail.com>
13
Date: Sun, 22 Mar 2015 14:26:09 -0400
14
Subject: Avoid regenerating the land tabs over top of themselves
15
16
This was only occurring when hooks caused a GUI reload, which is
17
somewhat unsafe, but this seems like a useful precaution to take.
18
19
Origin: https://github.com/naev/naev/commit/34651062f0f26b43489214137862148c7cf842c1
20
From: Deiz <silverwraithii@gmail.com>
21
Date: Tue, 24 Mar 2015 19:30:00 -0400
22
Subject: Regenerate the player's ship list when removing a ship
23
24
Origin: https://github.com/naev/naev/commit/b9bad809027529c0b0e95d9b8a011cb880229a5d
25
From: onpon4 <onpon4@riseup.net>
26
Date: Sun, 5 Apr 2015 09:50:35 -0400
27
Subject: Fixed "buy map" button not showing up until after land hooks.
28
29
This didn't cause a problem, but it looked weird when you were given
30
a dialog box at this time.
31
32
diff -ruN src/equipment.c src/equipment.c
33
--- src/equipment.c
34
+++ src/equipment.c
35
@@ -234,6 +234,9 @@
36
    GLfloat colour[4*4];
37
    const char *buf;
38
 
39
+   /* Mark as generated. */
40
+   land_tabGenerate(LAND_WINDOW_EQUIPMENT);
41
+
42
    /* Set global WID. */
43
    equipment_wid = wid;
44
 
45
diff -ruN src/hook.c src/hook.c
46
--- src/hook.c
47
+++ src/hook.c
48
@@ -837,8 +837,8 @@
49
 {
50
    int i;
51
    for (i=0; i<MISSION_MAX; i++)
52
-      if (player_missions[i].id == hook->u.misn.parent)
53
-         return &player_missions[i];
54
+      if (player_missions[i]->id == hook->u.misn.parent)
55
+         return player_missions[i];
56
 
57
    return NULL;
58
 }
59
diff -ruN src/info.c src/info.c
60
--- src/info.c
61
+++ src/info.c
62
@@ -785,8 +785,8 @@
63
       /* Get the mission. */
64
       f = 0;
65
       for (i=0; i<MISSION_MAX; i++) {
66
-         for (j=0; j<player_missions[i].ncargo; j++) {
67
-            if (player_missions[i].cargo[j] == player.p->commodities[pos].id) {
68
+         for (j=0; j<player_missions[i]->ncargo; j++) {
69
+            if (player_missions[i]->cargo[j] == player.p->commodities[pos].id) {
70
                f = 1;
71
                break;
72
             }
73
@@ -799,7 +799,7 @@
74
                player.p->commodities[pos].id);
75
          return;
76
       }
77
-      misn = &player_missions[i];
78
+      misn = player_missions[i];
79
 
80
       /* We run the "abort" function if it's found. */
81
       ret = misn_tryRun( misn, "abort" );
82
@@ -807,9 +807,7 @@
83
       /* Now clean up mission. */
84
       if (ret != 2) {
85
          mission_cleanup( misn );
86
-         memmove( misn, &player_missions[i+1],
87
-               sizeof(Mission) * (MISSION_MAX-i-1) );
88
-         memset( &player_missions[MISSION_MAX-1], 0, sizeof(Mission) );
89
+         mission_shift(pos);
90
       }
91
 
92
       /* Reset markers. */
93
@@ -1005,8 +1003,10 @@
94
    misn_names = malloc(sizeof(char*) * MISSION_MAX);
95
    j = 0;
96
    for (i=0; i<MISSION_MAX; i++)
97
-      if (player_missions[i].id != 0)
98
-         misn_names[j++] = (player_missions[i].title!=NULL) ? strdup(player_missions[i].title) : NULL;
99
+      if (player_missions[i]->id != 0)
100
+         misn_names[j++] = (player_missions[i]->title != NULL) ?
101
+               strdup(player_missions[i]->title) : NULL;
102
+
103
    if (j==0) { /* no missions */
104
       misn_names[0] = strdup("No Missions");
105
       j = 1;
106
@@ -1035,7 +1035,7 @@
107
    }
108
 
109
    /* Modify the text. */
110
-   misn = &player_missions[ toolkit_getListPos(wid, "lstMission" ) ];
111
+   misn = player_missions[ toolkit_getListPos(wid, "lstMission" ) ];
112
    window_modifyText( wid, "txtReward", misn->reward );
113
    window_modifyText( wid, "txtDesc", misn->desc );
114
    window_enableButton( wid, "btnAbortMission" );
115
@@ -1052,7 +1052,7 @@
116
 {
117
    (void)str;
118
    int pos;
119
-   Mission* misn;
120
+   Mission *misn;
121
    int ret;
122
 
123
    if (dialogue_YesNo( "Abort Mission",
124
@@ -1060,7 +1060,7 @@
125
 
126
       /* Get the mission. */
127
       pos = toolkit_getListPos(wid, "lstMission" );
128
-      misn = &player_missions[pos];
129
+      misn = player_missions[pos];
130
 
131
       /* We run the "abort" function if it's found. */
132
       ret = misn_tryRun( misn, "abort" );
133
@@ -1068,9 +1068,7 @@
134
       /* Now clean up mission. */
135
       if (ret != 2) {
136
          mission_cleanup( misn );
137
-         memmove( misn, &player_missions[pos+1],
138
-               sizeof(Mission) * (MISSION_MAX-pos-1) );
139
-         memset( &player_missions[MISSION_MAX-1], 0, sizeof(Mission) );
140
+         mission_shift(pos);
141
       }
142
 
143
       /* Reset markers. */
144
diff -ruN src/land.c src/land.c
145
--- src/land.c
146
+++ src/land.c
147
@@ -69,6 +69,8 @@
148
 #define has_visited(f)        (land_visited & (f)) /**< Check if player has visited. */
149
 static unsigned int land_visited = 0; /**< Contains what the player visited. */
150
 
151
+/* Which tabs have been generated by their respective open functions. */
152
+unsigned int land_generated = 0;
153
 
154
 /*
155
  * land variables
156
@@ -187,6 +189,9 @@
157
    char **goods;
158
    int w, h;
159
 
160
+   /* Mark as generated. */
161
+   land_tabGenerate(LAND_WINDOW_COMMODITY);
162
+
163
    /* Get window dimensions. */
164
    window_dimWindow( wid, &w, &h );
165
 
166
@@ -566,6 +571,9 @@
167
 {
168
    int w, h, iw, ih, bw, bh, dh, th;
169
 
170
+   /* Mark as generated. */
171
+   land_tabGenerate(LAND_WINDOW_BAR);
172
+
173
    /* Set window functions. */
174
    window_onClose( wid, bar_close );
175
 
176
@@ -822,6 +830,9 @@
177
    int w, h;
178
    int y;
179
 
180
+   /* Mark as generated. */
181
+   land_tabGenerate(LAND_WINDOW_MISSION);
182
+
183
    /* Get window dimensions. */
184
    window_dimWindow( wid, &w, &h );
185
 
186
@@ -900,7 +911,7 @@
187
 
188
    /* Make sure player can accept the mission. */
189
    for (i=0; i<MISSION_MAX; i++)
190
-      if (player_missions[i].data == NULL) break;
191
+      if (player_missions[i]->data == NULL) break;
192
    if (i >= MISSION_MAX) {
193
       dialogue_alert("You have too many active missions.");
194
       return;
195
@@ -1180,6 +1191,9 @@
196
    if (land_wid > 0) {
197
       land_regen = 2; /* Mark we're regenning. */
198
       window_destroy(land_wid);
199
+
200
+      /* Mark tabs as not generated. */
201
+      land_generated = 0;
202
    }
203
    land_loaded = 0;
204
 
205
@@ -1255,6 +1269,9 @@
206
    /* 1) Create main tab. */
207
    land_createMainTab( land_getWid(LAND_WINDOW_MAIN) );
208
 
209
+   /* Add local system map button. */
210
+   land_checkAddMap();
211
+
212
    /* 2) Set as landed and run hooks. */
213
    if (!regen) {
214
       landed = 1;
215
@@ -1274,24 +1291,34 @@
216
    }
217
 
218
    /* 4) Create other tabs. */
219
+#define should_open(s, w) \
220
+   (planet_hasService(land_planet, s) && (!land_tabGenerated(w)))
221
+
222
+   /* Things get a bit hairy here. Hooks may have triggered a GUI reload via
223
+    * e.g. player.swapShip, so the land tabs may have been generated already
224
+    * and we need to check that before regenerating them.
225
+    */
226
+
227
    /* Basic - bar + missions */
228
-   if (planet_hasService(land_planet, PLANET_SERVICE_BAR))
229
+   if (should_open( PLANET_SERVICE_BAR, LAND_WINDOW_BAR ))
230
       bar_open( land_getWid(LAND_WINDOW_BAR) );
231
-   if (planet_hasService(land_planet, PLANET_SERVICE_MISSIONS))
232
+   if (should_open( PLANET_SERVICE_MISSIONS, LAND_WINDOW_MISSION ))
233
       misn_open( land_getWid(LAND_WINDOW_MISSION) );
234
    /* Outfits. */
235
-   if (planet_hasService(land_planet, PLANET_SERVICE_OUTFITS))
236
+   if (should_open( PLANET_SERVICE_OUTFITS, LAND_WINDOW_OUTFITS ))
237
       outfits_open( land_getWid(LAND_WINDOW_OUTFITS) );
238
    /* Shipyard. */
239
-   if (planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD))
240
+   if (should_open( PLANET_SERVICE_SHIPYARD, LAND_WINDOW_SHIPYARD ))
241
       shipyard_open( land_getWid(LAND_WINDOW_SHIPYARD) );
242
    /* Equipment. */
243
-   if (planet_hasService(land_planet, PLANET_SERVICE_OUTFITS) ||
244
-         planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD))
245
+   if ((planet_hasService(land_planet, PLANET_SERVICE_OUTFITS) ||
246
+         planet_hasService(land_planet, PLANET_SERVICE_SHIPYARD)) &&
247
+         !land_tabGenerated( LAND_WINDOW_EQUIPMENT ))
248
       equipment_open( land_getWid(LAND_WINDOW_EQUIPMENT) );
249
    /* Commodity. */
250
-   if (planet_hasService(land_planet, PLANET_SERVICE_COMMODITY))
251
+   if (should_open( PLANET_SERVICE_COMMODITY, LAND_WINDOW_COMMODITY ))
252
       commodity_exchange_open( land_getWid(LAND_WINDOW_COMMODITY) );
253
+#undef should_open
254
 
255
    if (!regen) {
256
       /* Reset markers if needed. */
257
@@ -1310,9 +1337,6 @@
258
    if (changetab && land_windowsMap[ last_window ] != -1)
259
       window_tabWinSetActive( land_wid, "tabLand", land_windowsMap[ last_window ] );
260
 
261
-   /* Add local system map button. */
262
-   land_checkAddMap();
263
-
264
    /* Refuel if necessary. */
265
    land_refuel();
266
 
267
@@ -1689,6 +1713,7 @@
268
    land_planet    = NULL;
269
    landed         = 0;
270
    land_visited   = 0;
271
+   land_generated = 0;
272
 
273
    /* Destroy window. */
274
    if (land_wid > 0)
275
diff -ruN src/land.h src/land.h
276
--- src/land.h
277
+++ src/land.h
278
@@ -46,6 +46,12 @@
279
 extern Planet* land_planet;
280
 
281
 
282
+/* Tracking for which tabs have been generated. */
283
+#define land_tabGenerate(w)       (land_generated |= (1 << w)) /**< Mark tab generated. */
284
+#define land_tabGenerated(w)     (land_generated & (1 << w)) /**< Check if tab has been generated. */
285
+extern unsigned int land_generated;
286
+
287
+
288
 /*
289
  * Main interface.
290
  */
291
diff -ruN src/land_outfits.c src/land_outfits.c
292
--- src/land_outfits.c
293
+++ src/land_outfits.c
294
@@ -95,6 +95,9 @@
295
 {
296
    int w, h, iw, ih, bw, bh, off;
297
 
298
+   /* Mark as generated. */
299
+   land_tabGenerate(LAND_WINDOW_OUTFITS);
300
+
301
    /* Get dimensions. */
302
    outfits_getSize( wid, &w, &h, &iw, &ih, &bw, &bh );
303
 
304
diff -ruN src/land_shipyard.c src/land_shipyard.c
305
--- src/land_shipyard.c
306
+++ src/land_shipyard.c
307
@@ -61,6 +61,9 @@
308
    int y;
309
    const char *buf;
310
 
311
+   /* Mark as generated. */
312
+   land_tabGenerate(LAND_WINDOW_SHIPYARD);
313
+
314
    /* Init vars. */
315
    shipyard_selected = NULL;
316
 
317
diff -ruN src/mission.c src/mission.c
318
--- src/mission.c
319
+++ src/mission.c
320
@@ -50,7 +50,7 @@
321
  * current player missions
322
  */
323
 static unsigned int mission_id = 0; /**< Mission ID generator. */
324
-Mission player_missions[MISSION_MAX]; /**< Player's active missions. */
325
+Mission *player_missions[MISSION_MAX]; /**< Player's active missions. */
326
 
327
 
328
 /*
329
@@ -95,7 +95,7 @@
330
 
331
    /* we save mission ids, so check for collisions with player's missions */
332
    for (i=0; i<MISSION_MAX; i++)
333
-      if (id == player_missions[i].id) /* mission id was loaded from save */
334
+      if (id == player_missions[i]->id) /* mission id was loaded from save */
335
          return mission_genID(); /* recursively try again */
336
    return id;
337
 }
338
@@ -240,7 +240,7 @@
339
 {
340
    int i;
341
    for (i=0; i<MISSION_MAX; i++)
342
-      if (player_missions[i].data==misn)
343
+      if (player_missions[i]->data == misn)
344
          return 1;
345
    return 0;
346
 }
347
@@ -416,15 +416,15 @@
348
 
349
    for (i=0; i<MISSION_MAX; i++) {
350
       /* Must be a valid player mission. */
351
-      if (player_missions[i].id == 0)
352
+      if (player_missions[i]->id == 0)
353
          continue;
354
       /* Must have markers. */
355
-      if (player_missions[i].markers == NULL)
356
+      if (player_missions[i]->markers == NULL)
357
          continue;
358
 
359
-      n = array_size( player_missions[i].markers );
360
+      n = array_size( player_missions[i]->markers );
361
       for (j=0; j<n; j++) {
362
-         m = &player_missions[i].markers[j];
363
+         m = &player_missions[i]->markers[j];
364
 
365
          /* Add the individual markers. */
366
          space_addMarker( m->sys, m->type );
367
@@ -562,6 +562,30 @@
368
 
369
 
370
 /**
371
+ * @brief Puts the specified mission at the end of the player_missions array.
372
+ *
373
+ *    @param pos Mission's position within player_missions
374
+ */
375
+void mission_shift( int pos )
376
+{
377
+   Mission *misn;
378
+
379
+   if (pos >= (MISSION_MAX-1))
380
+      return;
381
+
382
+   /* Store specified mission. */
383
+   misn = player_missions[pos];
384
+
385
+   /* Move other missions down. */
386
+   memmove( &player_missions[pos], &player_missions[pos+1],
387
+      sizeof(Mission*) * (MISSION_MAX - pos - 1) );
388
+
389
+   /* Put the specified mission at the end of the array. */
390
+   player_missions[MISSION_MAX - 1] = misn;
391
+}
392
+
393
+
394
+/**
395
  * @brief Frees MissionData.
396
  *
397
  *    @param mission MissionData to free.
398
@@ -622,8 +646,8 @@
399
    int i;
400
 
401
    for (i=0; i<MISSION_MAX; i++)
402
-      if (player_missions[i].claims != NULL)
403
-         claim_activate( player_missions[i].claims );
404
+      if (player_missions[i]->claims != NULL)
405
+         claim_activate( player_missions[i]->claims );
406
 }
407
 
408
 
409
@@ -869,9 +893,14 @@
410
  */
411
 int missions_load (void)
412
 {
413
-   int m;
414
+   int i, m;
415
    uint32_t bufsize;
416
-   char *buf = ndata_read( MISSION_DATA_PATH, &bufsize );
417
+   char *buf;
418
+
419
+   for (i=0; i<MISSION_MAX; i++)
420
+      player_missions[i] = calloc(1, sizeof(Mission));
421
+
422
+   buf = ndata_read( MISSION_DATA_PATH, &bufsize );
423
 
424
    xmlNodePtr node;
425
    xmlDocPtr doc = xmlParseMemory( buf, bufsize );
426
@@ -933,6 +962,10 @@
427
    free( mission_stack );
428
    mission_stack = NULL;
429
    mission_nstack = 0;
430
+
431
+   /* Free the player mission stack. */
432
+   for (i=0; i<MISSION_MAX; i++)
433
+      free(player_missions[i]);
434
 }
435
 
436
 
437
@@ -944,7 +977,7 @@
438
    int i;
439
 
440
    for (i=0; i<MISSION_MAX; i++)
441
-      mission_cleanup( &player_missions[i] );
442
+      mission_cleanup( player_missions[i] );
443
 }
444
 
445
 
446
@@ -963,26 +996,26 @@
447
    xmlw_startElem(writer,"missions");
448
 
449
    for (i=0; i<MISSION_MAX; i++) {
450
-      if (player_missions[i].id != 0) {
451
+      if (player_missions[i]->id != 0) {
452
          xmlw_startElem(writer,"mission");
453
 
454
          /* data and id are attributes because they must be loaded first */
455
-         xmlw_attr(writer,"data","%s",player_missions[i].data->name);
456
-         xmlw_attr(writer,"id","%u",player_missions[i].id);
457
+         xmlw_attr(writer,"data","%s",player_missions[i]->data->name);
458
+         xmlw_attr(writer,"id","%u",player_missions[i]->id);
459
 
460
-         xmlw_elem(writer,"title","%s",player_missions[i].title);
461
-         xmlw_elem(writer,"desc","%s",player_missions[i].desc);
462
-         xmlw_elem(writer,"reward","%s",player_missions[i].reward);
463
+         xmlw_elem(writer,"title","%s",player_missions[i]->title);
464
+         xmlw_elem(writer,"desc","%s",player_missions[i]->desc);
465
+         xmlw_elem(writer,"reward","%s",player_missions[i]->reward);
466
 
467
          /* Markers. */
468
          xmlw_startElem( writer, "markers" );
469
-         if (player_missions[i].markers != NULL) {
470
-            n = array_size( player_missions[i].markers );
471
+         if (player_missions[i]->markers != NULL) {
472
+            n = array_size( player_missions[i]->markers );
473
             for (j=0; j<n; j++) {
474
                xmlw_startElem(writer,"marker");
475
-               xmlw_attr(writer,"id","%d",player_missions[i].markers[j].id);
476
-               xmlw_attr(writer,"type","%d",player_missions[i].markers[j].type);
477
-               xmlw_str(writer,"%s", system_getIndex(player_missions[i].markers[j].sys)->name);
478
+               xmlw_attr(writer,"id","%d",player_missions[i]->markers[j].id);
479
+               xmlw_attr(writer,"type","%d",player_missions[i]->markers[j].type);
480
+               xmlw_str(writer,"%s", system_getIndex(player_missions[i]->markers[j].sys)->name);
481
                xmlw_endElem(writer); /* "marker" */
482
             }
483
          }
484
@@ -990,19 +1023,19 @@
485
 
486
          /* Cargo */
487
          xmlw_startElem(writer,"cargos");
488
-         for (j=0; j<player_missions[i].ncargo; j++)
489
-            xmlw_elem(writer,"cargo","%u", player_missions[i].cargo[j]);
490
+         for (j=0; j<player_missions[i]->ncargo; j++)
491
+            xmlw_elem(writer,"cargo","%u", player_missions[i]->cargo[j]);
492
          xmlw_endElem(writer); /* "cargos" */
493
 
494
          /* OSD. */
495
-         if (player_missions[i].osd > 0) {
496
+         if (player_missions[i]->osd > 0) {
497
             xmlw_startElem(writer,"osd");
498
 
499
             /* Save attributes. */
500
-            items = osd_getItems(player_missions[i].osd, &nitems);
501
-            xmlw_attr(writer,"title","%s",osd_getTitle(player_missions[i].osd));
502
+            items = osd_getItems(player_missions[i]->osd, &nitems);
503
+            xmlw_attr(writer,"title","%s",osd_getTitle(player_missions[i]->osd));
504
             xmlw_attr(writer,"nitems","%d",nitems);
505
-            xmlw_attr(writer,"active","%d",osd_getActive(player_missions[i].osd));
506
+            xmlw_attr(writer,"active","%d",osd_getActive(player_missions[i]->osd));
507
 
508
             /* Save messages. */
509
             for (j=0; j<nitems; j++)
510
@@ -1013,12 +1046,12 @@
511
 
512
          /* Claims. */
513
          xmlw_startElem(writer,"claims");
514
-         claim_xmlSave( writer, player_missions[i].claims );
515
+         claim_xmlSave( writer, player_missions[i]->claims );
516
          xmlw_endElem(writer); /* "claims" */
517
 
518
          /* Write Lua magic */
519
          xmlw_startElem(writer,"lua");
520
-         nxml_persistLua( player_missions[i].L, writer );
521
+         nxml_persistLua( player_missions[i]->L, writer );
522
          xmlw_endElem(writer); /* "lua" */
523
 
524
          xmlw_endElem(writer); /* "mission" */
525
@@ -1078,7 +1111,7 @@
526
    node = parent->xmlChildrenNode;
527
    do {
528
       if (xml_isNode(node,"mission")) {
529
-         misn = &player_missions[m];
530
+         misn = player_missions[m];
531
 
532
          /* process the attributes to create the mission */
533
          xmlr_attr(node,"data",buf);
534
diff -ruN src/mission.h src/mission.h
535
--- src/mission.h
536
+++ src/mission.h
537
@@ -129,7 +129,7 @@
538
  * current player missions
539
  */
540
 #define MISSION_MAX  12 /**< No sense in allowing the player have infinite missions. */
541
-extern Mission player_missions[MISSION_MAX]; /**< Player's active missions. */
542
+extern Mission *player_missions[MISSION_MAX]; /**< Player's active missions. */
543
 
544
 
545
 /*
546
@@ -165,6 +165,7 @@
547
  */
548
 int missions_load (void);
549
 void mission_cleanup( Mission* misn );
550
+void mission_shift( int pos );
551
 void missions_free (void);
552
 void missions_cleanup (void);
553
 
554
diff -ruN src/nlua_hook.c src/nlua_hook.c
555
--- src/nlua_hook.c
556
+++ src/nlua_hook.c
557
@@ -246,7 +246,7 @@
558
    if (running_mission != NULL) {
559
       /* make sure mission is a player mission */
560
       for (i=0; i<MISSION_MAX; i++)
561
-         if (player_missions[i].id == running_mission->id)
562
+         if (player_missions[i]->id == running_mission->id)
563
             break;
564
       if (i>=MISSION_MAX) {
565
          WARN("Mission not in stack trying to hook, forgot to run misn.accept()?");
566
diff -ruN src/nlua_misn.c src/nlua_misn.c
567
--- src/nlua_misn.c
568
+++ src/nlua_misn.c
569
@@ -283,13 +283,13 @@
570
    if (misn_delete) {
571
       ret = 2;
572
       mission_cleanup( cur_mission );
573
-      for (i=0; i<MISSION_MAX; i++)
574
-         if (cur_mission == &player_missions[i]) {
575
-            memmove( &player_missions[i], &player_missions[i+1],
576
-                  sizeof(Mission) * (MISSION_MAX-i-1) );
577
-            memset( &player_missions[MISSION_MAX-1], 0, sizeof(Mission) );
578
-            break;
579
-         }
580
+      for (i=0; i<MISSION_MAX; i++) {
581
+         if (cur_mission != player_missions[i])
582
+            continue;
583
+
584
+         mission_shift(i);
585
+         break;
586
+      }
587
    }
588
 
589
    return ret;
590
@@ -609,7 +609,7 @@
591
 
592
    /* find last mission */
593
    for (i=0; i<MISSION_MAX; i++)
594
-      if (player_missions[i].data == NULL)
595
+      if (player_missions[i]->data == NULL)
596
          break;
597
 
598
    cur_mission = misn_getFromLua(L);
599
@@ -620,7 +620,7 @@
600
    else if (i>=MISSION_MAX)
601
       ret = 1;
602
    else { /* copy it over */
603
-      memcpy( &player_missions[i], cur_mission, sizeof(Mission) );
604
+      memcpy( player_missions[i], cur_mission, sizeof(Mission) );
605
       memset( cur_mission, 0, sizeof(Mission) );
606
-      cur_mission = &player_missions[i];
607
+      cur_mission = player_missions[i];
608
       cur_mission->accepted = 1; /* Mark as accepted. */
609
 
610
       /* Need to change pointer. */
611
diff -ruN src/npc.c src/npc.c
612
--- src/npc.c
613
+++ src/npc.c
614
@@ -559,7 +559,7 @@
615
 
616
    /* Make sure player can accept the mission. */
617
    for (i=0; i<MISSION_MAX; i++)
618
-      if (player_missions[i].data == NULL)
619
+      if (player_missions[i]->data == NULL)
620
          break;
621
    if (i >= MISSION_MAX) {
622
       dialogue_alert("You have too many active missions.");
623
diff -ruN src/player.c src/player.c
624
--- src/player.c
625
+++ src/player.c
626
@@ -665,7 +665,7 @@
627
  */
628
 void player_rmShip( char* shipname )
629
 {
630
-   int i;
631
+   int i, w;
632
 
633
    for (i=0; i<player_nstack; i++) {
634
       /* Not the ship we are looking for. */
635
@@ -684,6 +684,12 @@
636
       player_stack = realloc( player_stack,
637
             sizeof(PlayerShip_t) * (player_nstack) );
638
    }
639
+
640
+   /* Update ship list if landed. */
641
+   if (landed) {
642
+      w = land_getWid( LAND_WINDOW_EQUIPMENT );
643
+      equipment_regenLists( w, 0, 1 );
644
+   }
645
 }
646
 
647
 
648
@@ -3011,11 +3017,11 @@
649
          found = 0;
650
          for (j=0; j<MISSION_MAX; j++) {
651
             /* Only check active missions. */
652
-            if (player_missions[j].id > 0) {
653
+            if (player_missions[j]->id > 0) {
654
                /* Now check if it's in the cargo list. */
655
-               for (k=0; k<player_missions[j].ncargo; k++) {
656
+               for (k=0; k<player_missions[j]->ncargo; k++) {
657
                   /* See if it matches a cargo. */
658
-                  if (player_missions[j].cargo[k] == ship->commodities[i].id) {
659
+                  if (player_missions[j]->cargo[k] == ship->commodities[i].id) {
660
                      found = 1;
661
                      break;
662
                   }
(-)naev/files/patch-src_board.c (+45 lines)
Line 0 Link Here
1
Origin: https://github.com/naev/naev/commit/8b4ceb3c5db7171b65f918f278e2d3a0685bf0f2
2
From: "Ian D. Scott" <ian@perebruin.com>
3
Date: Sat, 21 Mar 2015 18:30:55 -0700
4
Subject: Correctly pass boarding ship to pilot board hook
5
6
Origin: https://github.com/naev/naev/commit/0b545ee49f33632e892e242807543d6b386a02af
7
From: "Ian D. Scott" <ian@perebruin.com>
8
Date: Mon, 30 Mar 2015 16:04:42 -0700
9
Subject: Run pilot board hook for all pilot, not just player
10
11
diff --git src/board.c src/board.c
12
index 9381cc1..24edd77 100644
13
--- src/board.c
14
+++ src/board.c
15
@@ -143,7 +143,8 @@ void player_board (void)
16
    hparam[0].u.lp.pilot = p->id;
17
    hparam[1].type       = HOOK_PARAM_SENTINEL;
18
    hooks_runParam( "board", hparam );
19
-   pilot_runHook(p, PILOT_HOOK_BOARD);
20
+   hparam[0].u.lp.pilot = PLAYER_ID;
21
+   pilot_runHookParam(p, PILOT_HOOK_BOARD, hparam, 1);
22
 
23
    if (board_stopboard) {
24
       board_boarded = 0;
25
@@ -526,6 +527,7 @@ static void board_update( unsigned int wdw )
26
 int pilot_board( Pilot *p )
27
 {
28
    Pilot *target;
29
+   HookParam hparam[2];
30
 
31
    /* Make sure target is sane. */
32
    target = pilot_get(p->target);
33
@@ -554,6 +556,12 @@ int pilot_board( Pilot *p )
34
    /* Set time it takes to board. */
35
    p->ptimer = 3.;
36
 
37
+   /* Run pilot board hook. */
38
+   hparam[0].type       = HOOK_PARAM_PILOT;
39
+   hparam[0].u.lp.pilot = p->id;
40
+   hparam[1].type       = HOOK_PARAM_SENTINEL;
41
+   pilot_runHookParam(target, PILOT_HOOK_BOARD, hparam, 1);
42
+
43
    return 1;
44
 }
45
 
(-)naev/files/patch-src_pilot_hook.c (+51 lines)
Line 0 Link Here
1
Origin: https://github.com/naev/naev/commit/6f4005f921650c1a8930721bbd1c0eab163673f8
2
From: Edgar Simo-Serra <bobbens@gmail.com>
3
Date: Wed, 1 Apr 2015 21:56:40 +0900
4
Subject: * Hook param off by one.
5
6
Origin: https://github.com/naev/naev/commit/3ba9cafb369f94115c897717b6f38415348f4c8f
7
Author: Edgar Simo-Serra <bobbens@gmail.com>
8
Date:   Wed Apr 1 22:44:08 2015 +0900
9
Subject: * Too many bugs in the code, should fix bugs with pilot hooks when using >1 parameter.
10
11
diff --git src/pilot_hook.c src/pilot_hook.c
12
index d8745aa..e6a2936 100644
13
--- src/pilot_hook.c
14
+++ src/pilot_hook.c
15
@@ -39,26 +39,26 @@ static int pilot_hookCleanup = 0; /**< Are hooks being removed from a pilot? */
16
 int pilot_runHookParam( Pilot* p, int hook_type, HookParam* param, int nparam )
17
 {
18
    int n, i, run, ret;
19
-   HookParam hparam[3], *hdynparam;
20
+   HookParam hstaparam[5], *hdynparam, *hparam;
21
 
22
    /* Set up hook parameters. */
23
-   if (nparam <= 1) {
24
-      hparam[0].type       = HOOK_PARAM_PILOT;
25
-      hparam[0].u.lp.pilot = p->id;
26
+   if (nparam <= 3) {
27
+      hstaparam[0].type       = HOOK_PARAM_PILOT;
28
+      hstaparam[0].u.lp.pilot = p->id;
29
       n  = 1;
30
-      if (nparam == 1) {
31
-         memcpy( &hparam[n], param, sizeof(HookParam) );
32
-         n++;
33
-      }
34
-      hparam[n].type    = HOOK_PARAM_SENTINEL;
35
+      memcpy( &hstaparam[n], param, sizeof(HookParam)*nparam );
36
+      n += nparam;
37
+      hstaparam[n].type = HOOK_PARAM_SENTINEL;
38
       hdynparam         = NULL;
39
+      hparam            = hstaparam;
40
    }
41
    else {
42
       hdynparam   = malloc( sizeof(HookParam) * (nparam+2) );
43
       hdynparam[0].type       = HOOK_PARAM_PILOT;
44
       hdynparam[0].u.lp.pilot = p->id;
45
       memcpy( &hdynparam[1], param, sizeof(HookParam)*nparam );
46
-      hdynparam[nparam].type  = HOOK_PARAM_SENTINEL;
47
+      hdynparam[nparam+1].type  = HOOK_PARAM_SENTINEL;
48
+      hparam                  = hdynparam;
49
    }
50
 
51
    /* Run pilot specific hooks. */
(-)naev/files/patch-src_space.c (+17 lines)
Line 0 Link Here
1
Origin: https://github.com/naev/naev/commit/173bad4a7bab85903575798a51259ff6f3dd42c8
2
From: Deiz <silverwraithii@gmail.com>
3
Date: Wed, 18 Mar 2015 20:21:06 -0400
4
Subject: Memory leak fix
5
6
diff --git src/space.c src/space.c
7
index b74e2f8..ebba1ad 100644
8
--- src/space.c
9
+++ src/space.c
10
@@ -2978,6 +2978,7 @@ void space_exit (void)
11
       free(pnt->land_func);
12
       free(pnt->land_msg);
13
       free(pnt->bribe_msg);
14
+      free(pnt->bribe_ack_msg);
15
 
16
       /* tech */
17
       if (pnt->tech != NULL)
(-)naev/files/pkg-message.in (-9 lines)
Lines 1-9 Link Here
1
###############################################################################
2
3
The NAEV space game was installed
4
5
1) You can find the conf.lua config file into your ~/.config/naev/ directory
6
7
2) Enjoy it :)
8
9
###############################################################################
(-)naev/pkg-descr (-1 / +1 lines)
Lines 1-4 Link Here
1
NAEV is a 2D space game that combines elements from the action, RPG, and
1
NAEV is a 2D space game that combines elements from the action, RPG, and
2
simulation genres.
2
simulation genres.
3
3
4
WWW: http://code.google.com/p/naev/
4
WWW: http://sourceforge.net/projects/naev/

Return to bug 198684