Skip to content

Commit d04de20

Browse files
committedSep 10, 2017
nifskope: Fix build
https://hydra.nixos.org/build/60608938 (cherry picked from commit 79c9adc)
1 parent 32e85cd commit d04de20

File tree

2 files changed

+127
-2
lines changed

2 files changed

+127
-2
lines changed
 

Diff for: ‎pkgs/tools/graphics/nifskope/default.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ stdenv.mkDerivation rec {
44
name = "nifskope-1.1.3";
55

66
src = fetchurl {
7-
url = "mirror://sourceforge/niftools/${name}.tar.bz2";
7+
url = "https://github.com/niftools/nifskope/releases/download/${name}/${name}.tar.bz2";
88
sha256 = "0fcvrcjyvivww10sjhxamcip797b9ykbf5p3rm2k24xhkwdaqp72";
99
};
1010

11+
patches = [ ./gcc-6.patch ];
12+
1113
buildInputs = [ qt4 ];
1214

1315
nativeBuildInputs = [ qmake4Hook ];
@@ -46,7 +48,7 @@ stdenv.mkDerivation rec {
4648
''; # */
4749

4850
meta = {
49-
homepage = http://niftools.sourceforge.net/;
51+
homepage = https://github.com/niftools/nifskope/;
5052
description = "A tool for analyzing and editing NetImmerse/Gamebryo '*.nif' files";
5153
maintainers = [ stdenv.lib.maintainers.eelco ];
5254
platforms = stdenv.lib.platforms.linux;

Diff for: ‎pkgs/tools/graphics/nifskope/gcc-6.patch

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Based on https://github.com/niftools/nifskope/commit/7261b0a119a549b11006d8e41ba990d706171f1c
2+
3+
diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/ColorBlock.cpp nifskope-1.1.3/gl/dds/ColorBlock.cpp
4+
--- nifskope-1.1.3-orig/gl/dds/ColorBlock.cpp 2012-11-17 23:40:31.000000000 +0100
5+
+++ nifskope-1.1.3/gl/dds/ColorBlock.cpp 2017-09-10 10:50:36.766909836 +0200
6+
@@ -78,8 +78,8 @@
7+
8+
void ColorBlock::init(const Image * img, uint x, uint y)
9+
{
10+
- const uint bw = min(img->width() - x, 4U);
11+
- const uint bh = min(img->height() - y, 4U);
12+
+ const uint bw = std::min(img->width() - x, 4U);
13+
+ const uint bh = std::min(img->height() - y, 4U);
14+
15+
static int remainder[] = {
16+
0, 0, 0, 0,
17+
diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/Common.h nifskope-1.1.3/gl/dds/Common.h
18+
--- nifskope-1.1.3-orig/gl/dds/Common.h 2012-11-17 23:40:31.000000000 +0100
19+
+++ nifskope-1.1.3/gl/dds/Common.h 2017-09-10 10:48:08.462099032 +0200
20+
@@ -33,14 +33,10 @@
21+
#ifndef _DDS_COMMON_H
22+
#define _DDS_COMMON_H
23+
24+
-#ifndef min
25+
-#define min(a,b) ((a) <= (b) ? (a) : (b))
26+
-#endif
27+
-#ifndef max
28+
-#define max(a,b) ((a) >= (b) ? (a) : (b))
29+
-#endif
30+
+#include <algorithm>
31+
+
32+
#ifndef clamp
33+
-#define clamp(x,a,b) min(max((x), (a)), (b))
34+
+#define clamp(x,a,b) std::min( std::max( (x), (a) ), (b) )
35+
#endif
36+
37+
template<typename T>
38+
diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/DirectDrawSurface.cpp nifskope-1.1.3/gl/dds/DirectDrawSurface.cpp
39+
--- nifskope-1.1.3-orig/gl/dds/DirectDrawSurface.cpp 2012-11-17 23:40:31.000000000 +0100
40+
+++ nifskope-1.1.3/gl/dds/DirectDrawSurface.cpp 2017-09-10 10:48:45.912056969 +0200
41+
@@ -63,6 +63,7 @@
42+
#include "DirectDrawSurface.h"
43+
#include "BlockDXT.h"
44+
#include "PixelFormat.h"
45+
+#include "Common.h"
46+
47+
#include <stdio.h> // printf
48+
#include <math.h> // sqrt
49+
@@ -685,8 +686,8 @@
50+
// Compute width and height.
51+
for (uint m = 0; m < mipmap; m++)
52+
{
53+
- w = max(1U, w / 2);
54+
- h = max(1U, h / 2);
55+
+ w = std::max(1U, w / 2);
56+
+ h = std::max(1U, h / 2);
57+
}
58+
59+
img->allocate(w, h);
60+
@@ -787,9 +788,9 @@
61+
readBlock(&block);
62+
63+
// Write color block.
64+
- for (uint y = 0; y < min(4U, h-4*by); y++)
65+
+ for (uint y = 0; y < std::min(4U, h-4*by); y++)
66+
{
67+
- for (uint x = 0; x < min(4U, w-4*bx); x++)
68+
+ for (uint x = 0; x < std::min(4U, w-4*bx); x++)
69+
{
70+
img->pixel(4*bx+x, 4*by+y) = block.color(x, y);
71+
}
72+
@@ -909,9 +910,9 @@
73+
74+
for (uint m = 0; m < mipmap; m++)
75+
{
76+
- w = max(1U, w / 2);
77+
- h = max(1U, h / 2);
78+
- d = max(1U, d / 2);
79+
+ w = std::max(1U, w / 2);
80+
+ h = std::max(1U, h / 2);
81+
+ d = std::max(1U, d / 2);
82+
}
83+
84+
if (header.pf.flags & DDPF_FOURCC)
85+
diff -ru -x '*~' nifskope-1.1.3-orig/gl/gltexloaders.cpp nifskope-1.1.3/gl/gltexloaders.cpp
86+
--- nifskope-1.1.3-orig/gl/gltexloaders.cpp 2012-11-17 23:40:31.000000000 +0100
87+
+++ nifskope-1.1.3/gl/gltexloaders.cpp 2017-09-10 10:51:23.586839810 +0200
88+
@@ -1736,8 +1736,8 @@
89+
90+
// generate next offset, resize
91+
mipmapOffset += mipmapWidth * mipmapHeight * 4;
92+
- mipmapWidth = max( 1, mipmapWidth / 2 );
93+
- mipmapHeight = max( 1, mipmapHeight / 2 );
94+
+ mipmapWidth = std::max( 1, mipmapWidth / 2 );
95+
+ mipmapHeight = std::max( 1, mipmapHeight / 2 );
96+
}
97+
98+
// set total pixel size
99+
@@ -1932,11 +1932,11 @@
100+
{
101+
if ( ddsHeader.ddsPixelFormat.dwFourCC == FOURCC_DXT1 )
102+
{
103+
- mipmapOffset += max( 8, ( mipmapWidth * mipmapHeight / 2 ) );
104+
+ mipmapOffset += std::max( 8, ( mipmapWidth * mipmapHeight / 2 ) );
105+
}
106+
else if ( ddsHeader.ddsPixelFormat.dwFourCC == FOURCC_DXT5 )
107+
{
108+
- mipmapOffset += max( 16, ( mipmapWidth * mipmapHeight ) );
109+
+ mipmapOffset += std::max( 16, ( mipmapWidth * mipmapHeight ) );
110+
}
111+
}
112+
else if ( ddsHeader.ddsPixelFormat.dwBPP == 24 )
113+
@@ -1947,8 +1947,8 @@
114+
{
115+
mipmapOffset += ( mipmapWidth * mipmapHeight * 4 );
116+
}
117+
- mipmapWidth = max( 1, mipmapWidth / 2 );
118+
- mipmapHeight = max( 1, mipmapHeight / 2 );
119+
+ mipmapWidth = std::max( 1, mipmapWidth / 2 );
120+
+ mipmapHeight = std::max( 1, mipmapHeight / 2 );
121+
}
122+
123+
nif->set<quint32>( iData, "Num Pixels", mipmapOffset );

0 commit comments

Comments
 (0)
Please sign in to comment.