PDA

View Full Version : import_raw_items.cpp compiling errors


Magoth78
08-10-2003, 11:55 PM
Hi there,

I'm trying to get this file compiled but it keeps sending me error that I can't understand.


Here is the file:


#include <mysql.h>
#include <stdio.h>
#include <string.h>

#include "../common/eq_packet_structs.h"

int main(int argc, char** argv)
{
MYSQL mysql;
FILE* fp;
char db_pass[32];

if (argc != 5)
{
printf("Usage: ./import_raw_items db_address db_username db_name item_filename\n");
return 1;
}

printf("Password:");
scanf("%s", db_pass);

mysql_init(&mysql);
if (!mysql_real_connect(&mysql, argv[1], argv[2], db_pass, argv[3], 0, 0, 0))
{
printf("Could not connect to database: Error:%s\n", mysql_error(&mysql));
return 1;
}

fp = fopen(argv[4], "r");
if (!fp)
{
printf("Could not open item file '%s'\n", argv[4]);
mysql_close(&mysql);
return 1;
}

Item_Struct item;
Item_Struct item2;
char query[1024];
char* end;
int16 id;
memset(&item, 0, sizeof(item));
memset(&item2, 0, sizeof(item));
// while(fread(&item, sizeof(item), 1, fp))
while(fread(&item, 240, 1, fp))
{
id = item.item_nr;

memcpy((char*)&item2, (char*)&item, 144);
memcpy((char*)&item2.unknown0144[8], (char*)item.unknown0144, sizeof(item)-152);
// memcpy((char*)((char*)&item)[148], (char*)((char*)&item)[144], sizeof(item)-148);
/*
((char*)&item)[144]=0;
((char*)&item)[145]=0;
((char*)&item)[146]=0;
((char*)&item)[147]=0;
*/
end = query;
end += sprintf(end, "INSERT INTO items SET id=%i,raw_data=", id);
*end++ = '\'';
end += mysql_real_escape_string(&mysql, end, (char*)&item2, sizeof(Item_Struct));
*end++ = '\'';
if (mysql_real_query(&mysql, query, (unsigned int) (end-query)))
{
printf("Could not insert item %i MySQL said: %s\n", id, mysql_error(&mysql));
}
}
}


and here are the errors:


--------------------Configuration: Zone - Win32 GuildWars Debug--------------------
Compiling...
import_raw_items.cpp
g:\lib\mysql_com.h(116) : error C2146: syntax error : missing ';' before identifier 'fd'
g:\lib\mysql_com.h(116) : error C2501: 'SOCKET' : missing storage-class or type specifiers
g:\lib\mysql_com.h(116) : error C2501: 'fd' : missing storage-class or type specifiers
g:\lib\mysql_com.h(180) : error C2065: 'SOCKET' : undeclared identifier
g:\lib\mysql_com.h(180) : error C2146: syntax error : missing ')' before identifier 's'
g:\lib\mysql_com.h(181) : error C2059: syntax error : ')'
G:\JOB\NightDumps\NightDumps\Source\zone\import_ra w_items.cpp(50) : error C2039: 'unknown0144' : is not a member of 'Item_Struct'
G:\JOB\NightDumps\NightDumps\Source\zone\../common/eq_packet_structs.h(973) : see declaration of 'Item_Struct'
G:\JOB\NightDumps\NightDumps\Source\zone\import_ra w_items.cpp(50) : error C2039: 'unknown0144' : is not a member of 'Item_Struct'
G:\JOB\NightDumps\NightDumps\Source\zone\../common/eq_packet_structs.h(973) : see declaration of 'Item_Struct'
Error executing cl.exe.

import_raw_items.obj - 8 error(s), 0 warning(s)


Any idea please?

08-11-2003, 02:36 AM
I googled for your error messages and found a reference to including <my_global.h> before <mysql.h>

http://www.mysql.com/doc/en/Windows_client_compiling.html

might be worth a try.

Magoth78
08-11-2003, 06:23 AM
Hello and thx for the reply,

I tried to include the <my_global.h> before <mysql.h>.
But I still have the same error.

Deawin
08-11-2003, 07:35 AM
Instead of doing this:

#include <mysql.h>
#include <stdio.h>
#include <string.h>


do this:


#include <windows.h>
#include <winsock.h>
#include <mysql.h>
#include <stdio.h>


Regards,
Markus

08-11-2003, 07:55 AM
Either including <my_global.h> or Deawin's suggestion get rid of the mysql errors for me.

G:\JOB\NightDumps\NightDumps\Source\zone\import_ra w_items.cpp(50) : error C2039: 'unknown0144' : is not a member of 'Item_Struct'
G:\JOB\NightDumps\NightDumps\Source\zone\../common/eq_packet_structs.h(973) : see declaration of 'Item_Struct'
G:\JOB\NightDumps\NightDumps\Source\zone\import_ra w_items.cpp(50) : error C2039: 'unknown0144' : is not a member of 'Item_Struct'
G:\JOB\NightDumps\NightDumps\Source\zone\../common/eq_packet_structs.h(973) : see declaration of 'Item_Struct'

Browsing the CVS on sourceforge, this would seem to be due to some conditional compilation in eq_packets_struct.h. It is only compiled in if TEST_SERVER_AA is defined.

Magoth78
08-12-2003, 05:14 AM
Hi there and thx for the replys,

yes, I got rid of the mysql errors while compiling and I thank you.

But, I still have the Item_Struct errors.
Derision> I have not exactly understood what you said. You mean I can compile if I #define TEST_SERVER_AA in the eq_packet_structs.h?

08-12-2003, 06:32 AM
Forget what i said about TEST_SERVER_AA, i wasn't paying enough attention to the code. My guess is that the devs have updated the Item_Struct and removed the member unknown144 but not got around to updating the program you are trying to compile.