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

Solved [7.72] TFS downgrade RSA

Koci

Member
Joined
Dec 18, 2009
Messages
784
Reaction score
18
Location
Scotland
Hello.
I want to downgrade latest tfs to 7.7 but I had some problems with RSA.
I added in otserv.cpp:
Code:
http://wklej.to/WlXcT/text
Protocol.cpp
Code:
http://wklej.to/MKZfI/text
protocolgame.cpp
Code:
http://wklej.to/0udYz/text
protocollogin.cpp
Code:
http://wklej.to/ifKKo/text
rsa.cpp
Code:
http://wklej.to/QqhrC/text
rsa.h
Code:
http://wklej.to/VVtcl/text
Server return when want to login but client debug:
Code:
Error: [OutputMessage::add_handler] m_outputufferStart<0> < 2
Those are not full files, only part with RSA.
I think that RSA is good beacuse I tested it changing some things in outputmessage:
remove add_handler and paste:
Code:
  void writeMessageLength()
  {
  *(uint16_t*)(m_MsgBuf + 2) = m_MsgSize;
  //added header size to the message size
  m_MsgSize = m_MsgSize + 2;
  m_outputBufferStart = 2;
  }
  void addCryptoHeader()
  {
  *(uint16_t*)(m_MsgBuf) = m_MsgSize;
  m_MsgSize = m_MsgSize + 2;
  m_outputBufferStart = 0;
  }

Code:
void writeMessageLength() {
       add_header((uint16_t)(m_MsgSize));
     }

     void addCryptoHeader() {
       add_header((uint16_t)(m_MsgSize));
     }

...
template <typename T>
     inline void add_header(T add) {
       if ((int32_t)m_outputBufferStart - (int32_t)sizeof(T) < 0) {
         std::cout << "Error: [OutputMessage::add_header] m_outputBufferStart(" << m_outputBufferStart <<
          ") < " << sizeof(T) << std::endl;
         return;
       }

       m_outputBufferStart = m_outputBufferStart - sizeof(T);
       *(T*)(m_MsgBuf + m_outputBufferStart) = add;
       //added header size to the message size
       m_MsgSize = m_MsgSize + sizeof(T);
     }
But after this and remove from protocolgame.cpp all :
Code:
writeToOutputBuffer(msg)
I can login to char list and char is loading ~minute and nothing. In console it shows that : player logged in.
I need Your help.
 
