Skip to content

Commit ebed392

Browse files
committed
fix(sw_cmds): Last page not showing up
1 parent 8fad52e commit ebed392

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

src/core/commands.cpp

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define GITHUB_SHA "LOCAL"
1919
#endif
2020

21-
const char *GetCppVersion()
21+
const char* GetCppVersion()
2222
{
2323
if (__cplusplus == 202101L)
2424
return "C++23";
@@ -56,11 +56,11 @@ void SwiftlyList(CPlayerSlot slot, CCommandContext context)
5656
uint16 idx = 0;
5757
for (uint16 i = 0; i < g_playerManager->GetPlayerCap(); i++)
5858
{
59-
Player *player = g_playerManager->GetPlayer(i);
59+
Player* player = g_playerManager->GetPlayer(i);
6060
if (!player)
6161
continue;
6262

63-
CBasePlayerController *controller = player->GetController();
63+
CBasePlayerController* controller = player->GetController();
6464
if (!controller)
6565
continue;
6666

@@ -82,11 +82,11 @@ void SwiftlyStatus(CPlayerSlot slot, CCommandContext context)
8282

8383
for (uint16 i = 0; i < g_playerManager->GetPlayerCap(); i++)
8484
{
85-
Player *player = g_playerManager->GetPlayer(i);
85+
Player* player = g_playerManager->GetPlayer(i);
8686
if (!player)
8787
continue;
8888

89-
CBasePlayerController *controller = player->GetController();
89+
CBasePlayerController* controller = player->GetController();
9090
if (!controller)
9191
continue;
9292

@@ -99,13 +99,13 @@ void SwiftlyStatus(CPlayerSlot slot, CCommandContext context)
9999
}
100100

101101
auto PrintTT = [slot](std::string category, TextTable table) -> void
102-
{
103-
std::stringstream outputTable;
104-
outputTable << table;
105-
std::vector<std::string> rows = explode(outputTable.str(), "\n");
106-
for (int i = 0; i < rows.size() - 1; i++)
107-
PrintToClientOrConsole(slot, category, "%s\n", rows[i].c_str());
108-
};
102+
{
103+
std::stringstream outputTable;
104+
outputTable << table;
105+
std::vector<std::string> rows = explode(outputTable.str(), "\n");
106+
for (size_t i = 0; i < rows.size() - 1; i++)
107+
PrintToClientOrConsole(slot, category, "%s\n", rows[i].c_str());
108+
};
109109

110110
PrintTT("Status", statusTable);
111111

@@ -114,16 +114,16 @@ void SwiftlyStatus(CPlayerSlot slot, CCommandContext context)
114114

115115
void ShowSwiftlyCommands(CPlayerSlot slot, CCommandContext context, int page)
116116
{
117-
std::map<std::string, Command *> cmds = g_commandsManager->GetCommands();
117+
std::map<std::string, Command*> cmds = g_commandsManager->GetCommands();
118118
PrintToClientOrConsole(slot, "Commands", "There are %d commands created by plugins.\n", cmds.size());
119119
PrintToClientOrConsole(slot, "Commands", "Below will be shown a list of all the commands:\n");
120120

121121
if (page < 1)
122122
page = 1;
123123
else if (static_cast<unsigned int>(page) * 10 > cmds.size())
124-
page = int(floor(cmds.size() / 10));
124+
page = int(ceil(double(cmds.size()) / 10.0));
125125

126-
std::map<std::string, Command *>::iterator it = cmds.begin();
126+
std::map<std::string, Command*>::iterator it = cmds.begin();
127127
for (int i = 0; i < (page - 1) * 10; i++)
128128
++it;
129129

@@ -202,7 +202,7 @@ void SwiftlyAddonsManagerStatus(CPlayerSlot slot, CCommandContext context)
202202
PrintToClientOrConsole(slot, "Addons", "Addons Status: %s.\n", g_addons.GetStatus() ? "Enabled" : "Disabled");
203203
}
204204

205-
void SwiftlyAddonsManager(CPlayerSlot slot, CCommandContext context, const char *subcmd)
205+
void SwiftlyAddonsManager(CPlayerSlot slot, CCommandContext context, const char* subcmd)
206206
{
207207
if (slot.Get() != -1)
208208
return;
@@ -285,7 +285,7 @@ void SwiftlyConFilterReload(CPlayerSlot slot, CCommandContext context)
285285
g_conFilter->Toggle();
286286
}
287287

288-
void SwiftlyConFilterManager(CPlayerSlot slot, CCommandContext context, const char *subcmd)
288+
void SwiftlyConFilterManager(CPlayerSlot slot, CCommandContext context, const char* subcmd)
289289
{
290290
if (slot.Get() != -1)
291291
return;
@@ -331,7 +331,7 @@ void SwiftlyPluginManagerList(CPlayerSlot slot, CCommandContext context)
331331
auto plugins = g_pluginManager->GetPluginsList();
332332
for (uint32 i = 0; i < plugins.size(); i++)
333333
{
334-
Plugin *plugin = plugins[i];
334+
Plugin* plugin = plugins[i];
335335
if (plugin == nullptr)
336336
continue;
337337
if (plugin->GetPluginState() == PluginState_t::Stopped)
@@ -348,7 +348,7 @@ void SwiftlyPluginManagerList(CPlayerSlot slot, CCommandContext context)
348348
std::vector<std::string> errors;
349349
for (uint32 i = 0; i < plugins.size(); i++)
350350
{
351-
Plugin *plugin = plugins[i];
351+
Plugin* plugin = plugins[i];
352352
if (plugin == nullptr)
353353
continue;
354354
if (plugin->GetLoadError().size() > 0)
@@ -361,11 +361,11 @@ void SwiftlyPluginManagerList(CPlayerSlot slot, CCommandContext context)
361361
auto website = plugin->GetWebsite();
362362

363363
PrintToClientOrConsole(slot, "Plugins List", "%02d. \"%s\" (%s) by %s%s\n",
364-
showingIdx,
365-
plugin->GetPlName().c_str(),
366-
plugin->GetVersion().c_str(),
367-
plugin->GetAuthor().c_str(),
368-
website == "" ? "" : string_format(" ( %s )", website.c_str()).c_str());
364+
showingIdx,
365+
plugin->GetPlName().c_str(),
366+
plugin->GetVersion().c_str(),
367+
plugin->GetAuthor().c_str(),
368+
website == "" ? "" : string_format(" ( %s )", website.c_str()).c_str());
369369
}
370370
if (errors.size() && slot.Get() == -1)
371371
{
@@ -385,7 +385,7 @@ void SwiftlyPluginManagerInfo(CPlayerSlot slot, CCommandContext context, std::st
385385
if (!g_pluginManager->PluginExists(plugin_name))
386386
return PrintToClientOrConsole(slot, "Plugin Info", "Invalid plugin name.\n");
387387

388-
Plugin *plugin = g_pluginManager->FetchPlugin(plugin_name);
388+
Plugin* plugin = g_pluginManager->FetchPlugin(plugin_name);
389389
if (plugin->GetPluginState() == PluginState_t::Stopped)
390390
return PrintToClientOrConsole(slot, "Plugin Info", "Plugin is not loaded.\n");
391391

@@ -398,7 +398,7 @@ void SwiftlyPluginManagerInfo(CPlayerSlot slot, CCommandContext context, std::st
398398
PrintToClientOrConsole(slot, "Plugin Info", "URL: %s\n", website == "" ? "Not Present" : website.c_str());
399399
if (plugin->GetKind() == PluginKind_t::Lua)
400400
{
401-
LuaPlugin *plg = (LuaPlugin *)plugin;
401+
LuaPlugin* plg = (LuaPlugin*)plugin;
402402

403403
auto collectgarbage = luabridge::getGlobal(plg->GetState(), "collectgarbage");
404404
auto countResult = collectgarbage(std::string("count"));
@@ -415,7 +415,7 @@ void SwiftlyPluginManagerUnload(CPlayerSlot slot, CCommandContext context, std::
415415
if (!g_pluginManager->PluginExists(plugin_name))
416416
return PrintToClientOrConsole(slot, "Plugin Unload", "Invalid plugin name.\n");
417417

418-
Plugin *plugin = g_pluginManager->FetchPlugin(plugin_name);
418+
Plugin* plugin = g_pluginManager->FetchPlugin(plugin_name);
419419
if (plugin->GetPluginState() == PluginState_t::Stopped)
420420
return PrintToClientOrConsole(slot, "Plugin Unload", "Plugin is not loaded.\n");
421421

@@ -431,7 +431,7 @@ void SwiftlyPluginManagerLoad(CPlayerSlot slot, CCommandContext context, std::st
431431
if (!g_pluginManager->PluginExists(plugin_name))
432432
return PrintToClientOrConsole(slot, "Plugin Load", "Invalid plugin name.\n");
433433

434-
Plugin *plugin = g_pluginManager->FetchPlugin(plugin_name);
434+
Plugin* plugin = g_pluginManager->FetchPlugin(plugin_name);
435435
if (plugin->GetPluginState() == PluginState_t::Started)
436436
return PrintToClientOrConsole(slot, "Plugin Load", "Plugin is already loaded.\n");
437437

@@ -448,7 +448,7 @@ void SwiftlyPluginManagerReload(CPlayerSlot slot, CCommandContext context, std::
448448
if (!g_pluginManager->PluginExists(plugin_name))
449449
return PrintToClientOrConsole(slot, "Plugin Reload", "Invalid plugin name.\n");
450450

451-
Plugin *plugin = g_pluginManager->FetchPlugin(plugin_name);
451+
Plugin* plugin = g_pluginManager->FetchPlugin(plugin_name);
452452
if (plugin->GetPluginState() == PluginState_t::Stopped)
453453
return PrintToClientOrConsole(slot, "Plugin Reload", "Plugin is not loaded.\n");
454454

@@ -466,7 +466,7 @@ void SwiftlyPluginManagerRefresh(CPlayerSlot slot, CCommandContext context)
466466
PrintToClientOrConsole(slot, "Plugin Refresh", "Plugins have been succesfully refreshed. (%d -> %d plugins)\n", oldPluginsAmount, newPluginsAmount);
467467
}
468468

469-
void SwiftlyPluginManager(CPlayerSlot slot, CCommandContext context, const char *subcmd, const char *plugin_name)
469+
void SwiftlyPluginManager(CPlayerSlot slot, CCommandContext context, const char* subcmd, const char* plugin_name)
470470
{
471471
if (slot.Get() != -1)
472472
return;
@@ -535,13 +535,13 @@ void SwiftlyResourceMonitorManagerViewPlugin(CPlayerSlot slot, CCommandContext c
535535
return PrintToClientOrConsole(slot, "Resource Monitor", "Invalid plugin ID.\n");
536536

537537
auto PrintTable = [](TextTable tbl) -> void
538-
{
539-
std::stringstream outputTable;
540-
outputTable << tbl;
541-
std::vector<std::string> rows = explode(outputTable.str(), "\n");
542-
for (int i = 0; i < rows.size(); i++)
543-
PLUGIN_PRINTF("Resource Monitor", "%s\n", rows[i].c_str());
544-
};
538+
{
539+
std::stringstream outputTable;
540+
outputTable << tbl;
541+
std::vector<std::string> rows = explode(outputTable.str(), "\n");
542+
for (size_t i = 0; i < rows.size(); i++)
543+
PLUGIN_PRINTF("Resource Monitor", "%s\n", rows[i].c_str());
544+
};
545545

546546
PrintToClientOrConsole(slot, "Resource Monitor", "Resource Monitor View Plugin\n");
547547
PrintToClientOrConsole(slot, "Resource Monitor", "ID: %s\n", plugin_id.c_str());
@@ -610,13 +610,13 @@ void SwiftlyResourceMonitorManagerView(CPlayerSlot slot, CCommandContext context
610610
pluginsTable.endOfRow();
611611

612612
auto PrintTable = [](TextTable tbl) -> void
613-
{
614-
std::stringstream outputTable;
615-
outputTable << tbl;
616-
std::vector<std::string> rows = explode(outputTable.str(), "\n");
617-
for (int i = 0; i < rows.size(); i++)
618-
PLUGIN_PRINTF("Resource Monitor", "%s\n", rows[i].c_str());
619-
};
613+
{
614+
std::stringstream outputTable;
615+
outputTable << tbl;
616+
std::vector<std::string> rows = explode(outputTable.str(), "\n");
617+
for (size_t i = 0; i < rows.size(); i++)
618+
PLUGIN_PRINTF("Resource Monitor", "%s\n", rows[i].c_str());
619+
};
620620

621621
PLUGIN_PRINTF("Resource Monitor", "Plugin Resource Viewer\n");
622622

@@ -660,7 +660,7 @@ void SwiftlyResourceMonitorManagerView(CPlayerSlot slot, CCommandContext context
660660

661661
pluginsTable.endOfRow();
662662

663-
for (Plugin *plugin : g_pluginManager->GetPluginsList())
663+
for (Plugin* plugin : g_pluginManager->GetPluginsList())
664664
{
665665
std::string plugin_id = plugin->GetName();
666666

@@ -671,7 +671,7 @@ void SwiftlyResourceMonitorManagerView(CPlayerSlot slot, CCommandContext context
671671
pluginsTable.add(std::string(" ") + (plugin->GetKind() == PluginKind_t::Lua ? "Lua" : "None") + " ");
672672
if (plugin->GetKind() == PluginKind_t::Lua && plugin->GetPluginState() == PluginState_t::Started)
673673
{
674-
auto collectgarbage = luabridge::getGlobal(((LuaPlugin *)plugin)->GetState(), "collectgarbage");
674+
auto collectgarbage = luabridge::getGlobal(((LuaPlugin*)plugin)->GetState(), "collectgarbage");
675675
auto countResult = collectgarbage(std::string("count"));
676676
pluginsTable.add(string_format(" %.4f MB ", (countResult.cast<double>() / 1024)));
677677
}
@@ -716,7 +716,7 @@ void SwiftlyResourceMonitorManagerView(CPlayerSlot slot, CCommandContext context
716716
PrintToClientOrConsole(slot, "Resource Monitor", "To view more detailed informations for each plugin, use: sw resmon viewplugin <ID>\n");
717717
}
718718

719-
void SwiftlyResourceMonitorManager(CPlayerSlot slot, CCommandContext context, const char *subcmd, const char *subcmd2)
719+
void SwiftlyResourceMonitorManager(CPlayerSlot slot, CCommandContext context, const char* subcmd, const char* subcmd2)
720720
{
721721
if (slot.Get() != -1)
722722
return;
@@ -757,7 +757,7 @@ void SwiftlyTranslationReload(CPlayerSlot slot, CCommandContext context)
757757
PrintToClientOrConsole(slot, "Translations", "All translations have been succesfully reloaded.\n");
758758
}
759759

760-
void SwiftlyTranslationManager(CPlayerSlot slot, CCommandContext context, const char *subcmd)
760+
void SwiftlyTranslationManager(CPlayerSlot slot, CCommandContext context, const char* subcmd)
761761
{
762762
if (slot.Get() != -1)
763763
return;
@@ -800,7 +800,7 @@ void ShowSwiftlyCredits(CPlayerSlot slot, CCommandContext context)
800800
PrintToClientOrConsole(slot, "Commands", "https://github.com/swiftly-solution \n");
801801
}
802802

803-
void SwiftlyCommand(const CCommandContext &context, const CCommand &args)
803+
void SwiftlyCommand(const CCommandContext& context, const CCommand& args)
804804
{
805805
CPlayerSlot slot = context.GetPlayerSlot();
806806
if (args.ArgC() < 2)

0 commit comments

Comments
 (0)