parent
6c281a828c
commit
17dd08d983
|
@ -128,8 +128,8 @@ endif()
|
|||
# gcc compile flags
|
||||
set(WARNS_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNS_FLAGS} ${ARCH_FLAGS} -std=gnu++0x -pipe")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -ggdb -fno-omit-frame-pointer")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -fno-omit-frame-pointer")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_CXX_FLAGS_PERFORMANCE "-Ofast -mmxx -msee -msee2")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
|
||||
|
@ -190,7 +190,6 @@ set(framework_INCLUDE_DIRS ${framework_INCLUDE_DIRS}
|
|||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
message(STATUS "Debug information: ON")
|
||||
add_definitions(-DDEBUG)
|
||||
else()
|
||||
message(STATUS "Debug information: OFF")
|
||||
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DNDEBUG) # NDEBUG disable asserts
|
||||
|
@ -214,7 +213,9 @@ if(WIN32)
|
|||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--large-address-aware") # strip all debug information
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic")
|
||||
if(NOT APPLE)
|
||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -rdynamic") # rdynamic is needed by backtrace.h used in crash handler
|
||||
endif()
|
||||
set(framework_LIBRARIES ${framework_LIBRARIES} dl)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -472,21 +472,23 @@ bool Map::loadOtcm(const std::string& fileName)
|
|||
if(!pos.isValid())
|
||||
break;
|
||||
|
||||
TilePtr tile = g_map.createTile(pos);
|
||||
|
||||
int stackPos = 0;
|
||||
while(true) {
|
||||
uint16 id = fin->getU16();
|
||||
int id = fin->getU16();
|
||||
|
||||
// end of tile
|
||||
if(id == 0xFFFF)
|
||||
break;
|
||||
|
||||
uint8 countOrSubType = fin->getU8();
|
||||
int countOrSubType = fin->getU8();
|
||||
|
||||
ItemPtr item = Item::create(id);
|
||||
if(item->isStackable() || item->isFluidContainer() || item->isSplash() || item->isChargeable())
|
||||
item->setCountOrSubType(countOrSubType);
|
||||
item->setCountOrSubType(countOrSubType);
|
||||
|
||||
if(item->isValid())
|
||||
addThing(item, pos);
|
||||
tile->addThing(item, stackPos++);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
Tile::Tile(const Position& position) :
|
||||
m_position(position),
|
||||
m_drawElevation(0),
|
||||
m_flags(0),
|
||||
m_minimapColorByte(0)
|
||||
m_flags(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -153,19 +152,21 @@ void Tile::removeWalkingCreature(const CreaturePtr& creature)
|
|||
m_walkingCreatures.erase(it);
|
||||
}
|
||||
|
||||
ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||
void Tile::appendThing(const ThingPtr& thing)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||
{
|
||||
if(!thing)
|
||||
return nullptr;
|
||||
return;
|
||||
|
||||
if(EffectPtr effect = thing->asEffect()) {
|
||||
m_effects.push_back(effect);
|
||||
return nullptr;
|
||||
if(thing->isEffect()) {
|
||||
m_effects.push_back(thing->asEffect());
|
||||
return;
|
||||
}
|
||||
|
||||
if(stackPos == 255)
|
||||
stackPos = -1;
|
||||
|
||||
// the items stackpos follows this order:
|
||||
// 0 - ground
|
||||
// 1 - ground borders
|
||||
|
@ -173,7 +174,7 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
|||
// 3 - on top (doors)
|
||||
// 4 - creatures, from top to bottom
|
||||
// 5 - items, from top to bottom
|
||||
if(stackPos < 0) {
|
||||
if(stackPos < 0 || stackPos == 255) {
|
||||
int priority = thing->getStackPriority();
|
||||
bool prepend = (stackPos == -2 || priority <= 3);
|
||||
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
||||
|
@ -184,9 +185,6 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
|||
} else if(stackPos > (int)m_things.size())
|
||||
stackPos = m_things.size();
|
||||
|
||||
ThingPtr oldObject;
|
||||
if(stackPos < (int)m_things.size())
|
||||
oldObject = m_things[stackPos];
|
||||
m_things.insert(m_things.begin() + stackPos, thing);
|
||||
|
||||
if(m_things.size() > MAX_THINGS)
|
||||
|
@ -202,9 +200,6 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
|||
lastPriority = priority;
|
||||
}
|
||||
*/
|
||||
|
||||
update();
|
||||
return oldObject;
|
||||
}
|
||||
|
||||
bool Tile::removeThing(ThingPtr thing)
|
||||
|
@ -228,10 +223,6 @@ bool Tile::removeThing(ThingPtr thing)
|
|||
}
|
||||
}
|
||||
|
||||
// reset values managed by this tile
|
||||
if(removed)
|
||||
update();
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
@ -312,6 +303,19 @@ int Tile::getGroundSpeed()
|
|||
return groundSpeed;
|
||||
}
|
||||
|
||||
uint8 Tile::getMinimapColorByte()
|
||||
{
|
||||
uint8 color = 0;
|
||||
for(const ThingPtr& thing : m_things) {
|
||||
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop())
|
||||
break;
|
||||
uint8 c = thing->getMinimapColor();
|
||||
if(c != 0)
|
||||
color = c;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
ThingPtr Tile::getTopLookThing()
|
||||
{
|
||||
if(isEmpty())
|
||||
|
@ -510,15 +514,3 @@ bool Tile::canErase()
|
|||
{
|
||||
return m_walkingCreatures.empty() && m_effects.empty() && m_things.empty();
|
||||
}
|
||||
|
||||
void Tile::update()
|
||||
{
|
||||
m_minimapColorByte = 0;
|
||||
for(const ThingPtr& thing : m_things) {
|
||||
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop())
|
||||
break;
|
||||
uint8 c = thing->getMinimapColor();
|
||||
if(c != 0)
|
||||
m_minimapColorByte = c;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ public:
|
|||
void addWalkingCreature(const CreaturePtr& creature);
|
||||
void removeWalkingCreature(const CreaturePtr& creature);
|
||||
|
||||
ThingPtr addThing(const ThingPtr& thing, int stackPos);
|
||||
void appendThing(const ThingPtr& thing);
|
||||
void addThing(const ThingPtr& thing, int stackPos);
|
||||
bool removeThing(ThingPtr thing);
|
||||
ThingPtr getThing(int stackPos);
|
||||
EffectPtr getEffect(uint16 id);
|
||||
|
@ -85,7 +86,7 @@ public:
|
|||
const std::vector<ThingPtr>& getThings() { return m_things; }
|
||||
ItemPtr getGround();
|
||||
int getGroundSpeed();
|
||||
uint8 getMinimapColorByte() { return m_minimapColorByte; }
|
||||
uint8 getMinimapColorByte();
|
||||
int getThingCount() { return m_things.size() + m_effects.size(); }
|
||||
bool isPathable();
|
||||
bool isWalkable();
|
||||
|
@ -109,15 +110,12 @@ public:
|
|||
TilePtr asTile() { return std::static_pointer_cast<Tile>(shared_from_this()); }
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
||||
std::vector<CreaturePtr> m_walkingCreatures;
|
||||
std::vector<EffectPtr> m_effects; // leave this outside m_things because it has no stackpos.
|
||||
std::vector<ThingPtr> m_things;
|
||||
Position m_position;
|
||||
uint8 m_drawElevation;
|
||||
uint32 m_flags, m_houseId;
|
||||
uint8 m_minimapColorByte;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
|
Loading…
Reference in New Issue