« first day (3002 days earlier)      last day (2003 days later) » 

user92578
1:56 PM
All right, service day is over, time for some smart pointers
 
user92578
2:30 PM
Having to restructure quite a bit of code since previously I've just been allocating child entities before spawning the entity into the level, but now I can't really do that since the level must take ownership of any entity I allocate
 
user92578
So I end up having to save up a bunch of state that's required to initialize the child objects properly
 
user92578
I'm trying to avoid storing any std::unique_ptrs "temporarily" in the entity classes
 
@Tyyppi_77 your daily medicine it seems :P
 
user92578
it's very true, this stuff makes me excited while everything else here does not
 
nwp
2:39 PM
Be careful that you don't become an engine developer and lose interest in making games :P
 
be very careful :D
 
user92578
I balance myself between those two positions
 
user92578
When I feel like doing massive refactorings of the codebase, I do those
 
user92578
And when I feel like implementing a new gameplay mode, I make one
 
nwp
Since you actually want to get a game done you should arguably just use entityx or similar.
 
user92578
2:43 PM
Probably, but that just seems like a much larger refactor since I do not currently use ECS
 
user92578
Also don't really feel like redoing the whole entity/level code in the game
 
user92578
Also I don't necessarily currently need to get anything done
 
user92578
I have a patch that I need to test and release that uses a stable branch, this is stuff that I do while I procrastinate pushing the update live
 
user92578
My biggest annoyance currently is the fact that std::make_unique doesn't provide IntelliSense help for the constructor parameters
 
user4704
3:20 PM
it also interferes with friending
 
user4704
and compiler errors when you screw up the parameters are poor
 
user92578
Yeah I already ran into the friend thing, sort of, with a singleton that had a private constructor
 
user92578
Well sort of into the friend thing
 
user4704
In general, compiler support around handling the "real" point of failure in forwarding functions via parameter packs could use some love, but it's a tough problem
 
user92578
Since ContentLoader::Create couldn't make_unique<ContentLoader> when the content loader has a private constructor
 
user4704
3:21 PM
Yep.
 
user92578
I think I ended up using the trick where I inherit ContentLoader into a struct and make the constructor public with using inside Create
 
user4704
I just don't use make_unique in those cases, but that works too.
 
user92578
What do you use instead? std::unique_ptr(new ...)?
 
user4704
Yeah
 
user4704
Unlike make_shared, make_unique doesn't afford any optimizations.
 
user4704
3:24 PM
It prevents (until recently) certain classes of bugs due to parameter evaluation order, but I generally don't end up needing it to protect me against that, so I just call new.
 
user92578
I'm sort of dreaming that once I'm done, I'll have a codebase with zero news, hence the struct trick
 
user92578
Dunno if that's really something to strive for, probably a better goal would be a codebase with zero deletes
 
user4704
I guess, I think once you know why you "shouldn't use new ever" you can be free to ignore it.
 
user4704
It's like of like "100% code coverage" in tests: okay, sure, doable, but at what cost and was that cost really worth it?
 
user92578
yeah
 
4:06 PM
Hey! I finally got an idea for a 2D mobile game!
I can't believe it, it's the first time I've come up with something good :D
 
user92578
4:20 PM
Down to 112 errors
 
user92578
These all come from <memory> though, and all are about deleting an incomplete type "CEntity"
 
user92578
No idea what's going on
 
4:39 PM
@Tyyppi_77 it's always an improvement :)
 
user92578
4:58 PM
Yeah so the <memory> errors happen inside a file that doesn't even use CEntity, wtf is going on?
 
user4704
Is the offending code on GitHub someplace?
 
user92578
It's on BitBucket where I could give you access to the project but I don't think you want to try building GunHero
 
user4704
Not a one-click build process? :D
 
user92578
Most likely not, that has not been my priority since it's just me working on it, some stuff (like the Steamworks API headers) aren't at all in the repo and then there's some build-step Python stuff happening and so on
 
user92578
std::vector<std::unique_ptr<CEntityBullet>> CEntityWeaponGunBehaviourCharge::CreateBullets(CLevel* level) const
{
	std::unique_ptr<CEntityBullet> bullet = m_BulletFactory->Create(level, m_Gun);
	static_cast<CEntityBulletPlasma*>(bullet.get())->SetSubdivisionCount(CalculateSubdivisionCount());
	return { std::move(bullet )};
}
 
