@@ -9920,41 +9920,68 @@ static BUILDIN(getpartyname)
9920
9920
9921
9921
/*==========================================
9922
9922
* Get the information of the members of a party by type
9923
- * @party_id, @type
9924
- * return by @type :
9925
- * - : nom des membres
9926
- * 1 : char_id des membres
9927
- * 2 : account_id des membres
9923
+ * getpartymember(<party_id>, <type>, <array>);
9928
9924
*------------------------------------------*/
9929
9925
static BUILDIN(getpartymember)
9930
9926
{
9931
- struct party_data *p;
9932
- int j=0,type=0;
9927
+ struct map_session_data *sd = NULL;
9928
+ struct party_data *p = party->search(script_getnum(st, 2));
9929
+ enum partymember_type type = script_getnum(st, 3);
9930
+ struct script_data *data = script_getdata(st, 4);
9931
+ const char *varname = reference_getname(data);
9932
+ int id = reference_getid(data);
9933
+ int num = 0;
9933
9934
9934
- p=party->search(script_getnum(st,2));
9935
+ if (!data_isreference(data) || reference_toconstant(data)) {
9936
+ ShowError("buildin_getpartymember: Target argument is not a variable\n");
9937
+ script->reportdata(data);
9938
+ st->state = END;
9939
+ return false;
9940
+ }
9941
+
9942
+ if (!is_int_variable(varname) && (type == PT_MEMBER_CHARID || type == PT_MEMBER_ACCID)) {
9943
+ ShowError("buildin_getpartymember: Target argument is not an int variable\n");
9944
+ script->reportdata(data);
9945
+ st->state = END;
9946
+ return false;
9947
+ }
9935
9948
9936
- if (script_hasdata(st,3))
9937
- type=script_getnum(st,3);
9949
+ if (!is_string_variable(varname) && type == PT_MEMBER_NAME) {
9950
+ ShowError("buildin_getpartymember: Target argument is not a string variable\n");
9951
+ script->reportdata(data);
9952
+ st->state = END;
9953
+ return false;
9954
+ }
9938
9955
9939
- if ( p != NULL) {
9940
- int i;
9941
- for (i = 0; i < MAX_PARTY; i++) {
9942
- if(p->party.member[i].account_id) {
9956
+ if (not_server_variable(*varname)) {
9957
+ sd = script->rid2sd(st);
9958
+
9959
+ if (sd == NULL) {
9960
+ script_pushint(st, 0);
9961
+ return true; // player variable but no player attached
9962
+ }
9963
+ }
9964
+
9965
+ if (p) {
9966
+ for (int i = 0; i < MAX_PARTY; i++) {
9967
+ if (p->party.member[i].account_id) {
9943
9968
switch (type) {
9944
- case 2:
9945
- mapreg->setreg(reference_uid(script->add_variable("$@partymemberaid"), j),p->party.member[i].account_id);
9946
- break;
9947
- case 1:
9948
- mapreg->setreg(reference_uid(script->add_variable("$@partymembercid"), j),p->party.member[i].char_id);
9949
- break;
9950
- default:
9951
- mapreg->setregstr(reference_uid(script->add_variable("$@partymembername$"), j),p->party.member[i].name);
9969
+ case PT_MEMBER_NAME:
9970
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE(p->party.member[i].name), reference_getref(data));
9971
+ break;
9972
+ case PT_MEMBER_CHARID:
9973
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE(p->party.member[i].char_id), reference_getref(data));
9974
+ break;
9975
+ case PT_MEMBER_ACCID:
9976
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE(p->party.member[i].account_id), reference_getref(data));
9977
+ break;
9952
9978
}
9953
- j ++;
9979
+ num ++;
9954
9980
}
9955
9981
}
9956
9982
}
9957
- mapreg->setreg(script->add_variable("$@partymembercount"),j);
9983
+
9984
+ script_pushint(st, num);
9958
9985
9959
9986
return true;
9960
9987
}
@@ -28867,7 +28894,7 @@ static void script_parse_builtin(void)
28867
28894
BUILDIN_DEF(setdialogpos, "ii"),
28868
28895
BUILDIN_DEF(setdialogpospercent, "ii"),
28869
28896
BUILDIN_DEF(getpartyname,"i"),
28870
- BUILDIN_DEF(getpartymember,"i? "),
28897
+ BUILDIN_DEF(getpartymember,"iir "),
28871
28898
BUILDIN_DEF(getpartyleader,"i?"),
28872
28899
BUILDIN_DEF(getguildmember,"i?"),
28873
28900
BUILDIN_DEF(getguildinfo,"i?"),
@@ -30121,6 +30148,11 @@ static void script_hardcoded_constants(void)
30121
30148
script->set_constant("SIEGE_TYPE_SE", SIEGE_TYPE_SE, false, false);
30122
30149
script->set_constant("SIEGE_TYPE_TE", SIEGE_TYPE_TE, false, false);
30123
30150
30151
+ script->constdb_comment("partymember types");
30152
+ script->set_constant("PT_MEMBER_NAME", PT_MEMBER_NAME, false, false);
30153
+ script->set_constant("PT_MEMBER_CHARID", PT_MEMBER_CHARID, false, false);
30154
+ script->set_constant("PT_MEMBER_ACCID", PT_MEMBER_ACCID, false, false);
30155
+
30124
30156
script->constdb_comment("guildinfo types");
30125
30157
script->set_constant("GUILDINFO_NAME", GUILDINFO_NAME, false, false);
30126
30158
script->set_constant("GUILDINFO_ID", GUILDINFO_ID, false, false);
0 commit comments