• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Compiling easy as hell for advanced c++ programers

Nuvemem

;]
Joined
Apr 4, 2009
Messages
220
Reaction score
0
Location
Somewhere...
hello,

I got some kind of problem, I added few lines of code, which does requires from player to open outfit window if they want to change to any other outfit, couse in older servers such like 7.92 there was bug which makes You able to set full addons outfit by clicking some function on bot. And when i added these lines, my server started to crashing down, and I don't have any idea what's i did wrong.

protocol79.cpp : ( it's about option hasRequestedOutfit, i added that one only ) [ marked what i added ]

Code:
void Protocol79::parseRequestOutfit(NetworkMessage& msg)
{
	OTSYS_THREAD_LOCK_CLASS lockClass(g_game.gameLock, "Protocol79::parseRequestOutfit()");
	msg.Reset();
	
	msg.AddByte(0xC8);
	AddCreatureOutfit(msg, player, player->getDefaultOutfit());
	
	unsigned long counter = 0;
	const OutfitListType& player_outfits = player->getPlayerOutfits();
	
	std::list<int> outfitList;
	for(OutfitListType::const_iterator it = player_outfits.begin(); it != player_outfits.end() && (counter < 15); ++it, ++counter){
		if((*it)->premium == 0 || player->isPremium()){
			outfitList.push_back((*it)->looktype);
		}
	}

	//client outfits limit is 15
	long count_outfits = outfitList.size();
	if(count_outfits > 15){
		msg.AddByte(15);
	}
	//there is not any available outfit
	else if(count_outfits == 0){
		return;
	}
	else{
		msg.AddByte(count_outfits);
	}

	for(std::list<int>::iterator i = outfitList.begin(); i != outfitList.end(); ++i){
		msg.AddU16(*i);
		msg.AddString(Outfits::getInstance()->getOutfitName(*i));
		msg.AddByte(player->getOutfitAddon(*i));
	}
		[COLOR="#f4a460"]hasRequestedOutfit = true;[/COLOR]	
	WriteBuffer(msg);
}

void Protocol79::parseSetOutfit(NetworkMessage& msg)
     
{
	int looktype = msg.GetU16();
	int lookhead = msg.GetByte();
	int lookbody = msg.GetByte();
	int looklegs = msg.GetByte();
	int lookfeet = msg.GetByte();
	int lookaddons = msg.GetByte();
	
	if(player->canWear(looktype))
	{
                                 		[COLOR="#f4a460"]if(hasRequestedOutfit)[/COLOR]
                                 		{
		Outfit_t newOutfit;
		newOutfit.lookType = looktype;
		newOutfit.lookHead = lookhead;
		newOutfit.lookBody = lookbody;
		newOutfit.lookLegs = looklegs;
		newOutfit.lookFeet = lookfeet;
		newOutfit.lookAddons = lookaddons;

		g_game.playerChangeOutfit(player, newOutfit);
		[COLOR="#f4a460"]hasRequestedOutfit = false;[/COLOR]
	}
}
}

protocol79.h :

Code:
	bool pendingLogout;
	Player* player;
	SOCKET s;
		[COLOR="#f4a460"]bool hasRequestedOutfit;[/COLOR]


the problem is thats it's working at the start but while after server goes down with crash, so if someone will now how to solve it, i would be glad and ofc i wll rep+

thanks!
 
Back
Top