From 8f9c3837d627aa48d42cfb80fe9bc4541d148097 Mon Sep 17 00:00:00 2001 From: Galaco Date: Mon, 22 Oct 2018 20:29:38 +0100 Subject: [PATCH 1/3] Fix staticpropv10 corruption --- primitives/game/staticpropv10.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/primitives/game/staticpropv10.go b/primitives/game/staticpropv10.go index 600dcc9..479a098 100644 --- a/primitives/game/staticpropv10.go +++ b/primitives/game/staticpropv10.go @@ -23,8 +23,7 @@ type StaticPropV10 struct { MaxGPULevel uint8 DiffuseModulation float32 Unknown float32 - DisableXBox360 bool - _ [3]byte + //DisableXBox360 bool } func (l *StaticPropV10) GetOrigin() mgl32.Vec3 { @@ -112,5 +111,5 @@ func (l *StaticPropV10) GetUnknown() float32 { } func (l *StaticPropV10) GetDisableXBox360() bool { - return l.DisableXBox360 + return true } From 71c5d6ad9c48fbbeb30a6bf1a85d704a9d76d812 Mon Sep 17 00:00:00 2001 From: Galaco Date: Thu, 1 Nov 2018 16:52:04 +0000 Subject: [PATCH 2/3] Corrected staticprop v11 sizing. trailing [7]byte usage unknown --- lumps/game.go | 2 +- lumps/lumps.go | 8 ++++++ primitives/common/common.go | 8 +++--- primitives/game/game.go | 45 ------------------------------ primitives/game/staticprop.go | 47 ++++++++++++++++++++++++++++++++ primitives/game/staticpropv10.go | 2 +- primitives/game/staticpropv11.go | 6 ++-- 7 files changed, 64 insertions(+), 54 deletions(-) create mode 100644 primitives/game/staticprop.go diff --git a/lumps/game.go b/lumps/game.go index 70cd62b..43f41ce 100644 --- a/lumps/game.go +++ b/lumps/game.go @@ -210,7 +210,7 @@ func (lump *Game) GetStaticPropLump() *primitives.StaticPropLump { case 11: propLumpSize = int(unsafe.Sizeof(primitives.StaticPropV11{})) * int(numProps) vprops := make([]primitives.StaticPropV11, numProps) - err = binary.Read(bytes.NewBuffer(sprpLump.Data[offset:offset+propLumpSize]), binary.LittleEndian, &vprops) + err = binary.Read(bytes.NewBuffer(sprpLump.Data[offset:]), binary.LittleEndian, &vprops) if err != nil { return nil } diff --git a/lumps/lumps.go b/lumps/lumps.go index cab4b0f..c1cd41e 100644 --- a/lumps/lumps.go +++ b/lumps/lumps.go @@ -35,6 +35,7 @@ Helper info for a lump */ type LumpInfo struct { length int32 + version int32 } /** @@ -50,3 +51,10 @@ Set lump import length in bytes func (info LumpInfo) SetLength(length int32) { info.length = length } + +/** +Set bsp version of lump +*/ +func (info LumpInfo) SetVersion(version int32) { + info.version = version +} diff --git a/primitives/common/common.go b/primitives/common/common.go index 273f913..a27ddef 100644 --- a/primitives/common/common.go +++ b/primitives/common/common.go @@ -6,10 +6,10 @@ import ( ) type ColorRGBExponent32 struct { - R byte - G byte - B byte - Exponent byte + R uint8 + G uint8 + B uint8 + Exponent int8 } const MAX_POINTS_ON_FIXED_WINDING = 12 diff --git a/primitives/game/game.go b/primitives/game/game.go index 8316636..fdc894f 100644 --- a/primitives/game/game.go +++ b/primitives/game/game.go @@ -1,9 +1,5 @@ package game -import ( - "github.com/go-gl/mathgl/mgl32" -) - const StaticPropLumpId = 1936749168 type Header struct { @@ -29,44 +25,3 @@ type GenericGameLump struct { Length int32 Data []byte } - -type StaticPropLump struct { - DictLump StaticPropDictLump - LeafLump StaticPropLeafLump - PropLumps []IStaticPropDataLump -} - -// Note: Nothing below here is actually implemented, as its primarily game/version specific data. -type StaticPropDictLump struct { - DictEntries int32 - Name []string // Slice length must equal dictEntries. Validation to be added -} -type StaticPropLeafLump struct { - LeafEntries int32 - Leaf []uint16 // Slice length must equal leafEntries. Validation to be added -} - -type IStaticPropDataLump interface { - GetOrigin() mgl32.Vec3 - GetAngles() mgl32.Vec3 - GetUniformScale() float32 //v11 onwards - GetPropType() uint16 - GetFirstLeaf() uint16 - GetLeafCount() uint16 - GetSolid() uint8 - GetFlags() uint8 - GetSkin() int32 - GetFadeMinDist() float32 - GetFadeMaxDist() float32 - GetLightingOrigin() mgl32.Vec3 - GetForcedFadeScale() float32 - GetMinDXLevel() uint16 - GetMaxDXLevel() uint16 - GetMinCPULevel() uint8 - GetMaxCPULevel() uint8 - GetMinGPULevel() uint8 - GetMaxGPULevel() uint8 - GetDiffuseModulation() float32 //v7 onwards - GetUnknown() float32 //v10 onwards - GetDisableXBox360() bool //v9 onwards -} diff --git a/primitives/game/staticprop.go b/primitives/game/staticprop.go new file mode 100644 index 0000000..c0d5931 --- /dev/null +++ b/primitives/game/staticprop.go @@ -0,0 +1,47 @@ +package game + + +import ( + "github.com/go-gl/mathgl/mgl32" +) + +type StaticPropLump struct { + DictLump StaticPropDictLump + LeafLump StaticPropLeafLump + PropLumps []IStaticPropDataLump +} + +// Note: Nothing below here is actually implemented, as its primarily game/version specific data. +type StaticPropDictLump struct { + DictEntries int32 + Name []string // Slice length must equal dictEntries. Validation to be added +} +type StaticPropLeafLump struct { + LeafEntries int32 + Leaf []uint16 // Slice length must equal leafEntries. Validation to be added +} + +type IStaticPropDataLump interface { + GetOrigin() mgl32.Vec3 + GetAngles() mgl32.Vec3 + GetUniformScale() float32 // v11 onwards + GetPropType() uint16 + GetFirstLeaf() uint16 + GetLeafCount() uint16 + GetSolid() uint8 + GetFlags() uint8 + GetSkin() int32 + GetFadeMinDist() float32 + GetFadeMaxDist() float32 + GetLightingOrigin() mgl32.Vec3 + GetForcedFadeScale() float32 // v5 onwards + GetMinDXLevel() uint16 // v6+7 only + GetMaxDXLevel() uint16 // v6+7 only + GetMinCPULevel() uint8 + GetMaxCPULevel() uint8 + GetMinGPULevel() uint8 + GetMaxGPULevel() uint8 + GetDiffuseModulation() float32 // v7 onwards + GetUnknown() float32 // v10 onwards + GetDisableXBox360() bool // v9 onwards +} diff --git a/primitives/game/staticpropv10.go b/primitives/game/staticpropv10.go index 479a098..3c24440 100644 --- a/primitives/game/staticpropv10.go +++ b/primitives/game/staticpropv10.go @@ -107,7 +107,7 @@ func (l *StaticPropV10) GetDiffuseModulation() float32 { } func (l *StaticPropV10) GetUnknown() float32 { - return l.Unknown + return 0 } func (l *StaticPropV10) GetDisableXBox360() bool { diff --git a/primitives/game/staticpropv11.go b/primitives/game/staticpropv11.go index 004ef61..812792d 100644 --- a/primitives/game/staticpropv11.go +++ b/primitives/game/staticpropv11.go @@ -7,7 +7,6 @@ import ( type StaticPropV11 struct { Origin mgl32.Vec3 Angles mgl32.Vec3 - UniformScale float32 PropType uint16 FirstLeaf uint16 LeafCount uint16 @@ -23,8 +22,9 @@ type StaticPropV11 struct { MinGPULevel uint8 MaxGPULevel uint8 DiffuseModulation float32 - Unknown float32 DisableXBox360 bool + UniformScale float32 + _ [7]byte } func (l *StaticPropV11) GetOrigin() mgl32.Vec3 { @@ -108,7 +108,7 @@ func (l *StaticPropV11) GetDiffuseModulation() float32 { } func (l *StaticPropV11) GetUnknown() float32 { - return l.Unknown + return 0 } func (l *StaticPropV11) GetDisableXBox360() bool { From 3e574ae42c57ed838cba337252f0dcaf26e0aadb Mon Sep 17 00:00:00 2001 From: Galaco Date: Mon, 5 Nov 2018 12:57:26 +0000 Subject: [PATCH 3/3] Code formatting, updated readme --- .DS_Store | Bin 0 -> 10244 bytes README.md | 3 +++ lump_test.go | 4 ++-- lumps/lumps.go | 2 +- primitives/game/staticprop.go | 7 +++---- primitives/game/staticpropv11.go | 2 +- primitives/visibility/visibility.go | 2 +- versions/v19.go | 10 ++-------- versions/v21.go | 10 ++-------- versions/versions.go | 3 +++ 10 files changed, 18 insertions(+), 25 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f834bc8aa0be47a310512ae03715230224963225 GIT binary patch literal 10244 zcmeHM&2Jk;6n~T2&Du$uO`DGrgjm&lRBD8hG)gN$6vs&f79R<52nlU**50+V>Uzi8 zT_+?V$Q<|s5SN0~KY-qPLqg(&1e_~{6DofI5=ivI3Es@Eo!NDq14yW#8ENLdo%c2K z8_&GV1OP~`VN3#O0H9!HRPD#+gu>*kc9fp5=S8Fh?ZK{27Rt0%@6ePT5&?;TL_i`S z5s(NxDF|TBW<}`>sB9$y5&?-o8v%AcXjmD|hO`+_eso~NuK-9B*v$*_Dr1mpA}sB9$y5`j(x z*xfw=FF_S7@WuOk>N#axl-20sqS5fn07qYa_jvxq7q;nc!PotUm($&w>}y5$w@V?vMycKA_0qa!?iSUd1?u>^<(MuvwhR+hZoO+c z2HnlkhGTf#PazN}N=iu;)k_BlGgFh}+SJsw!*T84`t^x%ZTi~G;bBS{eSUH_zg64Y zKlt$Qqt9_VSV)*lU?BKzw_hM9OwlUugi|Enw5Iq-Ra=uxrThBNogYvKFI*fP8XO)T z8ND?8)Y#KwMfGAyFW;%UY`6>5rf$w|m^Z7gWfbaq*>b8IzWIS)u=dTOdLgE|Y8vk! zcdhN!QD^A5gS&gxHBE>6Tdq_*)87#I&7wNsm0fDvE7Y@mi#nUPJOn=Po3*@Cp%`%o zfnKgNk+*KT9?}k*jZNKkb*F0P_HNsH$+VZ99QA!#+px;i2}VA^-QwqpYciLax!(dH zGuhW$%$0yqArmkFnQUc?^NLE=9O{^l!_L?j@sA@$mWf z!TopQ(&NLYQyMvZ5*nI{ad!%?V^gP!y=WLah(K90(SMTyD8B~eHCPpusPz0jpanFJ1hgl zPH4;*k@Gx-7MRa?R&%@N3h@j*AF(*~q-Oab7Ht(X$2=_JCRxI0H848I7df#NJ_{E! znFSP_j`?7O)AhwQ0Z7lGeuvM<+B~>_bh3`HMqPBowF1!44WwX~uL;Y>C*n(378LPi zR