Fixed coding conventions for Pull Request #1807
This commit is contained in:
parent
d8ab99e944
commit
f6912bd01c
@ -268,12 +268,15 @@ static int tolua_StringSplit(lua_State * tolua_S)
|
|||||||
|
|
||||||
static int tolua_StringSplitWithQuotes(lua_State * tolua_S)
|
static int tolua_StringSplitWithQuotes(lua_State * tolua_S)
|
||||||
{
|
{
|
||||||
cLuaState LuaState(tolua_S);
|
cLuaState S(tolua_S);
|
||||||
std::string str = (std::string)tolua_tocppstring(LuaState, 1, 0);
|
|
||||||
std::string delim = (std::string)tolua_tocppstring(LuaState, 2, 0);
|
AString str;
|
||||||
|
AString delim;
|
||||||
|
|
||||||
|
S.GetStackValues(1, str, delim);
|
||||||
|
|
||||||
AStringVector Split = StringSplitWithQuotes(str, delim);
|
AStringVector Split = StringSplitWithQuotes(str, delim);
|
||||||
LuaState.Push(Split);
|
S.Push(Split);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3676,18 +3679,18 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
|||||||
tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr);
|
tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr);
|
||||||
|
|
||||||
// Globals:
|
// Globals:
|
||||||
tolua_function(tolua_S, "Clamp", tolua_Clamp);
|
tolua_function(tolua_S, "Clamp", tolua_Clamp);
|
||||||
tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
|
tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
|
||||||
tolua_function(tolua_S, "StringSplitWithQuotes", tolua_StringSplitWithQuotes);
|
tolua_function(tolua_S, "StringSplitWithQuotes", tolua_StringSplitWithQuotes);
|
||||||
tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim);
|
tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim);
|
||||||
tolua_function(tolua_S, "LOG", tolua_LOG);
|
tolua_function(tolua_S, "LOG", tolua_LOG);
|
||||||
tolua_function(tolua_S, "LOGINFO", tolua_LOGINFO);
|
tolua_function(tolua_S, "LOGINFO", tolua_LOGINFO);
|
||||||
tolua_function(tolua_S, "LOGWARN", tolua_LOGWARN);
|
tolua_function(tolua_S, "LOGWARN", tolua_LOGWARN);
|
||||||
tolua_function(tolua_S, "LOGWARNING", tolua_LOGWARN);
|
tolua_function(tolua_S, "LOGWARNING", tolua_LOGWARN);
|
||||||
tolua_function(tolua_S, "LOGERROR", tolua_LOGERROR);
|
tolua_function(tolua_S, "LOGERROR", tolua_LOGERROR);
|
||||||
tolua_function(tolua_S, "Base64Encode", tolua_Base64Encode);
|
tolua_function(tolua_S, "Base64Encode", tolua_Base64Encode);
|
||||||
tolua_function(tolua_S, "Base64Decode", tolua_Base64Decode);
|
tolua_function(tolua_S, "Base64Decode", tolua_Base64Decode);
|
||||||
tolua_function(tolua_S, "md5", tolua_md5_obsolete); // OBSOLETE, use cCryptoHash.md5() instead
|
tolua_function(tolua_S, "md5", tolua_md5_obsolete); // OBSOLETE, use cCryptoHash.md5() instead
|
||||||
|
|
||||||
tolua_beginmodule(tolua_S, "cFile");
|
tolua_beginmodule(tolua_S, "cFile");
|
||||||
tolua_function(tolua_S, "GetFolderContents", tolua_cFile_GetFolderContents);
|
tolua_function(tolua_S, "GetFolderContents", tolua_cFile_GetFolderContents);
|
||||||
|
@ -111,12 +111,12 @@ public:
|
|||||||
Command permissions have already been checked.
|
Command permissions have already been checked.
|
||||||
Returns true if command handled successfully
|
Returns true if command handled successfully
|
||||||
*/
|
*/
|
||||||
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & fullCommand) = 0;
|
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand) = 0;
|
||||||
|
|
||||||
/** Handles the console command split into a_Split.
|
/** Handles the console command split into a_Split.
|
||||||
Returns true if command handled successfully. Output is to be sent to the a_Output callback.
|
Returns true if command handled successfully. Output is to be sent to the a_Output callback.
|
||||||
*/
|
*/
|
||||||
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & fullCommand) = 0;
|
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_FullCommand) = 0;
|
||||||
|
|
||||||
/// All bound commands are to be removed, do any language-dependent cleanup here
|
/// All bound commands are to be removed, do any language-dependent cleanup here
|
||||||
virtual void ClearCommands(void) {}
|
virtual void ClearCommands(void) {}
|
||||||
|
@ -1465,7 +1465,7 @@ bool cPluginLua::OnWorldTick(cWorld & a_World, std::chrono::milliseconds a_Dt, s
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & fullCommand)
|
bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand)
|
||||||
{
|
{
|
||||||
ASSERT(!a_Split.empty());
|
ASSERT(!a_Split.empty());
|
||||||
CommandMap::iterator cmd = m_Commands.find(a_Split[0]);
|
CommandMap::iterator cmd = m_Commands.find(a_Split[0]);
|
||||||
@ -1477,7 +1477,7 @@ bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer & a_Player
|
|||||||
|
|
||||||
cCSLock Lock(m_CriticalSection);
|
cCSLock Lock(m_CriticalSection);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
m_LuaState.Call(cmd->second, a_Split, &a_Player, fullCommand, cLuaState::Return, res);
|
m_LuaState.Call(cmd->second, a_Split, &a_Player, a_FullCommand, cLuaState::Return, res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1485,7 +1485,7 @@ bool cPluginLua::HandleCommand(const AStringVector & a_Split, cPlayer & a_Player
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginLua::HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & fullCommand)
|
bool cPluginLua::HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_FullCommand)
|
||||||
{
|
{
|
||||||
ASSERT(!a_Split.empty());
|
ASSERT(!a_Split.empty());
|
||||||
CommandMap::iterator cmd = m_ConsoleCommands.find(a_Split[0]);
|
CommandMap::iterator cmd = m_ConsoleCommands.find(a_Split[0]);
|
||||||
@ -1500,7 +1500,7 @@ bool cPluginLua::HandleConsoleCommand(const AStringVector & a_Split, cCommandOut
|
|||||||
cCSLock Lock(m_CriticalSection);
|
cCSLock Lock(m_CriticalSection);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
AString str;
|
AString str;
|
||||||
m_LuaState.Call(cmd->second, a_Split, fullCommand, cLuaState::Return, res, str);
|
m_LuaState.Call(cmd->second, a_Split, a_FullCommand, cLuaState::Return, res, str);
|
||||||
if (res && !str.empty())
|
if (res && !str.empty())
|
||||||
{
|
{
|
||||||
a_Output.Out(str);
|
a_Output.Out(str);
|
||||||
|
@ -131,9 +131,9 @@ public:
|
|||||||
virtual bool OnWorldStarted (cWorld & a_World) override;
|
virtual bool OnWorldStarted (cWorld & a_World) override;
|
||||||
virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override;
|
virtual bool OnWorldTick (cWorld & a_World, std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_LastTickDurationMSec) override;
|
||||||
|
|
||||||
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & fullCommand) override;
|
virtual bool HandleCommand(const AStringVector & a_Split, cPlayer & a_Player, const AString & a_FullCommand) override;
|
||||||
|
|
||||||
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & fullCommand) override;
|
virtual bool HandleConsoleCommand(const AStringVector & a_Split, cCommandOutputCallback & a_Output, const AString & a_FullCommand) override;
|
||||||
|
|
||||||
virtual void ClearCommands(void) override;
|
virtual void ClearCommands(void) override;
|
||||||
|
|
||||||
|
@ -170,7 +170,12 @@ AStringVector StringSplitWithQuotes(const AString & str, const AString & delim)
|
|||||||
{
|
{
|
||||||
AString current = str.substr(Prev);
|
AString current = str.substr(Prev);
|
||||||
|
|
||||||
if ((current.length() >= 2) && ((current.front() == '"') || (current.front() == '\'')) && (current.front() == current.back()))
|
// If the remant is wrapped in matching quotes, remove them:
|
||||||
|
if (
|
||||||
|
(current.length() >= 2) &&
|
||||||
|
((current.front() == '"') || (current.front() == '\'')) &&
|
||||||
|
(current.front() == current.back())
|
||||||
|
)
|
||||||
{
|
{
|
||||||
current = current.substr(1, current.length() - 2);
|
current = current.substr(1, current.length() - 2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user