@@ -9920,41 +9920,75 @@ 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
+ }
9935
9941
9936
- if (script_hasdata(st,3))
9937
- type=script_getnum(st,3);
9942
+ if (type < PT_MEMBER_NAME || type > PT_MEMBER_ACCID) {
9943
+ ShowError("buildin_getpartymember: Invalid type argument\n");
9944
+ script->reportdata(data);
9945
+ st->state = END;
9946
+ return false;
9947
+ }
9948
+
9949
+ if (!is_int_variable(varname) && (type == PT_MEMBER_CHARID || type == PT_MEMBER_ACCID)) {
9950
+ ShowError("buildin_getpartymember: Target argument is not an int 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 (!is_string_variable(varname) && type == PT_MEMBER_NAME) {
9957
+ ShowError("buildin_getpartymember: Target argument is not a string variable\n");
9958
+ script->reportdata(data);
9959
+ st->state = END;
9960
+ return false;
9961
+ }
9962
+
9963
+ if (not_server_variable(*varname)) {
9964
+ sd = script->rid2sd(st);
9965
+
9966
+ if (sd == NULL) {
9967
+ script_pushint(st, 0);
9968
+ return true; // player variable but no player attached
9969
+ }
9970
+ }
9971
+
9972
+ if (p != NULL) {
9973
+ for (int i = 0; i < MAX_PARTY; i++) {
9974
+ if (p->party.member[i].account_id != 0) {
9943
9975
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);
9976
+ case PT_MEMBER_NAME:
9977
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE(p->party.member[i].name), reference_getref(data));
9978
+ break;
9979
+ case PT_MEMBER_CHARID:
9980
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE(p->party.member[i].char_id), reference_getref(data));
9981
+ break;
9982
+ case PT_MEMBER_ACCID:
9983
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE(p->party.member[i].account_id), reference_getref(data));
9984
+ break;
9952
9985
}
9953
- j ++;
9986
+ num ++;
9954
9987
}
9955
9988
}
9956
9989
}
9957
- mapreg->setreg(script->add_variable("$@partymembercount"),j);
9990
+
9991
+ script_pushint(st, num);
9958
9992
9959
9993
return true;
9960
9994
}
@@ -28867,7 +28901,7 @@ static void script_parse_builtin(void)
28867
28901
BUILDIN_DEF(setdialogpos, "ii"),
28868
28902
BUILDIN_DEF(setdialogpospercent, "ii"),
28869
28903
BUILDIN_DEF(getpartyname,"i"),
28870
- BUILDIN_DEF(getpartymember,"i? "),
28904
+ BUILDIN_DEF(getpartymember,"iir "),
28871
28905
BUILDIN_DEF(getpartyleader,"i?"),
28872
28906
BUILDIN_DEF(getguildmember,"i?"),
28873
28907
BUILDIN_DEF(getguildinfo,"i?"),
@@ -30121,6 +30155,11 @@ static void script_hardcoded_constants(void)
30121
30155
script->set_constant("SIEGE_TYPE_SE", SIEGE_TYPE_SE, false, false);
30122
30156
script->set_constant("SIEGE_TYPE_TE", SIEGE_TYPE_TE, false, false);
30123
30157
30158
+ script->constdb_comment("partymember types");
30159
+ script->set_constant("PT_MEMBER_NAME", PT_MEMBER_NAME, false, false);
30160
+ script->set_constant("PT_MEMBER_CHARID", PT_MEMBER_CHARID, false, false);
30161
+ script->set_constant("PT_MEMBER_ACCID", PT_MEMBER_ACCID, false, false);
30162
+
30124
30163
script->constdb_comment("guildinfo types");
30125
30164
script->set_constant("GUILDINFO_NAME", GUILDINFO_NAME, false, false);
30126
30165
script->set_constant("GUILDINFO_ID", GUILDINFO_ID, false, false);
0 commit comments