• 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!

szukanie prostego skrypcioru do c++ :)

Nuvemem

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


hostuje server 7.92 i mam problem z outfitami, ponieważ można robić full outfity za pomocą NG Bota, a to jest troche żenujące ponieważ wole jakby ludzie zbierali itemy na nie, a nie jestem w stanie zapanować nad tym dając bany.

i mam pytanie, gdzie w source plikach jest wzmianka o tym bugu, przeszukiwałem w outfits.cpp i .h i nic nie znalazłem wartościowego.

ogólnie bym był wdzięczny jak by ktoś mnie nakierował gdzie powinienem działać, chyba, że to nie jest dla kogoś problem i by mi napisał co powoduje ten jakże wkur**ający bug.


oczywiście za każdą pomocną odpowiedź dam rep+


dzięki z góry,
pjona!
 
yyy, ale ten outfit widzą chyba tylko Ci co sobie go ustawią w ngbocie, to działa na każdej tibii...
 
Jesli gracie od tibi 8.5 to tak...
Ale na starszych ots'ach jest ten blad
 
pewnie chodzi o to, że klient nie dostaje możliwości ustawienia nieposiadanego outfitu(wysyłana lista zawiera tylko posiadane) ALE jeśli serv otrzyma pakiet z id outfitu to go ustawi, tak? powinno być proste, ale przydałby się player.cpp(ten check tu się znajduje w nowych)

pewnie będzie trochę zabawy aby to wszystko poskładać, cały staryt outfit.cpp pewnie też by się przydał dla porównania
 
outfit.cpp

Code:
//////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
//////////////////////////////////////////////////////////////////////
// 
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#include "otpch.h"

#include "definitions.h"
#include "outfit.h"
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include "creature.h"
#include "player.h"
#include "tools.h"

OutfitList::OutfitList()
{
	//
}

OutfitList::~OutfitList()
{
	OutfitListType::iterator it;
	for(it = m_list.begin(); it != m_list.end(); it++){
		delete *it;
	}
	m_list.clear();
}

void OutfitList::addOutfit(const Outfit& outfit)
{	
	OutfitListType::iterator it;
	for(it = m_list.begin(); it != m_list.end(); ++it){
		if((*it)->looktype == outfit.looktype){
			(*it)->premium = (*it)->premium | outfit.premium;
			return;
		}
	}
	//adding a new outfit
	Outfit* new_outfit = new Outfit;
	new_outfit->looktype = outfit.looktype;
	new_outfit->premium = outfit.premium;
	m_list.push_back(new_outfit);
}

bool OutfitList::remOutfit(const Outfit& outfit)
{
	OutfitListType::iterator it;
	for(it = m_list.begin(); it != m_list.end(); ++it){
		if((*it)->looktype == outfit.looktype){
			m_list.erase(it);
			return true;
		}
	}
	return false;
}

bool OutfitList::isInList(uint32_t looktype) const
{
	OutfitListType::const_iterator it;
	for(it = m_list.begin(); it != m_list.end(); ++it){
		if((*it)->looktype == looktype){
			return true;
		}
	}
	return false;
}

Outfits::Outfits()
{
	Outfit outfit;
	//build default outfit lists
	outfit.premium = 0;
	for(int i = PLAYER_FEMALE_1; i <= PLAYER_FEMALE_7; i++){
		outfit.looktype = i;
		m_female_list.addOutfit(outfit);
	}
		
	for(int i = PLAYER_MALE_1; i <= PLAYER_MALE_7; i++){
		outfit.looktype = i;
		m_male_list.addOutfit(outfit);
	}
	
	m_list.resize(10, NULL);
}

Outfits::~Outfits()
{
	OutfitsListVector::iterator it;
	for(it = m_list.begin(); it != m_list.end(); it++){
		delete *it;
	}
	m_list.clear();
}

