git: add4129da071 - main - games/openttd: update OpenTTD to version 12.0

From: Alexey Dokuchaev <danfe_at_FreeBSD.org>
Date: Fri, 22 Oct 2021 10:59:46 UTC
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=add4129da071870c390bfb8845ee9c01fc852f31

commit add4129da071870c390bfb8845ee9c01fc852f31
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2021-10-22 10:57:32 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2021-10-22 10:57:33 +0000

    games/openttd: update OpenTTD to version 12.0
    
    Disable __builtin_mul_overflow() on i386 for the time being as it
    breaks the build.  Yes, they have dropped the leading digit in the
    version scheme; it seems like a common trend, unfortunately.
    
    Reported on:    OpenNET
---
 games/openttd/Makefile                             |   3 +-
 games/openttd/distinfo                             |   6 +-
 games/openttd/files/extra-patch-save-passwords     | 125 ++++++++++-----------
 .../files/patch-src_core_overflowsafe__type.hpp    |  17 +++
 games/openttd/pkg-plist                            |  11 ++
 5 files changed, 93 insertions(+), 69 deletions(-)

diff --git a/games/openttd/Makefile b/games/openttd/Makefile
index 394142317d92..5572550a82d6 100644
--- a/games/openttd/Makefile
+++ b/games/openttd/Makefile
@@ -1,8 +1,7 @@
 # Created by: Alexey Dokuchaev <danfe@FreeBSD.org>
 
 PORTNAME=	openttd
-DISTVERSION=	1.11.2
-PORTREVISION=	1
+DISTVERSION=	12.0
 CATEGORIES=	games
 MASTER_SITES=	https://proxy.binaries.openttd.org/openttd-releases/${DISTVERSION}/
 DISTNAME=	${PORTNAME}-${DISTVERSION}-source
diff --git a/games/openttd/distinfo b/games/openttd/distinfo
index 21966db3a4c7..775fb34dd6f5 100644
--- a/games/openttd/distinfo
+++ b/games/openttd/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1620068733
-SHA256 (openttd-1.11.2-source.tar.xz) = 0fba935a2a815f4fe8cd6dc2e2ae33f72769538731228f848a63b3a6e9482e6d
-SIZE (openttd-1.11.2-source.tar.xz) = 6783972
+TIMESTAMP = 1634464789
+SHA256 (openttd-12.0-source.tar.xz) = bba0fd3800df0370259e642d251f362c7c00b478a2e3531f6ba7f84c1c2b32dc
+SIZE (openttd-12.0-source.tar.xz) = 7307832
diff --git a/games/openttd/files/extra-patch-save-passwords b/games/openttd/files/extra-patch-save-passwords
index 3620a34f7de7..37374d77683d 100644
--- a/games/openttd/files/extra-patch-save-passwords
+++ b/games/openttd/files/extra-patch-save-passwords
@@ -1,71 +1,72 @@
---- src/network/network_func.h	2014-10-21 21:36:31.000000000 +0300
-+++ src/network/network_func.h	2014-11-09 21:37:49.000000000 +0200
-@@ -74,7 +74,8 @@
+--- src/network/network_func.h.orig	2021-10-17 09:31:25 UTC
++++ src/network/network_func.h
+@@ -73,7 +73,8 @@ void NetworkServerShowStatusToConsole();
  bool NetworkServerStart();
  void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci);
- bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);
+ bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_name);
 -
 +void NetworkSavePassword();
 +void NetworkLoadPassword();
  
  void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
- void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string);
---- src/network/network_server.cpp	2014-10-21 21:36:31.000000000 +0300
-+++ src/network/network_server.cpp	2014-11-09 21:37:49.000000000 +0200
-@@ -32,7 +32,7 @@
- #include "../core/pool_func.hpp"
+ void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const std::string &string);
+--- src/network/network_server.cpp.orig	2021-10-17 09:31:25 UTC
++++ src/network/network_server.cpp
+@@ -32,6 +32,7 @@
  #include <mutex>
  #include <condition_variable>
--
+ 
 +#include "../fileio_func.h"
  #include "../safeguards.h"
  
  
-@@ -500,6 +500,7 @@
+@@ -439,6 +440,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Send
  	/* Reset 'lag' counters */
  	this->last_frame = this->last_frame_server = _frame_counter;
  
-+	DEBUG( net, 1, "requesting GAME password" );
++	Debug( net, 1, "requesting GAME password" );
  	Packet *p = new Packet(PACKET_SERVER_NEED_GAME_PASSWORD);
  	this->SendPacket(p);
  	return NETWORK_RECV_STATUS_OKAY;
-@@ -1684,6 +1685,9 @@
- 				IConsolePrintF(CC_DEFAULT, "Auto-removed protection from company #%d", c->index + 1);
+@@ -1563,6 +1565,9 @@ static void NetworkAutoCleanCompanies()
+ 				IConsolePrint(CC_INFO, "Auto-removed protection from company #{}.", c->index + 1);
  				_network_company_states[c->index].months_empty = 0;
  				NetworkServerUpdateCompanyPassworded(c->index, false);
-+                                if (_settings_client.network.save_password) {
-+                                        NetworkSavePassword( );
-+                        	}
++				if (_settings_client.network.save_password) {
++					NetworkSavePassword( );
++				}
  			}
  			/* Is the company empty for autoclean_novehicles-months, and has no vehicles? */
  			if (_settings_client.network.autoclean_novehicles != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_novehicles && vehicles_in_company[c->index] == 0) {
-@@ -1782,6 +1786,9 @@
+@@ -1656,6 +1661,9 @@ void NetworkServerSetCompanyPassword(CompanyID company
+ 	}
  
- 	strecpy(_network_company_states[company_id].password, password, lastof(_network_company_states[company_id].password));
- 	NetworkServerUpdateCompanyPassworded(company_id, !StrEmpty(_network_company_states[company_id].password));
-+        if (_settings_client.network.save_password) {
-+                NetworkSavePassword( );
+ 	NetworkServerUpdateCompanyPassworded(company_id, !_network_company_states[company_id].password.empty());
++	if (_settings_client.network.save_password) {
++		NetworkSavePassword( );
 +	}
  }
  
  /**
-@@ -2206,4 +2213,47 @@
+@@ -2022,6 +2030,49 @@ bool NetworkCompanyHasClients(CompanyID company)
+ 		if (ci->client_playas == company) return true;
  	}
- }
- 
+ 	return false;
++}
++
 +void NetworkSavePassword( )
 +{
 +	static FILE *file_pointer;
 +	char password_file_name[80];
 +
 +	seprintf( password_file_name, lastof(password_file_name), "%u.pwd", _settings_game.game_creation.generation_seed );
-+	DEBUG( net, 0, "Saving companies password to %s", password_file_name );
++	Debug( net, 0, "Saving companies password to %s", password_file_name );
 +	file_pointer = FioFOpenFile( password_file_name, "wb", SAVE_DIR );
 +
 +	if (file_pointer != NULL) {
 +		for( CompanyID l_company = (CompanyID)0; l_company < MAX_COMPANIES; l_company++ ) {
 +			if (NetworkCompanyIsPassworded(l_company)) {
-+				fwrite( _network_company_states[l_company].password, strlen(_network_company_states[l_company].password), 1, file_pointer);
++				fwrite(_network_company_states[l_company].password.c_str(), _network_company_states[l_company].password.size(), 1, file_pointer);
 +			}
 +			fwrite( "\n", 1, 1, file_pointer );
 +		}
@@ -82,56 +83,52 @@
 +	seprintf( password_file_name, lastof(password_file_name), "%u.pwd", _settings_game.game_creation.generation_seed );
 +	file_pointer = FioFOpenFile( password_file_name, "rb", SAVE_DIR );
 +	if (file_pointer != NULL) {
-+		DEBUG( net, 0, "Loading password from %s", password_file_name );
++		Debug( net, 0, "Loading password from %s", password_file_name );
 +		for( CompanyID l_company = (CompanyID)0; l_company < MAX_COMPANIES; l_company++ ) {
 +			fgets( password, sizeof( password), file_pointer);
 +			if (strlen(password)>1) {
 +				fseek( file_pointer, 1L, SEEK_CUR );
-+				strecpy(_network_company_states[l_company].password, password, lastof(_network_company_states[l_company].password));
-+				NetworkServerUpdateCompanyPassworded(l_company, !StrEmpty(_network_company_states[l_company].password));
++				_network_company_states[l_company].password = password;
++				NetworkServerUpdateCompanyPassworded(l_company, !_network_company_states[l_company].password.empty());
 +			}
 +		}
 +	} else {
-+		DEBUG( net, 0, "Password file %s not found", password_file_name );
++		Debug( net, 0, "Password file %s not found", password_file_name );
 +	}
-+}
-+
- #endif /* ENABLE_NETWORK */
---- src/openttd.cpp	2014-10-21 21:36:36.000000000 +0300
-+++ src/openttd.cpp	2014-11-09 21:40:39.000000000 +0200
-@@ -1111,6 +1111,10 @@
- #ifdef ENABLE_NETWORK
- 				if (_network_server) {
- 					seprintf(_network_game_info.map_name, lastof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title);
-+					// Try to load password
-+					if ( _settings_client.network.save_password ) {
-+						NetworkLoadPassword( );
-+					}
- 				}
- #endif /* ENABLE_NETWORK */
+ }
+ 
+ 
+--- src/openttd.cpp.orig	2021-10-17 09:31:25 UTC
++++ src/openttd.cpp
+@@ -1046,6 +1046,10 @@ void SwitchToMode(SwitchMode new_mode)
+ 				OnStartGame(_network_dedicated);
+ 				/* Decrease pause counter (was increased from opening load dialog) */
+ 				DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
++				// Try to load password
++				if (_settings_client.network.save_password) {
++					NetworkLoadPassword( );
++				}
  			}
---- src/settings_type.h	2014-10-21 21:36:35.000000000 +0300
-+++ src/settings_type.h	2014-11-09 21:37:49.000000000 +0200
-@@ -266,6 +266,7 @@
- 	char   last_host[NETWORK_HOSTNAME_LENGTH];            ///< IP address of the last joined server
- 	uint16 last_port;                                     ///< port of the last joined server
- 	bool   no_http_content_downloads;                     ///< do not do content downloads over HTTP
+ 			break;
+ 		}
+--- src/settings_type.h.orig	2021-10-17 09:31:25 UTC
++++ src/settings_type.h
+@@ -296,6 +296,7 @@ struct NetworkSettings {
+ 	std::string last_joined;                              ///< Last joined server
+ 	bool        no_http_content_downloads;                ///< do not do content downloads over HTTP
+ 	UseRelayService use_relay_service;                        ///< Use relay service?
 +	bool   save_password;                                 ///< If password file is used
  };
  
  /** Settings related to the creation of games. */
---- src/table/settings.ini	2014-10-21 21:36:21.000000000 +0300
-+++ src/table/settings.ini	2014-11-09 21:37:49.000000000 +0200
-@@ -3915,6 +3915,12 @@
- def      = false
- cat      = SC_EXPERT
- 
+--- src/table/settings/network_settings.ini.orig	2021-10-17 09:31:25 UTC
++++ src/table/settings/network_settings.ini
+@@ -265,3 +265,8 @@ str      = STR_CONFIG_SETTING_USE_RELAY_SERVICE
+ strhelp  = STR_CONFIG_SETTING_USE_RELAY_SERVICE_HELPTEXT
+ strval   = STR_CONFIG_SETTING_USE_RELAY_SERVICE_NEVER
+ cat      = SC_BASIC
++
 +[SDTC_BOOL]
-+ifdef   = ENABLE_NETWORK
 +var     = network.save_password
-+flags   = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
++flags   = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
 +def     = false
