addons, item count, stackpos fix
This commit is contained in:
parent
10ea2e5de1
commit
9088bad0b0
|
@ -1,8 +1,6 @@
|
|||
#include "creature.h"
|
||||
#include "creature.h"
|
||||
#include "datmanager.h"
|
||||
#include <framework/graphics/graphics.h>
|
||||
#include <framework/graphics/framebuffer.h>
|
||||
#include "game.h"
|
||||
#include <framework/graphics/fontmanager.h>
|
||||
|
||||
Creature::Creature() : Thing(THING_CREATURE)
|
||||
|
@ -13,13 +11,19 @@ Creature::Creature() : Thing(THING_CREATURE)
|
|||
|
||||
void Creature::draw(int x, int y)
|
||||
{
|
||||
//ThingAttributes *creatureAttributes = getAttributes();
|
||||
int anim = 0;
|
||||
|
||||
// draw outfit
|
||||
internalDraw(x, y, 0, m_direction, 0, 0, anim);
|
||||
|
||||
const ThingAttributes& attributes = getAttributes();
|
||||
for(int ydiv = 0; ydiv < attributes.ydiv; ydiv++) {
|
||||
|
||||
// continue if we dont have this addon.
|
||||
if(ydiv > 0 && !(m_outfit.addons & (1 << (ydiv-1))))
|
||||
continue;
|
||||
|
||||
// draw white item
|
||||
internalDraw(x, y, 0, m_direction, ydiv, 0, anim);
|
||||
|
||||
// draw mask if exists
|
||||
if(attributes.blendframes > 1) {
|
||||
g_graphics.bindBlendFunc(BLEND_COLORIZING);
|
||||
|
||||
|
@ -36,12 +40,13 @@ void Creature::draw(int x, int y)
|
|||
outfitColorId = m_outfit.feet;
|
||||
|
||||
g_graphics.bindColor(OutfitColors[outfitColorId]);
|
||||
internalDraw(x, y, 1, m_direction, 0, 0, anim, (SpriteMask)mask);
|
||||
internalDraw(x, y, 1, m_direction, ydiv, 0, anim, (SpriteMask)mask);
|
||||
}
|
||||
|
||||
g_graphics.bindBlendFunc(BLEND_NORMAL);
|
||||
g_graphics.bindColor(Color::white);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::drawInformation(int x, int y, bool useGray)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "item.h"
|
||||
#include "datmanager.h"
|
||||
#include "spritemanager.h"
|
||||
#include <framework/graphics/graphics.h>
|
||||
#include "thing.h"
|
||||
|
||||
Item::Item() : Thing(THING_ITEM)
|
||||
|
@ -15,9 +14,32 @@ void Item::draw(int x, int y)
|
|||
|
||||
int xdiv = 0, ydiv = 0, zdiv = 0, anim = 0;
|
||||
|
||||
if(attributes.group == THING_GROUP_SPLASH || attributes.group == THING_GROUP_FLUID || attributes.stackable) {
|
||||
//cDivX = subType % itemAttributes->xdiv;
|
||||
//cDivY = subType / itemAttributes->xdiv;
|
||||
if(attributes.group == THING_GROUP_SPLASH || attributes.group == THING_GROUP_FLUID) {
|
||||
//xdiv = m_count % attributes.xdiv;
|
||||
//ydiv = m_count / attributes.ydiv;
|
||||
|
||||
}
|
||||
else if(attributes.stackable) {
|
||||
if(m_count < 5) {
|
||||
xdiv = m_count-1;
|
||||
ydiv = 0;
|
||||
}
|
||||
else if(m_count < 10) {
|
||||
xdiv = 0;
|
||||
ydiv = 1;
|
||||
}
|
||||
else if(m_count < 25) {
|
||||
xdiv = 1;
|
||||
ydiv = 1;
|
||||
}
|
||||
else if(m_count < 50) {
|
||||
xdiv = 2;
|
||||
ydiv = 1;
|
||||
}
|
||||
else if(m_count <= 100) {
|
||||
xdiv = 3;
|
||||
ydiv = 1;
|
||||
}
|
||||
}
|
||||
else if(!attributes.moveable) {
|
||||
xdiv = m_position.x % attributes.xdiv;
|
||||
|
|
|
@ -40,7 +40,7 @@ void Map::draw(const Rect& rect)
|
|||
for(int jz = 6; jz >= 0; --jz) {
|
||||
Position coverPos = Position(playerPos.x+(7-jz)-1, playerPos.y+(7-jz)-1, jz);
|
||||
if(const TilePtr& tile = m_tiles[coverPos]) {
|
||||
if(tile->getStackSize() > 0 && jz < playerPos.z) {
|
||||
if(tile->getStackSize(3) > 0 && jz < playerPos.z) {
|
||||
drawFloorStop = jz;
|
||||
break;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void Map::draw(const Rect& rect)
|
|||
}
|
||||
}
|
||||
|
||||
void Map::addThing(ThingPtr thing, uint8 stackpos)
|
||||
void Map::addThing(ThingPtr thing, int stackpos)
|
||||
{
|
||||
if(!thing)
|
||||
return;
|
||||
|
@ -115,7 +115,7 @@ void Map::addThing(ThingPtr thing, uint8 stackpos)
|
|||
m_creatures[thing->getId()] = creature;
|
||||
}
|
||||
|
||||
ThingPtr Map::getThing(const Position& pos, uint8 stackpos)
|
||||
ThingPtr Map::getThing(const Position& pos, int stackpos)
|
||||
{
|
||||
if(const TilePtr& tile = m_tiles[pos]) {
|
||||
return tile->getThing(stackpos);
|
||||
|
@ -123,7 +123,7 @@ ThingPtr Map::getThing(const Position& pos, uint8 stackpos)
|
|||
return ThingPtr();
|
||||
}
|
||||
|
||||
void Map::removeThing(const Position& pos, uint8 stackpos)
|
||||
void Map::removeThing(const Position& pos, int stackpos)
|
||||
{
|
||||
if(TilePtr& tile = m_tiles[pos]) {
|
||||
tile->removeThing(stackpos);
|
||||
|
|
|
@ -10,9 +10,9 @@ class Map
|
|||
public:
|
||||
void draw(const Rect& rect);
|
||||
|
||||
void addThing(ThingPtr thing, uint8 stackpos = 0);
|
||||
ThingPtr getThing(const Position& pos, uint8 stackpos);
|
||||
void removeThing(const Position& pos, uint8 stackpos);
|
||||
void addThing(ThingPtr thing, int stackpos = -1);
|
||||
ThingPtr getThing(const Position& pos, int stackpos);
|
||||
void removeThing(const Position& pos, int stackpos);
|
||||
void removeThingByPtr(ThingPtr thing);
|
||||
|
||||
void clean();
|
||||
|
|
|
@ -72,8 +72,9 @@ void Tile::draw(int x, int y)
|
|||
}
|
||||
}
|
||||
|
||||
void Tile::addThing(ThingPtr thing, uint8 stackpos)
|
||||
void Tile::addThing(ThingPtr thing, int stackpos)
|
||||
{
|
||||
// TODO: rework this. that -1 sucks
|
||||
if(!thing)
|
||||
return;
|
||||
|
||||
|
@ -89,8 +90,13 @@ void Tile::addThing(ThingPtr thing, uint8 stackpos)
|
|||
else {
|
||||
if(thingAttributes.alwaysOnTop)
|
||||
m_itemsTop.push_back(thing);
|
||||
else
|
||||
else {
|
||||
if(stackpos == -1)
|
||||
m_itemsBottom.push_back(thing);
|
||||
else {
|
||||
m_itemsBottom.insert(m_itemsBottom.begin()+(stackpos-getStackSize(2)), thing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(thing->asCreature()) {
|
||||
|
@ -101,7 +107,7 @@ void Tile::addThing(ThingPtr thing, uint8 stackpos)
|
|||
}
|
||||
}
|
||||
|
||||
ThingPtr Tile::getThing(uint8 stackpos)
|
||||
ThingPtr Tile::getThing(unsigned int stackpos)
|
||||
{
|
||||
if(stackpos == 0)
|
||||
return m_ground;
|
||||
|
@ -121,7 +127,7 @@ ThingPtr Tile::getThing(uint8 stackpos)
|
|||
return ThingPtr();
|
||||
}
|
||||
|
||||
void Tile::removeThing(uint8 stackpos)
|
||||
void Tile::removeThing(unsigned int stackpos)
|
||||
{
|
||||
if(stackpos == 0) {
|
||||
m_ground.reset();
|
||||
|
@ -205,13 +211,20 @@ void Tile::clean()
|
|||
m_effects.clear();
|
||||
}
|
||||
|
||||
int Tile::getStackSize()
|
||||
int Tile::getStackSize(int stop)
|
||||
{
|
||||
int ret = 0;
|
||||
if(m_ground)
|
||||
ret++;
|
||||
ret += m_itemsBottom.size();
|
||||
ret += m_creatures.size();
|
||||
int ret = m_ground ? 1 : 0;
|
||||
if(stop == 0)
|
||||
return ret;
|
||||
|
||||
ret += m_itemsTop.size();
|
||||
if(stop == 1)
|
||||
return ret;
|
||||
|
||||
ret += m_creatures.size();
|
||||
if(stop == 2)
|
||||
return ret;
|
||||
|
||||
ret += m_itemsBottom.size();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@ public:
|
|||
|
||||
void draw(int x, int y);
|
||||
|
||||
void addThing(ThingPtr thing, uint8 stackpos);
|
||||
ThingPtr getThing(uint8 stackpos);
|
||||
void removeThing(uint8 stackpos);
|
||||
void addThing(ThingPtr thing, int stackpos);
|
||||
ThingPtr getThing(unsigned int stackpos);
|
||||
void removeThing(unsigned int stackpos);
|
||||
void removeThingByPtr(ThingPtr thing);
|
||||
|
||||
void clean();
|
||||
|
||||
bool hasGround() { return (!!m_ground); }
|
||||
|
||||
int getStackSize();
|
||||
int getStackSize(int stop);
|
||||
|
||||
std::deque<ThingPtr> getCreatures() { return m_creatures; }
|
||||
int getDrawNextOffset() { return m_drawNextOffset; }
|
||||
|
|
|
@ -923,7 +923,7 @@ void ProtocolGame::setTileDescription(InputMessage& msg, Position position)
|
|||
ThingPtr thing = internalGetThing(msg);
|
||||
if(thing)
|
||||
thing->setPosition(position);
|
||||
g_map.addThing(thing, stackpos);
|
||||
g_map.addThing(thing);
|
||||
}
|
||||
stackpos++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue