Skip to content

Commit

Permalink
Merge branch 'mehah:main' into browser
Browse files Browse the repository at this point in the history
  • Loading branch information
OTArchive authored Nov 8, 2024
2 parents 5b5019e + 01ebe1b commit 8e80533
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 36 deletions.
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- updater
Services = {
--updater = "http://localhost/api/updater.php", --./updater
--status = "http://localhost/api/status.php", --./client_entergame | ./client_topmenu
--status = "http://localhost/login.php", --./client_entergame | ./client_topmenu
--websites = "http://localhost/?subtopic=accountmanagement", --./client_entergame "Forgot password and/or email"
}

Expand Down
16 changes: 12 additions & 4 deletions modules/client_bottommenu/bottommenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function init()
creature_boosted = boostedWindow:recursiveGetChildById('creature')
boss_boosted = boostedWindow:recursiveGetChildById('boss')

if not Services.status and default_info then
-- if not Services.status and default_info then
if default_info then
local widget = g_ui.createWidget('ShowOffWidget', showOffWindow)
local description = widget:recursiveGetChildById('description')
local image = widget:recursiveGetChildById('image')
Expand Down Expand Up @@ -494,8 +495,15 @@ end

function Booster_creature(data)
if modules.game_things.isLoaded() then
-- note: is better image *
creature_boosted:setOutfit(data.creature)
boss_boosted:setOutfit(data.boss)
local creatureraceid = modules.game_cyclopedia.RACE[data.creatureraceid]
local bossraceid = modules.game_cyclopedia.RACE_Bosstiary[data.bossraceid]
if creatureraceid then
creature_boosted:setOutfit({type=creatureraceid.type})
creature_boosted:getCreature():setStaticWalking(1000)
end
if bossraceid then
boss_boosted:setOutfit({type=bossraceid.type})
boss_boosted:getCreature():setStaticWalking(1000)
end
end
end
12 changes: 10 additions & 2 deletions modules/client_bottommenu/bottommenu.otui
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ Panel
margin-left: 12
margin-top: 30
size: 64 64
image-source: /images/ui/panel_flat

Creature
id: creature
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
image-source: ""
image-border: 0
border-width: 0
border-color: alpha

UIWidget
id: creature2
anchors.horizontalCenter: parent.horizontalCenter
Expand All @@ -174,12 +178,16 @@ Panel
margin-right: 12
margin-top: 30
size: 64 64
image-source: /images/ui/panel_flat

Creature
id: boss
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
image-source: ""
image-border: 0
border-width: 0
border-color: alpha

UIWidget
id: boss2
anchors.horizontalCenter: parent.horizontalCenter
Expand Down
41 changes: 19 additions & 22 deletions modules/client_entergame/entergame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,16 @@ function EnterGame.init()
end

function EnterGame.hidePanels()
modules.client_bottommenu.hide()
if g_modules.getModule("client_bottommenu"):isLoaded() then
modules.client_bottommenu.hide()
end
modules.client_topmenu.toggle()
end

function EnterGame.showPanels()
modules.client_bottommenu.show()
if g_modules.getModule("client_bottommenu"):isLoaded() then
modules.client_bottommenu.show()
end
modules.client_topmenu.toggle()
end

Expand All @@ -245,10 +249,12 @@ function EnterGame.firstShow()
end

if Services and Services.status then
EnterGame.postCacheInfo()
EnterGame.postEventScheduler()
EnterGame.postShowOff()
EnterGame.postShowCreatureBoost()
if g_modules.getModule("client_bottommenu"):isLoaded() then
EnterGame.postCacheInfo()
EnterGame.postEventScheduler()
-- EnterGame.postShowOff() -- myacc/znote no send login.php
EnterGame.postShowCreatureBoost()
end
end
end

Expand Down Expand Up @@ -333,26 +339,20 @@ end
function EnterGame.postEventScheduler()
local onRecvInfo = function(message, err)
if err then
-- onError(nil, 'Bad Request. Game_entergame postEventScheduler1', 400)
g_logger.warning("[Webscraping] " .. "Bad Request.Game_entergame postEventScheduler1")
g_logger.warning("[Webscraping] Bad Request.Game_entergame postEventScheduler1")
return
end

local _, bodyStart = message:find('{')
local _, bodyEnd = message:find('.*}')
if not bodyStart or not bodyEnd then
-- onError(nil, 'Bad Request. Game_entergame postEventScheduler2', 400)
g_logger.warning("[Webscraping] " .. "Bad Request.Game_entergame postEventScheduler2")
return
end
local bodyStart, _ = message:find('{')
local _, bodyEnd = message:find('%}%b{}')

local response = json.decode(message:sub(bodyStart, bodyEnd))
local jsonString = message:sub(bodyStart, bodyEnd)

local response = json.decode(jsonString)
if response.errorMessage then
-- onError(nil, response.errorMessage, response.errorCode)
g_logger.warning("[Webscraping] " .. "response.errorMessage,response.errorCode")
return
end