-+
- ; Since the network code (CmdChangeSetting and friends) use the index in this array to decide
- ; which setting the server is talking about all conditional compilation of this array must be at the
- ; end. This isn't really the best solution, the settings the server can tell the client about should
diff --git a/games/openttd/files/patch-src_core_overflowsafe__type.hpp b/games/openttd/files/patch-src_core_overflowsafe__type.hpp
new file mode 100644
index 000000000000..03e53dbc376a
--- /dev/null
+++ b/games/openttd/files/patch-src_core_overflowsafe__type.hpp
@@ -0,0 +1,17 @@
+Avoid the following build error on i386:
+
+ld: error: undefined symbol: _GLOBAL_OFFSET_TABLE_
+>>> referenced by mulodi4.c:19 (/usr/src/contrib/llvm-project/compiler-rt/lib/builtins/mulodi4.c:19)
+>>>               mulodi4.o:(__mulodi4) in archive /usr/lib/libgcc.a
+
+--- src/core/overflowsafe_type.hpp.orig	2021-10-17 09:31:25 UTC
++++ src/core/overflowsafe_type.hpp
+@@ -112,7 +112,7 @@ class OverflowSafeInt (public)
+ 	 */
+ 	inline constexpr OverflowSafeInt& operator *= (const int factor)
+ 	{
+-#ifdef HAS_OVERFLOW_BUILTINS
++#if defined(HAS_OVERFLOW_BUILTINS) && !defined(__i386__)
+ 		const bool is_result_positive = (this->m_value < 0) == (factor < 0); // -ve * -ve == +ve
+ 		if (unlikely(__builtin_mul_overflow(this->m_value, factor, &this->m_value))) {
+ 			this->m_value = is_result_positive ? T_MAX : T_MIN;
diff --git a/games/openttd/pkg-plist b/games/openttd/pkg-plist
index f02729341eae..5af144131cca 100644
--- a/games/openttd/pkg-plist
+++ b/games/openttd/pkg-plist
@@ -17,6 +17,7 @@ man/man6/openttd.6.gz
 %%DATADIR%%/ai/compat_1.9.nut
 %%DATADIR%%/ai/compat_1.10.nut
 %%DATADIR%%/ai/compat_1.11.nut
+%%DATADIR%%/ai/compat_12.nut
 %%DATADIR%%/baseset/no_music.obm
 %%DATADIR%%/baseset/no_sound.obs
 %%DATADIR%%/baseset/openttd.grf
@@ -40,6 +41,7 @@ man/man6/openttd.6.gz
 %%DATADIR%%/game/compat_1.9.nut
 %%DATADIR%%/game/compat_1.10.nut
 %%DATADIR%%/game/compat_1.11.nut
+%%DATADIR%%/game/compat_12.nut
 %%DATADIR%%/lang/afrikaans.lng
 %%DATADIR%%/lang/arabic_egypt.lng
 %%DATADIR%%/lang/basque.lng
@@ -47,6 +49,7 @@ man/man6/openttd.6.gz
 %%DATADIR%%/lang/brazilian_portuguese.lng
 %%DATADIR%%/lang/bulgarian.lng
 %%DATADIR%%/lang/catalan.lng
+%%DATADIR%%/lang/chuvash.lng
 %%DATADIR%%/lang/croatian.lng
 %%DATADIR%%/lang/czech.lng
 %%DATADIR%%/lang/danish.lng
@@ -59,13 +62,16 @@ man/man6/openttd.6.gz
 %%DATADIR%%/lang/faroese.lng
 %%DATADIR%%/lang/finnish.lng
 %%DATADIR%%/lang/french.lng
+%%DATADIR%%/lang/frisian.lng
 %%DATADIR%%/lang/gaelic.lng
 %%DATADIR%%/lang/galician.lng
 %%DATADIR%%/lang/german.lng
 %%DATADIR%%/lang/greek.lng
 %%DATADIR%%/lang/hebrew.lng
+%%DATADIR%%/lang/hindi.lng
 %%DATADIR%%/lang/hungarian.lng
 %%DATADIR%%/lang/icelandic.lng
+%%DATADIR%%/lang/ido.lng
 %%DATADIR%%/lang/indonesian.lng
 %%DATADIR%%/lang/irish.lng
 %%DATADIR%%/lang/italian.lng
@@ -75,9 +81,13 @@ man/man6/openttd.6.gz
 %%DATADIR%%/lang/latvian.lng
 %%DATADIR%%/lang/lithuanian.lng
 %%DATADIR%%/lang/luxembourgish.lng
+%%DATADIR%%/lang/macedonian.lng
 %%DATADIR%%/lang/malay.lng
+%%DATADIR%%/lang/maltese.lng
+%%DATADIR%%/lang/marathi.lng
 %%DATADIR%%/lang/norwegian_bokmal.lng
 %%DATADIR%%/lang/norwegian_nynorsk.lng
+%%DATADIR%%/lang/persian.lng
 %%DATADIR%%/lang/polish.lng
 %%DATADIR%%/lang/portuguese.lng
 %%DATADIR%%/lang/romanian.lng
@@ -94,6 +104,7 @@ man/man6/openttd.6.gz
 %%DATADIR%%/lang/traditional_chinese.lng
 %%DATADIR%%/lang/turkish.lng
 %%DATADIR%%/lang/ukrainian.lng
+%%DATADIR%%/lang/urdu.lng
 %%DATADIR%%/lang/vietnamese.lng
 %%DATADIR%%/lang/welsh.lng
 %%DATADIR%%/scripts/autoexec.scr.example