Jump to content
  • 0

compile error


Jayz

Question


  • Group:  Members
  • Topic Count:  59
  • Topics Per Day:  0.01
  • Content Count:  396
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  59
  • Topics Per Day:  0.01
  • Content Count:  396
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

uhmm can you give me an example? how to accept the int64 on mapreg_setreg

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

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);
         }
     }
 
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  59
  • Topics Per Day:  0.01
  • Content Count:  396
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

i see ok ill try

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...