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 dynamic npc timer mismatch #8265

Merged
merged 6 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/map/buyingstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ void do_init_buyingstore_autotrade( void ) {

// initialize player
CREATE(at->sd, map_session_data, 1); // TODO: Dont use Memory Manager allocation anymore and rely on the C++ container
new (at->sd) map_session_data();
pc_setnewpc(at->sd, at->account_id, at->char_id, 0, gettick(), at->sex, 0);
at->sd->state.autotrade = 1|4;
if (battle_config.autotrade_monsterignore)
Expand Down
5 changes: 5 additions & 0 deletions src/map/mob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
mvptomb_destroy(md);

CREATE(nd, struct npc_data, 1);
new (nd) npc_data();

nd->bl.id = md->tomb_nid = npc_get_new_npc_id();

Expand All @@ -213,6 +214,10 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
nd->u.tomb.kill_time = time;
nd->u.tomb.spawn_timer = INVALID_TIMER;

nd->dynamicnpc.owner_char_id = 0;
nd->dynamicnpc.last_interaction = 0;
nd->dynamicnpc.removal_tid = INVALID_TIMER;

if (killer)
safestrncpy(nd->u.tomb.killer_name, killer, NAME_LENGTH);
else
Expand Down
4 changes: 1 addition & 3 deletions src/map/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9417,9 +9417,7 @@ void status_change_init(struct block_list *bl)
{
status_change *sc = status_get_sc(bl);
nullpo_retv(sc);
memset(sc, 0, sizeof (status_change));
sc->lastEffect = SC_NONE;
sc->lastEffectTimer = INVALID_TIMER;
new (sc) status_change;
vstumpf marked this conversation as resolved.
Show resolved Hide resolved
}

/*========================================== [Playtester]
Expand Down
24 changes: 12 additions & 12 deletions src/map/status.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3253,13 +3253,13 @@ struct status_change_entry {
///Status change
class status_change {
public:
Lemongrass3110 marked this conversation as resolved.
Show resolved Hide resolved
unsigned int option;// effect state (bitfield)
unsigned int opt3;// skill state (bitfield)
unsigned short opt1;// body state
unsigned short opt2;// health state (bitfield)
unsigned char count;
sc_type lastEffect; // Used to check for stacking damageable SC on the same attack
int32 lastEffectTimer; // Timer for lastEffect
unsigned int option{};// effect state (bitfield)
unsigned int opt3{};// skill state (bitfield)
unsigned short opt1{};// body state
unsigned short opt2{};// health state (bitfield)
unsigned char count{};
sc_type lastEffect{SC_NONE}; // Used to check for stacking damageable SC on the same attack
int32 lastEffectTimer{INVALID_TIMER}; // Timer for lastEffect
//! TODO: See if it is possible to implement the following SC's without requiring extra parameters while the SC is inactive.
struct {
uint8 move;
Expand All @@ -3274,18 +3274,18 @@ class status_change {
uint8 warp;
uint8 deathpenalty;
uint8 interact;
} cant;/* status change state flags */
} cant{};/* status change state flags */
//int sg_id; //ID of the previous Storm gust that hit you
short comet_x, comet_y; // Point where src casted Comet - required to calculate damage from this point
short comet_x{}, comet_y{}; // Point where src casted Comet - required to calculate damage from this point
/**
* The Storm Gust counter was dropped in renewal
**/
#ifndef RENEWAL
unsigned char sg_counter; //Storm gust counter (previous hits from storm gust)
unsigned char sg_counter{}; //Storm gust counter (previous hits from storm gust)
#endif
private:
struct status_change_entry *data[SC_MAX];
std::pair<enum sc_type, struct status_change_entry *> lastStatus; // last-fetched status
struct status_change_entry *data[SC_MAX]{nullptr};
std::pair<enum sc_type, struct status_change_entry *> lastStatus{SC_NONE, nullptr}; // last-fetched status

public:
status_change_entry * getSCE(enum sc_type type);
Expand Down
1 change: 1 addition & 0 deletions src/map/vending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ void do_init_vending_autotrade(void)

// initialize player
CREATE(at->sd, map_session_data, 1); // TODO: Dont use Memory Manager allocation anymore and rely on the C++ container
new (at->sd) map_session_data();
pc_setnewpc(at->sd, at->account_id, at->char_id, 0, gettick(), at->sex, 0);
at->sd->state.autotrade = 1|2;
if (battle_config.autotrade_monsterignore)
Expand Down