viewing paste Unknown #6080 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
//------------------------------------------------
//Guild bound items pull for offline characters [Akinari]
//Fills in item structure to be used elsewhere
//------------------------------------------------
int itemdb_offlinebound(int char_id, struct item *items[])
{
    StringBuf buf;
    SqlStmt* stmt;
    struct item item;
    int j, i=0;
 
    StringBuf_Init(&buf);
    StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`");
    for( j = 0; j < MAX_SLOTS; ++j )
        StringBuf_Printf(&buf, ", `card%d`", j);
    StringBuf_Printf(&buf, " FROM `inventory_db` WHERE `char_id`='%d'", char_id);
 
    stmt = SqlStmt_Malloc(mmysql_handle);
    if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
    ||  SQL_ERROR == SqlStmt_Execute(stmt) )
    {
        SqlStmt_ShowDebug(stmt);
        SqlStmt_Free(stmt);
        StringBuf_Destroy(&buf);
        return 1;
    }
 
    SqlStmt_BindColumn(stmt, 0, SQLDT_INT,       &item.id,          0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT,     &item.nameid,      0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,      0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT,    &item.equip,       0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,    0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,      &item.refine,      0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,      &item.attribute,   0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 7, SQLDT_UINT,      &item.expire_time, 0, NULL, NULL);
    SqlStmt_BindColumn(stmt, 8, SQLDT_UINT,      &item.bound,       0, NULL, NULL);
    for( j = 0; j < MAX_SLOTS; ++j )
        SqlStmt_BindColumn(stmt, 9+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
 
    while( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) {
        if(item.bound == 2) {
            memcpy(&items[i],&item,sizeof(item));
            i++;
        }
    }
 
    return 0;
}
Viewed 720 times, submitted by Guest.