-
Notifications
You must be signed in to change notification settings - Fork 85
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
Dead end connection #1613
Dead end connection #1613
Conversation
Tested and i love it. |
split overlay code into smaller methods use better render order overDrawCode is more readable and consistent.
its intentional. should it change to |
Maybe use some road sign like 🚫⛔ (easy to confuse with minus) or ❌or something |
I think there is no need for mouse sign in here. it only makes things more confusing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posting updated X texture plus editable SVG source, please drop them together in the same directory
@@ -423,6 +452,15 @@ public class LaneConnectionSubManager : | |||
return true; | |||
} | |||
|
|||
private void AssertLane(uint laneId, bool startNode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this function ends with Assert
call, is that a debug assert? And in release will it do the calculations but no assert?
Declare this function as [Conditional("DEBUG")]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its only called when adding/removing lane connections so its not performance critical. therefore I decided to include it in release build. you never know .... it might help with debugging user errors.
Should I make it conditional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the assert function is marked debug only. i believe it is. So in release this code does nothing, just calculates values and returns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert is not marked as debug.
AssertNotNone
is the only one that is marked as debug. its inconsistent with all the rest of the assert functions.
but that does not matter. I think its a good idea to execute assert in release mode here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the [Conditional("DEBUG")]
from AssertNotNone()
and instead added #if DEBUG around the usage. so now its consistent
if (!HasOutgoingConnections(laneId, startNode)) { | ||
const bool RESET = false; // reset lane arrows when last lane connection is removed. | ||
|
||
if (RESET && !HasOutgoingConnections(laneId, startNode)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if (false &&
is probably a source of a compiler warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not (and should not) cause compiler warnings. its a legit thing to do.
we do that all the time when logging:
#if DEBUG
private bool verbose_ => DebugSwitch.LaneConnections.Get();
#else
private const bool verbose_ = false;
#endif
if(verbose_ ) ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I understand if you feel like its unnecessary code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some small things. can't speak much for the logic itself since i m not deep enough in the details. krzy should def. check it out.
canConnect = | ||
IsDirectionValid(ref sourceNetLane, sourceLaneInfo, nodeId, true) && | ||
IsDirectionValid(ref targetNetLane, targetLaneInfo, nodeId, false); | ||
canConnect = IsDirectionValid(ref sourceNetLane, sourceLaneInfo, nodeId, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ternary expression for the win
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notice the &=
operator. won't fit well with ternary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true! I didn't see that at first.
wouldn't it be better to encapsulate the logic in the isdirectionvalid method itself?
since the method with the change now only does a "90% job".
if (sourceLaneId == targetLaneId) { | ||
return false; | ||
} | ||
bool deadEnd = sourceLaneId == targetLaneId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd move it down where its used first. just a small thing.
@@ -392,8 +393,36 @@ public class LaneConnectionSubManager : | |||
} | |||
} | |||
|
|||
var connections = GetLaneConnections(sourceLaneId, sourceStartNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be its own method right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what can be its own method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically the whole block that was added.
than again, I can't think of a good name, probably because these are actually two different things that are happening here based on deadEnd. I'd do it the other way around.
if (deadEnd)
removeNonDeadEndConnections()
else
removeDeadEndConnection()
and move the laneId loop inside.
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be two one line functions (unless if you count in the verbose log). Not sure this is a good idea.
if (!HasOutgoingConnections(laneId, startNode)) { | ||
const bool RESET = false; // reset lane arrows when last lane connection is removed. | ||
|
||
if (RESET && !HasOutgoingConnections(laneId, startNode)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also dont get the point of this code. i understand it for #ifdef but whats the point here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool I remove it.
@@ -423,6 +452,15 @@ public class LaneConnectionSubManager : | |||
return true; | |||
} | |||
|
|||
private void AssertLane(uint laneId, bool startNode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably AssertDeadEndConnection would be a better method name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i should also add IsValidWithSegment()
too. i mean if we are asserting stuff we might as well do it right.
@kianzarrin dead end icon is not visible if you close tool and open again. |
avoided code duplication to prevent such issues in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks ok, I hadn't got a chance to test it in game yet.
should I wait? |
Yeah, you can wait, I'll do a quick test later today. Do you have any other plans with this feature or something else? |
nope this is the last one in the series of the lane connection EPIC issue #1479. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backspace/Delete does not reset lane arrows on dead-end lanes just like removing dead-end manually does
OK I reset all lane arrow for node regardless of whether or not it had lane connection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seems to be working now
fixes #1213: Connecting a lane to itself creates dead end
TMPE.zip
it looks like this:

Note: as it was the case already: if a lane cannot have a possible target, then laneEnd node maker will not be displayed.
data base:
lane arrows:
when user hovers over same lane :