Skip to content

Endianness conversion calls #361

Closed
noodlecollie opened this issue Mar 5, 2018 · 8 comments
Closed

Endianness conversion calls #361

noodlecollie opened this issue Mar 5, 2018 · 8 comments

Comments

@noodlecollie
Copy link
Contributor

Can anyone give me some background the way/reasons why endianness conversion has been implemented? I've been trying to bring a branch in my fork up to date today as it was pretty far behind, and I've noticed a lot of calls to functions/macros like LittleLong() have been added. I'm aware of what endianness is, but not why the conversions have recently (ie. within the last 6 months) been introduced.

The somewhat ad-hoc nature of the conversions is causing me a little bit of a headache, as none of my existing code uses them and I'd have to track down everywhere I think they should be used. I'm feeling like it'd be more worth my time writing in a small endianness conversion helper framework, so that we could pass it some resource file (eg. a BSP), perform little-endian conversions in-place on that data, and then the rest of the code would never have to even care about endianness again. It'd keep all of the endianness conversions in one place instead of littering them throughout all the source files, which I'm worried will end up making things more difficult to maintain.

@mittorn
Copy link
Member

mittorn commented Mar 6, 2018

Xash3D reads data from files and network. Half-Life files and Xash3D protocol is little-endian so data should be always read like little-endian even if system is big endian.
Quake already have this calls, but Unkle Mike removed big endian support in early xash3d versions.

@mittorn
Copy link
Member

mittorn commented Mar 6, 2018

Most systems now is little-endian, so this macro does nothing. I have tested big-endian support on qemu and mips router.

@noodlecollie
Copy link
Contributor Author

Do you think writing a little-endian preprocessing step for BSPs would be worth doing? I'll probably need to do it for my own branch anyway to simplify how I'm processing the map data, so it wouldn't be much extra work to just contribute it to the engine in the first place.

@noodlecollie
Copy link
Contributor Author

I've done something of an implementation, which cleans up the model loading code a little (though not as much as I'd ideally hoped). I decided not to go full-on and convert the entire file in the conversion module because I wanted to avoid the module needing to know about validating data within the file (eg. lump lengths).

If you think it'd be useful for the engine I'll create a pull request, otherwise I'll leave it in my own fork.

@a1batross
Copy link
Member

Your just loader seems to be just more readable. :)

Xash3D 1.0 will have a polymorphic loader, which is alot easier than any other, as it more generic for a wide range of different BSP formats. You just define a lump info table and pass it to generic loader. I think, 0.19.x branch will not get it. As Xash3D 1.0 releases, we will most likely reboot our fork.

@noodlecollie
Copy link
Contributor Author

Is there any more info about what's planned for 1.0? If it means major changes, I'll just hold off with my own stuff until 1.0 comes along and deal with everything then.

@a1batross
Copy link
Member

a1batross commented Mar 10, 2018 via email

@noodlecollie
Copy link
Contributor Author

That's useful, thanks. It's probably gonna be best for me to hold off for now and I'll see how things develop.

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

No branches or pull requests

3 participants