Merge branch 'master' into jgrpp
# Conflicts: # CMakeLists.txt # src/3rdparty/md5/md5.h # src/3rdparty/squirrel/squirrel/squtils.h # src/animated_tile.cpp # src/console_func.h # src/core/CMakeLists.txt # src/core/container_func.hpp # src/core/smallstack_type.hpp # src/crashlog.cpp # src/crashlog.h # src/debug.h # src/economy.cpp # src/gamelog.cpp # src/industry_gui.cpp # src/lang/catalan.txt # src/misc_gui.cpp # src/network/network_content.h # src/newgrf.cpp # src/newgrf.h # src/newgrf_config.cpp # src/newgrf_config.h # src/newgrf_gui.cpp # src/os/unix/font_unix.cpp # src/os/windows/crashlog_win.cpp # src/rail_cmd.cpp # src/saveload/animated_tile_sl.cpp # src/script/api/script_tilelist.cpp # src/settings.cpp # src/settingsgen/settingsgen.cpp # src/sl/oldloader_sl.cpp # src/station.cpp # src/station_cmd.cpp # src/stdafx.h # src/strgen/strgen.cpp # src/strgen/strgen_base.cpp # src/table/settings/gui_settings.ini # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_base.h # src/vehicle_cmd.cpp # src/vehicle_gui_base.h # src/viewport_sprite_sorter.h
This commit is contained in:
@@ -65,14 +65,10 @@
|
||||
|
||||
Industry *i = ::Industry::Get(industry_id);
|
||||
|
||||
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
|
||||
if (i->accepts_cargo[j] == cargo_id) {
|
||||
if (IndustryTemporarilyRefusesCargo(i, cargo_id)) return CAS_TEMP_REFUSED;
|
||||
return CAS_ACCEPTED;
|
||||
}
|
||||
}
|
||||
if (!i->IsCargoAccepted(cargo_id)) return CAS_NOT_ACCEPTED;
|
||||
if (IndustryTemporarilyRefusesCargo(i, cargo_id)) return CAS_TEMP_REFUSED;
|
||||
|
||||
return CAS_NOT_ACCEPTED;
|
||||
return CAS_ACCEPTED;
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptIndustry::GetStockpiledCargo(IndustryID industry_id, CargoID cargo_id)
|
||||
@@ -80,15 +76,12 @@
|
||||
if (!IsValidIndustry(industry_id)) return -1;
|
||||
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
|
||||
|
||||
Industry *ind = ::Industry::Get(industry_id);
|
||||
for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
|
||||
CargoID cid = ind->accepts_cargo[i];
|
||||
if (cid == cargo_id) {
|
||||
return ind->incoming_cargo_waiting[i];
|
||||
}
|
||||
}
|
||||
Industry *i = ::Industry::Get(industry_id);
|
||||
|
||||
return -1;
|
||||
int j = i->GetCargoAcceptedIndex(cargo_id);
|
||||
if (j < 0) return -1;
|
||||
|
||||
return i->incoming_cargo_waiting[j];
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptIndustry::GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id)
|
||||
@@ -98,11 +91,10 @@
|
||||
|
||||
const Industry *i = ::Industry::Get(industry_id);
|
||||
|
||||
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] == cargo_id) return i->last_month_production[j];
|
||||
}
|
||||
int j = i->GetCargoProducedIndex(cargo_id);
|
||||
if (j < 0) return -1;
|
||||
|
||||
return -1;
|
||||
return i->last_month_production[j];
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptIndustry::GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id)
|
||||
@@ -112,11 +104,10 @@
|
||||
|
||||
const Industry *i = ::Industry::Get(industry_id);
|
||||
|
||||
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] == cargo_id) return i->last_month_transported[j];
|
||||
}
|
||||
int j = i->GetCargoProducedIndex(cargo_id);
|
||||
if (j < 0) return -1;
|
||||
|
||||
return -1;
|
||||
return i->last_month_transported[j];
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptIndustry::GetLastMonthTransportedPercentage(IndustryID industry_id, CargoID cargo_id)
|
||||
@@ -126,11 +117,10 @@
|
||||
|
||||
const Industry *i = ::Industry::Get(industry_id);
|
||||
|
||||
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] == cargo_id) return ::ToPercent8(i->last_month_pct_transported[j]);
|
||||
}
|
||||
int j = i->GetCargoProducedIndex(cargo_id);
|
||||
if (j < 0) return -1;
|
||||
|
||||
return -1;
|
||||
return ::ToPercent8(i->last_month_pct_transported[j]);
|
||||
}
|
||||
|
||||
/* static */ TileIndex ScriptIndustry::GetLocation(IndustryID industry_id)
|
||||
|
@@ -23,17 +23,13 @@ ScriptIndustryList::ScriptIndustryList()
|
||||
ScriptIndustryList_CargoAccepting::ScriptIndustryList_CargoAccepting(CargoID cargo_id)
|
||||
{
|
||||
for (const Industry *i : Industry::Iterate()) {
|
||||
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
|
||||
if (i->accepts_cargo[j] == cargo_id) this->AddItem(i->index);
|
||||
}
|
||||
if (i->IsCargoAccepted(cargo_id)) this->AddItem(i->index);
|
||||
}
|
||||
}
|
||||
|
||||
ScriptIndustryList_CargoProducing::ScriptIndustryList_CargoProducing(CargoID cargo_id)
|
||||
{
|
||||
for (const Industry *i : Industry::Iterate()) {
|
||||
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] == cargo_id) this->AddItem(i->index);
|
||||
}
|
||||
if (i->IsCargoProduced(cargo_id)) this->AddItem(i->index);
|
||||
}
|
||||
}
|
||||
|
@@ -83,13 +83,7 @@ ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID in
|
||||
if (i->neutral_station != nullptr && !_settings_game.station.serve_neutral_industries) return;
|
||||
|
||||
/* Check if this industry accepts anything */
|
||||
{
|
||||
bool cargo_accepts = false;
|
||||
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
|
||||
if (i->accepts_cargo[j] != CT_INVALID) cargo_accepts = true;
|
||||
}
|
||||
if (!cargo_accepts) return;
|
||||
}
|
||||
if (!i->IsCargoAccepted()) return;
|
||||
|
||||
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED + _settings_game.station.catchment_increase;
|
||||
|
||||
@@ -123,11 +117,7 @@ ScriptTileList_IndustryProducing::ScriptTileList_IndustryProducing(IndustryID in
|
||||
if (i->neutral_station != nullptr && !_settings_game.station.serve_neutral_industries) return;
|
||||
|
||||
/* Check if this industry produces anything */
|
||||
bool cargo_produces = false;
|
||||
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||
if (i->produced_cargo[j] != CT_INVALID) cargo_produces = true;
|
||||
}
|
||||
if (!cargo_produces) return;
|
||||
if (!i->IsCargoProduced()) return;
|
||||
|
||||
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED + _settings_game.station.catchment_increase;
|
||||
|
||||
|
@@ -155,18 +155,14 @@ std::string ScriptScanner::GetConsoleList(bool newest_only) const
|
||||
|
||||
/** Helper for creating a MD5sum of all files within of a script. */
|
||||
struct ScriptFileChecksumCreator : FileScanner {
|
||||
byte md5sum[16]; ///< The final md5sum.
|
||||
MD5Hash md5sum; ///< The final md5sum.
|
||||
Subdirectory dir; ///< The directory to look in.
|
||||
|
||||
/**
|
||||
* Initialise the md5sum to be all zeroes,
|
||||
* so we can easily xor the data.
|
||||
*/
|
||||
ScriptFileChecksumCreator(Subdirectory dir)
|
||||
{
|
||||
this->dir = dir;
|
||||
memset(this->md5sum, 0, sizeof(this->md5sum));
|
||||
}
|
||||
ScriptFileChecksumCreator(Subdirectory dir) : dir(dir) {}
|
||||
|
||||
/* Add the file and calculate the md5 sum. */
|
||||
virtual bool AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename)
|
||||
@@ -174,7 +170,6 @@ struct ScriptFileChecksumCreator : FileScanner {
|
||||
Md5 checksum;
|
||||
uint8 buffer[1024];
|
||||
size_t len, size;
|
||||
byte tmp_md5sum[16];
|
||||
|
||||
/* Open the file ... */
|
||||
FILE *f = FioFOpenFile(filename.c_str(), "rb", this->dir, &size);
|
||||
@@ -185,12 +180,14 @@ struct ScriptFileChecksumCreator : FileScanner {
|
||||
size -= len;
|
||||
checksum.Append(buffer, len);
|
||||
}
|
||||
|
||||
MD5Hash tmp_md5sum;
|
||||
checksum.Finish(tmp_md5sum);
|
||||
|
||||
FioFCloseFile(f);
|
||||
|
||||
/* ... and xor it to the overall md5sum. */
|
||||
for (uint i = 0; i < sizeof(md5sum); i++) this->md5sum[i] ^= tmp_md5sum[i];
|
||||
this->md5sum ^= tmp_md5sum;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -238,7 +235,7 @@ static bool IsSameScript(const ContentInfo *ci, bool md5sum, ScriptInfo *info, S
|
||||
checksum.Scan(".nut", path);
|
||||
}
|
||||
|
||||
return memcmp(ci->md5sum, checksum.md5sum, sizeof(ci->md5sum)) == 0;
|
||||
return ci->md5sum == checksum.md5sum;
|
||||
}
|
||||
|
||||
bool ScriptScanner::HasScript(const ContentInfo *ci, bool md5sum)
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#define SQUIRREL_HELPER_HPP
|
||||
|
||||
#include "squirrel.hpp"
|
||||
#include "../core/smallvec_type.hpp"
|
||||
#include "../economy_type.h"
|
||||
#include "../string_func.h"
|
||||
#include "../tile_type.h"
|
||||
|
Reference in New Issue
Block a user