Jump to content

Error in CreatePlayerSaveQuery [Only C++ Pro's]


Recommended Posts

Hello,

 

I think my Question is for Advanced C++ People :D.

 

So this is my szenario:

  • I added a new col in Player Table, called plan (INT)
  • Added it to all important places in db-, game src to make it accessable for Quests
  • The Metin2 Caching System gets the plan col and the data (no problem)
  • I can use it in Quests and could send it to the Client (no problem)
  • But you know, every 10 Minutes the Cache writes his Data in the mysql table Player back to save it (Async)
  • And this Method is CreatePlayerSaveQuery
  • So because I added a new col to the cache, I need to write it back again
  • I added plan to the Method below and included Debug Mode (vs2013)  on db_d.exe (windows serverfiles)
  • I have set my breakpoints on this method and waited for 10 Mins
  • Than I view ,,pkTab->plan" and in the end ,,pszQuery"
  • In Both var's, I found my plan value
  • So I thought everything should be right.
  • But then I Looked at the new input in my player table...
  • plan got the right value but other values are changed too (horse_level as example sometimes got 255, but I haven't got a horse, ip is (null) (But ,,pkTab->ip", in that method, got the right value) and part_main is 65535
  • I think it has something to do with queryLen but I'm not a C++ Pro :D (Got my Skillz in php, css, html, js, python, swift)
size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * pkTab)
{
	size_t queryLen;

	queryLen = snprintf(pszQuery, querySize,
		"UPDATE player%s SET "
		"job = %d, "
		"voice = %d, "
		"dir = %d, "
		"x = %d, "
		"y = %d, "
		"z = %d, "
		"map_index = %d, "
		"exit_x = %ld, "
		"exit_y = %ld, "
		"exit_map_index = %ld, "
		"hp = %d, "
		"mp = %d, "
		"stamina = %d, "
		"random_hp = %d, "
		"random_sp = %d, "
		"playtime = %d, "
		"level = %d, "
		"level_step = %d, "
		"st = %d, "
		"ht = %d, "
		"dx = %d, "
		"iq = %d, "
		"gold = %lld, "
		"exp = %u, "
		"stat_point = %d, "
		"skill_point = %d, "
		"sub_skill_point = %d, "
		"stat_reset_count = %d, "
		"ip = '%s', "
		"part_main = %d, "
		"part_hair = %d, "
		"last_play = NOW(), "
		"skill_group = %d, "
		"alignment = %ld, "
		"horse_level = %d, "
		"horse_riding = %d, "
		"horse_hp = %d, "
		"horse_hp_droptime = %u, "
		"horse_stamina = %d, "
		"horse_skill_point = %d, "
                "plan = %d, "

		,
		GetTablePostfix(),
		pkTab->job,
		pkTab->voice,
		pkTab->dir,
		pkTab->x,
		pkTab->y,
		pkTab->z,
		pkTab->lMapIndex,
		pkTab->lExitX,
		pkTab->lExitY,
		pkTab->lExitMapIndex,
		pkTab->hp,
		pkTab->sp,
		pkTab->stamina,
		pkTab->sRandomHP,
		pkTab->sRandomSP,
		pkTab->playtime,
		pkTab->level,
		pkTab->level_step,
		pkTab->st,
		pkTab->ht,
		pkTab->dx,
		pkTab->iq,
		(long long)pkTab->gold,
		pkTab->exp,
		pkTab->stat_point,
		pkTab->skill_point,
		pkTab->sub_skill_point,
		pkTab->stat_reset_count,
		pkTab->ip,
		pkTab->parts[PART_MAIN],
		pkTab->parts[PART_HAIR],
		pkTab->skill_group,
		pkTab->lAlignment,
		pkTab->horse.bLevel,
		pkTab->horse.bRiding,
		pkTab->horse.sHealth,
		pkTab->horse.dwHorseHealthDropTime,
		pkTab->horse.sStamina,
		pkTab->horse_skill_point,
                pkTab->plan);


	// Binary ·Î ¹Ù²Ù±â À§ÇÑ Àӽà °ø°£
	static char text[8192 + 1];

	CDBManager::instance().EscapeString(text, pkTab->skills, sizeof(pkTab->skills));
	queryLen += snprintf(pszQuery + queryLen, querySize - queryLen, "skill_level = '%s', ", text);

	CDBManager::instance().EscapeString(text, pkTab->quickslot, sizeof(pkTab->quickslot));
	queryLen += snprintf(pszQuery + queryLen, querySize - queryLen, "quickslot = '%s' ", text);

	queryLen += snprintf(pszQuery + queryLen, querySize - queryLen, " WHERE id=%d", pkTab->id);
	return queryLen;
}

I will love you for posting a Tipp or if you could explain this ,,queryLen"

 

Edit: Heres the query, the db server applies on player:

UPDATE player SET job = 6, voice = 0, dir = 0, x = 474928, y = 959144, z = 0, map_index = 1, exit_x = 474928, exit_y = 959144, exit_map_index = 1, hp = 770, mp = 300, stamina = 815, random_hp = 0, random_sp = 0, playtime = 306, level = 1, level_step = 0, st = 5, ht = 3, dx = 3, iq = 5, gold = 0, exp = 0, stat_point = 0, skill_point = 0, sub_skill_point = 0, stat_reset_count = 0, ip = '(null)', part_main = 29550585, part_hair = 0, last_play = NOW(), skill_group = 0, alignment = 0, horse_level = 300, horse_riding = 0, horse_hp = 0, horse_hp_droptime = 0, horse_stamina = 0, horse_skill_point = 0, plan = 3, skill_level = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', quickslot = '000000000000000000000000000000000000000000000000000000000000000000000000'  WHERE id=7338

Here It sets the right plan value... But ip = '(null)' , part_main = 29550585, horse_level = 300 dafuqqq??? :D

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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.