mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
now is walking
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <script/luainterface.h>
|
||||
#include <net/connection.h>
|
||||
#include <../game.h>
|
||||
#include <../item.h>
|
||||
|
||||
Engine g_engine;
|
||||
|
||||
@@ -97,7 +98,15 @@ void Engine::run()
|
||||
defaultFont->renderText(fpsText, Point(g_graphics.getScreenSize().width() - fpsTextSize.width() - 10, 10));
|
||||
|
||||
// todo remove. render map
|
||||
g_game.getMap()->draw(0, 0, g_graphics.getScreenSize().width(), g_graphics.getScreenSize().height());
|
||||
g_game.getMap()->draw(0, 0);
|
||||
|
||||
// todo remove. view items
|
||||
static Item *item = NULL;
|
||||
if(!item) {
|
||||
item = new Item();
|
||||
item->setId(8377);
|
||||
}
|
||||
//item->draw(1, 1, 7);
|
||||
|
||||
g_graphics.endRender();
|
||||
|
||||
@@ -129,4 +138,18 @@ void Engine::onResize(const Size& size)
|
||||
void Engine::onInputEvent(const InputEvent& event)
|
||||
{
|
||||
UIContainer::getRoot()->onInputEvent(event);
|
||||
|
||||
ProtocolGame *protocol = g_game.getProtocol();
|
||||
if(protocol) {
|
||||
if(event.type == EV_KEY_DOWN) {
|
||||
if(event.keycode == KC_UP)
|
||||
protocol->sendWalkNorth();
|
||||
if(event.keycode == KC_RIGHT)
|
||||
protocol->sendWalkEast();
|
||||
if(event.keycode == KC_DOWN)
|
||||
protocol->sendWalkSouth();
|
||||
if(event.keycode == KC_LEFT)
|
||||
protocol->sendWalkWest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ public:
|
||||
|
||||
uint8* getBuffer() { return m_buffer; }
|
||||
uint16 getMessageSize() { return m_messageSize; }
|
||||
void setMessageSize(uint16 messageSize) { m_messageSize = messageSize; }
|
||||
void setWritePos(uint16 writePos) { m_writePos = writePos; }
|
||||
|
||||
private:
|
||||
|
@@ -125,6 +125,13 @@ void Protocol::xteaEncrypt(OutputMessage& outputMessage)
|
||||
{
|
||||
uint16 messageLength = outputMessage.getMessageSize();
|
||||
|
||||
memmove(outputMessage.getBuffer() + OutputMessage::DATA_POS + 2, outputMessage.getBuffer() + OutputMessage::DATA_POS, messageLength);
|
||||
*(uint16*)(outputMessage.getBuffer() + OutputMessage::DATA_POS) = messageLength;
|
||||
|
||||
messageLength += 2;
|
||||
outputMessage.setMessageSize(messageLength);
|
||||
outputMessage.setWritePos(messageLength + OutputMessage::DATA_POS);
|
||||
|
||||
//add bytes until reach 8 multiple
|
||||
if((messageLength % 8) != 0) {
|
||||
uint16 n = 8 - (messageLength % 8);
|
||||
@@ -133,7 +140,7 @@ void Protocol::xteaEncrypt(OutputMessage& outputMessage)
|
||||
}
|
||||
|
||||
int readPos = 0;
|
||||
uint32 *buffer = (uint32*)outputMessage.getBuffer() + OutputMessage::DATA_POS;
|
||||
uint32 *buffer = (uint32*)(outputMessage.getBuffer() + OutputMessage::DATA_POS);
|
||||
while(readPos < messageLength / 4) {
|
||||
uint32 v0 = buffer[readPos], v1 = buffer[readPos + 1];
|
||||
uint32 delta = 0x61C88647;
|
||||
|
Reference in New Issue
Block a user