Remove a use of inline_tweak and use TallPacking instead of GridLtrPacking in common_net::msg::server.

This commit is contained in:
Avi Weinstock 2021-04-24 21:49:22 -04:00
parent ceeeef79d3
commit ab1ed3aaa6

View File

@ -1,6 +1,6 @@
use super::{ use super::{
world_msg::EconomyInfo, ClientType, CompressedData, EcsCompPacket, GridLtrPacking, world_msg::EconomyInfo, ClientType, CompressedData, EcsCompPacket, MixedEncoding, PingMsg,
MixedEncoding, PingMsg, QuadPngEncoding, TallPacking, TriPngEncoding, WireChonk, QuadPngEncoding, TallPacking, TriPngEncoding, WireChonk,
}; };
use crate::sync; use crate::sync;
use common::{ use common::{
@ -70,13 +70,13 @@ pub type ServerRegisterAnswer = Result<(), RegisterError>;
pub enum SerializedTerrainChunk { pub enum SerializedTerrainChunk {
DeflatedChonk(CompressedData<TerrainChunk>), DeflatedChonk(CompressedData<TerrainChunk>),
PngPngPngJpeg(WireChonk<MixedEncoding, TallPacking, TerrainChunkMeta, TerrainChunkSize>), PngPngPngJpeg(WireChonk<MixedEncoding, TallPacking, TerrainChunkMeta, TerrainChunkSize>),
QuadPng(WireChonk<QuadPngEncoding<4>, GridLtrPacking, TerrainChunkMeta, TerrainChunkSize>), QuadPng(WireChonk<QuadPngEncoding<4>, TallPacking, TerrainChunkMeta, TerrainChunkSize>),
TriPng(WireChonk<TriPngEncoding, TallPacking, TerrainChunkMeta, TerrainChunkSize>), TriPng(WireChonk<TriPngEncoding, TallPacking, TerrainChunkMeta, TerrainChunkSize>),
} }
impl SerializedTerrainChunk { impl SerializedTerrainChunk {
pub fn image(chunk: &TerrainChunk) -> Self { pub fn image(chunk: &TerrainChunk) -> Self {
match inline_tweak::tweak!(2) { match 2 {
0 => Self::deflate(chunk), 0 => Self::deflate(chunk),
1 => Self::jpeg(chunk), 1 => Self::jpeg(chunk),
2 => Self::quadpng(chunk), 2 => Self::quadpng(chunk),
@ -99,7 +99,9 @@ impl SerializedTerrainChunk {
} }
pub fn quadpng(chunk: &TerrainChunk) -> Self { pub fn quadpng(chunk: &TerrainChunk) -> Self {
if let Some(wc) = WireChonk::from_chonk(QuadPngEncoding(), GridLtrPacking, chunk) { if let Some(wc) =
WireChonk::from_chonk(QuadPngEncoding(), TallPacking { flip_y: true }, chunk)
{
Self::QuadPng(wc) Self::QuadPng(wc)
} else { } else {
warn!("Image encoding failure occurred, falling back to deflate"); warn!("Image encoding failure occurred, falling back to deflate");