Skip to content

Commit

Permalink
Merge pull request LandSandBoat#3603 from LandSandBoat/move_gobbie_sq…
Browse files Browse the repository at this point in the history
…l_update

[world] Move Gobbie Box SQL update to world server
  • Loading branch information
zach2good authored Feb 15, 2023
2 parents 8f46599 + 0f01578 commit 1e7ef82
Show file tree
Hide file tree
Showing 32 changed files with 414 additions and 273 deletions.
5 changes: 3 additions & 2 deletions settings/default/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ xi.settings.network =

SEARCH_PORT = 54002,

HTTP_HOST = "localhost",
HTTP_PORT = 8080,
ENABLE_HTTP = false,
HTTP_HOST = "localhost",
HTTP_PORT = 8088,

-- Central message server settings (ensure these are the same on both all map servers and the central (lobby) server
ZMQ_IP = "127.0.0.1",
Expand Down
2 changes: 2 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ set(COMMON_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/xirand.h
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.h
${CMAKE_CURRENT_SOURCE_DIR}/vana_time.cpp
${CMAKE_CURRENT_SOURCE_DIR}/vana_time.h
${CMAKE_CURRENT_SOURCE_DIR}/version.cpp # auto-generated
${CMAKE_CURRENT_SOURCE_DIR}/version.h
${CMAKE_CURRENT_SOURCE_DIR}/watchdog.cpp
Expand Down
3 changes: 1 addition & 2 deletions src/map/vana_time.cpp → src/common/vana_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
===========================================================================
*/

#include "../common/logging.h"
#include "common/logging.h"

#include <ctime>

#include "utils/zoneutils.h"
#include "vana_time.h"

CVanaTime* CVanaTime::_instance = nullptr;
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions src/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/unitychat.h
${CMAKE_CURRENT_SOURCE_DIR}/universal_container.cpp
${CMAKE_CURRENT_SOURCE_DIR}/universal_container.h
${CMAKE_CURRENT_SOURCE_DIR}/vana_time.cpp
${CMAKE_CURRENT_SOURCE_DIR}/vana_time.h
${CMAKE_CURRENT_SOURCE_DIR}/weapon_skill.cpp
${CMAKE_CURRENT_SOURCE_DIR}/weapon_skill.h
${CMAKE_CURRENT_SOURCE_DIR}/zone_entities.cpp
Expand Down
4 changes: 3 additions & 1 deletion src/map/conquest_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
*/

#include "conquest_system.h"

#include "common/vana_time.h"

#include "entities/charentity.h"
#include "utils/charutils.h"
#include "utils/zoneutils.h"
#include "vana_time.h"

#include "packets/conquest_map.h"

Expand Down
59 changes: 28 additions & 31 deletions src/map/daily_system.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
/*
===========================================================================
Copyright (c) 2022 LandSandBoat Dev Teams
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
===========================================================================
*/

#include "daily_system.h"

#include "items/item.h"
#include "utils/charutils.h"
#include "utils/itemutils.h"
Expand All @@ -11,7 +33,10 @@ namespace daily
std::vector<uint16> sundries1DialItems;
std::vector<uint16> sundries2DialItems;
std::vector<uint16> specialDialItems;
std::vector<uint16> gobbieJunk = {

// clang-format off
std::vector<uint16> gobbieJunk =
{
2542, // Goblin Mess Tin
2543, // Goblin Weel
4324, // Hobgoblin Chocolate
Expand All @@ -21,10 +46,10 @@ namespace daily
4495, // Goblin Chocolate
4539 // Goblin Pie
};
// clang-format on

uint16 SelectItem(CCharEntity* player, uint8 dial)
{
uint16 selection;
std::vector<uint16>* dialItems = &gobbieJunk;
switch (dial)
{
Expand Down Expand Up @@ -59,7 +84,7 @@ namespace daily
break;
}
}
selection = xirand::GetRandomElement(dialItems);
uint16 selection = xirand::GetRandomElement(dialItems);

// Check if Rare item is already owned and substitute with Goblin trash item.
if ((itemutils::GetItem(selection)->getFlag() & ITEM_FLAG_RARE) > 0 && charutils::HasItem(player, selection))
Expand Down Expand Up @@ -166,32 +191,4 @@ namespace daily
ShowError("Failed to load daily tally items");
}
}

void UpdateDailyTallyPoints()
{
uint16 dailyTallyLimit = settings::get<uint16>("main.DAILY_TALLY_LIMIT");
uint16 dailyTallyAmount = settings::get<uint16>("main.DAILY_TALLY_AMOUNT");

const char* fmtQuery = "UPDATE char_points \
SET char_points.daily_tally = LEAST(%u, char_points.daily_tally + %u) \
WHERE char_points.daily_tally > -1;";

int32 ret = sql->Query(fmtQuery, dailyTallyLimit, dailyTallyAmount);

if (ret == SQL_ERROR)
{
ShowError("Failed to update daily tally points");
}
else
{
ShowDebug("Distributed daily tally points");
}

fmtQuery = "DELETE FROM char_vars WHERE varname = 'gobbieBoxUsed';";

if (sql->Query(fmtQuery, dailyTallyAmount) == SQL_ERROR)
{
ShowError("Failed to delete daily tally char_vars entries");
}
}
} // namespace daily
22 changes: 21 additions & 1 deletion src/map/daily_system.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
===========================================================================
Copyright (c) 2023 LandSandBoat Dev Teams
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
===========================================================================
*/

#ifndef _DAILYSYSTEM_H
#define _DAILYSYSTEM_H
#include "map.h"
Expand All @@ -6,7 +27,6 @@ namespace daily
{
uint16 SelectItem(CCharEntity* player, uint8 dial);
void LoadDailyItems();
void UpdateDailyTallyPoints();
} // namespace daily

