MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / SaveGroups

Method SaveGroups

src/openrct2/network/NetworkBase.cpp:1059–1084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1057 }
1058
1059 void NetworkBase::SaveGroups()
1060 {
1061 if (GetMode() == Mode::server)
1062 {
1063 auto& env = GetContext().GetPlatformEnvironment();
1064 auto path = Path::Combine(env.GetDirectoryPath(DirBase::user), u8"groups.json");
1065
1066 json_t jsonGroups = json_t::array();
1067 for (auto& group : group_list)
1068 {
1069 jsonGroups.push_back(group->toJson());
1070 }
1071 json_t jsonGroupsCfg = {
1072 { "default_group", default_group },
1073 { "groups", jsonGroups },
1074 };
1075 try
1076 {
1077 Json::WriteToFile(path, jsonGroupsCfg);
1078 }
1079 catch (const std::exception& ex)
1080 {
1081 LOG_ERROR("Unable to save %s: %s", path.c_str(), ex.what());
1082 }
1083 }
1084 }
1085
1086 void NetworkBase::SetupDefaultGroups()
1087 {

Callers 1

ModifyGroupsFunction · 0.80

Calls 8

GetModeFunction · 0.85
GetContextFunction · 0.85
GetDirectoryPathMethod · 0.80
CombineFunction · 0.50
WriteToFileFunction · 0.50
push_backMethod · 0.45
toJsonMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected