[C++] Opcode versão 8.54+

BananaFight
em Clients
  • 1
  • 2

BananaFight

Allahu Akbar
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 14/02/13Posts: 702Gênero: Masculino

 

Adaptação pra source 8.54+



LEMBRE-SE, ISSO É NA SOURCE DO SERVIDOR



Vamos ao código.




protocolgame.h



Embaixo de



 

void AddShopItem(NetworkMessage_ptr msg, const ShopInfo item);

 



Adicione



 

void parseExtendedOpcode(NetworkMessage& msg);void sendExtendedOpcode(uint8_t opcode, const std::string& buffer);

 



protocolgame.cpp



Embaixo de



uint32_t key[4] = {msg.GetU32(), msg.GetU32(), msg.GetU32(), msg.GetU32()};enableXTEAEncryption();setXTEAKey(key);



Adicione



// notifies to otclient that this server can receive extended game protocol opcodesif(operatingSystem >= CLIENTOS_OTCLIENT_LINUX)sendExtendedOpcode(0x00, std::string()); 



Embaixo de



void ProtocolGame::AddShopItem(NetworkMessage_ptr msg, const ShopInfo item){const ItemType& it = Item::items[item.itemId];msg->AddU16(it.clientId);if(it.isSplash() || it.isFluidContainer())msg->AddByte(fluidMap[item.subType % 8]);else if(it.stackable || it.charges)msg->AddByte(item.subType);elsemsg->AddByte(0x01);msg->AddString(item.itemName);msg->AddU32(uint32_t(it.weight * 100));msg->AddU32(item.buyPrice);msg->AddU32(item.sellPrice);}



Adicione



void ProtocolGame::parseExtendedOpcode(NetworkMessage& msg){uint8_t opcode = msg.GetByte();std::string buffer = msg.GetString();// process additional opcodes via lua script eventaddGameTask(&Game::parsePlayerExtendedOpcode, player->getID(), opcode, buffer);}void ProtocolGame::sendExtendedOpcode(uint8_t opcode, const std::string& buffer){// extended opcodes can only be send to players using otclient, cipsoft's tibia can't understand themNetworkMessage_ptr msg = getOutputBuffer();if(msg){TRACK_MESSAGE(msg);msg->AddByte(0x32);msg->AddByte(opcode);msg->AddString(buffer);}}



Embaixo de



 

case 0x1E: // keep alive / ping responseparseReceivePing(msg);break;

 



Adicione



 

case 0x32: // otclient extended opcodeparseExtendedOpcode(msg);break; 

 



enums.h



Embaixo de



 

enum GuildLevel_t{GUILDLEVEL_NONE = 0,GUILDLEVEL_MEMBER,GUILDLEVEL_VICE,GUILDLEVEL_LEADER};

 



Substitua o OperatingSystem por este



 

enum OperatingSystem_t{CLIENTOS_LINUX = 0x01,CLIENTOS_WINDOWS = 0x02,CLIENTOS_OTCLIENT_LINUX = 0x0A,CLIENTOS_OTCLIENT_WINDOWS = 0x0B,CLIENTOS_OTCLIENT_MAC = 0x0C,};/

 



player.h



Embaixo de



void sendCreatureShield(const Creature* creature)



Adicione



 

void sendExtendedOpcode(uint8_t opcode, const std::string& buffer){if(client) client->sendExtendedOpcode(opcode, buffer);} 

 



luascript.cpp



Embaixo de


void LuaScriptInterface::registerFunctions(){



Adicione



 

//doSendPlayerExtendedOpcode(cid, opcode, buffer)lua_register(m_luaState, "doSendPlayerExtendedOpcode", LuaScriptInterface::luaDoSendPlayerExtendedOpcode); 

 



Embaixo de



 

SHIFT_OPERATOR(int32_t, LeftShift, <<)SHIFT_OPERATOR(int32_t, RightShift, >>)SHIFT_OPERATOR(uint32_t, ULeftShift, <<)SHIFT_OPERATOR(uint32_t, URightShift, >>)#undef SHIFT_OPERATOR

 



Adicione



 

int32_t LuaScriptInterface::luaDoSendPlayerExtendedOpcode(lua_State* L){//doSendPlayerExtendedOpcode(cid, opcode, buffer)std::string buffer = popString(L);int opcode = popNumber(L);ScriptEnviroment* env = getEnv();if(Player* player = env->getPlayerByUID(popNumber(L))) {player->sendExtendedOpcode(opcode, buffer);lua_pushboolean(L, true);}lua_pushboolean(L, false);return 1;}

 



luascript.h



Embaixo de



 

virtual void registerFunctions();

 



Adicione



 

static int32_t luaDoSendPlayerExtendedOpcode(lua_State* L); 

 



creatureevent.h


.


Substitua



 

CREATURE_EVENT_PREPAREDEATH

 



Por isso



 

CREATURE_EVENT_PREPAREDEATH,CREATURE_EVENT_EXTENDED_OPCODE // otclient additional network opcodes

 



Embaixo de



 

uint32_t executePrepareDeath(Creature* creature, DeathList deathList);

 



Adicione



 

uint32_t executeExtendedOpcode(Creature* creature, uint8_t opcode, const std::string& buffer); 

 



creatureevent.cpp



Embaixo de



 

else if(tmpStr == "death")m_type = CREATURE_EVENT_DEATH;

 



Adicione



 

else if(tmpStr == "extendedopcode")m_type = CREATURE_EVENT_EXTENDED_OPCODE;

 



Embaixo de



 

case CREATURE_EVENT_DEATH:return "onDeath";

 



Adicione



 

case CREATURE_EVENT_EXTENDED_OPCODE:return "onExtendedOpcode"; 

 



Embaixo de



 

case CREATURE_EVENT_DEATH:return "cid, corpse, deathList";

 



Adicione



 

case CREATURE_EVENT_EXTENDED_OPCODE:return "cid, opcode, buffer"; 

 



Embaixo de



 

std::cout << "[Error - CreatureEvent::executeFollow] Call stack overflow." << std::endl;return 0;}}

 



Adicione



 

uint32_t CreatureEvent::executeExtendedOpcode(Creature* creature, uint8_t opcode, const std::string& buffer){//onExtendedOpcode(cid, opcode, buffer)if(m_interface->reserveEnv()){ScriptEnviroment* env = m_interface->getEnv();if(m_scripted == EVENT_SCRIPT_BUFFER){env->setRealPos(creature->getPosition());std::stringstream scriptstream;scriptstream << "local cid = " << env->addThing(creature) << std::endl;scriptstream << "local opcode = " << (int)opcode << std::endl;scriptstream << "local buffer = " << buffer.c_str() << std::endl;scriptstream << m_scriptData;bool result = true;if(m_interface->loadBuffer(scriptstream.str())){lua_State* L = m_interface->getState();result = m_interface->getGlobalBool(L, "_result", true);}m_interface->releaseEnv();return result;}else{#ifdef __DEBUG_LUASCRIPTS__char desc[35];sprintf(desc, "%s", player->getName().c_str());env->setEvent(desc);#endifenv->setScriptId(m_scriptId, m_interface);env->setRealPos(creature->getPosition());lua_State* L = m_interface->getState();m_interface->pushFunction(m_scriptId);lua_pushnumber(L, env->addThing(creature));lua_pushnumber(L, opcode);lua_pushlstring(L, buffer.c_str(), buffer.length());bool result = m_interface->callFunction(3);m_interface->releaseEnv();return result;}}else{std::cout << "[Error - CreatureEvent::executeRemoved] Call stack overflow." << std::endl;return 0;}}

 



game.h



Embaixo de




int32_t getLightHour() {return lightHour;}void startDecay(Item* item);



Adicione



void parsePlayerExtendedOpcode(uint32_t playerId, uint8_t opcode, const std::string& buffer);



game.cpp



Embaixo de



player->sendTextMessage(MSG_INFO_DESCR, buffer);}



Adicione



void Game::parsePlayerExtendedOpcode(uint32_t playerId, uint8_t opcode, const std::string& buffer){Player* player = getPlayerByID(playerId);if(!player || player->isRemoved())return;CreatureEventList extendedOpcodeEvents = player->getCreatureEvents(CREATURE_EVENT_EXTENDED_OPCODE);for(CreatureEventList::iterator it = extendedOpcodeEvents.begin(); it != extendedOpcodeEvents.end(); ++it)(*it)->executeExtendedOpcode(player, opcode, buffer);}



/creaturescripts/creaturescrips.xml



<event type="extendedopcode" name="ExtendedOpcode" event="script" value="extendedopcode.lua"/>



/creaturescripts/extendedopcode.lua



OPCODE_LANGUAGE = 1function onExtendedOpcode(cid, opcode, buffer)if opcode == OPCODE_LANGUAGE then-- otclient languageif buffer == 'en' or buffer == 'pt' then-- example, setting player language, because otclient is multi-language...--doCreatureSetStorage(cid, CREATURE_STORAGE_LANGUAGE, buffer)endelse-- other opcodes can be ignored, and the server will just work fine...endend



 Créditos : MaXwEllDeN 100% por adaptar o código

 

SkyDarkyes

avatar
Infante
Infante

INFOS

Grupo: InfanteRegistrado: 28/01/13Posts: 1685Gênero: Masculino

Tambem queria saber para que serve

48EnrrM.png

 

BananaFight

Allahu Akbar
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 14/02/13Posts: 702Gênero: Masculino

Serve para comunicar servidor com client, Com isso é possível criar muitos sistemas, como de andar e soltar som etc.

manoelneto

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 29/03/13Posts: 99

Muito bom Banana, sempre trazendo coisas legais pra sessão de códigos prontos em.

 

Vai dar pra fazer bastante coisa legal com isso dai, pena que meus conhecimentos são bem limitados..

 

Enfim, reputado.

Att Manoel;

2rm9y0y.jpg

Lost Worl of the Middle Kingdom, em breve!

PostadorHunter

avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 10/12/11Posts: 962Gênero: Masculino

arruma aqueli code ali em cima

 

enum OperatingSystem_t
{
CLIENTOS_LINUX = 0x01,
CLIENTOS_WINDOWS = 0x02,
CLIENTOS_OTCLIENT_LINUX = 0x0A,
CLIENTOS_OTCLIENT_WINDOWS = 0x0B,
CLIENTOS_OTCLIENT_MAC = 0x0C,
};[code]

[b][size=5]player.h[/size][/b]

[b]Embaixo de[/b]

[code]void sendCreatureShield(const Creature* creature)

TheSource

TheSource
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 01/02/13Posts: 47

Vcs podem dar ele ja compilado com isso? o executavel só, se puder seria de grande ajuda, pois meu pc nao compila o otclient infelizmente ele fica com 90 mb o executavel.

z6VjA8W.png?1

PostadorHunter

avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 10/12/11Posts: 962Gênero: Masculino

Vcs podem dar ele ja compilado com isso? o executavel só, se puder seria de grande ajuda, pois meu pc nao compila o otclient infelizmente ele fica com 90 mb o executavel.

isso é nas sources do servidor e não do otclient

TheSource

TheSource
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 01/02/13Posts: 47

Vcs podem dar ele ja compilado com isso? o executavel só, se puder seria de grande ajuda, pois meu pc nao compila o otclient infelizmente ele fica com 90 mb o executavel.

isso é nas sources do servidor e não do otclient

 

Desculpe minha ignorancia, kkkkkk.

 

@topic

 

Obrigado banana, so traz coisas legais ao forum.

z6VjA8W.png?1

ZeNit91

ZeNit91 "Zerons"
avatar
Cavaleiro
Cavaleiro

INFOS

Grupo: CavaleiroRegistrado: 08/01/11Posts: 192Gênero: Masculino

Nao teria um link ja copilado ?

Brincado no server ^^


MAPERS, Quem nos Somos ?
 

Somons como Deuses Criamos e colocamos kd coisa em seu lugar, construímos ilhas continentes e até um mundo inteiro, para as pessoas que o vem desfrutar de um mundo onde o objetivo é ser o melhor.



Nos não somos nd alem de pequenas pessoas que criamos grandes mundos, utilizando nossa imaginação como ponto de inicio e a inteligência como ponto final.

Oq é um mundo comprado a nossa imaginação ?

 


AAAA!!!
Não custa clicar!

962348.png

Slicer

Insanity
avatar
Príncipe
Príncipe

INFOS

Grupo: PríncipeRegistrado: 19/08/10Posts: 4014Gênero: Masculino

/\ ques q ele compile TODAS as versoes de sourcers pra vc amigo? ;/ esse codigo eh pra sourcer do serv ta.. n do otclient...

"Só a beira do abismo que os seres humanos acham forças para mudar."... E isso me da nojo... ¬¬

"Insanity is doing the exact... same fucking thing... over and over again expecting... shit to change... That. Is. Crazy." -Vass/Einstein

 

Nu77

avatar
Visconde
Visconde

INFOS

Grupo: ViscondeRegistrado: 29/11/07Posts: 496

Pois é, a galera parece que gosta de continuar ignorante... Para aprender a compilar as sources com uma ferramenta muito fácil e simples como o Dev-CPP, que tem todas as libs ja instalada, em veis de correr atras fica pedindo aos outros... Não vejo por que se humilhar tanto assim :\ o tempo que vocês perdem pedindo podia ter aprendido já, Mais fazer oque né...

Nocktal

Programador
avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 16/03/13Posts: 101Char no Tibia: Noocktall

Bota o executável e as dlls de um server svn ou tfs 8.54 ja que pocas sabem compilhar

akira021

Sky's Heart
avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 10/08/08Posts: 127

Banana esse opcode tbm serve pra 8.6? poderia dizer em qual versão das sources foi feito? vlw

flug.png

 

 

BananaFight

Allahu Akbar
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 14/02/13Posts: 702Gênero: Masculino

Esse código está aptado para a versão 0.3.6pl1 das source, foi a que testei, porem deve funcionar nas outras.

  • 1
  • 2