Feature: GS methods to scroll viewport for players (#6745)

This commit is contained in:
Pavel Stupnikov
2018-04-24 20:19:01 +03:00
committed by frosch
parent 34b63930f5
commit 8e4bce58ea
8 changed files with 128 additions and 1 deletions

View File

@@ -84,6 +84,9 @@
#include "linkgraph/linkgraph_gui.h"
#include "viewport_sprite_sorter.h"
#include "bridge_map.h"
#include "company_base.h"
#include "command_func.h"
#include "network/network_func.h"
#include <map>
@@ -3250,3 +3253,40 @@ void InitializeSpriteSorter()
}
assert(_vp_sprite_sorter != NULL);
}
/**
* Scroll players main viewport.
* @param tile tile to center viewport on
* @param flags type of operation
* @param p1 ViewportScrollTarget of scroll target
* @param p2 company or client id depending on the target
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
if (_current_company != OWNER_DEITY) return CMD_ERROR;
ViewportScrollTarget target = (ViewportScrollTarget)p1;
switch (target) {
case VST_EVERYONE:
break;
case VST_COMPANY:
if (_local_company != (CompanyID)p2) return CommandCost();
break;
case VST_CLIENT:
#ifdef ENABLE_NETWORK
if (_network_own_client_id != (ClientID)p2) return CommandCost();
break;
#else
return CommandCost();
#endif
default:
return CMD_ERROR;
}
if (flags & DC_EXEC) {
ResetObjectToPlace();
ScrollMainWindowToTile(tile);
}
return CommandCost();
}