Jayz Posted April 20, 2013 Group: Members Topic Count: 59 Topics Per Day: 0.01 Content Count: 407 Reputation: 55 Joined: 07/24/12 Last Seen: October 22, 2024 Share Posted April 20, 2013 (edited) Hello just asking when compile have showing up error like this map.c(1538): warning C4244: 'function' : conversion from 'uint64' to 'int', possible loss of data this like is mapreg_setreg(add_str("$@itemdataunique_id"),fitem->item_data.unique_id); this is correct? oh wait still error sorry Edited April 20, 2013 by Zack- Quote Link to comment Share on other sites More sharing options...
Lighta Posted April 20, 2013 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 737 Reputation: 216 Joined: 11/29/11 Last Seen: December 20, 2020 Share Posted April 20, 2013 no it's an error, your unique_id will be truncated. So when uid > MAX_INT you wont see the diff, but that still give you around 2B uid. If you want to fix it you'll have to modify mapreg_setreg to accept int64 as argument and in the sql query change it to be long instead integer.%d => %ld Quote Link to comment Share on other sites More sharing options...
Jayz Posted April 20, 2013 Group: Members Topic Count: 59 Topics Per Day: 0.01 Content Count: 407 Reputation: 55 Joined: 07/24/12 Last Seen: October 22, 2024 Author Share Posted April 20, 2013 uhmm can you give me an example? how to accept the int64 on mapreg_setreg Quote Link to comment Share on other sites More sharing options...
Lighta Posted April 20, 2013 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 737 Reputation: 216 Joined: 11/29/11 Last Seen: December 20, 2020 Share Posted April 20, 2013 untested, and not totally finish but just so you see what I meant --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -34,7 +34,7 @@ } /// Modifies the value of an integer variable. -bool mapreg_setreg(int uid, int val) +bool mapreg_setreg(int uid, int64 val) { int num = (uid & 0x00ffffff); int i = (uid & 0xff000000) >> 24; @@ -42,13 +42,13 @@ if( val != 0 ) { - if( idb_iput(mapreg_db,uid,val) ) + if( idb_iput(mapreg_db,uid,val) ) //issue here idb_put need int for val mapreg_dirty = true; // already exists, delay write else if(name[1] != '@') {// write new variable to database char tmp_str[32*2+1]; Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32)); - if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) ) + if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%ld')", mapreg_table, tmp_str, i, val) ) Sql_ShowDebug(mmysql_handle); } } Quote Link to comment Share on other sites More sharing options...
Jayz Posted April 20, 2013 Group: Members Topic Count: 59 Topics Per Day: 0.01 Content Count: 407 Reputation: 55 Joined: 07/24/12 Last Seen: October 22, 2024 Author Share Posted April 20, 2013 i see ok ill try Quote Link to comment Share on other sites More sharing options...
Question
Jayz
Hello just asking
when compile have showing up error like this
map.c(1538): warning C4244: 'function' : conversion from 'uint64' to 'int', possible loss of data
this like is
mapreg_setreg(add_str("$@itemdataunique_id"),fitem->item_data.unique_id);
this is correct?
oh wait still error sorry
Edited by Zack-Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.