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

Unable to build any constructionSite of a type, if structures + sites of that type are higher than RCL allows #59

Open
TheRealMaxion opened this issue Oct 4, 2017 · 15 comments

Comments

@TheRealMaxion
Copy link

var structuresCnt = _(roomObjects).filter((i) => i.type == type || i.type == 'constructionSite' && i.structureType == type).size();

For example, if a room had previously been RCL 3, and somehow ends up being RCL 2 with no extensions currently built, and 6 constructionSites for extensions placed (before the downgrade of controller happened), then it is not possible to perform the last build action on any of the sites.

@sparr
Copy link
Contributor

sparr commented Nov 1, 2017

The concept of keeping track of changes in game state that affect the validity of other actions mid-tick-processing is one that is absent from the engine architecture, as far as I've discerned. Due to that, the engine has no way to prevent you from performing the last build step on all the sites in the same tick other than preventing you from doing it to any of them.

@TheRealMaxion
Copy link
Author

Other creep actions seem to get resolved through conflicts just fine, but this one would probably be a lot more involved to resolve.

@sparr
Copy link
Contributor

sparr commented Nov 1, 2017

I am new to the engine source. Can you give me an example of other conflicts that aren't resolved by just processing all of them?

@TheRealMaxion
Copy link
Author

That might be what I mean I guess, where the processing takes it into account so that only the allowed combination of results happens. Like two creeps trying to move to the same tile, or two creeps trying to withdraw the same resource from a container, etc.

@sparr
Copy link
Contributor

sparr commented Nov 1, 2017

withdrawing is easy, because all the necessary information exists in a single entity. simply modifying the target's storage values during the first withdraw causes the later withdraw to [silently] fail.

creeps moving is a special case, with conflicts in the processor/intents/creep/move.js intent handler resolved by processor/intents/movement.js

resolving the build/rcl conflict would require something akin to the creep solution

@WolfWings
Copy link
Contributor

Why is the building completion blocked at all though?

Blocking construction from completing doesn't appear needed since the system supports dynamically disabling Structures as needed to get the room to a legal level already.

If a room gets downgraded with too many extensions built then some of them get disabled (flashing red tint filling the square they're in). Same with labs if the room drops under 6, and all similar situations.

@TheRealMaxion
Copy link
Author

Probably because having the structure as a disabled structure instead of a construction site gives some slight advantages, at least if we ignore the increased cpu cost and code complexity of dealing with disabled structures.

@sparr
Copy link
Contributor

sparr commented Feb 12, 2018

@WolfWings so you're suggesting allowing the excess structures to finish building, then disabling some of the built structures? That's not a terrible idea, but would open a minor exploit where a player could build a whole new RCL worth of extensions/etc ahead of time, and have them become usable the moment the controller upgrades.

@tedivm
Copy link
Contributor

tedivm commented Feb 12, 2018

That would also be a huge advantage for defense, since it's easier to destroy a building that doesn't exist, or stomp a construction site, than it is to tear down already built up structures.

@TheRealMaxion
Copy link
Author

Exactly.

@WolfWings
Copy link
Contributor

@sparr and @tedivm No you wouldn't, because you still can't place ConstructionSite points in excess of your RCL. createConstructionSite will return ERR_RCL_NOT_ENOUGH in that case. :)

But for example:

  • Be at RCL 2
  • Have 4 finished StructureExtension's
  • Bump up to RCL 3
  • Place 2 more ConstructionSite(StructureExtension)'s
  • Drop to RCL 2

Suddenly not being able to complete ANY of those extensions seems broken. The game already prevents excess Structure's from being used, so how does allowing successfully placed ConstructionSite's to always be able to be completed allow for any exploits?

My thinking is that once you successfully place a ConstructionSite? Let it be completed and converted to a true Structure.

@sparr
Copy link
Contributor

sparr commented Feb 12, 2018

Good point, re it being prevented. OK, I retract my objection. Allowing completion and then immediately disabling some of the structures (as if they had existed at the time of the RCL loss) seems like a reasonable solution here.

@TheRealMaxion
Copy link
Author

Agreed.

@sparr
Copy link
Contributor

sparr commented Feb 13, 2018

Now, someone who cares has to code it and PR it :)

@WolfWings
Copy link
Contributor

I'm tracing through the code to write one up actually, why not? I already have 2 minor PRs in, I enjoy tackling lots of small things when I can, good way to learn the codebase! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants