Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
08ac3454
Commit
08ac3454
authored
13 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
minetestmapper speed tweaks (kahrl & JacobF)
parent
3ca847b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
util/minetestmapper.py
+30
-18
30 additions, 18 deletions
util/minetestmapper.py
with
30 additions
and
18 deletions
util/minetestmapper.py
100755 → 100644
+
30
−
18
View file @
08ac3454
...
...
@@ -56,6 +56,25 @@ TRANSLATION_TABLE = {
28
:
0x813
,
# CONTENT_PAPYRUS
29
:
0x814
}
# CONTENT_BOOKSHELF
class
Bytestream
:
def
__init__
(
self
,
stream
):
self
.
stream
=
stream
self
.
pos
=
0
# So you can use files also
if
hasattr
(
self
.
stream
,
'
read
'
):
self
.
read
=
self
.
stream
.
read
def
__len__
(
self
):
return
len
(
self
.
stream
)
def
read
(
self
,
length
=
None
):
if
length
is
None
:
length
=
len
(
self
)
self
.
pos
+=
length
return
self
.
stream
[
self
.
pos
-
length
:
self
.
pos
]
def
close
(
self
):
pass
def
hex_to_int
(
h
):
i
=
int
(
h
,
16
)
...
...
@@ -170,9 +189,9 @@ if path[-1:] != "/" and path[-1:] != "\\":
# Load color information for the blocks.
colors
=
{}
try
:
f
=
file
(
"
colors.txt
"
)
f
=
file
(
"
colors.txt
"
)
except
IOError
:
f
=
file
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
colors.txt
"
))
f
=
file
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
colors.txt
"
))
for
line
in
f
:
values
=
string
.
split
(
line
)
colors
[
int
(
values
[
0
],
16
)]
=
(
...
...
@@ -200,7 +219,7 @@ if os.path.exists(path + "map.sqlite"):
if
not
r
:
break
x
,
y
,
z
=
getIntegerAsBlock
(
r
[
0
])
x
,
y
,
z
=
getIntegerAsBlock
(
r
[
0
])
if
x
<
sector_xmin
or
x
>
sector_xmax
:
continue
...
...
@@ -233,6 +252,9 @@ if os.path.exists(path + "sectors"):
xlist
.
append
(
x
)
zlist
.
append
(
z
)
# Get rid of doubles
xlist
,
zlist
=
zip
(
*
sorted
(
set
(
zip
(
xlist
,
zlist
))))
minx
=
min
(
xlist
)
minz
=
min
(
zlist
)
maxx
=
max
(
xlist
)
...
...
@@ -382,7 +404,8 @@ for n in range(len(xlist)):
if
sectortype
==
""
:
continue
ylist
.
sort
()
#ylist.sort()
ylist
=
sorted
(
set
(
ylist
))
# Make a list of pixels of the sector that are to be looked for.
pixellist
=
[]
...
...
@@ -405,17 +428,14 @@ for n in range(len(xlist)):
r
=
cur
.
fetchone
()
if
not
r
:
continue
filename
=
"
mtm_tmp
"
f
=
file
(
filename
,
'
wb
'
)
f
.
write
(
r
[
0
])
f
.
close
()
f
=
Bytestream
(
r
[
0
])
else
:
if
sectortype
==
"
old
"
:
filename
=
path
+
"
sectors/
"
+
sector1
+
"
/
"
+
yhex
.
lower
()
else
:
filename
=
path
+
"
sectors2/
"
+
sector2
+
"
/
"
+
yhex
.
lower
()
f
=
file
(
filename
,
"
rb
"
)
f
=
file
(
filename
,
"
rb
"
)
# Let's just memorize these even though it's not really necessary.
version
=
ord
(
f
.
read
(
1
))
...
...
@@ -441,12 +461,7 @@ for n in range(len(xlist)):
r
=
cur
.
fetchone
()
if
not
r
:
continue
filename
=
"
mtm_tmp
"
f
=
file
(
filename
,
'
wb
'
)
f
.
write
(
r
[
0
])
f
.
close
()
f
=
file
(
filename
,
"
rb
"
)
f
=
Bytestream
(
r
[
0
])
version
=
ord
(
f
.
read
(
1
))
flags
=
f
.
read
(
1
)
...
...
@@ -567,8 +582,5 @@ if drawplayers:
except
OSError
:
pass
if
os
.
path
.
isfile
(
"
mtm_tmp
"
):
os
.
remove
(
"
mtm_tmp
"
)
print
"
Saving
"
im
.
save
(
output
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment