Skip to content

Commit

Permalink
Merge branch 'master' into water_region_pathfinder
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuhnovic committed Jan 7, 2024
2 parents 67038fd + 6bf7a86 commit 3ce56d6
Show file tree
Hide file tree
Showing 243 changed files with 3,055 additions and 2,573 deletions.
18 changes: 15 additions & 3 deletions cmake/scripts/SquirrelExport.cmake
Expand Up @@ -71,13 +71,23 @@ reset_reader()

file(STRINGS "${SCRIPT_API_FILE}" SOURCE_LINES)

set(NUM_LINE 0)
macro(doxygen_check)
if(NOT "${DOXYGEN_SKIP}" STREQUAL "")
message(FATAL_ERROR "${SCRIPT_API_FILE}:${NUM_LINE}: a DOXYGEN_API block was not properly closed")
endif()
endmacro()

foreach(LINE IN LISTS SOURCE_LINES)
math(EXPR NUM_LINE "${NUM_LINE} + 1")
# Ignore special doxygen blocks
if("${LINE}" MATCHES "^#ifndef DOXYGEN_API")
doxygen_check()
set(DOXYGEN_SKIP "next")
continue()
endif()
if("${LINE}" MATCHES "^#ifdef DOXYGEN_API")
doxygen_check()
set(DOXYGEN_SKIP "true")
continue()
endif()
Expand All @@ -86,10 +96,10 @@ foreach(LINE IN LISTS SOURCE_LINES)
continue()
endif()
if("${LINE}" MATCHES "^#else")
if("${DOXYGEN_SKIP}" STREQUAL "next")
if(DOXYGEN_SKIP STREQUAL "next")
set(DOXYGEN_SKIP "true")
else()
unset(DOXYGEN_SKIP)
elseif(DOXYGEN_SKIP STREQUAL "true")
set(DOXYGEN_SKIP "false")
endif()
continue()
endif()
Expand Down Expand Up @@ -668,4 +678,6 @@ foreach(LINE IN LISTS SOURCE_LINES)
endif()
endforeach()

doxygen_check()

configure_file(${SCRIPT_API_SOURCE_FILE} ${SCRIPT_API_BINARY_FILE})
4 changes: 4 additions & 0 deletions docs/eints.md
Expand Up @@ -25,6 +25,10 @@ The translators will decide whether, where and how to apply your suggestion.

Sorry, we don't offer this option.

Only when there is a consistency problem that needs addressing, this can be done via a PR.
We are very strict about this, and in general all PRs making translation changes will be closed.
But if it is really needed, and the change is not a revert of any older change, a PR can be created to do mass changes to a translation.

### I want to change the language definition (plural form, genders, cases) of a translation.

Please [create an issue](https://github.com/OpenTTD/OpenTTD/issues/new/choose) for this.
Expand Down
4 changes: 2 additions & 2 deletions src/3rdparty/squirrel/include/squirrel.h
Expand Up @@ -238,7 +238,7 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
static inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.data(), len == -1 ? str.size() : len); }
inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.data(), len == -1 ? str.size() : len); }
void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
void sq_pushbool(HSQUIRRELVM v,SQBool b);
Expand Down Expand Up @@ -308,7 +308,7 @@ SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err, SQInteger len = -1);
static inline SQRESULT sq_throwerror(HSQUIRRELVM v, const std::string_view err) { return sq_throwerror(v, err.data(), err.size()); }
inline SQRESULT sq_throwerror(HSQUIRRELVM v, const std::string_view err) { return sq_throwerror(v, err.data(), err.size()); }
void sq_reseterror(HSQUIRRELVM v);
void sq_getlasterror(HSQUIRRELVM v);

Expand Down
6 changes: 6 additions & 0 deletions src/3rdparty/squirrel/squirrel/sqvm.cpp
Expand Up @@ -116,6 +116,8 @@ SQVM::SQVM(SQSharedState *ss)
_can_suspend = false;
_in_stackoverflow = false;
_ops_till_suspend = 0;
_ops_till_suspend_error_threshold = INT64_MIN;
_ops_till_suspend_error_label = nullptr;
_callsstack = nullptr;
_callsstacksize = 0;
_alloccallsstacksize = 0;
Expand Down Expand Up @@ -744,6 +746,10 @@ bool SQVM::Execute(SQObjectPtr &closure, SQInteger target, SQInteger nargs, SQIn
{
DecreaseOps(1);
if (ShouldSuspend()) { _suspended = SQTrue; _suspended_traps = traps; return true; }
if (IsOpsTillSuspendError()) {
Raise_Error(fmt::format("excessive CPU usage in {}", _ops_till_suspend_error_label));
SQ_THROW();
}

const SQInstruction &_i_ = *ci->_ip++;
#ifdef _DEBUG_DUMP
Expand Down
7 changes: 7 additions & 0 deletions src/3rdparty/squirrel/squirrel/sqvm.h
Expand Up @@ -168,13 +168,20 @@ typedef sqvector<CallInfo> CallInfoVec;

SQBool _can_suspend;
SQInteger _ops_till_suspend;
SQInteger _ops_till_suspend_error_threshold;
const char *_ops_till_suspend_error_label;
SQBool _in_stackoverflow;

bool ShouldSuspend()
{
return _can_suspend && _ops_till_suspend <= 0;
}

bool IsOpsTillSuspendError()
{
return _ops_till_suspend < _ops_till_suspend_error_threshold;
}

void DecreaseOps(SQInteger amount)
{
if (_ops_till_suspend - amount < _ops_till_suspend) _ops_till_suspend -= amount;
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -510,6 +510,7 @@ add_files(
vehiclelist.cpp
vehiclelist.h
vehiclelist_cmd.h
vehiclelist_func.h
viewport.cpp
viewport_cmd.h
viewport_func.h
Expand Down
12 changes: 6 additions & 6 deletions src/autoreplace_func.h
Expand Up @@ -22,7 +22,7 @@ CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, Group
* Remove all engine replacement settings for the given company.
* @param c the company.
*/
static inline void RemoveAllEngineReplacementForCompany(Company *c)
inline void RemoveAllEngineReplacementForCompany(Company *c)
{
RemoveAllEngineReplacement(&c->engine_renew_list);
}
Expand All @@ -36,7 +36,7 @@ static inline void RemoveAllEngineReplacementForCompany(Company *c)
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
{
return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
}
Expand All @@ -48,7 +48,7 @@ static inline EngineID EngineReplacementForCompany(const Company *c, EngineID en
* @param group The group related to this replacement.
* @return true if a replacement was set up, false otherwise.
*/
static inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
{
return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
}
Expand All @@ -60,7 +60,7 @@ static inline bool EngineHasReplacementForCompany(const Company *c, EngineID eng
* @param group The group related to this replacement.
* @return True if a replacement when old was set up, false otherwise.
*/
static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
{
bool replace_when_old;
EngineReplacement(c->engine_renew_list, engine, group, &replace_when_old);
Expand All @@ -77,7 +77,7 @@ static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, Engin
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
{
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
}
Expand All @@ -90,7 +90,7 @@ static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID ol
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
{
return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
}
Expand Down
4 changes: 2 additions & 2 deletions src/autoslope.h
Expand Up @@ -28,7 +28,7 @@
* @param entrance Entrance edge.
* @return true iff terraforming is allowed.
*/
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
{
if (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new)) return false;
return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
Expand All @@ -41,7 +41,7 @@ static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slop
*
* @return true iff autoslope is enabled.
*/
static inline bool AutoslopeEnabled()
inline bool AutoslopeEnabled()
{
return (_settings_game.construction.autoslope &&
(_current_company < MAX_COMPANIES ||
Expand Down
18 changes: 9 additions & 9 deletions src/blitter/32bpp_sse_func.hpp
Expand Up @@ -13,7 +13,7 @@
#ifdef WITH_SSE

GNU_TARGET(SSE_TARGET)
static inline void InsertFirstUint32(const uint32_t value, __m128i &into)
inline void InsertFirstUint32(const uint32_t value, __m128i &into)
{
#if (SSE_VERSION >= 4)
into = _mm_insert_epi32(into, value, 0);
Expand All @@ -24,7 +24,7 @@ static inline void InsertFirstUint32(const uint32_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
static inline void InsertSecondUint32(const uint32_t value, __m128i &into)
inline void InsertSecondUint32(const uint32_t value, __m128i &into)
{
#if (SSE_VERSION >= 4)
into = _mm_insert_epi32(into, value, 1);
Expand All @@ -35,7 +35,7 @@ static inline void InsertSecondUint32(const uint32_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
static inline void LoadUint64(const uint64_t value, __m128i &into)
inline void LoadUint64(const uint64_t value, __m128i &into)
{
#ifdef POINTER_IS_64BIT
into = _mm_cvtsi64_si128(value);
Expand All @@ -50,7 +50,7 @@ static inline void LoadUint64(const uint64_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
{
#if (SSE_VERSION == 2)
from = _mm_and_si128(from, mask); // PAND, wipe high bytes to keep low bytes when packing
Expand All @@ -61,7 +61,7 @@ static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
{
#if (SSE_VERSION == 2)
__m128i alphaAB = _mm_shufflelo_epi16(from, 0x3F); // PSHUFLW, put alpha1 in front of each rgb1
Expand All @@ -73,7 +73,7 @@ static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
{
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8_t into uint16
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
Expand All @@ -97,7 +97,7 @@ static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128
* rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
*/
GNU_TARGET(SSE_TARGET)
static inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
{
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
Expand Down Expand Up @@ -145,7 +145,7 @@ IGNORE_UNINITIALIZED_WARNING_STOP
/** ReallyAdjustBrightness() is not called that often.
* Inlining this function implies a far jump, which has a huge latency.
*/
static inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
{
/* Shortcut for normal brightness. */
if (brightness == Blitter_32bppBase::DEFAULT_BRIGHTNESS) return colour;
Expand All @@ -154,7 +154,7 @@ static inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
}

GNU_TARGET(SSE_TARGET)
static inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
{
#if (SSE_VERSION < 3)
NOT_REACHED();
Expand Down
2 changes: 1 addition & 1 deletion src/bridge.h
Expand Up @@ -63,7 +63,7 @@ bool HasBridgeFlatRamp(Slope tileh, Axis axis);
* @param i The type of bridge to get the specification for.
* @return The specification.
*/
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
inline const BridgeSpec *GetBridgeSpec(BridgeType i)
{
assert(i < lengthof(_bridge));
return &_bridge[i];
Expand Down

0 comments on commit 3ce56d6

Please sign in to comment.