user92578
5:07 PM
So for an example this errors on the line with the opening curly brace?
 
user4704
With the error about "using undefined type CEntityBullet"?
 
user92578
No that's about attempting to reference a delete function
 
user92578
The undefined type stuff either doesn't give out a line, or just references a forward-declaration of CEntity in Level.h
 
user4704
A deleted function of CEntityBullet? Is there a cascade of other errors after the first talking about candidate functions?
 
user92578
5:11 PM
A deleted function of std::unique_ptr it seems
 
user92578
But why? And why on the brace?
 
user92578
Wait whoops wrong error
 
user92578
That one corresponds to the code I showed, line 60 is the method name, 61 is the curly brace
 
user4704
The beginning of that boils down to: unique_ptr<S>::unique_ptr(const unique_ptr<S>&) is explicitly deleted, I believe.
 
user4704
5:15 PM
Which makes sense (that's the copy ct)
 
user4704
Is CEntityBullet movable?
 
user92578
I have no idea, so I'm guessing no?
 
user92578
Is this some sort of "cant put unique_ptrs in a vector" thing?
 
user4704
No, you can put them in a vector because they can be moved.
 
user4704
And they shuoldn't disable moving if their T can't be moved because you don't need to move T to move the pointer.
 
user92578
5:17 PM
Yeah that's what I thought, it shouldn't really matter what's in the unique_ptr
 
user4704
what's Centitybuillet look like?
 
nwp
std::unique_ptr is overloaded for polymorphic types, so you can do std::unique_ptr<Derived> derived_p; std::unique_ptr<Base> base_p = std::move(derived_p);.
Which should let you get rid of the static_cast.
 
user92578
Bullet factory implements an interface that always return unique_ptr<CEntityBullet>
 
user92578
Here's CEntityBullet: pastebin.com/0xX23EWK
 
nwp
Hmm, unfortunate. I feel like that should be avoidable.
 
user4704
5:21 PM
I don't see anything in CEntityBullet that would upset unique_ptr, offhand.
 
user92578
These are the two types of errors I have left, this one, and the one about CEntity being incomplete in bunch of super random places
 
nwp
Actually I can reproduce.
 
user4704
ah
 
user92578
wow nice
 
user4704
because you can't copy a vector with a bunch of unique_ptrs in it
 
nwp
5:26 PM
Well yeah, but somehow RVO doesn't trigger despite C++17.
There should be mandatory copy elision happening.
 
user92578
I think I might still be compiling in C++14
 
user92578
So... how do I fix this? std::unique_ptr<std::vector<std::unique_ptr<CEntityBullet>>>?
 
user4704
no outer unique_ptr
 
user4704
I'd don't think it's a "not eliding" issue
 
nwp
No, that is silly.
 
user4704
5:31 PM
yep: std::vector<std::unique_ptr<CEntityBullet>> result{std::move(bullet)}; does the same thing, and you can then "return result" fine.
 
user4704
if you result; result.emplace_back(move crap here)
 
user4704
something about how the brace initialization parses is making it do something unexpected
 
nwp
I'm gonna blame initializer lists that have const members and you can't move a const unique_ptr &&.
 
user4704
yeah
 
user4704
seems viable
 
user4704
 
user92578
well that's kinda stupid
 
user92578
thank you so much once again guys
 
user4704
I vaguely recall reading something about this once, about how brace-init can interfere with constructors that take std::initializer_lists or some such
 
user4704
I never use brace-init, really, so I've never actually encountered it and I'm not clear on the details
 
user92578
I use it when it's handy, like this case
 
user4704
5:35 PM
I'm not sure hair-pulling for hours constitutes "handy" but... :P
 
user92578
Well it was handy when it was just plain pointers and it just worked (tm)
 
user4704
:D
 
user92578
I so much appreciate the help, I gotta head off so that I can take a shower before they'll count us and make sure we're all still stuck here :D
 
user4704
good luck
 
6:22 PM
@Tyyppi_77 now that's some good protection against reverse engineering :D
 
user4704
6:35 PM
@GabrieleVierti Except you wouldn't need to "reverse engineer" anything if you have the source code like that, and if you just have the executable none of that matters :P
 
7:09 PM
@Josh oh yeah, that's right :P
 

« first day (3002 days earlier)      last day (2003 days later) »