pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

barony337: add patches to fix corrupt textures



Module Name:	pkgsrc-wip
Committed By:	Yorick Hardy <yorickhardy%gmail.com@localhost>
Pushed By:	yhardy
Date:		Sun May 30 20:50:48 2021 +0200
Changeset:	9c52e841d8ed36d402a86bda5e13ea0cb59d0482

Modified Files:
	barony337/Makefile
	barony337/distinfo
Added Files:
	barony337/=3.4.2
	barony337/patches/patch-src_draw.cpp
	barony337/patches/patch-src_files.cpp
	barony337/patches/patch-src_opengl.cpp
	barony337/patches/patch-src_savepng.cpp

Log Message:
barony337: add patches to fix corrupt textures

TurningWheel/Barony issue #580 (reported by rapenne-s on github),
and fixed in pull request #582 (by 1bsyl on github).

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=9c52e841d8ed36d402a86bda5e13ea0cb59d0482

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 barony337/=3.4.2                        |   0
 barony337/Makefile                      |   1 +
 barony337/distinfo                      |   4 ++
 barony337/patches/patch-src_draw.cpp    | 113 ++++++++++++++++++++++++++++++++
 barony337/patches/patch-src_files.cpp   |  32 +++++++++
 barony337/patches/patch-src_opengl.cpp  | 106 ++++++++++++++++++++++++++++++
 barony337/patches/patch-src_savepng.cpp |  23 +++++++
 7 files changed, 279 insertions(+)

diffs:
diff --git a/barony337/=3.4.2 b/barony337/=3.4.2
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/barony337/Makefile b/barony337/Makefile
index 0f7a299259..6ae903090e 100644
--- a/barony337/Makefile
+++ b/barony337/Makefile
@@ -2,6 +2,7 @@
 
 GITHUB_PROJECT=	Barony
 DISTNAME=	Barony-3.3.7
+PKGREVISION=	1
 PKGNAME=	${DISTNAME:tl}
 CATEGORIES=	games
 MASTER_SITES=	${MASTER_SITE_GITHUB:=TurningWheel/}
diff --git a/barony337/distinfo b/barony337/distinfo
index 519fee0a44..73f38e4ae3 100644
--- a/barony337/distinfo
+++ b/barony337/distinfo
@@ -4,3 +4,7 @@ SHA1 (Barony-3.3.7.tar.gz) = a10e4d65168af60d343887eb5898a37d5f5098c4
 RMD160 (Barony-3.3.7.tar.gz) = a7dcbf8a6619e405ff214f9a46818767e037bcb9
 SHA512 (Barony-3.3.7.tar.gz) = e7091c55af798967afd6c8c162864bd3f9329c914ddfa31c44ae4de2cdb721fc7a22fc6984d0a132240d35ecb7c164bc4570cd36ac1faa073d939d608b988897
 Size (Barony-3.3.7.tar.gz) = 53830405 bytes
+SHA1 (patch-src_draw.cpp) = 735145f95b80eaa1296d9353e7d726c174558e0c
+SHA1 (patch-src_files.cpp) = 4c214574534cd9801a25d305d0b2a9112181423f
+SHA1 (patch-src_opengl.cpp) = 5f666dafbc21d73a0ce2ca8fa1a45c9439138a33
+SHA1 (patch-src_savepng.cpp) = e0f8388e0aebc39be6dc8b559b66d3833e6526fb
diff --git a/barony337/patches/patch-src_draw.cpp b/barony337/patches/patch-src_draw.cpp
new file mode 100644
index 0000000000..2f3ffb8e9c
--- /dev/null
+++ b/barony337/patches/patch-src_draw.cpp
@@ -0,0 +1,113 @@
+$NetBSD$
+
+From pull request https://github.com/TurningWheel/Barony/pull/582.
+
+From c07db95221606e88b58908fee314cf1e8d14bb6a Mon Sep 17 00:00:00 2001
+From: Sylvain
+Date: Sat, 10 Apr 2021 21:33:29 +0200
+Subject: [PATCH 1/3] Fixed bug 580 - Use 'userdata' instead of 'refcount'
+ 'refcount' is a private SDL_Surface field
+
+diff --git a/src/draw.cpp b/src/draw.cpp
+index 08f95343f..4e62c751a 100644
+--- src/draw.cpp
++++ src/draw.cpp
+@@ -443,7 +443,7 @@ void drawImageRotatedAlpha( SDL_Surface* image, SDL_Rect* src, SDL_Rect* pos, re
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	glColor4f(1, 1, 1, alpha / 255.1);
+ 	glBegin(GL_QUADS);
+ 	glTexCoord2f(1.0 * ((real_t)src->x / image->w), 1.0 * ((real_t)src->y / image->h));
+@@ -492,7 +492,7 @@ void drawImageColor( SDL_Surface* image, SDL_Rect* src, SDL_Rect* pos, Uint32 co
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	real_t r = ((Uint8)(color >> mainsurface->format->Rshift)) / 255.f;
+ 	real_t g = ((Uint8)(color >> mainsurface->format->Gshift)) / 255.f;
+ 	real_t b = ((Uint8)(color >> mainsurface->format->Bshift)) / 255.f;
+@@ -546,7 +546,7 @@ void drawImageAlpha( SDL_Surface* image, SDL_Rect* src, SDL_Rect* pos, Uint8 alp
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	glColor4f(1, 1, 1, alpha / 255.1);
+ 	glPushMatrix();
+ 	glBegin(GL_QUADS);
+@@ -596,7 +596,7 @@ void drawImage( SDL_Surface* image, SDL_Rect* src, SDL_Rect* pos )
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	glColor4f(1, 1, 1, 1);
+ 	glPushMatrix();
+ 	glBegin(GL_QUADS);
+@@ -646,7 +646,7 @@ void drawImageRing(SDL_Surface* image, SDL_Rect* src, int radius, int thickness,
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	glColor4f(1, 1, 1, alpha / 255.f);
+ 	glPushMatrix();
+ 
+@@ -771,7 +771,7 @@ void drawImageScaled( SDL_Surface* image, SDL_Rect* src, SDL_Rect* pos )
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	glColor4f(1, 1, 1, 1);
+ 	glPushMatrix();
+ 	glBegin(GL_QUADS);
+@@ -826,7 +826,7 @@ void drawImageScaledPartial(SDL_Surface* image, SDL_Rect* src, SDL_Rect* pos, fl
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	glColor4f(1, 1, 1, 1);
+ 	glPushMatrix();
+ 	glBegin(GL_QUADS);
+@@ -889,7 +889,7 @@ void drawImageScaledColor(SDL_Surface* image, SDL_Rect* src, SDL_Rect* pos, Uint
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	real_t r = ((Uint8)(color >> mainsurface->format->Rshift)) / 255.f;
+ 	real_t g = ((Uint8)(color >> mainsurface->format->Gshift)) / 255.f;
+ 	real_t b = ((Uint8)(color >> mainsurface->format->Bshift)) / 255.f;
+@@ -985,7 +985,7 @@ void drawImageFancy( SDL_Surface* image, Uint32 color, real_t angle, SDL_Rect* s
+ 	}
+ 
+ 	// draw a textured quad
+-	glBindTexture(GL_TEXTURE_2D, texid[image->refcount]);
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)image->userdata]);
+ 	real_t r = ((Uint8)(color >> mainsurface->format->Rshift)) / 255.f;
+ 	real_t g = ((Uint8)(color >> mainsurface->format->Gshift)) / 255.f;
+ 	real_t b = ((Uint8)(color >> mainsurface->format->Bshift)) / 255.f;
+@@ -2186,7 +2186,7 @@ void drawWindowFancy(int x1, int y1, int x2, int y2)
+ 	glVertex2f(x2 - 1, yres - y1 - 1);
+ 	glEnd();
+ 	glColor3f(.75, .75, .75);
+-	glBindTexture(GL_TEXTURE_2D, texid[fancyWindow_bmp->refcount]); // wood texture
++	glBindTexture(GL_TEXTURE_2D, texid[(long int)fancyWindow_bmp->userdata]); // wood texture
+ 	glBegin(GL_QUADS);
+ 	glTexCoord2f(0, 0);
+ 	glVertex2f(x1 + 2, yres - y1 - 2);
+@@ -2322,7 +2322,7 @@ SDL_Rect ttfPrintTextColor( TTF_Font* font, int x, int y, Uint32 color, bool out
+ 		SDL_BlitSurface(textSurf, NULL, surf, &pos);
+ 		// load the text outline surface as a GL texture
+ 		allsurfaces[imgref] = surf;
+-		allsurfaces[imgref]->refcount = imgref;
++		allsurfaces[imgref]->userdata = (void*) imgref;
+ 		glLoadTexture(allsurfaces[imgref], imgref);
+ 		imgref++;
+ 		// store the surface in the text surface cache
diff --git a/barony337/patches/patch-src_files.cpp b/barony337/patches/patch-src_files.cpp
new file mode 100644
index 0000000000..38055091eb
--- /dev/null
+++ b/barony337/patches/patch-src_files.cpp
@@ -0,0 +1,32 @@
+$NetBSD$
+
+From pull request https://github.com/TurningWheel/Barony/pull/582.
+
+From c07db95221606e88b58908fee314cf1e8d14bb6a Mon Sep 17 00:00:00 2001
+From: Sylvain
+Date: Sat, 10 Apr 2021 21:33:29 +0200
+Subject: [PATCH 1/3] Fixed bug 580 - Use 'userdata' instead of 'refcount'
+ 'refcount' is a private SDL_Surface field
+
+diff --git a/src/files.cpp b/src/files.cpp
+index 2beb9a6b9..389ade6d1 100644
+
+From cf95fc1519465d0391d55e86624f10f8d0cf65de Mon Sep 17 00:00:00 2001
+From: Sylvain
+Date: Sat, 10 Apr 2021 21:34:27 +0200
+Subject: [PATCH 2/3] Fixed bug 580 - use 'imgref' and not 'imgref + 1'
+
+diff --git a/src/files.cpp b/src/files.cpp
+index 389ade6d1..d37f98398 100644
+
+--- src/files.cpp
++++ src/files.cpp
+@@ -591,7 +591,7 @@ SDL_Surface* loadImage(char const * const filename)
+ 
+ 	// load the new surface as a GL texture
+ 	allsurfaces[imgref] = newSurface;
+-	allsurfaces[imgref]->refcount = imgref + 1;
++	allsurfaces[imgref]->userdata = (void *)(imgref);
+ 	glLoadTexture(allsurfaces[imgref], imgref);
+ 
+ 	// free the translated surface
diff --git a/barony337/patches/patch-src_opengl.cpp b/barony337/patches/patch-src_opengl.cpp
new file mode 100644
index 0000000000..014e6b2bc2
--- /dev/null
+++ b/barony337/patches/patch-src_opengl.cpp
@@ -0,0 +1,106 @@
+$NetBSD$
+
+From pull request https://github.com/TurningWheel/Barony/pull/582.
+
+From c07db95221606e88b58908fee314cf1e8d14bb6a Mon Sep 17 00:00:00 2001
+From: Sylvain
+Date: Sat, 10 Apr 2021 21:33:29 +0200
+Subject: [PATCH 1/3] Fixed bug 580 - Use 'userdata' instead of 'refcount'
+ 'refcount' is a private SDL_Surface field
+
+diff --git a/src/opengl.cpp b/src/opengl.cpp
+index f5b81e77a..3ac225825 100644
+--- src/opengl.cpp
++++ src/opengl.cpp
+@@ -500,7 +500,7 @@ void glDrawSprite(view_t* camera, Entity* entity, int mode)
+ 	}
+ 	if ( mode == REALCOLORS )
+ 	{
+-		glBindTexture(GL_TEXTURE_2D, texid[sprite->refcount]);
++		glBindTexture(GL_TEXTURE_2D, texid[(long int)sprite->userdata]);
+ 	}
+ 	else
+ 	{
+@@ -586,7 +586,7 @@ void glDrawSpriteFromImage(view_t* camera, Entity* entity, std::string text, int
+ 	//int x, y;
+ 	real_t s = 1;
+ 	SDL_Surface* image = sprites[0];
+-	GLuint textureId = texid[sprites[0]->refcount];
++	GLuint textureId = texid[(long int)sprites[0]->userdata];
+ 	char textToRetrieve[128];
+ 
+ 	if ( text.compare("") == 0 )
+@@ -603,7 +603,7 @@ void glDrawSpriteFromImage(view_t* camera, Entity* entity, std::string text, int
+ 	textToRetrieve[std::min(static_cast<int>(strlen(text.c_str())), 22)] = '\0';
+ 	if ( (image = ttfTextHashRetrieve(ttfTextHash, textToRetrieve, ttf12, true)) != NULL )
+ 	{
+-		textureId = texid[image->refcount];
++		textureId = texid[(long int)image->userdata];
+ 	}
+ 	else
+ 	{
+@@ -627,7 +627,7 @@ void glDrawSpriteFromImage(view_t* camera, Entity* entity, std::string text, int
+ 		SDL_BlitSurface(textSurf, NULL, image, &pos);
+ 		// load the text outline surface as a GL texture
+ 		allsurfaces[imgref] = image;
+-		allsurfaces[imgref]->refcount = imgref;
++		allsurfaces[imgref]->userdata = (void *)((long int)imgref);
+ 		glLoadTexture(allsurfaces[imgref], imgref);
+ 		imgref++;
+ 		// store the surface in the text surface cache
+@@ -635,7 +635,7 @@ void glDrawSpriteFromImage(view_t* camera, Entity* entity, std::string text, int
+ 		{
+ 			printlog("warning: failed to store text outline surface with imgref %d\n", imgref - 1);
+ 		}
+-		textureId = texid[image->refcount];
++		textureId = texid[(long int)image->userdata];
+ 	}
+ 	// setup projection
+ 	glMatrixMode(GL_PROJECTION);
+@@ -864,7 +864,7 @@ void glDrawWorld(view_t* camera, int mode)
+ 
+ 		// first (higher) sky layer
+ 		glColor4f(1.f, 1.f, 1.f, .5);
+-		glBindTexture(GL_TEXTURE_2D, texid[tiles[cloudtile]->refcount]); // sky tile
++		glBindTexture(GL_TEXTURE_2D, texid[(long int)tiles[cloudtile]->userdata]); // sky tile
+ 		glBegin( GL_QUADS );
+ 		glTexCoord2f((real_t)(ticks % 60) / 60, (real_t)(ticks % 60) / 60);
+ 		glVertex3f(-CLIPFAR * 16, 64, -CLIPFAR * 16);
+@@ -881,7 +881,7 @@ void glDrawWorld(view_t* camera, int mode)
+ 
+ 		// second (closer) sky layer
+ 		glColor4f(1.f, 1.f, 1.f, .5);
+-		glBindTexture(GL_TEXTURE_2D, texid[tiles[cloudtile]->refcount]); // sky tile
++		glBindTexture(GL_TEXTURE_2D, texid[(long int)tiles[cloudtile]->userdata]); // sky tile
+ 		glBegin( GL_QUADS );
+ 		glTexCoord2f((real_t)(ticks % 240) / 240, (real_t)(ticks % 240) / 240);
+ 		glVertex3f(-CLIPFAR * 16, 32, -CLIPFAR * 16);
+@@ -954,13 +954,13 @@ void glDrawWorld(view_t* camera, int mode)
+ 						{
+ 							if ( map.tiles[index] < 0 || map.tiles[index] >= numtiles )
+ 							{
+-								new_tex = texid[sprites[0]->refcount];
+-								//glBindTexture(GL_TEXTURE_2D, texid[sprites[0]->refcount]);
++								new_tex = texid[(long int)sprites[0]->userdata];
++								//glBindTexture(GL_TEXTURE_2D, texid[(long int)sprites[0]->userdata]);
+ 							}
+ 							else
+ 							{
+-								new_tex = texid[tiles[map.tiles[index]]->refcount];
+-								//glBindTexture(GL_TEXTURE_2D, texid[tiles[map.tiles[index]]->refcount]);
++								new_tex = texid[(long int)tiles[map.tiles[index]]->userdata];
++								//glBindTexture(GL_TEXTURE_2D, texid[(long int)tiles[map.tiles[index]]->userdata]);
+ 							}
+ 						}
+ 						else
+@@ -1282,8 +1282,8 @@ void glDrawWorld(view_t* camera, int mode)
+ 						// bind texture
+ 						if ( mode == REALCOLORS )
+ 						{
+-							new_tex = texid[tiles[mapceilingtile]->refcount];
+-							//glBindTexture(GL_TEXTURE_2D, texid[tiles[50]->refcount]); // rock tile
++							new_tex = texid[(long int)tiles[mapceilingtile]->userdata];
++							//glBindTexture(GL_TEXTURE_2D, texid[(long int)tiles[50]->userdata]); // rock tile
+ 							if (cur_tex!=new_tex)
+ 							{
+ 								glEnd();
diff --git a/barony337/patches/patch-src_savepng.cpp b/barony337/patches/patch-src_savepng.cpp
new file mode 100644
index 0000000000..98ad6f88b1
--- /dev/null
+++ b/barony337/patches/patch-src_savepng.cpp
@@ -0,0 +1,23 @@
+$NetBSD$
+
+From pull request https://github.com/TurningWheel/Barony/pull/582.
+
+From c07db95221606e88b58908fee314cf1e8d14bb6a Mon Sep 17 00:00:00 2001
+From: Sylvain
+Date: Sat, 10 Apr 2021 21:33:29 +0200
+Subject: [PATCH 1/3] Fixed bug 580 - Use 'userdata' instead of 'refcount'
+ 'refcount' is a private SDL_Surface field
+
+diff --git a/src/savepng.cpp b/src/savepng.cpp
+index fa7a5d4e2..59e052a5c 100644
+--- src/savepng.cpp
++++ src/savepng.cpp
+@@ -59,7 +59,7 @@ SDL_Surface* SDL_PNGFormatAlpha(SDL_Surface* src)
+ 	/* NO-OP for images < 32bpp and 32bpp images that already have Alpha channel */
+ 	if (src->format->BitsPerPixel <= 24 || src->format->Amask)
+ 	{
+-		src->refcount++;
++		src->userdata = (void *)((long int) src->userdata + 1);
+ 		return src;
+ 	}
+ 


Home | Main Index | Thread Index | Old Index