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
520b4702
Commit
520b4702
authored
13 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'kahrl/sectors2sqlite-fix'
parents
9a7471b7
561bb649
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/sectors2sqlite.py
+17
-8
17 additions, 8 deletions
util/sectors2sqlite.py
with
17 additions
and
8 deletions
util/sectors2sqlite.py
+
17
−
8
View file @
520b4702
...
...
@@ -3,7 +3,7 @@
# Loads block files from sectors folders into map.sqlite database.
# The sectors folder should be safe to remove after this prints "Finished."
import
time
,
os
import
time
,
os
,
sys
try
:
import
sqlite3
...
...
@@ -23,10 +23,14 @@ if os.path.isdir(path + 'sectors/'):
if
not
paths
:
exit
(
'
Could not find sectors folder at
'
+
path
+
'
sectors2/ or
'
+
path
+
'
sectors/
'
)
def
uin
t
(
u
):
def
parseSigned12bi
t
(
u
):
u
=
int
(
'
0x
'
+
u
,
16
)
return
(
u
if
u
<
2
**
11
else
u
-
2
**
12
)
def
parseSigned16bit
(
u
):
u
=
int
(
'
0x
'
+
u
,
16
)
return
(
u
if
u
<
2
**
15
else
u
-
2
**
16
)
def
int64
(
u
):
while
u
>=
2
**
63
:
u
-=
2
**
64
...
...
@@ -38,12 +42,12 @@ def int64(u):
def
getSectorPos
(
dirname
):
if
len
(
dirname
)
==
8
:
# Old layout
x
=
uin
t
(
dirname
[:
4
])
z
=
uin
t
(
dirname
[
4
:])
x
=
parseSigned16bi
t
(
dirname
[:
4
])
z
=
parseSigned16bi
t
(
dirname
[
4
:])
elif
len
(
dirname
)
==
7
:
# New layout
x
=
uin
t
(
dirname
[:
3
])
z
=
uin
t
(
dirname
[
4
:])
x
=
parseSigned12bi
t
(
dirname
[:
3
])
z
=
parseSigned12bi
t
(
dirname
[
4
:])
else
:
print
(
'
Terrible sector at
'
+
dirname
)
return
...
...
@@ -60,7 +64,7 @@ def getBlockPos(sectordir, blockfile):
if
len
(
blockfile
)
!=
4
:
print
(
"
Invalid block filename:
"
+
blockfile
)
y
=
uin
t
(
blockfile
)
y
=
parseSigned16bi
t
(
blockfile
)
return
p2d
[
0
],
y
,
p2d
[
1
]
...
...
@@ -110,8 +114,13 @@ for base in paths:
continue
f
=
open
(
root
+
'
/
'
+
block
,
'
rb
'
)
cur
.
execute
(
'
INSERT OR IGNORE INTO `blocks` VALUES(?, ?)
'
,
(
pos
,
f
.
read
()
))
blob
=
f
.
read
()
f
.
close
()
if
sys
.
version_info
.
major
==
2
:
blob
=
buffer
(
blob
)
else
:
blob
=
memoryview
(
blob
)
cur
.
execute
(
'
INSERT OR IGNORE INTO `blocks` VALUES(?, ?)
'
,
(
pos
,
blob
))
count
+=
1
if
(
time
.
time
()
-
t
>
3
):
...
...
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