Corrected script commands containing arrays (#3932)
* Corrects a potential map-server crash with script commands min, max, getpartymember, getguildmember, getunits, getmapunits, getareaunits, getunitdata, and channel_setgroup when a character variable is used when no character is attached to the script. Thanks to @Tokeiburu and @Atemo!
This commit is contained in:
parent
c5a5c54518
commit
d649ede46b
@ -8269,6 +8269,14 @@ BUILDIN_FUNC(getpartymember)
|
|||||||
ShowError("buildin_getpartymember: The array %s is not string type.\n", varname);
|
ShowError("buildin_getpartymember: The array %s is not string type.\n", varname);
|
||||||
return SCRIPT_CMD_FAILURE;
|
return SCRIPT_CMD_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (not_server_variable(*varname)) {
|
||||||
|
struct map_session_data *sd;
|
||||||
|
|
||||||
|
if (!script_rid2sd(sd)) {
|
||||||
|
ShowError("buildin_getpartymember: Cannot use a player variable '%s' if no player is attached.\n", varname);
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_PARTY; i++) {
|
for (i = 0; i < MAX_PARTY; i++) {
|
||||||
@ -11164,6 +11172,11 @@ BUILDIN_FUNC(getunits)
|
|||||||
id = reference_getid(data);
|
id = reference_getid(data);
|
||||||
idx = reference_getindex(data);
|
idx = reference_getindex(data);
|
||||||
name = reference_getname(data);
|
name = reference_getname(data);
|
||||||
|
|
||||||
|
if (not_server_variable(*name) && !script_rid2sd(sd)) {
|
||||||
|
ShowError("buildin_%s: Cannot use a player variable '%s' if no player is attached.\n", command, name);
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (bl = (struct block_list*)mapit_first(iter); mapit_exists(iter); bl = (struct block_list*)mapit_next(iter))
|
for (bl = (struct block_list*)mapit_first(iter); mapit_exists(iter); bl = (struct block_list*)mapit_next(iter))
|
||||||
@ -17334,6 +17347,11 @@ BUILDIN_FUNC(getunitdata)
|
|||||||
|
|
||||||
name = reference_getname(data);
|
name = reference_getname(data);
|
||||||
|
|
||||||
|
if (not_server_variable(*name) && !script_rid2sd(sd)) {
|
||||||
|
ShowError("buildin_getunitdata: Cannot use a player variable '%s' if no player is attached.\n", name);
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
#define getunitdata_sub(idx__,var__) setd_sub(st,sd,name,(idx__),(void *)__64BPRTSIZE((int)(var__)),data->ref)
|
#define getunitdata_sub(idx__,var__) setd_sub(st,sd,name,(idx__),(void *)__64BPRTSIZE((int)(var__)),data->ref)
|
||||||
|
|
||||||
switch(bl->type) {
|
switch(bl->type) {
|
||||||
@ -21699,6 +21717,14 @@ BUILDIN_FUNC(getguildmember)
|
|||||||
ShowError("buildin_getguildmember: The array %s is not string type.\n", varname);
|
ShowError("buildin_getguildmember: The array %s is not string type.\n", varname);
|
||||||
return SCRIPT_CMD_FAILURE;
|
return SCRIPT_CMD_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (not_server_variable(*varname)) {
|
||||||
|
struct map_session_data *sd;
|
||||||
|
|
||||||
|
if (!script_rid2sd(sd)) {
|
||||||
|
ShowError("buildin_getguildmember: Cannot use a player variable '%s' if no player is attached.\n", varname);
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_GUILD; i++) {
|
for (i = 0; i < MAX_GUILD; i++) {
|
||||||
@ -22430,6 +22456,11 @@ BUILDIN_FUNC(minmax){
|
|||||||
// Get the session data, if a player is attached
|
// Get the session data, if a player is attached
|
||||||
sd = st->rid ? map_id2sd(st->rid) : NULL;
|
sd = st->rid ? map_id2sd(st->rid) : NULL;
|
||||||
|
|
||||||
|
if (not_server_variable(*name) && !script_rid2sd(sd)) {
|
||||||
|
ShowError("buildin_%s: Cannot use a player variable '%s' if no player is attached.\n", functionname, name);
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Try to find the array's source pointer
|
// Try to find the array's source pointer
|
||||||
if( !script_array_src( st, sd, name, reference_getref( data ) ) ){
|
if( !script_array_src( st, sd, name, reference_getref( data ) ) ){
|
||||||
ShowError( "buildin_%s: not a array!\n", functionname );
|
ShowError( "buildin_%s: not a array!\n", functionname );
|
||||||
@ -23008,6 +23039,15 @@ BUILDIN_FUNC(channel_setgroup) {
|
|||||||
return SCRIPT_CMD_FAILURE;
|
return SCRIPT_CMD_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (not_server_variable(*varname)) {
|
||||||
|
struct map_session_data *sd;
|
||||||
|
|
||||||
|
if (!script_rid2sd(sd)) {
|
||||||
|
ShowError("buildin_%s: Cannot use a player variable '%s' if no player is attached.\n", funcname, varname);
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
n = script_array_highest_key(st, NULL, reference_getname(data), reference_getref(data));
|
n = script_array_highest_key(st, NULL, reference_getname(data), reference_getref(data));
|
||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
ShowError("buildin_channel_setgroup: No group id listed.\n");
|
ShowError("buildin_channel_setgroup: No group id listed.\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user