Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
tome
Tales of MajEyal
Commits
71f8c033
Commit
71f8c033
authored
10 years ago
by
Alex Ksandra
Browse files
Options
Downloads
Patches
Plain Diff
Made the game being gentle about e_array modifications.
parent
fb397b15
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!120
Occasional turn loss fix.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/GameEnergyBased.lua
+9
-7
9 additions, 7 deletions
game/engines/default/engine/GameEnergyBased.lua
game/engines/default/engine/Level.lua
+11
-1
11 additions, 1 deletion
game/engines/default/engine/Level.lua
with
20 additions
and
8 deletions
game/engines/default/engine/GameEnergyBased.lua
+
9
−
7
View file @
71f8c033
...
...
@@ -94,19 +94,19 @@ function _M:tickLevel(level)
local
arr
=
level
.
e_array
if
level
.
last_iteration
then
i
=
nil
for
ii
=
1
,
#
arr
do
if
arr
[
ii
]
==
level
.
last_iteration
.
e
then
i
=
ii
+
1
break
end
end
if
not
i
then
i
=
level
.
last_iteration
.
i
+
1
end
i
=
level
.
last_iteration
.
i
+
1
if
i
>
#
arr
then
i
=
1
end
level
.
last_iteration
=
nil
-- print("=====LEVEL", level.level, level.sublevel_id, "resuming tick loop at ", i, arr[i].name)
end
for
i
=
i
,
#
arr
do
level
.
last_iteration
=
{}
-- mark as iterating
local
iter
=
level
.
last_iteration
local
finished
=
true
while
i
<=
#
arr
do
e
=
arr
[
i
]
iter
.
e
,
iter
.
i
=
e
,
i
if
e
and
e
.
act
and
e
.
energy
then
if
e
.
actBase
and
e
.
energyBase
then
if
e
.
energyBase
<
self
.
energy_to_act
then
...
...
@@ -128,12 +128,14 @@ function _M:tickLevel(level)
-- print(">ENERGY", e.name, e.uid, "::", e.energy.value, self.paused, "::", e.player)
if
self
.
can_pause
and
self
.
paused
then
level
.
last_iteration
=
{
i
=
i
,
e
=
e
}
finished
=
false
-- print("====LEVEL", level.level, level.sublevel_id, "pausing tick loop at ", i, e.name)
break
end
end
i
=
iter
.
i
+
1
end
if
finished
then
level
.
last_iteration
=
nil
end
end
--- Called every game turns
...
...
This diff is collapsed.
Click to expand it.
game/engines/default/engine/Level.lua
+
11
−
1
View file @
71f8c033
...
...
@@ -106,6 +106,9 @@ function _M:addEntity(e, after, no_error)
end
if
pos
then
table.insert
(
self
.
e_array
,
pos
+
1
,
e
)
if
self
.
last_iteration
and
self
.
last_iteration
.
i
>=
pos
then
self
.
last_iteration
.
i
=
self
.
last_iteration
.
i
+
1
end
else
table.insert
(
self
.
e_array
,
e
)
end
...
...
@@ -125,12 +128,19 @@ function _M:removeEntity(e, force)
if
not
self
.
entities
[
e
.
uid
]
and
not
force
then
error
(
"Entity "
..
e
.
uid
..
"("
..
(
e
.
name
or
"???"
)
..
") not present on the level"
)
end
self
.
entities
[
e
.
uid
]
=
nil
local
pos
=
nil
for
i
=
1
,
#
self
.
e_array
do
if
self
.
e_array
[
i
]
==
e
then
table.remove
(
self
.
e_array
,
i
)
pos
=
i
break
end
end
if
pos
then
if
self
.
last_iteration
and
self
.
last_iteration
.
i
>=
pos
then
self
.
last_iteration
.
i
=
self
.
last_iteration
.
i
-
1
end
table.remove
(
self
.
e_array
,
pos
)
end
game
:
removeEntity
(
e
)
-- Tells it to delete itself if needed
...
...
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