Change FOR_ALL_ cycles to ::Iterate
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -53,3 +53,5 @@ src/os/windows/ottdres.rc
|
||||
|
||||
/game/
|
||||
/openttd
|
||||
grf/.nmlcache/
|
||||
grf/cmclient.grf
|
||||
|
||||
@@ -40,8 +40,7 @@ uint8 GetAnyTownZone(TileIndex tile) {
|
||||
HouseZonesBits next_zone = HZB_BEGIN;
|
||||
uint8 z = 0;
|
||||
|
||||
Town *town;
|
||||
FOR_ALL_TOWNS(town) {
|
||||
for (Town *town : Town::Iterate()) {
|
||||
uint dist = DistanceSquare(tile, town->xy);
|
||||
// town code uses <= for checking town borders (tz0) but < for other zones
|
||||
while (next_zone < HZB_END
|
||||
@@ -87,9 +86,8 @@ void UpdateTownZoning(Town *town, uint32 prev_edge) {
|
||||
}
|
||||
|
||||
void InitializeZoningMap() {
|
||||
Town *town;
|
||||
FOR_ALL_TOWNS(town) {
|
||||
UpdateTownZoning(town, 0);
|
||||
for (Town *t : Town::Iterate()) {
|
||||
UpdateTownZoning(t, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -767,8 +767,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
||||
else break;
|
||||
}
|
||||
|
||||
NetworkClientInfo *ci;
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
||||
if (ci->client_playas == _current_company) {
|
||||
wc = dynamic_cast<WatchCompany*>(FindWindowById(WC_WATCH_COMPANYA, ci->client_id));
|
||||
if (wc != NULL) wc->OnDoCommand(_current_company, tile);
|
||||
|
||||
@@ -1976,8 +1976,7 @@ void CompaniesMonthlyLoop()
|
||||
CompaniesPayInterest();
|
||||
HandleEconomyFluctuations();
|
||||
|
||||
Company *c;
|
||||
FOR_ALL_COMPANIES(c){
|
||||
for (Company *c : Company::Iterate()) {
|
||||
CargoResetPeriods(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +181,7 @@ struct GoalListWindow : public Window {
|
||||
resize->height = d.height;
|
||||
|
||||
uint num = 0;
|
||||
const Goal *s;
|
||||
FOR_ALL_GOALS(s) {
|
||||
for (const Goal *s : Goal::Iterate()) {
|
||||
if (s->company == INVALID_COMPANY || s->company == this->window_number) {
|
||||
num++;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
bool IsReleasedVersion()
|
||||
{
|
||||
return HasBit(_openttd_newgrf_version, 19);
|
||||
return HasBit(_openttd_newgrf_version, 19);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,3 +81,6 @@ const byte _openttd_revision_tagged = 1;
|
||||
* version, thus making comparisons on specific revisions easy.
|
||||
*/
|
||||
const uint32 _openttd_newgrf_version = 1 << 28 | 10 << 24 | 0 << 20 | 0 << 19 | 28004;
|
||||
|
||||
|
||||
const char _citymania_version[] = "20200106-master-m1492a22027 06.01.20";
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
bool IsReleasedVersion()
|
||||
{
|
||||
return HasBit(_openttd_newgrf_version, 19);
|
||||
return HasBit(_openttd_newgrf_version, 19);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ bool IsReleasedVersion()
|
||||
*
|
||||
* <modified> shows a "M", if the binary is made from modified source code.
|
||||
*/
|
||||
const char _openttd_revision[] = "1.10.0-beta1";
|
||||
const char _openttd_revision[] = "1.10.0-beta2";
|
||||
|
||||
/**
|
||||
* The text version of OpenTTD's build date.
|
||||
@@ -48,7 +48,7 @@ const char _openttd_build_date[] = __DATE__ " " __TIME__;
|
||||
/**
|
||||
* The git revision hash of this version.
|
||||
*/
|
||||
const char _openttd_revision_hash[] = "9f50c754ffee52211e61d88e6d5fc296dfc585e0";
|
||||
const char _openttd_revision_hash[] = "18f03a300b12bb022fb3273ff6273c430b28f787";
|
||||
|
||||
/**
|
||||
* Let us know if current build was modified. This detection
|
||||
@@ -82,4 +82,5 @@ const byte _openttd_revision_tagged = 1;
|
||||
*/
|
||||
const uint32 _openttd_newgrf_version = 1 << 28 | 10 << 24 | 0 << 20 | 0 << 19 | 28004;
|
||||
|
||||
|
||||
const char _citymania_version[] = "!!VERSION!! !!DATE!!";
|
||||
|
||||
@@ -535,7 +535,6 @@ extern GameStrings *_current_data;
|
||||
|
||||
void AfterLoadFindBTProCBInfo() {
|
||||
if (_current_data == NULL) return;
|
||||
StoryPageElement *se;
|
||||
|
||||
char buf[15];
|
||||
char *p = buf;
|
||||
@@ -553,18 +552,15 @@ void AfterLoadFindBTProCBInfo() {
|
||||
pn = p - buf + seprintf(p, lastof(buf), "%X:", string_id);
|
||||
bool with_decay = (strncmp(s.c_str(), "STR_TOWN_CLAIMED_CARGOS_DECAY",
|
||||
strlen("STR_TOWN_CLAIMED_CARGOS_DECAY")) == 0);
|
||||
FOR_ALL_STORY_PAGE_ELEMENTS(se) {
|
||||
// DEBUG(misc, 0, "SE: %s", se->text);
|
||||
for (StoryPageElement *se : StoryPageElement::Iterate()) {
|
||||
if (!se->text || strncmp(se->text, buf, pn) != 0) continue;
|
||||
uint req, cargomask, from, decay=0;
|
||||
// DEBUG(misc, 0, "BINGO %s", se->text);
|
||||
if (with_decay) {
|
||||
sscanf(se->text + pn, "%X:%X:%X:%X", &req, &cargomask, &from, &decay);
|
||||
} else {
|
||||
sscanf(se->text + pn, "%X:%X:%X", &req, &cargomask, &from);
|
||||
}
|
||||
uint cargo_id = FindFirstBit(cargomask);
|
||||
// DEBUG(misc, 0, "PARSED %u %u %u %u", req, cargo_id, from, decay);
|
||||
if (!CB_Enabled()) CB_SetCB(true);
|
||||
CB_SetRequirements(cargo_id, req, from, decay);
|
||||
}
|
||||
|
||||
@@ -11,15 +11,14 @@ assert_compile(NUM_CARGO < 256);
|
||||
|
||||
static void CM_EncodeTownsExtraInfo(BitOStream &bs)
|
||||
{
|
||||
Town *t;
|
||||
uint n_affected_towns = 0;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (t->growing_by_chance || t->houses_reconstruction ||
|
||||
t->houses_demolished)
|
||||
n_affected_towns++;
|
||||
}
|
||||
bs.WriteBytes(n_affected_towns, 2);
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (t->growing_by_chance || t->houses_reconstruction ||
|
||||
t->houses_demolished) {
|
||||
bs.WriteBytes(t->index, 2);
|
||||
@@ -42,14 +41,13 @@ static void CM_EncodeTownsGrowthTiles(BitOStream &bs, TownsGrowthTilesIndex &til
|
||||
|
||||
static void CM_EncodeTownsLayoutErrors(BitOStream &bs)
|
||||
{
|
||||
Town *t;
|
||||
uint n_affected_towns = 0;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (t->cb_houses_removed || t->houses_skipped || t->cycles_skipped)
|
||||
n_affected_towns++;
|
||||
}
|
||||
bs.WriteBytes(n_affected_towns, 2);
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (t->cb_houses_removed || t->houses_skipped || t->cycles_skipped) {
|
||||
bs.WriteBytes(t->index, 2);
|
||||
bs.WriteBytes(t->houses_skipped, 2);
|
||||
@@ -87,9 +85,8 @@ static void CM_EncodeTownsCargo(BitOStream &bs)
|
||||
bs.WriteBytes(CB_GetDecay(cargo), 1);
|
||||
}
|
||||
|
||||
Town *t;
|
||||
bs.WriteBytes(Town::GetNumItems(), 2);
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
bs.WriteBytes(t->index, 2);
|
||||
for (uint i = 0; i < n_cb_cargos; i++) {
|
||||
CargoID cargo = cb_cargos[i];
|
||||
|
||||
@@ -80,8 +80,7 @@ static void Save_CMDataAsPSAC() {
|
||||
};
|
||||
|
||||
uint index = 0;
|
||||
PersistentStorage *ps;
|
||||
FOR_ALL_STORAGES(ps) {
|
||||
for (PersistentStorage *ps : PersistentStorage::Iterate()) {
|
||||
if (ps->grfid != CITYMANIA_GRFID)
|
||||
index = max(index, ps->index + 1);
|
||||
}
|
||||
|
||||
@@ -91,8 +91,7 @@ Station::Station(TileIndex tile) :
|
||||
*/
|
||||
Station::~Station()
|
||||
{
|
||||
Town *t;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
// Using poiter comparison instead of cycling cargos
|
||||
if (t->ad_ref_goods_entry >= this->goods &&
|
||||
t->ad_ref_goods_entry < this->goods + NUM_CARGO) {
|
||||
|
||||
@@ -951,8 +951,7 @@ static void DoRegularAdvertising(Town *t) {
|
||||
|
||||
if (t->ad_ref_goods_entry == NULL) {
|
||||
// Pick as ref station and cargo with min rating
|
||||
const Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
for (Station *st : Station::Iterate()) {
|
||||
if (st->owner == _local_company && DistanceManhattan(t->xy, st->xy) <= 20) {
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++)
|
||||
if (st->goods[i].HasRating() && (t->ad_ref_goods_entry == NULL ||
|
||||
|
||||
@@ -896,8 +896,7 @@ public:
|
||||
case TDW_CAPTION_TEXT: {
|
||||
uint16 town_number = 0;
|
||||
uint16 city_number = 0;
|
||||
const Town *t;
|
||||
FOR_ALL_TOWNS(t){
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if(t->larger_town) city_number++;
|
||||
town_number++;
|
||||
}
|
||||
@@ -1557,8 +1556,7 @@ public:
|
||||
}
|
||||
|
||||
const Company *GetCompany() const {
|
||||
Company *c;
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
for (Company *c : Company::Iterate()) {
|
||||
if (c->location_of_HQ != INVALID_TILE
|
||||
&& DistanceMax(c->location_of_HQ, this->town->xy) < 11)
|
||||
return c;
|
||||
@@ -1579,8 +1577,7 @@ public:
|
||||
uint desired_height = 0;
|
||||
auto company = GetCompany();
|
||||
if (company) {
|
||||
const Goal *g;
|
||||
FOR_ALL_GOALS(g) {
|
||||
for(const Goal *g : Goal::Iterate()) {
|
||||
if (g->company == company->index) {
|
||||
desired_height++;
|
||||
}
|
||||
@@ -1632,8 +1629,7 @@ public:
|
||||
case WID_CB_GOALS: {
|
||||
auto company = GetCompany();
|
||||
if (!company) break;
|
||||
const Goal *g;
|
||||
FOR_ALL_GOALS(g) {
|
||||
for(const Goal *g : Goal::Iterate()) {
|
||||
if (g->company != company->index)
|
||||
continue;
|
||||
SetDParamStr(0, g->text);
|
||||
|
||||
@@ -468,6 +468,8 @@ void WatchCompany::OnQueryTextFinished(char *str)
|
||||
seprintf(msg, lastof(msg), "!ban %i %s", this->watched_client, str);
|
||||
NetworkClientSendChatToServer(msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,8 +506,7 @@ void WatchCompany::OnInvalidateData(int data, bool gui_scope)
|
||||
this->company_count_client[i] = 0;
|
||||
}
|
||||
/* Calculate client count into company - network only */
|
||||
NetworkClientInfo *ci;
|
||||
FOR_ALL_CLIENT_INFOS( ci ) {
|
||||
for (NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
||||
if (Company::IsValidID(ci->client_playas)) {
|
||||
company_count_client[ci->client_playas] += 1;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ std::vector<ClosestTownRecord> _closest_cache;
|
||||
void RebuildClosestHash(TileIndex tile) {
|
||||
_closest_cache_ref = INVALID_TILE;
|
||||
_closest_cache.clear();
|
||||
Town *t;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (Town *t : Town::Iterate()) {
|
||||
_closest_cache.push_back(std::make_pair(
|
||||
DistanceManhattan(t->xy, tile), t));
|
||||
}
|
||||
@@ -257,8 +256,7 @@ SpriteID TileZoneCheckUnservedIndustriesEvaluation(TileIndex tile) {
|
||||
SpriteID TileZoneCheckTownZones(TileIndex tile) {
|
||||
HouseZonesBits next_zone = HZB_BEGIN, tz = HZB_END;
|
||||
|
||||
Town *town;
|
||||
FOR_ALL_TOWNS(town) {
|
||||
for (Town *town : Town::Iterate()) {
|
||||
uint dist = DistanceSquare(tile, town->xy);
|
||||
// town code uses <= for checking town borders (tz0) but < for other zones
|
||||
while (next_zone < HZB_END
|
||||
@@ -283,8 +281,7 @@ SpriteID TileZoneCheckTownZones(TileIndex tile) {
|
||||
|
||||
//Check CB town acceptance area
|
||||
SpriteID TileZoneCheckNewCBBorders(TileIndex tile) {
|
||||
Town *town;
|
||||
FOR_ALL_TOWNS(town) {
|
||||
for (Town *town : Town::Iterate()) {
|
||||
if (DistanceSquare(tile, town->xy) <= town->cache.squared_town_zone_radius[0] + 30)
|
||||
return SPR_PALETTE_ZONING_BLACK;
|
||||
}
|
||||
@@ -305,8 +302,7 @@ SpriteID TileZoneCheckCBBorders(TileIndex tile) {
|
||||
|
||||
//Check whether the tile is within citybuilder server town border (where houses could be built)
|
||||
SpriteID TileZoneCheckCBTownBorders(TileIndex tile) {
|
||||
Town *town;
|
||||
FOR_ALL_TOWNS(town) {
|
||||
for (Town *town : Town::Iterate()) {
|
||||
uint32 distMax = DistanceMax(town->xy, tile);
|
||||
if (distMax * distMax < town->cache.squared_town_zone_radius[0]){
|
||||
return SPR_PALETTE_ZONING_GREEN;
|
||||
|
||||
@@ -4,6 +4,7 @@ curdir=`pwd`
|
||||
echo $dir
|
||||
cd $dir
|
||||
wget https://proxy.binaries.openttd.org/openttd-releases/$version/openttd-$version-source.tar.xz
|
||||
#cp ~/Downloads/openttd-$version-source.tar.xz .
|
||||
tar xf openttd-$version-source.tar.xz
|
||||
ttdir=$dir/openttd-$version
|
||||
cp -r $ttdir/* $curdir
|
||||
@@ -13,6 +14,6 @@ find . -type f > $dir/ttd_files
|
||||
cd objs/release
|
||||
make $ttdir/src/rev.cpp
|
||||
cd $curdir
|
||||
cp $ttdir/src/rev.cpp src/
|
||||
cat $dir/ttd_files | xargs git add
|
||||
cp $ttdir/src/rev.cpp src
|
||||
cat $dir/ttd_files | xargs hg add
|
||||
rm -rf $dir
|
||||
|
||||
Reference in New Issue
Block a user