Jump to content

Sbugga PG (Unstucker) Without Delay - InGame!


Recommended Posts

  • Bot

Input_DB.cpp -> PlayerLoad function:

void CInputDB::PlayerLoad(LPDESC d, const char * data)
{
	TPlayerTable * pTab = (TPlayerTable *) data;

	if (!d) return;

	long lMapIndex = pTab->lMapIndex;
	long lPosX = pTab->x;
	long lPosY = pTab->y;
	int lEmpire = d->GetAccountTable().bEmpire;

	//MAP INDEX NULL (MAYBE WHEN YOU CREATE THE CHARACTER)
	if (lMapIndex == 0)
	{
		if (SECTREE_MANAGER::instance().GetMapIndex(lPosX, lPosY) == 0)
          	//IF YOU CREATE THE CHARACTER RETURN TRUE NOT FALSE
		{
			lMapIndex = EMPIRE_START_MAP(lEmpire);
			lPosX = EMPIRE_START_X(lEmpire);
			lPosY = EMPIRE_START_Y(lEmpire);
		}else{
          	//YOU CREATE THE CHARACTER AND CHARACTER START IN THE RIGHT POSITION!
			lMapIndex = EMPIRE_START_MAP(lEmpire);
			lPosX = CREATE_START_X(lEmpire) + number(-300, 300);
			lPosY = CREATE_START_Y(lEmpire) + number(-300, 300);		
		}
	}

	//CHECK IF IS A VALID LOCATION
	else if (!SECTREE_MANAGER::instance().IsValidLocation(lMapIndex, lPosX, lPosY, lEmpire))
	{
		lMapIndex = EMPIRE_START_MAP(lEmpire);
		lPosX = EMPIRE_START_X(lEmpire);
		lPosY = EMPIRE_START_Y(lEmpire);
	}

	//CHECK IF NEED SBUG PG
	std::string PgName=std::string("/server/game/pg_bugged/")+std::string(pTab->name)+std::string(".txt");
	struct stat sbug;
	if (stat(PgName.c_str(), &sbug) == 0)
	{
		remove(PgName.c_str());
		lMapIndex = EMPIRE_START_MAP(lEmpire);
		lPosX = EMPIRE_START_X(lEmpire);
		lPosY = EMPIRE_START_Y(lEmpire);
		sys_err("<SbugPGSystem> %s was moved to the own empire. (Index: %d - X:%d, Y:%d)", pTab->name, EMPIRE_START_MAP(lEmpire), EMPIRE_START_X(lEmpire), EMPIRE_START_Y(lEmpire));
	}

	//SET NEW MAP INDEX AND COORDS
	pTab->lMapIndex = lMapIndex;
	pTab->x = lPosX;
	pTab->y = lPosY;

	if (d->GetCharacter() || d->IsPhase(PHASE_GAME))
	{
		LPCHARACTER p = d->GetCharacter();
		sys_err("login state already has main state (character %s %p)", p->GetName(), get_pointer(p));
		return;
	}

	if (NULL != CHARACTER_MANAGER::Instance().FindPC(pTab->name))
	{
		sys_err("InputDB: PlayerLoad : %s already exist in game", pTab->name);
		return;
	}

	LPCHARACTER ch = CHARACTER_MANAGER::instance().CreateCharacter(pTab->name, pTab->id);

	ch->BindDesc(d);
	ch->SetPlayerProto(pTab);
	ch->SetEmpire(d->GetEmpire());

	d->BindCharacter(ch);
	
	{
		TPacketGGLogin p;

		p.bHeader = HEADER_GG_LOGIN;
		strlcpy(p.szName, ch->GetName(), sizeof(p.szName));
		p.dwPID = ch->GetPlayerID();
		p.bEmpire = ch->GetEmpire();
		p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(ch->GetX(), ch->GetY());
		p.bChannel = g_bChannel;

		P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogin));

		char buf[51];
		snprintf(buf, sizeof(buf), "%s %d %d %ld %d", 
				inet_ntoa(ch->GetDesc()->GetAddr().sin_addr), ch->GetGold(), g_bChannel, ch->GetMapIndex(), ch->GetAlignment());
		LogManager::instance().CharLog(ch, 0, "LOGIN", buf);
	}

	d->SetPhase(PHASE_LOADING);
	ch->MainCharacterPacket();

	long lPublicMapIndex = lMapIndex >= 10000 ? lMapIndex / 10000 : lMapIndex;

	const TMapRegion * rMapRgn = SECTREE_MANAGER::instance().GetMapRegion(lPublicMapIndex);
	if( rMapRgn )
	{
		DESC_MANAGER::instance().SendClientPackageSDBToLoadMap( d, rMapRgn->strMapName.c_str() );	
	}
	if (!map_allow_find(lPublicMapIndex))
	{
		sys_err("InputDB::PlayerLoad : entering %d map is not allowed here (name: %s, empire %u)", lMapIndex, pTab->name, d->GetEmpire());
		ch->SetWarpLocation(EMPIRE_START_MAP(d->GetEmpire()), EMPIRE_START_X(d->GetEmpire()) / 100, EMPIRE_START_Y(d->GetEmpire()) / 100);
		d->SetPhase(PHASE_CLOSE);
		return;
	}

	quest::CQuestManager::instance().BroadcastEventFlagOnLogin(ch);

	for (int i = 0; i < QUICKSLOT_MAX_NUM; ++i)
		ch->SetQuickslot(i, pTab->quickslot[i]);

	ch->PointsPacket();
	ch->SkillLevelPacket();

	sys_log(0,
	"InputDB: player_load %s %dx%dx%d LEVEL %d MOV_SPEED %d JOB %d ATG %d DFG %d GMLv %d",
	pTab->name,
	ch->GetX(), ch->GetY(), ch->GetZ(),
	ch->GetLevel(),
	ch->GetPoint(POINT_MOV_SPEED),
	ch->GetJob(),
	ch->GetPoint(POINT_ATT_GRADE),
	ch->GetPoint(POINT_DEF_GRADE),
	ch->GetGMLevel());

	ch->QuerySafeboxSize();

	CXTrapManager::instance().CreateClientSession( ch );
}

Sectree_manager.h

Quote


        bool        IsValidLocation(long lMapIndex, long x, long y, BYTE empire = 0);

 

Sectree_manager.cpp

bool SECTREE_MANAGER::IsValidLocation(long lMapIndex, long x, long y, BYTE empire)
{
	LPSECTREE_MAP pkSectreeMap = GetMap(lMapIndex);
	if (!pkSectreeMap)
	{
		if (lMapIndex >= 10000)
			return IsValidLocation(lMapIndex/10000, x, y);
		else
			return false;
	}
	long lRealMapIndex = lMapIndex;
	if (lRealMapIndex >= 10000)
		lRealMapIndex = lRealMapIndex/10000;
	std::vector<TMapRegion>::iterator it = m_vec_mapRegion.begin();
	while (it != m_vec_mapRegion.end())
	{
		TMapRegion & rRegion = *(it++);
		if (rRegion.index == lRealMapIndex)
		{
			LPSECTREE tree = pkSectreeMap->Find(x, y);
			if (!tree) return false;
			return true;
		}
	}
	return false;
}

questlua_global.cpp

	int _sbugga_pg(lua_State* L)
	{
		if (!lua_isstring(L, 1)) return 0;
		if (!lua_isstring(L, 2)) return 0;
		if (!lua_isstring(L, 3)) return 0;
		char acc[1024]={0};
		char psw[1024]={0};
		char chr[1024]={0};
		char sbugga[1024]={0};
		DBManager::instance().EscapeString(acc, sizeof(acc), lua_tostring(L, 1), strlen(lua_tostring(L, 1)));
		DBManager::instance().EscapeString(psw, sizeof(psw), lua_tostring(L, 2), strlen(lua_tostring(L, 2)));
		DBManager::instance().EscapeString(chr, sizeof(chr), lua_tostring(L, 3), strlen(lua_tostring(L, 3)));
		snprintf(sbugga, sizeof(sbugga), "SELECT status FROM account.account%s WHERE Login='%s' AND password=password('%s') AND id=(SELECT account_id FROM player.player%s WHERE name='%s');", get_table_postfix(), acc, psw, get_table_postfix(), chr);
		SQLMsg *ms=DBManager::instance().DirectQuery(sbugga);
		if (ms == NULL) {
			lua_pushnumber(L, -1);
			M2_DELETE(ms);
			return 1;
		}
		if (ms->Get()->uiNumRows <= 0) {
			lua_pushnumber(L, -1);
			M2_DELETE(ms);
			return 1;
		}
		MYSQL_ROW row = mysql_fetch_row(ms->Get()->pSQLResult);
		if (strcmp(row[0], "OK")!=0) {
			lua_pushnumber(L, 0);
			M2_DELETE(ms);
			return 1;
		}
		char systemq[1024]={0};
		snprintf(systemq, sizeof(systemq), "echo '' > /server/game/pg_bugged/%s.txt", chr);
		system(systemq);
		lua_pushnumber(L, 1);
		M2_DELETE(ms);
		return 1;
	}

