mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Fix out of range enum casts in deSerialize functions (#14090)
This commit is contained in:
parent
0383c44f0d
commit
2ea8d9ca11
15 changed files with 138 additions and 77 deletions
|
@ -41,16 +41,23 @@ void TileAnimationParams::serialize(std::ostream &os, u16 protocol_ver) const
|
|||
|
||||
void TileAnimationParams::deSerialize(std::istream &is, u16 protocol_ver)
|
||||
{
|
||||
type = (TileAnimationType) readU8(is);
|
||||
|
||||
if (type == TAT_VERTICAL_FRAMES) {
|
||||
vertical_frames.aspect_w = readU16(is);
|
||||
vertical_frames.aspect_h = readU16(is);
|
||||
vertical_frames.length = readF32(is);
|
||||
} else if (type == TAT_SHEET_2D) {
|
||||
sheet_2d.frames_w = readU8(is);
|
||||
sheet_2d.frames_h = readU8(is);
|
||||
sheet_2d.frame_length = readF32(is);
|
||||
type = static_cast<TileAnimationType>(readU8(is));
|
||||
switch(type) {
|
||||
case TAT_NONE:
|
||||
break;
|
||||
case TAT_VERTICAL_FRAMES:
|
||||
vertical_frames.aspect_w = readU16(is);
|
||||
vertical_frames.aspect_h = readU16(is);
|
||||
vertical_frames.length = readF32(is);
|
||||
break;
|
||||
case TAT_SHEET_2D:
|
||||
sheet_2d.frames_w = readU8(is);
|
||||
sheet_2d.frames_h = readU8(is);
|
||||
sheet_2d.frame_length = readF32(is);
|
||||
break;
|
||||
default:
|
||||
type = TAT_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue