Skip to content
Permalink
Browse files

Add client-side function extinguishAllFires

Also moved Fire functions to CLuaFireDefs
  • Loading branch information...
Octalype
Octalype committed Jun 27, 2018
1 parent 40118f7 commit 7838b7b028f87248a7cd37f82fe1241bbc393ebc
@@ -4112,6 +4112,12 @@ bool CStaticFunctionDefinitions::ExtinguishFireInRadius(CVector& vecPosition, fl
return true;
}

bool CStaticFunctionDefinitions::ExtinguishAllFires()
{
g_pGame->GetFireManager()->ExtinguishAllFires();
return true;
}

bool CStaticFunctionDefinitions::PlaySoundFrontEnd(unsigned char ucSound)
{
g_pGame->GetAudioEngine()->PlayFrontEndSound(ucSound);
@@ -308,6 +308,7 @@ class CStaticFunctionDefinitions
// Fire funcs
static bool CreateFire(CVector& vecPosition, float fSize);
static bool ExtinguishFireInRadius(CVector& vecPosition, float fRadius);
static bool ExtinguishAllFires();

// Light funcs
static CClientPointLights* CreateLight(CResource& Resource, int iMode, const CVector& vecPosition, float fRadius, SColor color, CVector& vecDirection);
@@ -46,56 +46,6 @@ int CLuaFunctionDefs::CreateExplosion(lua_State* luaVM)
return 1;
}

int CLuaFunctionDefs::CreateFire(lua_State* luaVM)
{
// bool createFire ( float x, float y, float z [, float size = 1.8 ] )
CVector vecPosition;
float fSize;

CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(vecPosition);
argStream.ReadNumber(fSize, 1.8f);

if (!argStream.HasErrors())
{
if (CStaticFunctionDefinitions::CreateFire(vecPosition, fSize))
{
lua_pushboolean(luaVM, true);
return 1;
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
}

int CLuaFunctionDefs::ExtinguishFireInRadius(lua_State* luaVM)
{
// bool extinguishFireInRadius ( float x, float y, float z [, float radius = 1.0 ] )
CVector vecPosition;
float fRadius;

CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(vecPosition);
argStream.ReadNumber(fRadius, 1.0f);

if (!argStream.HasErrors())
{
if (CStaticFunctionDefinitions::ExtinguishFireInRadius(vecPosition, fRadius))
{
lua_pushboolean(luaVM, true);
return 1;
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
}

int CLuaFunctionDefs::GetTime_(lua_State* luaVM)
{
// Get the time
@@ -67,10 +67,6 @@ class CLuaFunctionDefs
// Explosion functions
LUA_DECLARE(CreateExplosion);

// Fire functions
LUA_DECLARE(CreateFire);
LUA_DECLARE(ExtinguishFireInRadius);

// Cursor funcs
LUA_DECLARE(GetCursorPosition);
LUA_DECLARE(SetCursorPosition);
@@ -10,6 +10,7 @@
*****************************************************************************/

#include "StdInc.h"
#include "../luadefs/CLuaFireDefs.h"

using std::list;

@@ -242,10 +243,6 @@ void CLuaManager::LoadCFunctions(void)
// Explosion funcs
CLuaCFunctions::AddFunction("createExplosion", CLuaFunctionDefs::CreateExplosion);

// Fire funcs
CLuaCFunctions::AddFunction("createFire", CLuaFunctionDefs::CreateFire);
CLuaCFunctions::AddFunction("extinguishFireInRadius", CLuaFunctionDefs::ExtinguishFireInRadius);

// Cursor funcs
CLuaCFunctions::AddFunction("getCursorPosition", CLuaFunctionDefs::GetCursorPosition);
CLuaCFunctions::AddFunction("setCursorPosition", CLuaFunctionDefs::SetCursorPosition);
@@ -403,6 +400,7 @@ void CLuaManager::LoadCFunctions(void)
CLuaEffectDefs::LoadFunctions();
CLuaElementDefs::LoadFunctions();
CLuaEngineDefs::LoadFunctions();
CLuaFireDefs::LoadFunctions();
CLuaGUIDefs::LoadFunctions();
CLuaMarkerDefs::LoadFunctions();
CLuaObjectDefs::LoadFunctions();
@@ -0,0 +1,75 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: Client/mods/deathmatch/logic/luadefs/CLuaFireDefs.cpp
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/
#include "StdInc.h"
#include "CLuaFireDefs.h"

void CLuaFireDefs::LoadFunctions(void)
{
CLuaCFunctions::AddFunction("createFire", CLuaFireDefs::CreateFire);
CLuaCFunctions::AddFunction("extinguishFireInRadius", CLuaFireDefs::ExtinguishFireInRadius);
CLuaCFunctions::AddFunction("extinguishAllFires", CLuaFireDefs::ExtinguishAllFires);
}

int CLuaFireDefs::CreateFire(lua_State* luaVM)
{
// bool createFire ( float x, float y, float z [, float size = 1.8 ] )
CVector vecPosition;
float fSize;

CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(vecPosition);
argStream.ReadNumber(fSize, 1.8f);

if (!argStream.HasErrors())
{
if (CStaticFunctionDefinitions::CreateFire(vecPosition, fSize))
{
lua_pushboolean(luaVM, true);
return 1;
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
}

int CLuaFireDefs::ExtinguishFireInRadius(lua_State* luaVM)
{
// bool extinguishFireInRadius ( float x, float y, float z [, float radius = 1.0 ] )
CVector vecPosition;
float fRadius;

CScriptArgReader argStream(luaVM);
argStream.ReadVector3D(vecPosition);
argStream.ReadNumber(fRadius, 1.0f);

if (!argStream.HasErrors())
{
if (CStaticFunctionDefinitions::ExtinguishFireInRadius(vecPosition, fRadius))
{
lua_pushboolean(luaVM, true);
return 1;
}
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

lua_pushboolean(luaVM, false);
return 1;
}

int CLuaFireDefs::ExtinguishAllFires(lua_State* luaVM)
{
// bool extinguishAllFires ( )
lua_pushboolean(luaVM, CStaticFunctionDefinitions::ExtinguishAllFires());
return 1;
}
@@ -0,0 +1,22 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: Client/mods/deathmatch/logic/luadefs/CLuaFireDefs.h
*
* Multi Theft Auto is available from http://www.multitheftauto.com/
*
*****************************************************************************/
#pragma once

#include "CLuaDefs.h"

class CLuaFireDefs : public CLuaDefs
{
public:
static void LoadFunctions(void);

LUA_DECLARE(CreateFire);
LUA_DECLARE(ExtinguishFireInRadius);
LUA_DECLARE(ExtinguishAllFires);
};

0 comments on commit 7838b7b

Please sign in to comment.
You can’t perform that action at this time.