Skip to content

Commit 44525b5

Browse files
authored
Merge pull request #21 from TibiaDev/feature/0.2.9
[Feature] 0.2.9
2 parents 14a7692 + cf86758 commit 44525b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2699
-1350
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
# Makefile for Linux (tested under Debian and Ubuntu)
12
TFS = forgottenserver
23

34
INCLUDEDIRS = -I. -I/usr/include/libxml2 \
45
-I /usr/include/lua5.1
56

67
LIBDIRS =
78

8-
FLAGS = -D_THREAD_SAFE -D_REENTRANT -D__NO_HOMEDIR_CONF__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__USE_SQLITE__ -D__USE_MYSQL__
9+
FLAGS = -D_THREAD_SAFE -D_REENTRANT -D__NO_HOMEDIR_CONF__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__USE_SQLITE__ -D__USE_MYSQL__
910

10-
CXXFLAGS = $(INCLUDEDIRS) $(FLAGS) -Werror -Wall -O0 -ggdb
11+
CXXFLAGS = $(INCLUDEDIRS) $(FLAGS) -Werror -Wall -O2
1112
CXX = g++
1213

13-
LIBS = -lxml2 -lpthread -llua5.1 -lgmp -lmysqlclient -lsqlite3 -lboost_regex -llua5.1-sql-mysql -llua5.1-sql-sqlite -ldl -lboost_system -lboost_thread
14+
LIBS = -lxml2 -lpthread -llua5.1 -lgmp -lmysqlclient -lsqlite3 -lboost_regex -llua5.1-sql-mysql -ldl -lboost_system -lboost_thread
1415

1516
LDFLAGS = $(LIBDIRS) $(LIBS)
1617

17-
CXXSOURCES = account.cpp actions.cpp admin.cpp allocator.cpp ban.cpp baseevents.cpp beds.cpp creature.cpp creatureevent.cpp chat.cpp combat.cpp commands.cpp condition.cpp configmanager.cpp connection.cpp container.cpp cylinder.cpp database.cpp databasemysql.cpp databasesqlite.cpp depot.cpp exception.cpp fileloader.cpp game.cpp gui.cpp house.cpp housetile.cpp ioguild.cpp iologindata.cpp iomap.cpp iomapserialize.cpp inputbox.cpp item.cpp items.cpp logger.cpp luascript.cpp mailbox.cpp map.cpp md5.cpp monster.cpp monsters.cpp movement.cpp networkmessage.cpp npc.cpp otserv.cpp outfit.cpp outputmessage.cpp party.cpp player.cpp playerbox.cpp position.cpp protocol.cpp protocolgame.cpp protocollogin.cpp protocolold.cpp quests.cpp raids.cpp rsa.cpp scheduler.cpp scriptmanager.cpp server.cpp sha1.cpp spawn.cpp spells.cpp status.cpp talkaction.cpp tasks.cpp teleport.cpp textlogger.cpp thing.cpp tile.cpp tools.cpp trashholder.cpp vocation.cpp waitlist.cpp weapons.cpp
18+
CXXSOURCES = account.cpp actions.cpp admin.cpp allocator.cpp ban.cpp baseevents.cpp beds.cpp creature.cpp creatureevent.cpp chat.cpp combat.cpp commands.cpp condition.cpp configmanager.cpp connection.cpp container.cpp cylinder.cpp database.cpp databasemysql.cpp databasesqlite.cpp depot.cpp exception.cpp fileloader.cpp game.cpp globalevent.cpp gui.cpp house.cpp housetile.cpp ioguild.cpp iologindata.cpp iomap.cpp iomapserialize.cpp inputbox.cpp item.cpp items.cpp logger.cpp luascript.cpp mailbox.cpp map.cpp md5.cpp monster.cpp monsters.cpp mounts.cpp movement.cpp networkmessage.cpp npc.cpp otserv.cpp outfit.cpp outputmessage.cpp party.cpp player.cpp playerbox.cpp position.cpp protocol.cpp protocolgame.cpp protocollogin.cpp protocolold.cpp quests.cpp raids.cpp rsa.cpp scheduler.cpp scriptmanager.cpp server.cpp sha1.cpp spawn.cpp spells.cpp status.cpp talkaction.cpp tasks.cpp teleport.cpp textlogger.cpp thing.cpp tile.cpp tools.cpp trashholder.cpp vocation.cpp waitlist.cpp weapons.cpp
1819

1920
CXXOBJECTS = $(CXXSOURCES:.cpp=.o)
2021

actions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,9 @@ bool Action::executeUse(Player* player, Item* item, const PositionEx& fromPos, c
619619
LuaScriptInterface::pushPosition(L, posEx, 0);
620620
}
621621

622-
int32_t result = m_scriptInterface->callFunction(5);
622+
bool result = m_scriptInterface->callFunction(5);
623623
m_scriptInterface->releaseScriptEnv();
624-
return (result != LUA_FALSE);
624+
return result;
625625
}
626626
else
627627
{

beds.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ BedItem* BedItem::getNextBedItem()
9696
Position targetPos = getNextPosition(dir, getPosition());
9797

9898
Tile* tile = g_game.getMap()->getTile(targetPos);
99-
if(tile != NULL)
99+
if(tile)
100100
return tile->getBedItem();
101101

102102
return NULL;
103103
}
104104

105105
bool BedItem::canUse(Player* player)
106106
{
107-
if(player == NULL || house == NULL || !player->isPremium())
107+
if(!player || !house || !player->isPremium())
108108
return false;
109109
else if(player->hasCondition(CONDITION_INFIGHT))
110110
return false;
@@ -142,7 +142,7 @@ bool BedItem::canUse(Player* player)
142142
void BedItem::sleep(Player* player)
143143
{
144144
// avoid crashes
145-
if((house == NULL) || (player == NULL) || player->isRemoved())
145+
if((!house) || (!player) || player->isRemoved())
146146
return;
147147

148148
if(sleeperGUID != 0)
@@ -183,12 +183,12 @@ void BedItem::sleep(Player* player)
183183
void BedItem::wakeUp(Player* player)
184184
{
185185
// avoid crashes
186-
if(house == NULL)
186+
if(!house)
187187
return;
188188

189189
if(sleeperGUID != 0)
190190
{
191-
if(player == NULL)
191+
if(!player)
192192
{
193193
std::string name;
194194
if(IOLoginData::getInstance()->getNameByGuid(sleeperGUID, name))

chat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void ChatChannel::sendToAll(std::string message, SpeakClasses type)
147147
it->second->sendChannelMessage("", message, type, m_id);
148148
}
149149

150-
bool ChatChannel::talk(Player* fromPlayer, SpeakClasses type, const std::string& text, uint32_t time /*= 0*/)
150+
bool ChatChannel::talk(Player* fromPlayer, SpeakClasses type, const std::string& text)
151151
{
152152
if(m_users.find(fromPlayer->getID()) == m_users.end())
153153
return false;
@@ -159,7 +159,7 @@ bool ChatChannel::talk(Player* fromPlayer, SpeakClasses type, const std::string&
159159
}
160160

161161
for(UsersMap::iterator it = m_users.begin(); it != m_users.end(); ++it)
162-
it->second->sendToChannel(fromPlayer, type, text, getId(), time);
162+
it->second->sendToChannel(fromPlayer, type, text, getId());
163163

164164
return true;
165165
}

chat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ChatChannel
4242
bool addUser(Player* player);
4343
bool removeUser(Player* player);
4444

45-
bool talk(Player* fromPlayer, SpeakClasses type, const std::string& text, uint32_t time = 0);
45+
bool talk(Player* fromPlayer, SpeakClasses type, const std::string& text);
4646
void sendToAll(std::string message, SpeakClasses type);
4747

4848
const std::string& getName() {return m_name;}

codeblocks/The Forgotten Server.cbp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
<Unit filename="..\fileloader.h" />
101101
<Unit filename="..\game.cpp" />
102102
<Unit filename="..\game.h" />
103+
<Unit filename="..\globalevent.cpp" />
104+
<Unit filename="..\globalevent.h" />
103105
<Unit filename="..\gui.cpp" />
104106
<Unit filename="..\gui.h" />
105107
<Unit filename="..\house.cpp" />
@@ -135,6 +137,8 @@
135137
<Unit filename="..\monster.h" />
136138
<Unit filename="..\monsters.cpp" />
137139
<Unit filename="..\monsters.h" />
140+
<Unit filename="..\mounts.cpp" />
141+
<Unit filename="..\mounts.h" />
138142
<Unit filename="..\movement.cpp" />
139143
<Unit filename="..\movement.h" />
140144
<Unit filename="..\networkmessage.cpp" />

combat.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ void ValueCallback::getMinMaxValues(Player* player, int32_t& min, int32_t& max,
10151015
min = LuaScriptInterface::popNumber(L);
10161016
}
10171017

1018-
if((lua_gettop(L) + parameters /*nParams*/ + 1) != size0)
1018+
if((lua_gettop(L) + parameters /*nParams*/ + 1) != size0)
10191019
LuaScriptInterface::reportError(NULL, "Stack size changed!");
10201020

10211021
env->resetCallback();
@@ -1088,7 +1088,7 @@ void TargetCallback::onTargetCombat(Creature* creature, Creature* target) const
10881088
if(lua_pcall(L, 2, 0 /*nReturnValues*/, 0) != 0)
10891089
LuaScriptInterface::reportError(NULL, LuaScriptInterface::popString(L));
10901090

1091-
if((lua_gettop(L) + 2 /*nParams*/ + 1) != size0)
1091+
if((lua_gettop(L) + 2 /*nParams*/ + 1) != size0)
10921092
LuaScriptInterface::reportError(NULL, "Stack size changed!");
10931093

10941094
env->resetCallback();
@@ -1146,7 +1146,7 @@ bool AreaCombat::getList(const Position& centerPos, const Position& targetPos, s
11461146
{
11471147
if(tmpPosX >= 0 && tmpPosX < 0xFFFF &&
11481148
tmpPosY >= 0 && tmpPosY < 0xFFFF &&
1149-
tmpPosZ >= 0 && tmpPosZ < MAP_MAX_LAYERS)
1149+
tmpPosZ >= 0 && tmpPosZ < MAP_MAX_LAYERS)
11501150
{
11511151
if(g_game.isSightClear(targetPos, Position(tmpPosX, tmpPosY, tmpPosZ), true))
11521152
{

commands.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "raids.h"
4444
#include "chat.h"
4545
#include "quests.h"
46+
#include "mounts.h"
4647
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
4748
#include "outputmessage.h"
4849
#include "connection.h"
@@ -186,7 +187,11 @@ bool Commands::loadFromXml()
186187
else
187188
std::cout << "missing acctype tag for " << strCmd << std::endl;
188189
}
190+
#ifdef __ENABLE_SERVER_DIAGNOSTIC__
189191
else
192+
#else
193+
else if(strCmd != "/serverdiag")
194+
#endif
190195
std::cout << "Unknown command " << strCmd << std::endl;
191196
}
192197
else
@@ -580,11 +585,15 @@ void Commands::reloadInfo(Player* player, const std::string& cmd, const std::str
580585
Quests::getInstance()->reload();
581586
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded quests.");
582587
}
588+
else if(tmpParam == "mount" || tmpParam == "mounts")
589+
{
590+
Mounts::getInstance()->reload();
591+
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded mounts.");
592+
}
583593
else
584594
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reload type not found.");
585595
}
586596

587-
588597
void Commands::teleportToTown(Player* player, const std::string& cmd, const std::string& param)
589598
{
590599
std::string tmp = param;
@@ -1019,8 +1028,12 @@ void Commands::removeThing(Player* player, const std::string& cmd, const std::st
10191028
void Commands::newType(Player* player, const std::string& cmd, const std::string& param)
10201029
{
10211030
int32_t lookType = atoi(param.c_str());
1022-
if(lookType >= 0 && lookType != 1 && lookType != 135 && (lookType <= 160 || lookType >= 192) && lookType <= 367)
1023-
g_game.internalCreatureChangeOutfit(player, (const Outfit_t&)lookType);
1031+
if(lookType >= 0 && lookType != 1 && lookType != 135 && (lookType <= 160 || lookType >= 192) && lookType <= 386)
1032+
{
1033+
Outfit_t newOutfit = player->getDefaultOutfit();
1034+
newOutfit.lookType = lookType;
1035+
g_game.internalCreatureChangeOutfit(player, newOutfit);
1036+
}
10241037
else
10251038
player->sendTextMessage(MSG_STATUS_SMALL, "This looktype does not exist.");
10261039
}
@@ -1283,10 +1296,10 @@ void Commands::playerKills(Player* player, const std::string& cmd, const std::st
12831296
int32_t fragTime = g_config.getNumber(ConfigManager::FRAG_TIME);
12841297
if(player->redSkullTicks && fragTime > 0)
12851298
{
1286-
int32_t frags = ceil(player->redSkullTicks / (double)fragTime);
1299+
int32_t frags = (int32_t)ceil(player->redSkullTicks / (double)fragTime);
12871300
int32_t remainingTime = (player->redSkullTicks % fragTime) / 1000;
1288-
int32_t hours = floor(remainingTime / 3600);
1289-
int32_t minutes = floor((remainingTime % 3600) / 60);
1301+
int32_t hours = (int32_t)floor(remainingTime / 3600);
1302+
int32_t minutes = (int32_t)floor((remainingTime % 3600) / 60);
12901303

12911304
std::stringstream ss;
12921305
ss << "You have " << frags << " unjustified kill" << (frags > 1 ? "s" : "") << ". The amount of unjustified kills will decrease after: " << hours << " hour" << (hours != 1 ? "s" : "") << " and " << minutes << " minute" << (minutes != 1 ? "s" : "") << ".";

0 commit comments

Comments
 (0)