[PATCH] Fix TGA file writing on Windows #1980

Closed
opened 2022-01-31 05:53:09 +01:00 by erlehmann · 6 comments
Member

Apply with git am:

From e041533bb194cbdd60e14467f7cbd1a8c9225f95 Mon Sep 17 00:00:00 2001
From: Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Date: Sun, 30 Jan 2022 20:33:06 +0100
Subject: [PATCH] Fix TGA file writing on Windows

Before this patch, the tga_encoder mod would write corrupted TGA files
on Windows: Bytes that looked like newlines were replaced by a carriage
return and a newline.
---
 mods/CORE/tga_encoder/init.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mods/CORE/tga_encoder/init.lua b/mods/CORE/tga_encoder/init.lua
index 39309c9c9..24ec502e1 100644
--- a/mods/CORE/tga_encoder/init.lua
+++ b/mods/CORE/tga_encoder/init.lua
@@ -84,7 +84,7 @@ function image:encode()
 end
 
 function image:save(filename)
-	local f = assert(io.open(filename, "w"))
+	local f = assert(io.open(filename, "wb"))
 	f:write(self.data)
 	f:close()
 end
-- 
2.30.2


[Apply with `git am`](https://thoughtbot.com/blog/send-a-patch-to-someone-using-git-format-patch): ``` From e041533bb194cbdd60e14467f7cbd1a8c9225f95 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> Date: Sun, 30 Jan 2022 20:33:06 +0100 Subject: [PATCH] Fix TGA file writing on Windows Before this patch, the tga_encoder mod would write corrupted TGA files on Windows: Bytes that looked like newlines were replaced by a carriage return and a newline. --- mods/CORE/tga_encoder/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/CORE/tga_encoder/init.lua b/mods/CORE/tga_encoder/init.lua index 39309c9c9..24ec502e1 100644 --- a/mods/CORE/tga_encoder/init.lua +++ b/mods/CORE/tga_encoder/init.lua @@ -84,7 +84,7 @@ function image:encode() end function image:save(filename) - local f = assert(io.open(filename, "w")) + local f = assert(io.open(filename, "wb")) f:write(self.data) f:close() end -- 2.30.2 ```
AFCMS added the
bug
contribution inside
#P3: elevated
labels 2022-01-31 08:32:50 +01:00
Author
Member

How to test:

  1. Start game on Windows without this patch. Note that you can not make maps.

  2. Notice that the textures are generated, but are indeed corrupted sadly.

  3. Start game on Windows with this patch. Note that you can make maps.

How to test: 1. Start game on Windows without this patch. Note that you can not make maps. 2. Notice that the textures are generated, but are indeed corrupted sadly. 3. Start game on Windows with this patch. Note that you can make maps.
Author
Member

@cora now that you are the new maintainer, can this be considered?

@cora now that you are the new maintainer, can this be considered?
Contributor

will you consider making a pr ?

will you consider making a pr ?
Author
Member

I will consider it.

I will consider it.
Author
Member
https://git.minetest.land/MineClone2/MineClone2/pulls/1985

PR was merged, closing issue.

PR was merged, closing issue.
Ghost closed this issue 2022-09-06 22:51:59 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#1980
No description provided.