Skip to content
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

Fix #8037: assertion failed when reloading AI for last existing company in offline mode #8587

Merged
merged 3 commits into from Jan 22, 2021

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented Jan 18, 2021

Fixes #8037

Motivation / Problem

Reloading AI means deleting and recreating a company.
This is not possible if it's the last existing company in offline mode, as it's the only company in which player can be.

Description

First commit prevents deletion of last existing company.
Second commit prevents the reloading of AI for local company, in the same way stop_ai does it.

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')
@@ -14,6 +14,7 @@
#include "../querystring_gui.h"
#include "../stringfilter_type.h"
#include "../company_base.h"
#include "../company_func.h"
Copy link
Member

@LordAro LordAro Jan 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be extern _local_company instead of an #include ?

Copy link
Contributor Author

@glx22 glx22 Jan 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah should work too.

src/company_cmd.cpp Show resolved Hide resolved
src/console_cmds.cpp Show resolved Hide resolved
@glx22 glx22 force-pushed the fix_8037 branch 3 times, most recently from ec16e6e to 38afa48 Jan 18, 2021
src/ai/ai_gui.cpp Show resolved Hide resolved
@TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Jan 22, 2021

The mention of offline mode triggered something in me, so I did some grepping in the code:

  • 2 instances of offline references
  • 13 instances of singleplayer (5) / single player (8) references

In commits, offline mode is never references, and singleplayer (4) / single player (5) a total of 9 times.

Not sure what we should call non-multiplayer, but for sure we use different names for it currently :) Maybe good to tackle that for this PR already?

@glx22 glx22 merged commit 6b8ad5a into OpenTTD:master Jan 22, 2021
8 checks passed
@glx22 glx22 deleted the fix_8037 branch Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants