Update: Translations from eints
[openttd-github.git] / src / script / api / script_clientlist.cpp
blobeb57d8e44af54868b8b34ac99ad2ca4fb6eb8569
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file script_clientlist.cpp Implementation of ScriptClientList and friends. */
10 #include "../../stdafx.h"
11 #include "script_company.hpp"
12 #include "script_clientlist.hpp"
13 #include "../../network/network.h"
14 #include "../../network/network_base.h"
16 #include "../../safeguards.h"
18 ScriptClientList::ScriptClientList()
20 if (!_networking) return;
21 for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
22 this->AddItem(ci->client_id);
26 ScriptClientList_Company::ScriptClientList_Company(ScriptCompany::CompanyID company)
28 if (!_networking) return;
29 CompanyID c;
30 if (company == ScriptCompany::COMPANY_SPECTATOR) {
31 c = ::COMPANY_SPECTATOR;
32 } else {
33 company = ScriptCompany::ResolveCompanyID(company);
34 if (company == ScriptCompany::COMPANY_INVALID) return;
35 c = (CompanyID)company;
38 for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
39 if (ci->client_playas == c) this->AddItem(ci->client_id);