Update: Translations from eints
[openttd-github.git] / src / script / api / script_viewport.cpp
blobb5f85850974aa6a1689dcd20cc0b3eb673d3ac3d
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_viewport.cpp Implementation of ScriptViewport. */
10 #include "../../stdafx.h"
11 #include "script_error.hpp"
12 #include "script_viewport.hpp"
13 #include "script_game.hpp"
14 #include "script_map.hpp"
15 #include "../script_instance.hpp"
16 #include "../../viewport_func.h"
17 #include "../../viewport_cmd.h"
19 #include "../../safeguards.h"
21 /* static */ void ScriptViewport::ScrollTo(TileIndex tile)
23 if (ScriptGame::IsMultiplayer()) return;
24 if (!ScriptMap::IsValidTile(tile)) return;
26 ScrollMainWindowToTile(tile);
29 /* static */ bool ScriptViewport::ScrollEveryoneTo(TileIndex tile)
31 EnforceDeityMode(false);
32 EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
34 return ScriptObject::Command<CMD_SCROLL_VIEWPORT>::Do(tile, VST_EVERYONE, 0);
37 /* static */ bool ScriptViewport::ScrollCompanyClientsTo(ScriptCompany::CompanyID company, TileIndex tile)
39 EnforceDeityMode(false);
40 EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
42 company = ScriptCompany::ResolveCompanyID(company);
43 EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);
45 return ScriptObject::Command<CMD_SCROLL_VIEWPORT>::Do(tile, VST_COMPANY, company);
48 /* static */ bool ScriptViewport::ScrollClientTo(ScriptClient::ClientID client, TileIndex tile)
50 EnforcePrecondition(false, ScriptGame::IsMultiplayer());
51 EnforceDeityMode(false);
52 EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
54 client = ScriptClient::ResolveClientID(client);
55 EnforcePrecondition(false, client != ScriptClient::CLIENT_INVALID);
57 return ScriptObject::Command<CMD_SCROLL_VIEWPORT>::Do(tile, VST_CLIENT, client);