Add cmgamestats console command to show total number of vehicles in the game
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "cm_command_log.hpp"
|
||||
#include "cm_export.hpp"
|
||||
|
||||
#include "../aircraft.h"
|
||||
#include "../command_func.h"
|
||||
#include "../console_func.h"
|
||||
#include "../console_type.h"
|
||||
@@ -13,8 +14,11 @@
|
||||
#include "../fileio_type.h"
|
||||
#include "../map_type.h"
|
||||
#include "../map_func.h"
|
||||
#include "../roadveh.h"
|
||||
#include "../strings_func.h"
|
||||
#include "../ship.h"
|
||||
#include "../town.h"
|
||||
#include "../train.h"
|
||||
#include "../tree_map.h"
|
||||
|
||||
#include <fstream>
|
||||
@@ -205,4 +209,30 @@ bool ConStopRecord(byte argc, char *argv[]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConGameStats(byte argc, char *argv[]) {
|
||||
auto num_trains = 0u;
|
||||
auto num_rvs = 0u;
|
||||
auto num_ships = 0u;
|
||||
auto num_aircraft = 0u;
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
if (!v->IsPrimaryVehicle()) continue;
|
||||
switch (v->type) {
|
||||
default: break;
|
||||
case VEH_TRAIN: num_trains++; break;
|
||||
case VEH_ROAD: num_rvs++; break;
|
||||
case VEH_AIRCRAFT: num_aircraft++; break;
|
||||
case VEH_SHIP: num_ships++; break;
|
||||
}
|
||||
}
|
||||
|
||||
IConsolePrint(CC_INFO, "Number of trains: {}", num_trains);
|
||||
IConsolePrint(CC_INFO, "Number of rvs: {}", num_rvs);
|
||||
IConsolePrint(CC_INFO, "Number of ships: {}", num_ships);
|
||||
IConsolePrint(CC_INFO, "Number of aircraft: {}", num_aircraft);
|
||||
IConsolePrint(CC_INFO, "Total number of vehicles: {}", num_trains + num_rvs + num_ships + num_aircraft);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace citymania
|
||||
|
||||
@@ -20,6 +20,7 @@ void ExecuteFakeCommands(Date date, DateFract date_fract);
|
||||
|
||||
bool ConStartRecord(byte argc, char *argv[]);
|
||||
bool ConStopRecord(byte argc, char *argv[]);
|
||||
bool ConGameStats(byte argc, char *argv[]);
|
||||
|
||||
} // namespace citymania
|
||||
|
||||
|
||||
@@ -2670,4 +2670,5 @@ void IConsoleStdLibRegister()
|
||||
IConsole::CmdRegister("cmgamespeed", citymania::ConGameSpeed);
|
||||
IConsole::CmdRegister("cmstartrecord", citymania::ConStartRecord);
|
||||
IConsole::CmdRegister("cmstoprecord", citymania::ConStopRecord);
|
||||
IConsole::CmdRegister("cmgamestats", citymania::ConGameStats);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user