Solved :) Sorry my bad :( I was idiot and was compiling wrong sources :)
Fix:
outputmessage.h
Code:
/**
 * The Forgotten Server - a server application for the MMORPG Tibia
 * Copyright (C) 2013  Mark Samman <[email protected]>
 *
 * 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.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef __OTSERV_OUTPUT_MESSAGE_H__
#define __OTSERV_OUTPUT_MESSAGE_H__

#include "networkmessage.h"
#include "connection.h"
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include "tools.h"

#include <list>

#include <boost/utility.hpp>

class Protocol;

#define OUTPUT_POOL_SIZE 100

class OutputMessage : public NetworkMessage, boost::noncopyable
{
   private:
     OutputMessage();

   public:
     ~OutputMessage() {}

     char* getOutputBuffer() { return (char*)&m_MsgBuf[m_outputBufferStart]; }

     void writeMessageLength()
     {
       *(uint16_t*)(m_MsgBuf + 2) = m_MsgSize;
       //added header size to the message size
       m_MsgSize = m_MsgSize + 2;
       m_outputBufferStart = 2;
     }

     void addCryptoHeader()
     {
       *(uint16_t*)(m_MsgBuf) = m_MsgSize;
       m_MsgSize = m_MsgSize + 2;
       m_outputBufferStart = 0;
     }

     enum OutputMessageState {
       STATE_FREE,
       STATE_ALLOCATED,
       STATE_ALLOCATED_NO_AUTOSEND,
       STATE_WAITING
     };

     Protocol* getProtocol() {
       return m_protocol;
     }
     Connection_ptr getConnection() {
       return m_connection;
     }
     int64_t getFrame() const {
       return m_frame;
     }

     inline void append(const NetworkMessage& msg) {
       int32_t msgLen = msg.getMessageLength();
       memcpy(m_MsgBuf + m_ReadPos, msg.getBuffer() + 4, msgLen);
       m_MsgSize += msgLen;
       m_ReadPos += msgLen;
     }

     inline void append(OutputMessage_ptr msg) {
       int32_t msgLen = msg->getMessageLength();
       memcpy(m_MsgBuf + m_ReadPos, msg->getBuffer() + 4, msgLen);
       m_MsgSize += msgLen;
       m_ReadPos += msgLen;
     }

     void setFrame(int64_t frame) {
       m_frame = frame;
     }

   protected:

     void freeMessage() {
       setConnection(Connection_ptr());
       setProtocol(nullptr);
       m_frame = 0;
       //allocate enough size for headers
       //2 bytes for unencrypted message size
       //2 bytes for encrypted message size
       m_outputBufferStart = 4;

       //setState have to be the last one
       setState(OutputMessage::STATE_FREE);
     }

     friend class OutputMessagePool;

     void setProtocol(Protocol* protocol) {
       m_protocol = protocol;
     }
     void setConnection(Connection_ptr connection) {
       m_connection = connection;
     }

     void setState(OutputMessageState state) {
       m_state = state;
     }
     OutputMessageState getState() const {
       return m_state;
     }

     Protocol* m_protocol;
     Connection_ptr m_connection;

     uint32_t m_outputBufferStart;
     int64_t m_frame;

     OutputMessageState m_state;
};

typedef boost::shared_ptr<OutputMessage> OutputMessage_ptr;

class OutputMessagePool
{
   private:
     OutputMessagePool();

   public:
     ~OutputMessagePool();

     static OutputMessagePool* getInstance() {
       static OutputMessagePool instance;
       return &instance;
     }

#ifdef __ENABLE_SERVER_DIAGNOSTIC__
     static uint32_t OutputMessagePoolCount;
#endif

     void send(OutputMessage_ptr msg);
     void sendAll();
     void stop() {
       m_isOpen = false;
     }
     OutputMessage_ptr getOutputMessage(Protocol* protocol, bool autosend = true);
     void startExecutionFrame();

     int64_t getFrameTime() const {
       return m_frameTime;
     }

#ifdef __ENABLE_SERVER_DIAGNOSTIC__
     size_t getTotalMessageCount() const {
       return OutputMessagePoolCount;
     }
#else
     size_t getTotalMessageCount() const {
       return m_allOutputMessages.size();
     }
#endif
     size_t getAvailableMessageCount() const {
       return m_outputMessages.size();
     }
     size_t getAutoMessageCount() const {
       return m_autoSendOutputMessages.size();
     }
     void addToAutoSend(OutputMessage_ptr msg);

   protected:
     void configureOutputMessage(OutputMessage_ptr msg, Protocol* protocol, bool autosend);
     void releaseMessage(OutputMessage* msg);
     void internalReleaseMessage(OutputMessage* msg);

     typedef std::list<OutputMessage*> InternalOutputMessageList;
     typedef std::list<OutputMessage_ptr> OutputMessageMessageList;

     InternalOutputMessageList m_outputMessages;
     InternalOutputMessageList m_allOutputMessages;
     OutputMessageMessageList m_autoSendOutputMessages;
     OutputMessageMessageList m_toAddQueue;
     boost::recursive_mutex m_outputPoolLock;
     int64_t m_frameTime;
     bool m_isOpen;
};
#endif
 
I have a TFS 1.0 for 7.72 version, it's by far the best out there, unfortunately I downgraded a TFS revision were the code base had a bug with creature check and I'm really busy with college to update the code, so once I've free time I will downgrade a newer TFS 1.0 revision (before the party & player LUA update) to work with 7.72 and will release. Nothing promised though ~
 
@Ezzz Is OTHire one of your downgraded TFS 1.0 versions? =)

No it is not, OTHire is downgraded OTServ svn, I had a TFS 1.0 downgraded version public in Github but I removed it as it was a dropped project and still had plenty of things to be removed/done.
 
Hail @Ninja ;]]]]] polski

Ive asked him if he gonna finnish it.. already asked to many times... so ill keep on waiting for an response here i guess!
SkeletonMeme.jpg
plx
 
Back
Top Bottom