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

[bugfix] Exise speed attribute from monster. #9007

Merged

Conversation

Projects
None yet
3 participants
@kevingranade
Copy link
Member

commented Sep 15, 2014

Fixes being unable to hit monsters due to superspeed as reported at http://smf.cataclysmdda.com/index.php?topic=7771
Fixes #8991
Fixes #9006
The fix is super long, because there was actually a huge latent bug in that the transition from using monster::speed to creature::get_speed() and friends was stopped part way through, so roughly half the code was using one, and half was using the other.
This was triggered by BevapDin's save/load streamlining, because the old code was actually saving/loading more than it should have and hiding this bug.
The extra good news is that it didn't mutate any values, so it's a rare save/load bug that will go back to normal after applying the fix.

Rivet-the-Zombie added a commit that referenced this pull request Sep 15, 2014

Merge pull request #9007 from kevingranade/fix-superdodge-monsters
[bugfix] Exise speed attribute from monster.

@Rivet-the-Zombie Rivet-the-Zombie merged commit bd401ab into CleverRaven:master Sep 15, 2014

1 check passed

default This has been rescheduled for testing as the 'master' branch has been updated.
@@ -361,7 +361,7 @@ void mdeath::blobsplit(monster *z)
return;
}
monster blob(GetMType((speed < 50 ? "mon_blob_small" : "mon_blob")));
blob.speed = speed;
blob.set_speed_bonus( speed - blob.get_speed_base() );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Sep 15, 2014

Contributor

This should probably set the base speed. The speed bonus is reset and lost at the end of the turn, so every blob ends up with the default speed again. The above should also test the local variable speed, not z->get_speed, because the local variable has been reduces by a random amount and the previous code used the local variable.

Edit: a similar problem might be in mattack::resurrect / mattack::formblob. The speed bonus is gone on the next turn and the function would behave like on the first call.

@@ -1871,6 +1871,8 @@ void monster::load_legacy(std::stringstream & dump) {
// load->int->str->int (possibly shifted)
type = GetMType( legacy_mon_id[idtmp] );

Creature::set_speed_bonus( speed - type->speed );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Sep 15, 2014

Contributor

I think in this situation the base speed is not initialized to the monster type specific value. The monster type is first known at line 1872, the base speed can not be known before that and there is no setting of the based speed afterwards. The speed is actually initialized to 100 in the Creature constructor, but is not monster type specific.

@kevingranade

This comment has been minimized.

Copy link
Member Author

commented Sep 16, 2014

Thanks, I had missed that speed bonus resets every turn.

@kevingranade kevingranade deleted the kevingranade:fix-superdodge-monsters branch Mar 21, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.