@@ -10128,44 +10128,76 @@ static BUILDIN(getguildinfo)
10128
10128
10129
10129
/*==========================================
10130
10130
* Get the information of the members of a guild by type.
10131
- * getguildmember <guild_id>{,<type>};
10132
- * @param guild_id: ID of guild
10133
- * @param type:
10134
- * 0 : name (default)
10135
- * 1 : character ID
10136
- * 2 : account ID
10131
+ * getguildmember(<guild_id>, <type>, <array>);
10137
10132
*------------------------------------------*/
10138
10133
static BUILDIN(getguildmember)
10139
10134
{
10140
- struct guild *g = NULL;
10141
- int j = 0;
10135
+ struct map_session_data *sd = NULL;
10136
+ struct guild *g = guild->search(script_getnum(st, 2));
10137
+ enum guildmember_type type = script_getnum(st, 3);
10138
+ struct script_data *data = script_getdata(st, 4);
10139
+ const char *varname = reference_getname(data);
10140
+ int id = reference_getid(data);
10141
+ int num = 0;
10142
10142
10143
- g = guild->search(script_getnum(st,2));
10143
+ if (!data_isreference(data) || reference_toconstant(data)) {
10144
+ ShowError("buildin_getguildmember: Target argument is not a variable\n");
10145
+ script->reportdata(data);
10146
+ st->state = END;
10147
+ return false;
10148
+ }
10149
+
10150
+ if (type < GD_MEMBER_NAME || type > GD_MEMBER_ACCID) {
10151
+ ShowError("buildin_getguildmember: Invalid type argument\n");
10152
+ script->reportdata(data);
10153
+ st->state = END;
10154
+ return false;
10155
+ }
10144
10156
10145
- if (g) {
10146
- int i, type = 0;
10157
+ if (!is_int_variable(varname) && (type == GD_MEMBER_CHARID || type == GD_MEMBER_ACCID)) {
10158
+ ShowError("buildin_getguildmember: Target argument is not an int variable\n");
10159
+ script->reportdata(data);
10160
+ st->state = END;
10161
+ return false;
10162
+ }
10163
+
10164
+ if (!is_string_variable(varname) && type == GD_MEMBER_NAME) {
10165
+ ShowError("buildin_getguildmember: Target argument is not a string variable\n");
10166
+ script->reportdata(data);
10167
+ st->state = END;
10168
+ return false;
10169
+ }
10147
10170
10148
- if (script_hasdata(st,3))
10149
- type = script_getnum(st,3);
10171
+ if (not_server_variable(*varname)) {
10172
+ sd = script->rid2sd(st);
10173
+
10174
+ if (sd == NULL) {
10175
+ script_pushint(st, 0);
10176
+ return true; // player variable but no player attached
10177
+ }
10178
+ }
10150
10179
10151
- for ( i = 0; i < MAX_GUILD; i++ ) {
10152
- if ( g->member[i].account_id ) {
10180
+ if (g != NULL) {
10181
+ for (int i = 0; i < MAX_GUILD; i++) {
10182
+ if (g->member[i].account_id != 0) {
10153
10183
switch (type) {
10154
- case 2 :
10155
- mapreg->setreg( reference_uid(script->add_variable("$@guildmemberaid"), j), g->member[i].account_id );
10184
+ case GD_MEMBER_NAME :
10185
+ script->set_reg(st, sd, reference_uid(id, num), varname, (const void *)h64BPTRSIZE( g->member[i].name), reference_getref(data) );
10156
10186
break;
10157
- case 1 :
10158
- mapreg->setreg( reference_uid(script->add_variable("$@guildmembercid"), j ), g->member[i].char_id);
10187
+ case GD_MEMBER_CHARID :
10188
+ script->set_reg(st, sd, reference_uid(id, num ), varname, (const void *)h64BPTRSIZE( g->member[i].char_id), reference_getref(data) );
10159
10189
break;
10160
- default :
10161
- mapreg->setregstr( reference_uid(script->add_variable("$@guildmembername$"), j ), g->member[i].name );
10190
+ case GD_MEMBER_ACCID :
10191
+ script->set_reg(st, sd, reference_uid(id, num ), varname, (const void *)h64BPTRSIZE( g->member[i].account_id), reference_getref(data) );
10162
10192
break;
10163
10193
}
10164
- j ++;
10194
+ num ++;
10165
10195
}
10166
10196
}
10167
10197
}
10168
- mapreg->setreg(script->add_variable("$@guildmembercount"), j);
10198
+
10199
+ script_pushint(st, num);
10200
+
10169
10201
return true;
10170
10202
}
10171
10203
@@ -28903,7 +28935,7 @@ static void script_parse_builtin(void)
28903
28935
BUILDIN_DEF(getpartyname,"i"),
28904
28936
BUILDIN_DEF(getpartymember,"iir"),
28905
28937
BUILDIN_DEF(getpartyleader,"i?"),
28906
- BUILDIN_DEF(getguildmember,"i? "),
28938
+ BUILDIN_DEF(getguildmember,"iir "),
28907
28939
BUILDIN_DEF(getguildinfo,"i?"),
28908
28940
BUILDIN_DEF(getguildonline, "i?"),
28909
28941
BUILDIN_DEF(strcharinfo,"i??"),
@@ -30155,7 +30187,12 @@ static void script_hardcoded_constants(void)
30155
30187
script->set_constant("SIEGE_TYPE_SE", SIEGE_TYPE_SE, false, false);
30156
30188
script->set_constant("SIEGE_TYPE_TE", SIEGE_TYPE_TE, false, false);
30157
30189
30158
- script->constdb_comment("partymember types");
30190
+ script->constdb_comment("guildmember types");
30191
+ script->set_constant("GD_MEMBER_NAME", GD_MEMBER_NAME, false, false);
30192
+ script->set_constant("GD_MEMBER_CHARID", GD_MEMBER_CHARID, false, false);
30193
+ script->set_constant("GD_MEMBER_ACCID", GD_MEMBER_ACCID, false, false);
30194
+
30195
+ script->constdb_comment("partymember types");
30159
30196
script->set_constant("PT_MEMBER_NAME", PT_MEMBER_NAME, false, false);
30160
30197
script->set_constant("PT_MEMBER_CHARID", PT_MEMBER_CHARID, false, false);
30161
30198
script->set_constant("PT_MEMBER_ACCID", PT_MEMBER_ACCID, false, false);
0 commit comments