Skip to content

Commit 76174d1

Browse files
author
CrosRoad95
committed
changed according Necktrox advices
1 parent 05e6458 commit 76174d1

File tree

7 files changed

+59
-54
lines changed

7 files changed

+59
-54
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ void CLuaColShapeDefs::LoadFunctions ( void )
1919
CLuaCFunctions::AddFunction ( "createColRectangle", CreateColRectangle );
2020
CLuaCFunctions::AddFunction ( "createColPolygon", CreateColPolygon );
2121
CLuaCFunctions::AddFunction ( "createColTube", CreateColTube );
22+
CLuaCFunctions::AddFunction ( "getColShapeType", GetColShapeType);
23+
2224
}
2325

2426
void CLuaColShapeDefs::AddClass ( lua_State* luaVM )
@@ -41,6 +43,31 @@ void CLuaColShapeDefs::AddClass ( lua_State* luaVM )
4143
lua_registerclass ( luaVM, "ColShape", "Element" );
4244
}
4345

46+
int CLuaColShapeDefs::GetColShapeType ( lua_State* luaVM )
47+
{
48+
// Verify the arguments
49+
CClientColShape* pColShape = nullptr;
50+
CScriptArgReader argStream ( luaVM );
51+
argStream.ReadUserData ( pColShape );
52+
53+
if ( !argStream.HasErrors ( ) )
54+
{
55+
// Grab our VM
56+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
57+
if (pLuaMain)
58+
{
59+
lua_pushnumber ( luaVM, pColShape->GetShapeType( ) + 1 );
60+
return 1;
61+
}
62+
}
63+
else
64+
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage ( ) );
65+
66+
// Failed
67+
lua_pushboolean ( luaVM, false );
68+
return 1;
69+
}
70+
4471
int CLuaColShapeDefs::CreateColCircle ( lua_State* luaVM )
4572
{
4673
CVector2D vecPosition;

Client/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ class CLuaColShapeDefs : public CLuaDefs
2424
LUA_DECLARE ( CreateColRectangle );
2525
LUA_DECLARE ( CreateColPolygon );
2626
LUA_DECLARE ( CreateColTube );
27+
28+
LUA_DECLARE ( GetColShapeType );
2729
};

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ void CLuaElementDefs::LoadFunctions ( void )
3636
CLuaCFunctions::AddFunction ( "isElementWithinColShape", IsElementWithinColShape );
3737
CLuaCFunctions::AddFunction ( "isElementWithinMarker", IsElementWithinMarker );
3838
CLuaCFunctions::AddFunction ( "getElementsWithinColShape", GetElementsWithinColShape );
39-
CLuaCFunctions::AddFunction ( "getColShapeType", GetColShapeType );
4039
CLuaCFunctions::AddFunction ( "getElementDimension", GetElementDimension );
4140
CLuaCFunctions::AddFunction ( "getElementBoundingBox", GetElementBoundingBox );
4241
CLuaCFunctions::AddFunction ( "getElementRadius", GetElementRadius );
@@ -892,31 +891,6 @@ int CLuaElementDefs::IsElementWithinMarker ( lua_State* luaVM )
892891
return 1;
893892
}
894893

895-
int CLuaElementDefs::GetColShapeType ( lua_State* luaVM )
896-
{
897-
// Verify the arguments
898-
CClientColShape* pColShape = NULL;
899-
CScriptArgReader argStream ( luaVM );
900-
argStream.ReadUserData ( pColShape );
901-
902-
if ( ! argStream.HasErrors ( ) )
903-
{
904-
// Grab our VM
905-
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
906-
if (pLuaMain)
907-
{
908-
lua_pushnumber ( luaVM, pColShape->GetShapeType ( ) + 1 );
909-
return 1;
910-
}
911-
}
912-
else
913-
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage ( ) );
914-
915-
// Failed
916-
lua_pushboolean ( luaVM, false );
917-
return 1;
918-
}
919-
920894
int CLuaElementDefs::GetElementsWithinColShape ( lua_State* luaVM )
921895
{
922896
// Verify the arguments

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void CLuaColShapeDefs::LoadFunctions ()
2020
CLuaCFunctions::AddFunction ( "createColRectangle", CreateColRectangle );
2121
CLuaCFunctions::AddFunction ( "createColPolygon", CreateColPolygon );
2222
CLuaCFunctions::AddFunction ( "createColTube", CreateColTube );
23+
CLuaCFunctions::AddFunction ( "getColShapeType", GetColShapeType );
2324
}
2425

