Added int64 support to the script engine (#4522)
Added support for signed 64 bit integer value computation into the script engine. This is required because newer official features require support for bigger numbers inside the scripts. This also cleans up a lot of messy code and fixes a few issues like script stack corruptions. Thanks to @aleos89 and everyone who supported me with this.
This commit is contained in:
parent
3142863a13
commit
e72c7360cf
@ -1525,7 +1525,7 @@
|
||||
1370: Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
|
||||
1371: NPC variables may not be used with @set.
|
||||
1372: Instance variables may not be used with @set.
|
||||
1373: %s value is now: %d
|
||||
1373: %s value is now: %lld
|
||||
1374: %s value is now: %s
|
||||
1375: %s is blank.
|
||||
|
||||
|
@ -1341,8 +1341,8 @@
|
||||
1370: 用法: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
|
||||
1371: NPC variables may not be used with @set.
|
||||
1372: Instance variables may not be used with @set.
|
||||
1373: %s value is now :%d
|
||||
1374: %s value is now :%s
|
||||
1373: %s value is now: %lld
|
||||
1374: %s value is now: %s
|
||||
1375: %s is empty
|
||||
//1376: free
|
||||
|
||||
|
@ -1354,8 +1354,8 @@
|
||||
1370: Usage: ex. "@set PoringCharVarSTR$" affiche sa valeur actuelle, Super Duper String.
|
||||
1371: Les variables des NPC ne peuvent pas être utilisées/changées avec @set.
|
||||
1372: Les variables d'Instance ne peuvent pas être utilisées avec @set.
|
||||
1373: %s valeur est maintenant :%d
|
||||
1374: %s valeur est maintenant :%s
|
||||
1373: %s valeur est maintenant: %lld
|
||||
1374: %s valeur est maintenant: %s
|
||||
1375: %s est vide
|
||||
//1376: free
|
||||
|
||||
|
@ -1445,7 +1445,7 @@
|
||||
1370: Contoh penggunaan: \"@set PoringCharVarSTR$\" menampilkan nilainya, Super Duper String.
|
||||
1371: Variabel pada NPC tidak boleh digunakan dengan @set.
|
||||
1372: Variabel instansi tidak boleh digunakan dengan @set.
|
||||
1373: Nilai %s saat ini: %d
|
||||
1373: Nilai %s saat ini: %lld
|
||||
1374: Nilai %s saat ini: %s
|
||||
1375: %s kosong
|
||||
//1376: free
|
||||
|
@ -1524,8 +1524,8 @@
|
||||
1370: Uso: ex. "@set PoringCharVarSTR$" exibe seu valor, Super Duper String.
|
||||
1371: Variáveis de NPC não podem ser usadas com @set.
|
||||
1372: Variáveis de instância não podem ser usadas com @set.
|
||||
1373: %s valor agora é :%d
|
||||
1374: %s valor agora é :%s
|
||||
1373: %s valor agora é: %lld
|
||||
1374: %s valor agora é: %s
|
||||
1375: %s é vazia
|
||||
//1376: free
|
||||
|
||||
|
@ -1354,8 +1354,8 @@
|
||||
1370: Использование: прим. "@set PoringCharVarSTR$" будет иметь значение "Super Duper String".
|
||||
1371: Переменные НИП не могут быть использованы командой @set.
|
||||
1372: Переменные групп не могут быть использованы командой @set.
|
||||
1373: %s значение :%d
|
||||
1374: %s значение :%s
|
||||
1373: %s значение: %lld
|
||||
1374: %s значение: %s
|
||||
1375: %s пусто
|
||||
//1376: free
|
||||
|
||||
|
@ -1493,7 +1493,7 @@
|
||||
1370: Instrucciones: ej. "@set PoringCharVarSTR$" muestra su valor, cadena de texto.
|
||||
1371: Las variables de NPC no se pueden editar con @set.
|
||||
1372: Las variables de instancias no se pueden editar con @set.
|
||||
1373: El valor %s ahora es: %d
|
||||
1373: El valor %s ahora es: %lld
|
||||
1374: El valor %s ahora es: %s
|
||||
1375: %s está vacío
|
||||
|
||||
|
@ -1347,7 +1347,7 @@
|
||||
1370: ÇÔ¸Õãªé: ex. "@set PoringCharVarSTR$" ¨ÐáÊ´§¼ÅÅѾ¸ìà»ç¹¤èÒ, Super Duper String.
|
||||
1371: µÑÇá»Ã NPC äÁèÊÒÁÒöµÑ駤èÒä´é´éÇ @set ä´é.
|
||||
1372: µÑÇá»Ã Instance äÁèÊÒÁÒöµÑ駤èÒä´é´éÇ @set ä´é.
|
||||
1373: %s チユ、靨: %d
|
||||
1373: %s チユ、靨: %lld
|
||||
1374: %s ÁÕ¤èÒ: %s
|
||||
1375: %s äÁèÁÕ¤èÒã´æ.
|
||||
//1376: free
|
||||
|
@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS `acc_reg_num` (
|
||||
`account_id` int(11) unsigned NOT NULL default '0',
|
||||
`key` varchar(32) binary NOT NULL default '',
|
||||
`index` int(11) unsigned NOT NULL default '0',
|
||||
`value` int(11) NOT NULL default '0',
|
||||
`value` bigint(11) NOT NULL default '0',
|
||||
PRIMARY KEY (`account_id`,`key`,`index`),
|
||||
KEY `account_id` (`account_id`)
|
||||
) ENGINE=MyISAM;
|
||||
@ -274,7 +274,7 @@ CREATE TABLE IF NOT EXISTS `char_reg_num` (
|
||||
`char_id` int(11) unsigned NOT NULL default '0',
|
||||
`key` varchar(32) binary NOT NULL default '',
|
||||
`index` int(11) unsigned NOT NULL default '0',
|
||||
`value` int(11) NOT NULL default '0',
|
||||
`value` bigint(11) NOT NULL default '0',
|
||||
PRIMARY KEY (`char_id`,`key`,`index`),
|
||||
KEY `char_id` (`char_id`)
|
||||
) ENGINE=MyISAM;
|
||||
@ -403,7 +403,7 @@ CREATE TABLE IF NOT EXISTS `global_acc_reg_num` (
|
||||
`account_id` int(11) unsigned NOT NULL default '0',
|
||||
`key` varchar(32) binary NOT NULL default '',
|
||||
`index` int(11) unsigned NOT NULL default '0',
|
||||
`value` int(11) NOT NULL default '0',
|
||||
`value` bigint(11) NOT NULL default '0',
|
||||
PRIMARY KEY (`account_id`,`key`,`index`),
|
||||
KEY `account_id` (`account_id`)
|
||||
) ENGINE=MyISAM;
|
||||
|
8
sql-files/upgrades/upgrade_20200109.sql
Normal file
8
sql-files/upgrades/upgrade_20200109.sql
Normal file
@ -0,0 +1,8 @@
|
||||
ALTER TABLE `acc_reg_num`
|
||||
MODIFY `value` bigint(11) NOT NULL default '0';
|
||||
|
||||
ALTER TABLE `global_acc_reg_num`
|
||||
MODIFY `value` bigint(11) NOT NULL default '0';
|
||||
|
||||
ALTER TABLE `char_reg_num`
|
||||
MODIFY `value` bigint(11) NOT NULL default '0';
|
@ -178,7 +178,7 @@ void chlogif_prepsend_global_accreg(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void chlogif_send_global_accreg(const char *key, unsigned int index, intptr_t val, bool is_string) {
|
||||
void chlogif_send_global_accreg(const char *key, unsigned int index, int64 int_value, const char* string_value, bool is_string) {
|
||||
int nlen = WFIFOW(login_fd, 2);
|
||||
size_t len;
|
||||
|
||||
@ -197,26 +197,25 @@ void chlogif_send_global_accreg(const char *key, unsigned int index, intptr_t va
|
||||
nlen += 4;
|
||||
|
||||
if( is_string ) {
|
||||
WFIFOB(login_fd, nlen) = val ? 2 : 3;
|
||||
WFIFOB(login_fd, nlen) = string_value ? 2 : 3;
|
||||
nlen += 1;
|
||||
|
||||
if( val ) {
|
||||
char *sval = (char*)val;
|
||||
len = strlen(sval)+1;
|
||||
if( string_value ) {
|
||||
len = strlen(string_value)+1;
|
||||
|
||||
WFIFOB(login_fd, nlen) = (unsigned char)len; // won't be higher; the column size is 254
|
||||
nlen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(login_fd,nlen), sval, len);
|
||||
safestrncpy(WFIFOCP(login_fd,nlen), string_value, len);
|
||||
nlen += len;
|
||||
}
|
||||
} else {
|
||||
WFIFOB(login_fd, nlen) = val ? 0 : 1;
|
||||
WFIFOB(login_fd, nlen) = int_value ? 0 : 1;
|
||||
nlen += 1;
|
||||
|
||||
if( val ) {
|
||||
WFIFOL(login_fd, nlen) = (int)val;
|
||||
nlen += 4;
|
||||
if( int_value ) {
|
||||
WFIFOQ(login_fd, nlen) = int_value;
|
||||
nlen += 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ TIMER_FUNC(chlogif_broadcast_user_count);
|
||||
void chlogif_send_usercount(int users);
|
||||
void chlogif_upd_global_accreg(uint32 account_id, uint32 char_id);
|
||||
void chlogif_prepsend_global_accreg(void);
|
||||
void chlogif_send_global_accreg(const char *key, unsigned int index, intptr_t val, bool is_string);
|
||||
void chlogif_send_global_accreg(const char *key, unsigned int index, int64 int_value, const char* string_value, bool is_string);
|
||||
void chlogif_request_accreg2(uint32 account_id, uint32 char_id);
|
||||
void chlogif_send_reqaccdata(int fd, struct char_session_data *sd);
|
||||
void chlogif_send_setacconline(int aid);
|
||||
|
@ -561,54 +561,54 @@ void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int accoun
|
||||
* @param val either str or int, depending on type
|
||||
* @param type false when int, true otherwise
|
||||
**/
|
||||
void inter_savereg(uint32 account_id, uint32 char_id, const char *key, unsigned int index, intptr_t val, bool is_string)
|
||||
void inter_savereg(uint32 account_id, uint32 char_id, const char *key, uint32 index, int64 int_value, const char* string_value, bool is_string)
|
||||
{
|
||||
char esc_val[254*2+1];
|
||||
char esc_key[32*2+1];
|
||||
|
||||
Sql_EscapeString(sql_handle, esc_key, key);
|
||||
if( is_string && val ) {
|
||||
Sql_EscapeString(sql_handle, esc_val, (char*)val);
|
||||
if( is_string && string_value ) {
|
||||
Sql_EscapeString(sql_handle, esc_val, string_value);
|
||||
}
|
||||
if( key[0] == '#' && key[1] == '#' ) { // global account reg
|
||||
if( session_isValid(login_fd) )
|
||||
chlogif_send_global_accreg(key,index,val,is_string);
|
||||
chlogif_send_global_accreg( key, index, int_value, string_value, is_string );
|
||||
else {
|
||||
ShowError("Login server unavailable, can't perform update on '%s' variable for AID:%d CID:%d\n",key,account_id,char_id);
|
||||
ShowError("Login server unavailable, can't perform update on '%s' variable for AID:%" PRIu32 " CID:%" PRIu32 "\n",key,account_id,char_id);
|
||||
}
|
||||
} else if ( key[0] == '#' ) { // local account reg
|
||||
if( is_string ) {
|
||||
if( val ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", schema_config.acc_reg_str_table, account_id, esc_key, index, esc_val) )
|
||||
if( string_value ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%s')", schema_config.acc_reg_str_table, account_id, esc_key, index, esc_val) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
} else {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", schema_config.acc_reg_str_table, account_id, esc_key, index) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", schema_config.acc_reg_str_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
} else {
|
||||
if( val ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", schema_config.acc_reg_num_table, account_id, esc_key, index, (int)val) )
|
||||
if( int_value ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%" PRId64 "')", schema_config.acc_reg_num_table, account_id, esc_key, index, int_value) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
} else {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", schema_config.acc_reg_num_table, account_id, esc_key, index) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", schema_config.acc_reg_num_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
}
|
||||
} else { /* char reg */
|
||||
if( is_string ) {
|
||||
if( val ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", schema_config.char_reg_str_table, char_id, esc_key, index, esc_val) )
|
||||
if( string_value ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%s')", schema_config.char_reg_str_table, char_id, esc_key, index, esc_val) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
} else {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", schema_config.char_reg_str_table, char_id, esc_key, index) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", schema_config.char_reg_str_table, char_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
} else {
|
||||
if( val ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", schema_config.char_reg_num_table, char_id, esc_key, index, (int)val) )
|
||||
if( int_value ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%" PRId64 "')", schema_config.char_reg_num_table, char_id, esc_key, index, int_value) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
} else {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", schema_config.char_reg_num_table, char_id, esc_key, index) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", schema_config.char_reg_num_table, char_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
}
|
||||
@ -624,11 +624,11 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
|
||||
|
||||
switch( type ) {
|
||||
case 3: //char reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", schema_config.char_reg_str_table, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%" PRIu32 "'", schema_config.char_reg_str_table, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 2: //account reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", schema_config.acc_reg_str_table, account_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", schema_config.acc_reg_str_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 1: //account2 reg
|
||||
@ -667,7 +667,7 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, NULL);
|
||||
|
||||
WFIFOL(fd, plen) = (unsigned int)atol(data);
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, NULL);
|
||||
@ -705,11 +705,11 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
|
||||
|
||||
switch( type ) {
|
||||
case 3: //char reg
|
||||
if (SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", schema_config.char_reg_num_table, char_id))
|
||||
if (SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%" PRIu32 "'", schema_config.char_reg_num_table, char_id))
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 2: //account reg
|
||||
if (SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", schema_config.acc_reg_num_table, account_id))
|
||||
if (SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", schema_config.acc_reg_num_table, account_id))
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
#if 0 // This is already checked above.
|
||||
@ -747,13 +747,13 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, NULL);
|
||||
|
||||
WFIFOL(fd, plen) = (unsigned int)atol(data);
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, NULL);
|
||||
|
||||
WFIFOL(fd, plen) = atoi(data);
|
||||
plen += 4;
|
||||
WFIFOQ(fd, plen) = strtoll(data,NULL,10);
|
||||
plen += 8;
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
@ -1258,7 +1258,8 @@ int mapif_parse_WisToGM(int fd)
|
||||
// Save account_reg into sql (type=2)
|
||||
int mapif_parse_Registry(int fd)
|
||||
{
|
||||
int account_id = RFIFOL(fd, 4), char_id = RFIFOL(fd, 8), count = RFIFOW(fd, 12);
|
||||
uint32 account_id = RFIFOL(fd, 4), char_id = RFIFOL(fd, 8);
|
||||
uint16 count = RFIFOW(fd, 12);
|
||||
|
||||
if( count ) {
|
||||
int cursor = 14, i;
|
||||
@ -1273,20 +1274,17 @@ int mapif_parse_Registry(int fd)
|
||||
std::string key( src_key, lenkey );
|
||||
cursor += lenkey + 1;
|
||||
|
||||
unsigned int index = RFIFOL(fd, cursor);
|
||||
uint32 index = RFIFOL(fd, cursor);
|
||||
cursor += 4;
|
||||
|
||||
switch (RFIFOB(fd, cursor++)) {
|
||||
// int
|
||||
case 0:
|
||||
{
|
||||
intptr_t lVal = RFIFOL( fd, cursor );
|
||||
inter_savereg( account_id, char_id, key.c_str(), index, lVal, false );
|
||||
cursor += 4;
|
||||
inter_savereg( account_id, char_id, key.c_str(), index, RFIFOQ( fd, cursor ), nullptr, false );
|
||||
cursor += 8;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
inter_savereg(account_id,char_id,key.c_str(),index,0,false);
|
||||
inter_savereg( account_id, char_id, key.c_str(), index, 0, nullptr, false );
|
||||
break;
|
||||
// str
|
||||
case 2:
|
||||
@ -1295,11 +1293,11 @@ int mapif_parse_Registry(int fd)
|
||||
const char* src_val= RFIFOCP(fd, cursor + 1);
|
||||
std::string sval( src_val, len_val );
|
||||
cursor += len_val + 1;
|
||||
inter_savereg( account_id, char_id, key.c_str(), index, (intptr_t)sval.c_str(), true );
|
||||
inter_savereg( account_id, char_id, key.c_str(), index, 0, sval.c_str(), true );
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
inter_savereg(account_id,char_id,key.c_str(),index,0,true);
|
||||
inter_savereg( account_id, char_id, key.c_str(), index, 0, nullptr, true );
|
||||
break;
|
||||
default:
|
||||
ShowError("mapif_parse_Registry: unknown type %d\n",RFIFOB(fd, cursor - 1));
|
||||
|
@ -42,7 +42,6 @@ extern unsigned int party_share_level;
|
||||
extern Sql* sql_handle;
|
||||
extern Sql* lsql_handle;
|
||||
|
||||
void inter_savereg(uint32 account_id, uint32 char_id, const char *key, unsigned int index, intptr_t val, bool is_string);
|
||||
int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type);
|
||||
|
||||
#endif /* INTER_HPP */
|
||||
|
@ -2707,6 +2707,22 @@ DBData db_ptr2data(void *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manual cast from 'int' to the struct DBData.
|
||||
* @param data Data to be casted
|
||||
* @return The data as a DBData struct
|
||||
* @public
|
||||
*/
|
||||
DBData db_i642data(int64 data)
|
||||
{
|
||||
DBData ret;
|
||||
|
||||
DB_COUNTSTAT(db_i2data);
|
||||
ret.type = DB_DATA_I64;
|
||||
ret.u.i64 = data;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets int type data from struct DBData.
|
||||
* If data is not int type, returns 0.
|
||||
@ -2752,6 +2768,21 @@ void* db_data2ptr(DBData *data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets int64 type data from struct DBData.
|
||||
* If data is not int64 type, returns 0.
|
||||
* @param data Data
|
||||
* @return Integer(64-bit signed) value of the data.
|
||||
* @public
|
||||
*/
|
||||
int64 db_data2i64(DBData *data)
|
||||
{
|
||||
DB_COUNTSTAT(db_data2i64);
|
||||
if (data && DB_DATA_I64 == data->type)
|
||||
return data->u.i64;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the database system.
|
||||
* @public
|
||||
|
@ -167,6 +167,7 @@ typedef enum DBDataType {
|
||||
DB_DATA_INT,
|
||||
DB_DATA_UINT,
|
||||
DB_DATA_PTR,
|
||||
DB_DATA_I64
|
||||
} DBDataType;
|
||||
|
||||
/**
|
||||
@ -176,6 +177,7 @@ typedef enum DBDataType {
|
||||
* @param u.i Data of int type
|
||||
* @param u.ui Data of unsigned int type
|
||||
* @param u.ptr Data of void* type
|
||||
* @param u.i64 Data of int64 type
|
||||
* @public
|
||||
*/
|
||||
typedef struct DBData {
|
||||
@ -184,6 +186,7 @@ typedef struct DBData {
|
||||
int i;
|
||||
unsigned int ui;
|
||||
void *ptr;
|
||||
int64 i64;
|
||||
} u;
|
||||
} DBData;
|
||||
|
||||
@ -638,6 +641,14 @@ struct DBMap {
|
||||
#define i64db_uiget(db,k) ( db_data2ui((db)->get((db),db_i642key(k))) )
|
||||
#define ui64db_uiget(db,k) ( db_data2ui((db)->get((db),db_ui642key(k))) )
|
||||
|
||||
// Get int64-type data from DBMaps of various key types
|
||||
#define db_i64get(db,k) ( db_data2i64((db)->get((db),(k))) )
|
||||
#define idb_i64get(db,k) ( db_data2i64((db)->get((db),db_i2key(k))) )
|
||||
#define uidb_i64get(db,k) ( db_data2i64((db)->get((db),db_ui2key(k))) )
|
||||
#define strdb_i64get(db,k) ( db_data2i64((db)->get((db),db_str2key(k))) )
|
||||
#define i64db_i64get(db,k) ( db_data2i64((db)->get((db),db_i642key(k))) )
|
||||
#define ui64db_i64get(db,k) ( db_data2i64((db)->get((db),db_ui642key(k))) )
|
||||
|
||||
// Put pointer-type data into DBMaps of various key types
|
||||
#define db_put(db,k,d) ( (db)->put((db),(k),db_ptr2data(d),NULL) )
|
||||
#define idb_put(db,k,d) ( (db)->put((db),db_i2key(k),db_ptr2data(d),NULL) )
|
||||
@ -662,6 +673,14 @@ struct DBMap {
|
||||
#define i64db_uiput(db,k,d) ( (db)->put((db),db_i642key(k),db_ui2data(d),NULL) )
|
||||
#define ui64db_uiput(db,k,d) ( (db)->put((db),db_ui642key(k),db_ui2data(d),NULL) )
|
||||
|
||||
// Put int64 data into DBMaps of various key types
|
||||
#define db_i64put(db,k,d) ( (db)->put((db),(k),db_i642data(d),NULL) )
|
||||
#define idb_i64put(db,k,d) ( (db)->put((db),db_i2key(k),db_i642data(d),NULL) )
|
||||
#define uidb_i64put(db,k,d) ( (db)->put((db),db_ui2key(k),db_i642data(d),NULL) )
|
||||
#define strdb_i64put(db,k,d) ( (db)->put((db),db_str2key(k),db_i642data(d),NULL) )
|
||||
#define i64db_i64put(db,k,d) ( (db)->put((db),db_i642key(k),db_i642data(d),NULL) )
|
||||
#define ui64db_i64put(db,k,d) ( (db)->put((db),db_ui642key(k),db_i642data(d),NULL) )
|
||||
|
||||
// Remove entry from DBMaps of various key types
|
||||
#define db_remove(db,k) ( (db)->remove((db),(k),NULL) )
|
||||
#define idb_remove(db,k) ( (db)->remove((db),db_i2key(k),NULL) )
|
||||
@ -872,6 +891,14 @@ DBData db_ui2data(unsigned int data);
|
||||
*/
|
||||
DBData db_ptr2data(void *data);
|
||||
|
||||
/**
|
||||
* Manual cast from 'int64' to the struct DBData.
|
||||
* @param data Data to be casted
|
||||
* @return The data as a DBData struct
|
||||
* @public
|
||||
*/
|
||||
DBData db_i642data(int64 data);
|
||||
|
||||
/**
|
||||
* Gets int type data from struct DBData.
|
||||
* If data is not int type, returns 0.
|
||||
@ -899,6 +926,15 @@ unsigned int db_data2ui(DBData *data);
|
||||
*/
|
||||
void* db_data2ptr(DBData *data);
|
||||
|
||||
/**
|
||||
* Gets int64 type data from struct DBData.
|
||||
* If data is not int64 type, returns 0.
|
||||
* @param data Data
|
||||
* @return Integer(64-bit signed) value of the data.
|
||||
* @public
|
||||
*/
|
||||
int64 db_data2i64(DBData *data);
|
||||
|
||||
/**
|
||||
* Initialize the database system.
|
||||
* @public
|
||||
|
@ -322,7 +322,7 @@ struct script_reg_state {
|
||||
|
||||
struct script_reg_num {
|
||||
struct script_reg_state flag;
|
||||
int value;
|
||||
int64 value;
|
||||
};
|
||||
|
||||
struct script_reg_str {
|
||||
|
@ -64,3 +64,71 @@ int levenshtein(const std::string &s1, const std::string &s2)
|
||||
delete[] column;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool rathena::util::safe_addition( int64 a, int64 b, int64& result ){
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_add_overflow( a, b, &result );
|
||||
#else
|
||||
bool overflow = false;
|
||||
|
||||
if( b < 0 ){
|
||||
if( a < ( INT64_MIN - b ) ){
|
||||
overflow = true;
|
||||
}
|
||||
}else{
|
||||
if( a > ( INT64_MAX - b ) ){
|
||||
overflow = true;
|
||||
}
|
||||
}
|
||||
|
||||
result = a + b;
|
||||
|
||||
return overflow;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rathena::util::safe_substraction( int64 a, int64 b, int64& result ){
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_sub_overflow( a, b, &result );
|
||||
#else
|
||||
bool overflow = false;
|
||||
|
||||
if( b < 0 ){
|
||||
if( a > ( INT64_MAX + b ) ){
|
||||
overflow = true;
|
||||
}
|
||||
}else{
|
||||
if( a < ( INT64_MIN + b ) ){
|
||||
overflow = true;
|
||||
}
|
||||
}
|
||||
|
||||
result = a - b;
|
||||
|
||||
return overflow;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rathena::util::safe_multiplication( int64 a, int64 b, int64& result ){
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_mul_overflow( a, b, &result );
|
||||
#else
|
||||
result = a * b;
|
||||
|
||||
if( a > 0 ){
|
||||
if( b > 0 ){
|
||||
return result < 0;
|
||||
}else if( b < 0 ){
|
||||
return result > 0;
|
||||
}
|
||||
}else if( a < 0 ){
|
||||
if( b > 0 ){
|
||||
return result > 0;
|
||||
}else if( b < 0 ){
|
||||
return result < 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
@ -134,6 +134,10 @@ namespace rathena {
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool safe_addition( int64 a, int64 b, int64& result );
|
||||
bool safe_substraction( int64 a, int64 b, int64& result );
|
||||
bool safe_multiplication( int64 a, int64 b, int64& result );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -641,17 +641,17 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
|
||||
return result;
|
||||
}
|
||||
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, int account_id, int char_id) {
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
int count = RFIFOW(fd, 12);
|
||||
uint16 count = RFIFOW(fd, 12);
|
||||
|
||||
if (count) {
|
||||
int cursor = 14, i;
|
||||
char key[32], sval[254], esc_key[32*2+1], esc_sval[254*2+1];
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
unsigned int index;
|
||||
uint32 index;
|
||||
safestrncpy(key, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
Sql_EscapeString(sql_handle, esc_key, key);
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
@ -662,12 +662,12 @@ void mmo_save_global_accreg(AccountDB* self, int fd, int account_id, int char_id
|
||||
switch (RFIFOB(fd, cursor++)) {
|
||||
// int
|
||||
case 0:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%d')", db->global_acc_reg_num_table, account_id, esc_key, index, RFIFOL(fd, cursor)) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%" PRId64 "')", db->global_acc_reg_num_table, account_id, esc_key, index, RFIFOQ(fd, cursor)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
cursor += 4;
|
||||
cursor += 8;
|
||||
break;
|
||||
case 1:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", db->global_acc_reg_num_table, account_id, esc_key, index) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_num_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
// str
|
||||
@ -675,11 +675,11 @@ void mmo_save_global_accreg(AccountDB* self, int fd, int account_id, int char_id
|
||||
safestrncpy(sval, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
Sql_EscapeString(sql_handle, esc_sval, sval);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", db->global_acc_reg_str_table, account_id, esc_key, index, esc_sval) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%s')", db->global_acc_reg_str_table, account_id, esc_key, index, esc_sval) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 3:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", db->global_acc_reg_str_table, account_id, esc_key, index) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_str_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
default:
|
||||
@ -690,14 +690,14 @@ void mmo_save_global_accreg(AccountDB* self, int fd, int account_id, int char_id
|
||||
}
|
||||
}
|
||||
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, int account_id, int char_id) {
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
char* data;
|
||||
int plen = 0;
|
||||
size_t len;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_str_table, account_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_str_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
@ -728,7 +728,7 @@ void mmo_send_global_accreg(AccountDB* self, int fd, int account_id, int char_id
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, NULL);
|
||||
|
||||
WFIFOL(fd, plen) = (unsigned int)atol(data);
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, NULL);
|
||||
@ -764,7 +764,7 @@ void mmo_send_global_accreg(AccountDB* self, int fd, int account_id, int char_id
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_num_table, account_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_num_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
@ -795,13 +795,13 @@ void mmo_send_global_accreg(AccountDB* self, int fd, int account_id, int char_id
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, NULL);
|
||||
|
||||
WFIFOL(fd, plen) = (unsigned int)atol(data);
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, NULL);
|
||||
|
||||
WFIFOL(fd, plen) = atoi(data);
|
||||
plen += 4;
|
||||
WFIFOQ(fd, plen) = strtoll(data,NULL,10);
|
||||
plen += 8;
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
|
@ -132,7 +132,7 @@ struct AccountDB {
|
||||
AccountDBIterator* (*iterator)(AccountDB* self);
|
||||
};
|
||||
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, int account_id, int char_id);
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, int account_id, int char_id);
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
|
||||
#endif /* ACCOUNT_HPP */
|
||||
|
@ -77,7 +77,7 @@ uint64 AchievementDatabase::parseBodyNode(const YAML::Node &node){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int constant;
|
||||
int64 constant;
|
||||
|
||||
if( !script_get_constant( group_name.c_str(), &constant ) ){
|
||||
this->invalidWarning( node, "achievement_read_db_sub: Invalid group %s for achievement %d, skipping.\n", group_name.c_str(), achievement_id );
|
||||
|
@ -9259,7 +9259,8 @@ ACMD_FUNC(accinfo) {
|
||||
*/
|
||||
ACMD_FUNC(set) {
|
||||
char reg[46], val[128], name[32];
|
||||
int toset = 0, len, index;
|
||||
int toset = 0, len;
|
||||
uint32 index;
|
||||
bool is_str = false;
|
||||
int64 uid;
|
||||
|
||||
@ -9281,7 +9282,7 @@ ACMD_FUNC(set) {
|
||||
}
|
||||
|
||||
// Check if the user wanted to set an array
|
||||
if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
|
||||
if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
|
||||
// The user did not specify array brackets, so we set the index to zero
|
||||
index = 0;
|
||||
}
|
||||
@ -9297,7 +9298,11 @@ ACMD_FUNC(set) {
|
||||
|
||||
// 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 );
|
||||
if( is_str ){
|
||||
setd_sub_str( NULL, sd, name, index, val, NULL );
|
||||
}else{
|
||||
setd_sub_num( NULL, sd, name, index, strtoll( val, NULL, 10 ), NULL );
|
||||
}
|
||||
}
|
||||
|
||||
uid = reference_uid( add_str( name ), index );
|
||||
@ -9326,10 +9331,10 @@ ACMD_FUNC(set) {
|
||||
if( value == NULL || *value == '\0' ){// empty string
|
||||
sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
|
||||
}else{
|
||||
sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
|
||||
sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
|
||||
}
|
||||
} else {// integer variable
|
||||
int value;
|
||||
int64 value;
|
||||
|
||||
switch( reg[0] ) {
|
||||
case '@':
|
||||
@ -9349,7 +9354,7 @@ ACMD_FUNC(set) {
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
|
||||
sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
|
||||
}
|
||||
|
||||
clif_displaymessage(fd, atcmd_output);
|
||||
|
@ -1320,7 +1320,8 @@ bool channel_read_sub(config_setting_t *chan, struct Channel *tmp_chan, uint8 i)
|
||||
config_setting_t *group_list = NULL;
|
||||
int delay = 1000, autojoin = 0, leave = 1, chat = 1, color_override = 0,
|
||||
self_notif = 1, join_notif = 0, leave_notif = 0;
|
||||
int type = CHAN_TYPE_PUBLIC, group_count = 0;
|
||||
int64 type = CHAN_TYPE_PUBLIC;
|
||||
int group_count = 0;
|
||||
const char *name = NULL, *password = NULL, *alias = NULL, *color_str = "Default", *type_str = NULL;
|
||||
|
||||
if (tmp_chan == NULL)
|
||||
|
@ -11362,7 +11362,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
|
||||
for( i = 0; i < NUM_WHISPER_VAR; ++i ) {
|
||||
char variablename[CHAT_SIZE_MAX];
|
||||
safesnprintf(variablename,sizeof(variablename),"@whispervar%d$", i);
|
||||
set_var(sd,variablename,(char *) split_data[i]);
|
||||
set_var_str( sd, variablename, split_data[i] );
|
||||
}
|
||||
|
||||
safesnprintf(event,sizeof(event),"%s::%s", npc->exname,script_config.onwhisper_event_name);
|
||||
|
@ -63,7 +63,7 @@ void duel_savetime(struct map_session_data* sd)
|
||||
*/
|
||||
bool duel_checktime(struct map_session_data* sd)
|
||||
{
|
||||
int diff;
|
||||
int64 diff;
|
||||
time_t timer;
|
||||
struct tm *t;
|
||||
|
||||
|
@ -479,8 +479,8 @@ int intif_saveregistry(struct map_session_data *sd)
|
||||
plen += 1;
|
||||
|
||||
if( p->value ) {
|
||||
WFIFOL(inter_fd, plen) = p->value;
|
||||
plen += 4;
|
||||
WFIFOQ(inter_fd, plen) = p->value;
|
||||
plen += 8;
|
||||
} else {
|
||||
script_reg_destroy_single(sd,key.i64,&p->flag);
|
||||
}
|
||||
@ -1407,7 +1407,7 @@ void intif_parse_Registers(int fd)
|
||||
|
||||
if( RFIFOW(fd, 14) ) {
|
||||
char key[32];
|
||||
unsigned int index;
|
||||
uint32 index;
|
||||
int max = RFIFOW(fd, 14), cursor = 16, i;
|
||||
|
||||
/**
|
||||
@ -1428,7 +1428,7 @@ void intif_parse_Registers(int fd)
|
||||
safestrncpy(sval, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
|
||||
set_reg(NULL,sd,reference_uid(add_str(key), index), key, (void*)sval, NULL);
|
||||
set_reg_str( NULL, sd, reference_uid( add_str( key ), index ), key, sval, NULL );
|
||||
}
|
||||
/**
|
||||
* Vessel!
|
||||
@ -1438,17 +1438,17 @@ void intif_parse_Registers(int fd)
|
||||
**/
|
||||
} else {
|
||||
for(i = 0; i < max; i++) {
|
||||
int ival;
|
||||
int64 ival;
|
||||
safestrncpy(key, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
|
||||
index = RFIFOL(fd, cursor);
|
||||
cursor += 4;
|
||||
|
||||
ival = RFIFOL(fd, cursor);
|
||||
cursor += 4;
|
||||
ival = RFIFOQ(fd, cursor);
|
||||
cursor += 8;
|
||||
|
||||
set_reg(NULL,sd,reference_uid(add_str(key), index), key, (void*)__64BPRTSIZE(ival), NULL);
|
||||
set_reg_num( NULL, sd, reference_uid( add_str( key ), index ), key, ival, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -634,8 +634,14 @@ static bool itemdb_read_group(char* str[], int columns, int current) {
|
||||
if( ISDIGIT(str[0][0]) ){
|
||||
group_id = atoi(str[0]);
|
||||
}else{
|
||||
int64 group_tmp;
|
||||
|
||||
// Try to parse group id as constant
|
||||
script_get_constant(str[0], &group_id);
|
||||
if (!script_get_constant(str[0], &group_tmp)) {
|
||||
ShowError("itemdb_read_group: Unknown group constant \"%s\".\n", str[0]);
|
||||
return false;
|
||||
}
|
||||
group_id = static_cast<int>(group_tmp);
|
||||
}
|
||||
|
||||
// Check the group id
|
||||
@ -830,7 +836,7 @@ static bool itemdb_read_itemdelay(char* str[], int columns, int current) {
|
||||
else if( ISDIGIT(str[2][0]) )
|
||||
id->delay_sc = atoi(str[2]);
|
||||
else{ // Try read sc group id from const db
|
||||
int constant;
|
||||
int64 constant;
|
||||
|
||||
if( !script_get_constant(trim(str[2]), &constant) ){
|
||||
ShowWarning("itemdb_read_itemdelay: Invalid sc group \"%s\" for item id %hu.\n", str[2], nameid);
|
||||
@ -1707,7 +1713,13 @@ static bool itemdb_read_randomopt(const char* basedir, bool silent) {
|
||||
id = atoi(str[0]);
|
||||
}
|
||||
else {
|
||||
script_get_constant(str[0], &id);
|
||||
int64 id_tmp;
|
||||
|
||||
if (!script_get_constant(str[0], &id_tmp)) {
|
||||
ShowError("itemdb_read_randopt: Unknown random option constant \"%s\".\n", str[0]);
|
||||
continue;
|
||||
}
|
||||
id = static_cast<int>(id_tmp);
|
||||
}
|
||||
|
||||
if (id < 0) {
|
||||
@ -1769,15 +1781,19 @@ struct s_random_opt_group *itemdb_randomopt_group_exists(int id) {
|
||||
* @author [Cydh]
|
||||
**/
|
||||
static bool itemdb_read_randomopt_group(char* str[], int columns, int current) {
|
||||
int id = 0, i;
|
||||
int64 id_tmp;
|
||||
int id = 0;
|
||||
int i;
|
||||
unsigned short rate = (unsigned short)strtoul(str[1], NULL, 10);
|
||||
struct s_random_opt_group *g = NULL;
|
||||
|
||||
if (!script_get_constant(str[0], &id)) {
|
||||
if (!script_get_constant(str[0], &id_tmp)) {
|
||||
ShowError("itemdb_read_randomopt_group: Invalid ID for Random Option Group '%s'.\n", str[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = static_cast<int>(id_tmp);
|
||||
|
||||
if ((columns-2)%3 != 0) {
|
||||
ShowError("itemdb_read_randomopt_group: Invalid column entries '%d'.\n", columns);
|
||||
return false;
|
||||
@ -1797,8 +1813,10 @@ static bool itemdb_read_randomopt_group(char* str[], int columns, int current) {
|
||||
int j, k;
|
||||
memset(&g->entries[i].option, 0, sizeof(g->entries[i].option));
|
||||
for (j = 0, k = 2; k < columns && j < MAX_ITEM_RDM_OPT; k+=3) {
|
||||
int64 randid_tmp;
|
||||
int randid = 0;
|
||||
if (!script_get_constant(str[k], &randid) || !itemdb_randomopt_exists(randid)) {
|
||||
|
||||
if (!script_get_constant(str[k], &randid_tmp) || ((randid = static_cast<int>(randid_tmp)) && !itemdb_randomopt_exists(randid))) {
|
||||
ShowError("itemdb_read_randomopt_group: Invalid random group id '%s' in column %d!\n", str[k], k+1);
|
||||
continue;
|
||||
}
|
||||
|
@ -4517,7 +4517,7 @@ static int map_mapflag_pvp_stop_sub(struct block_list *bl, va_list ap)
|
||||
enum e_mapflag map_getmapflag_by_name(char* name)
|
||||
{
|
||||
char flag_constant[255];
|
||||
int mapflag;
|
||||
int64 mapflag;
|
||||
|
||||
safesnprintf(flag_constant, sizeof(flag_constant), "mf_%s", name);
|
||||
|
||||
|
@ -34,7 +34,7 @@ struct reg_db regs;
|
||||
* @param uid: variable's unique identifier.
|
||||
* @return: variable's integer value
|
||||
*/
|
||||
int mapreg_readreg(int64 uid)
|
||||
int64 mapreg_readreg(int64 uid)
|
||||
{
|
||||
struct mapreg_save *m = (struct mapreg_save *)i64db_get(regs.vars, uid);
|
||||
return m ? m->u.i : 0;
|
||||
@ -59,11 +59,11 @@ char* mapreg_readregstr(int64 uid)
|
||||
* @param val new value
|
||||
* @return: true value was successfully set
|
||||
*/
|
||||
bool mapreg_setreg(int64 uid, int val)
|
||||
bool mapreg_setreg(int64 uid, int64 val)
|
||||
{
|
||||
struct mapreg_save *m;
|
||||
int num = script_getvarid(uid);
|
||||
unsigned int i = script_getvaridx(uid);
|
||||
uint32 i = script_getvaridx(uid);
|
||||
const char* name = get_str(num);
|
||||
|
||||
if (val != 0) {
|
||||
@ -87,7 +87,7 @@ bool mapreg_setreg(int64 uid, int val)
|
||||
if (name[1] != '@' && !skip_insert) {// write new variable to database
|
||||
char esc_name[32 * 2 + 1];
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_name, name, strnlen(name, 32));
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, esc_name, i, val))
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%" PRIu32 "','%" PRId64 "')", mapreg_table, esc_name, i, val))
|
||||
Sql_ShowDebug(mmysql_handle);
|
||||
}
|
||||
i64db_put(regs.vars, uid, m);
|
||||
@ -103,7 +103,7 @@ bool mapreg_setreg(int64 uid, int val)
|
||||
if (name[1] != '@') {// Remove from database because it is unused.
|
||||
char esc_name[32 * 2 + 1];
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_name, name, strnlen(name, 32));
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, esc_name, i))
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%" PRIu32 "'", mapreg_table, esc_name, i))
|
||||
Sql_ShowDebug(mmysql_handle);
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ bool mapreg_setregstr(int64 uid, const char* str)
|
||||
{
|
||||
struct mapreg_save *m;
|
||||
int num = script_getvarid(uid);
|
||||
unsigned int i = script_getvaridx(uid);
|
||||
uint32 i = script_getvaridx(uid);
|
||||
const char* name = get_str(num);
|
||||
|
||||
if (str == NULL || *str == 0) {
|
||||
@ -131,7 +131,7 @@ bool mapreg_setregstr(int64 uid, const char* str)
|
||||
if (name[1] != '@') {
|
||||
char esc_name[32 * 2 + 1];
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_name, name, strnlen(name, 32));
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, esc_name, i))
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%" PRIu32 "'", mapreg_table, esc_name, i))
|
||||
Sql_ShowDebug(mmysql_handle);
|
||||
}
|
||||
if ((m = static_cast<mapreg_save *>(i64db_get(regs.vars, uid)))) {
|
||||
@ -165,7 +165,7 @@ bool mapreg_setregstr(int64 uid, const char* str)
|
||||
char esc_str[255 * 2 + 1];
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_name, name, strnlen(name, 32));
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_str, str, strnlen(str, 255));
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, esc_name, i, esc_str))
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%" PRIu32 "','%s')", mapreg_table, esc_name, i, esc_str))
|
||||
Sql_ShowDebug(mmysql_handle);
|
||||
}
|
||||
i64db_put(regs.vars, uid, m);
|
||||
@ -188,7 +188,7 @@ static void script_load_mapreg(void)
|
||||
*/
|
||||
SqlStmt* stmt = SqlStmt_Malloc(mmysql_handle);
|
||||
char varname[32+1];
|
||||
int index;
|
||||
uint32 index;
|
||||
char value[255+1];
|
||||
uint32 length;
|
||||
|
||||
@ -203,21 +203,21 @@ static void script_load_mapreg(void)
|
||||
skip_insert = true;
|
||||
|
||||
SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], sizeof(varname), &length, NULL);
|
||||
SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &index, 0, NULL, NULL);
|
||||
SqlStmt_BindColumn(stmt, 1, SQLDT_UINT32, &index, 0, NULL, NULL);
|
||||
SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], sizeof(value), NULL, NULL);
|
||||
|
||||
while ( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) {
|
||||
int s = add_str(varname);
|
||||
int i = index;
|
||||
int64 uid = reference_uid(s, index);
|
||||
|
||||
if( i64db_exists(regs.vars, reference_uid(s, i)) ) {
|
||||
if( i64db_exists(regs.vars, uid) ) {
|
||||
ShowWarning("load_mapreg: duplicate! '%s' => '%s' skipping...\n",varname,value);
|
||||
continue;
|
||||
}
|
||||
if( varname[length-1] == '$' ) {
|
||||
mapreg_setregstr(reference_uid(s, i), value);
|
||||
mapreg_setregstr(uid, value);
|
||||
} else {
|
||||
mapreg_setreg(reference_uid(s, i), atoi(value));
|
||||
mapreg_setreg(uid, strtoll(value,NULL,10));
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,19 +238,19 @@ static void script_save_mapreg(void)
|
||||
for (m = static_cast<mapreg_save *>(dbi_first(iter)); dbi_exists(iter); m = static_cast<mapreg_save *>(dbi_next(iter))) {
|
||||
if (m->save) {
|
||||
int num = script_getvarid(m->uid);
|
||||
int i = script_getvaridx(m->uid);
|
||||
uint32 i = script_getvaridx(m->uid);
|
||||
const char* name = get_str(num);
|
||||
if (!m->is_string) {
|
||||
char esc_name[32 * 2 + 1];
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_name, name, strnlen(name, 32));
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, esc_name, i))
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%" PRId64 "' WHERE `varname`='%s' AND `index`='%" PRIu32 "' LIMIT 1", mapreg_table, m->u.i, esc_name, i))
|
||||
Sql_ShowDebug(mmysql_handle);
|
||||
} else {
|
||||
char esc_str[2 * 255 + 1];
|
||||
char esc_name[32 * 2 + 1];
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_name, name, strnlen(name, 32));
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_str, m->u.str, safestrnlen(m->u.str, 255));
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, esc_str, esc_name, i))
|
||||
if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%" PRIu32 "' LIMIT 1", mapreg_table, esc_str, esc_name, i))
|
||||
Sql_ShowDebug(mmysql_handle);
|
||||
}
|
||||
m->save = false;
|
||||
|
@ -10,7 +10,7 @@
|
||||
struct mapreg_save {
|
||||
int64 uid; ///< Unique ID
|
||||
union {
|
||||
int i; ///< Numeric value
|
||||
int64 i; ///< Numeric value
|
||||
char *str; ///< String value
|
||||
} u;
|
||||
bool is_string; ///< true if it's a string, false if it's a number
|
||||
@ -25,9 +25,9 @@ void mapreg_final(void);
|
||||
void mapreg_init(void);
|
||||
bool mapreg_config_read(const char* w1, const char* w2);
|
||||
|
||||
int mapreg_readreg(int64 uid);
|
||||
int64 mapreg_readreg(int64 uid);
|
||||
char* mapreg_readregstr(int64 uid);
|
||||
bool mapreg_setreg(int64 uid, int val);
|
||||
bool mapreg_setreg(int64 uid, int64 val);
|
||||
bool mapreg_setregstr(int64 uid, const char* str);
|
||||
int mapreg_destroyreg(DBKey key, DBData *data, va_list ap);
|
||||
|
||||
|
@ -4379,7 +4379,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
|
||||
if (!this->asString(node, "Sprite", sprite))
|
||||
return 0;
|
||||
|
||||
int constant;
|
||||
int64 constant;
|
||||
|
||||
if (script_get_constant(sprite.c_str(), &constant)) {
|
||||
if (npcdb_checkid(constant) == 0 && pcdb_checkid(constant) == 0) {
|
||||
@ -4397,7 +4397,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
|
||||
constant = sprite_mob->vd.class_;
|
||||
}
|
||||
|
||||
mob->vd.class_ = constant;
|
||||
mob->vd.class_ = (unsigned short)constant;
|
||||
} else {
|
||||
this->invalidWarning(node["Sprite"], "Sprite is missing.\n");
|
||||
return 0;
|
||||
@ -4416,7 +4416,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
|
||||
|
||||
std::string sex_constant = "SEX_" + sex;
|
||||
|
||||
int constant;
|
||||
int64 constant;
|
||||
|
||||
if (!script_get_constant(sex_constant.c_str(), &constant)) {
|
||||
this->invalidWarning(node["Sex"], "Unknown sex constant %s.\n", sex.c_str());
|
||||
@ -4428,7 +4428,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
mob->vd.sex = constant;
|
||||
mob->vd.sex = (char)constant;
|
||||
}
|
||||
|
||||
if (this->nodeExists(node, "HairStyle")) {
|
||||
@ -4620,7 +4620,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
|
||||
for (const auto &optionNode : node["Options"]) {
|
||||
std::string option = optionNode.first.as<std::string>();
|
||||
std::string option_constant = "OPTION_" + option;
|
||||
int constant;
|
||||
int64 constant;
|
||||
|
||||
if (!script_get_constant(option_constant.c_str(), &constant)) {
|
||||
this->invalidWarning(optionNode, "Unknown option constant %s, skipping.\n", option.c_str());
|
||||
@ -4665,9 +4665,14 @@ static bool mob_readdb_group(char* str[], int columns, int current){
|
||||
|
||||
if (ISDIGIT(str[0][0]) && ISDIGIT(str[0][1]))
|
||||
group = atoi(str[0]);
|
||||
else if (!script_get_constant(str[0], &group)) {
|
||||
ShowError("mob_readdb_group: Invalid random monster group '%s'\n", str[0]);
|
||||
return false;
|
||||
else {
|
||||
int64 group_tmp;
|
||||
|
||||
if (!script_get_constant(str[0], &group_tmp)) {
|
||||
ShowError("mob_readdb_group: Invalid random monster group '%s'\n", str[0]);
|
||||
return false;
|
||||
}
|
||||
group = static_cast<int>(group_tmp);
|
||||
}
|
||||
|
||||
mob_id = atoi(str[1]);
|
||||
@ -5077,7 +5082,8 @@ static int mob_read_sqlskilldb(void)
|
||||
*------------------------------------------*/
|
||||
static bool mob_readdb_race2(char* fields[], int columns, int current)
|
||||
{
|
||||
int race, i;
|
||||
int64 race;
|
||||
int i;
|
||||
|
||||
if( ISDIGIT(fields[0][0]) )
|
||||
race = atoi(fields[0]);
|
||||
@ -5087,7 +5093,7 @@ static bool mob_readdb_race2(char* fields[], int columns, int current)
|
||||
}
|
||||
|
||||
if (!CHK_RACE2(race)) {
|
||||
ShowWarning("mob_readdb_race2: Unknown race2 %d.\n", race);
|
||||
ShowWarning("mob_readdb_race2: Unknown race2 %lld.\n", race);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -5096,7 +5102,7 @@ static bool mob_readdb_race2(char* fields[], int columns, int current)
|
||||
struct mob_db* db = mob_db(mob_id);
|
||||
|
||||
if (db == NULL) {
|
||||
ShowWarning("mob_readdb_race2: Unknown mob id %d for race2 %d.\n", mob_id, race);
|
||||
ShowWarning("mob_readdb_race2: Unknown mob id %d for race2 %lld.\n", mob_id, race);
|
||||
continue;
|
||||
}
|
||||
db->race2 = (enum e_race2)race;
|
||||
@ -5205,11 +5211,14 @@ static bool mob_readdb_drop(char* str[], int columns, int current) {
|
||||
drop[i].randomopt_group = 0;
|
||||
|
||||
if (columns > 3) {
|
||||
int64 randomopt_group_tmp = -1;
|
||||
int randomopt_group = -1;
|
||||
if (!script_get_constant(trim(str[3]), &randomopt_group)) {
|
||||
|
||||
if (!script_get_constant(trim(str[3]), &randomopt_group_tmp)) {
|
||||
ShowError("mob_readdb_drop: Invalid 'randopt_groupid' '%s' for monster '%hu'.\n", str[3], mobid);
|
||||
return false;
|
||||
}
|
||||
randomopt_group = static_cast<int>(randomopt_group_tmp);
|
||||
if (randomopt_group == RDMOPTG_None)
|
||||
return true;
|
||||
if (!itemdb_randomopt_group_exists(randomopt_group)) {
|
||||
|
@ -1704,7 +1704,7 @@ void npc_shop_currency_type(struct map_session_data *sd, struct npc_data *nd, in
|
||||
clif_broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE,SELF);
|
||||
}
|
||||
|
||||
cost[0] = pc_readreg2(sd, nd->u.shop.pointshop_str);
|
||||
cost[0] = static_cast<int>(pc_readreg2(sd, nd->u.shop.pointshop_str));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1813,13 +1813,13 @@ static int npc_buylist_sub(struct map_session_data* sd, uint16 n, struct s_npc_b
|
||||
int i, key_nameid = 0, key_amount = 0;
|
||||
|
||||
// discard old contents
|
||||
script_cleararray_pc(sd, "@bought_nameid", (void*)0);
|
||||
script_cleararray_pc(sd, "@bought_quantity", (void*)0);
|
||||
script_cleararray_pc( sd, "@bought_nameid" );
|
||||
script_cleararray_pc( sd, "@bought_quantity" );
|
||||
|
||||
// save list of bought items
|
||||
for (i = 0; i < n; i++) {
|
||||
script_setarray_pc(sd, "@bought_nameid", i, (void*)(intptr_t)item_list[i].nameid, &key_nameid);
|
||||
script_setarray_pc(sd, "@bought_quantity", i, (void*)(intptr_t)item_list[i].qty, &key_amount);
|
||||
script_setarray_pc( sd, "@bought_nameid", i, item_list[i].nameid, &key_nameid );
|
||||
script_setarray_pc( sd, "@bought_quantity", i, item_list[i].qty, &key_amount );
|
||||
}
|
||||
|
||||
// invoke event
|
||||
@ -2000,28 +2000,28 @@ static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short*
|
||||
int key_option_id[MAX_ITEM_RDM_OPT], key_option_val[MAX_ITEM_RDM_OPT], key_option_param[MAX_ITEM_RDM_OPT];
|
||||
|
||||
// discard old contents
|
||||
script_cleararray_pc(sd, "@sold_nameid", (void*)0);
|
||||
script_cleararray_pc(sd, "@sold_quantity", (void*)0);
|
||||
script_cleararray_pc(sd, "@sold_refine", (void*)0);
|
||||
script_cleararray_pc(sd, "@sold_attribute", (void*)0);
|
||||
script_cleararray_pc(sd, "@sold_identify", (void*)0);
|
||||
script_cleararray_pc( sd, "@sold_nameid" );
|
||||
script_cleararray_pc( sd, "@sold_quantity" );
|
||||
script_cleararray_pc( sd, "@sold_refine" );
|
||||
script_cleararray_pc( sd, "@sold_attribute" );
|
||||
script_cleararray_pc( sd, "@sold_identify" );
|
||||
|
||||
for( j = 0; j < MAX_SLOTS; j++ )
|
||||
{// clear each of the card slot entries
|
||||
key_card[j] = 0;
|
||||
snprintf(card_slot, sizeof(card_slot), "@sold_card%d", j + 1);
|
||||
script_cleararray_pc(sd, card_slot, (void*)0);
|
||||
script_cleararray_pc( sd, card_slot );
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_ITEM_RDM_OPT; j++) { // Clear each of the item option entries
|
||||
key_option_id[j] = key_option_val[j] = key_option_param[j] = 0;
|
||||
|
||||
snprintf(option_id, sizeof(option_id), "@sold_option_id%d", j + 1);
|
||||
script_cleararray_pc(sd, option_id, (void *)0);
|
||||
script_cleararray_pc( sd, option_id );
|
||||
snprintf(option_val, sizeof(option_val), "@sold_option_val%d", j + 1);
|
||||
script_cleararray_pc(sd, option_val, (void *)0);
|
||||
script_cleararray_pc( sd, option_val );
|
||||
snprintf(option_param, sizeof(option_param), "@sold_option_param%d", j + 1);
|
||||
script_cleararray_pc(sd, option_param, (void *)0);
|
||||
script_cleararray_pc( sd, option_param );
|
||||
}
|
||||
|
||||
// save list of to be sold items
|
||||
@ -2029,28 +2029,28 @@ static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short*
|
||||
{
|
||||
int idx = item_list[i * 2] - 2;
|
||||
|
||||
script_setarray_pc(sd, "@sold_nameid", i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].nameid, &key_nameid);
|
||||
script_setarray_pc(sd, "@sold_quantity", i, (void*)(intptr_t)item_list[i*2+1], &key_amount);
|
||||
script_setarray_pc( sd, "@sold_nameid", i, sd->inventory.u.items_inventory[idx].nameid, &key_nameid );
|
||||
script_setarray_pc( sd, "@sold_quantity", i, item_list[i*2+1], &key_amount );
|
||||
|
||||
if( itemdb_isequip(sd->inventory.u.items_inventory[idx].nameid) )
|
||||
{// process equipment based information into the arrays
|
||||
script_setarray_pc(sd, "@sold_refine", i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].refine, &key_refine);
|
||||
script_setarray_pc(sd, "@sold_attribute", i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].attribute, &key_attribute);
|
||||
script_setarray_pc(sd, "@sold_identify", i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].identify, &key_identify);
|
||||
script_setarray_pc( sd, "@sold_refine", i, sd->inventory.u.items_inventory[idx].refine, &key_refine );
|
||||
script_setarray_pc( sd, "@sold_attribute", i, sd->inventory.u.items_inventory[idx].attribute, &key_attribute );
|
||||
script_setarray_pc( sd, "@sold_identify", i, sd->inventory.u.items_inventory[idx].identify, &key_identify );
|
||||
|
||||
for( j = 0; j < MAX_SLOTS; j++ )
|
||||
{// store each of the cards from the equipment in the array
|
||||
snprintf(card_slot, sizeof(card_slot), "@sold_card%d", j + 1);
|
||||
script_setarray_pc(sd, card_slot, i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].card[j], &key_card[j]);
|
||||
script_setarray_pc( sd, card_slot, i, sd->inventory.u.items_inventory[idx].card[j], &key_card[j] );
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_ITEM_RDM_OPT; j++) { // Store each of the item options in the array
|
||||
snprintf(option_id, sizeof(option_id), "@sold_option_id%d", j + 1);
|
||||
script_setarray_pc(sd, option_id, i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].option[j].id, &key_option_id[j]);
|
||||
script_setarray_pc( sd, option_id, i, sd->inventory.u.items_inventory[idx].option[j].id, &key_option_id[j] );
|
||||
snprintf(option_val, sizeof(option_val), "@sold_option_val%d", j + 1);
|
||||
script_setarray_pc(sd, option_val, i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].option[j].value, &key_option_val[j]);
|
||||
script_setarray_pc( sd, option_val, i, sd->inventory.u.items_inventory[idx].option[j].value, &key_option_val[j] );
|
||||
snprintf(option_param, sizeof(option_param), "@sold_option_param%d", j + 1);
|
||||
script_setarray_pc(sd, option_param, i, (void*)(intptr_t)sd->inventory.u.items_inventory[idx].option[j].param, &key_option_param[j]);
|
||||
script_setarray_pc( sd, option_param, i, sd->inventory.u.items_inventory[idx].option[j].param, &key_option_param[j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2544,11 +2544,14 @@ int npc_parseview(const char* w4, const char* start, const char* buffer, const c
|
||||
|
||||
// Check if view id is not an ID (only numbers).
|
||||
if (pid != nullptr && *pid != '\0') {
|
||||
int64 val_tmp;
|
||||
|
||||
// Check if constant exists and get its value.
|
||||
if(!script_get_constant(viewid, &val)) {
|
||||
if(!script_get_constant(viewid, &val_tmp)) {
|
||||
ShowWarning("npc_parseview: Invalid NPC constant '%s' specified in file '%s', line'%d'. Defaulting to INVISIBLE. \n", viewid, filepath, strline(buffer,start-buffer));
|
||||
val = JT_INVISIBLE;
|
||||
}
|
||||
} else
|
||||
val = static_cast<int>(val_tmp);
|
||||
}
|
||||
|
||||
return val;
|
||||
@ -3795,7 +3798,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
|
||||
}
|
||||
|
||||
st = script_alloc_state(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id);
|
||||
setd_sub(st, NULL, ".@atcmd_command$", 0, (void *)command, NULL);
|
||||
setd_sub_str( st, NULL, ".@atcmd_command$", 0, command, NULL );
|
||||
|
||||
// split atcmd parameters based on spaces
|
||||
|
||||
@ -3809,7 +3812,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
|
||||
temp[k] = '\0';
|
||||
k = 0;
|
||||
if( temp[0] != '\0' ) {
|
||||
setd_sub( st, NULL, ".@atcmd_parameters$", j++, (void *)temp, NULL );
|
||||
setd_sub_str( st, NULL, ".@atcmd_parameters$", j++, temp, NULL );
|
||||
}
|
||||
} else {
|
||||
temp[k] = message[i];
|
||||
@ -3817,7 +3820,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
|
||||
}
|
||||
}
|
||||
|
||||
setd_sub(st, NULL, ".@atcmd_numparameters", 0, (void *)__64BPRTSIZE(j), NULL);
|
||||
setd_sub_num( st, NULL, ".@atcmd_numparameters", 0, j, NULL );
|
||||
aFree(temp);
|
||||
|
||||
run_script_main(st);
|
||||
@ -4185,13 +4188,15 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
|
||||
if (ISDIGIT(caster_constant[0]))
|
||||
args.skill_damage.caster = atoi(caster_constant);
|
||||
else {
|
||||
int64 val_tmp;
|
||||
int val;
|
||||
|
||||
if (!script_get_constant(caster_constant, &val)) {
|
||||
if (!script_get_constant(caster_constant, &val_tmp)) {
|
||||
ShowError( "npc_parse_mapflag: Unknown constant '%s'. Skipping (file '%s', line '%d').\n", caster_constant, filepath, strline(buffer, start - buffer) );
|
||||
break;
|
||||
}
|
||||
|
||||
val = static_cast<int>(val_tmp);
|
||||
args.skill_damage.caster = val;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ struct pcrematch_set {
|
||||
struct pcrematch_set* prev;
|
||||
struct pcrematch_set* next;
|
||||
struct pcrematch_entry* head;
|
||||
int setid;
|
||||
int64 setid;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -110,7 +110,7 @@ void finalize_pcrematch_entry(struct pcrematch_entry* e)
|
||||
/**
|
||||
* Lookup (and possibly create) a new set of patterns by the set id
|
||||
*/
|
||||
static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
|
||||
static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int64 setid)
|
||||
{
|
||||
struct pcrematch_set *pcreset;
|
||||
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
|
||||
@ -151,7 +151,7 @@ static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
|
||||
*
|
||||
* if the setid does not exist, this will silently return
|
||||
*/
|
||||
static void activate_pcreset(struct npc_data* nd, int setid)
|
||||
static void activate_pcreset(struct npc_data* nd, int64 setid)
|
||||
{
|
||||
struct pcrematch_set *pcreset;
|
||||
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
|
||||
@ -184,7 +184,7 @@ static void activate_pcreset(struct npc_data* nd, int setid)
|
||||
*
|
||||
* if the setid does not exist, this will silently return
|
||||
*/
|
||||
static void deactivate_pcreset(struct npc_data* nd, int setid)
|
||||
static void deactivate_pcreset(struct npc_data* nd, int64 setid)
|
||||
{
|
||||
struct pcrematch_set *pcreset;
|
||||
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
|
||||
@ -220,7 +220,7 @@ static void deactivate_pcreset(struct npc_data* nd, int setid)
|
||||
/**
|
||||
* delete a set of patterns.
|
||||
*/
|
||||
static void delete_pcreset(struct npc_data* nd, int setid)
|
||||
static void delete_pcreset(struct npc_data* nd, int64 setid)
|
||||
{
|
||||
int active = 1;
|
||||
struct pcrematch_set *pcreset;
|
||||
@ -300,7 +300,7 @@ static struct pcrematch_entry* create_pcrematch_entry(struct pcrematch_set* set)
|
||||
/**
|
||||
* define/compile a new pattern
|
||||
*/
|
||||
void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, const char* label)
|
||||
void npc_chat_def_pattern(struct npc_data* nd, int64 setid, const char* pattern, const char* label)
|
||||
{
|
||||
const char *err;
|
||||
int erroff;
|
||||
@ -375,7 +375,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
|
||||
char var[255], val[255];
|
||||
snprintf(var, sizeof(var), "$@p%i$", i);
|
||||
pcre_copy_substring(msg, offsets, r, i, val, sizeof(val));
|
||||
set_var(sd, var, val);
|
||||
set_var_str( sd, var, val );
|
||||
}
|
||||
|
||||
// find the target label.. this sucks..
|
||||
@ -400,7 +400,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
|
||||
|
||||
int buildin_defpattern(struct script_state* st)
|
||||
{
|
||||
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
|
||||
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
|
||||
const char* pattern = conv_str(st,& (st->stack->stack_data[st->start+3]));
|
||||
const char* label = conv_str(st,& (st->stack->stack_data[st->start+4]));
|
||||
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
|
||||
@ -412,7 +412,7 @@ int buildin_defpattern(struct script_state* st)
|
||||
|
||||
int buildin_activatepset(struct script_state* st)
|
||||
{
|
||||
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
|
||||
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
|
||||
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
|
||||
|
||||
activate_pcreset(nd, setid);
|
||||
@ -422,7 +422,7 @@ int buildin_activatepset(struct script_state* st)
|
||||
|
||||
int buildin_deactivatepset(struct script_state* st)
|
||||
{
|
||||
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
|
||||
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
|
||||
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
|
||||
|
||||
deactivate_pcreset(nd, setid);
|
||||
@ -432,7 +432,7 @@ int buildin_deactivatepset(struct script_state* st)
|
||||
|
||||
int buildin_deletepset(struct script_state* st)
|
||||
{
|
||||
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
|
||||
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
|
||||
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
|
||||
|
||||
delete_pcreset(nd, setid);
|
||||
|
108
src/map/pc.cpp
108
src/map/pc.cpp
@ -1603,34 +1603,34 @@ void pc_reg_received(struct map_session_data *sd)
|
||||
|
||||
sd->vars_ok = true;
|
||||
|
||||
sd->change_level_2nd = pc_readglobalreg(sd, add_str(JOBCHANGE2ND_VAR));
|
||||
sd->change_level_3rd = pc_readglobalreg(sd, add_str(JOBCHANGE3RD_VAR));
|
||||
sd->die_counter = pc_readglobalreg(sd, add_str(PCDIECOUNTER_VAR));
|
||||
sd->change_level_2nd = static_cast<unsigned char>(pc_readglobalreg(sd, add_str(JOBCHANGE2ND_VAR)));
|
||||
sd->change_level_3rd = static_cast<unsigned char>(pc_readglobalreg(sd, add_str(JOBCHANGE3RD_VAR)));
|
||||
sd->die_counter = static_cast<int>(pc_readglobalreg(sd, add_str(PCDIECOUNTER_VAR)));
|
||||
|
||||
sd->langtype = pc_readaccountreg(sd, add_str(LANGTYPE_VAR));
|
||||
sd->langtype = static_cast<int>(pc_readaccountreg(sd, add_str(LANGTYPE_VAR)));
|
||||
if (msg_checklangtype(sd->langtype,true) < 0)
|
||||
sd->langtype = 0; //invalid langtype reset to default
|
||||
|
||||
// Cash shop
|
||||
sd->cashPoints = pc_readaccountreg(sd, add_str(CASHPOINT_VAR));
|
||||
sd->kafraPoints = pc_readaccountreg(sd, add_str(KAFRAPOINT_VAR));
|
||||
sd->cashPoints = static_cast<int>(pc_readaccountreg(sd, add_str(CASHPOINT_VAR)));
|
||||
sd->kafraPoints = static_cast<int>(pc_readaccountreg(sd, add_str(KAFRAPOINT_VAR)));
|
||||
|
||||
// Cooking Exp
|
||||
sd->cook_mastery = pc_readglobalreg(sd, add_str(COOKMASTERY_VAR));
|
||||
sd->cook_mastery = static_cast<short>(pc_readglobalreg(sd, add_str(COOKMASTERY_VAR)));
|
||||
|
||||
if( (sd->class_&MAPID_BASEMASK) == MAPID_TAEKWON )
|
||||
{ // Better check for class rather than skill to prevent "skill resets" from unsetting this
|
||||
sd->mission_mobid = pc_readglobalreg(sd, add_str(TKMISSIONID_VAR));
|
||||
sd->mission_count = pc_readglobalreg(sd, add_str(TKMISSIONCOUNT_VAR));
|
||||
sd->mission_mobid = static_cast<short>(pc_readglobalreg(sd, add_str(TKMISSIONID_VAR)));
|
||||
sd->mission_count = static_cast<unsigned char>(pc_readglobalreg(sd, add_str(TKMISSIONCOUNT_VAR)));
|
||||
}
|
||||
|
||||
if (battle_config.feature_banking)
|
||||
sd->bank_vault = pc_readreg2(sd, BANK_VAULT_VAR);
|
||||
sd->bank_vault = static_cast<int>(pc_readreg2(sd, BANK_VAULT_VAR));
|
||||
|
||||
if (battle_config.feature_roulette) {
|
||||
sd->roulette_point.bronze = pc_readreg2(sd, ROULETTE_BRONZE_VAR);
|
||||
sd->roulette_point.silver = pc_readreg2(sd, ROULETTE_SILVER_VAR);
|
||||
sd->roulette_point.gold = pc_readreg2(sd, ROULETTE_GOLD_VAR);
|
||||
sd->roulette_point.bronze = static_cast<int>(pc_readreg2(sd, ROULETTE_BRONZE_VAR));
|
||||
sd->roulette_point.silver = static_cast<int>(pc_readreg2(sd, ROULETTE_SILVER_VAR));
|
||||
sd->roulette_point.gold = static_cast<int>(pc_readreg2(sd, ROULETTE_GOLD_VAR));
|
||||
}
|
||||
sd->roulette.prizeIdx = -1;
|
||||
|
||||
@ -1638,33 +1638,33 @@ void pc_reg_received(struct map_session_data *sd)
|
||||
for(i=0;i<MAX_PC_FEELHATE;i++) { //for now - someone need to make reading from txt/sql
|
||||
uint16 j;
|
||||
|
||||
if ((j = pc_readglobalreg(sd, add_str(sg_info[i].feel_var))) != 0) {
|
||||
if ((j = static_cast<uint16>(pc_readglobalreg(sd, add_str(sg_info[i].feel_var)))) != 0) {
|
||||
sd->feel_map[i].index = j;
|
||||
sd->feel_map[i].m = map_mapindex2mapid(j);
|
||||
} else {
|
||||
sd->feel_map[i].index = 0;
|
||||
sd->feel_map[i].m = -1;
|
||||
}
|
||||
sd->hate_mob[i] = pc_readglobalreg(sd, add_str(sg_info[i].hate_var))-1;
|
||||
sd->hate_mob[i] = static_cast<short>(pc_readglobalreg(sd, add_str(sg_info[i].hate_var)))-1;
|
||||
}
|
||||
|
||||
if ((i = pc_checkskill(sd,RG_PLAGIARISM)) > 0) {
|
||||
unsigned short skid = pc_readglobalreg(sd, add_str(SKILL_VAR_PLAGIARISM));
|
||||
unsigned short skid = static_cast<unsigned short>(pc_readglobalreg(sd, add_str(SKILL_VAR_PLAGIARISM)));
|
||||
sd->cloneskill_idx = skill_get_index(skid);
|
||||
if (sd->cloneskill_idx > 0) {
|
||||
sd->status.skill[sd->cloneskill_idx].id = skid;
|
||||
sd->status.skill[sd->cloneskill_idx].lv = pc_readglobalreg(sd, add_str(SKILL_VAR_PLAGIARISM_LV));
|
||||
sd->status.skill[sd->cloneskill_idx].lv = static_cast<uint8>(pc_readglobalreg(sd, add_str(SKILL_VAR_PLAGIARISM_LV)));
|
||||
if (sd->status.skill[sd->cloneskill_idx].lv > i)
|
||||
sd->status.skill[sd->cloneskill_idx].lv = i;
|
||||
sd->status.skill[sd->cloneskill_idx].flag = SKILL_FLAG_PLAGIARIZED;
|
||||
}
|
||||
}
|
||||
if ((i = pc_checkskill(sd,SC_REPRODUCE)) > 0) {
|
||||
unsigned short skid = pc_readglobalreg(sd, add_str(SKILL_VAR_REPRODUCE));
|
||||
unsigned short skid = static_cast<unsigned short>(pc_readglobalreg(sd, add_str(SKILL_VAR_REPRODUCE)));
|
||||
sd->reproduceskill_idx = skill_get_index(skid);
|
||||
if (sd->reproduceskill_idx > 0) {
|
||||
sd->status.skill[sd->reproduceskill_idx].id = skid;
|
||||
sd->status.skill[sd->reproduceskill_idx].lv = pc_readglobalreg(sd, add_str(SKILL_VAR_REPRODUCE_LV));
|
||||
sd->status.skill[sd->reproduceskill_idx].lv = static_cast<uint8>(pc_readglobalreg(sd, add_str(SKILL_VAR_REPRODUCE_LV)));
|
||||
if (i < sd->status.skill[sd->reproduceskill_idx].lv)
|
||||
sd->status.skill[sd->reproduceskill_idx].lv = i;
|
||||
sd->status.skill[sd->reproduceskill_idx].flag = SKILL_FLAG_PLAGIARIZED;
|
||||
@ -8365,9 +8365,9 @@ bool pc_revive_item(struct map_session_data *sd) {
|
||||
/*==========================================
|
||||
* script reading pc status registry
|
||||
*------------------------------------------*/
|
||||
int pc_readparam(struct map_session_data* sd,int type)
|
||||
int64 pc_readparam(struct map_session_data* sd,int64 type)
|
||||
{
|
||||
int val = 0;
|
||||
int64 val = 0;
|
||||
|
||||
nullpo_ret(sd);
|
||||
|
||||
@ -8527,7 +8527,7 @@ int pc_readparam(struct map_session_data* sd,int type)
|
||||
val = sd->castrate; break;
|
||||
#endif
|
||||
default:
|
||||
ShowError("pc_readparam: Attempt to read unknown parameter '%d'.\n", type);
|
||||
ShowError("pc_readparam: Attempt to read unknown parameter '%lld'.\n", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -8537,22 +8537,24 @@ int pc_readparam(struct map_session_data* sd,int type)
|
||||
/*==========================================
|
||||
* script set pc status registry
|
||||
*------------------------------------------*/
|
||||
bool pc_setparam(struct map_session_data *sd,int type,int val)
|
||||
bool pc_setparam(struct map_session_data *sd,int64 type,int64 val_tmp)
|
||||
{
|
||||
nullpo_retr(false,sd);
|
||||
|
||||
int val = static_cast<unsigned int>(val_tmp);
|
||||
|
||||
switch(type){
|
||||
case SP_BASELEVEL:
|
||||
if ((unsigned int)val > pc_maxbaselv(sd)) //Capping to max
|
||||
if (val > pc_maxbaselv(sd)) //Capping to max
|
||||
val = pc_maxbaselv(sd);
|
||||
if ((unsigned int)val > sd->status.base_level) {
|
||||
if (val > sd->status.base_level) {
|
||||
int i = 0;
|
||||
int stat=0;
|
||||
for (i = 0; i < (int)((unsigned int)val - sd->status.base_level); i++)
|
||||
for (i = 0; i < (int)(val - sd->status.base_level); i++)
|
||||
stat += pc_gets_status_point(sd->status.base_level + i);
|
||||
sd->status.status_point += stat;
|
||||
}
|
||||
sd->status.base_level = (unsigned int)val;
|
||||
sd->status.base_level = val;
|
||||
sd->status.base_exp = 0;
|
||||
// clif_updatestatus(sd, SP_BASELEVEL); // Gets updated at the bottom
|
||||
clif_updatestatus(sd, SP_NEXTBASEEXP);
|
||||
@ -8563,12 +8565,12 @@ bool pc_setparam(struct map_session_data *sd,int type,int val)
|
||||
party_send_levelup(sd);
|
||||
break;
|
||||
case SP_JOBLEVEL:
|
||||
if ((unsigned int)val >= sd->status.job_level) {
|
||||
if ((unsigned int)val > pc_maxjoblv(sd)) val = pc_maxjoblv(sd);
|
||||
if (val >= sd->status.job_level) {
|
||||
if (val > pc_maxjoblv(sd)) val = pc_maxjoblv(sd);
|
||||
sd->status.skill_point += val - sd->status.job_level;
|
||||
clif_updatestatus(sd, SP_SKILLPOINT);
|
||||
}
|
||||
sd->status.job_level = (unsigned int)val;
|
||||
sd->status.job_level = val;
|
||||
sd->status.job_exp = 0;
|
||||
// clif_updatestatus(sd, SP_JOBLEVEL); // Gets updated at the bottom
|
||||
clif_updatestatus(sd, SP_NEXTJOBEXP);
|
||||
@ -8590,7 +8592,7 @@ bool pc_setparam(struct map_session_data *sd,int type,int val)
|
||||
case SP_BASEEXP:
|
||||
{
|
||||
val = cap_value(val, 0, INT_MAX);
|
||||
if ((unsigned int)val < sd->status.base_exp) // Lost
|
||||
if (val < sd->status.base_exp) // Lost
|
||||
pc_lostexp(sd, sd->status.base_exp - val, 0);
|
||||
else // Gained
|
||||
pc_gainexp(sd, NULL, val - sd->status.base_exp, 0, 2);
|
||||
@ -8599,7 +8601,7 @@ bool pc_setparam(struct map_session_data *sd,int type,int val)
|
||||
case SP_JOBEXP:
|
||||
{
|
||||
val = cap_value(val, 0, INT_MAX);
|
||||
if ((unsigned int)val < sd->status.job_exp) // Lost
|
||||
if (val < sd->status.job_exp) // Lost
|
||||
pc_lostexp(sd, 0, sd->status.job_exp - val);
|
||||
else // Gained
|
||||
pc_gainexp(sd, NULL, 0, val - sd->status.job_exp, 2);
|
||||
@ -8750,10 +8752,10 @@ bool pc_setparam(struct map_session_data *sd,int type,int val)
|
||||
pc_setglobalreg(sd, add_str(COOKMASTERY_VAR), sd->cook_mastery);
|
||||
return true;
|
||||
default:
|
||||
ShowError("pc_setparam: Attempted to set unknown parameter '%d'.\n", type);
|
||||
ShowError("pc_setparam: Attempted to set unknown parameter '%lld'.\n", type);
|
||||
return false;
|
||||
}
|
||||
clif_updatestatus(sd,type);
|
||||
clif_updatestatus(sd,static_cast<int>(type));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -8972,7 +8974,7 @@ bool pc_jobchange(struct map_session_data *sd,int job, char upper)
|
||||
sd->status.skill[sd->cloneskill_idx].id = 0;
|
||||
sd->status.skill[sd->cloneskill_idx].lv = 0;
|
||||
sd->status.skill[sd->cloneskill_idx].flag = SKILL_FLAG_PERMANENT;
|
||||
clif_deleteskill(sd,pc_readglobalreg(sd, add_str(SKILL_VAR_PLAGIARISM)));
|
||||
clif_deleteskill(sd, static_cast<int>(pc_readglobalreg(sd, add_str(SKILL_VAR_PLAGIARISM))));
|
||||
}
|
||||
sd->cloneskill_idx = 0;
|
||||
pc_setglobalreg(sd, add_str(SKILL_VAR_PLAGIARISM), 0);
|
||||
@ -8984,7 +8986,7 @@ bool pc_jobchange(struct map_session_data *sd,int job, char upper)
|
||||
sd->status.skill[sd->reproduceskill_idx].id = 0;
|
||||
sd->status.skill[sd->reproduceskill_idx].lv = 0;
|
||||
sd->status.skill[sd->reproduceskill_idx].flag = SKILL_FLAG_PERMANENT;
|
||||
clif_deleteskill(sd,pc_readglobalreg(sd, add_str(SKILL_VAR_REPRODUCE)));
|
||||
clif_deleteskill(sd, static_cast<int>(pc_readglobalreg(sd, add_str(SKILL_VAR_REPRODUCE))));
|
||||
}
|
||||
sd->reproduceskill_idx = 0;
|
||||
pc_setglobalreg(sd, add_str(SKILL_VAR_REPRODUCE), 0);
|
||||
@ -9469,22 +9471,22 @@ bool pc_can_attack( struct map_session_data *sd, int target_id ) {
|
||||
/*==========================================
|
||||
* Read '@type' variables (temporary numeric char reg)
|
||||
*------------------------------------------*/
|
||||
int pc_readreg(struct map_session_data* sd, int64 reg)
|
||||
int64 pc_readreg(struct map_session_data* sd, int64 reg)
|
||||
{
|
||||
return i64db_iget(sd->regs.vars, reg);
|
||||
return i64db_i64get(sd->regs.vars, reg);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Set '@type' variables (temporary numeric char reg)
|
||||
*------------------------------------------*/
|
||||
bool pc_setreg(struct map_session_data* sd, int64 reg, int val)
|
||||
bool pc_setreg(struct map_session_data* sd, int64 reg, int64 val)
|
||||
{
|
||||
unsigned int index = script_getvaridx(reg);
|
||||
uint32 index = script_getvaridx(reg);
|
||||
|
||||
nullpo_retr(false, sd);
|
||||
|
||||
if( val ) {
|
||||
i64db_iput(sd->regs.vars, reg, val);
|
||||
i64db_i64put(sd->regs.vars, reg, val);
|
||||
if( index )
|
||||
script_array_update(&sd->regs, reg, false);
|
||||
} else {
|
||||
@ -9554,7 +9556,7 @@ bool pc_setregstr(struct map_session_data* sd, int64 reg, const char* str)
|
||||
* - '#type' (permanent numeric account reg)
|
||||
* - '##type' (permanent numeric account reg2)
|
||||
**/
|
||||
int pc_readregistry(struct map_session_data *sd, int64 reg)
|
||||
int64 pc_readregistry(struct map_session_data *sd, int64 reg)
|
||||
{
|
||||
struct script_reg_num *p = NULL;
|
||||
|
||||
@ -9600,12 +9602,12 @@ char* pc_readregistry_str(struct map_session_data *sd, int64 reg)
|
||||
* - '#type' (permanent numeric account reg)
|
||||
* - '##type' (permanent numeric account reg2)
|
||||
**/
|
||||
int pc_setregistry(struct map_session_data *sd, int64 reg, int val)
|
||||
int pc_setregistry(struct map_session_data *sd, int64 reg, int64 val)
|
||||
{
|
||||
struct script_reg_num *p = NULL;
|
||||
const char *regname = get_str(script_getvarid(reg));
|
||||
unsigned int index = script_getvaridx(reg);
|
||||
|
||||
uint32 index = script_getvaridx(reg);
|
||||
|
||||
if ( !reg_load && !sd->vars_ok ) {
|
||||
ShowError("pc_setregistry : refusing to set %s until vars are received.\n", regname);
|
||||
return 0;
|
||||
@ -9721,7 +9723,7 @@ int pc_setregistry_str(struct map_session_data *sd, int64 reg, const char *val)
|
||||
* @param value
|
||||
* @return True if success, false if failed.
|
||||
**/
|
||||
bool pc_setreg2(struct map_session_data *sd, const char *reg, int val) {
|
||||
bool pc_setreg2(struct map_session_data *sd, const char *reg, int64 val) {
|
||||
char prefix = reg[0];
|
||||
|
||||
nullpo_retr(false, sd);
|
||||
@ -9756,7 +9758,7 @@ bool pc_setreg2(struct map_session_data *sd, const char *reg, int val) {
|
||||
* @param reg Variable name
|
||||
* @return Variable value or 0 if failed.
|
||||
**/
|
||||
int pc_readreg2(struct map_session_data *sd, const char *reg) {
|
||||
int64 pc_readreg2(struct map_session_data *sd, const char *reg) {
|
||||
char prefix = reg[0];
|
||||
|
||||
nullpo_ret(sd);
|
||||
@ -11854,10 +11856,12 @@ static bool pc_readdb_job_basehpsp(char* fields[], int columns, int current)
|
||||
*/
|
||||
static bool pc_readdb_job_param(char* fields[], int columns, int current)
|
||||
{
|
||||
int64 class_tmp;
|
||||
int idx, class_;
|
||||
uint16 str, agi, vit, int_, dex, luk;
|
||||
|
||||
script_get_constant(trim(fields[0]),&class_);
|
||||
script_get_constant(trim(fields[0]),&class_tmp);
|
||||
class_ = static_cast<int>(class_tmp);
|
||||
|
||||
if ((idx = pc_class2idx(class_)) < 0) {
|
||||
ShowError("pc_readdb_job_param: Invalid job '%s'. Skipping!",fields[0]);
|
||||
@ -11885,14 +11889,16 @@ static bool pc_readdb_job_param(char* fields[], int columns, int current)
|
||||
**/
|
||||
static bool pc_readdb_job_noenter_map(char *str[], int columns, int current) {
|
||||
int idx, class_ = -1;
|
||||
int64 class_tmp;
|
||||
|
||||
if (ISDIGIT(str[0][0])) {
|
||||
class_ = atoi(str[0]);
|
||||
} else {
|
||||
if (!script_get_constant(str[0], &class_)) {
|
||||
if (!script_get_constant(str[0], &class_tmp)) {
|
||||
ShowError("pc_readdb_job_noenter_map: Invalid job %s specified.\n", str[0]);
|
||||
return false;
|
||||
}
|
||||
class_ = static_cast<int>(class_tmp);
|
||||
}
|
||||
|
||||
if (!pcdb_checkid(class_) || (idx = pc_class2idx(class_)) < 0) {
|
||||
@ -13106,7 +13112,7 @@ int32 pc_attendance_counter( struct map_session_data* sd ){
|
||||
}
|
||||
|
||||
// Get the counter for the current period
|
||||
int counter = pc_readreg2( sd, ATTENDANCE_COUNT_VAR );
|
||||
int counter = static_cast<int>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));
|
||||
|
||||
// Check if we have a remaining counter from a previous period
|
||||
if( counter > 0 && pc_readreg2( sd, ATTENDANCE_DATE_VAR ) < period->start ){
|
||||
@ -13135,7 +13141,7 @@ void pc_attendance_claim_reward( struct map_session_data* sd ){
|
||||
return;
|
||||
}
|
||||
|
||||
int32 attendance_counter = pc_readreg2( sd, ATTENDANCE_COUNT_VAR );
|
||||
int32 attendance_counter = static_cast<int32>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));
|
||||
|
||||
attendance_counter += 1;
|
||||
|
||||
|
@ -1181,14 +1181,14 @@ void pc_changelook(struct map_session_data *,int,int);
|
||||
void pc_equiplookall(struct map_session_data *sd);
|
||||
void pc_set_costume_view(struct map_session_data *sd);
|
||||
|
||||
int pc_readparam(struct map_session_data *sd, int type);
|
||||
bool pc_setparam(struct map_session_data *sd, int type, int val);
|
||||
int pc_readreg(struct map_session_data *sd, int64 reg);
|
||||
bool pc_setreg(struct map_session_data *sd, int64 reg, int val);
|
||||
int64 pc_readparam(struct map_session_data *sd, int64 type);
|
||||
bool pc_setparam(struct map_session_data *sd, int64 type, int64 val);
|
||||
int64 pc_readreg(struct map_session_data *sd, int64 reg);
|
||||
bool pc_setreg(struct map_session_data *sd, int64 reg, int64 val);
|
||||
char *pc_readregstr(struct map_session_data *sd, int64 reg);
|
||||
bool pc_setregstr(struct map_session_data *sd, int64 reg, const char *str);
|
||||
int pc_readregistry(struct map_session_data *sd, int64 reg);
|
||||
int pc_setregistry(struct map_session_data *sd, int64 reg, int val);
|
||||
int64 pc_readregistry(struct map_session_data *sd, int64 reg);
|
||||
int pc_setregistry(struct map_session_data *sd, int64 reg, int64 val);
|
||||
char *pc_readregistry_str(struct map_session_data *sd, int64 reg);
|
||||
int pc_setregistry_str(struct map_session_data *sd, int64 reg, const char *val);
|
||||
|
||||
@ -1205,8 +1205,8 @@ int pc_setregistry_str(struct map_session_data *sd, int64 reg, const char *val);
|
||||
#define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg)
|
||||
#define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val)
|
||||
|
||||
bool pc_setreg2(struct map_session_data *sd, const char *reg, int val);
|
||||
int pc_readreg2(struct map_session_data *sd, const char *reg);
|
||||
bool pc_setreg2(struct map_session_data *sd, const char *reg, int64 val);
|
||||
int64 pc_readreg2(struct map_session_data *sd, const char *reg);
|
||||
|
||||
bool pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
|
||||
bool pc_deleventtimer(struct map_session_data *sd,const char *name);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -50,6 +50,7 @@
|
||||
#define script_isint(st,i) data_isint(get_val(st, script_getdata(st,i)))
|
||||
|
||||
#define script_getnum(st,val) conv_num(st, script_getdata(st,val))
|
||||
#define script_getnum64(st,val) conv_num64(st, script_getdata(st,val))
|
||||
#define script_getstr(st,val) conv_str(st, script_getdata(st,val))
|
||||
#define script_getref(st,val) ( script_getdata(st,val)->ref )
|
||||
// Returns name of currently running function
|
||||
@ -2011,9 +2012,12 @@ bool is_number(const char *p);
|
||||
struct script_code* parse_script(const char* src,const char* file,int line,int options);
|
||||
void run_script(struct script_code *rootscript,int pos,int rid,int oid);
|
||||
|
||||
int set_reg(struct script_state* st, struct map_session_data* sd, int64 num, const char* name, const void* value, struct reg_db *ref);
|
||||
int set_var(struct map_session_data *sd, char *name, void *val);
|
||||
int conv_num(struct script_state *st,struct script_data *data);
|
||||
bool set_reg_num(struct script_state* st, struct map_session_data* sd, int64 num, const char* name, const int64 value, struct reg_db *ref);
|
||||
bool set_reg_str(struct script_state* st, struct map_session_data* sd, int64 num, const char* name, const char* value, struct reg_db* ref);
|
||||
bool set_var_str(struct map_session_data *sd, const char* name, const char* val);
|
||||
bool clear_reg( struct script_state* st, struct map_session_data* sd, int64 num, const char* name, struct reg_db *ref );
|
||||
int64 conv_num64(struct script_state *st, struct script_data *data);
|
||||
int conv_num(struct script_state *st, struct script_data *data);
|
||||
const char* conv_str(struct script_state *st,struct script_data *data);
|
||||
void pop_stack(struct script_state* st, int start, int end);
|
||||
TIMER_FUNC(run_script_timer);
|
||||
@ -2034,14 +2038,14 @@ struct DBMap* script_get_userfunc_db(void);
|
||||
void script_run_autobonus(const char *autobonus, struct map_session_data *sd, unsigned int pos);
|
||||
|
||||
const char* script_get_constant_str(const char* prefix, int64 value);
|
||||
bool script_get_parameter(const char* name, int* value);
|
||||
bool script_get_constant(const char* name, int* value);
|
||||
void script_set_constant_(const char* name, int value, const char* constant_name, bool isparameter, bool deprecated);
|
||||
bool script_get_parameter(const char* name, int64* value);
|
||||
bool script_get_constant(const char* name, int64* value);
|
||||
void script_set_constant_(const char* name, int64 value, const char* constant_name, bool isparameter, bool deprecated);
|
||||
#define script_set_constant(name, value, isparameter, deprecated) script_set_constant_(name, value, NULL, isparameter, deprecated)
|
||||
void script_hardcoded_constants(void);
|
||||
|
||||
void script_cleararray_pc(struct map_session_data* sd, const char* varname, void* value);
|
||||
void script_setarray_pc(struct map_session_data* sd, const char* varname, uint32 idx, void* value, int* refcache);
|
||||
void script_cleararray_pc(struct map_session_data* sd, const char* varname);
|
||||
void script_setarray_pc(struct map_session_data* sd, const char* varname, uint32 idx, int64 value, int* refcache);
|
||||
|
||||
int script_config_read(const char *cfgName);
|
||||
void do_init_script(void);
|
||||
@ -2050,8 +2054,8 @@ int add_str(const char* p);
|
||||
const char* get_str(int id);
|
||||
void script_reload(void);
|
||||
|
||||
// @commands (script based)
|
||||
void setd_sub(struct script_state *st, struct map_session_data *sd, const char *varname, int elem, void *value, struct reg_db *ref);
|
||||
void setd_sub_num( struct script_state* st, struct map_session_data* sd, const char* varname, int elem, int64 value, struct reg_db* ref );
|
||||
void setd_sub_str( struct script_state* st, struct map_session_data* sd, const char* varname, int elem, const char* value, struct reg_db* ref );
|
||||
|
||||
/**
|
||||
* Array Handling
|
||||
|
@ -21098,16 +21098,20 @@ uint8 skill_split_atoi2(char *str, int *val, const char *delim, int min_value, u
|
||||
char *p = strtok(str, delim);
|
||||
|
||||
while (p != NULL) {
|
||||
int64 n_tmp;
|
||||
int n = min_value;
|
||||
|
||||
trim(p);
|
||||
|
||||
if (ISDIGIT(p[0])) // If using numeric
|
||||
n = atoi(p);
|
||||
else if (!script_get_constant(p, &n)) { // If using constant value
|
||||
ShowError("skill_split_atoi2: Invalid value: '%s'\n", p);
|
||||
p = strtok(NULL, delim);
|
||||
continue;
|
||||
else {
|
||||
if (!script_get_constant(p, &n_tmp)) { // If using constant value
|
||||
ShowError("skill_split_atoi2: Invalid value: '%s'\n", p);
|
||||
p = strtok(NULL, delim);
|
||||
continue;
|
||||
}
|
||||
n = static_cast<int>(n_tmp);
|
||||
}
|
||||
|
||||
if (n > min_value) {
|
||||
@ -21799,6 +21803,7 @@ static bool skill_parse_row_changematerialdb(char* split[], int columns, int cur
|
||||
*/
|
||||
static bool skill_parse_row_skilldamage(char* split[], int columns, int current)
|
||||
{
|
||||
int64 caster_tmp;
|
||||
uint16 id = 0;
|
||||
int caster;
|
||||
|
||||
@ -21815,10 +21820,11 @@ static bool skill_parse_row_skilldamage(char* split[], int columns, int current)
|
||||
if (ISDIGIT(split[1][0]))
|
||||
caster = atoi(split[1]);
|
||||
else { // Try to parse caster as constant
|
||||
if (!script_get_constant(split[1], &caster)) {
|
||||
if (!script_get_constant(split[1], &caster_tmp)) {
|
||||
ShowError("skill_parse_row_skilldamage: Invalid caster constant given for skill %d. Skipping.", id);
|
||||
return false;
|
||||
}
|
||||
caster = static_cast<int>(caster_tmp);
|
||||
}
|
||||
skill_db[id]->damage.caster |= caster;
|
||||
skill_db[id]->damage.map |= atoi(split[2]);
|
||||
|
@ -14553,7 +14553,7 @@ void status_change_clear_onChangeMap(struct block_list *bl, struct status_change
|
||||
*/
|
||||
static bool status_readdb_status_disabled(char **str, int columns, int current)
|
||||
{
|
||||
int type = SC_NONE;
|
||||
int64 type = SC_NONE;
|
||||
|
||||
if (ISDIGIT(str[0][0]))
|
||||
type = atoi(str[0]);
|
||||
@ -14611,6 +14611,7 @@ static bool status_yaml_readdb_refine_sub(const YAML::Node &node, int refine_inf
|
||||
const YAML::Node &costs = node["Costs"];
|
||||
|
||||
for (const auto costit : costs) {
|
||||
int64 idx_tmp = 0;
|
||||
const YAML::Node &type = costit;
|
||||
int idx = 0, price;
|
||||
unsigned short material;
|
||||
@ -14624,8 +14625,10 @@ static bool status_yaml_readdb_refine_sub(const YAML::Node &node, int refine_inf
|
||||
std::string refine_cost_const = type["Type"].as<std::string>();
|
||||
if (ISDIGIT(refine_cost_const[0]))
|
||||
idx = atoi(refine_cost_const.c_str());
|
||||
else
|
||||
script_get_constant(refine_cost_const.c_str(), &idx);
|
||||
else {
|
||||
script_get_constant(refine_cost_const.c_str(), &idx_tmp);
|
||||
idx = static_cast<int>(idx_tmp);
|
||||
}
|
||||
price = type["Price"].as<int>();
|
||||
material = type["Material"].as<uint16>();
|
||||
|
||||
|
@ -80,7 +80,7 @@ std::unordered_map<uint16, std::string> aegis_itemnames;
|
||||
std::unordered_map<uint16, uint16> aegis_itemviewid;
|
||||
std::unordered_map<uint16, std::string> aegis_mobnames;
|
||||
std::unordered_map<uint16, std::string> aegis_skillnames;
|
||||
std::unordered_map<const char*, int32> constants;
|
||||
std::unordered_map<const char*, int64> constants;
|
||||
|
||||
// Forward declaration of constant loading functions
|
||||
static bool parse_item_constants( const char* path );
|
||||
@ -93,7 +93,7 @@ bool askConfirmation( const char* fmt, ... );
|
||||
YAML::Emitter body;
|
||||
|
||||
// Implement the function instead of including the original version by linking
|
||||
void script_set_constant_( const char* name, int value, const char* constant_name, bool isparameter, bool deprecated ){
|
||||
void script_set_constant_( const char* name, int64 value, const char* constant_name, bool isparameter, bool deprecated ){
|
||||
constants[name] = value;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user