Skip to content

Commit 1321b53

Browse files
authored
Merge pull request #240 from patrikjuvonen/issue-9608
0009608: add bShallow argument for server-side water as well
2 parents f9919a3 + 4d6cf82 commit 1321b53

File tree

12 files changed

+31
-14
lines changed

12 files changed

+31
-14
lines changed

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,14 +3902,19 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
39023902
vecVertices[i].fX = sX;
39033903
vecVertices[i].fY = sY;
39043904
}
3905+
3906+
bool bShallow = false;
3907+
if (bitStream.Version() >= 0x06C)
3908+
bitStream.ReadBit(bShallow);
3909+
39053910
CClientWater* pWater = NULL;
39063911
if (ucNumVertices == 3)
39073912
{
3908-
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2]);
3913+
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2], bShallow);
39093914
}
39103915
else
39113916
{
3912-
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2], vecVertices[3]);
3917+
pWater = new CClientWater(g_pClientGame->GetManager(), EntityID, vecVertices[0], vecVertices[1], vecVertices[2], vecVertices[3], bShallow);
39133918
}
39143919
if (!pWater->Exists())
39153920
{

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;

Client/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
7575
#define _CLIENT_NET_MODULE_VERSION 0x0A8 // (0x000 - 0xfff) Lvl9 wizards only
7676
#define _NETCODE_VERSION 0x1DA // (0x000 - 0xfff) Increment when net messages change (pre-release)
77-
#define MTA_DM_BITSTREAM_VERSION 0x06B // (0x000 - 0xfff) Increment when net messages change (post-release). (Changing will also require additional backward compatibility code).
77+
#define MTA_DM_BITSTREAM_VERSION 0x06C // (0x000 - 0xfff) Increment when net messages change (post-release). (Changing will also require additional backward compatibility code).
7878

7979
// To avoid user confusion, make sure the ASE version matches only if communication is possible
8080
#if defined(MTA_DM_CONNECT_TO_PUBLIC)

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9093,12 +9093,12 @@ bool CStaticFunctionDefinitions::SetTeamFriendlyFire(CTeam* pTeam, bool bFriendl
90939093
return false;
90949094
}
90959095

9096-
CWater* CStaticFunctionDefinitions::CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4)
9096+
CWater* CStaticFunctionDefinitions::CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4, bool bShallow)
90979097
{
90989098
if (!pV1 || !pV2 || !pV3)
90999099
return NULL;
91009100

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

91039103
if (pWater)
91049104
{

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h

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

524524
// Water funcs
525-
static CWater* CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4);
525+
static CWater* CreateWater(CResource* pResource, CVector* pV1, CVector* pV2, CVector* pV3, CVector* pV4, bool bShallow);
526526
static bool SetElementWaterLevel(CWater* pWater, float fLevel);
527527
static bool SetAllElementWaterLevel(float fLevel);
528528
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();

0 commit comments

Comments
 (0)