Quellcode durchsuchen

* Adjusted @speed so it is no longer reset when a player's status is recalculated. Log out or use @speed -1 to reset to default. (bugreport:7306)
> Follow up to r17220:
* Added an extra check if a player does not have a homunculus for 'hommutate' and 'morphembryo'

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17236 54d463be-8e91-2dee-dedb-b68131a5f0ec

aleos vor 12 Jahren
Ursprung
Commit
4bd5674350
5 geänderte Dateien mit 18 neuen und 5 gelöschten Zeilen
  1. 7 1
      src/map/atcommand.c
  2. 2 0
      src/map/map.c
  3. 1 0
      src/map/pc.h
  4. 3 3
      src/map/script.c
  5. 5 1
      src/map/status.c

+ 7 - 1
src/map/atcommand.c

@@ -782,7 +782,13 @@ ACMD_FUNC(speed)
 		return -1;
 	}
 
-	sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
+	if (speed < 0) {
+		sd->base_status.speed = DEFAULT_WALK_SPEED;
+		sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
+	} else {
+		sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
+		sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
+	}
 	status_calc_bl(&sd->bl, SCB_SPEED);
 	clif_displaymessage(fd, msg_txt(8)); // Speed changed.
 	return 0;

+ 2 - 0
src/map/map.c

@@ -1691,6 +1691,8 @@ int map_quit(struct map_session_data *sd) {
 
 	if( sd->state.storage_flag == 1 ) sd->state.storage_flag = 0; // No need to Double Save Storage on Quit.
 
+	if (sd->state.permanent_speed == 1) sd->state.permanent_speed = 0; // Remove lock so speed is set back to normal at login.
+
 	if( sd->ed ) {
 		elemental_clean_effect(sd->ed);
 		unit_remove_map(&sd->ed->bl,CLR_TELEPORT);

+ 1 - 0
src/map/pc.h

@@ -164,6 +164,7 @@ struct map_session_data {
 		struct guild *gmaster_flag;
 		unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
 		unsigned int warping : 1;//states whether you're in the middle of a warp processing
+		unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
 	} state;
 	struct {
 		unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;

+ 3 - 3
src/map/script.c

@@ -10137,7 +10137,7 @@ BUILDIN_FUNC(homunculus_mutate)
 	TBL_PC *sd;
 
 	sd = script_rid2sd(st);
-	if( sd == NULL )
+	if( sd == NULL || sd->hd == NULL )
 		return 0;
 
 	if(script_hasdata(st,2))
@@ -10179,7 +10179,7 @@ BUILDIN_FUNC(morphembryo)
 	TBL_PC *sd;
 
 	sd = script_rid2sd(st);
-	if( sd == NULL )
+	if( sd == NULL || sd->hd == NULL )
 		return 0;
 
 	if( merc_is_hom_active(sd->hd) ) {
@@ -10190,7 +10190,7 @@ BUILDIN_FUNC(morphembryo)
 			item_tmp.nameid = ITEMID_STRANGE_EMBRYO;
 			item_tmp.identify = 1;
 
-			if( item_tmp.nameid==0 || (i = pc_additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT)) ) {
+			if( item_tmp.nameid == 0 || (i = pc_additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT)) ) {
 				clif_additem(sd, 0, 0, i);
 				clif_emotion(&sd->bl, E_SWT); // Fail to avoid item drop exploit.
 			} else {

+ 5 - 1
src/map/status.c

@@ -2387,7 +2387,8 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
 	memset(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp)));
 
 	//FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex]
-	status->speed = DEFAULT_WALK_SPEED;
+	if (!pc->state.permanent_speed)
+		status->speed = DEFAULT_WALK_SPEED;
 	//Give them all modes except these (useful for clones)
 	status->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK);
 
@@ -5120,6 +5121,9 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
 	if( sc == NULL )
 		return cap_value(speed,10,USHRT_MAX);
 
+	if (sd && sd->state.permanent_speed)
+		return (short)cap_value(speed,10,USHRT_MAX);
+
 	if( sd && sd->ud.skilltimer != INVALID_TIMER && (pc_checkskill(sd,SA_FREECAST) > 0 || sd->ud.skill_id == LG_EXEEDBREAK) )
 	{
 		if( sd->ud.skill_id == LG_EXEEDBREAK )