Command & Conquer™ Remastered Collection

Command & Conquer™ Remastered Collection

CFE Patch
A__Gun 10 Jun, 2020 @ 7:59am
Building gap
I've been digging through the code all morning simply because I dislike the inelegance of FluffyQuack's "Let's just loop through every adjacent cell's adjacent cell's" solution and have found the way adjacent cells are actually returned.

From here, its a simple case of using nested loops to cycle through all the cells to check (Just once each, no more doubling up!). An added benefit of this is that you could change the ini option from a binary on/off, to an integer to define how big a gap is allowed. Pseudocode below

MAX_GAP=1 FOR(INT X = -MAX_GAP-1; X < MAX_GAP+2; X++) { FOR(INT Y= -MAX_GAP-1; Y < MAX_GAP+2; Y++) { CELL newCell = cell + (Y*MAP_CELL_W)+X; // DO STUFF WITH CELL } }
< >
Showing 1-15 of 17 comments
A__Gun 10 Jun, 2020 @ 8:00am 
Also your bitbucket link isn't showing, hence posting this here
cfehunter  [developer] 10 Jun, 2020 @ 8:41am 
This doesn't work because buildings aren't always boxes

Edit: Sorry that was a little terse.

Buildings like the refinery aren't boxes, and you can't just test the cells in a larger box around them.
The only solution is a floodfill and a redundant comparison is very likely cheaper than the pointer indirection and allocation you'd need to do to book keep which cells you've tested.

At least while it's this small.
Last edited by cfehunter; 10 Jun, 2020 @ 8:56am
A__Gun 10 Jun, 2020 @ 9:38am 
Originally posted by cfehunter:
Buildings like the refinery aren't boxes, and you can't just test the cells in a larger box around them.

Maybe I'm way off the mark, but what I thought I was proposing was adjusting the method that looks for nearby friendly cells. Whilst I agree that you don't necessarily have to do this in a square, there's no reason not to for these purposes.

The "facing" loop that this replaces does not take the building geometry into account at all - it just looks at the 8 cells that surround the given cell and returns true if at least one of them is friendly.
cfehunter  [developer] 10 Jun, 2020 @ 10:06am 
Sorry I see what you're doing. Yeah that could work.

I have been looking at adapting the cached version the remastered UI uses, but I think it suffers similar issues.
FluffyQuack 10 Jun, 2020 @ 11:32am 
Just to defend my own implementation: I don't always have a lot of free time or motivation to program so I've started to lean more and more towards efficiency. Basically, I try to always go for the simplest implementation while doubling down on making everything as stable as possible (though I guess my mod implementing this isn't the best example as I ended up with adding a bad bug).

And when it comes to time to optimize, I optimize where it matters the most. Your idea would definitely be faster, but it also wouldn't make a difference. As you're optimizing a function which seemingly has zero effect on performance anyway. (That said, it would have a noticeable benefit in that it lets the user choose building gap size.)

And also, if you wanna optimize, where do you stop? I'd say the most obvious thing to optimize in that function is the fact it re-calculates the placement_distance value for *every* tile on the entire map.

Sorry if I sound defensive. This is just the general philosophy I use when programming, or well, any kind of content creation really. I used to be super nitpicky with video quality on my Youtube videos, but I eventually realized no one complained whenever I did a mistake which resulted in worse quality, so I stopped caring about it. And that made it possible to work on more videos rather than spending hours needlessly working on details no one but myself cares about.
cfehunter  [developer] 10 Jun, 2020 @ 11:36am 
Just to update here. I've added configurable build distance to the mod.
AT 10 Jun, 2020 @ 11:39am 
Wow. I almost spilled my drink. Thanks so much guys, on to play now! :D
SuiciSpai 10 Jun, 2020 @ 12:34pm 
Current implementation for some reason does not work on mission 10 (both A and B) of GDI, More noticiable on mision 10A. I cant even place the power plant, everything is red. Removing the mod and restarting the game it worked fine.
mikes @ rogaine 10 Jun, 2020 @ 12:48pm 
yeah I think there's a bug with the latest version? It's like the cell gap is actually -1 (meaning you have to have a cell inside the current structure to be allowed to place the building; but of course you can't place a building on a building - meaning you can't build anything).
This is in all single player missions for me (even after restarting the mission), Skirmish mode seems to work fine
cfehunter  [developer] 10 Jun, 2020 @ 12:51pm 
It seems to be working fine here, make sure you didn't overwrite the new ini file with your old one. There are new settings.

Edit: I've updated the mod to default to a single tile gap even if your ini is broken.
Last edited by cfehunter; 10 Jun, 2020 @ 1:01pm
cfehunter  [developer] 10 Jun, 2020 @ 1:16pm 
There are issues in the campaign I'm just tracking down. Sorry about this.
Pottsy 10 Jun, 2020 @ 1:38pm 
I think your adjustment at 9:01PM for helping people with broken ini files broke the configurable distance :D Can't even build a Power Plant now, and it's forever stuck on -1 build range.

If peoples .ini files are breaking, you can unsubscribe to the mod, and subscribe back and it replaces all the files with fresh ones.

Was working fine up till then :P I went for a run, came back and it was broken as my Workshop pulled updates down while i was out haha

EDIT: Saw your latest patch notes, i guess you already know :)
Last edited by Pottsy; 10 Jun, 2020 @ 1:41pm
cfehunter  [developer] 10 Jun, 2020 @ 1:51pm 
Typically, I found the cause immediately after uploading reverted changes everywhere.
Didn't want to leave people with a broken mod...

Anyway, fixed version coming soon
chrcoluk 10 Jun, 2020 @ 2:14pm 
How would I turn this off and just use the mod to boost tiberium growth only?
A__Gun 11 Jun, 2020 @ 1:19am 
Originally posted by FluffyQuack:
Just to defend my own implementation...

Hey man no offence meant whatsoever! I'm also usually heavily limited on the time I can put into things, just have the (mis)fortune of being out of work at the moment. Big thanks to you and everyone who has made the time to dive in and start experimenting!

You're totally right that this isn't particularly impactful performance-wise, this was more borne out of my own curiosity and compulsive need to keep things neat and tidy.
< >
Showing 1-15 of 17 comments
Per page: 1530 50