diff options
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index cd5e69b22..f06f4da37 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -4348,6 +4348,69 @@ static int tolua_cEntity_GetSpeed(lua_State * tolua_S) +static int tolua_get_StatisticsManager_Custom(lua_State * tolua_S) +{ + // Check the params: + cLuaState L(tolua_S); + if (!L.CheckParamNumber(2)) + { + return 0; + } + + // Get the params: + lua_pushstring(tolua_S, ".self"); + lua_rawget(tolua_S, 1); + StatisticsManager * Self = static_cast<StatisticsManager *>(lua_touserdata(tolua_S, -1)); + CustomStatistic Statistic; + if (!L.GetStackValue(2, Statistic)) + { + return L.ApiParamError("Expected a valid custom statistic ID"); + } + + // Push result if statistic exists: + if (const auto Result = Self->Custom.find(Statistic); Result != Self->Custom.end()) + { + L.Push(Result->second); + return 1; + } + + return 0; +} + + + + + +static int tolua_set_StatisticsManager_Custom(lua_State * tolua_S) +{ + // Check the params: + cLuaState L(tolua_S); + if (!L.CheckParamNumber(2)) + { + return 0; + } + + // Get the params: + lua_pushstring(tolua_S, ".self"); + lua_rawget(tolua_S, 1); + StatisticsManager * Self = static_cast<StatisticsManager *>(lua_touserdata(tolua_S, -1)); + CustomStatistic Statistic; + StatisticsManager::StatValue Value; + if (!L.GetStackValues(2, Statistic, Value)) + { + return L.ApiParamError("Expected a valid custom statistic ID and value"); + } + + // Set the value: + Self->Custom[Statistic] = Value; + + return 0; +} + + + + + void cManualBindings::Bind(lua_State * tolua_S) { tolua_beginmodule(tolua_S, nullptr); @@ -4357,10 +4420,12 @@ void cManualBindings::Bind(lua_State * tolua_S) tolua_usertype(tolua_S, "cLineBlockTracer"); tolua_usertype(tolua_S, "cStringCompression"); tolua_usertype(tolua_S, "cUrlParser"); + // StatisticsManager was already created by cPlayer::GetStatistics' autogenerated bindings. tolua_cclass(tolua_S, "cCryptoHash", "cCryptoHash", "", nullptr); tolua_cclass(tolua_S, "cLineBlockTracer", "cLineBlockTracer", "", nullptr); tolua_cclass(tolua_S, "cStringCompression", "cStringCompression", "", nullptr); tolua_cclass(tolua_S, "cUrlParser", "cUrlParser", "", nullptr); + tolua_cclass(tolua_S, "StatisticsManager", "StatisticsManager", "", nullptr); // Globals: tolua_function(tolua_S, "Clamp", tolua_Clamp); @@ -4592,6 +4657,10 @@ void cManualBindings::Bind(lua_State * tolua_S) tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, nullptr); tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "StatisticsManager"); + tolua_array(tolua_S, "Custom", tolua_get_StatisticsManager_Custom, tolua_set_StatisticsManager_Custom); + tolua_endmodule(tolua_S); + BindNetwork(tolua_S); BindRankManager(tolua_S); BindWorld(tolua_S); |