bool Outfits::loadFromXml(const std::string& datadir)
{
	std::string filename = datadir + "outfits.xml";

	xmlDocPtr doc = xmlParseFile(filename.c_str());
	if(doc){
		xmlNodePtr root, p;
		root = xmlDocGetRootElement(doc);
		
		if(xmlStrcmp(root->name,(const xmlChar*)"outfits") != 0){
			xmlFreeDoc(doc);
			std::cout << "Warning: outfits.xml not found, using defaults." << std::endl;
			return true;
		}
		
		p = root->children;
		
		while(p){
			std::string str;
			int intVal;
			if(xmlStrcmp(p->name, (const xmlChar*)"outfit") == 0){
				if(readXMLInteger(p, "type", intVal)){
					if(intVal > 9 || intVal < 0){
						std::cout << "Warning: No valid outfit type " << intVal << std::endl;
					}
					else{
						OutfitList* list;
						
						if(m_list[intVal] != NULL){
							list = m_list[intVal];
						}
						else{
							list = new OutfitList;
							m_list[intVal] = list;
						}
						
						Outfit outfit;
						std::string outfitName;
						readXMLString(p, "name", outfitName);
						if(readXMLInteger(p, "looktype", intVal)){
							outfit.looktype = intVal;
						}
						if(readXMLInteger(p, "premium", intVal)){
							outfit.premium = intVal;
						}
						
						outfitNamesMap[outfit.looktype] = outfitName;
						
						list->addOutfit(outfit);
					}
				}
				else{
					std::cout << "Missing outfit type." << std::endl;
				}
			}
			p = p->next;
		}
		xmlFreeDoc(doc);
	}
	return true;
}


pare linijek z protocol79.cpp o ustawieniu outfitu

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));
	}
		
	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)){
		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);
	}
}
 
okej dzięki chłopaki, macie rep+ za pomoc, może jeszcze dacie rade coś mi pomóc, hehe :)

oto co znalazłem z (canwear) w player.cpp :

Code:
const OutfitListType& Player::getPlayerOutfits()
{    
    return m_playerOutfits.getOutfits();
}

bool Player::canWear(uint32_t _looktype)
{
    if(m_playerOutfits.isInList(_looktype)){
        return true;
    }    
    return false;
}

void Player::genReservedStorageRange()
{
    unsigned long base_key;
    //generate outfits range
    base_key = PSTRG_OUTFITS_RANGE_START + 1;
    
    const OutfitList& global_outfits = Outfits::getInstance()->getOutfitList(sex);
    
    const OutfitListType& outfits = m_playerOutfits.getOutfits();
    OutfitListType::const_iterator it;
    for(it = outfits.begin(); it != outfits.end(); ++it){
        uint32_t looktype = (*it)->looktype;
        if(!global_outfits.isInList(looktype)){
            long value = (looktype << 16);
            storageMap[base_key] = value;
            base_key++;
            if(base_key > PSTRG_OUTFITS_RANGE_START + PSTRG_OUTFITS_RANGE_SIZE){
                std::cout << "Warning: [Player::genReservedStorageRange()] Player " << getName() << " with more than 500 outfits!." << std::endl;
                break;
            }
        }
    }
}

void Player::addOutfit(uint32_t _looktype, uint32_t _premium)
{
    Outfit outfit;
    outfit.looktype = _looktype;
    outfit.premium = _premium;
    m_playerOutfits.addOutfit(outfit);
}

bool Player::remOutfit(uint32_t _looktype, uint32_t _premium)
{
    Outfit outfit;
    outfit.looktype = _looktype;
    outfit.premium = _premium;
    return m_playerOutfits.remOutfit(outfit);
}
witam ponownie,


dzięki pomocy paru użytkowników tego forum, jestem bliski rozwiązania problemu "robienia full outfitów za pomocą Tibia Bot NG w starszych silnikach typu {7.92}"


otóż nie jestem koxem w c++ to mam lekkie problemy z połączeniem dwóch skryptów, a dokładniej do tego :

Code:
bool Player::canWear(uint32_t _looktype)
{
    if(m_playerOutfits.isInList(_looktype)){
        return true;
    }    
    return false;
}
chciałbym wkleić coś z tego, aby główny efekt był taki, że "gdy gracz będzie chciał zmienić outfit, to najpierw zobaczy czy w ogóle posiada takowy addon.


Silnik sprawdza posiadane przez gracza addony w taki dziwny sposób :


Code:
void Player::addAddon(uint32_t lookType, uint32_t addon)
{
    KnowAddonMap::iterator it = knowAddonMap.find(lookType);
    if(it != knowAddonMap.end()){
        uint32_t knowAddon = it->second;
        if(knowAddon == 0){
            if(addon == 1 || addon == 2){
                knowAddonMap[lookType] = addon;
            }
        }
        else if(knowAddon == 1 && addon == 2){
            knowAddonMap[lookType] = 3;
        }
        else if(knowAddon == 2 && addon == 1){
            knowAddonMap[lookType] = 3;
        }
    }
    else{
        knowAddonMap[lookType] = addon;
    }
}
Dzięki z góry!
 
Last edited by a moderator:
Back
Top