summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-21 00:13:56 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-21 00:13:56 +0000
commitfd665092bbcd4be32f9d8319ffbb4aad30b40d08 (patch)
tree96fbf399d2704c89a5254a91994dd07a40fdfe39 /src/map/unit.c
parent5870b45487fde3bc3fef54062aab5fcce4ce39ca (diff)
downloadhercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.tar.gz
hercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.tar.bz2
hercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.tar.xz
hercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.zip
- Fixed new guilds displaying online-connect member count at 0 rather than 1, and the guild master not knowing it is one (eg: it cannot edit the guild notice of a newly created guild until relogging).
- Fixed acc_reg2 parsing screwing up the char_id and subtracting 2 from it rather than passing it as it is. - Extended the auth_node/auth_db system in chrif.c to handle log in/out and mapserver-change procedures. This way players are not in the main dbs when they are not "active", which blocks potential invalid accesses to them. - Replaced states auth, waiting_disconnect and finalsave with active. - Cleaned some the party/guild login and creation procedures, removed the party_sent/guild_sent states. - Removed a redundant guild_check_member call which is beyond not-needed and into the realm of wasting resources. - clif_parse will no longer process packets from !sd->state.active players, this also makes checking for finalsave uneccessary (since players re already removed from the maps and dbs by this point, so you can't access them in any other way) - Separated the roles of unit_free and map_quit, the former will handle cleaning structures from the player so it can be free'd safely, while the latter performs additional routines which are unique to characters logging out normally (map-server changes will invoke unit_free and bypass map_quit). - Removed pc_isplaying, quit_db, map_knowsaccount, MAPIT_PCISPLAYING among other functions/defines which are no longer needed due to the new login scheme. - Cleand up a bit some code in the clif_send(_sub) functions. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12223 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c106
1 files changed, 51 insertions, 55 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index d0d06ff06..66f362085 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1658,13 +1658,11 @@ int unit_remove_map(struct block_list *bl, int clrtype)
trade_tradecancel(sd);
if(sd->vender_id)
vending_closevending(sd);
- if(!sd->state.waitingdisconnect)
- { //when quitting, let the final chrif_save handle storage saving.
- if(sd->state.storage_flag == 1)
- storage_storage_quit(sd,0);
- else if (sd->state.storage_flag == 2)
- storage_guild_storage_quit(sd,0);
- }
+ if(sd->state.storage_flag == 1)
+ storage_storage_quit(sd,0);
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storage_quit(sd,0);
+ sd->state.storage_flag = 0; //Force close it when being warped.
if(sd->party_invite>0)
party_reply_invite(sd,sd->party_invite_account,0);
if(sd->guild_invite>0)
@@ -1708,7 +1706,7 @@ int unit_remove_map(struct block_list *bl, int clrtype)
case BL_PET:
{
struct pet_data *pd = (struct pet_data*)bl;
- if( pd->pet.intimate <= 0 && !(pd->msd && pd->msd->state.waitingdisconnect) )
+ if( pd->pet.intimate <= 0 && !(pd->msd && pd->msd->state.active) )
{ //If logging out, this is deleted on unit_free
clif_clearunit_area(bl,clrtype);
map_delblock(bl);
@@ -1723,7 +1721,7 @@ int unit_remove_map(struct block_list *bl, int clrtype)
{
struct homun_data *hd = (struct homun_data *) bl;
ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick.
- if(!hd->homunculus.intimacy && !(hd->master && hd->master->state.waitingdisconnect) )
+ if(!hd->homunculus.intimacy && !(hd->master && hd->master->state.active) )
{ //If logging out, this is deleted on unit_free
clif_emotion(bl, 28) ; //sob
clif_clearunit_area(bl,clrtype);
@@ -1744,6 +1742,25 @@ int unit_remove_map(struct block_list *bl, int clrtype)
return 1;
}
+void unit_remove_map_pc(struct map_session_data *sd, int clrtype)
+{
+ unit_remove_map(&sd->bl,clrtype);
+
+ if (clrtype == 3) clrtype = 0; //3 is the warp from logging out, but pets/homunc need to just 'vanish' instead of showing the warping out animation.
+
+ if(sd->pd)
+ unit_remove_map(&sd->pd->bl, clrtype);
+ if(merc_is_hom_active(sd->hd))
+ unit_remove_map(&sd->hd->bl, clrtype);
+}
+
+void unit_free_pc(struct map_session_data *sd)
+{
+ if (sd->pd) unit_free(&sd->pd->bl,0);
+ if (sd->hd) unit_free(&sd->hd->bl,0);
+ unit_free(&sd->bl,3);
+}
+
/*==========================================
* Function to free all related resources to the bl
* if unit is on map, it is removed using the clrtype specified
@@ -1765,44 +1782,6 @@ int unit_free(struct block_list *bl, int clrtype)
pc_setrestartvalue(sd,2);
pc_delinvincibletimer(sd);
- //Status that are not saved...
- if(sd->sc.count) {
- if(sd->sc.data[SC_SPURT])
- status_change_end(bl,SC_SPURT,-1);
- if(sd->sc.data[SC_BERSERK])
- status_change_end(bl,SC_BERSERK,-1);
- if(sd->sc.data[SC_TRICKDEAD])
- status_change_end(bl,SC_TRICKDEAD,-1);
- if(sd->sc.data[SC_GUILDAURA])
- status_change_end(bl,SC_GUILDAURA,-1);
- if (battle_config.debuff_on_logout&1) {
- if(sd->sc.data[SC_ORCISH])
- status_change_end(bl,SC_ORCISH,-1);
- if(sd->sc.data[SC_STRIPWEAPON])
- status_change_end(bl,SC_STRIPWEAPON,-1);
- if(sd->sc.data[SC_STRIPARMOR])
- status_change_end(bl,SC_STRIPARMOR,-1);
- if(sd->sc.data[SC_STRIPSHIELD])
- status_change_end(bl,SC_STRIPSHIELD,-1);
- if(sd->sc.data[SC_STRIPHELM])
- status_change_end(bl,SC_STRIPHELM,-1);
- if(sd->sc.data[SC_EXTREMITYFIST])
- status_change_end(bl,SC_EXTREMITYFIST,-1);
- if(sd->sc.data[SC_EXPLOSIONSPIRITS])
- status_change_end(bl,SC_EXPLOSIONSPIRITS,-1);
- if(sd->sc.data[SC_REGENERATION] && sd->sc.data[SC_REGENERATION]->val4)
- status_change_end(bl,SC_REGENERATION,-1);
- }
- if (battle_config.debuff_on_logout&2)
- {
- if(sd->sc.data[SC_MAXIMIZEPOWER])
- status_change_end(bl,SC_MAXIMIZEPOWER,-1);
- if(sd->sc.data[SC_MAXOVERTHRUST])
- status_change_end(bl,SC_MAXOVERTHRUST,-1);
- if(sd->sc.data[SC_STEELBODY])
- status_change_end(bl,SC_STEELBODY,-1);
- }
- }
pc_autoscript_clear(sd->autoscript, ARRAYLENGTH(sd->autoscript));
pc_autoscript_clear(sd->autoscript2, ARRAYLENGTH(sd->autoscript2));
@@ -1819,10 +1798,29 @@ int unit_free(struct block_list *bl, int clrtype)
guild_send_memberinfoshort(sd,0);
pc_cleareventtimer(sd);
pc_delspiritball(sd,sd->spiritball,1);
- if (clrtype >= 0) {
- chrif_save_scdata(sd); //Save status changes, then clear'em out from memory. [Skotlex]
- pc_makesavestatus(sd);
- pc_clean_skilltree(sd);
+
+ if(sd->reg)
+ { //Double logout already freed pointer fix... [Skotlex]
+ aFree(sd->reg);
+ sd->reg = NULL;
+ sd->reg_num = 0;
+ }
+ if(sd->regstr)
+ {
+ int i;
+ for( i = 0; i < sd->regstr_num; ++i )
+ if( sd->regstr[i].data )
+ aFree(sd->regstr[i].data);
+ aFree(sd->regstr);
+ sd->regstr = NULL;
+ sd->regstr_num = 0;
+ }
+ if (sd->st) {
+ if (sd->st->stack)
+ script_free_stack (sd->st->stack);
+ aFree(sd->st);
+ sd->st = NULL;
+ sd->npc_id = 0;
}
} else if( bl->type == BL_PET ) {
struct pet_data *pd = (struct pet_data*)bl;
@@ -1924,11 +1922,9 @@ int unit_free(struct block_list *bl, int clrtype)
skill_clear_unitgroup(bl);
status_change_clear(bl,1);
- if (bl->type != BL_PC)
- { //Players are handled by map_quit
- map_deliddb(bl);
+ map_deliddb(bl);
+ if (bl->type != BL_PC) //Players are handled by map_quit
map_freeblock(bl);
- }
map_freeblock_unlock();
return 0;
}