2526
void CLuaColShapeDefs::AddClass ( lua_State* luaVM )
@@ -36,11 +37,37 @@ void CLuaColShapeDefs::AddClass ( lua_State* luaVM )
3637
lua_classfunction ( luaVM, "getElementsWithin", "getElementsWithinColShape" );
3738
lua_classfunction ( luaVM, "getShapeType", "getColShapeType" );
3839

39-
lua_classvariable ( luaVM, "shape", NULL, "getColShapeType" );
40+
lua_classvariable ( luaVM, "shape", nullptr, "getColShapeType" );
4041

4142
lua_registerclass ( luaVM, "ColShape", "Element" );
4243
}
4344

45+
46+
int CLuaColShapeDefs::GetColShapeType ( lua_State* luaVM )
47+
{
48+
// Verify the arguments
49+
CColShape* pColShape = nullptr;
50+
CScriptArgReader argStream ( luaVM );
51+
argStream.ReadUserData( pColShape );
52+
53+
if ( !argStream.HasErrors( ) )
54+
{
55+
// Grab our VM
56+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
57+
if (pLuaMain)
58+
{
59+
lua_pushnumber ( luaVM, pColShape->GetShapeType ( ) + 1); // start from 1 not 0
60+
return 1;
61+
}
62+
}
63+
else
64+
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage ( ) );
65+
66+
// Failed
67+
lua_pushboolean ( luaVM, false );
68+
return 1;
69+
}
70+
4471
int CLuaColShapeDefs::CreateColCircle ( lua_State* luaVM )
4572
{
4673
CVector2D vecPosition;

Server/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ class CLuaColShapeDefs : public CLuaDefs
2525
LUA_DECLARE ( CreateColRectangle );
2626
LUA_DECLARE ( CreateColPolygon );
2727
LUA_DECLARE ( CreateColTube );
28+
29+
LUA_DECLARE ( GetColShapeType );
2830
};

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ void CLuaElementDefs::LoadFunctions ( void )
4747
CLuaCFunctions::AddFunction ( "getElementType", getElementType );
4848
CLuaCFunctions::AddFunction ( "getElementInterior", getElementInterior );
4949
CLuaCFunctions::AddFunction ( "getElementsWithinColShape", getElementsWithinColShape );
50-
CLuaCFunctions::AddFunction ( "getColShapeType", getColShapeType );
5150
CLuaCFunctions::AddFunction ( "getElementDimension", getElementDimension );
5251
CLuaCFunctions::AddFunction ( "getElementZoneName", getElementZoneName );
5352
CLuaCFunctions::AddFunction ( "getElementColShape", getElementColShape );
@@ -965,31 +964,6 @@ int CLuaElementDefs::isElementWithinColShape ( lua_State* luaVM )
965964
return 1;
966965
}
967966

968-
int CLuaElementDefs::getColShapeType ( lua_State* luaVM )
969-
{
970-
// Verify the arguments
971-
CColShape* pColShape = NULL;
972-
CScriptArgReader argStream ( luaVM );
973-
argStream.ReadUserData ( pColShape );
974-
975-
if ( ! argStream.HasErrors ( ) )
976-
{
977-
// Grab our VM
978-
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
979-
if (pLuaMain)
980-
{
981-
lua_pushnumber ( luaVM, pColShape->GetShapeType ( ) + 1 ); // start from 1 not 0
982-
return 1;
983-
}
984-
}
985-
else
986-
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage ( ) );
987-
988-
// Failed
989-
lua_pushboolean( luaVM, false );
990-
return 1;
991-
}
992-
993967
int CLuaElementDefs::getElementsWithinColShape ( lua_State* luaVM )
994968
{
995969
// table getElementsWithinColShape ( colshape shape, [ string elemType ] )

Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class CLuaElementDefs: public CLuaDefs
4747
LUA_DECLARE ( getElementsByType );
4848
LUA_DECLARE ( getElementInterior );
4949
LUA_DECLARE ( getElementsWithinColShape );
50-
LUA_DECLARE ( getColShapeType );
5150
LUA_DECLARE ( getElementDimension );
5251
LUA_DECLARE ( getElementZoneName );
5352
LUA_DECLARE ( getElementColShape );

0 commit comments

Comments
 (0)