mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Frictions: Fix none assiciated stricklers at save/load.
This commit is contained in:
1 parent
e86111bd7a
commit
8b8aff7df1
1 file changed
+17
-1
@@ -77,7 +77,14 @@ class Friction(SQLSubModel):
|
||||
for row in table:
|
||||
ind = row[0]
|
||||
# Get stricklers
|
||||
if int(row[3]) == -1:
|
||||
bs = None
|
||||
else:
|
||||
bs = next(filter(lambda s: s.id == row[3], stricklers))
|
||||
|
||||
if int(row[4]) == -1:
|
||||
es = None
|
||||
else:
|
||||
es = next(filter(lambda s: s.id == row[4], stricklers))
|
||||
|
||||
# Create friction
|
||||
@@ -94,6 +101,15 @@ class Friction(SQLSubModel):
|
||||
|
||||
def _db_save(self, execute, data=None):
|
||||
ind = data["ind"]
|
||||
|
||||
b_s_id = -1
|
||||
e_s_id = -1
|
||||
|
||||
if self._begin_strickler is not None:
|
||||
b_s_id = self._begin_strickler.id
|
||||
if self._end_strickler is not None:
|
||||
e_s_id = self._end_strickler.id
|
||||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"friction(ind, begin_kp, end_kp, " +
|
||||
@@ -101,7 +117,7 @@ class Friction(SQLSubModel):
|
||||
"VALUES (" +
|
||||
f"{ind}, {self._begin_kp}, {self._end_kp}, " +
|
||||
f"{self._edge.id}, " +
|
||||
f"{self._begin_strickler.id}, {self._end_strickler.id}" +
|
||||
f"{b_s_id}, {e_s_id}" +
|
||||
")"
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user