modules.client_bottommenu.setEventsSchedulerTimestamp(response.lastupdatetimestamp)
modules.client_bottommenu.setEventsSchedulerCalender(response.eventlist)
end
Expand All @@ -365,22 +365,19 @@ end
function EnterGame.postShowOff()
local onRecvInfo = function(message, err)
if err then
-- onError(nil, 'Bad Request. 1 Game_entergame postShowOff', 400)
g_logger.warning("[Webscraping] " .. "Bad Request.Game_entergame postShowOff")
return
end

local _, bodyStart = message:find('{')
local _, bodyEnd = message:find('.*}')
if not bodyStart or not bodyEnd then
-- onError(nil, 'Bad Request. 2 Game_entergame postShowOff', 400)
g_logger.warning("[Webscraping] " .. "Bad Request.Game_entergame postShowOff")
return
end

local response = json.decode(message:sub(bodyStart, bodyEnd))
if response.errorMessage then
-- onError(nil, response.errorMessage, response.errorCode)
g_logger.warning("[Webscraping] " .. response.errorMessage, response.errorCode)
return
end
Expand Down Expand Up @@ -420,7 +417,7 @@ function EnterGame.postShowCreatureBoost()
end

HTTP.post(Services.status, json.encode({
type = 'Creatureboost'
type = 'boostedcreature'
}), onRecvInfo, false)
end

Expand Down
6 changes: 5 additions & 1 deletion modules/game_questlog/questlog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ function terminate()

destroyWindows()
questLogButton:destroy()
questLogButton = nil
end

function destroyWindows()
if questLogWindow then
questLogWindow:destroy()
questLogWindow = nil
end

if questLineWindow then
questLineWindow:destroy()
questLineWindow = nil
end
end

Expand Down Expand Up @@ -69,6 +72,7 @@ function onGameQuestLine(questId, questMissions)
end
if questLineWindow then
questLineWindow:destroy()
questLineWindow = nil
end

questLineWindow = g_ui.createWidget('QuestLineWindow', rootWidget)
Expand All @@ -85,7 +89,7 @@ function onGameQuestLine(questId, questMissions)
})

for i, questMission in pairs(questMissions) do
local name, description = unpack(questMission)
local name, description, missionId = unpack(questMission)

local missionLabel = g_ui.createWidget('MissionLabel')
missionLabel:setText(name)
Expand Down
2 changes: 1 addition & 1 deletion src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ void Game::processQuestLog(const std::vector<std::tuple<uint16_t, std::string, b
g_lua.callGlobalField("g_game", "onQuestLog", questList);
}

void Game::processQuestLine(const uint16_t questId, const std::vector<std::tuple<std::string, std::string>>& questMissions)
void Game::processQuestLine(const uint16_t questId, const std::vector<std::tuple<std::string_view, std::string_view, uint16_t>>& questMissions)
{
g_lua.callGlobalField("g_game", "onQuestLine", questId, questMissions);
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class Game

// questlog
static void processQuestLog(const std::vector<std::tuple<uint16_t, std::string, bool>>& questList);
static void processQuestLine(const uint16_t questId, const std::vector<std::tuple<std::string, std::string>>& questMissions);
static void processQuestLine(const uint16_t questId, const std::vector<std::tuple<std::string_view, std::string_view, uint16_t>>& questMissions);

// modal dialogs >= 970
static void processModalDialog(const uint32_t id, const std::string_view title, const std::string_view message, const std::vector<std::tuple<uint8_t, std::string>>
Expand Down
8 changes: 6 additions & 2 deletions src/client/protocolgameparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2933,12 +2933,16 @@ void ProtocolGame::parseQuestLine(const InputMessagePtr& msg)
const uint16_t questId = msg->getU16();

const uint8_t missionCount = msg->getU8();
std::vector<std::tuple<std::string, std::string>> questMissions;
std::vector<std::tuple<std::string_view, std::string_view, uint16_t>> questMissions;

for (auto i = 0; i < missionCount; ++i) {
auto missionId = 0;
if (g_game.getClientVersion() >= 1200) {
missionId = msg->getU16();
}
const auto& missionName = msg->getString();
const auto& missionDescrition = msg->getString();
questMissions.emplace_back(missionName, missionDescrition);
questMissions.emplace_back(missionName, missionDescrition, missionId);
}

g_game.processQuestLine(questId, questMissions);
Expand Down
2 changes: 1 addition & 1 deletion src/client/protocolgamesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ void ProtocolGame::sendChangeOutfit(const Outfit& outfit)
}
}

if (g_game.getClientVersion() >= 1340) {
if (g_game.getClientVersion() >= 1334) {
msg->addU8(static_cast<uint8_t>(outfit.hasMount()));
}

Expand Down
2 changes: 1 addition & 1 deletion tools/api/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
echo json_encode($response);

// EnterGame.postShowCreatureBoost()
} elseif ($requestType === 'Creatureboost') {
} elseif ($requestType === 'boostedcreature') {


$response = array(
Expand Down

0 comments on commit 8e80533

Please sign in to comment.