diff --git a/conf/msg_conf/map_msg.conf b/conf/msg_conf/map_msg.conf index 78500e307e..5c6d8f75a6 100644 --- a/conf/msg_conf/map_msg.conf +++ b/conf/msg_conf/map_msg.conf @@ -1458,7 +1458,7 @@ 1373: %s value is now: %d 1374: %s value is now: %s 1375: %s is blank. -1376: %s data type is not supported: %u +//1376: free // @reloadquestdb 1377: Quest database has been reloaded. diff --git a/conf/msg_conf/map_msg_chn.conf b/conf/msg_conf/map_msg_chn.conf index 1a8322f1d6..c73a97c7a2 100644 --- a/conf/msg_conf/map_msg_chn.conf +++ b/conf/msg_conf/map_msg_chn.conf @@ -1337,7 +1337,7 @@ 1373: %s value is now :%d 1374: %s value is now :%s 1375: %s is empty -1376: %s data type is not supported :%u +//1376: free // @reloadquestdb 1377: 完成重載任睥數據庫. diff --git a/conf/msg_conf/map_msg_frn.conf b/conf/msg_conf/map_msg_frn.conf index 3d98bf6e5f..3cbc748741 100644 --- a/conf/msg_conf/map_msg_frn.conf +++ b/conf/msg_conf/map_msg_frn.conf @@ -1350,7 +1350,7 @@ 1373: %s valeur est maintenant :%d 1374: %s valeur est maintenant :%s 1375: %s est vide -1376: Le type de donne %s n'est pas supporte :%u +//1376: free // @reloadquestdb 1377: Base de donnes des Qutes recharge. diff --git a/conf/msg_conf/map_msg_idn.conf b/conf/msg_conf/map_msg_idn.conf index c36f114c3b..9dce4fad25 100644 --- a/conf/msg_conf/map_msg_idn.conf +++ b/conf/msg_conf/map_msg_idn.conf @@ -1438,7 +1438,7 @@ 1373: Nilai %s saat ini: %d 1374: Nilai %s saat ini: %s 1375: %s kosong -1376: Jenis data %s tidak didukung: %u +//1376: free // @reloadquestdb 1377: Database Quest sudah dimuat ulang. diff --git a/conf/msg_conf/map_msg_por.conf b/conf/msg_conf/map_msg_por.conf index 711e5c900c..122d207c29 100644 --- a/conf/msg_conf/map_msg_por.conf +++ b/conf/msg_conf/map_msg_por.conf @@ -1331,7 +1331,7 @@ 1373: %s valor agora :%d 1374: %s valor agora :%s 1375: %s vazia -1376: %s tipo de dado no suportado :%u +//1376: free // @reloadquestdb 1377: Banco de dados de quest recarregado. diff --git a/conf/msg_conf/map_msg_rus.conf b/conf/msg_conf/map_msg_rus.conf index 7664e9b350..65953679d6 100644 --- a/conf/msg_conf/map_msg_rus.conf +++ b/conf/msg_conf/map_msg_rus.conf @@ -1350,7 +1350,7 @@ 1373: %s :%d 1374: %s :%s 1375: %s -1376: %s :%u +//1376: free // @reloadquestdb 1377: . diff --git a/conf/msg_conf/map_msg_spn.conf b/conf/msg_conf/map_msg_spn.conf index 10f11fabdf..5117e1eceb 100644 --- a/conf/msg_conf/map_msg_spn.conf +++ b/conf/msg_conf/map_msg_spn.conf @@ -1336,7 +1336,7 @@ 1373: El valor %s ahora es:%d 1374: El valor %sahora es:%s 1375: %s est vaco -1376: %s data type is not supported :%u +//1376: free // @reloadquestdb 1377: Se ha actualizado la base de datos de las quest con xito. diff --git a/conf/msg_conf/map_msg_tha.conf b/conf/msg_conf/map_msg_tha.conf index 152e0b9694..34a84d53da 100644 --- a/conf/msg_conf/map_msg_tha.conf +++ b/conf/msg_conf/map_msg_tha.conf @@ -1343,7 +1343,7 @@ 1373: %s դ: %d 1374: %s դ: %s 1375: %s դ. -1376: %s ѺʹѺʹع: %u +//1376: free // @reloadquestdb 1377: ҹ Quest ӡŴº. diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 860894f78a..a7c5a6ab8f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9001,14 +9001,23 @@ ACMD_FUNC(accinfo) { return 0; } -/* [Ind] */ +/** + * @set { } + * + * Gets or sets a value of a non server variable. + * If a value is specified it is used to set the variable's value, + * if not the variable's value is read. + * In any case it reads and displays the variable's value. + * + * Original implementation by Ind +*/ ACMD_FUNC(set) { - char reg[32], val[128]; - struct script_data* data; - int toset = 0, len; + char reg[46], val[128], name[32]; + int toset = 0, len, index; bool is_str = false; + int64 uid; - if( !message || !*message || (toset = sscanf(message, "%31s %127[^\n]s", reg, val)) < 1 ) { + if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) { clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50" clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String" @@ -9025,7 +9034,13 @@ ACMD_FUNC(set) { return -1; } - is_str = ( reg[strlen(reg) - 1] == '$' ); + // Check if the user wanted to set an array + if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){ + // The user did not specify array brackets, so we set the index to zero + index = 0; + } + + is_str = is_string_variable(name); if( ( len = strlen(val) ) > 1 ) { if( val[0] == '"' && val[len-1] == '"') { @@ -9034,89 +9049,65 @@ ACMD_FUNC(set) { } } - if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */ - if( is_str ) - set_var(sd, reg, (void*) val); - else - set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val)))); - + // Only set the variable if there is a value for it + if( toset >= 2 ){ + setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL ); } - CREATE(data, struct script_data,1); - + uid = reference_uid( add_str( name ), index ); if( is_str ) {// string variable + char* value; switch( reg[0] ) { case '@': - data->u.str = pc_readregstr(sd, add_str(reg)); + value = pc_readregstr(sd, uid); break; case '$': - data->u.str = mapreg_readregstr(add_str(reg)); + value = mapreg_readregstr(uid); break; case '#': if( reg[1] == '#' ) - data->u.str = pc_readaccountreg2str(sd, add_str(reg));// global + value = pc_readaccountreg2str(sd, uid);// global else - data->u.str = pc_readaccountregstr(sd, add_str(reg));// local + value = pc_readaccountregstr(sd, uid);// local break; default: - data->u.str = pc_readglobalreg_str(sd, add_str(reg)); + value = pc_readglobalreg_str(sd, uid); break; } - if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string - data->type = C_CONSTSTR; - data->u.str = ""; - } else {// duplicate string - data->type = C_STR; - data->u.str = aStrdup(data->u.str); - } - - } else {// integer variable - - data->type = C_INT; - switch( reg[0] ) { - case '@': - data->u.num = pc_readreg(sd, add_str(reg)); - break; - case '$': - data->u.num = mapreg_readreg(add_str(reg)); - break; - case '#': - if( reg[1] == '#' ) - data->u.num = pc_readaccountreg2(sd, add_str(reg));// global - else - data->u.num = pc_readaccountreg(sd, add_str(reg));// local - break; - default: - data->u.num = pc_readglobalreg(sd, add_str(reg)); - break; - } - - } - - switch( data->type ) { - case C_INT: - sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d - break; - case C_STR: - sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s - break; - case C_CONSTSTR: + if( value == NULL || value == '\0' ){// empty string sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty - break; - default: - sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u - break; + }else{ + sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s + } + } else {// integer variable + int value; + + switch( reg[0] ) { + case '@': + value = pc_readreg(sd, uid); + break; + case '$': + value = mapreg_readreg(uid); + break; + case '#': + if( reg[1] == '#' ) + value = pc_readaccountreg2(sd, uid);// global + else + value = pc_readaccountreg(sd, uid);// local + break; + default: + value = pc_readglobalreg(sd, uid); + break; + } + + sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d } clif_displaymessage(fd, atcmd_output); - if (is_str && data->u.str) - aFree(data->u.str); - aFree(data); - return 0; } ACMD_FUNC(addperm) {