Jump to content
  • 0

compile error


Question

Posted (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 by Zack-

4 answers to this question

Recommended Posts

Posted

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

Posted

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);
         }
     }
 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...