-
-
Notifications
You must be signed in to change notification settings - Fork 875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch town growth rate and counter to actual game ticks #6763
Conversation
src/saveload/saveload.cpp
Outdated
@@ -266,7 +266,7 @@ | |||
* 196 27778 1.7.x | |||
* 197 27978 1.8.x | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add PR# to comment when bumping revision? Probably needs some discussion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git blame
ftw? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git log -U0 -G "SAVEGAME_VERSION =" src/saveload/saveload.cpp
And get rid of this pointless comment altogether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, loses a lot of otherwise easily findable history that way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean openttd version history? Yeah, will be a bit trickier to get, but saves from the need for someone to constantly update the comment. Like how the hell am I even supposed to know what's next OpenTTD version is going to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The important part here are the savegame versions of the stable branches.
The revisions are not important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't add the 1.8.x. That's wrong.
src/saveload/afterload.cpp
Outdated
t->growth_rate = TownTicksToGameTicks(t->growth_rate & ~0x8000); | ||
} | ||
/* Offset t->grow_counter by t->index to emulate original behaviour of spreading tick calls. */ | ||
t->grow_counter = TownTicksToGameTicks(t->grow_counter) + ((uint32)_tick_counter + t->index) % TOWN_GROWTH_TICKS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would drop "_tick_counter" here.
It rather confuses than affects stuff.
src/town_cmd.cpp
Outdated
t->growth_rate = 250; | ||
/* Spread growth across ticks so even if there are many | ||
* similar towns they're unlikely to grow all at once */ | ||
t->grow_counter = ((uint32)_tick_counter + t->index) % TOWN_GROWTH_TICKS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I would drop "_tick_counter" here.
It rather confuses than affects stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't like it from competitive CB perspective, but it makes sense since if you create a big map with a lot of towns many of them will have exact same growth_rate so will be growing in same tick which I assume can even be a bit laggy in some cases (haven't tested though). I was thinking of making default growth rate calculation to be smooth rather than jump in 50-house steps then it will probably be ok to remove this part but before that I'd leave it be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frosch123 or did you mean drop _tick_counter but leave t->index? Yeah, that would probably work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, leave t->index for the spreading of CPU resources.
But remove _tick_counter since it does not do anything.
src/town_cmd.cpp
Outdated
/* If growth failed wait TOWN_GROWTH_TICKS before retrying */ | ||
i = TOWN_GROWTH_TICKS - 1; | ||
/* If growth failed wait a bit before retrying */ | ||
i = min(t->growth_rate, TOWN_GROWTH_TICKS - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also reduced retry time as it was growing in waves on fast speeds.
Please don't add the "1.8.x" to the savegame version. It won't be 1.8.x. |
This is more of a groundwork type patch rather one doing something particularly useful. It's needed to be settled first as it changes inner workings of town growth and my other town patches are obviously affected by that. But to keep it simple I actually tried to make this patch change as little as possible and not focus on GS API or gameplay changes. Though some stuff still got fixed along the way.
There are three main reasons for this tick conversion
So what it actually changes:
What it does NOT change: