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

Using multiple DamageInfos/EffectDatas will clear the previous one, even if still in use #2771

Open
Kefta opened this issue Aug 13, 2016 · 10 comments

Comments

@Kefta
Copy link
Contributor

Kefta commented Aug 13, 2016

> local info = DamageInfo() info:SetAttacker( Entity(1) ) print( info:GetAttacker() ) local info2 = DamageInfo() print( info:GetAttacker() )...
Player [1][code_gs]
[NULL Entity]

"Why would you ever need more than one?"

https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/shared/gamerules.cpp#L491-L533

@robotboy655
Copy link
Contributor

It is by design.

@Kefta
Copy link
Contributor Author

Kefta commented Aug 13, 2016

So how do I manage multiple DamageInfos? Store all the values before and restore them?

@bigdogmat
Copy link

Is this still a possibility, #860 (comment)?

@ZehMatt
Copy link

ZehMatt commented Aug 15, 2016

If this is by design it should be changed to not use the same pointer over and over on the global function, use a memory pool if you are worried about allocation performance.

@FPtje
Copy link

FPtje commented Aug 15, 2016

An important question here is whose design? GMod's or Source's?

@robotboy655
Copy link
Contributor

Garry's

@ZehMatt
Copy link

ZehMatt commented Aug 15, 2016

Just use a circular buffer with a fixed size of 100 or something, this can't be a issue tbh.

@FPtje
Copy link

FPtje commented Aug 15, 2016

Then surely the developers of GMod should be able to justify this design decision?

@Kefta
Copy link
Contributor Author

Kefta commented Jan 9, 2024

Just so it's not forgotten

I'm not sure how addons would break from that change unless they're doing very weird things with the single instance, but if that's the case, then how about a bool argument to EffectData() and DamageInfo() to create a new instance? false = use the singleton (default), true = new object that is not invalidated across ticks.

@brannanz
Copy link

garry made some extremely questionable desicions during the development of gmod

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

No branches or pull requests

6 participants