changes to wotk with protocol 860

This commit is contained in:
Eduardo Bart
2012-01-08 13:42:23 -02:00
parent d04596c5fd
commit fbaa7c8c43
17 changed files with 226 additions and 81 deletions

View File

@@ -4,14 +4,16 @@ IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
# otclient options
OPTION(FORBIDDEN_FUNCTIONS "Enable forbidden lua functions" ON)
OPTION(NO_BOT_PROTECTION "Disables bot protection" OFF)
SET(PROTOCOL 862 CACHE "Protocol version" STRING)
ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL})
IF(FORBIDDEN_FUNCTIONS)
ADD_DEFINITIONS(-DFORBIDDEN_FUNCTIONS)
MESSAGE(STATUS "Lua forbidden functions: ON")
ELSE(FORBIDDEN_FUNCTIONS)
MESSAGE(STATUS "Lua forbidden functions: OFF")
ENDIF(FORBIDDEN_FUNCTIONS)
IF(NO_BOT_PROTECTION)
ADD_DEFINITIONS(-DNO_BOT_PROTECTION)
MESSAGE(STATUS "Bot protection: OFF")
ELSE(NO_BOT_PROTECTION)
MESSAGE(STATUS "Bot protection: ON")
ENDIF(NO_BOT_PROTECTION)
SET(otclient_SOURCES ${otclient_SOURCES}
# otclient

View File

@@ -333,20 +333,30 @@ namespace Otc
};
enum SpeakClasses {
SpeakSay = 0x01, //normal talk
SpeakWhisper = 0x02, //whispering - #w text
SpeakYell = 0x03, //yelling - #y text
SpeakPrivatePlayerToNpc = 0x04, //Player-to-NPC speaking(NPCs channel)
SpeakPrivateNpcToPlayer = 0x05, //NPC-to-Player speaking
SpeakPrivate = 0x06, //Players speaking privately to players
SpeakChannelYellow = 0x07, //Yellow message in chat
SpeakChannelWhite = 0x08, //White message in chat
SpeakBroadcast = 0x09, //Broadcast a message - #b
SpeakChannelRed = 0x0A, //Talk red on chat - #c
SpeakPrivateRed = 0x0B, //Red private - @name@ text
SpeakChannelOrange = 0x0C, //Talk orange on text
SpeakMonsterSay = 0x0D, //Talk orange
SpeakMonsterYell = 0x0E //Yell orange
SpeakSay = 1, //normal talk
SpeakWhisper, //whispering - #w text
SpeakYell, //yelling - #y text
SpeakPrivatePlayerToNpc, //Player-to-NPC speaking(NPCs channel)
SpeakPrivateNpcToPlayer, //NPC-to-Player speaking
SpeakPrivate, //Players speaking privately to players
SpeakChannelYellow, //Yellow message in chat
SpeakChannelWhite, //White message in chat
#if PROTOCOL==860
SpeakReportChannel, //Reporting rule violation - Ctrl+R
SpeakReportAnswer, //Answering report
SpeakReportContinue, //Answering the answer of the report
#endif
SpeakBroadcast, //Broadcast a message - #b
SpeakChannelRed, //Talk red on chat - #c
SpeakPrivateRed, //Red private - @name@ text
SpeakChannelOrange, //Talk orange on text
#if PROTOCOL==860
SpeakUnk1,
SpeakChannelRed2, //Talk red anonymously on chat - #d
SpeakUnk2,
#endif
SpeakMonsterSay, //Talk orange
SpeakMonsterYell //Yell orange
};
enum CreaturesIdRange {

View File

@@ -322,7 +322,7 @@ void Game::removeVip(int playerId)
bool Game::checkBotProtection()
{
#ifndef DISABLE_BOT_PROTECTION
#ifndef NO_BOT_PROTECTION
if(g_lua.isInCppCallback() && !g_ui.isOnInputEvent()) {
logError("caught a lua call to a bot protected game function, the call was canceled");
return false;

View File

@@ -78,6 +78,7 @@ public:
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
int getProtocolVersion() { return PROTOCOL; }
private:
LocalPlayerPtr m_localPlayer;

View File

@@ -286,10 +286,10 @@ ThingPtr Map::getThing(const Position& pos, int stackPos)
return nullptr;
}
void Map::removeThing(const Position& pos, int stackPos)
void Map::removeThingByPos(const Position& pos, int stackPos)
{
if(TilePtr& tile = m_tiles[pos])
tile->removeThing(stackPos);
tile->removeThingByStackpos(stackPos);
}
void Map::removeThing(const ThingPtr& thing)

View File

@@ -53,7 +53,7 @@ public:
void addThing(const ThingPtr& thing, const Position& pos, int stackPos = -1);
ThingPtr getThing(const Position& pos, int stackPos);
void removeThing(const Position& pos, int stackPos);
void removeThingByPos(const Position& pos, int stackPos);
void removeThing(const ThingPtr& thing);
void cleanTile(const Position& pos);
TilePtr getTile(const Position& pos);

View File

@@ -107,7 +107,7 @@ void StaticText::compose()
m_color = Color(95, 247, 247);
}
else {
logWarning("unknown message type: ", m_type);
logWarning("unknown speak type: ", m_type);
}
// Todo: add break lines

View File

@@ -149,7 +149,7 @@ ThingPtr Tile::getTopThing()
return m_things[m_things.size() - 1];
}
ThingPtr Tile::removeThing(int stackPos)
ThingPtr Tile::removeThingByStackpos(int stackPos)
{
ThingPtr oldObject;
if(stackPos >= 0 && stackPos < (int)m_things.size()) {

View File

@@ -41,7 +41,7 @@ public:
ThingPtr getThing(int stackPos);
int getThingStackpos(const ThingPtr& thing);
ThingPtr getTopThing();
ThingPtr removeThing(int stackPos);
ThingPtr removeThingByStackpos(int stackPos);
ThingPtr removeThing(const ThingPtr& thing);

View File

@@ -26,6 +26,10 @@
#include <otclient/core/game.h>
#include <otclient/core/tile.h>
#include <otclient/core/item.h>
#include <otclient/core/effect.h>
#include <otclient/core/missile.h>
#include <otclient/core/statictext.h>
#include <otclient/core/animatedtext.h>
#include <otclient/core/creature.h>
#include <otclient/core/player.h>
#include <otclient/core/localplayer.h>
@@ -54,6 +58,27 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_sprites", "isLoaded", std::bind(&SpriteManager::isLoaded, &g_sprites));
g_lua.bindClassStaticFunction("g_sprites", "getSignature", std::bind(&SpriteManager::getSignature, &g_sprites));
g_lua.registerStaticClass("g_map");
g_lua.bindClassStaticFunction("g_map", "getFirstVisibleFloor", std::bind(&Map::getFirstVisibleFloor, &g_map));
g_lua.bindClassStaticFunction("g_map", "isLookPossible", std::bind(&Map::isLookPossible, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "isCovered", std::bind(&Map::isCovered, &g_map, _1, _2));
g_lua.bindClassStaticFunction("g_map", "isCompletlyCovered", std::bind(&Map::isCompletlyCovered, &g_map, _1, _2));
g_lua.bindClassStaticFunction("g_map", "addThing", std::bind(&Map::addThing, &g_map, _1, _2, _3));
g_lua.bindClassStaticFunction("g_map", "getThing", std::bind(&Map::getThing, &g_map, _1, _2));
g_lua.bindClassStaticFunction("g_map", "removeThingByPos", std::bind(&Map::removeThingByPos, &g_map, _1, _2));
g_lua.bindClassStaticFunction("g_map", "removeThing", std::bind(&Map::removeThing, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "cleanTile", std::bind(&Map::cleanTile, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "getTile", std::bind(&Map::getTile, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "setCentralPosition", std::bind(&Map::setCentralPosition, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "getCentralPosition", std::bind(&Map::getCentralPosition, &g_map));
g_lua.bindClassStaticFunction("g_map", "addCreature", std::bind(&Map::addCreature, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "getCreatureById", std::bind(&Map::getCreatureById, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "removeCreatureById", std::bind(&Map::removeCreatureById, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "setVisibleSize", std::bind(&Map::setVisibleSize, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "getVibibleSize", std::bind(&Map::getVibibleSize, &g_map));
g_lua.bindClassStaticFunction("g_map", "getCentralOffset", std::bind(&Map::getCentralOffset, &g_map));
g_lua.bindClassStaticFunction("g_map", "positionTo2D", std::bind(&Map::positionTo2D, &g_map, _1));
g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor);
g_lua.registerClass<ProtocolLogin, Protocol>();
@@ -64,16 +89,36 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<ProtocolGame, Protocol>();
g_lua.registerClass<Thing>();
g_lua.bindClassMemberFunction<Thing>("setId", &Thing::setId);
g_lua.bindClassMemberFunction<Thing>("setPos", &Thing::setPos);
g_lua.bindClassMemberFunction<Thing>("getId", &Thing::getId);
g_lua.bindClassMemberFunction<Thing>("getType", &Thing::getType);
g_lua.bindClassMemberFunction<Thing>("getPos", &Thing::getPos);
g_lua.bindClassMemberFunction<Thing>("getStackPriority", &Thing::getStackPriority);
g_lua.bindClassMemberFunction<Thing>("getAnimationPhases", &Thing::getAnimationPhases);
g_lua.bindClassMemberFunction<Thing>("setXPattern", &Thing::setXPattern);
g_lua.bindClassMemberFunction<Thing>("setYPattern", &Thing::setYPattern);
g_lua.bindClassMemberFunction<Thing>("setZPattern", &Thing::setZPattern);
g_lua.bindClassMemberFunction<Thing>("asThing", &Thing::asThing);
g_lua.bindClassMemberFunction<Thing>("asItem", &Thing::asItem);
g_lua.bindClassMemberFunction<Thing>("asCreature", &Thing::asCreature);
g_lua.bindClassMemberFunction<Thing>("asEffect", &Thing::asEffect);
g_lua.bindClassMemberFunction<Thing>("asMissile", &Thing::asMissile);
g_lua.bindClassMemberFunction<Thing>("asPlayer", &Thing::asPlayer);
g_lua.bindClassMemberFunction<Thing>("asLocalPlayer", &Thing::asLocalPlayer);
g_lua.bindClassMemberFunction<Thing>("asAnimatedText", &Thing::asAnimatedText);
g_lua.bindClassMemberFunction<Thing>("asStaticText", &Thing::asStaticText);
g_lua.bindClassMemberFunction<Thing>("isGround", &Thing::isGround);
g_lua.bindClassMemberFunction<Thing>("isGroundBorder", &Thing::isGroundBorder);
g_lua.bindClassMemberFunction<Thing>("isOnBottom", &Thing::isOnBottom);
g_lua.bindClassMemberFunction<Thing>("isOnTop", &Thing::isOnTop);
g_lua.bindClassMemberFunction<Thing>("isContainer", &Thing::isContainer);
g_lua.bindClassMemberFunction<Thing>("isForceUse", &Thing::isForceUse);
g_lua.bindClassMemberFunction<Thing>("isMultiUse", &Thing::isMultiUse);
g_lua.bindClassMemberFunction<Thing>("isRotateable", &Thing::isRotateable);
g_lua.bindClassMemberFunction<Thing>("isNotMoveable", &Thing::isNotMoveable);
g_lua.bindClassMemberFunction<Thing>("isPickupable", &Thing::isPickupable);
g_lua.bindClassMemberFunction<Thing>("asCreature", &Thing::asCreature);
g_lua.bindClassMemberFunction<Thing>("asPlayer", &Thing::asPlayer);
g_lua.bindClassMemberFunction<Thing>("asLocalPlayer", &Thing::asLocalPlayer);
g_lua.bindClassMemberFunction<Thing>("ignoreLook", &Thing::ignoreLook);
g_lua.bindClassMemberFunction<Thing>("isStackable", &Thing::isStackable);
g_lua.registerClass<Creature, Thing>();
g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName);
@@ -85,12 +130,40 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<Player, Creature>();
g_lua.registerClass<Effect, Thing>();
g_lua.registerClass<Missile, Thing>();
g_lua.registerClass<StaticText, Thing>();
g_lua.registerClass<AnimatedText, Thing>();
g_lua.registerClass<LocalPlayer, Player>();
g_lua.bindClassMemberFunction<LocalPlayer>("getAttackingCreature", &LocalPlayer::getAttackingCreature);
g_lua.bindClassMemberFunction<LocalPlayer>("getFollowingCreature", &LocalPlayer::getFollowingCreature);
g_lua.registerClass<Item, Thing>();
g_lua.registerClass<Tile>();
g_lua.bindClassMemberFunction<Tile>("clean", &Tile::clean);
g_lua.bindClassMemberFunction<Tile>("addThing", &Tile::addThing);
g_lua.bindClassMemberFunction<Tile>("getThing", &Tile::getThing);
g_lua.bindClassMemberFunction<Tile>("getThingStackpos", &Tile::getThingStackpos);
g_lua.bindClassMemberFunction<Tile>("getTopThing", &Tile::getTopThing);
g_lua.bindClassMemberFunction<Tile>("removeThingByStackpos", &Tile::removeThingByStackpos);
g_lua.bindClassMemberFunction<Tile>("removeThing", &Tile::removeThing);
g_lua.bindClassMemberFunction<Tile>("getTopLookThing", &Tile::getTopLookThing);
g_lua.bindClassMemberFunction<Tile>("getTopUseThing", &Tile::getTopUseThing);
g_lua.bindClassMemberFunction<Tile>("getTopCreature", &Tile::getTopCreature);
g_lua.bindClassMemberFunction<Tile>("getPos", &Tile::getPos);
g_lua.bindClassMemberFunction<Tile>("getDrawElevation", &Tile::getDrawElevation);
g_lua.bindClassMemberFunction<Tile>("getCreatures", &Tile::getCreatures);
g_lua.bindClassMemberFunction<Tile>("getGround", &Tile::getGround);
g_lua.bindClassMemberFunction<Tile>("isWalkable", &Tile::isWalkable);
g_lua.bindClassMemberFunction<Tile>("isFullGround", &Tile::isFullGround);
g_lua.bindClassMemberFunction<Tile>("isFullyOpaque", &Tile::isFullyOpaque);
g_lua.bindClassMemberFunction<Tile>("isLookPossible", &Tile::isLookPossible);
g_lua.bindClassMemberFunction<Tile>("hasCreature", &Tile::hasCreature);
g_lua.bindClassMemberFunction<Tile>("isEmpty", &Tile::isEmpty);
g_lua.bindClassMemberFunction<Tile>("isClickable", &Tile::isClickable);
g_lua.registerClass<Map>();
g_lua.registerClass<Game>();
@@ -114,6 +187,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("talkChannel", std::bind(&Game::talkChannel, &g_game, _1, _2, _3));
g_lua.bindClassStaticFunction<Game>("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3));
g_lua.bindClassStaticFunction<Game>("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game));
g_lua.bindClassStaticFunction<Game>("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game));
g_lua.registerClass<UIItem, UIWidget>();
g_lua.bindClassStaticFunction<UIItem>("create", []{ return UIItemPtr(new UIItem); } );

View File

@@ -80,6 +80,7 @@ bool luavalue_cast(int index, Position& pos)
pos.y = g_lua.popInteger();
g_lua.getField("z", index);
pos.z = g_lua.popInteger();
return true;
}
return false;
}

View File

@@ -353,8 +353,6 @@ void ProtocolGame::parseMoveWest(InputMessage& msg)
void ProtocolGame::parseUpdateTile(InputMessage& msg)
{
logDebug("PARSE UPDATE TILE!");
Position tilePos = parsePosition(msg);
uint16 thingId = msg.getU16(true);
if(thingId == 0xFF01) {
@@ -390,7 +388,7 @@ void ProtocolGame::parseTileTransformThing(InputMessage& msg)
}
else {
ThingPtr thing = internalGetItem(msg, thingId);
g_map.removeThing(pos, stackPos);
g_map.removeThingByPos(pos, stackPos);
g_map.addThing(thing, pos, stackPos);
}
}
@@ -400,7 +398,7 @@ void ProtocolGame::parseTileRemoveThing(InputMessage& msg)
Position pos = parsePosition(msg);
uint8 stackPos = msg.getU8();
g_map.removeThing(pos, stackPos);
g_map.removeThingByPos(pos, stackPos);
}
void ProtocolGame::parseCreatureMove(InputMessage& msg)
@@ -756,10 +754,13 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
case Otc::SpeakPrivateNpcToPlayer:
creaturePos = parsePosition(msg);
break;
case Otc::SpeakChannelRed:
case Otc::SpeakChannelOrange:
case Otc::SpeakChannelYellow:
case Otc::SpeakChannelWhite:
case Otc::SpeakChannelRed:
#if PROTOCOL==860
case Otc::SpeakChannelRed2:
#endif
case Otc::SpeakChannelOrange:
channelId = msg.getU16();
break;
case Otc::SpeakPrivate:
@@ -767,6 +768,11 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
case Otc::SpeakBroadcast:
case Otc::SpeakPrivateRed:
break;
#if PROTOCOL==860
case Otc::SpeakReportChannel:
msg.getU32();
break;
#endif
default:
logTraceError("unknown speak type ", type);
break;