@@ -10094,44 +10094,76 @@ static BUILDIN(getguildinfo)
10094
10094
10095
10095
/*==========================================
10096
10096
* Get the information of the members of a guild by type.
10097
- * getguildmember <guild_id>{,<type>};
10098
- * @param guild_id: ID of guild
10099
- * @param type:
10100
- * 0 : name (default)
10101
- * 1 : character ID
10102
- * 2 : account ID
10097
+ * getguildmember(<guild_id>, <type>, <array>);
10103
10098
*------------------------------------------*/
10104
10099
static BUILDIN(getguildmember)
10105
10100
{
10106
- struct guild *g = NULL;
10107
- int j = 0;
10101
+ struct map_session_data *sd = NULL;
10102
+ struct guild *g = guild->search(script_getnum(st, 2));
10103
+ enum guildmember_type type = script_getnum(st, 3);
10104
+ struct script_data *data = script_getdata(st, 4);
10105
+ const char *varname = reference_getname(data);
10106
+ int id = reference_getid(data);
10107
+ int num = 0;
10108
10108
10109
- g = guild->search(script_getnum(st,2));
10109
+ if (!data_isreference(data) || reference_toconstant(data)) {
10110
+ ShowError("buildin_getguildmember: Target argument is not a variable\n");
10111
+ script->reportdata(data);
10112
+ st->state = END;
10113
+ return false;
10114
+ }
10115
+
10116
+ if (type < GD_MEMBER_NAME || type > GD_MEMBER_ACCID) {
10117
+ ShowError("buildin_getguildmember: Invalid type argument\n");
10118
+ script->reportdata(data);
10119
+ st->state = END;
10120
+ return false;
10121
+ }
10110
10122
10111
- if (g) {
10112
- int i, type = 0;
10123
+ if (!is_int_variable(varname) && (type == GD_MEMBER_CHARID || type == GD_MEMBER_ACCID)) {
10124
+ ShowError("buildin_getguildmember: Target argument is not an int variable\n");
10125
+ script->reportdata(data);
10126
+ st->state = END;
10127
+ return false;
10128
+ }
10113
10129
10114
- if (script_hasdata(st,3))
10115
- type = script_getnum(st,3);
10130
+ if (!is_string_variable(varname) && type == GD_MEMBER_NAME) {
10131
+ ShowError("buildin_getguildmember: Target argument is not a string variable\n");
10132
+ script->reportdata(data);
10133
+ st->state = END;
10134
+ return false;
10135
+ }
10136
+
10137
+ if (not_server_variable(*varname)) {
10138
+ sd = script->rid2sd(st);
10139
+
10140
+ if (sd == NULL) {
10141
+ script_pushint(st, 0);
10142
+ return true; // player variable but no player attached
10143
+ }
10144
+ }
10116
10145
10117
- for ( i = 0; i < MAX_GUILD; i++ ) {
10118
- if ( g->member[i].account_id ) {
10146
+ if (g != NULL) {
10147
+ for (int i = 0; i < MAX_GUILD; i++) {
10148
+ if (g->member[i].account_id != 0) {
10119
10149
switch (type) {
10120
- case 2 :
10121
- mapreg->setreg( reference_uid(script->add_variable("$@guildmemberaid"), j), g->member[i].account_id );
10150
+ case GD_MEMBER_NAME :
10151
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE( g->member[i].name), reference_getref(data) );
10122
10152
break;
10123
- case 1 :
10124
- mapreg->setreg( reference_uid(script->add_variable("$@guildmembercid"), j ), g->member[i].char_id);
10153
+ case GD_MEMBER_CHARID :
10154
+ script->set_reg(st, sd, reference_uid(id, num ), varname, (const void *)h64BPTRSIZE( g->member[i].char_id), reference_getref(data) );
10125
10155
break;
10126
- default :
10127
- mapreg->setregstr( reference_uid(script->add_variable("$@guildmembername$"), j ), g->member[i].name );
10156
+ case GD_MEMBER_ACCID :
10157
+ script->set_reg(st, sd, reference_uid(id, num ), varname, (const void *)h64BPTRSIZE( g->member[i].account_id), reference_getref(data) );
10128
10158
break;
10129
10159
}
10130
- j ++;
10160
+ num ++;
10131
10161
}
10132
10162
}
10133
10163
}
10134
- mapreg->setreg(script->add_variable("$@guildmembercount"), j);
10164
+
10165
+ script_pushint(st, num);
10166
+
10135
10167
return true;
10136
10168
}
10137
10169
@@ -28869,7 +28901,7 @@ static void script_parse_builtin(void)
28869
28901
BUILDIN_DEF(getpartyname,"i"),
28870
28902
BUILDIN_DEF(getpartymember,"i?"),
28871
28903
BUILDIN_DEF(getpartyleader,"i?"),
28872
- BUILDIN_DEF(getguildmember,"i? "),
28904
+ BUILDIN_DEF(getguildmember,"iir "),
28873
28905
BUILDIN_DEF(getguildinfo,"i?"),
28874
28906
BUILDIN_DEF(getguildonline, "i?"),
28875
28907
BUILDIN_DEF(strcharinfo,"i??"),
@@ -30121,6 +30153,11 @@ static void script_hardcoded_constants(void)
30121
30153
script->set_constant("SIEGE_TYPE_SE", SIEGE_TYPE_SE, false, false);
30122
30154
script->set_constant("SIEGE_TYPE_TE", SIEGE_TYPE_TE, false, false);
30123
30155
30156
+ script->constdb_comment("guildmember types");
30157
+ script->set_constant("GD_MEMBER_NAME", GD_MEMBER_NAME, false, false);
30158
+ script->set_constant("GD_MEMBER_CHARID", GD_MEMBER_CHARID, false, false);
30159
+ script->set_constant("GD_MEMBER_ACCID", GD_MEMBER_ACCID, false, false);
30160
+
30124
30161
script->constdb_comment("guildinfo types");
30125
30162
script->set_constant("GUILDINFO_NAME", GUILDINFO_NAME, false, false);
30126
30163
script->set_constant("GUILDINFO_ID", GUILDINFO_ID, false, false);
0 commit comments