From 02c5e7b8fff7e1b0d94606ee4833147cc52547f0 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Tue, 1 May 2012 21:41:42 -0300 Subject: [PATCH] missing files * add questlog icon * add playertrade otui * some protocol changes for extended messages --- doc/luafunctions.rb | 3 ++ modules/game_playertrade/tradewindow.otui | 38 ++++++++++++++++++++++ modules/game_questlog/questlog.png | Bin 0 -> 1063 bytes src/framework/net/outputmessage.cpp | 19 +++++------ src/framework/net/outputmessage.h | 4 +-- src/otclient/net/protocolcodes.h | 4 ++- src/otclient/net/protocolgame.h | 2 ++ src/otclient/net/protocolgameparse.cpp | 17 ++++++++-- src/otclient/net/protocolgamesend.cpp | 9 +++++ src/otclient/net/protocollogin.cpp | 6 ++-- 10 files changed, 83 insertions(+), 19 deletions(-) create mode 100644 modules/game_playertrade/tradewindow.otui create mode 100644 modules/game_questlog/questlog.png 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 0000000000000000000000000000000000000000..0ad6ea4be47ac8558ead476e41031b2094c1724a GIT binary patch literal 1063 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zK-vS0-A-oPfdtD69Mgd`SU*F|v9*U87?|xmT^vI!PKQqN&X|)b(l-D7{xd3*Q_?1# zd}5TT=9$~&b!An+T1UqzN#ahT;!RPmTwF>W({~kJ?JY^1D5lsYx^kC>iFBrtX^Ef` z=hls#VXHE;mv}C7&YNsf{PX$$|L?8!CS}-u(7FG7k4zua4=wo%vYYwzL!YFq)QUSg zxn^h5G_#tMqP3d?_)->%c$~YQrWrKjzwM_-d$%u(vpcpl-`<6><44c5IqPGOE?m)& z?BMiaYXDz@vcaZjlK;=ol%Bd|`=98&uVrdKKS)-7`B%P^xgdva&I~Gu9&S};UcYS8*Ux+hs;(~RO_`FqSKI4qVsrM*h`g3t5=*2Mvs*53 zWUJnnp1sHHN$=cK&*kbkS3k&f%8dzpRjd1@o$Z~<4L1?dWW!op`^vP8M|b}5_q9(; ze!M_uit2fZE3e%G+#K=+Pc2)rYT=rPVGC=1w_l9kA1NcZqpt3qLd;K|^s|>s1CQJF zC@o~&a+8ORt%iBtJ&}s29W_tae@|;jp(w9KMAE-uvX|(yWLtP77Bp+_klGw!?$6m8WhTDKVOxTmSs$ zV|%-!S2)+W-(x-yx9OecyB9v@>!xe{o$6p6s{5l#J4eCg^T0O zZ^=5u;qh<8^0BEy}h#aCTSh~Lm?lhKwfMg~{RHf%65U|?{3!YcCD(wh&aGdDjaGp!O+=N1k_ldVRE+l;nc afa-M8W|dhtxzZM>lfl!~&t;ucLK6Tf@Z%%^ literal 0 HcmV?d00001 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; } }