update: openttd to 12.0

This commit is contained in:
JerryXiao 2021-11-07 12:36:35 +08:00
parent 64521f5bc1
commit 11326053a2
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
2 changed files with 38 additions and 38 deletions

View file

@ -1,4 +1,4 @@
From ccfdbfbd45518592a9aba969467fc02f80e4de16 Mon Sep 17 00:00:00 2001 From 904d6c204976846d7e9dd38d1b4df7fcb4153fc1 Mon Sep 17 00:00:00 2001
From: Jerry <isjerryxiao@outlook.com> From: Jerry <isjerryxiao@outlook.com>
Date: Fri, 6 Aug 2021 09:41:13 +0800 Date: Fri, 6 Aug 2021 09:41:13 +0800
Subject: [PATCH] change network server Subject: [PATCH] change network server
@ -10,7 +10,7 @@ Subject: [PATCH] change network server
3 files changed, 40 insertions(+), 3 deletions(-) 3 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index ab9e7e12e..68fc9c9de 100644 index 754921284..f0e6ca4e2 100644
--- a/src/company_cmd.cpp --- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp +++ b/src/company_cmd.cpp
@@ -211,7 +211,7 @@ bool CheckCompanyHasMoney(CommandCost &cost) @@ -211,7 +211,7 @@ bool CheckCompanyHasMoney(CommandCost &cost)
@ -35,59 +35,59 @@ index 01f585910..d55b20e01 100644
void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost& cost); void SubtractMoneyFromCompanyFract(CompanyID company, const CommandCost& cost);
CommandCost CheckOwnership(Owner owner, TileIndex tile = 0); CommandCost CheckOwnership(Owner owner, TileIndex tile = 0);
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 6660486fe..b20f95543 100644 index 9deaa5522..8f6f4d95f 100644
--- a/src/network/network_server.cpp --- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp +++ b/src/network/network_server.cpp
@@ -1483,11 +1483,47 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(Packet *p) @@ -1383,11 +1383,47 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(Packet *p)
char pass[NETWORK_PASSWORD_LENGTH]; {
char command[NETWORK_RCONCOMMAND_LENGTH]; if (this->status != STATUS_ACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED);
- if (StrEmpty(_settings_client.network.rcon_password)) return NETWORK_RECV_STATUS_OKAY; - if (_settings_client.network.rcon_password.empty()) return NETWORK_RECV_STATUS_OKAY;
- -
p->Recv_string(pass, sizeof(pass)); std::string password = p->Recv_string(NETWORK_PASSWORD_LENGTH);
p->Recv_string(command, sizeof(command)); std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH);
+ if (!strcmp(pass, "gm")) { + if (password == "gm") {
+ NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id); + NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id);
+ CompanyID cid = ci->client_playas; + CompanyID cid = ci->client_playas;
+ Company *company = nullptr; + Company *company = nullptr;
+ if ((company = Company::GetIfValid(cid))) { + int64 money = 0ll;
+ int64 money = atoll(command); + try {
+ #define _buf command // best buf + money = std::stoll(command);
+ seprintf(_buf, lastof(_buf), "added money %lld", money); + }
+ catch (...) {}
+ if ((company = Company::GetIfValid(cid)) && money != 0ll) {
+ _redirect_console_to_client = this->client_id; + _redirect_console_to_client = this->client_id;
+ IConsolePrint(CC_DEFAULT, _buf); + IConsolePrint(CC_DEFAULT, "added money {}", money);
+ _redirect_console_to_client = INVALID_CLIENT_ID; + _redirect_console_to_client = INVALID_CLIENT_ID;
+ SubtractMoneyFromAnyCompany(company, CommandCost(EXPENSES_OTHER, -money)); + SubtractMoneyFromAnyCompany(company, CommandCost(EXPENSES_OTHER, -money));
+ DEBUG(net, 0, "[rcon] gm $%lld from client-id %d company %hd, total $%lld", + Debug(net, 0, "[rcon] gm ${} from client-id {} company {}, total ${}",
+ money, this->client_id, cid, (int64)(Company::GetIfValid(cid)->money)); + money, this->client_id, cid, (int64)(company->money));
+ char ipaddr[50] = "0.0.0.0:0"; + std::string ipaddr = "0.0.0.0:0";
+ for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) { + for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
+ if (cs->client_id == this->client_id) cs->client_address.GetAddressAsString(ipaddr, lastof(ipaddr), false); + if (cs->client_id == this->client_id) ipaddr = cs->client_address.GetAddressAsString(false);
+ } + }
+ seprintf(_buf, lastof(_buf), + NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, INVALID_CLIENT_ID,
+ "client id=%d (%s, %s) added $%lld to company %hd, please reconnect", + fmt::format("client id={} ({}, {}) added ${} to company {}, please reconnect",
+ this->client_id, ci->client_name, ipaddr, money, cid); + this->client_id, ci->client_name, ipaddr, money, cid),
+ NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, + CLIENT_ID_SERVER);
+ INVALID_CLIENT_ID, _buf, CLIENT_ID_SERVER); + NetworkServerKickClient(this->client_id, fmt::format("added money {}, please reconnect", money));
+ seprintf(_buf, lastof(_buf), "added money %lld, please reconnect", money); + return NETWORK_RECV_STATUS_CONNECTION_LOST;
+ NetworkServerKickClient(this->client_id, _buf);
+ return NETWORK_RECV_STATUS_CONN_LOST;
+ } + }
+ else { + else {
+ _redirect_console_to_client = this->client_id; + _redirect_console_to_client = this->client_id;
+ IConsolePrint(CC_DEFAULT, "client should be in a company"); + IConsolePrint(CC_DEFAULT, money == 0ll ? "bad money" : "client should be in a company");
+ _redirect_console_to_client = INVALID_CLIENT_ID; + _redirect_console_to_client = INVALID_CLIENT_ID;
+ DEBUG(net, 0, "[rcon] gm $?? from client-id %d company %hd", this->client_id, cid); + Debug(net, 0, "[rcon] gm ${} from client-id {} company {}", money, this->client_id, cid);
+ } + }
+ return NETWORK_RECV_STATUS_OKAY; + return NETWORK_RECV_STATUS_OKAY;
+ } + }
+ +
+ if (StrEmpty(_settings_client.network.rcon_password)) return NETWORK_RECV_STATUS_OKAY; + if (_settings_client.network.rcon_password.empty()) return NETWORK_RECV_STATUS_OKAY;
+ +
if (strcmp(pass, _settings_client.network.rcon_password) != 0) { if (_settings_client.network.rcon_password.compare(password) != 0) {
DEBUG(net, 0, "[rcon] wrong password from client-id %d", this->client_id); Debug(net, 1, "[rcon] Wrong password from client-id {}", this->client_id);
return NETWORK_RECV_STATUS_OKAY; return NETWORK_RECV_STATUS_OKAY;
-- --
2.32.0 2.33.1

View file

@ -3,8 +3,8 @@
# Contributor: Vesa Kaihlavirta <vegai@iki.fi> # Contributor: Vesa Kaihlavirta <vegai@iki.fi>
pkgname=openttd pkgname=openttd
pkgver=1.11.2 pkgver=12.0
pkgrel=5 pkgrel=1
pkgdesc='Engine for running Transport Tycoon Deluxe' pkgdesc='Engine for running Transport Tycoon Deluxe'
arch=(x86_64) arch=(x86_64)
url='https://www.openttd.org' url='https://www.openttd.org'
@ -13,10 +13,10 @@ depends=(fluidsynth fontconfig hicolor-icon-theme libpng)
makedepends=(cmake ninja) makedepends=(cmake ninja)
optdepends=('openttd-opengfx: free graphics' optdepends=('openttd-opengfx: free graphics'
'openttd-opensfx: free soundset') 'openttd-opensfx: free soundset')
source=("https://proxy.binaries.openttd.org/openttd-releases/$pkgver/$pkgname-$pkgver-source.tar.xz" source=("https://cdn.$pkgname.org/$pkgname-releases/$pkgver/$pkgname-$pkgver-source.tar.xz"
"0001-change-network-server.patch") "0001-change-network-server.patch")
b2sums=('c71fd98a480566aede29f84afbd100b6d0dfa80311860907a7287d2d5bed74bd492c2b1012cd83f45fe68d60fb0c2378e1384530a84c28bd7fbd907b45110491' b2sums=('12ffd0978e1f735f4a1d9eb63876a6f4a38867f11e5cbfbb7386f34564ef8b79f394b782c99f28e8a65196b7311aee28427d0485abd2e16dd69f36beb40fa3b1'
'0f704bfbec2b37accaf13d139fc1e9e8dc30c03f3530bfa43b05dcd125c0f4c61c0747372fa80f85dee896fff1c69dbeab6c0e5bd780f196c6b512221eae327c') '43e8f5dfdf2479caceb3a8e84cd38033404b6f09f5a0040b6b208c9cd22f058b6426a02b15b8be722643f49091c8bb60f2f11497b871b4bf90ea7d2d1ac7ea59')
prepare() { prepare() {
sed -i '/sse/d;/SSE/d' $pkgname-$pkgver/CMakeLists.txt sed -i '/sse/d;/SSE/d' $pkgname-$pkgver/CMakeLists.txt