Skip to content

Commit b7a5ec8

Browse files
committed
add bShallow argument for server-side water as well, fixes 9608
1 parent 0bb1ec6 commit b7a5ec8

File tree

10 files changed

+27
-12
lines changed

10 files changed

+27
-12
lines changed

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,14 +3902,18 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
39023902
vecVertices[i].fX = sX;
39033903
vecVertices[i].fY = sY;
39043904
}
3905+
3906+
bool bShallow;
3907+
bitStream.ReadBit(bShallow);
3908+
39053909
CClientWater* pWater = NULL;
39063910
if (ucNumVertices == 3)
39073911
{
3908-
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2]);
3912+
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2], bShallow);
39093913
}
39103914
else
39113915
{
3912-
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2], vecVertices[3]);
3916+
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2], vecVertices[3], bShallow);
39133917
}
39143918
if (!pWater->Exists())
39153919
{

Client/mods/deathmatch/logic/luadefs/CLuaWaterDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void CLuaWaterDefs::AddClass(lua_State* luaVM)
6363

6464
int CLuaWaterDefs::CreateWater(lua_State* luaVM)
6565
{
66-
// water createWater ( float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3 [, float x4, float y4, float z4 ] )
66+
// water createWater ( float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3 [, float x4, float y4, float z4 ] [, bool bShallow = false ] )
6767
CVector v1;
6868
CVector v2;
6969
CVector v3;

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9055,12 +9055,12 @@ bool CStaticFunctionDefinitions::SetTeamFriendlyFire(CTeam* pTeam, bool bFriendl
90559055
return false;
90569056
}
90579057

9058-
CWater* CStaticFunctionDefinitions::CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4)
9058+
CWater* CStaticFunctionDefinitions::CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4, bool bShallow)
90599059
{
90609060
if (!pV1 || !pV2 || !pV3)
90619061
return NULL;
90629062

9063-
CWater* pWater = m_pWaterManager->Create(pV4 ? CWater::QUAD : CWater::TRIANGLE, pResource->GetDynamicElementRoot());
9063+
CWater* pWater = m_pWaterManager->Create(pV4 ? CWater::QUAD : CWater::TRIANGLE, pResource->GetDynamicElementRoot(), NULL, bShallow);
90649064

90659065
if (pWater)
90669066
{

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class CStaticFunctionDefinitions
521521
static bool SetTeamFriendlyFire(CTeam* pTeam, bool bFriendlyFire);
522522

523523
// Water funcs
524-
static CWater* CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4);
524+
static CWater* CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4, bool bShallow);
525525
static bool SetElementWaterLevel(CWater* pWater, float fLevel);
526526
static bool SetAllElementWaterLevel(float fLevel);
527527
static bool SetWorldWaterLevel(float fLevel, bool bIncludeWorldNonSeaLevel);

Server/mods/deathmatch/logic/CWater.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "StdInc.h"
1313

14-
CWater::CWater(CWaterManager* pWaterManager, CElement* pParent, CXMLNode* pNode, EWaterType waterType) : CElement(pParent, pNode)
14+
CWater::CWater(CWaterManager* pWaterManager, CElement* pParent, CXMLNode* pNode, EWaterType waterType, bool bShallow) : CElement(pParent, pNode)
1515
{
1616
m_pWaterManager = pWaterManager;
1717

@@ -25,6 +25,8 @@ CWater::CWater(CWaterManager* pWaterManager, CElement* pParent, CXMLNode* pNode,
2525
if (m_WaterType == QUAD)
2626
m_Vertices[3] = CVector(10.0f, 10.0f, 0.0f);
2727

28+
m_bShallow = bShallow;
29+
2830
if (m_pWaterManager)
2931
m_pWaterManager->AddToList(this);
3032
}
@@ -129,6 +131,9 @@ bool CWater::ReadSpecialData()
129131
}
130132
}
131133

134+
if (!GetCustomDataBool("shallow", m_bShallow, true))
135+
m_bShallow = false;
136+
132137
RoundVertices();
133138
if (!Valid())
134139
{

Server/mods/deathmatch/logic/CWater.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CWater : public CElement
2222
QUAD
2323
};
2424

