Comments (8)
I ran this with AddressSanitizer and found something:
This might have something to do with this line. For humanoids, GetDrawDisplacement
simply returns a v2(0, 0)
, but for kamikaze dwarves it has been overridden to return something more interesting, e.g. v2(0, -1)
, which actually causes an out-of-bounds access here (maybe elsewhere too) because B.Dest.Y
is -1
.
There's some kind of validation block earlier in AlphaPriorityBlit
which is run if FastFlag
is not set. If I make it unconditional then femath::Clip
fixes the invalid B.Dest.Y
value and the crash seems to go away. But that block clearly shouldn't be unconditional so maybe FastFlag
just needs to be unset when drawing kamikaze dwarf bodyparts?
from ivan.
I could reproduce this error, but it took maybe >10 dwarfs. I wonder why GetDrawDisplacement is necessary at all? I suppose it is there to make dwarfs look like shorties, because the GetDrawDisplacement array for dwarfs looks like body part indicies, and dwarf's legs don't touch the bottom of their bounding box.
Dwarf bodyparts don't need this property when they are detached from the torso... Does the crash happen when a dwarf explodes?
from ivan.
Actually, try to use the 'go' command so that the explosion happens while you're 'go'ing. That way it seems to happen about 50% of the time.
And yes the crash seems to happen only when they explode. But my guess is that the undefined behavior starts earlier (here as reported by AddressSanitizer), and for some reason only triggers the crash when drawing the flying bodyparts.
from ivan.
I am becoming suspicious of burning bodyparts. Does the problem go away if in material.dat we set DWARF_FLESH
interaction flags to: InteractionFlags = Base;
instead of: InteractionFlags = Base|CAN_BURN;
?
This would prevent them from burning and therefore trying to animate flames.
from ivan.
Hmm, removing CAN_BURN
still doesn't prevent the out-of-bounds access at line 1812. Maybe if we fix that then the crash will go away as well.
from ivan.
It seems that femath::Clip
should be called on the blitdata whenever it would otherwise draw outside the actual bitmap. This seems to be the case whenever GetDrawDisplacement
returns something else than v2(0, 0)
.
One way to make the problem go away would be to check BlitData.Dest
in bodypart::Draw
and if it's non-zero then deactivate FastFlag before calling the blit function, so that inside the blit function femath::Clip
is called. F.ex. something like this:
if(BlitData.Dest.X < 0 || BlitData.Dest.Y < 0)
P->DeactivateFastFlag();
P->AlphaPriorityBlit(BlitData);
P->ActivateFastFlag();
But this is probably not how (De)activateFastFlag
should be used, and also if FastFlag was already deactivated before that operation then we wouldn't want activate it in the end. But there's no GetFastFlagState
or similar so again, it shouldn't probably be used that way.
Any better ideas?
from ivan.
Sorry for the hiatus on this, I went away for the weekend and forgot to get back to it.
What if we work higher up in the chain and make it conditional on a kamikaze dwarf that he has to be in one piece to have these displacements. So that dismembered bodyparts always return ZERO_V2
.
Trouble is at present GetDrawDisplacement()
seems to work at the character level and not bodypart level.
I don't really understand the way this array corresponds to the drawn bodyparts. If I summon a kamikaze dwarf in cheat mode New Attnam, I can see his right arm (on the left) is moved up slightly, and both legs don't touch the bottom of the bounding box, and it looks like his groin is transparent because I can see grass on the other side. Either that or he's wearing a grass skirt.
I suggest we turf the special parts of the code that mangle the kamikaze dwarf bitmaps and just edit the humanoid.pcx to get the same result. I looked through char.dat and the leg and arm bodyparts are all unique to the dwarf. Check out #66.
from ivan.
NP! Yeah I have noticed that transparent groin too, it's probably a bug.
from ivan.
Related Issues (20)
- Crash on continue HOT 1
- Bone files from Aslona appearing in GC HOT 1
- The message "You feel the cold breeze of death" doesn't appear HOT 1
- Wishing for wand of polymorph doesn't work
- Compiling in Ubuntu 20.04 with an SDL2 error HOT 2
- Make linux binaries HOT 1
- Infinite recursion with dummy sound system HOT 2
- Werewolf diet
- Add alternate graphics to main menu
- Flaming material spills
- Floodfill on Pangea HOT 1
- Vomiting during Sumo Wrestling HOT 1
- Building on postmarketOS (Alpine) on aarch64 hardware HOT 21
- GitHub Action for OSX HOT 3
- Multiple problems related to sound support HOT 1
- String question crash HOT 5
- XBRz multithread? HOT 1
- Crash after attacking with a weapon coated with raw liquefied magic
- Dismantling provides more material than what you started with HOT 1
- v0.59 Crash on start MacOS Big Sur 11.3.1 HOT 4
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 ivan.