Comments (4)
@ManManson Would you be up to taking this? The code this centers around may be near stuff you are planning on changing/refactoring at some point.
from warzone2100.
Yes, I'll take a look.
from warzone2100.
The problem lies within the loadSaveDroid
function. The exact underlying scenario that triggers the error is as follows:
- The savegame files from Beta 8 (after
let me win
cheat and returing to base from Beta 7) are valid, i.e. there are two commanders, one of which has the associated group with ID=1 (the one which was back at the base during the offworld mission, let's call itA
). The second one, which returned from the Beta 7 (let's call itB
), doesn't have any group (that's another issue, but not really relevant at the moment). - The first one to be constructed during
loadSaveDroid
function isB
, which will first create an empty group with ID=0 for itself in thereallyBuildDroid
function. - Later on, in the same
loadSaveDroid
function, there's the code to handleaigroup
droid attribute. This code triggers the creation of another group, this time with ID=1, and assigns itself to it as a commander. The group with ID=0 gets destroyed. - Sometime later
A
will be created in theloadSaveDroid -> reallyBuildDroid
function call sequence. Again, it will create a group with ID=0, which will later be destroyed after processingaigroup
reference, which, in this particular case, is set to1
(as was defined in thedroid.json
file from the savegame). - Now, the code handling the
aigroup
attribute will issue agrpFind(1)
call. This will find an existing group with ID=1 created byB
. From now on, everything is broken. A
tries to add itself to this ID=1 group, effectively increasing itsrefCount
by an additional 1 (though, thepsCommander
still points toB
).- Sometime later the save fails to load (not sure about the exact reason, though), leading to calling the
freeAllDroids
function. A
is destroyed first, this will reset theB
's group type fromGT_COMMAND
toGT_NORMAL
, but the group is still there, because the refcount is still positive.B
gets destroyed, attempts to remove itself from its group- This triggers the code branch in
DROID_GROUP::remove
that will try to remove it from group'spsList
. Commanders aren't added to this list, sostd::find
returns anend()
iterator. And we try to callpsList.erase(psList.end())
, which is forbidden and wreaks havok by corruptingpsList:s
memory. DROID_GROUP::~DROID_GROUP
tries to call dtor forpsList
and raises SIGSEGV.
The code that allocates and assigns the groups to droids and commanders should be fixed to eliminate such behavior. I'll try to fix that.
from warzone2100.
The main issue is that the commander from the offworld mission loses its group (e.g. the associated DROID_GROUP
is destroyed and psDroid->psGroup
is set to nullptr
in droidRemove()
function) upon transitioning from Beta 7 to Beta 8 as described in the issue repro.
The issue can be worked around either by preserving an empty group for the commander in such case, so that its psGroup
is still set, or by modifying the loadSaveDroid()
behavior to check for other group IDs present in the current droid.json
file to avoid clashes between group IDs.
EDIT: the latter seems to be more preferrable, since this solution would work irrelevant of whether the group is set or not, which can also protect from some programming errors when groups are lost, like this particular case, but not limited to.
from warzone2100.
Related Issues (20)
- observers distract from the battle
- SSAO
- NERF TRANSPORTS HP OR SPEED
- Return the event "eventKeyPressed" HOT 2
- Warning when bringing sensor units into Beta/Gamma 1 from transporter menu
- gfx_api::context::get().initialize failed for backend: opengl HOT 4
- Replace all uses of `replaceTexture` with the new PIE4 texture tileset override directives
- Display scale HOT 1
- Mini map (radar) wrong colors on linux, git build HOT 2
- 4.4.2: build fails HOT 7
- Commander Specific Retreat Threshold
- Patrol Command Ignores Movement Commands.
- Propulsion Speed Comparison UI Bug
- Display Commander's Health in Commander Menu UI
- Sensor Units Cannot Target/Attack While Moving
- Rework the network code that handles the connection to the server
- Formation Speed Limiting Was Removed Due To Bugs
- Commander linking and control grouping gets screwed at start of Alpha 10 HOT 1
- Shaking object animation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from warzone2100.