1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 04:53:12 +01:00

Add network.currentPlayer plugin API (#11607)

This commit is contained in:
Ted John
2020-05-03 13:53:36 +01:00
committed by GitHub
parent 56b2f49c89
commit 2c153477a6
2 changed files with 12 additions and 0 deletions

View File

@@ -616,6 +616,7 @@ declare global {
readonly numPlayers: number;
readonly groups: PlayerGroup[];
readonly players: Player[];
readonly currentPlayer: Player;
defaultGroup: number;
getServerInfo(): ServerInfo;

View File

@@ -343,6 +343,16 @@ namespace OpenRCT2::Scripting
return players;
}
std::shared_ptr<ScPlayer> currentPlayer_get() const
{
std::shared_ptr<ScPlayer> player;
# ifndef DISABLE_NETWORK
auto playerId = network_get_current_player_id();
player = std::make_shared<ScPlayer>(playerId);
# endif
return player;
}
std::shared_ptr<ScPlayer> getPlayer(int32_t index) const
{
# ifndef DISABLE_NETWORK
@@ -443,6 +453,7 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScNetwork::numPlayers_get, nullptr, "numPlayers");
dukglue_register_property(ctx, &ScNetwork::groups_get, nullptr, "groups");
dukglue_register_property(ctx, &ScNetwork::players_get, nullptr, "players");
dukglue_register_property(ctx, &ScNetwork::currentPlayer_get, nullptr, "currentPlayer");
dukglue_register_property(ctx, &ScNetwork::defaultGroup_get, &ScNetwork::defaultGroup_set, "defaultGroup");
dukglue_register_method(ctx, &ScNetwork::addGroup, "addGroup");
dukglue_register_method(ctx, &ScNetwork::getGroup, "getGroup");