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

GS methods to let company have exclusive access to the industry #8115

Merged
merged 1 commit into from Dec 22, 2020

Conversation

@ldpl
Copy link
Contributor

@ldpl ldpl commented May 5, 2020

This is now build on top of #7912, which is included in the commits. Merge #7912 before this!


This allows GS to set/reset some company as an exclusive consumer or supplier for the industry. Meaning only that company would be able to take from / deliver to this industry.

This will allow multiplayer servers to cover most of the industry sharing scenarios that atm have to be enforced by rules and moderation. For example:

  • Make the company "own" funded industry. (set both consumer/supplier to the founder company).
  • Only allow sharing on primary industries (set exclusive consumer to the first company delivering cargo to the non-primary industry).
  • On competitive servers stop companies from helping each other by delivering cargo to the secondary industry (set the first company as exclusive supplier).

I also decided to remove the unused owner field in the industry structure as it's somewhat related.

GS to test stuff (sets both consumer/supplier to the first company delivering or taking cargo):
ownit.zip

It can probably be better to somehow merge this with #7912 to save on network commands and savegame versions but I've no idea what's the proper way to do that.

@nielsmh
Copy link
Contributor

@nielsmh nielsmh commented May 5, 2020

I don't think we'll run out of savegame versions in the foreseeable future (currently at version 218 out of 65535 max), but saving network command id's is definitely something #7912 and this should do. Merge one of the PRs first, then rework the other to use the same command, perhaps?

@James103
Copy link
Contributor

@James103 James103 commented May 5, 2020

I don't think we'll run out of savegame versions in the foreseeable future (currently at version 218 out of 65535 max)

This is not taking into account that patch packs have already allocated some of the version numbers. How will we distinguish save games made with official OpenTTD versions (1.11 and up) from save games made with various patch packs (Spring 2013, ChillPP, JokerPP), given the fact that we'll start to overlap with Spring 2013 in just 2 savegame versions from now?

@@ -3222,7 +3222,7 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
case STATION_OILRIG: {
const Industry *i = Station::GetByTile(tile)->industry;
const IndustrySpec *is = GetIndustrySpec(i->type);
td->owner[0] = i->owner;
td->owner[0] = OWNER_NONE;
Copy link
Member

@TrueBrain TrueBrain Dec 22, 2020

Choose a reason for hiding this comment

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

I also decided to remove the unused owner field in the industry structure as it's somewhat related.

Do I understand you correctly that it has no effect on the PR if you would not do this? As when reading the patch I was confused by this change, and I do not really see why/how this belongs here?
If I understand you correct, and you are just cleaning up unused stuff, I would prefer this being in its own commit at least, but honestly .. if that is the case, I would not do it at all in this PR. A new PR to clean up these things would be better, as that means this change doesn't distract from the feature itself :)

@TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Dec 22, 2020

This is currently missing a GUI indication to tell an industry is exclusively assigned to a player, right? (checking to see if my patch-reading-skills are correct :D). Would you consider that a problem during gameplay?

@ldpl
Copy link
Contributor Author

@ldpl ldpl commented Dec 22, 2020

Yeah, GUI is missing but that's somewhat intentional as at this point I don't fully know how ppl are going to use this api and what would be the most appropriate thing to do with gui. Also default ui can only show what is happening and can't possibly explain why as only GS itself knows that and imo that's way more important information. So it would be much better to let GS explain things as it see fits and add methods for it to do so if existing aren't enough. For example, I plan to use this thing to limit competition on secondary industries to "first come - first served". Default UI can only show smth like "exclusive to x" but that is almost useless information. Instead I can just write in the story book that gs prevents competition on secondary industries.

So, basically, I think it's ok to add this as it is and do a gui later if it's needed when we have a more clear understanding of what it should show and how.

Copy link
Member

@LordAro LordAro left a comment

code looks fine, except for the probably unnecessary saveload block mentioned in the other PR

Presume you've tested suitably!

@TrueBrain TrueBrain merged commit 9a45a0f into OpenTTD:master Dec 22, 2020
8 checks passed
@ldpl ldpl deleted the industry-sharing branch Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants