Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup more the entities once they get destructed #39

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

necessarily-equal
Copy link
Contributor

@necessarily-equal
Copy link
Contributor Author

necessarily-equal commented Sep 30, 2022

I tried to use the arrays EmptyEntity::componentOffsets and EmptyEntity::messageHandlers instead, but they are apprently private. This PR is an alternative solution.

/home/afontain/unv/Unvanquished/src/sgame/backend/CBSEBackend.cpp: In destructor ‘virtual Entity::~Entity()’:
/home/afontain/unv/Unvanquished/src/sgame/backend/CBSEBackend.cpp:24:41: error: ‘const int EmptyEntity::componentOffsets []’ is private within this context
   24 |         componentOffsets = EmptyEntity::componentOffsets;
      |                                         ^~~~~~~~~~~~~~~~
In file included from /home/afontain/unv/Unvanquished/src/sgame/backend/CBSEBackend.cpp:9:
/home/afontain/unv/Unvanquished/src/sgame/backend/CBSEEntities.h:37:34: note: declared private here
   37 |                 static const int componentOffsets[];
      |                                  ^~~~~~~~~~~~~~~~
/home/afontain/unv/Unvanquished/src/sgame/backend/CBSEBackend.cpp:25:40: error: ‘void (* const EmptyEntity::messageHandlers [])(Entity*, const void*)’ is private within this context
   25 |         messageHandlers = EmptyEntity::messageHandlers;
      |                                        ^~~~~~~~~~~~~~~
In file included from /home/afontain/unv/Unvanquished/src/sgame/backend/CBSEBackend.cpp:9:
/home/afontain/unv/Unvanquished/src/sgame/backend/CBSEEntities.h:34:45: note: declared private here
   34 |                 static const MessageHandler messageHandlers[];
      |                                             ^~~~~~~~~~~~~~~
[54/55] Building CXX object CMakeFiles/s...c/sgame/components/TurretComponent.cpp.o
ninja: build stopped: subcommand failed.
ninja -C build-nixos  236.92s user 13.48s system 373% cpu 1:07.06 total

@DolceTriade
Copy link
Contributor

Can you explain the bug in detail so we can learn?

@slipher
Copy link
Member

slipher commented Sep 30, 2022

Is your hypothesis that one of the components of the entity being destroyed tries to access one of the entity's other components from its destructor? If that's the case, the fix won't help as ~Entity() only runs after all of the component destructors run.

@slipher
Copy link
Member

slipher commented Sep 30, 2022

Is your hypothesis that one of the components of the entity being destroyed tries to access one of the entity's other components from its destructor?

Well that's not it - the only two components with user-defined destructors are TurretComponent and SpawnerComponent. (The latter does have something of a bug of the type I described though - Unvanquished#2233)

@necessarily-equal
Copy link
Contributor Author

Marking as draft before I find time to test more (probably not soon)

@necessarily-equal necessarily-equal marked this pull request as draft October 4, 2022 16:23
@illwieckz
Copy link
Member

It looks like this submodule reference had been mistakenly committed.

I noticed it because a sync submodules commit reverted it:

@illwieckz
Copy link
Member

It looks to have been committed in Unvanquished/Unvanquished@4fb94c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sgame crash after game decided
4 participants