From 05af593814d83347078b7f99eb382d49429af89c Mon Sep 17 00:00:00 2001 From: ErikasKontenis Date: Wed, 13 Nov 2019 17:06:13 +0200 Subject: [PATCH] fix debug caused by SendIcons. Fix max stamina. Fix character say. Fully finish 7.81 basic implementation. --- config.lua | 2 +- nostalrius.sql | 2 + src/luascript.cpp | 2 +- src/player.h | 2 +- src/protocolgame.cpp | 118 +++++++++++++++++++++---------------------- src/protocolgame.h | 1 - 6 files changed, 64 insertions(+), 63 deletions(-) diff --git a/config.lua b/config.lua index 0383f6a..e354f60 100644 --- a/config.lua +++ b/config.lua @@ -52,7 +52,7 @@ timeBetweenExActions = 1000 -- Map -- NOTE: set mapName WITHOUT .otbm at the end -mapName = "mymap" +mapName = "map" mapAuthor = "CipSoft" -- MySQL diff --git a/nostalrius.sql b/nostalrius.sql index 4f21d2b..4564d28 100644 --- a/nostalrius.sql +++ b/nostalrius.sql @@ -1125,6 +1125,7 @@ CREATE TABLE `players` ( `lookhead` int(11) NOT NULL DEFAULT '0', `looklegs` int(11) NOT NULL DEFAULT '0', `looktype` int(11) NOT NULL DEFAULT '136', + `lookaddons` int(11) NOT NULL DEFAULT '0', `maglevel` int(11) NOT NULL DEFAULT '0', `mana` int(11) NOT NULL DEFAULT '0', `manamax` int(11) NOT NULL DEFAULT '0', @@ -1147,6 +1148,7 @@ CREATE TABLE `players` ( `onlinetime` int(11) NOT NULL DEFAULT '0', `deletion` bigint(15) NOT NULL DEFAULT '0', `balance` bigint(20) UNSIGNED NOT NULL DEFAULT '0', + `stamina` smallint(5) NOT NULL DEFAULT '3360', `skill_fist` int(10) UNSIGNED NOT NULL DEFAULT '10', `skill_fist_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0', `skill_club` int(10) UNSIGNED NOT NULL DEFAULT '10', diff --git a/src/luascript.cpp b/src/luascript.cpp index 3401679..7519da5 100644 --- a/src/luascript.cpp +++ b/src/luascript.cpp @@ -7783,7 +7783,7 @@ int LuaScriptInterface::luaPlayerSetStamina(lua_State* L) uint16_t stamina = getNumber(L, 2); Player* player = getUserdata(L, 1); if (player) { - player->staminaMinutes = std::min(2520, stamina); + player->staminaMinutes = std::min(3360, stamina); player->sendStats(); pushBoolean(L, true); } diff --git a/src/player.h b/src/player.h index 743e2ac..5050903 100644 --- a/src/player.h +++ b/src/player.h @@ -1046,7 +1046,7 @@ class Player final : public Creature, public Cylinder int32_t shieldBlockCount = 0; int32_t idleTime = 0; - uint16_t staminaMinutes = 2520; + uint16_t staminaMinutes = 3360; uint16_t maxWriteLen = 0; uint8_t soul = 0; diff --git a/src/protocolgame.cpp b/src/protocolgame.cpp index b004596..0b51ab1 100644 --- a/src/protocolgame.cpp +++ b/src/protocolgame.cpp @@ -1168,11 +1168,12 @@ void ProtocolGame::sendChannel(uint16_t channelId, const std::string& channelNam writeToOutputBuffer(msg); } + void ProtocolGame::sendIcons(uint16_t icons) { NetworkMessage msg; msg.addByte(0xA2); - msg.addByte(static_cast(icons)); + msg.add(icons); writeToOutputBuffer(msg); } @@ -1204,6 +1205,8 @@ void ProtocolGame::sendContainer(uint8_t cid, const Container* container, bool h writeToOutputBuffer(msg); } + + void ProtocolGame::sendTradeItemRequest(const std::string& traderName, const Item* item, bool ack) { NetworkMessage msg; @@ -1277,14 +1280,61 @@ void ProtocolGame::sendCreatureTurn(const Creature* creature, uint32_t stackPos) void ProtocolGame::sendCreatureSay(const Creature* creature, SpeakClasses type, const std::string& text, const Position* pos/* = nullptr*/) { NetworkMessage msg; - AddCreatureSpeak(msg, creature, type, text, 0, pos); + msg.addByte(0xAA); + + static uint32_t statementId = 0; + msg.add(++statementId); + + msg.addString(creature->getName()); + + //Add level only for players + if (const Player* speaker = creature->getPlayer()) { + msg.add(speaker->getLevel()); + } + else { + msg.add(0x00); + } + + msg.addByte(type); + if (pos) { + msg.addPosition(*pos); + } + else { + msg.addPosition(creature->getPosition()); + } + + msg.addString(text); writeToOutputBuffer(msg); } void ProtocolGame::sendToChannel(const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId) { NetworkMessage msg; - AddCreatureSpeak(msg, creature, type, text, channelId); + msg.addByte(0xAA); + + static uint32_t statementId = 0; + msg.add(++statementId); + if (!creature) { + msg.add(0x00); + } + else if (type == TALKTYPE_CHANNEL_R2) { + msg.add(0x00); + type = TALKTYPE_CHANNEL_R1; + } + else { + msg.addString(creature->getName()); + //Add level only for players + if (const Player* speaker = creature->getPlayer()) { + msg.add(speaker->getLevel()); + } + else { + msg.add(0x00); + } + } + + msg.addByte(type); + msg.add(channelId); + msg.addString(text); writeToOutputBuffer(msg); } @@ -1294,16 +1344,13 @@ void ProtocolGame::sendPrivateMessage(const Player* speaker, SpeakClasses type, msg.addByte(0xAA); static uint32_t statementId = 0; msg.add(++statementId); - if (type == TALKTYPE_RVR_ANSWER) { - msg.addString("Gamemaster"); - } else { - if (speaker) { - msg.addString(speaker->getName()); - } else { - msg.add(0x00); - } + if (speaker) { + msg.addString(speaker->getName()); + msg.add(speaker->getLevel()); + } + else { + msg.add(0x00); } - msg.addByte(type); msg.addString(text); writeToOutputBuffer(msg); @@ -1890,53 +1937,6 @@ void ProtocolGame::AddCreatureLight(NetworkMessage& msg, const Creature* creatur msg.addByte(lightInfo.color); } -void ProtocolGame::AddCreatureSpeak(NetworkMessage& msg, const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId, const Position* pos /*= nullptr*/) -{ - msg.addByte(0xAA); - static uint32_t statementId = 0; - msg.add(++statementId); - - if (type != TALKTYPE_RVR_ANSWER) { - if (type != TALKTYPE_CHANNEL_R2) { - if (creature) { - msg.addString(creature->getName()); - } else { - msg.add(0); - } - } else { - msg.add(0); - } - } - - msg.addByte(type); - switch (type) { - case TALKTYPE_SAY: - case TALKTYPE_WHISPER: - case TALKTYPE_YELL: - case TALKTYPE_MONSTER_SAY: - case TALKTYPE_MONSTER_YELL: - if (!pos) { - msg.addPosition(creature->getPosition()); - } else { - msg.addPosition(*pos); - } - break; - case TALKTYPE_CHANNEL_Y: - case TALKTYPE_CHANNEL_R1: - case TALKTYPE_CHANNEL_R2: - case TALKTYPE_CHANNEL_O: - msg.add(channelId); - break; - case TALKTYPE_RVR_CHANNEL: - msg.add(0); - break; - default: - break; - } - - msg.addString(text); -} - //tile void ProtocolGame::RemoveTileThing(NetworkMessage& msg, const Position& pos, uint32_t stackpos) { diff --git a/src/protocolgame.h b/src/protocolgame.h index aca3e38..9d0cbe3 100644 --- a/src/protocolgame.h +++ b/src/protocolgame.h @@ -234,7 +234,6 @@ class ProtocolGame final : public Protocol void AddPlayerSkills(NetworkMessage& msg); void AddWorldLight(NetworkMessage& msg, const LightInfo& lightInfo); void AddCreatureLight(NetworkMessage& msg, const Creature* creature); - void AddCreatureSpeak(NetworkMessage& msg, const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId, const Position* pos = nullptr); //tiles static void RemoveTileThing(NetworkMessage& msg, const Position& pos, uint32_t stackpos);