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

Fix spawned monster upgrading #12147

Merged
merged 8 commits into from Apr 25, 2015

Conversation

Projects
None yet
4 participants
@i2amroy
Copy link
Member

commented Apr 24, 2015

Fixes #12106 permanently.

This turns the "spawn a new monster" block of 4 lines or so into a single function that takes a monster id and a tripoint and then returns a pointer to the newly made monster. This function updates the summoned monster's last update check to the current date, instead of leaving it at the default value of 0.

add_zombie(mon);

// Return the non-local copy of the monster
return &zombie(critter_tracker.mon_at(p));

This comment has been minimized.

Copy link
@i2amroy

i2amroy Apr 24, 2015

Author Member

Anyone know of a better way to do this than searching through the critter_tracker again to find the monster we just added? I couldn't think of any better way to get a permanent pointer to the monster.

This comment has been minimized.

Copy link
@BevapDin

BevapDin Apr 24, 2015

Contributor

You could make add_zombie return the new monster, than return add_zombie(...). add_zombie already returns a bool, but is only used in catalua.cpp

But you want to check the result of add_zombie anyway, there are several situations when it wont have add a zombie, calling critter_tracker.mon_at(p) will fail then:

  • the monster id was mon_null,
  • the monsters location is outside the map
  • (most likely) the monster is blacklisted

Edit: I suggest you make the function return the bool from add_zombie directly and let the caller get the monster reference themself, the caller often doesn't need it anyway.

This comment has been minimized.

Copy link
@i2amroy

i2amroy Apr 24, 2015

Author Member

Good points, I'll look into them. Thanks. : )

@Coolthulhu Coolthulhu assigned Coolthulhu and unassigned Coolthulhu Apr 24, 2015

@kevingranade kevingranade merged commit c8bdadd into CleverRaven:master Apr 25, 2015

1 check passed

default
Details

@i2amroy i2amroy deleted the i2amroy:Summoning branch Apr 27, 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.