Pārlūkot izejas kodu

- Removed the max cap of autoloot so you are now allowed to set autoloot values above 100.
- Initialized w1/w2/w3/w4 before reading each npc line to avoid sending unread values to the parsers (for example, if w4 has a value in one line and none on the next, it will be parsed with the previous value of w4 on the following lines)
- Updated getpartymember to receive an int which specifies what to retrieve. 0: Character names (array $@partymembername$), 1 character char ids (array $@partymembercid), 2 character account ids (array $@partynameaid). By default it returns party member names.
- Updated script_commands.txt with the updated behaviour of getpartymember.


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

skotlex 19 gadi atpakaļ
vecāks
revīzija
8934d52b73
5 mainītis faili ar 50 papildinājumiem un 12 dzēšanām
  1. 14 0
      Changelog-Trunk.txt
  2. 17 6
      doc/script_commands.txt
  3. 1 2
      src/map/atcommand.c
  4. 3 0
      src/map/npc.c
  5. 15 4
      src/map/script.c

+ 14 - 0
Changelog-Trunk.txt

@@ -3,6 +3,20 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/04/19
+	* Removed the max cap of autoloot so you are now allowed to set autoloot
+	  values above 100. [Skotlex]
+	* Initialized w1/w2/w3/w4 before reading each npc line to avoid sending
+	  unread values to the parsers (for example, if w4 has a value in one line
+	  and none on the next, it will be parsed with the previous value of w4 on
+	  the following lines), this could cause serious problems with mapflags and
+	  the recent "off" addition. [Skotlex]
+	* Updated getpartymember to receive an int which specifies what to
+	  retrieve. 0: Character names (array $@partymembername$), 1 character char
+	  ids (array $@partymembercid), 2 character account ids (array
+	  $@partynameaid). By default it returns party member names. [Skotlex]
+	* Updated script_commands.txt with the updated behaviour of getpartymember.
+	  [Skotlex]
 2006/04/18
 	* Fixed a typo in map_search_freecell which was returning incorrect cells
 	  according to the ranges given. [Skotlex]

+ 17 - 6
doc/script_commands.txt

@@ -1988,19 +1988,30 @@ Lets say the ID of a party was saved as a global variable:
 
 ---------------------------------------
 
-*getpartymember <party id>;
+*getpartymember <party id>,[<type>];
 
 Thank you to HappyDenn for all this information.
 
 This command will finds all members of a specified party and returns their names 
-into an array of temporary global variables. There's actually quite a few 
-commands like this which will fill a special variable with data upon execution 
-and not do anything else.
+(or character id or account id depending on the value of "type") into an array
+of temporary global variables. There's actually quite a few commands like this
+which will fill a special variable with data upon execution and not do anything
+else.
 
 Upon executing this,
 
 $@partymembername$[] is a global temporary stringarray which contains all the 
-                     names of these party members.
+                     names of these party members
+                     (only set when type is 0 or not specified)
+
+$@partymembercid[]   is a global temporary number array which contains the 
+                     character id of these party members.
+                     (only set when type is 1)
+
+$@partymemberaid[]   is a global temporary number array which contains the 
+                     account id of these party members.
+                     (only set when type is 2)
+
 $@partymembercount   is the number of party members that were found.
 
 The party members will (apparently) be found regardless of whether they are 
@@ -2014,7 +2025,7 @@ server will not clear the array for you, overwriting the values instead. So in
 addition to returning the 5 member names, the 6th and 7th elements from the last 
 call remain, and you will get 5+2 members, of which the last 2 don't belong to 
 the new guy's party. $@partymembercount will always contain the correct number, 
-(5) unlike 'getarraysise()' which will return 7 in this case.
+(5) unlike 'getarraysize()' which will return 7 in this case.
 
 Example:
 

+ 1 - 2
src/map/atcommand.c

@@ -7711,8 +7711,7 @@ atcommand_autoloot(
 		drate = atof(message);
 		rate = (int)(drate*100);
 	}
-	if (rate > 10000) rate = 10000;
-	else if (rate < 0) rate = 0;
+	if (rate < 0) rate = 0;
 	
 	sd->state.autoloot = rate;
 	if (sd->state.autoloot) { 

+ 3 - 0
src/map/npc.c

@@ -2484,6 +2484,9 @@ void npc_parsesrcfile (char *name)
 		}
 		line[j] = '\0'; //Forget to terminate the string. From [jA 1091]
 		// 最初はタブ区切りでチェックしてみて、ダメならスペース区切りで確認
+		w1[0] = w2[0] = w3[0] = w4[0] = '\0'; //It's best to initialize values
+		//to prevent passing previously parsed values to the parsers when not all
+		//fields are specified. [Skotlex]
 		if ((count = sscanf(line,"%[^\t]\t%[^\t]\t%[^\t\r\n]\t%n%[^\t\r\n]", w1, w2, w3, &w4pos, w4)) < 3 &&
 		   (count = sscanf(line,"%s%s%s%n%s", w1, w2, w3, &w4pos, w4)) < 3) {
 			continue;

+ 15 - 4
src/map/script.c

@@ -504,7 +504,7 @@ struct {
 	{buildin_readparam,"readparam","i*"},
 	{buildin_getcharid,"getcharid","i*"},
 	{buildin_getpartyname,"getpartyname","i"},
-	{buildin_getpartymember,"getpartymember","i"},
+	{buildin_getpartymember,"getpartymember","i*"},
 	{buildin_getguildname,"getguildname","i"},
 	{buildin_getguildmaster,"getguildmaster","i"},
 	{buildin_getguildmasterid,"getguildmasterid","i"},
@@ -4303,16 +4303,27 @@ int buildin_getpartyname(struct script_state *st)
 int buildin_getpartymember(struct script_state *st)
 {
 	struct party *p;
-	int i,j=0;
+	int i,j=0,type=0;
 
 	p=NULL;
 	p=party_search(conv_num(st,& (st->stack->stack_data[st->start+2])));
 
+	if( st->end>st->start+3 )
+ 		type=conv_num(st,& (st->stack->stack_data[st->start+3]));
+	
 	if(p!=NULL){
 		for(i=0;i<MAX_PARTY;i++){
 			if(p->member[i].account_id){
-//				printf("name:%s %d\n",p->member[i].name,i);
-				mapreg_setregstr(add_str((unsigned char *) "$@partymembername$")+(i<<24),p->member[i].name);
+				switch (type) {
+				case 2:
+					mapreg_setreg(add_str((unsigned char *) "$@partymemberaid")+(j<<24),p->member[i].account_id);
+					break;
+				case 1:
+					mapreg_setreg(add_str((unsigned char *) "$@partymembercid")+(j<<24),p->member[i].char_id);
+					break;
+				default:
+					mapreg_setregstr(add_str((unsigned char *) "$@partymembername$")+(j<<24),p->member[i].name);
+				}
 				j++;
 			}
 		}