Skip to content

Commit 6915bc1

Browse files
committed
Applied source patch #8737 (PointLight Creation) by Lex128.
For testing and evaluation.
1 parent 9c9b5a0 commit 6915bc1

27 files changed

+683
-19
lines changed

MTA10/game_sa/CPointLightsSA.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* PROJECT: Multi Theft Auto v1.0
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: game_sa/CPointLightsSA.cpp
6-
* PURPOSE: Point lights class
6+
* PURPOSE: PointLights entity
77
* DEVELOPERS: Jax <>
88
*
99
* Multi Theft Auto is available from http://www.multitheftauto.com/
@@ -12,29 +12,30 @@
1212

1313
#include "StdInc.h"
1414

15-
void CPointLightsSA::AddLight ( unsigned char ucType, CVector vec_2, CVector vec_3, float fRed, float fGreen, float fBlue, float f_7, unsigned char uc_8, bool bCreatesShadow, CEntity * pEntity )
15+
void CPointLightsSA::AddLight ( int iMode, const CVector vecPosition, CVector vecDirection, float fRadius, SColor color, unsigned char uc_8, bool bCreatesShadow, CEntity * pAffected )
1616
{
1717
DWORD dwEntityInterface = 0;
18-
if ( pEntity ) dwEntityInterface = ( DWORD ) pEntity->GetInterface ();
18+
if ( pAffected ) dwEntityInterface = ( DWORD ) pAffected->GetInterface ();
1919
DWORD dwFunc = FUNC_CPointLights_AddLight;
20-
float f_3x = vec_3.fX, f_3y = vec_3.fY, f_3z = vec_3.fZ;
21-
float f_2x = vec_2.fX, f_2y = vec_2.fY, f_2z = vec_2.fZ;
20+
float fPosX = vecPosition.fX, fPosY = vecPosition.fY, fPosZ = vecPosition.fZ;
21+
float fDirX = vecDirection.fX, fDirY = vecDirection.fY, fDirZ = vecDirection.fZ;
22+
float fRed = (float)color.R / 255, fGreen = (float)color.G / 255, fBlue = (float)color.B / 255;
2223
_asm
2324
{
2425
push dwEntityInterface
2526
push bCreatesShadow
2627
push uc_8
27-
push f_7
2828
push fBlue
2929
push fGreen
3030
push fRed
31-
push f_3z
32-
push f_3y
33-
push f_3x
34-
push f_2z
35-
push f_2y
36-
push f_2x
37-
push ucType
31+
push fRadius
32+
push fDirZ
33+
push fDirY
34+
push fDirX
35+
push fPosZ
36+
push fPosY
37+
push fPosX
38+
push iMode
3839
call dwFunc
3940
add esp, 56
4041
}

MTA10/game_sa/CPointLightsSA.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* PROJECT: Multi Theft Auto v1.0
44
* LICENSE: See LICENSE in the top level directory
55
* FILE: game_sa/CPointLightsSA.h
6-
* PURPOSE: Point lights class header
6+
* PURPOSE: Header file for PointLights entity class
77
* DEVELOPERS: Jax <>
88
*
99
* Multi Theft Auto is available from http://www.multitheftauto.com/
1010
*
1111
*****************************************************************************/
1212

13-
#ifndef __CPointLightsSA_H
14-
#define __CPointLightsSA_H
13+
#ifndef __CGAMESA_POINTLIGHTS
14+
#define __CGAMESA_POINTLIGHTS
1515

1616
#include <game/CPointLights.h>
1717

@@ -20,7 +20,7 @@
2020
class CPointLightsSA : public CPointLights
2121
{
2222
public:
23-
void AddLight ( unsigned char ucType, CVector vec_2, CVector vec_3, float fRed, float fGreen, float fBlue, float f_7, unsigned char uc_8, bool bCreatesShadow, CEntity * pEntity );
23+
void AddLight ( int iMode, const CVector vecPosition, CVector vecDirection, float fRadius, SColor color, unsigned char uc_8, bool bCreatesShadow, CEntity * pAffected );
2424
};
2525

2626
#endif

MTA10/mods/deathmatch/StdInc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include <CClientPed.h>
7474
#include <CClientPlayerClothes.h>
7575
#include <CClientPlayerVoice.h>
76+
#include <CClientPointLights.h>
7677
#include <CClientProjectileManager.h>
7778
#include <CClientStreamSector.h>
7879
#include <CClientStreamSectorRow.h>

MTA10/mods/deathmatch/_Deathmatch 2008.vcproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,14 @@
864864
RelativePath="..\shared_logic\CClientPlayerVoice.cpp"
865865
>
866866
</File>
867+
<File
868+
RelativePath="..\shared_logic\CClientPointLights.cpp"
869+
>
870+
</File>
871+
<File
872+
RelativePath="..\shared_logic\CClientPointLightsManager.cpp"
873+
>
874+
</File>
867875
<File
868876
RelativePath="..\shared_logic\CClientProjectile.cpp"
869877
>
@@ -1151,6 +1159,10 @@
11511159
RelativePath="..\shared_logic\lua\CLuaFunctionDefs.Player.cpp"
11521160
>
11531161
</File>
1162+
<File
1163+
RelativePath="..\shared_logic\lua\CLuaFunctionDefs.PointLights.cpp"
1164+
>
1165+
</File>
11541166
<File
11551167
RelativePath="..\shared_logic\lua\CLuaFunctionDefs.Projectile.cpp"
11561168
>
@@ -3366,6 +3378,14 @@
33663378
RelativePath="..\shared_logic\CClientPlayerVoice.h"
33673379
>
33683380
</File>
3381+
<File
3382+
RelativePath="..\shared_logic\CClientPointLights.h"
3383+
>
3384+
</File>
3385+
<File
3386+
RelativePath="..\shared_logic\CClientPointLightsManager.h"
3387+
>
3388+
</File>
33693389
<File
33703390
RelativePath="..\shared_logic\CClientProjectile.h"
33713391
>

MTA10/mods/deathmatch/_Deathmatch 2008.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,12 @@
359359
</ClCompile>
360360
<ClCompile Include="..\shared_logic\CClientEffect.cpp" />
361361
<ClCompile Include="..\shared_logic\CClientEffectManager.cpp" />
362+
<ClCompile Include="..\shared_logic\CClientPointLights.cpp" />
363+
<ClCompile Include="..\shared_logic\CClientPointLightsManager.cpp" />
362364
<ClCompile Include="..\shared_logic\luadefs\CLuaVector2Defs.cpp" />
363365
<ClCompile Include="..\shared_logic\luadefs\CLuaVector3Defs.cpp" />
364366
<ClCompile Include="..\shared_logic\luadefs\CLuaVector4Defs.cpp" />
367+
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.PointLights.cpp" />
365368
<ClCompile Include="..\shared_logic\lua\CLuaVector2.cpp" />
366369
<ClCompile Include="..\shared_logic\lua\CLuaVector3.cpp" />
367370
<ClCompile Include="..\shared_logic\lua\CLuaVector4.cpp" />
@@ -748,6 +751,8 @@
748751
<ItemGroup>
749752
<ClInclude Include="..\shared_logic\CClientEffect.h" />
750753
<ClInclude Include="..\shared_logic\CClientEffectManager.h" />
754+
<ClInclude Include="..\shared_logic\CClientPointLights.h" />
755+
<ClInclude Include="..\shared_logic\CClientPointLightsManager.h" />
751756
<ClInclude Include="..\shared_logic\luadefs\CLuaVector2Defs.h" />
752757
<ClInclude Include="..\shared_logic\luadefs\CLuaVector3Defs.h" />
753758
<ClInclude Include="..\shared_logic\luadefs\CLuaVector4Defs.h" />

MTA10/mods/deathmatch/_Deathmatch 2008.vcxproj.filters

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,15 @@
920920
<ClCompile Include="..\..\..\vendor\lua\src\llex.c">
921921
<Filter>Source Files\utils\lualib</Filter>
922922
</ClCompile>
923+
<ClCompile Include="..\shared_logic\CClientPointLights.cpp">
924+
<Filter>Source Files\shared_logic</Filter>
925+
</ClCompile>
926+
<ClCompile Include="..\shared_logic\CClientPointLightsManager.cpp">
927+
<Filter>Source Files\shared_logic</Filter>
928+
</ClCompile>
929+
<ClCompile Include="..\shared_logic\lua\CLuaFunctionDefs.PointLights.cpp">
930+
<Filter>Source Files\shared_logic\lua</Filter>
931+
</ClCompile>
923932
</ItemGroup>
924933
<ItemGroup>
925934
<ClInclude Include="CClient.h">
@@ -1627,5 +1636,11 @@
16271636
<ClInclude Include="..\shared_logic\lua\CLuaVector2.h">
16281637
<Filter>Header Files\shared_logic\lua</Filter>
16291638
</ClInclude>
1639+
<ClInclude Include="..\shared_logic\CClientPointLights.h">
1640+
<Filter>Header Files\shared_logic</Filter>
1641+
</ClInclude>
1642+
<ClInclude Include="..\shared_logic\CClientPointLightsManager.h">
1643+
<Filter>Header Files\shared_logic</Filter>
1644+
</ClInclude>
16301645
</ItemGroup>
16311646
</Project>

MTA10/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,7 @@ void CClientGame::SetAllDimensions ( unsigned short usDimension )
23142314
m_pManager->GetVehicleStreamer ()->SetDimension ( usDimension );
23152315
m_pManager->GetRadarMarkerManager ()->SetDimension ( usDimension );
23162316
m_pManager->GetSoundManager ()->SetDimension ( usDimension );
2317+
m_pManager->GetPointLightsManager ()->SetDimension ( usDimension );
23172318
m_pNametags->SetDimension ( usDimension );
23182319
}
23192320

