Changeset - r23960:7332b2a6afc5
[Not reviewed]
master
0 4 0
glx - 4 years ago 2019-12-16 16:53:40
glx@openttd.org
Codechange: Replace FOR_ALL_GOALS with range-based for loops
4 files changed with 7 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -532,8 +532,7 @@ void ChangeOwnershipOfCompanyItems(Owner
 
	}
 

	
 
	/* Remove Game Script created Goals, CargoMonitors and Story pages. */
 
	Goal *g;
 
	FOR_ALL_GOALS(g) {
 
	for (Goal *g : Goal::Iterate()) {
 
		if (g->company == old_owner) delete g;
 
	}
 

	
src/goal_base.h
Show inline comments
 
@@ -37,7 +37,4 @@ struct Goal : GoalPool::PoolItem<&_goal_
 
	inline ~Goal() { free(this->text); free(this->progress); }
 
};
 

	
 
#define FOR_ALL_GOALS_FROM(var, start) FOR_ALL_ITEMS_FROM(Goal, goal_index, var, start)
 
#define FOR_ALL_GOALS(var) FOR_ALL_GOALS_FROM(var, 0)
 

	
 
#endif /* GOAL_BASE_H */
src/goal_gui.cpp
Show inline comments
 
@@ -66,8 +66,7 @@ struct GoalListWindow : public Window {
 

	
 
		int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
 
		int num = 0;
 
		const Goal *s;
 
		FOR_ALL_GOALS(s) {
 
		for (const Goal *s : Goal::Iterate()) {
 
			if (s->company == INVALID_COMPANY) {
 
				y--;
 
				if (y == 0) {
 
@@ -86,7 +85,7 @@ struct GoalListWindow : public Window {
 
		y -= 2; // "Company specific goals:" line.
 
		if (y < 0) return;
 

	
 
		FOR_ALL_GOALS(s) {
 
		for (const Goal *s : Goal::Iterate()) {
 
			if (s->company == this->window_number) {
 
				y--;
 
				if (y == 0) {
 
@@ -158,8 +157,7 @@ struct GoalListWindow : public Window {
 
		/* Count number of (non) awarded goals. */
 
		uint num_global = 0;
 
		uint num_company = 0;
 
		const Goal *s;
 
		FOR_ALL_GOALS(s) {
 
		for (const Goal *s : Goal::Iterate()) {
 
			if (s->company == INVALID_COMPANY) {
 
				num_global++;
 
			} else if (s->company == this->window_number) {
 
@@ -207,8 +205,7 @@ struct GoalListWindow : public Window {
 
		bool rtl = _current_text_dir == TD_RTL;
 

	
 
		uint num = 0;
 
		const Goal *s;
 
		FOR_ALL_GOALS(s) {
 
		for (const Goal *s : Goal::Iterate()) {
 
			if (global_section ? s->company == INVALID_COMPANY : (s->company == this->window_number && s->company != INVALID_COMPANY)) {
 
				if (IsInsideMM(pos, 0, cap)) {
 
					switch (column) {
 
@@ -278,8 +275,7 @@ struct GoalListWindow : public Window {
 

	
 
		/* Calculate progress column width. */
 
		uint max_width = 0;
 
		Goal *s;
 
		FOR_ALL_GOALS(s) {
 
		for (const Goal *s : Goal::Iterate()) {
 
			if (s->progress != nullptr) {
 
				SetDParamStr(0, s->progress);
 
				StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
src/saveload/goal_sl.cpp
Show inline comments
 
@@ -26,8 +26,7 @@ static const SaveLoad _goals_desc[] = {
 

	
 
static void Save_GOAL()
 
{
 
	Goal *s;
 
	FOR_ALL_GOALS(s) {
 
	for (Goal *s : Goal::Iterate()) {
 
		SlSetArrayIndex(s->index);
 
		SlObject(s, _goals_desc);
 
	}
0 comments (0 inline, 0 general)