Merge branch 'master' into jgrpp
# Conflicts: # src/ai/ai_core.cpp # src/ai/ai_gui.cpp # src/ai/ai_instance.cpp # src/console_cmds.cpp # src/engine_type.h # src/game/game_gui.cpp # src/game/game_instance.cpp # src/goal.cpp # src/goal_cmd.h # src/lang/english.txt # src/lang/estonian.txt # src/network/network_client.cpp # src/newgrf.cpp # src/newgrf_generic.h # src/openttd.cpp # src/saveload/saveload.h # src/script/api/script_log.cpp # src/script/api/script_town.cpp # src/settings_table.cpp # src/station_cmd.cpp # src/station_cmd.h # src/station_map.h # src/strings.cpp # src/table/settings/difficulty_settings.ini # src/table/settings/gui_settings.ini # src/tbtr_template_gui_main.h # src/timetable_cmd.cpp # src/timetable_cmd.h # src/timetable_gui.cpp # src/town_gui.cpp # src/train_gui.cpp # src/water_cmd.cpp
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
*
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li AITown::ROAD_LAYOUT_RANDOM
|
||||
*
|
||||
* \b 13.0
|
||||
*
|
||||
* API additions:
|
||||
|
@@ -17,6 +17,9 @@
|
||||
*
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li GSTown::ROAD_LAYOUT_RANDOM
|
||||
*
|
||||
* \b 13.0
|
||||
*
|
||||
* API additions:
|
||||
|
@@ -15,6 +15,9 @@
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
extern Town *AirportGetNearestTown(const struct AirportSpec *as, const TileIterator &it, uint &mindist);
|
||||
extern uint8 GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance);
|
||||
|
||||
/* static */ bool ScriptAirport::IsValidAirportType(AirportType type)
|
||||
{
|
||||
return IsAirportInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable();
|
||||
@@ -128,9 +131,6 @@
|
||||
|
||||
/* static */ int ScriptAirport::GetNoiseLevelIncrease(TileIndex tile, AirportType type)
|
||||
{
|
||||
extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist);
|
||||
extern uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance);
|
||||
|
||||
if (!::IsValidTile(tile)) return -1;
|
||||
if (!IsAirportInformationAvailable(type)) return -1;
|
||||
|
||||
@@ -149,8 +149,6 @@
|
||||
|
||||
/* static */ TownID ScriptAirport::GetNearestTown(TileIndex tile, AirportType type)
|
||||
{
|
||||
extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it, uint &mindist);
|
||||
|
||||
if (!::IsValidTile(tile)) return INVALID_TOWN;
|
||||
if (!IsAirportInformationAvailable(type)) return INVALID_TOWN;
|
||||
|
||||
|
@@ -13,33 +13,36 @@
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ uint32 ScriptBase::Rand()
|
||||
/* static */ SQInteger ScriptBase::Rand()
|
||||
{
|
||||
return ScriptObject::GetRandomizer().Next();
|
||||
}
|
||||
|
||||
/* static */ uint32 ScriptBase::RandItem(int unused_param)
|
||||
/* static */ SQInteger ScriptBase::RandItem(SQInteger unused_param)
|
||||
{
|
||||
return ScriptBase::Rand();
|
||||
}
|
||||
|
||||
/* static */ uint ScriptBase::RandRange(uint max)
|
||||
/* static */ SQInteger ScriptBase::RandRange(SQInteger max)
|
||||
{
|
||||
max = Clamp<SQInteger>(max, 0, UINT32_MAX);
|
||||
return ScriptObject::GetRandomizer().Next(max);
|
||||
}
|
||||
|
||||
/* static */ uint32 ScriptBase::RandRangeItem(int unused_param, uint max)
|
||||
/* static */ SQInteger ScriptBase::RandRangeItem(SQInteger unused_param, SQInteger max)
|
||||
{
|
||||
return ScriptBase::RandRange(max);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptBase::Chance(uint out, uint max)
|
||||
/* static */ bool ScriptBase::Chance(SQInteger out, SQInteger max)
|
||||
{
|
||||
out = Clamp<SQInteger>(out, 0, UINT32_MAX);
|
||||
max = Clamp<SQInteger>(max, 0, UINT32_MAX);
|
||||
EnforcePrecondition(false, out <= max);
|
||||
return ScriptBase::RandRange(max) < out;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptBase::ChanceItem(int unused_param, uint out, uint max)
|
||||
/* static */ bool ScriptBase::ChanceItem(SQInteger unused_param, SQInteger out, SQInteger max)
|
||||
{
|
||||
return ScriptBase::Chance(out, max);
|
||||
}
|
||||
|
@@ -25,50 +25,56 @@ public:
|
||||
* Get a random value.
|
||||
* @return A random value between 0 and MAX(uint32).
|
||||
*/
|
||||
static uint32 Rand();
|
||||
static SQInteger Rand();
|
||||
|
||||
/**
|
||||
* Get a random value.
|
||||
* @param unused_param This parameter is not used, but is needed to work with lists.
|
||||
* @return A random value between 0 and MAX(uint32).
|
||||
*/
|
||||
static uint32 RandItem(int unused_param);
|
||||
static SQInteger RandItem(SQInteger unused_param);
|
||||
|
||||
/**
|
||||
* Get a random value in a range.
|
||||
* @param max The first number this function will never return (the maximum it returns is max - 1).
|
||||
* The value will be clamped to 0 .. MAX(uint32).
|
||||
* @return A random value between 0 .. max - 1.
|
||||
*/
|
||||
static uint RandRange(uint max);
|
||||
static SQInteger RandRange(SQInteger max);
|
||||
|
||||
/**
|
||||
* Get a random value in a range.
|
||||
* @param unused_param This parameter is not used, but is needed to work with lists.
|
||||
* @param max The first number this function will never return (the maximum it returns is max - 1).
|
||||
* The value will be clamped to 0 .. MAX(uint32).
|
||||
* @return A random value between 0 .. max - 1.
|
||||
*/
|
||||
static uint RandRangeItem(int unused_param, uint max);
|
||||
static SQInteger RandRangeItem(SQInteger unused_param, SQInteger max);
|
||||
|
||||
/**
|
||||
* Returns approximately 'out' times true when called 'max' times.
|
||||
* After all, it is a random function.
|
||||
* @param out How many times it should return true.
|
||||
* The value will be clamped to 0 .. MAX(uint32).
|
||||
* @param max Out of this many times.
|
||||
* The value will be clamped to 0 .. MAX(uint32).
|
||||
* @pre \a out is at most equal to \a max.
|
||||
* @return True if the chance worked out.
|
||||
*/
|
||||
static bool Chance(uint out, uint max);
|
||||
static bool Chance(SQInteger out, SQInteger max);
|
||||
|
||||
/**
|
||||
* Returns approximately 'out' times true when called 'max' times.
|
||||
* After all, it is a random function.
|
||||
* @param unused_param This parameter is not used, but is needed to work with lists.
|
||||
* @param out How many times it should return true.
|
||||
* The value will be clamped to 0 .. MAX(uint32).
|
||||
* @param max Out of this many times.
|
||||
* The value will be clamped to 0 .. MAX(uint32).
|
||||
* @pre \a out is at most equal to \a max.
|
||||
* @return True if the chance worked out.
|
||||
*/
|
||||
static bool ChanceItem(int unused_param, uint out, uint max);
|
||||
static bool ChanceItem(SQInteger unused_param, SQInteger out, SQInteger max);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_BASE_HPP */
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#include "../script_info.hpp"
|
||||
#include "../script_instance.hpp"
|
||||
#include "script_log.hpp"
|
||||
#include "../../ai/ai_gui.hpp"
|
||||
#include "../script_gui.h"
|
||||
#include "../../settings_type.h"
|
||||
#include "../../network/network.h"
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
/* Inform script developer that their script has been paused and
|
||||
* needs manual action to continue. */
|
||||
ShowAIDebugWindow(ScriptObject::GetRootCompany());
|
||||
ShowScriptDebugWindow(ScriptObject::GetRootCompany());
|
||||
|
||||
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {
|
||||
ScriptObject::DoCommand(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
|
||||
|
@@ -381,7 +381,7 @@ public:
|
||||
* @param owner The company that can be bought.
|
||||
* @param value The value/costs of buying the company.
|
||||
*/
|
||||
ScriptEventCompanyAskMerger(Owner owner, int32 value) :
|
||||
ScriptEventCompanyAskMerger(Owner owner, Money value) :
|
||||
ScriptEvent(ET_COMPANY_ASK_MERGER),
|
||||
owner((ScriptCompany::CompanyID)owner),
|
||||
value(value)
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
* Get the value of the new company.
|
||||
* @return The value of the new company.
|
||||
*/
|
||||
int32 GetValue() { return this->value; }
|
||||
Money GetValue() { return this->value; }
|
||||
|
||||
/**
|
||||
* Take over the company for this merger.
|
||||
@@ -416,7 +416,7 @@ public:
|
||||
|
||||
private:
|
||||
ScriptCompany::CompanyID owner; ///< The company that is in trouble.
|
||||
int32 value; ///< The value of the company, i.e. the amount you would pay.
|
||||
Money value; ///< The value of the company, i.e. the amount you would pay.
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -120,7 +120,7 @@
|
||||
EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT));
|
||||
EnforcePrecondition(false, (int)type < ::GQT_END);
|
||||
|
||||
return ScriptObject::DoCommand(0, uniqueid | (target << 16), buttons | (type << 29) | (is_client ? (1 << 31) : 0), CMD_GOAL_QUESTION, text);
|
||||
return ScriptObject::DoCommandEx(0, uniqueid, buttons | (type << 29) | (is_client ? (1 << 31) : 0), target, CMD_GOAL_QUESTION, text);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons)
|
||||
@@ -136,8 +136,6 @@
|
||||
{
|
||||
EnforcePrecondition(false, ScriptGame::IsMultiplayer());
|
||||
EnforcePrecondition(false, ScriptClient::ResolveClientID(client) != ScriptClient::CLIENT_INVALID);
|
||||
/* Can only send 16 bits of client_id before proper fix is implemented */
|
||||
EnforcePrecondition(false, client < (1 << 16));
|
||||
return DoQuestion(uniqueid, client, true, question, type, buttons);
|
||||
}
|
||||
|
||||
|
@@ -28,9 +28,9 @@ public:
|
||||
/**
|
||||
* The goal IDs.
|
||||
*/
|
||||
enum GoalID {
|
||||
enum GoalID : uint16 {
|
||||
/* Note: these values represent part of the in-game GoalID enum */
|
||||
GOAL_INVALID = ::INVALID_GOALTYPE, ///< An invalid goal id.
|
||||
GOAL_INVALID = ::INVALID_GOAL, ///< An invalid goal id.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
* @pre question != null && len(question) != 0.
|
||||
* @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
|
||||
* @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3.
|
||||
* @note Replies to the question are given by you via the event ScriptEvent_GoalQuestionAnswer.
|
||||
* @note Replies to the question are given by you via the event ScriptEventGoalQuestionAnswer.
|
||||
* @note There is no guarantee you ever get a reply on your question.
|
||||
*/
|
||||
static bool Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons);
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
* @pre question != null && len(question) != 0.
|
||||
* @pre ResolveClientID(client) != CLIENT_INVALID.
|
||||
* @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3.
|
||||
* @note Replies to the question are given by you via the event ScriptEvent_GoalQuestionAnswer.
|
||||
* @note Replies to the question are given by you via the event ScriptEventGoalQuestionAnswer.
|
||||
* @note There is no guarantee you ever get a reply on your question.
|
||||
*/
|
||||
static bool QuestionClient(uint16 uniqueid, ScriptClient::ClientID client, Text *question, QuestionType type, int buttons);
|
||||
|
@@ -75,7 +75,7 @@
|
||||
|
||||
/* Also still print to debug window */
|
||||
DEBUG(script, level, "[%d] [%c] %s", (uint)ScriptObject::GetRootCompany(), logc, log->lines[log->pos]);
|
||||
InvalidateWindowData(WC_AI_DEBUG, 0, ScriptObject::GetRootCompany());
|
||||
InvalidateWindowData(WC_SCRIPT_DEBUG, 0, ScriptObject::GetRootCompany());
|
||||
}
|
||||
|
||||
/* static */ void ScriptLog::FreeLogPointer()
|
||||
|
@@ -79,7 +79,7 @@
|
||||
|
||||
/* static */ int32 ScriptSubsidy::GetSourceIndex(SubsidyID subsidy_id)
|
||||
{
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_SOURCE;
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->src;
|
||||
}
|
||||
@@ -93,7 +93,7 @@
|
||||
|
||||
/* static */ int32 ScriptSubsidy::GetDestinationIndex(SubsidyID subsidy_id)
|
||||
{
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_SOURCE;
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->dst;
|
||||
}
|
||||
|
@@ -290,7 +290,7 @@
|
||||
EnforcePrecondition(false, size == TOWN_SIZE_SMALL || size == TOWN_SIZE_MEDIUM || size == TOWN_SIZE_LARGE)
|
||||
EnforcePrecondition(false, size != TOWN_SIZE_LARGE || ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
if (ScriptObject::GetCompany() == OWNER_DEITY || _settings_game.economy.found_town == TF_CUSTOM_LAYOUT) {
|
||||
EnforcePrecondition(false, layout == ROAD_LAYOUT_ORIGINAL || layout == ROAD_LAYOUT_BETTER_ROADS || layout == ROAD_LAYOUT_2x2 || layout == ROAD_LAYOUT_3x3);
|
||||
EnforcePrecondition(false, layout >= ROAD_LAYOUT_ORIGINAL && layout <= ROAD_LAYOUT_RANDOM);
|
||||
} else {
|
||||
/* The layout parameter is ignored for AIs when custom layouts is disabled. */
|
||||
layout = (RoadLayout) (byte)_settings_game.economy.town_layout;
|
||||
@@ -361,10 +361,7 @@
|
||||
int16 new_rating = Clamp(t->ratings[company] + delta, RATING_MINIMUM, RATING_MAXIMUM);
|
||||
if (new_rating == t->ratings[company]) return false;
|
||||
|
||||
uint16 p2 = 0;
|
||||
memcpy(&p2, &new_rating, sizeof(p2));
|
||||
|
||||
return ScriptObject::DoCommand(0, town_id | (company_id << 16), p2, CMD_TOWN_RATING);
|
||||
return ScriptObject::DoCommand(0, town_id | (company_id << 16), new_rating, CMD_TOWN_RATING);
|
||||
}
|
||||
|
||||
/* static */ int ScriptTown::GetAllowedNoise(TownID town_id)
|
||||
|
@@ -98,6 +98,7 @@ public:
|
||||
ROAD_LAYOUT_BETTER_ROADS = ::TL_BETTER_ROADS, ///< Extended original algorithm (min. 2 distance between roads).
|
||||
ROAD_LAYOUT_2x2 = ::TL_2X2_GRID, ///< Geometric 2x2 grid algorithm
|
||||
ROAD_LAYOUT_3x3 = ::TL_3X3_GRID, ///< Geometric 3x3 grid algorithm
|
||||
ROAD_LAYOUT_RANDOM = ::TL_RANDOM, ///< Random road layout
|
||||
|
||||
/* Custom added value, only valid for this API */
|
||||
ROAD_LAYOUT_INVALID = -1, ///< The layout for invalid towns.
|
||||
|
Reference in New Issue
Block a user