25-
CWater(CWaterManager* pWaterManager, CElement* pParent, CXMLNode* pNode = NULL, EWaterType waterType = QUAD);
25+
CWater(CWaterManager* pWaterManager, CElement* pParent, CXMLNode* pNode = NULL, EWaterType waterType = QUAD, bool bShallow = false);
2626
~CWater();
2727

2828
bool IsEntity() { return true; }
@@ -35,6 +35,7 @@ class CWater : public CElement
3535
void Unlink();
3636
bool ReadSpecialData();
3737

38+
bool IsWaterShallow() const { return m_bShallow; }
3839
EWaterType GetWaterType() const { return m_WaterType; }
3940
int GetNumVertices() const { return m_WaterType == TRIANGLE ? 3 : 4; }
4041
bool GetVertex(int index, CVector& vecPosition) const;
@@ -51,4 +52,5 @@ class CWater : public CElement
5152

5253
SFixedArray<CVector, 4> m_Vertices;
5354
EWaterType m_WaterType;
55+
bool m_bShallow;
5456
};

Server/mods/deathmatch/logic/CWaterManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ CWaterManager::~CWaterManager()
2424
DeleteAll();
2525
}
2626

27-
CWater* CWaterManager::Create(CWater::EWaterType waterType, CElement* pParent, CXMLNode* pNode)
27+
CWater* CWaterManager::Create(CWater::EWaterType waterType, CElement* pParent, CXMLNode* pNode, bool bShallow)
2828
{
29-
CWater* pWater = new CWater(this, pParent, pNode, waterType);
29+
CWater* pWater = new CWater(this, pParent, pNode, waterType, bShallow);
3030
if (pWater->GetID() == INVALID_ELEMENT_ID)
3131
{
3232
delete pWater;

Server/mods/deathmatch/logic/CWaterManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CWaterManager
2121
CWaterManager();
2222
~CWaterManager();
2323

24-
CWater* Create(CWater::EWaterType waterType, CElement* pParent, CXMLNode* Node = NULL);
24+
CWater* Create(CWater::EWaterType waterType, CElement* pParent, CXMLNode* Node = NULL, bool bShallow = false);
2525
CWater* CreateFromXML(CElement* pParent, CXMLNode& Node, CEvents* pEvents);
2626
void DeleteAll();
2727

Server/mods/deathmatch/logic/luadefs/CLuaWaterDefs.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int CLuaWaterDefs::CreateWater(lua_State* luaVM)
5656

5757
CVector v1, v2, v3, v4;
5858
CVector* pv4 = NULL;
59+
bool bShallow;
5960
CScriptArgReader argStream(luaVM);
6061
argStream.ReadVector3D(v1);
6162
argStream.ReadVector3D(v2);
@@ -67,9 +68,11 @@ int CLuaWaterDefs::CreateWater(lua_State* luaVM)
6768
pv4 = &v4;
6869
}
6970

71+
argStream.ReadBool(bShallow, false);
72+
7073
if (!argStream.HasErrors())
7174
{
72-
CWater* pWater = CStaticFunctionDefinitions::CreateWater(pLuaMain->GetResource(), &v1, &v2, &v3, pv4);
75+
CWater* pWater = CStaticFunctionDefinitions::CreateWater(pLuaMain->GetResource(), &v1, &v2, &v3, pv4, bShallow);
7376
if (pWater)
7477
{
7578
CElementGroup* pGroup = pLuaMain->GetResource()->GetElementGroup();

Server/mods/deathmatch/logic/packets/CEntityAddPacket.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ bool CEntityAddPacket::Write(NetBitStreamInterface& BitStream) const
10501050
BitStream.Write((short)vecVertex.fY);
10511051
BitStream.Write(vecVertex.fZ);
10521052
}
1053+
BitStream.WriteBit(pWater->IsWaterShallow());
10531054
break;
10541055
}
10551056

0 commit comments

Comments
 (0)