#endif //_DAILYSYSTEM_H
8 changes: 4 additions & 4 deletions src/map/items/item_usable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
===========================================================================
*/

#include "common/utils.h"

#include "item_usable.h"

#include "../map.h"
#include "../vana_time.h"
#include "common/utils.h"
#include "common/vana_time.h"

#include "map.h"

CItemUsable::CItemUsable(uint16 id)
: CItem(id)
Expand Down
5 changes: 3 additions & 2 deletions src/map/lua/luautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
===========================================================================
*/

#include "luautils.h"

#include "common/filewatcher.h"
#include "common/logging.h"
#include "common/utils.h"
#include "common/vana_time.h"
#include "common/version.h"

#include <array>
Expand All @@ -43,7 +46,6 @@
#include "lua_trade_container.h"
#include "lua_trigger_area.h"
#include "lua_zone.h"
#include "luautils.h"

#include "ability.h"
#include "ai/ai_container.h"
Expand Down Expand Up @@ -93,7 +95,6 @@
#include "utils/moduleutils.h"
#include "utils/serverutils.h"
#include "utils/zoneutils.h"
#include "vana_time.h"
#include "weapon_skill.h"

void ReportErrorToPlayer(CBaseEntity* PEntity, std::string const& message = "") noexcept
Expand Down
5 changes: 3 additions & 2 deletions src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ along with this program. If not, see http://www.gnu.org/licenses/
===========================================================================
*/

#include "map.h"

#include "common/blowfish.h"
#include "common/console_service.h"
#include "common/logging.h"
#include "common/md52.h"
#include "common/timer.h"
#include "common/utils.h"
#include "common/vana_time.h"
#include "common/version.h"
#include "common/zlib.h"

Expand All @@ -37,7 +40,6 @@ along with this program. If not, see http://www.gnu.org/licenses/
#include "ability.h"
#include "job_points.h"
#include "linkshell.h"
#include "map.h"
#include "message.h"
#include "mob_spell_list.h"
#include "packet_guard.h"
Expand All @@ -47,7 +49,6 @@ along with this program. If not, see http://www.gnu.org/licenses/
#include "status_effect_container.h"
#include "time_server.h"
#include "transport.h"
#include "vana_time.h"
#include "zone.h"
#include "zone_entities.h"

Expand Down
12 changes: 6 additions & 6 deletions src/map/packets/auction_house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
===========================================================================
*/

#include "auction_house.h"

#include "common/socket.h"
#include "common/vana_time.h"

#include <cstring>

#include "auction_house.h"

#include "../entities/charentity.h"
#include "../map.h"
#include "../utils/itemutils.h"
#include "../vana_time.h"
#include "entities/charentity.h"
#include "map.h"
#include "utils/itemutils.h"

bool IsAuctionOpen = true; // Trading is allowed at the auction

Expand Down
8 changes: 4 additions & 4 deletions src/map/packets/bazaar_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
===========================================================================
*/

#include "bazaar_item.h"

#include "common/socket.h"
#include "common/utils.h"
#include "common/vana_time.h"

#include <cstring>

#include "bazaar_item.h"

#include "../utils/itemutils.h"
#include "../vana_time.h"
#include "utils/itemutils.h"

CBazaarItemPacket::CBazaarItemPacket(CItem* PItem, uint8 SlotID, uint16 Tax)
{
Expand Down
10 changes: 5 additions & 5 deletions src/map/packets/char_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
===========================================================================
*/

#include "char_check.h"

#include "common/socket.h"
#include "common/utils.h"
#include "common/vana_time.h"

#include <cstring>

#include "char_check.h"

#include "../entities/charentity.h"
#include "../utils/itemutils.h"
#include "../vana_time.h"
#include "entities/charentity.h"
#include "utils/itemutils.h"

CCheckPacket::CCheckPacket(CCharEntity* PChar, CCharEntity* PTarget)
{
Expand Down
16 changes: 8 additions & 8 deletions src/map/packets/char_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
===========================================================================
*/

#include "char_update.h"

#include "common/logging.h"
#include "common/socket.h"
#include "common/vana_time.h"

#include <cstring>

#include "char_update.h"

#include "../ai/ai_container.h"
#include "../ai/states/death_state.h"
#include "../entities/charentity.h"
#include "../status_effect_container.h"
#include "../utils/itemutils.h"
#include "../vana_time.h"
#include "ai/ai_container.h"
#include "ai/states/death_state.h"
#include "entities/charentity.h"
#include "status_effect_container.h"
#include "utils/itemutils.h"

CCharUpdatePacket::CCharUpdatePacket(CCharEntity* PChar)
{
Expand Down
8 changes: 4 additions & 4 deletions src/map/packets/inventory_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
===========================================================================
*/

#include "inventory_item.h"

#include "common/socket.h"
#include "common/utils.h"
#include "common/vana_time.h"

#include <cstring>

#include "inventory_item.h"

#include "../utils/itemutils.h"
#include "../vana_time.h"
#include "utils/itemutils.h"

CInventoryItemPacket::CInventoryItemPacket(CItem* PItem, uint8 LocationID, uint8 SlotID)
{
Expand Down
8 changes: 4 additions & 4 deletions src/map/packets/trade_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
===========================================================================
*/

#include "trade_update.h"

#include "common/socket.h"
#include "common/utils.h"
#include "common/vana_time.h"

#include <cstring>

#include "../utils/itemutils.h"
#include "../vana_time.h"

#include "trade_update.h"
#include "utils/itemutils.h"

CTradeUpdatePacket::CTradeUpdatePacket(CItem* PItem, uint8 SlotID)
{
Expand Down
Loading

0 comments on commit 1e7ef82

Please sign in to comment.