Jump to content

New pet system server source ERR


Recommended Posts

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Before:

std::ifstream exppet_table_open("/usr/home/game/share/exppettable.txt");

Add:

std::string temp_exp_line;
#ifdef NEW_PET_SYSTEM
	std::string temp_exp_line;
	std::ifstream exppet_table_open("/usr/home/game/share/exppettable.txt");
	/*if (!exp_table_open.is_open())
	return 0;*/

	int exppet_table_counter = 0;
	int tmppet_exp = 0;
	while (!exppet_table_open.eof())
	{
		exppet_table_open >> temp_exp_line;
		str_to_number(exppet_table_common[exppet_table_counter], temp_exp_line.c_str());
		if (exppet_table_common[exppet_table_counter] < 2147483647) {
			sys_log(0, "Livelli Pet caricati da exppettable.txt: %d !", exppet_table_common[exppet_table_counter]);
			exppet_table_counter++;
		}
		else {
			fprintf(stderr, "[main] Impossibile caricare la tabella exp valore non valido\n");
			break;
		}
	}
#endif

Learn some basics of C++ - it doesn't hurt.

Link to comment
Share on other sites

1 minute ago, vandragoon said:

now i have this:
main.cpp:497: error: redeclaration of 'std::string temp_exp_line'
main.cpp:474: error: 'std::string temp_exp_line' previously declared here
 

Better do it this way:

	// START_OF_Player_EXP_TABLE_LOADING
	string temp_exp_line;
	char szExpTable[256];
	snprintf(szExpTable, sizeof(szExpTable), "%s/exp.txt", LocaleService_GetBasePath().c_str());
	ifstream exp_table_open(szExpTable);
	if (!exp_table_open.is_open()) {
		fprintf(stderr, "Failed to Load ExpTable from %s/exp.txt\n", LocaleService_GetBasePath().c_str());
		sys_err("Failed to Load ExpTable from %s/exp.txt", LocaleService_GetBasePath().c_str());
		return 0;
	}
	int exp_table_counter = 0;
	while (!exp_table_open.eof())
	{
		exp_table_open >> temp_exp_line;
		str_to_number(exp_table_common[exp_table_counter], temp_exp_line.c_str());
		exp_table_counter++;
	}
	fprintf(stderr, "EXP erfolgreich geladen von: %s\n", LocaleService_GetBasePath().c_str());
	//sys_log(0, "EXP Table Loaded succsefully from %s", LocaleService_GetBasePath().c_str());
	// END_OF_Player_EXP_TABLE_LOADING
	
#ifdef NEW_PET_SYSTEM
 	temp_exp_line = ""; //clearing
	std::ifstream exppet_table_open("/usr/home/game/share/exppettable.txt");
	/*if (!exp_table_open.is_open())
	return 0;*/

	int exppet_table_counter = 0;
	int tmppet_exp = 0;
	while (!exppet_table_open.eof())
	{
		exppet_table_open >> temp_exp_line;
		str_to_number(exppet_table_common[exppet_table_counter], temp_exp_line.c_str());
		if (exppet_table_common[exppet_table_counter] < 2147483647) {
			sys_log(0, "Livelli Pet caricati da exppettable.txt: %d !", exppet_table_common[exppet_table_counter]);
			exppet_table_counter++;
		}
		else {
			fprintf(stderr, "[main] Impossibile caricare la tabella exp valore non valido\n");
			break;
		}
	}
#endif

You didn't notice you've added something with the same name of variable before. Next time remember to check.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.