diff --git a/doc/luafunctions.rb b/doc/luafunctions.rb index ce7e4370..35d93683 100644 --- a/doc/luafunctions.rb +++ b/doc/luafunctions.rb @@ -1,3 +1,6 @@ +class UIWidget +end + class g_game def self.login() end def self.logout() end diff --git a/modules/game_playertrade/tradewindow.otui b/modules/game_playertrade/tradewindow.otui new file mode 100644 index 00000000..59664efe --- /dev/null +++ b/modules/game_playertrade/tradewindow.otui @@ -0,0 +1,38 @@ +TradeWindow < MiniWindow + !text: tr('Trade') + height: 150 + + UIItem + id: tradeItem + virtual: true + item-id: 3253 + size: 32 32 + anchors.top: parent.top + anchors.left: parent.left + margin-top: -6 + margin-left: -6 + + MiniWindowContents + padding: 6 + + FlatPanel + id: ownTradeContainer + anchors.fill: parent + anchors.right: parent.horizontalCenter + margin-right: 2 + layout: + type: grid + cell-size: 40 40 + flow: true + cell-spacing: 0 + + FlatPanel + id: counterTradeContainer + anchors.fill: parent + anchors.left: parent.horizontalCenter + margin-left: 2 + layout: + type: grid + cell-size: 40 40 + flow: true + cell-spacing: 0 \ No newline at end of file diff --git a/modules/game_questlog/questlog.png b/modules/game_questlog/questlog.png new file mode 100644 index 00000000..0ad6ea4b Binary files /dev/null and b/modules/game_questlog/questlog.png differ diff --git a/src/framework/net/outputmessage.cpp b/src/framework/net/outputmessage.cpp index d1e956c2..f9db6f30 100644 --- a/src/framework/net/outputmessage.cpp +++ b/src/framework/net/outputmessage.cpp @@ -65,21 +65,20 @@ void OutputMessage::addU64(uint64 value) m_messageSize += 8; } -void OutputMessage::addString(const char* value) +void OutputMessage::addString(const char* value, int length) { - size_t stringLength = strlen(value); - if(stringLength > 65535) + if(length > 65535) throw NetworkException("[OutputMessage::addString] string length > 65535"); - checkWrite(stringLength + 2); - addU16(stringLength); - strcpy((char*)(m_buffer + m_writePos), value); - m_writePos += stringLength; - m_messageSize += stringLength; + checkWrite(length + 2); + addU16(length); + memcpy((char*)(m_buffer + m_writePos), value, length); + m_writePos += length; + m_messageSize += length; } -void OutputMessage::addString(const std::string &value) +void OutputMessage::addString(const std::string& value) { - addString(value.c_str()); + addString(value.c_str(), value.length()); } void OutputMessage::addPaddingBytes(int bytes, uint8 byte) diff --git a/src/framework/net/outputmessage.h b/src/framework/net/outputmessage.h index bdc72309..94442b38 100644 --- a/src/framework/net/outputmessage.h +++ b/src/framework/net/outputmessage.h @@ -49,8 +49,8 @@ public: void addU16(uint16 value); void addU32(uint32 value); void addU64(uint64 value); - void addString(const char* value); - void addString(const std::string &value); + void addString(const char* value, int length); + void addString(const std::string& value); void addPaddingBytes(int bytes, uint8 byte = 0); uint8* getBuffer() { return m_buffer; } diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h index 089562b5..8a78e352 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/net/protocolcodes.h @@ -145,7 +145,8 @@ namespace Proto { GameServerQuestLine = 241, GameServerChannelEvent = 243, GameServerObjectInfo = 244, - GameServerPlayerInventory = 245 + GameServerPlayerInventory = 245, + GameServerExtendedOpcode = 254 // otclient only }; enum ClientOpts { @@ -221,6 +222,7 @@ namespace Proto { ClientRequestQuestLine = 241, //ClientRuleViolationReport = 242, //ClientGetObjectInfo = 243 + ClientExtendedOpcode = 254 // otclient only }; enum ServerSpeakType { diff --git a/src/otclient/net/protocolgame.h b/src/otclient/net/protocolgame.h index 7a6867e4..bfac3180 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/net/protocolgame.h @@ -103,6 +103,7 @@ public: void sendDebugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d); void sendRequestQuestLog(); void sendRequestQuestLine(int questId); + void sendExtendedOpcode(uint8 opcode, const std::string& buffer); private: void sendLoginPacket(uint timestamp, uint8 unknown); @@ -183,6 +184,7 @@ private: void parseAutomapFlag(InputMessage& msg); void parseQuestLog(InputMessage& msg); void parseQuestLine(InputMessage& msg); + void parseExtendedOpcode(InputMessage& msg); void setMapDescription(InputMessage& msg, int x, int y, int z, int width, int height); void setFloorDescription(InputMessage& msg, int x, int y, int z, int width, int height, int offset, int* skipTiles); diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index 53e57e45..cf51fe94 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -37,9 +37,9 @@ void ProtocolGame::parseMessage(InputMessage& msg) { try { while(!msg.eof()) { - int opt = msg.getU8(); + int opcode = msg.getU8(); - switch(opt) { + switch(opcode) { case Proto::GameServerInitGame: parseInitGame(msg); break; @@ -264,8 +264,11 @@ void ProtocolGame::parseMessage(InputMessage& msg) //case Proto::GameServerChannelEvent: //case Proto::GameServerObjectInfo: //case Proto::GameServerPlayerInventory: + case Proto::GameServerExtendedOpcode: // additional opcode used by otclient + parseExtendedOpcode(msg); + break; default: - Fw::throwException("unknown opt byte ", (int)opt); + Fw::throwException("unknown opcode ", opcode); break; } } @@ -1079,6 +1082,14 @@ void ProtocolGame::parseQuestLine(InputMessage& msg) g_game.processQuestLine(questId, questMissions); } +void ProtocolGame::parseExtendedOpcode(InputMessage& msg) +{ + int opcode = msg.getU8(); + std::string buffer = msg.getString(); + + callLuaField("onExtendedOpcode", opcode, buffer); +} + void ProtocolGame::setMapDescription(InputMessage& msg, int32 x, int32 y, int32 z, int32 width, int32 height) { int startz, endz, zstep, skip = 0; diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index e1f07a1e..2af4b5a8 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -649,6 +649,15 @@ void ProtocolGame::sendRequestQuestLine(int questId) send(msg); } +void ProtocolGame::sendExtendedOpcode(uint8 opcode, const std::string& buffer) +{ + OutputMessage msg; + msg.addU8(Proto::ClientExtendedOpcode); + msg.addU8(opcode); + msg.addString(buffer); + send(msg); +} + void ProtocolGame::addPosition(OutputMessage& msg, const Position& position) { msg.addU16(position.x); diff --git a/src/otclient/net/protocollogin.cpp b/src/otclient/net/protocollogin.cpp index 530569f6..bbee2161 100644 --- a/src/otclient/net/protocollogin.cpp +++ b/src/otclient/net/protocollogin.cpp @@ -55,8 +55,8 @@ void ProtocolLogin::onRecv(InputMessage& inputMessage) { try { while(!inputMessage.eof()) { - int opt = inputMessage.getU8(); - switch(opt) { + int opcode = inputMessage.getU8(); + switch(opcode) { case Proto::LoginServerError: parseError(inputMessage); break; @@ -70,7 +70,7 @@ void ProtocolLogin::onRecv(InputMessage& inputMessage) parseCharacterList(inputMessage); break; default: - Fw::throwException("unknown opt byte ", opt); + Fw::throwException("unknown opt byte ", opcode); break; } }