Skip to content
Permalink
Browse files

BLADERUNNER: Add Further Missing Default Switch Cases

These are flagged by GCC if -Wswitch-default is enabled.
  • Loading branch information...
digitall committed Oct 7, 2019
1 parent 750b19d commit b87ebdce2101a9943f727168526fe89725ebe759
@@ -202,12 +202,17 @@ bool AIScriptBryant::GoalChanged(int currentGoalNumber, int newGoalNumber) {
AI_Movement_Track_Append(kActorBryant, 331, 0);
AI_Movement_Track_Repeat(kActorBryant);
break;
default:
break;
}
// fallthrough
case 102:
AI_Movement_Track_Append(kActorBryant, 39, 0);
AI_Movement_Track_Repeat(kActorBryant);
break;

default:
break;
}

return false;
@@ -243,6 +248,8 @@ bool AIScriptBryant::UpdateAnimation(int *animation, int *frame) {
*animation = 808;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(808) - 1;
break;
default:
break;
}

*frame = _animationFrame;
@@ -264,6 +271,8 @@ bool AIScriptBryant::ChangeAnimationMode(int mode) {
_animationFrame = 0;
Actor_Set_Goal_Number(kActorBryant, 0);
break;
default:
break;
}
return true;
}
@@ -425,6 +425,9 @@ bool AIScriptBulletBob::UpdateAnimation(int *animation, int *frame) {
*animation = 510;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(510) - 1;
break;

default:
break;
}
*frame = _animationFrame;

@@ -241,6 +241,8 @@ int AIScriptClovis::GetFriendlinessModifierIfGetsClue(int otherActorId, int clue
case kClueMcCoyRetiredLutherLance:
case kClueMcCoyIsInsane:
return -5;
default:
break;
}
return 0;
}
@@ -1500,6 +1502,9 @@ bool AIScriptClovis::ChangeAnimationMode(int mode) {
_animationFrame = 0;
_animationState = 32;
break;

default:
break;
}

return true;
@@ -375,6 +375,8 @@ bool AIScriptCrazylegs::ChangeAnimationMode(int mode) {
case 15:
_flag = true;
break;
default:
break;
}
break;
case 1:
@@ -440,6 +442,8 @@ bool AIScriptCrazylegs::ChangeAnimationMode(int mode) {
_animationFrame = Slice_Animation_Query_Number_Of_Frames(469) - 1;
}
break;
default:
break;
}

return true;
@@ -109,6 +109,9 @@ bool AIScriptDektora::Update() {
case 275:
Actor_Set_Goal_Number(kActorDektora, 276);
break;

default:
break;
}
}
return true;
@@ -1010,6 +1013,9 @@ bool AIScriptDektora::UpdateAnimation(int *animation, int *frame) {
case 2:
Sound_Play(kSfxWHISTLE3, (100 / Random_Query(5, 9)), 0, 0, 50);
break;

default:
break;
}
}

@@ -1037,6 +1043,9 @@ bool AIScriptDektora::UpdateAnimation(int *animation, int *frame) {
case 2:
Sound_Play(kSfxWHISTLE3, (100 / Random_Query(5, 9)), 0, 0, 50);
break;

default:
break;
}
}

@@ -1063,6 +1072,9 @@ bool AIScriptDektora::UpdateAnimation(int *animation, int *frame) {
case 2:
Sound_Play(kSfxWHISTLE3, (100 / Random_Query(5, 9)), 0, 0, 50);
break;

default:
break;
}
}

@@ -1088,6 +1100,9 @@ bool AIScriptDektora::UpdateAnimation(int *animation, int *frame) {
case 2:
Sound_Play(kSfxWHISTLE3, (100 / Random_Query(5, 9)), 0, 0, 50);
break;

default:
break;
}
}

@@ -1341,6 +1356,8 @@ bool AIScriptDektora::ChangeAnimationMode(int mode) {
_animationState = 19;
}
break;
default:
break;
}
_animationFrame = 0;
break;
@@ -1423,6 +1440,9 @@ bool AIScriptDektora::ChangeAnimationMode(int mode) {
_animationState = 37;
_animationFrame = 0;
break;

default:
break;
}
return true;
}
@@ -525,6 +525,9 @@ bool PoliceMazeTargetTrack::tick() {
case 3:
_vm->_policeMaze->_tracks[trackId3]->resetPaused();
break;

default:
break;
}

break;

5 comments on commit b87ebdc

@peterkohaut

This comment has been minimized.

Copy link
Contributor

replied Oct 7, 2019

To be honest, I don't like this commit, it just adding useless clutter for sake of some useless warning... -Wswitch with enum is much more useful

@digitall

This comment has been minimized.

Copy link
Member Author

replied Oct 7, 2019

It is listed as good practice in Bjarne Stroustrup's C++ Core Guidelines. See:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-default

Admittedly it is not necessary as noted by ISO/IEC 9899:1999, section 6.8.4.2:
[...] If no converted case constant expression matches and there is no default label, no part of the switch body is executed.

https://stackoverflow.com/questions/8021321/what-if-i-dont-write-default-in-switch-case

However as it does make this explicit in the code.

@peterkohaut

This comment has been minimized.

Copy link
Contributor

replied Oct 7, 2019

These guidelines are not commandment, just recommendations and we don't have to use them all (and Bjarne told that as well few times). In this case, Blade Runner is using huge switches as part of it's state machine for AI and this change is sadly not adding any code clarity or improving readability (more the other way around).
But ok, it's there already, no need to change it again.

@digitall

This comment has been minimized.

Copy link
Member Author

replied Oct 7, 2019

Unfortunately there are about another 50 or so cases of this so would be pretty erratic to only change half of them.
You have made your view clear. I will revert these changes to the Bladerunner engine shortly.

@peterkohaut

This comment has been minimized.

Copy link
Contributor

replied Oct 7, 2019

no no, sorry i didnt mean that, you don't have to revert them.

Please sign in to comment.
You can’t perform that action at this time.