Jump to content

recovery function


chriser

Recommended Posts


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  94
  • Reputation:   4
  • Joined:  01/29/13
  • Last Seen:  

Hi guys,

 

I implemented the King of the Hill Event on my server, and modified it a bit. It now revives all the players in an interval of 20 seconds with the recovery function.

As there is no RID attached when i call recovery on the whole map, it throws and error and exists the script. But as no RID is needed when reviving the whole map or the whole server, the script should be modified to only get the RID if we really need it, otherwise we have our map iterator getting all the SDs.

 

I just realised that when there is any option given, you don't need a RID attached. So basically, we just have to check:

BUILDIN_FUNC(recovery)
{
    if(!script_hasdata(sd,3)) 
        TBL_PC *sd = script_rid2sd(st);
    ....
}

 

I think that should be all.

 

Greets~

chriser

Edited by chriser
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  247
  • Reputation:   207
  • Joined:  10/23/12
  • Last Seen:  

You're right about the command always checking for player first, but a check for the second argument in the command is no good as the second argument can also contain a party ID, guild ID, or map name.  I think (untested) the real fix would look like this.

 

Index: src/map/script.c
===================================================================
--- src/map/script.c	(revision 17485)
+++ src/map/script.c	(working copy)
@@ -12883,10 +12883,8 @@
  *-------------------------------------------------------------------------*/
 BUILDIN_FUNC(recovery)
 {
-	TBL_PC *sd = script_rid2sd(st);
-
+	TBL_PC *sd;
 	int map = 0, type = 0, revive = 1;
-
 	type = script_getnum(st,2);
 
 	if(script_hasdata(st,4))
@@ -12896,6 +12894,8 @@
 		case 0:
 			if(script_hasdata(st,3))
 				sd=map_charid2sd(script_getnum(st,3));
+			else
+				sd = script_rid2sd(st);
 			if(sd == NULL) //If we don't have sd by now, bail out
 				return 0;
 			recovery_sub(sd, revive);
@@ -12915,8 +12915,10 @@
 			}
 			if(script_hasdata(st,3))
 				p_id = script_getnum(st,3);
-			else
+			else {
+				sd = script_rid2sd(st);
 				p_id = (sd)?sd->status.party_id:0;
+			}
 			p = party_search(p_id);
 			if(p == NULL)
 				return 0;
@@ -12943,8 +12945,10 @@
 			}
 			if(script_hasdata(st,3))
 				g_id = script_getnum(st,3);
-			else
+			else {
+				sd = script_rid2sd(st);
 				g_id = (sd)?sd->status.guild_id:0;
+			}
 			g = guild_search(g_id);
 			if(g == NULL)
 				return 0;
@@ -12959,8 +12963,10 @@
 		case 3:
 			if(script_hasdata(st,3))
 				map = map_mapname2mapid(script_getstr(st,3));
-			else
+			else {
+				sd = script_rid2sd(st);
 				map = (sd)?sd->bl.m:0; //No sd and no map given - return
+			}
 			if(map < 1)
 				return 1;
 		case 4:

 

Also, something like this should have been posted in bug reports.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  94
  • Reputation:   4
  • Joined:  01/29/13
  • Last Seen:  

Sorry for the wrong section, you can move it if you want to.

 

I really think that my fix would actually work, because you are exactly doing the same. (You patch definitly works, but it's more code :P)

You always try to get the SD when there was no 2nd argument passed, that's what I did.

You only need rid2sd when there was no 2nd argument. When you don't have a second argument, you always take the party, guild or map from the current attached player.

The only part which might not work with this fix is when recovery raises the whole server (type 4), which does not need any further arguments.

 

Either ways would work, it's only a matter of beauty :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  247
  • Reputation:   207
  • Joined:  10/23/12
  • Last Seen:  

Ahh, you're right.  And here I am the one who scripted that command.  It'll be fixed soon.  Thanks.

  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.01
  • Content Count:  247
  • Reputation:   207
  • Joined:  10/23/12
  • Last Seen:  

Fixed in 5bdb25e.

Link to comment
Share on other sites

×
×
  • Create New...