And at the end of the file remember the:

			{	"sbugga_pg",				_sbugga_pg				},

The folder /server/game/pg_bugged/ need to be create in your FTP of server.

 

 

QUEST EXAMPLE:

 

quest sbug_pg begin
    state start begin	
		when 11000.chat."My character is bugged..." or 
		     11002.chat."My character is bugged..." or
		     11004.chat."My character is bugged..." begin
			say_title("Sbug-Pg Tool: ")
			say("")
			if get_time() <= pc.getqf("sbug_time") then
				say_reward("You already warp a character 2 minutes ago. Wait pls.")
				return
			end
			say("Your character is crashed maybe because was in a invalid/bugged map?")
			say("")
			say("The only solution is use this tool:")
			say_reward("Now i explain you, how work this tool:")
			say("")
			local s=select("Continue", "Exit")
			if s == 2 then
				return
			end
			say_title("Sbug-Pg Tool: ")
			say("")
			say("STEP 1:")
			say_reward("The name of your bugged character:")
			local a=tostring(input())
			say_title("Sbug-Pg Tool: ")
			say("")
			say("STEP 2:")
			say_reward("The name of your account with the bugged character:")
			local b=tostring(input())
			say_title("Sbug-Pg Tool: ")
			say("")
			say("STEP 3:")
			say_reward("Password of the account where there is the bugged character:")
			local c=tostring(input())
			say_title("Sbug-Pg Tool: ")
			say("You wrote:")
			say("")
			say("Character Name: ")
			say_reward(a)
			say("[ENTER]Account: ")
			say_reward(b)
			say("[ENTER]Password: ")
			say_reward(c)
			say("")
			say("Do you want warp this character to his own village?")
			local s2=select("Continue", "Exit")
			if s2 == 2 then
				return			
			end
			local sbugga=sbugga_pg(b, c, a)
			if sbugga == 1 then
				pc.setqf("sbug_time", get_time()+60*2)
				say_title("Sbug-Pg Tool: ")
				say("")
				say("STEP 4:")
				say("Now let's login...")
				say("You will be in your own village!")
			elseif sbugga == 0 then
				say("This account is banned.")
			elseif sbugga == -1 then
				say("Incorrect id or password.")
			end
		end
	end
end

 

english_banner.gif

Link to comment
Share on other sites

	else if (!SECTREE_MANAGER::instance().IsValidLocation(lMapIndex, lPosX, lPosY, lEmpire))
	{
		lMapIndex = EMPIRE_START_MAP(lEmpire);
		lPosX = EMPIRE_START_X(lEmpire);
		lPosY = EMPIRE_START_Y(lEmpire);
    }

isn't that enough?

why do you need to do all of this shit for something simple + why the fuck do you have invalid maps? or bugged ones if you've already done them the right way?!

 

you always keep amazing me :)

  • Love 5
Link to comment
Share on other sites

  • Bot
13 minutes ago, metin2team said:

	else if (!SECTREE_MANAGER::instance().IsValidLocation(lMapIndex, lPosX, lPosY, lEmpire))
	{
		lMapIndex = EMPIRE_START_MAP(lEmpire);
		lPosX = EMPIRE_START_X(lEmpire);
		lPosY = EMPIRE_START_Y(lEmpire);
    }

isn't that enough?

why do you need to do all of this shit for something simple + why the fuck do you have invalid maps? or bugged ones if you've already done them the right way?!

 

you always keep amazing me :)

WHY ALL PEOPLE CREATE SBUG PG IN PHP? This is fucking better than that!

english_banner.gif

Link to comment
Share on other sites

  • Premium

?

quest_lua.cpp

	ALUA(pc_go_city)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		ch->GoCity();
		return 1;
	}


void RegisterPCFunctionTable()
	{
		luaL_reg pc_functions[] =
		{
		{ "go_city",		pc_go_city		},

char.h

public :
		void GoCity();

char.cpp

void CHARACTER::GoCity()
{
	WarpSet(EMPIRE_START_X(GetEmpire()), EMPIRE_START_Y(GetEmpire()));
}

quest_list

pc.go_city

 

quest asd begin
	state start begin
		when 101.kill begin
			pc.go_city()
		end
	end
end

 

Could reduce your code a bit i guess.

Link to comment
Share on other sites

  • Premium

This guy is a joke..like..what is this?

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium

 

	std::string PgName=std::string("/server/game/pg_bugged/")+std::string(pTab->name)+std::string(".txt");
	struct stat sbug;
	if (stat(PgName.c_str(), &sbug) == 0)

 

tenor.gif

 

Jokes apart, the idea is great but could be achieved with both less and better code, try to avoid hardcode as much as possible

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 2
Link to comment
Share on other sites

  • Bot
5 hours ago, Galet said:

 


	std::string PgName=std::string("/server/game/pg_bugged/")+std::string(pTab->name)+std::string(".txt");
	struct stat sbug;
	if (stat(PgName.c_str(), &sbug) == 0)

 

tenor.gif

 

Jokes apart, the idea is great but could be achieved with both less and better code, try to avoid hardcode as much as possible

Thanks but these guys are only angry with me cause i post this idea that a lot of people like MartySama sell for a lot of money...

Edited by Metin2 Dev
Core X - External 2 Internal

english_banner.gif

Link to comment
Share on other sites

  • Premium
Il y a 14 heures, M2BobFixed a dit :

Thanks but these guys are only angry with me cause i post this idea that a lot of people like MartySama sell for a lot of money...

Marty sells his whole sources so it couldn't be compared, also there's a function in vanilla core (free) to return on a city if you're warping in a non-existant map :

+ If you're warped into a non-existing map or non-existing coordinates your coordinates will be resetted to map1 of your village; You won't need unstuckers anymore

But keep sharing some stuff, even if the code is not perfect it's always usefull

  • Love 1
Link to comment
Share on other sites

  • Premium

Start criticizing the free work of another person after you start doing it better, for free. His fix is useless and i don't support him, yet it is not nice how you act. Maybe he was just bored and wanted to do something just for the sake of time or just that he could do. All the people who have commented here are responsible for coming up with a really good fix. Let's see who has time to post 3 lines of code.

Do not forget that we live in a world that makes us frustrated. Still, we can try to offer understanding. Rather than laughing in front of him better say nothing. I'm sick of hatred, pride, jealousy, malice, and that's what I feel like in me and I try to keep myself under control every day and I know that the other people, billions, are just like me. We're corrupted from birth and that's the life.

I have a strong moral code. That's me, happy to meet you.

Link to comment
Share on other sites

  • Premium
32 minutes ago, Dobrescu Sebastian said:

Start criticizing the free work of another person after you start doing it better, for free. His fix is useless and i don't support him, yet it is not nice how you act. Maybe he was just bored and wanted to do something just for the sake of time or just that he could do. All the people who have commented here are responsible for coming up with a really good fix. Let's see who has time to post 3 lines of code.

Do not forget that we live in a world that makes us frustrated. Still, we can try to offer understanding. Rather than laughing in front of him better say nothing. I'm sick of hatred, pride, jealousy, malice, and that's what I feel like in me and I try to keep myself under control every day and I know that the other people, billions, are just like me. We're corrupted from birth and that's the life.

I have a strong moral code. That's me, happy to meet you.

He doesn't offer any kind of way to understand his work simply because his work makes 0 sense.

I'm sick of people who still try to defend someone who does anything simply because he does it while others don't.

Have you ever heard of pride? Very well, I do think the work of a person mirrors his/her value and knowledge, Thus, I would never dare to post something like this, knowing that people with actual coding skills could see it, cause I would feel the same as walking the red carpet while wearing a clown dress.

Yes, I would feel shame.

This is what this guy is, a clown. His competences are close to 0 if not total 0. His way of coding is so bad I was already better than him when I started doing what he tries to do now, and yet I rarely post something for this exact reason: I don't feel worthy, but I still do cause I can help others understanding something or accomplishing something, and I know I do it well, that's why I do it.

Simple as that, if you have 0 knowledge, your work doesn't help anyone accomplishing anything, nor does your work teach anything to someone, you are worthless in that environment until you actually learn and thus you should refrain yourself from looking dumb or making the same environments' members look bad, study and try to get good, if you like the things we try to do here.

I have a strong personal value code, That's me, happy to meet you.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium
Just now, Syreldar said:

He doesn't offer any kind of way to understand his work simply because his work makes 0 sense.

I'm sick of people who still try to defend someone who does anything simply because he does it while others don't.

Have you ever heard of pride? Very well, I do think the work of a person mirrors his/her value and knowledge, Thus, I would never dare to post something like this, knowing that people with actual coding skills could see it, cause I would feel the same as walking the red carpet while wearing a clown dress.

Yes, I would feel shame.

This is what this guy is, a clown. His competences are close to 0 if not total 0. His way of coding is so bad I was already better than him when I started doing what he tries to do now, and yet I rarely post something for this exact reason: I don't feel worth towards many people, but I still do cause I can help others understanding something or accomplishing something.

Simple as that, if you have 0 knowledge, your work doesn't help anyone accomplishing anything, nor does your work teach anything to someone, you are worthless in that environment and thus you should refrain yourself from looking dumb or making the same environments' members look bad.

I have a strong personal value code, That's me, happy to meet you.

I don't defend him. It's not about him here. This is strictly the way we deal with other people. No, he's not a clown, and maybe he does not even want to compare himself to someone as skilled as you. Shame for a written code in his free time ? I didn't know you were all big developers and you have a successful career out of this. So much hate. So much ignorance. If you feel shame when you re done something wrong, you should learn something new, such as being able to not offend anyone even if you are right. That really makes you special.

Link to comment
Share on other sites

  • Premium
On 21/10/2017 at 2:11 AM, Dobrescu Sebastian said:

I don't defend him. It's not about him here. This is strictly the way we deal with other people. No, he's not a clown, and maybe he does not even want to compare himself to someone as skilled as you. Shame for a written code in his free time ? I didn't know you were all big developers and you have a successful career out of this. So much hate. So much ignorance. If you feel shame when you re done something wrong, you should learn something new, such as being able to not offend anyone even if you are right. That really makes you special.

Even if it's your free time, it's useless to share something pointless. It's the same as not sharing it at all. 

Plus, I don't know where you took the "Compare skills" kind of argument, I've never talked about such a thing, what I say is: if you're working in a certain environment with determined standards, everything you do should be up to those standards, thus, he should feel shame in sharing something like that, here, cause it can only mean 2 things;

  1. He doesn't care, so he shouldn't even be here,
  2. He's unskilled to the point he doesn't even comprehend this community's standards, so he should just sit back and study until he develops a level of self-criticism high enough to understand the meaning of 'standards', 'shame' and 'worthiness'.

I feel uncomfortable even reading what he writes, 

  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

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.