Skip to content

Instantly share code, notes, and snippets.

@dbjorkholm
Created October 10, 2015 10:29
Show Gist options
  • Save dbjorkholm/53d1b402e710a83eacb1 to your computer and use it in GitHub Desktop.
Save dbjorkholm/53d1b402e710a83eacb1 to your computer and use it in GitHub Desktop.
1041 downgrade
From 01be417776d2ab41036a12fac49da0fb5a68b85f Mon Oct 10 00:00:00 2001
From: Daniel Björkholm <danielbjorkholm@gmail.com>
Date: Sat, 10 Oct 2015 12:25:24 +0200
Subject: [PATCH] 1041 downgrade
---
const.h | 39 +++++++++++++++------------------------
definitions.h | 6 +++---
itemloader.h | 1 -
items.cpp | 2 +-
luascript.cpp | 8 +-------
protocol.cpp | 4 ++--
protocolgame.cpp | 35 ++++++++++-------------------------
protocollogin.cpp | 19 ++++++++-----------
protocollogin.h | 6 +++---
tools.cpp | 8 +-------
10 files changed, 44 insertions(+), 84 deletions(-)
diff --git a/const.h b/const.h
index 53692af..2d9c30d 100644
--- a/const.h
+++ b/const.h
@@ -103,11 +103,6 @@ enum MagicEffectClasses : uint8_t {
CONST_ME_CONFETTI_VERTICAL = 76,
// 77-157 are empty
CONST_ME_BLACKSMOKE = 158,
- // 159-166 are empty
- CONST_ME_REDSMOKE = 167,
- CONST_ME_YELLOWSMOKE = 168,
- CONST_ME_GREENSMOKE = 169,
- CONST_ME_PURPLESMOKE = 170,
};
enum ShootType_t : uint8_t {
@@ -164,9 +159,6 @@ enum ShootType_t : uint8_t {
CONST_ANI_DRILLBOLT = 50,
CONST_ANI_ENVENOMEDARROW = 51,
- CONST_ANI_GLOOTHSPEAR = 53,
- CONST_ANI_SIMPLEARROW = 54,
-
// for internal use, don't send to client
CONST_ANI_WEAPONTYPE = 0xFE, // 254
};
@@ -185,8 +177,8 @@ enum SpeakClasses : uint8_t {
TALKTYPE_CHANNEL_R1 = 14, //red - #c text
TALKTYPE_PRIVATE_RED_FROM = 15, //@name@text
TALKTYPE_PRIVATE_RED_TO = 16, //@name@text
- TALKTYPE_MONSTER_SAY = 36,
- TALKTYPE_MONSTER_YELL = 37,
+ TALKTYPE_MONSTER_SAY = 35,
+ TALKTYPE_MONSTER_YELL = 36,
TALKTYPE_CHANNEL_R2 = 0xFF, //#d
};
@@ -200,20 +192,19 @@ enum MessageClasses : uint8_t {
MESSAGE_STATUS_WARNING = 18, /*Red message in game window and in the console*/
MESSAGE_EVENT_ADVANCE = 19, /*White message in game window and in the console*/
- MESSAGE_STATUS_SMALL = 21, /*White message at the bottom of the game window"*/
- MESSAGE_INFO_DESCR = 22, /*Green message in game window and in the console*/
- MESSAGE_DAMAGE_DEALT = 23,
- MESSAGE_DAMAGE_RECEIVED = 24,
- MESSAGE_HEALED = 25,
- MESSAGE_EXPERIENCE = 26,
- MESSAGE_DAMAGE_OTHERS = 27,
- MESSAGE_HEALED_OTHERS = 28,
- MESSAGE_EXPERIENCE_OTHERS = 29,
- MESSAGE_EVENT_DEFAULT = 30, /*White message at the bottom of the game window and in the console*/
- MESSAGE_LOOT = 31,
-
- MESSAGE_EVENT_ORANGE = 36, /*Orange message in the console*/
- MESSAGE_STATUS_CONSOLE_ORANGE = 37, /*Orange message in the console*/
+ MESSAGE_STATUS_SMALL = 20, /*White message at the bottom of the game window"*/
+ MESSAGE_INFO_DESCR = 21, /*Green message in game window and in the console*/
+ MESSAGE_DAMAGE_DEALT = 22,
+ MESSAGE_DAMAGE_RECEIVED = 23,
+ MESSAGE_HEALED = 24,
+ MESSAGE_EXPERIENCE = 25,
+ MESSAGE_DAMAGE_OTHERS = 26,
+ MESSAGE_HEALED_OTHERS = 27,
+ MESSAGE_EXPERIENCE_OTHERS = 28,
+ MESSAGE_EVENT_DEFAULT = 29, /*White message at the bottom of the game window and in the console*/
+
+ MESSAGE_EVENT_ORANGE = 35, /*Orange message in the console*/
+ MESSAGE_STATUS_CONSOLE_ORANGE = 36, /*Orange message in the console*/
};
enum FluidColors_t : uint8_t {
diff --git a/definitions.h b/definitions.h
index 7de54c6..54d17ad 100644
--- a/definitions.h
+++ b/definitions.h
@@ -24,9 +24,9 @@
#define STATUS_SERVER_VERSION "1.2"
#define STATUS_SERVER_DEVELOPERS "Mark Samman"
-#define CLIENT_VERSION_MIN 1076
-#define CLIENT_VERSION_MAX 1077
-#define CLIENT_VERSION_STR "10.77"
+#define CLIENT_VERSION_MIN 1038
+#define CLIENT_VERSION_MAX 1041
+#define CLIENT_VERSION_STR "10.41"
#ifndef __FUNCTION__
#define __FUNCTION__ __func__
diff --git a/itemloader.h b/itemloader.h
index 3d01456..237b90d 100644
--- a/itemloader.h
+++ b/itemloader.h
@@ -101,7 +101,6 @@ enum clientVersion_t {
CLIENT_VERSION_1030 = 53,
CLIENT_VERSION_1031 = 54,
CLIENT_VERSION_1035 = 55,
- CLIENT_VERSION_1076 = 56,
};
enum rootattrib_ {
diff --git a/items.cpp b/items.cpp
index 52c84f3..84ddfad 100644
--- a/items.cpp
+++ b/items.cpp
@@ -192,7 +192,7 @@ FILELOADER_ERRORS Items::loadFromOtb(const std::string& file)
} else if (Items::dwMajorVersion != 3) {
std::cout << "Old version detected, a newer version of items.otb is required." << std::endl;
return ERROR_INVALID_FORMAT;
- } else if (Items::dwMinorVersion < CLIENT_VERSION_1076) {
+ } else if (Items::dwMinorVersion < CLIENT_VERSION_1035) {
std::cout << "A newer version of items.otb is required." << std::endl;
return ERROR_INVALID_FORMAT;
}
diff --git a/luascript.cpp b/luascript.cpp
index 9c84d8a..0a70c40 100644
--- a/luascript.cpp
+++ b/luascript.cpp
@@ -1253,10 +1253,6 @@ void LuaScriptInterface::registerFunctions()
registerEnum(CONST_ME_CONFETTI_HORIZONTAL)
registerEnum(CONST_ME_CONFETTI_VERTICAL)
registerEnum(CONST_ME_BLACKSMOKE)
- registerEnum(CONST_ME_REDSMOKE)
- registerEnum(CONST_ME_YELLOWSMOKE)
- registerEnum(CONST_ME_GREENSMOKE)
- registerEnum(CONST_ME_PURPLESMOKE)
registerEnum(CONST_ANI_NONE)
registerEnum(CONST_ANI_SPEAR)
@@ -1307,8 +1303,6 @@ void LuaScriptInterface::registerFunctions()
registerEnum(CONST_ANI_CRYSTALLINEARROW)
registerEnum(CONST_ANI_DRILLBOLT)
registerEnum(CONST_ANI_ENVENOMEDARROW)
- registerEnum(CONST_ANI_GLOOTHSPEAR)
- registerEnum(CONST_ANI_SIMPLEARROW)
registerEnum(CONST_ANI_WEAPONTYPE)
registerEnum(CONST_PROP_BLOCKSOLID)
@@ -12252,4 +12246,4 @@ void LuaEnvironment::executeTimerEvent(uint32_t eventIndex)
for (auto parameter : timerEventDesc.parameters) {
luaL_unref(m_luaState, LUA_REGISTRYINDEX, parameter);
}
-}
\ No newline at end of file
+}
diff --git a/protocol.cpp b/protocol.cpp
index ea06ee9..a180fa7 100644
--- a/protocol.cpp
+++ b/protocol.cpp
@@ -135,7 +135,7 @@ bool Protocol::XTEA_decrypt(NetworkMessage& msg) const
bool Protocol::RSA_decrypt(NetworkMessage& msg)
{
- if ((msg.getLength() - msg.getBufferPosition()) < 128) {
+ if ((msg.getLength() - msg.getBufferPosition()) != 128) {
return false;
}
@@ -150,4 +150,4 @@ uint32_t Protocol::getIP() const
}
return 0;
-}
\ No newline at end of file
+}
diff --git a/protocolgame.cpp b/protocolgame.cpp
index b77f632..fcbc17d 100644
--- a/protocolgame.cpp
+++ b/protocolgame.cpp
@@ -257,7 +257,7 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
OperatingSystem_t operatingSystem = static_cast<OperatingSystem_t>(msg.get<uint16_t>());
version = msg.get<uint16_t>();
- msg.skipBytes(7); // U32 client version, U8 client type, U16 dat revision
+ msg.skipBytes(5); // U32 client version, U8 client type, U16 dat revision
if (!Protocol::RSA_decrypt(msg)) {
disconnect();
@@ -282,22 +282,9 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
msg.skipBytes(1); // gamemaster flag
- std::string sessionKey = msg.getString();
- size_t pos = sessionKey.find('\n');
- if (pos == std::string::npos) {
- disconnectClient("You must enter your account name.");
- return;
- }
-
- std::string accountName = sessionKey.substr(0, pos);
- if (accountName.empty()) {
- disconnectClient("You must enter your account name.");
- return;
- }
-
- std::string password = sessionKey.substr(pos + 1);
-
+ std::string accountName = msg.getString();
std::string characterName = msg.getString();
+ std::string password = msg.getString();
uint32_t timeStamp = msg.get<uint32_t>();
uint8_t randNumber = msg.getByte();
@@ -311,6 +298,11 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
return;
}
+ if (accountName.empty()) {
+ disconnectClient("You must enter your account name.");
+ return;
+ }
+
if (g_game.getGameState() == GAME_STATE_STARTUP) {
disconnectClient("Gameworld is starting up. Please wait.");
return;
@@ -1248,9 +1240,8 @@ void ProtocolGame::sendCreatureSquare(const Creature* creature, SquareColor_t co
}
NetworkMessage msg;
- msg.addByte(0x93);
+ msg.addByte(0x86);
msg.add<uint32_t>(creature->getID());
- msg.addByte(0x01);
msg.addByte(color);
writeToOutputBuffer(msg);
}
@@ -1277,7 +1268,6 @@ void ProtocolGame::sendReLoginWindow(uint8_t unfairFightReduction)
{
NetworkMessage msg;
msg.addByte(0x28);
- msg.addByte(0x00);
msg.addByte(unfairFightReduction);
writeToOutputBuffer(msg);
}
@@ -2169,7 +2159,6 @@ void ProtocolGame::sendChangeSpeed(const Creature* creature, uint32_t speed)
NetworkMessage msg;
msg.addByte(0x8F);
msg.add<uint32_t>(creature->getID());
- msg.add<uint16_t>(creature->getBaseSpeed() / 2);
msg.add<uint16_t>(speed / 2);
writeToOutputBuffer(msg);
}
@@ -2387,9 +2376,6 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos
msg.addByte(0x00);
}
- msg.addByte(0x00); // can change pvp framing option
- msg.addByte(0x00); // expert mode button enabled
-
writeToOutputBuffer(msg);
sendPendingStateEntered();
@@ -2843,7 +2829,6 @@ void ProtocolGame::AddPlayerStats(NetworkMessage& msg)
msg.add<uint16_t>(player->getLevel());
msg.addByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
- msg.addDouble(0, 3); // experience bonus
msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(std::min<int32_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA), std::numeric_limits<uint16_t>::max()));
@@ -3034,4 +3019,4 @@ void ProtocolGame::parseExtendedOpcode(NetworkMessage& msg)
// process additional opcodes via lua script event
addGameTask(&Game::parsePlayerExtendedOpcode, player->getID(), opcode, buffer);
-}
\ No newline at end of file
+}
diff --git a/protocollogin.cpp b/protocollogin.cpp
index eb54258..ee1852a 100644
--- a/protocollogin.cpp
+++ b/protocollogin.cpp
@@ -33,22 +33,22 @@
extern ConfigManager g_config;
extern Game g_game;
-void ProtocolLogin::disconnectClient(const std::string& message, uint16_t version)
+void ProtocolLogin::disconnectClient(const std::string& message)
{
auto output = OutputMessagePool::getOutputMessage();
- output->addByte(version >= 1076 ? 0x0B : 0x0A);
+ output->addByte(0x0A);
output->addString(message);
send(output);
disconnect();
}
-void ProtocolLogin::getCharacterList(const std::string& accountName, const std::string& password, uint16_t version)
+void ProtocolLogin::getCharacterList(const std::string& accountName, const std::string& password)
{
Account account;
if (!IOLoginData::loginserverAuthentication(accountName, password, account)) {
- disconnectClient("Account name or password is not correct.", version);
+ disconnectClient("Account name or password is not correct.");
return;
}
@@ -66,10 +66,6 @@ void ProtocolLogin::getCharacterList(const std::string& accountName, const std::
output->addString(ss.str());
}
- //Add session key
- output->addByte(0x28);
- output->addString(accountName + "\n" + password);
-
//Add char list
output->addByte(0x64);
@@ -140,6 +136,9 @@ void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg)
enableXTEAEncryption();
setXTEAKey(key);
+ std::string accountName = msg.getString();
+ std::string password = msg.getString();
+
if (version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX) {
disconnectClient("Only clients with protocol " CLIENT_VERSION_STR " allowed!", version);
return;
@@ -172,13 +171,11 @@ void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg)
return;
}
- std::string accountName = msg.getString();
if (accountName.empty()) {
disconnectClient("Invalid account name.", version);
return;
}
- std::string password = msg.getString();
auto thisPtr = std::dynamic_pointer_cast<ProtocolLogin>(shared_from_this());
g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCharacterList, thisPtr, accountName, password, version)));
-}
\ No newline at end of file
+}
diff --git a/protocollogin.h b/protocollogin.h
index 16c6e17..1953356 100644
--- a/protocollogin.h
+++ b/protocollogin.h
@@ -41,9 +41,9 @@ class ProtocolLogin : public Protocol
void onRecvFirstMessage(NetworkMessage& msg);
protected:
- void disconnectClient(const std::string& message, uint16_t version);
+ void disconnectClient(const std::string& message);
- void getCharacterList(const std::string& accountName, const std::string& password, uint16_t version);
+ void getCharacterList(const std::string& accountName, const std::string& password);
};
-#endif
\ No newline at end of file
+#endif
diff --git a/tools.cpp b/tools.cpp
index 70073b1..30f8532 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -556,10 +556,6 @@ MagicEffectNames magicEffectNames[] = {
{"confettihorizontal", CONST_ME_CONFETTI_HORIZONTAL},
{"confettivertical", CONST_ME_CONFETTI_VERTICAL},
{"blacksmoke", CONST_ME_BLACKSMOKE},
- {"redsmoke", CONST_ME_REDSMOKE},
- {"yellowsmoke", CONST_ME_YELLOWSMOKE},
- {"greensmoke", CONST_ME_GREENSMOKE},
- {"purplesmoke", CONST_ME_PURPLESMOKE},
};
ShootTypeNames shootTypeNames[] = {
@@ -611,8 +607,6 @@ ShootTypeNames shootTypeNames[] = {
{"crystallinearrow", CONST_ANI_CRYSTALLINEARROW},
{"drillbolt", CONST_ANI_DRILLBOLT},
{"envenomedarrow", CONST_ANI_ENVENOMEDARROW},
- {"gloothspear", CONST_ANI_GLOOTHSPEAR},
- {"simplearrow", CONST_ANI_SIMPLEARROW},
};
CombatTypeNames combatTypeNames[] = {
@@ -1160,4 +1154,4 @@ const char* getReturnMessage(ReturnValue value)
default: // RETURNVALUE_NOTPOSSIBLE, etc
return "Sorry, not possible.";
}
-}
\ No newline at end of file
+}
--
1.9.5.msysgit.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment