Update to 1.10.0-beta1

This commit is contained in:
dP
2019-10-31 22:24:28 +03:00
parent b84a475e14
commit 599ccf0c2b
1470 changed files with 354219 additions and 16795 deletions
+9 -13
View File
@@ -39,7 +39,6 @@ LinkGraphJob::LinkGraphJob(const LinkGraph &orig) :
* This is on purpose. */
link_graph(orig),
settings(_settings_game.linkgraph),
thread(NULL),
join_date(_date + _settings_game.linkgraph.recalc_time)
{
}
@@ -61,10 +60,9 @@ void LinkGraphJob::EraseFlows(NodeID from)
*/
void LinkGraphJob::SpawnThread()
{
if (!ThreadObject::New(&(LinkGraphSchedule::Run), this, &this->thread, "ottd:linkgraph")) {
this->thread = NULL;
if (!StartNewThread(&this->thread, "ottd:linkgraph", &(LinkGraphSchedule::Run), this)) {
/* Of course this will hang a bit.
* On the other hand, if you want to play games which make this hang noticably
* On the other hand, if you want to play games which make this hang noticeably
* on a platform without threads then you'll probably get other problems first.
* OK:
* If someone comes and tells me that this hangs for him/her, I'll implement a
@@ -79,10 +77,8 @@ void LinkGraphJob::SpawnThread()
*/
void LinkGraphJob::JoinThread()
{
if (this->thread != NULL) {
this->thread->Join();
delete this->thread;
this->thread = NULL;
if (this->thread.joinable()) {
this->thread.join();
}
}
@@ -106,7 +102,7 @@ LinkGraphJob::~LinkGraphJob()
/* The station can have been deleted. Remove all flows originating from it then. */
Station *st = Station::GetIfValid(from.Station());
if (st == NULL) {
if (st == nullptr) {
this->EraseFlows(node_id);
continue;
}
@@ -126,7 +122,7 @@ LinkGraphJob::~LinkGraphJob()
if (from[it->first].Flow() == 0) continue;
StationID to = (*this)[it->first].Station();
Station *st2 = Station::GetIfValid(to);
if (st2 == NULL || st2->goods[this->Cargo()].link_graph != this->link_graph.index ||
if (st2 == nullptr || st2->goods[this->Cargo()].link_graph != this->link_graph.index ||
st2->goods[this->Cargo()].node != it->first ||
(*lg)[node_id][it->first].LastUpdate() == INVALID_DATE) {
/* Edge has been removed. Delete flows. */
@@ -179,7 +175,7 @@ LinkGraphJob::~LinkGraphJob()
void LinkGraphJob::Init()
{
uint size = this->Size();
this->nodes.Resize(size);
this->nodes.resize(size);
this->edges.Resize(size, size);
for (uint i = 0; i < size; ++i) {
this->nodes[i].Init(this->link_graph[i].Supply());
@@ -244,7 +240,7 @@ void Path::Fork(Path *base, uint cap, int free_cap, uint dist)
*/
uint Path::AddFlow(uint new_flow, LinkGraphJob &job, uint max_saturation)
{
if (this->parent != NULL) {
if (this->parent != nullptr) {
LinkGraphJob::Edge edge = job[this->parent->node][this->node];
if (max_saturation != UINT_MAX) {
uint usable_cap = edge.Capacity() * max_saturation / 100;
@@ -274,6 +270,6 @@ Path::Path(NodeID n, bool source) :
capacity(source ? UINT_MAX : 0),
free_capacity(source ? INT_MAX : INT_MIN),
flow(0), node(n), origin(source ? n : INVALID_NODE),
num_children(0), parent(NULL)
num_children(0), parent(nullptr)
{}