Phobos-developers / Phobos

Ares-compatible C&C Red Alert 2: Yuri's Revenge engine extension
GNU Lesser General Public License v3.0
300 stars 95 forks source link

Rewrite frame CRC generation #1369

Open Starkku opened 2 months ago

Starkku commented 2 months ago

Reimplements game's frame CRC generation function, only change logic-wise is that it now excludes AnimClass and ParticleClass objects that are purely visual.

github-actions[bot] commented 2 months ago

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

FS-21 commented 2 months ago

What kind of tests should be done here if you want feedback?

Starkku commented 2 months ago

The wrapper may be good idea in theory but that implementation mostly just obfuscates what gets hashed and for what type of object (it also changes the functionality from how game does it slightly, although likely to little to no tangible effect). The benefits would be more obvious if there was a realistic chance for new properties that need hashing to be added for, say, TechnoClass and derivatives in the future but as it stands this is very unlikely. If you can think of a way to do it without extra overhead or the obfuscating nature while reducing repeated code be my guest, but the previous implementation was not it so I've elected to revert it. I do hold a local copy of it for now still just in case though.

I'm not even going to repeat the point about the rules hash check in Phobos anymore, should be obvious by now that it does not belong here.

I did do some cleanup to the first iteration too.

chaserli commented 2 months ago

If you can think of a way to do it without extra overhead or the obfuscating nature while reducing repeated code be my guest

It only wrapped a DWORD and serves for hash the object on creation and do the hash combine operation. I bet it makes less overhead than your current method. It also allows you to know the "sum" at compile time. But anyway these are small things and make literally no difference.