@@ -3896,6 +3897,7 @@ void CClientGame::PreWorldProcessHandler ( void )
38963897
void CClientGame::PostWorldProcessHandler ( void )
38973898
{
38983899
m_pManager->GetMarkerManager ()->DoPulse ();
3900+
m_pManager->GetPointLightsManager ()->DoPulse ();
38993901

39003902
// Update frame time slice
39013903
uint uiCurrentTick = GetTickCount32 ();

MTA10/mods/deathmatch/logic/CClientGame.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class CClientGame
124124
SCRIPTFILE,
125125
WATER,
126126
WEAPON,
127+
POINTLIGHTS,
127128
UNKNOWN,
128129
};
129130

@@ -609,6 +610,7 @@ class CClientGame
609610
CClientPathManager* m_pPathManager;
610611
CClientTeamManager* m_pTeamManager;
611612
CClientPedManager* m_pPedManager;
613+
CClientPointLightsManager* m_pPointLightsManager;
612614
CClientProjectileManager* m_pProjectileManager;
613615
CRPCFunctions* m_pRPCFunctions;
614616
CUnoccupiedVehicleSync* m_pUnoccupiedVehicleSync;

MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,7 @@ bool CStaticFunctionDefinitions::SetElementDimension ( CClientEntity& Entity, un
12441244
case CCLIENTRADARMARKER:
12451245
case CCLIENTPED:
12461246
case CCLIENTPICKUP:
1247+
case CCLIENTPOINTLIGHTS:
12471248
case CCLIENTRADARAREA:
12481249
case CCLIENTWORLDMESH:
12491250
case CCLIENTSOUND:
@@ -8623,4 +8624,100 @@ bool CStaticFunctionDefinitions::SetSoundPan ( CClientSound& pSound, float fPan
86238624
bool CStaticFunctionDefinitions::GetSoundPan ( CClientSound& pSound, float& fPan )
86248625
{
86258626
return pSound.GetPan ( fPan );
8627+
}
8628+
8629+
CClientPointLights* CStaticFunctionDefinitions::CreateLight ( CResource& Resource, int iMode, const CVector& vecPosition, float fRadius, SColor color, CVector& vecDirection )
8630+
{
8631+
// Create it
8632+
CClientPointLights* pLight = new CClientPointLights ( m_pManager, INVALID_ELEMENT_ID );
8633+
if ( pLight )
8634+
{
8635+
pLight->SetParent ( Resource.GetResourceDynamicEntity () );
8636+
pLight->SetMode ( iMode );
8637+
pLight->SetPosition ( vecPosition );
8638+
pLight->SetRadius ( fRadius );
8639+
pLight->SetColor ( color );
8640+
pLight->SetDirection ( vecDirection );
8641+
8642+
return pLight;
8643+
}
8644+
8645+
return NULL;
8646+
}
8647+
8648+
8649+
bool CStaticFunctionDefinitions::GetLightType ( CClientPointLights* pLight, int& iMode )
8650+
{
8651+
if ( pLight )
8652+
{
8653+
iMode = pLight->GetMode ();
8654+
return true;
8655+
}
8656+
return false;
8657+
}
8658+
8659+
8660+
bool CStaticFunctionDefinitions::GetLightRadius ( CClientPointLights* pLight, float& fRadius )
8661+
{
8662+
if ( pLight )
8663+
{
8664+
fRadius = pLight->GetRadius ();
8665+
return true;
8666+
}
8667+
return false;
8668+
}
8669+
8670+
8671+
bool CStaticFunctionDefinitions::GetLightColor ( CClientPointLights* pLight, SColor& outColor )
8672+
{
8673+
if ( pLight )
8674+
{
8675+
outColor = pLight->GetColor ();
8676+
return true;
8677+
}
8678+
return false;
8679+
}
8680+
8681+
8682+
bool CStaticFunctionDefinitions::GetLightDirection ( CClientPointLights* pLight, CVector& vecDirection )
8683+
{
8684+
if ( pLight )
8685+
{
8686+
vecDirection = pLight->GetDirection();
8687+
return true;
8688+
}
8689+
return false;
8690+
}
8691+
8692+
8693+
bool CStaticFunctionDefinitions::SetLightRadius ( CClientPointLights* pLight, float fRadius )
8694+
{
8695+
if ( pLight )
8696+
{
8697+
pLight->SetRadius ( fRadius );
8698+
return true;
8699+
}
8700+
return false;
8701+
}
8702+
8703+
8704+
bool CStaticFunctionDefinitions::SetLightColor ( CClientPointLights* pLight, SColor color )
8705+
{
8706+
if ( pLight )
8707+
{
8708+
pLight->SetColor ( color );
8709+
return true;
8710+
}
8711+
return false;
8712+
}
8713+
8714+
8715+
bool CStaticFunctionDefinitions::SetLightDirection ( CClientPointLights* pLight, CVector vecDirection )
8716+
{
8717+
if ( pLight )
8718+
{
8719+
pLight->SetDirection ( vecDirection );
8720+
return true;
8721+
}
8722+
return false;
86268723
}

MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@ class CStaticFunctionDefinitions
304304

305305
// Fire funcs
306306
static bool CreateFire ( CVector& vecPosition, float fSize );
307+
308+
// Light funcs
309+
static CClientPointLights* CreateLight ( CResource& Resource, int iMode, const CVector& vecPosition, float fRadius, SColor color, CVector& vecDirection );
310+
static bool GetLightType ( CClientPointLights* pLight, int& iMode );
311+
static bool GetLightRadius ( CClientPointLights* pLight, float& fRadius );
312+
static bool GetLightColor ( CClientPointLights* pLight, SColor& outColor );
313+
static bool GetLightDirection ( CClientPointLights* pLight, CVector& vecDirection );
314+
static bool SetLightRadius ( CClientPointLights* pLight, float fRadius );
315+
static bool SetLightColor ( CClientPointLights* pLight, SColor color );
316+
static bool SetLightDirection ( CClientPointLights* pLight, CVector vecDirection );
307317

308318
// Audio funcs
309319
static bool PlaySoundFrontEnd ( unsigned char ucSound );

MTA10/mods/shared_logic/CClientEntity.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ bool CClientEntity::IsAttachable ( void )
11881188
case CCLIENTSOUND:
11891189
case CCLIENTCOLSHAPE:
11901190
case CCLIENTWEAPON:
1191+
case CCLIENTPOINTLIGHTS:
11911192
{
11921193
return true;
11931194
break;
@@ -1213,6 +1214,7 @@ bool CClientEntity::IsAttachToable ( void )
12131214
case CCLIENTSOUND:
12141215
case CCLIENTCOLSHAPE:
12151216
case CCLIENTCAMERA:
1217+
case CCLIENTPOINTLIGHTS:
12161218
{
12171219
return true;
12181220
break;
@@ -1262,6 +1264,8 @@ unsigned int CClientEntity::GetTypeID ( const char* szTypeName )
12621264
return CCLIENTRADARAREA;
12631265
else if ( strcmp ( szTypeName, "sound" ) == 0 )
12641266
return CCLIENTSOUND;
1267+
else if ( strcmp ( szTypeName, "light" ) == 0 )
1268+
return CCLIENTPOINTLIGHTS;
12651269
else
12661270
return CCLIENTUNKNOWN;
12671271
}

MTA10/mods/shared_logic/CClientEntity.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ enum eClientEntityType
7878
CCLIENTSHADER,
7979
CCLIENTWEAPON,
8080
CCLIENTEFFECT,
81+
CCLIENTPOINTLIGHTS,
8182
CCLIENTSCREENSOURCE,
8283
CCLIENTRENDERTARGET,
8384
CCLIENTUNKNOWN,
@@ -142,6 +143,7 @@ enum eCClientEntityClassTypes
142143
CLASS_CClientScreenSource,
143144
CLASS_CClientWeapon,
144145
CLASS_CClientEffect,
146+
CLASS_CClientPointLights,
145147
};
146148

147149

MTA10/mods/shared_logic/CClientManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ CClientManager::CClientManager ( void )
5454
m_pWaterManager = new CClientWaterManager ( this );
5555
m_pWeaponManager = new CClientWeaponManager ( this );
5656
m_pEffectManager = new CClientEffectManager ( this );
57+
m_pPointLightsManager = new CClientPointLightsManager ( this );
5758
m_pPacketRecorder = new CClientPacketRecorder ( this );
5859

5960
m_bBeingDeleted = false;
@@ -170,6 +171,9 @@ CClientManager::~CClientManager ( void )
170171

171172
delete m_pWeaponManager;
172173
m_pWeaponManager = NULL;
174+
175+
delete m_pPointLightsManager;
176+
m_pPointLightsManager = NULL;
173177
}
174178

175179
//

0 commit comments

Comments
 (0)